本文整理汇总了C#中Project.ContainsSymbolsWithNameAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Project.ContainsSymbolsWithNameAsync方法的具体用法?C# Project.ContainsSymbolsWithNameAsync怎么用?C# Project.ContainsSymbolsWithNameAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Project
的用法示例。
在下文中一共展示了Project.ContainsSymbolsWithNameAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindSourceDeclarationsAsync
/// <summary>
/// Find the symbols for declarations made in source with a matching name.
/// </summary>
public static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Project project, Func<string, bool> predicate, SymbolFilter filter, CancellationToken cancellationToken = default(CancellationToken))
{
if (project == null)
{
throw new ArgumentNullException(nameof(project));
}
if (predicate == null)
{
throw new ArgumentNullException(nameof(predicate));
}
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Predicate_FindSourceDeclarationsAsync, cancellationToken))
{
var result = new List<ISymbol>();
if (!await project.ContainsSymbolsWithNameAsync(predicate, filter, cancellationToken).ConfigureAwait(false))
{
return result;
}
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
result.AddRange(FilterByCriteria(compilation.GetSymbolsWithName(predicate, filter, cancellationToken), filter));
return result;
}
}
示例2: AddDeclarationsAsync
private static async Task AddDeclarationsAsync(Project project, Compilation startingCompilation, IAssemblySymbol startingAssembly, string name, bool ignoreCase, SymbolFilter filter, List<ISymbol> list, CancellationToken cancellationToken)
{
Func<string, bool> predicate = n => ignoreCase ? CaseInsensitiveComparison.Comparer.Equals(name, n) : StringComparer.Ordinal.Equals(name, n);
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_AddDeclarationsAsync, cancellationToken))
using (var set = SharedPools.Default<HashSet<ISymbol>>().GetPooledObject())
{
if (!await project.ContainsSymbolsWithNameAsync(predicate, filter, cancellationToken).ConfigureAwait(false))
{
return;
}
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
if ((startingCompilation != null) && (startingAssembly != null) && (compilation.Assembly != startingAssembly))
{
// Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation.
list.AddRange(
FilterByCriteria(compilation.GetSymbolsWithName(predicate, filter, cancellationToken), filter)
.Select(s => s.GetSymbolKey().Resolve(startingCompilation, cancellationToken: cancellationToken).Symbol).WhereNotNull());
}
else
{
list.AddRange(FilterByCriteria(compilation.GetSymbolsWithName(predicate, filter, cancellationToken), filter));
}
}
}
示例3: FindSourceDeclarationsAsync
internal static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken)
{
if (project == null)
{
throw new ArgumentNullException(nameof(project));
}
if (query.Name != null && string.IsNullOrWhiteSpace(query.Name))
{
return SpecializedCollections.EmptyEnumerable<ISymbol>();
}
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Predicate_FindSourceDeclarationsAsync, cancellationToken))
{
var result = new List<ISymbol>();
if (!await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false))
{
return result;
}
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
result.AddRange(FilterByCriteria(compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken), filter));
return result;
}
}
示例4: AddDeclarationsAsync
private static async Task AddDeclarationsAsync(
Project project,
SearchQuery query,
SymbolFilter filter,
List<ISymbol> list,
Compilation startingCompilation,
IAssemblySymbol startingAssembly,
CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_AddDeclarationsAsync, cancellationToken))
using (var set = SharedPools.Default<HashSet<ISymbol>>().GetPooledObject())
{
if (!await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false))
{
return;
}
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
if (startingCompilation != null && startingAssembly != null && compilation.Assembly != startingAssembly)
{
// Return symbols from skeleton assembly in this case so that symbols have the same language as startingCompilation.
list.AddRange(
FilterByCriteria(compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken), filter)
.Select(s => s.GetSymbolKey().Resolve(startingCompilation, cancellationToken: cancellationToken).Symbol).WhereNotNull());
}
else
{
list.AddRange(FilterByCriteria(compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken), filter));
}
}
}
示例5: FindSourceDeclarationsAsync
internal static async Task<ImmutableArray<ISymbol>> FindSourceDeclarationsAsync(
Project project, SearchQuery query, SymbolFilter filter, CancellationToken cancellationToken)
{
if (project == null)
{
throw new ArgumentNullException(nameof(project));
}
if (query.Name != null && string.IsNullOrWhiteSpace(query.Name))
{
return ImmutableArray<ISymbol>.Empty;
}
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Predicate_FindSourceDeclarationsAsync, cancellationToken))
{
if (!await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false))
{
return ImmutableArray<ISymbol>.Empty;
}
var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
var unfiltered = compilation.GetSymbolsWithName(query.GetPredicate(), filter, cancellationToken).ToImmutableArray();
return FilterByCriteria(unfiltered, filter);
}
}
示例6: AddDeclarationsAsync
private static async Task AddDeclarationsAsync(
Project project,
SearchQuery query,
SymbolFilter filter,
ArrayBuilder<ISymbol> list,
Compilation startingCompilation,
IAssemblySymbol startingAssembly,
CancellationToken cancellationToken)
{
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_AddDeclarationsAsync, cancellationToken))
{
if (!await project.ContainsSymbolsWithNameAsync(query.GetPredicate(), filter, cancellationToken).ConfigureAwait(false))
{
return;
}
var unfilteredSymbols = await GetUnfilteredSymbolsAsync(
project, query, filter, startingCompilation, startingAssembly, cancellationToken).ConfigureAwait(false);
list.AddRange(FilterByCriteria(unfilteredSymbols, filter));
}
}