Skip to content

Commit

Permalink
Merge pull request #75721 from dibarbet/fix_analyzer_completion_provi…
Browse files Browse the repository at this point in the history
…ders

Also check if reference is isolated file reference for completion providers
  • Loading branch information
dibarbet authored Nov 5, 2024
2 parents 9dcb2a3 + ea665d3 commit 0d31e5d
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ private ImmutableArray<TExtension> CreateExtensions(string language)
if (TryGetExtensionsFromReference(this.Reference, out var extensions))
return extensions;

var analyzerFileReference = GetAnalyzerFileReference(this.Reference);

// otherwise, see whether we can pick it up from reference itself
if (this.Reference is not AnalyzerFileReference analyzerFileReference)
if (analyzerFileReference is null)
return [];

using var _ = ArrayBuilder<TExtension>.GetInstance(out var builder);
Expand Down Expand Up @@ -183,5 +185,17 @@ private ImmutableArray<TExtension> CreateExtensions(string language)
}

return builder.ToImmutableAndClear();

static AnalyzerFileReference? GetAnalyzerFileReference(AnalyzerReference reference)
{
if (reference is AnalyzerFileReference analyzerFileReference)
return analyzerFileReference;
#if NET
if (reference is IsolatedAnalyzerFileReference isolatedReference)
return isolatedReference.UnderlyingAnalyzerFileReference;
#endif

return null;
}
}
}

0 comments on commit 0d31e5d

Please sign in to comment.