Skip to content

Commit e260ae6

Browse files
MaStr11sharwell
authored andcommitted
Support GotoDefinition in LINQ query syntax (#23049)
* Initial support for GotoDefinition in LINQ query syntax. * Fixed naming issues. * Fixed failing tests. * Added support for Cast<> in from clause. Removed support for degenerated select clause. Reverted changes causing regressions. * Added support for tokens to distinguish which MethodSymbol to return for a SyntaxNode that binds to more than one method. This adds support for range variable types and orderby. * Fixed regression. Suppressed quick-info for degenerated query expressions. * Added quick info tests according to the proposal. * Added test for GotoDefinition. Moved logic for degenerated clauses to deeper layer. * Added GotoDefinition for let test. * Added test for incomplete orderby clause * Code refactorings (Review feedback). * PR feedback (nits) * PR feedback (code comments). * Revert changes in compiler. * Revert changes in compiler (2). * Added test for single from clause with out cast. * Removed call to GetLanguageService and ValueTuple.Create * Unify to return default; * Corrected ISyntaxFactsService.IsQueryKeyword for VB and C#
1 parent 95cd555 commit e260ae6

File tree

10 files changed

+1582
-26
lines changed

10 files changed

+1582
-26
lines changed

src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs

Lines changed: 514 additions & 3 deletions
Large diffs are not rendered by default.

src/EditorFeatures/Core/Implementation/IntelliSense/QuickInfo/Providers/AbstractSemanticQuickInfoProvider.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,10 @@ private async Task<ValueTuple<SemanticModel, ImmutableArray<ISymbol>>> BindToken
280280
SyntaxToken token,
281281
CancellationToken cancellationToken)
282282
{
283+
var syntaxFacts = document.Project.LanguageServices.GetService<ISyntaxFactsService>();
283284
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
284285
var enclosingType = semanticModel.GetEnclosingNamedType(token.SpanStart, cancellationToken);
285286

286-
var syntaxFacts = document.Project.LanguageServices.GetService<ISyntaxFactsService>();
287-
288287
ImmutableArray<ISymbol> symbols;
289288
if (GetBindableNodeForTokenIndicatingLambda(token, out SyntaxNode lambdaSyntax))
290289
{
@@ -296,7 +295,7 @@ private async Task<ValueTuple<SemanticModel, ImmutableArray<ISymbol>>> BindToken
296295
.GetSymbols(includeType: true);
297296
}
298297

299-
var bindableParent = document.GetLanguageService<ISyntaxFactsService>().GetBindableParent(token);
298+
var bindableParent = syntaxFacts.GetBindableParent(token);
300299
var overloads = semanticModel.GetMemberGroup(bindableParent, cancellationToken);
301300

302301
symbols = symbols.Where(IsOk)
@@ -307,12 +306,8 @@ private async Task<ValueTuple<SemanticModel, ImmutableArray<ISymbol>>> BindToken
307306

308307
if (symbols.Any())
309308
{
310-
var typeParameter = symbols.First() as ITypeParameterSymbol;
311-
return ValueTuple.Create(
312-
semanticModel,
313-
typeParameter != null && typeParameter.TypeParameterKind == TypeParameterKind.Cref
314-
? ImmutableArray<ISymbol>.Empty
315-
: symbols);
309+
var discardSymbols = (symbols.First() as ITypeParameterSymbol)?.TypeParameterKind == TypeParameterKind.Cref;
310+
return (semanticModel, discardSymbols ? ImmutableArray<ISymbol>.Empty : symbols);
316311
}
317312

318313
// Couldn't bind the token to specific symbols. If it's an operator, see if we can at
@@ -322,12 +317,11 @@ private async Task<ValueTuple<SemanticModel, ImmutableArray<ISymbol>>> BindToken
322317
var typeInfo = semanticModel.GetTypeInfo(token.Parent, cancellationToken);
323318
if (IsOk(typeInfo.Type))
324319
{
325-
return ValueTuple.Create(semanticModel,
326-
ImmutableArray.Create<ISymbol>(typeInfo.Type));
320+
return (semanticModel, ImmutableArray.Create<ISymbol>(typeInfo.Type));
327321
}
328322
}
329323

330-
return ValueTuple.Create(semanticModel, ImmutableArray<ISymbol>.Empty);
324+
return (semanticModel, ImmutableArray<ISymbol>.Empty);
331325
}
332326

333327
private static bool IsOk(ISymbol symbol)

0 commit comments

Comments
 (0)