本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxNode.GetNameAndArityOfSimpleName方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNode.GetNameAndArityOfSimpleName方法的具体用法?C# SyntaxNode.GetNameAndArityOfSimpleName怎么用?C# SyntaxNode.GetNameAndArityOfSimpleName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.SyntaxNode
的用法示例。
在下文中一共展示了SyntaxNode.GetNameAndArityOfSimpleName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMatchingNamespacesAsync
internal async Task<IEnumerable<ISymbol>> GetMatchingNamespacesAsync(
Microsoft.CodeAnalysis.Project project,
SemanticModel semanticModel,
SyntaxNode simpleName,
CancellationToken cancellationToken)
{
if (simpleName.IsAttributeName())
{
return null;
}
string name;
int arity;
simpleName.GetNameAndArityOfSimpleName(out name, out arity);
if (cancellationToken.IsCancellationRequested)
{
return null;
}
var symbols = await SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Namespace, cancellationToken).ConfigureAwait(false);
var namespaces = symbols
.OfType<INamespaceSymbol>()
.Where(n => !n.IsGlobalNamespace &&
HasAccessibleTypes(n, semanticModel, cancellationToken));
return namespaces;
}
示例2: GetMatchingTypesAsync
internal async Task<IEnumerable<ISymbol>> GetMatchingTypesAsync(
Microsoft.CodeAnalysis.Project project, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
{
// Can't be on the right hand side of binary expression (like 'dot').
cancellationToken.ThrowIfCancellationRequested();
string name;
int arity;
node.GetNameAndArityOfSimpleName(out name, out arity);
var symbols = await SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Type, cancellationToken).ConfigureAwait(false);
// also lookup type symbols with the "Attribute" suffix.
var inAttributeContext = node.IsAttributeName();
if (inAttributeContext)
{
symbols = symbols.Concat(
await SymbolFinder.FindDeclarationsAsync(project, name + "Attribute", this.IgnoreCase, SymbolFilter.Type, cancellationToken).ConfigureAwait(false));
}
var accessibleTypeSymbols = symbols
.OfType<INamedTypeSymbol>()
.Where(s => (arity == 0 || s.GetArity() == arity)
&& s.IsAccessibleWithin(semanticModel.Compilation.Assembly)
&& (!inAttributeContext || s.IsAttribute())
&& HasValidContainer(s))
.ToList();
return accessibleTypeSymbols;
}
示例3: CalculateContext
private static void CalculateContext(SyntaxNode node, out string name, out int arity, out bool inAttributeContext, out bool hasIncompleteParentMember)
{
// Has to be a simple identifier or generic name.
node.GetNameAndArityOfSimpleName(out name, out arity);
inAttributeContext = node.IsAttributeName();
hasIncompleteParentMember = node.HasIncompleteParentMember();
}
示例4: GetAddMethodsAsync
private async Task<IEnumerable<IMethodSymbol>> GetAddMethodsAsync(
Microsoft.CodeAnalysis.Project project,
Diagnostic diagnostic,
SyntaxNode node,
SemanticModel semanticModel,
ISet<INamespaceSymbol> namespacesInScope,
SyntaxNode expression,
CancellationToken cancellationToken)
{
string name;
int arity;
node.GetNameAndArityOfSimpleName(out name, out arity);
if (name != null)
{
return SpecializedCollections.EmptyEnumerable<IMethodSymbol>();
}
if (IsAddMethodContext(node, semanticModel))
{
var symbols = await SymbolFinder.FindDeclarationsAsync(project, "Add", this.IgnoreCase, SymbolFilter.Member, cancellationToken).ConfigureAwait(false);
return symbols
.OfType<IMethodSymbol>()
.Where(method => method.IsExtensionMethod &&
method.ContainingType?.IsAccessibleWithin(semanticModel.Compilation.Assembly) == true &&
IsViableExtensionMethod(method, expression, semanticModel, cancellationToken));
}
return SpecializedCollections.EmptyEnumerable<IMethodSymbol>();
}
示例5: GetSymbolsAsync
private Task<IEnumerable<ISymbol>> GetSymbolsAsync(
Microsoft.CodeAnalysis.Project project,
SyntaxNode node,
SemanticModel semanticModel,
CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
// See if the name binds. If it does, there's nothing further we need to do.
if (ExpressionBinds(node, semanticModel, cancellationToken, checkForExtensionMethods: true))
{
return Task.FromResult (Enumerable.Empty<ISymbol>());
}
string name;
int arity;
node.GetNameAndArityOfSimpleName(out name, out arity);
if (name == null)
{
return Task.FromResult (Enumerable.Empty<ISymbol>());
}
return SymbolFinder.FindDeclarationsAsync(project, name, this.IgnoreCase, SymbolFilter.Member, cancellationToken);
}
示例6: GetNamespacesForMatchingNamespacesAsync
private async Task<IEnumerable<INamespaceSymbol>> GetNamespacesForMatchingNamespacesAsync(
Microsoft.CodeAnalysis.Project project,
Diagnostic diagnostic,
SyntaxNode node,
SemanticModel semanticModel,
ISet<INamespaceSymbol> namespacesInScope,
CancellationToken cancellationToken)
{
if (!this.CanAddImportForNamespace(diagnostic, ref node))
{
return null;
}
string name;
int arity;
node.GetNameAndArityOfSimpleName(out name, out arity);
if (ExpressionBinds(node, semanticModel, cancellationToken))
{
return null;
}
var symbols = await SymbolFinder.FindDeclarationsAsync(
project, name, this.IgnoreCase, SymbolFilter.Namespace, cancellationToken).ConfigureAwait(false);
return GetProposedNamespaces(
symbols.OfType<INamespaceSymbol>().Select(n => n.ContainingNamespace),
semanticModel,
namespacesInScope);
}