-
Notifications
You must be signed in to change notification settings - Fork 4k
/
SymbolFinder_Declarations_SourceDeclarations.cs
121 lines (106 loc) · 6.89 KB
/
SymbolFinder_Declarations_SourceDeclarations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Internal.Log;
namespace Microsoft.CodeAnalysis.FindSymbols
{
// All the logic for finding source declarations in a given solution/project with some name
// is in this file.
public static partial class SymbolFinder
{
/// <summary>
/// Find the symbols for declarations made in source with the specified name.
/// </summary>
public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Solution solution, string name, bool ignoreCase, CancellationToken cancellationToken = default)
=> FindSourceDeclarationsAsync(solution, name, ignoreCase, SymbolFilter.All, cancellationToken);
/// <summary>
/// Find the symbols for declarations made in source with the specified name.
/// </summary>
public static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(
Solution solution, string name, bool ignoreCase, SymbolFilter filter, CancellationToken cancellationToken = default)
{
using (Logger.LogBlock(FunctionId.SymbolFinder_Solution_Name_FindSourceDeclarationsAsync, cancellationToken))
{
var declarations = await DeclarationFinder.FindSourceDeclarationsWithNormalQueryAsync(
solution, name, ignoreCase, filter, cancellationToken).ConfigureAwait(false);
return declarations;
}
}
/// <summary>
/// Find the symbols for declarations made in source with the specified name.
/// </summary>
public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(Project project, string name, bool ignoreCase, CancellationToken cancellationToken = default)
=> FindSourceDeclarationsAsync(project, name, ignoreCase, SymbolFilter.All, cancellationToken);
/// <summary>
/// Find the symbols for declarations made in source with the specified name.
/// </summary>
public static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsAsync(
Project project, string name, bool ignoreCase, SymbolFilter filter, CancellationToken cancellationToken = default)
{
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Name_FindSourceDeclarationsAsync, cancellationToken))
{
var declarations = await DeclarationFinder.FindSourceDeclarationsWithNormalQueryAsync(
project, name, ignoreCase, filter, cancellationToken).ConfigureAwait(false);
return declarations;
}
}
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
/// <summary>
/// Find the symbols for declarations made in source with the specified pattern. This pattern is matched
/// using heuristics that may change from release to release. So, the set of symbols matched by a given
/// pattern may change between releases. For example, new symbols may be matched by a pattern and/or
/// symbols previously matched by a pattern no longer are. However, the set of symbols matched by a
/// specific release will be consistent for a specific pattern.
/// </summary>
public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsWithPatternAsync(Solution solution, string pattern, CancellationToken cancellationToken = default)
=> FindSourceDeclarationsWithPatternAsync(solution, pattern, SymbolFilter.All, cancellationToken);
/// <summary>
/// Find the symbols for declarations made in source with the specified pattern. This pattern is matched
/// using heuristics that may change from release to release. So, the set of symbols matched by a given
/// pattern may change between releases. For example, new symbols may be matched by a pattern and/or
/// symbols previously matched by a pattern no longer are. However, the set of symbols matched by a
/// specific release will be consistent for a specific pattern.
/// </summary>
public static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsWithPatternAsync(
Solution solution, string pattern, SymbolFilter filter, CancellationToken cancellationToken = default)
{
using (Logger.LogBlock(FunctionId.SymbolFinder_Solution_Pattern_FindSourceDeclarationsAsync, cancellationToken))
{
var declarations = await DeclarationFinder.FindSourceDeclarationsWithPatternAsync(
solution, pattern, filter, cancellationToken).ConfigureAwait(false);
return declarations;
}
}
/// <summary>
/// Find the symbols for declarations made in source with the specified pattern. This pattern is matched
/// using heuristics that may change from release to release. So, the set of symbols matched by a given
/// pattern may change between releases. For example, new symbols may be matched by a pattern and/or
/// symbols previously matched by a pattern no longer are. However, the set of symbols matched by a
/// specific release will be consistent for a specific pattern.
/// </summary>
public static Task<IEnumerable<ISymbol>> FindSourceDeclarationsWithPatternAsync(Project project, string pattern, CancellationToken cancellationToken = default)
=> FindSourceDeclarationsWithPatternAsync(project, pattern, SymbolFilter.All, cancellationToken);
/// <summary>
/// Find the symbols for declarations made in source with the specified pattern. This pattern is matched
/// using heuristics that may change from release to release. So, the set of symbols matched by a given
/// pattern may change between releases. For example, new symbols may be matched by a pattern and/or
/// symbols previously matched by a pattern no longer are. However, the set of symbols matched by a
/// specific release will be consistent for a specific pattern.
/// </summary>
public static async Task<IEnumerable<ISymbol>> FindSourceDeclarationsWithPatternAsync(
Project project, string pattern, SymbolFilter filter, CancellationToken cancellationToken = default)
{
using (Logger.LogBlock(FunctionId.SymbolFinder_Project_Pattern_FindSourceDeclarationsAsync, cancellationToken))
{
var declarations = await DeclarationFinder.FindSourceDeclarationsWithPatternAsync(
project, pattern, filter, cancellationToken).ConfigureAwait(false);
return declarations;
}
}
#pragma warning restore RS0026
}
}