提交 17a9a685 编写于 作者: D David Barbet

Rename filter to descendInto to better convey its meaning.

上级 64be2a31
......@@ -221,7 +221,6 @@ private Glyph GetGlyph(SymbolKind kind, Accessibility? declaredAccessibility)
var rules = await document.GetNamingRulesAsync(FallbackNamingRules.CompletionOfferingRules, cancellationToken).ConfigureAwait(false);
var result = new Dictionary<string, SymbolKind>();
var semanticFactsService = context.GetLanguageService<ISemanticFactsService>();
var syntaxFactsService = context.GetLanguageService<ISyntaxFactsService>();
foreach (var kind in declarationInfo.PossibleSymbolKinds)
{
......@@ -245,7 +244,7 @@ private Glyph GetGlyph(SymbolKind kind, Accessibility? declaredAccessibility)
var targetToken = context.TargetToken;
var uniqueName = semanticFactsService.GenerateUniqueName(
context.SemanticModel,
targetToken.Parent,
context.TargetToken.Parent,
containerOpt: null,
baseName: name,
filter: IsRelevantSymbolKind,
......
......@@ -33,12 +33,12 @@ protected override IEnumerable<ISymbol> GetUsedSymbols(SemanticModel semanticMod
// Some symbols in the enclosing block could cause conflicts even if they are not available at the location.
// E.g. symbols inside if statements / try catch statements.
// Walk through the enclosing block to find them, but make sure to exclude local functions because
// a) Visible local function symbols would be returned from LookupSymbols (e.g. location is inside a local function).
// b) Local function symbols are only in scope inside the local function.
// Relevant ones (e.g. method name) would be returned by a).
// Walk through the enclosing block to find them, but avoid exploring local functions because
// a) Visible local function symbols would be returned from LookupSymbols
// (e.g. location is inside a local function or the local function method name).
// b) Local function symbols are not affected by outer variables and do not contribute to the outer scope.
var symbolsInBlock = semanticModel.GetExistingSymbols(container, cancellationToken,
filter: (SyntaxNode n) => !n.IsKind(SyntaxKind.LocalFunctionStatement));
descendInto: n => !n.IsKind(SyntaxKind.LocalFunctionStatement));
return symbolsInBlock.Concat(visibleSymbols);
}
......
......@@ -234,17 +234,17 @@ public static SemanticModel GetOriginalSemanticModel(this SemanticModel semantic
}
public static IEnumerable<ISymbol> GetExistingSymbols(
this SemanticModel semanticModel, SyntaxNode container, CancellationToken cancellationToken, Func<SyntaxNode, bool> filter = null)
this SemanticModel semanticModel, SyntaxNode container, CancellationToken cancellationToken, Func<SyntaxNode, bool> descendInto = null)
{
// Ignore an anonymous type property or tuple field. It's ok if they have a name that
// matches the name of the local we're introducing.
return semanticModel.GetAllDeclaredSymbols(container, cancellationToken, filter)
return semanticModel.GetAllDeclaredSymbols(container, cancellationToken, descendInto)
.Where(s => !s.IsAnonymousTypeProperty() && !s.IsTupleField());
}
private static void GetAllDeclaredSymbols(
SemanticModel semanticModel, SyntaxNode node,
HashSet<ISymbol> symbols, CancellationToken cancellationToken, Func<SyntaxNode, bool> filter = null)
HashSet<ISymbol> symbols, CancellationToken cancellationToken, Func<SyntaxNode, bool> descendInto = null)
{
var symbol = semanticModel.GetDeclaredSymbol(node, cancellationToken);
......@@ -258,14 +258,14 @@ public static SemanticModel GetOriginalSemanticModel(this SemanticModel semantic
if (child.IsNode)
{
var childNode = child.AsNode();
if (ApplyFilter(childNode, filter))
if (ShouldDescendInto(childNode, descendInto))
{
GetAllDeclaredSymbols(semanticModel, child.AsNode(), symbols, cancellationToken, filter);
GetAllDeclaredSymbols(semanticModel, child.AsNode(), symbols, cancellationToken, descendInto);
}
}
}
static bool ApplyFilter(SyntaxNode node, Func<SyntaxNode, bool> filter)
static bool ShouldDescendInto(SyntaxNode node, Func<SyntaxNode, bool> filter)
=> filter != null ? filter(node) : true;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册