src\Analyzers\Core\Analyzers\AddAccessibilityModifiers\IAddAccessibilityModifiersService.cs (1)
19SyntaxNode member,
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (19)
49protected abstract bool ContainsPragmaDirective(SyntaxNode root);
127var root = tree.GetRoot(cancellationToken);
166using var _5 = PooledDictionary<string, List<SyntaxNode>>.GetInstance(out var idToSuppressMessageAttributesMap);
167using var _6 = PooledDictionary<SyntaxNode, bool>.GetInstance(out var suppressMessageAttributesToIsUsedMap);
210foreach (var attributeNode in attributeNodes)
226SyntaxNode root,
297SyntaxNode idNode,
391SyntaxNode root,
512PooledDictionary<string, List<SyntaxNode>> idToSuppressMessageAttributesMap,
513PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
586PooledDictionary<string, List<SyntaxNode>> idToSuppressMessageAttributesMap,
587PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
596var attributeNode = await attribute.ApplicationSyntaxReference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
597foreach (var node in suppressMessageAttributesForId)
611PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
663PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
733SyntaxNode root,
736PooledDictionary<string, List<SyntaxNode>> idToSuppressMessageAttributesMap,
737PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
src\Analyzers\Core\Analyzers\SimplifyTypeNames\SimplifyTypeNamesDiagnosticAnalyzerBase.cs (8)
78internal abstract bool IsCandidate(SyntaxNode node);
80SemanticModel model, SyntaxNode node, TSimplifierOptions options,
110protected abstract bool IsIgnoredCodeBlock(SyntaxNode codeBlock);
111protected abstract ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context, SyntaxNode root);
112protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanMutableIntervalTree? codeBlockIntervalTree);
114public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, AnalyzerOptions analyzerOptions, CancellationToken cancellationToken)
237var root = context.GetAnalysisRoot(findInTrivia: true);
293var root = context.GetAnalysisRoot(findInTrivia: true);
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (27)
33where TPropertyDeclaration : SyntaxNode
34where TConstructorDeclaration : SyntaxNode
35where TFieldDeclaration : SyntaxNode
36where TVariableDeclarator : SyntaxNode
37where TExpression : SyntaxNode
44private static readonly ObjectPool<ConcurrentSet<SyntaxNode>> s_nodeSetPool = new(() => []);
46private static readonly ObjectPool<ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>>> s_fieldToUsageLocationPool = new(() => []);
63protected static void AddFieldUsage(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, IFieldSymbol field, SyntaxNode location)
66private static void ClearAndFree(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> multiMap)
98protected abstract SyntaxNode GetFieldNode(TFieldDeclaration fieldDeclaration, TVariableDeclarator variableDeclarator);
103HashSet<string> fieldNames, ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, SemanticModel semanticModel, SyntaxNode codeBlock, CancellationToken cancellationToken);
209var analysisRoot = context.GetAnalysisRoot(findInTrivia: false);
210foreach (var node in analysisRoot.DescendantNodes())
219if (!shouldAnalyze && analysisRoot.FirstAncestorOrSelf<SyntaxNode>(node => node is TPropertyDeclaration or TFieldDeclaration) == null)
229ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads,
230ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites,
232SyntaxNode codeBlock,
539ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty,
540ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads,
541ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites,
626static bool NotWithinProperty(IEnumerable<SyntaxNode> nodes, TPropertyDeclaration propertyDeclaration)
628foreach (var node in nodes)
637static IEnumerable<SyntaxNode> NonConstructorLocations(IEnumerable<SyntaxNode> nodes)
644var fieldNode = GetFieldNode(result.FieldDeclaration, variableDeclarator);
src\Analyzers\Core\Analyzers\UseCompoundAssignment\UseCompoundAssignmentUtilities.cs (7)
41ISyntaxFacts syntaxFacts, SyntaxNode expr, SemanticModel semanticModel, CancellationToken cancellationToken)
47ISyntaxFacts syntaxFacts, SyntaxNode expr, SemanticModel semanticModel,
74out _, out var expression, out _);
82out var subExpr, out _);
90out var expression, out var whenNotNull);
100SyntaxNode expr, SemanticModel semanticModel, bool isTopLevel, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (10)
150public static SyntaxNode GetAnalysisRoot(this SyntaxTreeAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
156public static SyntaxNode GetAnalysisRoot(this SemanticModelAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
164public static SyntaxNode GetAnalysisRoot(this SymbolStartAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
176public static SyntaxNode GetAnalysisRoot(this SymbolAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
186public static SyntaxNode GetAnalysisRoot(this OperationBlockStartAnalysisContext context, IOperation operationBlock, bool findInTrivia, bool getInnermostNodeForTie = false)
192public static SyntaxNode GetAnalysisRoot(this OperationBlockAnalysisContext context, IOperation operationBlock, bool findInTrivia, bool getInnermostNodeForTie = false)
198public static SyntaxNode GetAnalysisRoot(this OperationAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
204public static SyntaxNode GetAnalysisRoot(this SyntaxNodeAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
210public static SyntaxNode GetAnalysisRoot<TSyntaxKind>(this CodeBlockStartAnalysisContext<TSyntaxKind> context, bool findInTrivia, bool getInnermostNodeForTie = false) where TSyntaxKind : struct
216public static SyntaxNode GetAnalysisRoot(this CodeBlockAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SemanticModelExtensions.cs (18)
35public static DataFlowAnalysis AnalyzeRequiredDataFlow(this SemanticModel semanticModel, SyntaxNode statementOrExpression)
38public static DataFlowAnalysis AnalyzeRequiredDataFlow(this SemanticModel semanticModel, SyntaxNode firstStatement, SyntaxNode lastStatement)
41public static ControlFlowAnalysis AnalyzeRequiredControlFlow(this SemanticModel semanticModel, SyntaxNode statement)
44public static ControlFlowAnalysis AnalyzeRequiredControlFlow(this SemanticModel semanticModel, SyntaxNode firstStatement, SyntaxNode lastStatement)
47public static ISymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel, SyntaxNode declaration, CancellationToken cancellationToken)
53public static IOperation GetRequiredOperation(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
94this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func<SyntaxNode, bool>? descendInto = null)
116this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func<SyntaxNode, bool>? filter = null)
128SemanticModel semanticModel, SyntaxNode node,
129HashSet<ISymbol> symbols, CancellationToken cancellationToken, Func<SyntaxNode, bool>? descendInto = null)
140if (child.AsNode(out var childNode) &&
147static bool ShouldDescendInto(SyntaxNode node, Func<SyntaxNode, bool>? filter)
233SyntaxNode expression,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (111)
23public static SyntaxNode GetRequiredParent(this SyntaxNode node)
26public static IEnumerable<SyntaxNodeOrToken> DepthFirstTraversal(this SyntaxNode node)
29public static IEnumerable<SyntaxNode> DepthFirstTraversalNodes(this SyntaxNode node)
32public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxNode node)
34var current = node.Parent;
44public static IEnumerable<TNode> GetAncestors<TNode>(this SyntaxNode node)
45where TNode : SyntaxNode
47var current = node.Parent;
59public static TNode? GetAncestor<TNode>(this SyntaxNode node)
60where TNode : SyntaxNode
62var current = node.Parent;
76public static TNode? GetAncestorOrThis<TNode>(this SyntaxNode? node)
77where TNode : SyntaxNode
82public static IEnumerable<TNode> GetAncestorsOrThis<TNode>(this SyntaxNode? node)
83where TNode : SyntaxNode
85var current = node;
97public static bool HasAncestor<TNode>(this SyntaxNode node)
98where TNode : SyntaxNode
104this SyntaxNode node, TextSpan searchSpan, Func<SyntaxNode, bool> predicate)
105where TSyntaxNode : SyntaxNode
109var nodes = new LinkedList<SyntaxNode>();
114var currentNode = nodes.First!.Value;
129public static bool CheckParent<T>([NotNullWhen(returnValue: true)] this SyntaxNode? node, Func<T, bool> valueChecker) where T : SyntaxNode
145public static bool IsChildNode<TParent>(this SyntaxNode node, Func<TParent, SyntaxNode?> childGetter)
146where TParent : SyntaxNode
154var ancestorNode = childGetter(ancestor);
162public static bool IsFoundUnder<TParent>(this SyntaxNode node, Func<TParent, SyntaxNode?> childGetter)
163where TParent : SyntaxNode
171var child = childGetter(ancestor);
174return node.GetAncestorsOrThis<SyntaxNode>().Contains(child);
177public static SyntaxNode GetCommonRoot(this SyntaxNode node1, SyntaxNode node2)
183using var _ = PooledHashSet<SyntaxNode>.GetInstance(out var set);
184set.AddRange(node2.GetAncestorsOrThis<SyntaxNode>());
186foreach (var ancestor in node1.AncestorsAndSelf())
195public static int Width(this SyntaxNode node)
198public static int FullWidth(this SyntaxNode node)
201public static SyntaxNode? FindInnermostCommonNode(this IEnumerable<SyntaxNode> nodes, Func<SyntaxNode, bool> predicate)
204public static SyntaxNode? FindInnermostCommonNode(this IEnumerable<SyntaxNode> nodes)
214using var _1 = ArrayBuilder<SyntaxNode>.GetInstance(out var commonAncestorsStack);
215using var _2 = PooledHashSet<SyntaxNode>.GetInstance(out var commonAncestorsSet);
218foreach (var node in nodes)
239var commonAncestor = FindCommonAncestor(node, commonAncestorsSet);
281static SyntaxNode? FindCommonAncestor(SyntaxNode node, HashSet<SyntaxNode> commonAncestorsSet)
293public static TSyntaxNode? FindInnermostCommonNode<TSyntaxNode>(this IEnumerable<SyntaxNode> nodes) where TSyntaxNode : SyntaxNode
296public static TextSpan GetContainedSpan(this IEnumerable<SyntaxNode> nodes)
302foreach (var node in nodes)
312public static bool OverlapsHiddenPosition(this SyntaxNode node, CancellationToken cancellationToken)
315public static bool OverlapsHiddenPosition(this SyntaxNode node, TextSpan span, CancellationToken cancellationToken)
318public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNode startNode, SyntaxNode endNode, CancellationToken cancellationToken)
327public static IEnumerable<T> GetAnnotatedNodes<T>(this SyntaxNode node, SyntaxAnnotation syntaxAnnotation) where T : SyntaxNode
341IEnumerable<SyntaxNode> nodes,
342Func<SyntaxNode, SyntaxNode, CancellationToken, Task<SyntaxNode>> computeReplacementAsync,
343CancellationToken cancellationToken) where TRootNode : SyntaxNode
365CancellationToken cancellationToken) where TRootNode : SyntaxNode
378CancellationToken cancellationToken) where TRoot : SyntaxNode
389IEnumerable<SyntaxNode>? nodes,
390Func<SyntaxNode, SyntaxNode, CancellationToken, Task<SyntaxNode>>? computeReplacementNodeAsync,
396where TRoot : SyntaxNode
403var nodeReplacements = new Dictionary<SyntaxNode, SyntaxNode>();
441var original = (SyntaxNode?)retryAnnotations.GetAnnotations(currentNode).SingleOrDefault() ?? currentNode;
472if (rewritten != original || !nodeReplacements.TryGetValue(original, out var replaced))
598SyntaxNode root,
614this SyntaxNode root,
653this SyntaxNode root,
690params SyntaxTrivia[] trivia) where T : SyntaxNode
702SyntaxTriviaList trivia) where T : SyntaxNode
714IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode
724params SyntaxTrivia[] trivia) where T : SyntaxNode
736SyntaxTriviaList trivia) where T : SyntaxNode
748IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode
759IEnumerable<SyntaxTrivia> trailingTrivia) where T : SyntaxNode
784public static SyntaxNode FindNode(this SyntaxNode root, TextSpan? span, bool findInTrivia, bool getInnermostNodeForTie)
792public static SyntaxNode? GetParent(this SyntaxNode node, bool ascendOutOfTrivia)
794var parent = node.Parent;
806public static TNode? FirstAncestorOrSelfUntil<TNode>(this SyntaxNode? node, Func<SyntaxNode, bool> predicate)
807where TNode : SyntaxNode
809for (var current = node; current != null; current = current.GetParent(ascendOutOfTrivia: true))
826SyntaxNode root,
829where TDirectiveTriviaSyntax : SyntaxNode
835where TDirectiveTriviaSyntax : SyntaxNode
855SyntaxNode root,
946public static ValueAncestorsAndSelfEnumerable ValueAncestorsAndSelf(this SyntaxNode syntaxNode, bool ascendOutOfTrivia = true)
949public readonly struct ValueAncestorsAndSelfEnumerable(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
954public struct Enumerator(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
956public SyntaxNode Current { get; private set; } = null!;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (12)
15public static SyntaxNode? GetAncestor(this SyntaxToken token, Func<SyntaxNode, bool>? predicate)
16=> token.GetAncestor<SyntaxNode>(predicate);
18public static T? GetAncestor<T>(this SyntaxToken token, Func<T, bool>? predicate = null) where T : SyntaxNode
21public static T GetRequiredAncestor<T>(this SyntaxToken token, Func<T, bool>? predicate = null) where T : SyntaxNode
25where T : SyntaxNode
32public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxToken token, Func<SyntaxNode, bool> predicate)
39public static SyntaxNode? GetCommonRoot(this SyntaxToken token1, SyntaxToken token2)
53public static bool CheckParent<T>(this SyntaxToken token, Func<T, bool> valueChecker) where T : SyntaxNode
69public static SyntaxToken FindTokenFromEnd(this SyntaxNode root, int position, bool includeZeroWidth = true, bool findInsideTrivia = false)
164public static SyntaxNode GetRequiredParent(this SyntaxToken token)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\AbstractSyntaxFormatting.cs (3)
28protected abstract IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList<AbstractFormattingResult> results, TextSpanMutableIntervalTree? formattingSpans = null);
30protected abstract AbstractFormattingResult Format(SyntaxNode node, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken);
32public IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan>? spans, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\BaseIndentationFormattingRule.cs (7)
19private readonly SyntaxNode? _commonNode;
22public BaseIndentationFormattingRule(SyntaxNode root, TextSpan span, int baseIndentation, AbstractFormattingRule? vbHelperFormattingRule = null)
31public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
54private void AddNextIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
133private static void SetInnermostNodeForSpan(SyntaxNode root, ref TextSpan span, out SyntaxToken token1, out SyntaxToken token2, out SyntaxNode? commonNode)
149private static void GetTokens(SyntaxNode root, TextSpan span, out SyntaxToken token1, out SyntaxToken token2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\CompatAbstractFormattingRule.cs (8)
17public sealed override void AddSuppressOperations(ArrayBuilder<SuppressOperation> list, SyntaxNode node, in NextSuppressOperationAction nextOperation)
25public sealed override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
33public sealed override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
41public sealed override void AddAlignTokensOperations(List<AlignTokensOperation> list, SyntaxNode node, in NextAlignTokensOperationAction nextOperation)
72public virtual void AddSuppressOperationsSlow(ArrayBuilder<SuppressOperation> list, SyntaxNode node, ref NextSuppressOperationAction nextOperation)
78public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, ref NextAnchorIndentationOperationAction nextOperation)
84public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, ref NextIndentBlockOperationAction nextOperation)
90public virtual void AddAlignTokensOperationsSlow(List<AlignTokensOperation> list, SyntaxNode node, ref NextAlignTokensOperationAction nextOperation)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextAlignTokensOperationAction.cs (1)
15SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextAnchorIndentationOperationAction.cs (1)
15SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextIndentBlockOperationAction.cs (1)
15SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextSuppressOperationAction.cs (1)
16SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Helpers\RemoveUnnecessaryImports\AbstractUnnecessaryImportsProvider.cs (4)
18where TSyntaxNode : SyntaxNode
21SemanticModel model, Func<SyntaxNode, bool>? predicate, CancellationToken cancellationToken);
27SemanticModel model, TextSpan? span, Func<SyntaxNode, bool>? predicate, CancellationToken cancellationToken)
32var node = model.SyntaxTree.FindNode(span, findInTrivia: false, getInnermostNodeForTie: false, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\HeaderFacts\AbstractHeaderFacts.cs (28)
23public abstract bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
24public abstract bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration);
25public abstract bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter);
26public abstract bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method);
27public abstract bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction);
28public abstract bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration);
29public abstract bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement);
30public abstract bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement);
31public abstract bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement);
33public bool IsOnHeader(SyntaxNode root, int position, SyntaxNode ownerOfHeader, SyntaxNodeOrToken lastTokenOrNodeOfHeader)
34=> IsOnHeader(root, position, ownerOfHeader, lastTokenOrNodeOfHeader, ImmutableArray<SyntaxNode>.Empty);
37SyntaxNode root,
39SyntaxNode ownerOfHeader,
42where THoleSyntax : SyntaxNode
71protected TNode? TryGetAncestorForLocation<TNode>(SyntaxNode root, int position) where TNode : SyntaxNode
89protected int GetStartOfNodeExcludingAttributes(SyntaxNode root, SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\HeaderFacts\IHeaderFacts.cs (18)
16bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
18bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration);
19bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter);
20bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method);
21bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction);
22bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration);
23bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement);
24bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement);
25bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SemanticFacts\ISemanticFacts.cs (23)
53bool IsWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
60bool IsOnlyWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
61bool IsInOutContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
62bool IsInRefContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
63bool IsInInContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
65bool CanReplaceWithRValue(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? expression, CancellationToken cancellationToken);
74bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, [NotNullWhen(true)] out SemanticModel? speculativeModel);
81ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode forEachStatement);
82SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
84IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node);
86ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node);
88ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node);
92IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken);
94IParameterSymbol? FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken);
95IParameterSymbol? FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken);
97ISymbol? FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken);
98ISymbol? FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken);
100ImmutableArray<ISymbol> GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode? node, SyntaxToken token, CancellationToken cancellationToken);
102bool IsInsideNameOfExpression(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
109bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, [NotNullWhen(true)] INamedTypeSymbol? expressionType, CancellationToken cancellationToken);
111string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken);
122IPreprocessingSymbol? GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFacts.cs (294)
116bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node);
117bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node, PredefinedType type);
166bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node);
167bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node);
168bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node);
169bool IsDeclaration([NotNullWhen(true)] SyntaxNode? node);
170bool IsTypeDeclaration(SyntaxNode node);
172bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node);
177bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes);
181bool IsDocumentationComment(SyntaxNode node);
188bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? directive, out ExternalSourceInfo info);
190bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node);
192bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node);
193bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node);
195bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node);
196SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement);
198void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
199out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode;
201bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node);
204bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node);
206bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
207bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
208void GetPartsOfAssignmentStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
209void GetPartsOfAssignmentExpressionOrStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
212bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node);
214bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node);
215SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node);
217bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node);
218bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node);
219bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node);
221bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node);
222SyntaxNode? GetRightSideOfDot(SyntaxNode? node);
236SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget = false);
238bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node);
240bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
241bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
242bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
251SyntaxNode? GetStandaloneExpression(SyntaxNode? node);
260SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node);
269SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget = false);
271SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node);
273SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node);
275bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
277bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node);
278bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node);
279SyntaxNode? GetParameterList(SyntaxNode node);
280bool IsParameterList([NotNullWhen(true)] SyntaxNode? node);
284void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList);
286SyntaxNode GetExpressionOfArgument(SyntaxNode node);
287SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node);
288SyntaxNode GetExpressionOfInterpolation(SyntaxNode node);
290bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node);
291bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
292bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node);
294SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node);
295SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node);
296SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node);
297SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node);
303bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node);
304bool IsArgument([NotNullWhen(true)] SyntaxNode? node);
305bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node);
306RefKind GetRefKindOfArgument(SyntaxNode node);
308void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity);
309bool LooksGeneric(SyntaxNode simpleName);
311SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName);
313SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString);
315SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode node);
316SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode node);
317SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode node);
319bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node);
322SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node);
323SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node);
325bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node);
326bool IsMemberInitializerNamedAssignmentIdentifier([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance);
327bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression);
329bool IsDirective([NotNullWhen(true)] SyntaxNode? node);
330bool IsStatement([NotNullWhen(true)] SyntaxNode? node);
331bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node);
332bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node);
333SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node);
334bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement);
336bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node);
337bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node);
351bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node);
353bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement);
354SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node);
355SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node);
356SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node);
361bool IsElementAccessExpression([NotNullWhen(true)] SyntaxNode? node);
379bool IsInStaticContext(SyntaxNode node);
380bool IsUnsafeContext(SyntaxNode node);
382bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node);
384bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node);
386bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node);
387bool IsInConstructor(SyntaxNode node);
388bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node);
389bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node);
392bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2);
394string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null);
397SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position);
398SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
399SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
400SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node);
404SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false);
407PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root);
409PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root);
410SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration);
413bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span);
418/// Given a <see cref="SyntaxNode"/>, return the <see cref="TextSpan"/> representing the span of the member body
424TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node);
432SyntaxNode? TryGetBindableParent(SyntaxToken token);
435IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken);
438/// Given a <see cref="SyntaxNode"/>, that represents and argument return the string representation of
442string GetNameForArgument(SyntaxNode? argument);
445/// Given a <see cref="SyntaxNode"/>, that represents an attribute argument return the string representation of
449string GetNameForAttributeArgument(SyntaxNode? argument);
451bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node);
452bool IsPropertyPatternClause(SyntaxNode node);
454bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node);
455bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node);
456bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node);
458SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node);
459SyntaxNode GetTypeOfTypePattern(SyntaxNode node);
461void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen);
462void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
463void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation);
464void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation);
465void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression);
466void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern);
470SyntaxTokenList GetModifiers(SyntaxNode? node);
474SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers);
477Location GetDeconstructionReferenceLocation(SyntaxNode node);
482bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node);
484SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia);
490bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node);
491bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node);
492bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node);
493bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node);
494bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
495bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node);
496bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node);
497bool IsAnyName([NotNullWhen(true)] SyntaxNode? node);
498bool IsAnyType([NotNullWhen(true)] SyntaxNode? node);
500bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
501bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node);
503bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
504bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node);
510void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type);
511void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken);
512void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList);
513void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members);
514void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer);
515void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
516void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression);
517void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members);
518void GetPartsOfConditionalAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull);
519void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse);
520void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments);
521void GetPartsOfInterpolationExpression(SyntaxNode node, out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken);
522void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList);
523void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right);
524void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name);
525void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode name, out SyntaxNode expression);
526void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer);
527void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer);
528void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default);
529void GetPartsOfParenthesizedExpression(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen);
530void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand);
531void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken dotToken, out SyntaxNode right);
532void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name);
542SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node);
544SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node);
545SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node);
546SyntaxNode GetExpressionOfRefExpression(SyntaxNode node);
547SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node);
548SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node);
549SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node);
551bool IsEqualsValueOfPropertyDeclaration([NotNullWhen(true)] SyntaxNode? node);
552SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node);
554SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node);
555SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node);
557SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (199)
23public static bool IsMemberInitializerNamedAssignmentIdentifier(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
26public static bool IsOnSingleLine(this ISyntaxFacts syntaxFacts, SyntaxNode node, bool fullSpan)
62var currentNode = currentNodeOrToken.AsNode()!;
160this ISyntaxFacts syntaxFacts, ImmutableArray<SyntaxNode> nodes, CancellationToken cancellationToken)
166foreach (var node in nodes)
178public static bool ContainsInterleavedDirective(this ISyntaxFacts syntaxFacts, SyntaxNode node, CancellationToken cancellationToken)
182this ISyntaxFacts syntaxFacts, TextSpan span, SyntaxNode node, CancellationToken cancellationToken)
193public static bool SpansPreprocessorDirective(this ISyntaxFacts syntaxFacts, IEnumerable<SyntaxNode> nodes)
286public static SyntaxNode? WalkDownParentheses(this ISyntaxFacts syntaxFacts, SyntaxNode? node)
290syntaxFacts.GetPartsOfParenthesizedExpression(node, out _, out var child, out _);
298public static SyntaxNode? WalkUpParentheses(this ISyntaxFacts syntaxFacts, SyntaxNode? node)
307this ISyntaxFacts syntaxFacts, SyntaxNode statement,
308out SyntaxNode left, out SyntaxNode right)
313public static SyntaxNode GetExpressionOfInvocationExpression(
314this ISyntaxFacts syntaxFacts, SyntaxNode node)
316syntaxFacts.GetPartsOfInvocationExpression(node, out var expression, out _);
320public static SyntaxNode Unparenthesize(
321this ISyntaxFacts syntaxFacts, SyntaxNode node)
324SyntaxNode operand;
348var resultNode = operand
383public static bool SpansPreprocessorDirective(this ISyntaxFacts service, SyntaxNode node)
386public static bool SpansPreprocessorDirective(this ISyntaxFacts service, params SyntaxNode[] nodes)
387=> service.SpansPreprocessorDirective((IEnumerable<SyntaxNode>)nodes);
392public static void GetPartsOfBinaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node, out SyntaxNode left, out SyntaxNode right)
395public static SyntaxNode GetPatternOfParenthesizedPattern(this ISyntaxFacts syntaxFacts, SyntaxNode node)
397syntaxFacts.GetPartsOfParenthesizedPattern(node, out _, out var pattern, out _);
401public static SyntaxToken GetOperatorTokenOfBinaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
407public static bool IsAnonymousOrLocalFunction(this ISyntaxFacts syntaxFacts, SyntaxNode node)
411public static SyntaxNode? GetExpressionOfElementAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
413syntaxFacts.GetPartsOfElementAccessExpression(node, out var expression, out _);
417public static SyntaxNode? GetArgumentListOfElementAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
419syntaxFacts.GetPartsOfElementAccessExpression(node, out _, out var argumentList);
423public static SyntaxNode GetExpressionOfConditionalAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
425syntaxFacts.GetPartsOfConditionalAccessExpression(node, out var expression, out _);
429public static SyntaxToken GetOperatorTokenOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
435public static void GetPartsOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node, out SyntaxNode expression, out SyntaxNode name)
438public static void GetPartsOfConditionalAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node, out SyntaxNode expression, out SyntaxNode whenNotNull)
441public static TextSpan GetSpanWithoutAttributes(this ISyntaxFacts syntaxFacts, SyntaxNode root, SyntaxNode node)
468/// Similar to <see cref="ISyntaxFacts.GetStandaloneExpression(SyntaxNode)"/>, this gets the containing
478public static SyntaxNode GetRootStandaloneExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
481var standalone = syntaxFacts.GetStandaloneExpression(node);
489public static SyntaxNode? GetArgumentListOfInvocationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
491syntaxFacts.GetPartsOfInvocationExpression(node, out _, out var argumentList);
495public static SeparatedSyntaxList<SyntaxNode> GetArgumentsOfInvocationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
497var argumentList = syntaxFacts.GetArgumentListOfInvocationExpression(node);
501public static SyntaxNode? GetArgumentListOfBaseObjectCreationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
503syntaxFacts.GetPartsOfBaseObjectCreationExpression(node, out var argumentList, out _);
507public static SyntaxNode? GetDefaultOfParameter(this ISyntaxFacts syntaxFacts, SyntaxNode node)
509syntaxFacts.GetPartsOfParameter(node, out _, out var @default);
513public static SyntaxNode GetExpressionOfParenthesizedExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
515syntaxFacts.GetPartsOfParenthesizedExpression(node, out _, out var expression, out _);
519public static SyntaxToken GetIdentifierOfGenericName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
525public static SyntaxToken GetIdentifierOfIdentifierName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
528public static SyntaxToken GetIdentifierOfParameter(this ISyntaxFacts syntaxFacts, SyntaxNode node)
534public static SyntaxList<SyntaxNode> GetImportsOfBaseNamespaceDeclaration(this ISyntaxFacts syntaxFacts, SyntaxNode node)
540public static SyntaxList<SyntaxNode> GetImportsOfCompilationUnit(this ISyntaxFacts syntaxFacts, SyntaxNode node)
546public static SyntaxNode? GetInitializerOfBaseObjectCreationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
548syntaxFacts.GetPartsOfBaseObjectCreationExpression(node, out _, out var initializer);
552public static SyntaxList<SyntaxNode> GetMembersOfBaseNamespaceDeclaration(this ISyntaxFacts syntaxFacts, SyntaxNode node)
558public static SyntaxList<SyntaxNode> GetMembersOfCompilationUnit(this ISyntaxFacts syntaxFacts, SyntaxNode node)
564public static SyntaxNode GetNameOfAttribute(this ISyntaxFacts syntaxFacts, SyntaxNode node)
566syntaxFacts.GetPartsOfAttribute(node, out var name, out _);
570public static SyntaxNode GetNameOfBaseNamespaceDeclaration(this ISyntaxFacts syntaxFacts, SyntaxNode node)
572syntaxFacts.GetPartsOfBaseNamespaceDeclaration(node, out var name, out _, out _);
576public static SyntaxNode GetNameOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
578syntaxFacts.GetPartsOfMemberAccessExpression(node, out _, out var name);
582public static SyntaxNode GetOperandOfPrefixUnaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
584syntaxFacts.GetPartsOfPrefixUnaryExpression(node, out _, out var operand);
588public static SyntaxToken GetOperatorTokenOfPrefixUnaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
594public static SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
600public static SyntaxNode GetTypeOfObjectCreationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
602syntaxFacts.GetPartsOfObjectCreationExpression(node, out _, out var type, out _, out _);
610public static bool IsExpressionOfAwaitExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
612var parent = node?.Parent;
619public static bool IsExpressionOfInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
621var parent = node?.Parent;
625syntaxFacts.GetPartsOfInvocationExpression(parent, out var expression, out _);
629public static bool IsExpressionOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
631var parent = node?.Parent;
635syntaxFacts.GetPartsOfMemberAccessExpression(parent, out var expression, out _);
639public static bool IsNameOfAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
644syntaxFacts.GetPartsOfAttribute(node.Parent, out var name, out _);
648public static bool IsRightOfQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
650var parent = node?.Parent;
654syntaxFacts.GetPartsOfQualifiedName(parent, out _, out _, out var right);
658public static bool IsTypeOfObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
660var parent = node?.Parent;
664syntaxFacts.GetPartsOfObjectCreationExpression(parent, out _, out var type, out _, out _);
695public static bool IsSkippedTokensTrivia(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
735public static bool IsGenericName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
738public static bool IsIdentifierName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
741public static bool IsQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
748public static bool IsTupleType(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
755public static bool IsCharacterLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
758public static bool IsDefaultLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
761public static bool IsFalseLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
764public static bool IsNumericLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
767public static bool IsNullLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
770public static bool IsStringLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
773public static bool IsTrueLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
780public static bool IsArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
783public static bool IsAwaitExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
786public static bool IsBaseExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
789public static bool IsConditionalExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
792public static bool IsConditionalAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
795public static bool IsImplicitArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
798public static bool IsImplicitObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
801public static bool IsIndexExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
804public static bool IsInterpolatedStringExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
807public static bool IsInterpolation(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
810public static bool IsInterpolatedStringText(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
813public static bool IsInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
816public static bool IsIsTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
819public static bool IsIsNotTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
822public static bool IsIsPatternExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
825public static bool IsLogicalAndExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
828public static bool IsLogicalOrExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
831public static bool IsLogicalNotExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
834public static bool IsObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
837public static bool IsParenthesizedExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
840public static bool IsQueryExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
843public static bool IsRangeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
846public static bool IsRefExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
849public static bool IsSimpleMemberAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
852public static bool IsThisExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
855public static bool IsThrowExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
858public static bool IsTupleExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
861public static bool ContainsGlobalStatement(this ISyntaxFacts syntaxFacts, SyntaxNode node)
868public static bool IsAndPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
871public static bool IsConstantPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
874public static bool IsDeclarationPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
877public static bool IsListPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
880public static bool IsNotPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
883public static bool IsOrPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
886public static bool IsParenthesizedPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
889public static bool IsRecursivePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
892public static bool IsRelationalPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
895public static bool IsTypePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
898public static bool IsVarPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
905public static bool IsExpressionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
908public static bool IsForEachStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
911public static bool IsForStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
914public static bool IsIfStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
917public static bool IsLocalDeclarationStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
920public static bool IsLocalFunctionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
923public static bool IsLockStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
926public static bool IsReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
929public static bool IsThrowStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
932public static bool IsUsingStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
935public static bool IsWhileStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
938public static bool IsYieldReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
945public static bool IsAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
948public static bool IsClassDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
951public static bool IsConstructorDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
954public static bool IsEnumDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
957public static bool IsGlobalAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
960public static bool IsInterfaceDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
963public static bool IsParameter(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
966public static bool IsTypeConstraint(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
969public static bool IsVariableDeclarator(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
972public static bool IsFieldDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
975public static bool IsPropertyDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
978public static bool IsStructDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
981public static bool IsTypeArgumentList(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
988public static bool IsElseClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
990public static bool IsEqualsValueClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
997public static bool IsImplicitElementAccess(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1000public static bool IsIndexerMemberCref(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (39)
35where TExpressionSyntax : SyntaxNode
37where TAttributeSyntax : SyntaxNode
38where TArgumentSyntax : SyntaxNode
39where TForEachStatementSyntax : SyntaxNode
40where TThrowStatementSyntax : SyntaxNode
49private SyntaxNode? _lazySemanticRootOfOriginalExpression;
51private SyntaxNode? _lazySemanticRootOfReplacedExpression;
97protected abstract SyntaxNode GetSemanticRootForSpeculation(TExpressionSyntax expression);
98protected abstract SemanticModel CreateSpeculativeSemanticModel(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel);
101protected abstract bool ExpressionMightReferenceMember([NotNullWhen(true)] SyntaxNode? node);
116protected abstract bool ReplacementChangesSemanticsForNodeLanguageSpecific(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode? previousOriginalNode, SyntaxNode? previousReplacedNode);
118protected abstract bool IsParenthesizedExpression([NotNullWhen(true)] SyntaxNode? node);
130SyntaxNode ISpeculationAnalyzer.OriginalExpression => OriginalExpression;
137public SyntaxNode SemanticRootOfOriginalExpression
170SyntaxNode ISpeculationAnalyzer.ReplacedExpression => ReplacedExpression;
177public SyntaxNode SemanticRootOfReplacedExpression
200protected virtual SyntaxNode GetSemanticRootOfReplacedExpression(SyntaxNode semanticRootOfOriginalExpression, TExpressionSyntax annotatedReplacedExpression)
223protected abstract void ValidateSpeculativeSemanticModel(SemanticModel speculativeSemanticModel, SyntaxNode nodeToSpeculate);
230var nodeToSpeculate = this.SemanticRootOfReplacedExpression;
316protected bool SymbolsAreCompatible(SyntaxNode originalNode, SyntaxNode newNode, bool requireNonNullSymbols = false)
518protected bool ReplacementChangesSemantics(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode originalRoot, bool skipVerificationForCurrentNode)
526SyntaxNode? previousOriginalNode = null, previousReplacedNode = null;
571private bool ReplacementChangesSemanticsForNode(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode? previousOriginalNode, SyntaxNode? previousReplacedNode)
688var originalExpressionOfMemberAccess = syntaxFacts.GetExpressionOfMemberAccessExpression(originalExpression);
731private bool ReplacementBreaksSystemObjectMethodResolution(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, [NotNullWhen(true)] SyntaxNode? previousOriginalNode, [NotNullWhen(true)] SyntaxNode? previousReplacedNode)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (8)
46public static IEnumerable<(SyntaxToken, SyntaxToken)> ConvertToTokenPairs(this SyntaxNode root, IReadOnlyList<TextSpan> spans)
82public static ValueTuple<SyntaxToken, SyntaxToken> ConvertToTokenPair(this SyntaxNode root, TextSpan textSpan)
128public static bool IsInvalidTokenRange(this SyntaxNode root, SyntaxToken startToken, SyntaxToken endToken)
279var parentNode = GetParentThatContainsGivenSpan(token.Parent, backwardPosition, forward: false);
310var parentNode = GetParentThatContainsGivenSpan(token.Parent, forwardPosition, forward: true);
321private static SyntaxNode? GetParentThatContainsGivenSpan(SyntaxNode? node, int position, bool forward)
358public static TextSpan GetFormattingSpan(SyntaxNode root, TextSpan span)
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (13)
22where TExpressionSyntax : SyntaxNode
31protected abstract void GetPartsOfCastOrConversionExpression(TExpressionSyntax expression, out SyntaxNode type, out TExpressionSyntax castedExpression);
49Document document, SemanticModel semanticModel, SyntaxNode root,
61Document document, SemanticModel semanticModel, SyntaxNode root,
72var root = await document.GetRequiredSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
116private (SyntaxNode finalTarget, SyntaxNode finalReplacement) ApplyFix(
136(SyntaxNode finalTarget, SyntaxNode finalReplacement) ApplyFixWorker()
141GetPartsOfCastOrConversionExpression(targetNode, out var castTypeNode, out var castedExpression);
161protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
218var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
src\Analyzers\Core\CodeFixes\ConvertToAsync\AbstractConvertToAsyncCodeFixProvider.cs (10)
20protected abstract Task<string> GetDescriptionAsync(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
21protected abstract Task<Tuple<SyntaxTree, SyntaxNode>> GetRootInOtherSyntaxTreeAsync(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
32var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
33if (!TryGetNode(root, context.Span, out var node))
48private static bool TryGetNode(SyntaxNode root, TextSpan span, out SyntaxNode node)
51var ancestors = root.FindToken(span.Start).GetAncestors<SyntaxNode>();
62SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
71var newRoot = result.Item2;
src\Analyzers\Core\CodeFixes\FileHeaders\AbstractFileHeaderCodeFixProvider.cs (8)
49private async Task<SyntaxNode> GetTransformedSyntaxRootAsync(Document document, CancellationToken cancellationToken)
58internal static async Task<SyntaxNode> GetTransformedSyntaxRootAsync(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, Document document, string? fileHeaderTemplate, CancellationToken cancellationToken)
61var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
81SyntaxNode newSyntaxRoot;
94private static SyntaxNode ReplaceHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader)
176private static SyntaxNode AddHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader)
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.cs (9)
26where TExpressionSyntax : SyntaxNode
29protected abstract bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
30protected abstract bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
31protected abstract bool IsImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
33protected abstract bool TryInitializeImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
78public async Task<ImmutableArray<CodeAction>> GenerateConstructorAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (6)
21where TExpressionSyntax : SyntaxNode
24protected abstract bool IsImplicitConversionGeneration(SyntaxNode node);
25protected abstract bool IsExplicitConversionGeneration(SyntaxNode node);
26protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
27protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
31SyntaxNode node,
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.cs (6)
25where TExpressionSyntax : SyntaxNode
31protected abstract bool IsExplicitInterfaceGeneration(SyntaxNode node);
32protected abstract bool IsIdentifierNameGeneration(SyntaxNode node);
34protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn);
37protected abstract bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, SemanticModel semanticModel, CancellationToken cancellationToken, out SyntaxNode newRoot);
41SyntaxNode node,
src\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (10)
33Document document, ImplementTypeOptions options, SyntaxNode classNode, SyntaxToken classIdentifier,
39private readonly SyntaxNode _classNode = classNode;
47Document document, SyntaxNode classNode, SyntaxToken classIdentifier, CancellationToken cancellationToken)
79Document document, SyntaxNode classNode, SyntaxToken classIdentifier, CancellationToken cancellationToken)
182var body = throughMember == null
250Func<SyntaxNode, SyntaxNode, SyntaxNode> createAddOrRemoveHandler)
256var throughExpression = generator.CreateDelegateThroughExpression(@event, throughMember);
257var statement = generator.ExpressionStatement(createAddOrRemoveHandler(
src\Analyzers\Core\CodeFixes\ImplementInterface\AbstractImplementInterfaceService.cs (10)
30protected abstract bool TryInitializeState(Document document, SemanticModel model, SyntaxNode interfaceNode, CancellationToken cancellationToken, out SyntaxNode classOrStructDecl, out INamedTypeSymbol classOrStructType, out ImmutableArray<INamedTypeSymbol> interfaceTypes);
33protected abstract SyntaxNode AddCommentInsideIfStatement(SyntaxNode ifDisposingStatement, SyntaxTriviaList trivia);
34protected abstract SyntaxNode CreateFinalizer(SyntaxGenerator generator, INamedTypeSymbol classType, string disposeMethodDisplayString);
37Document document, ImplementTypeOptions options, SyntaxNode node, CancellationToken cancellationToken)
57public async Task<IImplementInterfaceInfo?> AnalyzeAsync(Document document, SyntaxNode interfaceType, CancellationToken cancellationToken)
63protected TNode AddComment<TNode>(string comment, TNode node) where TNode : SyntaxNode
66protected TNode AddComments<TNode>(string comment1, string comment2, TNode node) where TNode : SyntaxNode
69protected TNode AddComments<TNode>(string[] comments, TNode node) where TNode : SyntaxNode
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (14)
21protected abstract bool IsAsyncSupportingFunctionSyntax(SyntaxNode node);
28protected abstract SyntaxNode AddAsyncTokenAndFixReturnType(
29bool keepVoid, IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes, CancellationToken cancellationToken);
42var node = GetContainingFunction(diagnostic, cancellationToken);
87private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
109var node = GetContainingFunction(diagnostic, cancellationToken);
147private SyntaxNode? GetContainingFunction(Diagnostic diagnostic, CancellationToken cancellationToken)
157SyntaxNode node,
173var newRoot = await newDocument.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
174if (syntaxPath.TryResolve(newRoot, out SyntaxNode? newNode))
189SyntaxNode node,
192var newNode = AddAsyncTokenAndFixReturnType(keepVoid, methodSymbol, node, knownTypes, cancellationToken);
194var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
195var newRoot = root.ReplaceNode(node, newNode);
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (15)
24protected abstract bool IsAsyncSupportingFunctionSyntax(SyntaxNode node);
25protected abstract SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes);
52Document document, SyntaxNode node, CancellationToken cancellationToken)
73private async Task<Solution> RenameThenRemoveAsyncTokenAsync(Document document, SyntaxNode node, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
85var newRoot = await newDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
86if (syntaxPath.TryResolve(newRoot, out SyntaxNode? newNode))
97Document document, IMethodSymbol methodSymbol, SyntaxNode node, CancellationToken cancellationToken)
103var newNode = RemoveAsyncTokenAndFixReturnType(methodSymbol, node, knownTypes)
106var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
107var newRoot = root.ReplaceNode(node, newNode);
122var syntaxRoot = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
123var methodDeclaration = syntaxRoot.GetAnnotatedNodes(annotation).FirstOrDefault();
175var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
182var newRoot = editor.GetChangedRoot();
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (35)
22where TReturnStatementSyntax : SyntaxNode
23where TExpressionSyntax : SyntaxNode
25protected abstract bool IsAsyncSupportingFunctionSyntax(SyntaxNode node);
26protected abstract SyntaxNode RemoveAsyncModifier(SyntaxGenerator generator, SyntaxNode methodLikeNode);
27protected abstract SyntaxNode? ConvertToBlockBody(SyntaxNode node, TExpressionSyntax expressionBody);
104private static IMethodSymbol? GetMethodSymbol(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken)
117private SyntaxNode RemoveAsyncModifier(
121SyntaxNode node,
128var expression = generator.GetExpression(node);
134var blockBodiedNode = ConvertToBlockBody(node, expressionBody);
146var newExpressionBody = WrapExpressionWithTaskFromResult(generator, expressionBody, returnType, knownTypes);
166private static ControlFlowAnalysis? GetControlFlowAnalysis(SyntaxGenerator generator, SemanticModel semanticModel, SyntaxNode node)
177private static SyntaxNode AddReturnStatement(SyntaxGenerator generator, SyntaxNode node)
180private SyntaxNode ChangeReturnStatements(
184SyntaxNode node,
200var returnTaskCompletedTask = GetReturnTaskCompletedTaskStatement(generator, returnType, knownTypes);
206var newExpression = WrapExpressionWithTaskFromResult(generator, returnExpression, returnType, knownTypes);
214private static SyntaxNode GetReturnTaskCompletedTaskStatement(SyntaxGenerator generator, ITypeSymbol returnType, KnownTaskTypes knownTypes)
216SyntaxNode invocation;
219var taskTypeExpression = TypeExpressionForStaticMemberAccess(generator, knownTypes.TaskType);
227var statement = generator.ReturnStatement(invocation);
231private static SyntaxNode WrapExpressionWithTaskFromResult(SyntaxGenerator generator, SyntaxNode expression, ITypeSymbol returnType, KnownTaskTypes knownTypes)
235var taskTypeExpression = TypeExpressionForStaticMemberAccess(generator, knownTypes.TaskType!);
237var memberName = generator.GenericName(nameof(Task.FromResult), unwrappedReturnType);
238var taskFromResult = generator.MemberAccessExpression(taskTypeExpression, memberName);
249private static SyntaxNode TypeExpressionForStaticMemberAccess(SyntaxGenerator generator, INamedTypeSymbol typeSymbol)
254var typeExpression = generator.TypeExpression(typeSymbol);
258static SyntaxNode QualifiedNameToMemberAccess(int qualifiedNameSyntaxKind, int memberAccessExpressionSyntaxKind, SyntaxNode expression, SyntaxGenerator generator)
262var left = QualifiedNameToMemberAccess(qualifiedNameSyntaxKind, memberAccessExpressionSyntaxKind, expression.ChildNodes().First(), generator);
263var right = expression.ChildNodes().Last();
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (73)
48where TExpressionSyntax : SyntaxNode
49where TStatementSyntax : SyntaxNode
54where TVariableDeclaratorSyntax : SyntaxNode
55where TSwitchCaseBlockSyntax : SyntaxNode
56where TSwitchCaseLabelOrClauseSyntax : SyntaxNode
76protected abstract SyntaxNode? TryUpdateNameForFlaggedNode(SyntaxNode node, SyntaxToken newName);
100protected abstract SyntaxNode GetReplacementNodeForCompoundAssignment(
101SyntaxNode originalCompoundAssignment,
102SyntaxNode newAssignmentTarget,
110protected abstract SyntaxNode GetReplacementNodeForVarPattern(SyntaxNode originalVarPattern, SyntaxNode newNameNode);
122protected virtual SyntaxNode? TryUpdateParentOfUpdatedNode(SyntaxNode parent, SyntaxNode newNameNode, SyntaxEditor editor, ISyntaxFacts syntaxFacts, SemanticModel semanticModel) => null;
131protected abstract SyntaxNode ComputeReplacementNode(SyntaxNode originalOldNode, SyntaxNode changedOldNode, SyntaxNode proposedReplacementNode);
165var root = await context.Document.GetRequiredSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
166var node = root.FindNode(context.Span, getInnermostNodeForTie: true);
240private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
243SyntaxNode root,
265private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
268SyntaxNode root)
279var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
293private async Task<SyntaxNode> GetNewRootAsync(
299var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
325var containingMemberDeclaration = diagnosticsToFix.Key;
335var currentRoot = editor.GetChangedRoot();
336var newRoot = await PostProcessDocumentAsync(document, options, currentRoot,
350SyntaxNode root,
351SyntaxNode containingMemberDeclaration,
387SyntaxNode root,
430var localDecl = editor.Generator.LocalDeclarationStatement(
446SyntaxNode root,
447SyntaxNode containingMemberDeclaration,
470using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var nodeReplacementMap);
471using var _2 = PooledHashSet<SyntaxNode>.GetInstance(out var nodesToRemove);
472using var _3 = PooledHashSet<(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)>.GetInstance(out var nodesToAdd);
474using var _4 = PooledHashSet<SyntaxNode>.GetInstance(out var processedNodes);
550var newNameNode = TryUpdateNameForFlaggedNode(node, newNameToken);
570var newParentNode = TryUpdateParentOfUpdatedNode(node.GetRequiredParent(), newNameNode, editor, syntaxFacts, semanticModel);
674IEnumerable<(SyntaxNode node, bool isUnusedLocalAssignment)> GetNodesToFix()
678var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
692void InsertLocalDeclarationStatement(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)
695var insertionNode = node.FirstAncestorOrSelf<SyntaxNode>(
726bool ShouldRemoveStatement(TLocalDeclarationStatementSyntax localDeclarationStatement, out SeparatedSyntaxList<SyntaxNode> variables)
732foreach (var variable in variables)
746private async Task<SyntaxNode> PostProcessDocumentAsync(
749SyntaxNode currentRoot,
775private static async Task<SyntaxNode> PostProcessDocumentCoreAsync(
776Func<SyntaxNode, Document, SyntaxFormattingOptions, CancellationToken, Task<SyntaxNode>> processMemberDeclarationAsync,
777SyntaxNode currentRoot,
786var newRoot = await newDocument.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
787using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var memberDeclReplacementsMap);
789foreach (var memberDecl in newRoot.DescendantNodes().Where(n => n.HasAnnotation(s_memberAnnotation)))
791var newMemberDecl = await processMemberDeclarationAsync(memberDecl, newDocument, options, cancellationToken).ConfigureAwait(false);
807private async Task<SyntaxNode> ReplaceDiscardDeclarationsWithAssignmentsAsync(SyntaxNode memberDeclaration, Document document, SyntaxFormattingOptions options, CancellationToken cancellationToken)
823private async Task<SyntaxNode> AdjustLocalDeclarationsAsync(
824SyntaxNode memberDeclaration,
846var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
847var rootWithTrackedNodes = root.TrackNodes(originalDeclStatementsToMoveOrRemove);
900var rootWithRemovedDeclaration = root.RemoveNode(newDecl, SyntaxGenerator.DefaultRemoveOptions | SyntaxRemoveOptions.KeepLeadingTrivia);
927SyntaxNode memberDeclaration,
932private readonly SyntaxNode _memberDeclaration = memberDeclaration;
938public SyntaxToken GenerateUniqueNameAtSpanStart(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (83)
48public TDeclarationNode AddEvent<TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
51public TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
54public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
57public TDeclarationNode AddProperty<TDeclarationNode>(TDeclarationNode destination, IPropertySymbol property, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
60public TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
63public TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationNode destination, INamespaceSymbol @namespace, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
67where TDeclarationNode : SyntaxNode
70private static TNode WithAnnotations<TNode>(TNode node, CodeGenerationContextInfo info) where TNode : SyntaxNode
77public SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
80public SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
83public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
86public SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
89public SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
92public SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
95public TDeclarationNode AddParameters<TDeclarationNode>(TDeclarationNode destination, IEnumerable<IParameterSymbol> parameters, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
98public TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
101public TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, SyntaxNode attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
104public TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, AttributeData attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
107public TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
110public TDeclarationNode UpdateDeclarationAccessibility<TDeclarationNode>(TDeclarationNode declaration, Accessibility newAccessibility, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
113public TDeclarationNode UpdateDeclarationType<TDeclarationNode>(TDeclarationNode declaration, ITypeSymbol newType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
116public TDeclarationNode UpdateDeclarationMembers<TDeclarationNode>(TDeclarationNode declaration, IList<ISymbol> newMembers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
119public TDeclarationNode AddStatements<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> statements, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
124protected abstract TDeclarationNode AddEvent<TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
125protected abstract TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
126protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
127protected abstract TDeclarationNode AddProperty<TDeclarationNode>(TDeclarationNode destination, IPropertySymbol property, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
128protected abstract TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
129protected abstract TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationNode destination, INamespaceSymbol @namespace, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
130protected abstract TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> members) where TDeclarationNode : SyntaxNode;
132public abstract TDeclarationNode AddParameters<TDeclarationNode>(TDeclarationNode destinationMember, IEnumerable<IParameterSymbol> parameters, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
133public abstract TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
134public abstract TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, SyntaxNode attributeToRemove, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
135public abstract TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, AttributeData attributeToRemove, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
136public abstract TDeclarationNode AddStatements<TDeclarationNode>(TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
138public abstract TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
139public abstract TDeclarationNode UpdateDeclarationAccessibility<TDeclarationNode>(TDeclarationNode declaration, Accessibility newAccessibility, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
140public abstract TDeclarationNode UpdateDeclarationType<TDeclarationNode>(TDeclarationNode declaration, ITypeSymbol newType, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
141public abstract TDeclarationNode UpdateDeclarationMembers<TDeclarationNode>(TDeclarationNode declaration, IList<ISymbol> newMembers, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
143public abstract CodeGenerationDestination GetDestination(SyntaxNode node);
144public abstract SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
145public abstract SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
148public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
150public abstract SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
151public abstract SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
152public abstract SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
157protected static void CheckDeclarationNode<TDeclarationNode>(SyntaxNode destination) where TDeclarationNode : SyntaxNode
172protected static void CheckDeclarationNode<TDeclarationNode1, TDeclarationNode2>(SyntaxNode destination)
173where TDeclarationNode1 : SyntaxNode
174where TDeclarationNode2 : SyntaxNode
191protected static void CheckDeclarationNode<TDeclarationNode1, TDeclarationNode2, TDeclarationNode3>(SyntaxNode destination)
192where TDeclarationNode1 : SyntaxNode
193where TDeclarationNode2 : SyntaxNode
194where TDeclarationNode3 : SyntaxNode
212protected static void CheckDeclarationNode<TDeclarationNode1, TDeclarationNode2, TDeclarationNode3, TDeclarationNode4>(SyntaxNode destination)
213where TDeclarationNode1 : SyntaxNode
214where TDeclarationNode2 : SyntaxNode
215where TDeclarationNode3 : SyntaxNode
216where TDeclarationNode4 : SyntaxNode
233Func<SyntaxNode, TCodeGenerationContextInfo, IList<bool>?, CancellationToken, SyntaxNode> declarationTransform,
248var transformedDeclaration = declarationTransform(destinationDeclaration, info, availableIndices, cancellationToken);
250var root = await destinationTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
251var currentRoot = root.ReplaceNode(destinationDeclaration, transformedDeclaration);
276where TDeclarationNode : SyntaxNode
298where TDeclarationSyntax : SyntaxNode
300var newMembers = new List<SyntaxNode>();
305var newMember = GetNewMember(info, codeGenerationDestination, member, cancellationToken);
330where TDeclarationSyntax : SyntaxNode
343private SyntaxNode? GetNewMember(TCodeGenerationContextInfo info, CodeGenerationDestination codeGenerationDestination, ISymbol member, CancellationToken cancellationToken)
360CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
380protected abstract IComparer<SyntaxNode> GetMemberComparer();
482protected static void CheckLocation(SyntaxNode destinationMember, [NotNull] Location? location)
501SyntaxNode attributeList,
521SyntaxNode attributeToRemove,
527var root = attributeToRemove.SyntaxTree.GetRoot();
536where T : SyntaxNode
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (16)
19protected abstract IList<bool>? GetAvailableInsertionIndices(SyntaxNode destination, CancellationToken cancellationToken);
21private IList<bool>? GetAvailableInsertionIndices<TDeclarationNode>(TDeclarationNode destination, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
22=> GetAvailableInsertionIndices((SyntaxNode)destination, cancellationToken);
30protected static SyntaxToken GetEndToken(SyntaxNode node)
46protected static TextSpan GetSpan(SyntaxNode node)
54public bool CanAddTo(SyntaxNode destination, Solution solution, CancellationToken cancellationToken)
57private bool CanAddTo(SyntaxNode? destination, Solution solution, CancellationToken cancellationToken,
126public async Task<SyntaxNode?> FindMostRelevantNameSpaceOrTypeDeclarationAsync(
136private async Task<(SyntaxNode? declaration, IList<bool>? availableIndices)> FindMostRelevantDeclarationAsync(
142var declaration = (SyntaxNode?)null;
149var fallbackDeclaration = (SyntaxNode?)null;
215private static async Task<SyntaxNode?> SelectFirstOrDefaultAsync(IEnumerable<SyntaxReference> references, Func<SyntaxNode, bool> predicate, CancellationToken cancellationToken)
219var node = await r.GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractFlagsEnumGenerator.cs (8)
15protected abstract SyntaxNode CreateExplicitlyCastedLiteralValue(SyntaxGenerator generator, INamedTypeSymbol enumType, SpecialType underlyingSpecialType, object constantValue);
18public SyntaxNode CreateEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
63private SyntaxNode CreateFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
73private SyntaxNode CreateFlagsEnumConstantValue(
106SyntaxNode? finalNode = null;
110var node = CreateMemberAccessExpression(generator, field.field, enumType, underlyingSpecialType);
140private SyntaxNode CreateMemberAccessExpression(
188private SyntaxNode CreateNonFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (16)
60SyntaxNode? initializer = null)
113SyntaxNode? initializer = null)
129ImmutableArray<SyntaxNode> statements = default,
130ImmutableArray<SyntaxNode> baseConstructorArguments = default,
131ImmutableArray<SyntaxNode> thisConstructorArguments = default,
144ImmutableArray<SyntaxNode> statements = default)
162ImmutableArray<SyntaxNode> statements = default,
163ImmutableArray<SyntaxNode> handlesExpressions = default,
183ImmutableArray<SyntaxNode> statements = default,
184ImmutableArray<SyntaxNode> handlesExpressions = default,
202ImmutableArray<SyntaxNode> statements = default,
228ImmutableArray<SyntaxNode> statements = default,
256ImmutableArray<SyntaxNode> statements = default,
365ImmutableArray<SyntaxNode> statements = default)
389ImmutableArray<SyntaxNode> statements)
522ImmutableArray<SyntaxNode> statements = default,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\ICodeGenerationService.cs (26)
23SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
28SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
34SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
39SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
44SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
49SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
54TDeclarationNode AddEvent<TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
59TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
64TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
69TDeclarationNode AddProperty<TDeclarationNode>(TDeclarationNode destination, IPropertySymbol property, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
74TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
79TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationNode destination, INamespaceSymbol @namespace, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
84TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNode destination, IEnumerable<ISymbol> members, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
89TDeclarationNode AddParameters<TDeclarationNode>(TDeclarationNode destination, IEnumerable<IParameterSymbol> parameters, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
94TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
99TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, SyntaxNode attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
104TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, AttributeData attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
109TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
114TDeclarationNode UpdateDeclarationAccessibility<TDeclarationNode>(TDeclarationNode declaration, Accessibility newAccessibility, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
119TDeclarationNode UpdateDeclarationType<TDeclarationNode>(TDeclarationNode declaration, ITypeSymbol newType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
124TDeclarationNode UpdateDeclarationMembers<TDeclarationNode>(TDeclarationNode declaration, IList<ISymbol> newMembers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
129TDeclarationNode AddStatements<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> statements, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
184bool CanAddTo(SyntaxNode destination, Solution solution, CancellationToken cancellationToken);
192Task<SyntaxNode?> FindMostRelevantNameSpaceOrTypeDeclarationAsync(Solution solution, INamespaceOrTypeSymbol namespaceOrType, Location? location, CancellationToken cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (47)
18where TExpressionSyntax : SyntaxNode
19where TArgumentSyntax : SyntaxNode
20where TExpressionStatementSyntax : SyntaxNode
24public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
26private static void AddNode<TSyntaxNode>(bool allowEmptyNodes, ref TemporaryArray<TSyntaxNode> result, TSyntaxNode node) where TSyntaxNode : SyntaxNode
35ParsedDocument document, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
42var root = document.Root;
137private static bool IsWantedTypeExpressionLike<TSyntaxNode>() where TSyntaxNode : SyntaxNode
157SyntaxNode root,
268CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
275var leftNode = tokenToLeft.Parent;
302SyntaxNode root,
307CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
313var rightNode = tokenToRightOrIn.Parent;
347SyntaxNode root,
352CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
354var selectionNode = root.FindNode(selectionTrimmed, getInnermostNodeForTie: true);
355var prevNode = selectionNode;
393protected virtual IEnumerable<SyntaxNode> ExtractNodesSimple(SyntaxNode? node, ISyntaxFactsService syntaxFacts)
411var localDeclarationStatement = syntaxFacts.IsLocalDeclarationStatement(node) ? node : node.Parent!;
480protected virtual IEnumerable<SyntaxNode> ExtractNodesInHeader(SyntaxNode root, int location, IHeaderFactsService headerFacts)
520CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
524var root = document.Root;
559IEnumerable<SyntaxNode> nodes, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
561foreach (var node in nodes)
573public bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
576public bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration)
579public bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter)
582public bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method)
585public bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction)
588public bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration)
591public bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement)
594public bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement)
597public bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ImportAdderService.cs (19)
39var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
66bool OverlapsWithSpan(SyntaxNode n) => spansTree.HasIntervalThatOverlapsWith(n.FullSpan.Start, n.FullSpan.Length);
69protected abstract INamespaceSymbol? GetExplicitNamespaceSymbol(SyntaxNode node, SemanticModel model);
73SyntaxNode container,
91SyntaxNode container,
96private static SyntaxNode GenerateNamespaceImportDeclaration(INamespaceSymbol namespaceSymbol, SyntaxGenerator generator)
107IEnumerable<SyntaxNode> syntaxNodes,
113using var _1 = ArrayBuilder<SyntaxNode>.GetInstance(out var importsToAdd);
114using var _2 = ArrayBuilder<SyntaxNode>.GetInstance(out var nodesToSimplify);
116var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
135var namespaceSyntax = GenerateNamespaceImportDeclaration(namespaceSymbol, generator);
155var first = root.DescendantNodesAndSelf().First(x => x.HasAnnotation(annotation));
156var last = root.DescendantNodesAndSelf().Last(x => x.HasAnnotation(annotation));
168IEnumerable<SyntaxNode> syntaxNodes,
174using var _ = PooledDictionary<INamespaceSymbol, SyntaxNode>.GetInstance(out var importToSyntax);
184SyntaxNode? first = null, last = null;
215var namespaceSyntax = GenerateNamespaceImportDeclaration(namespaceSymbol, generator);
233var importContainer = addImportsService.GetImportContainer(root, context, importToSyntax.First().Value, options);
254private static bool IsInsideNamespace(SyntaxNode node, INamespaceSymbol symbol, SemanticModel model, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxEditorExtensions.cs (29)
31Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
32CancellationToken cancellationToken) where TNode : SyntaxNode
54Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
55CancellationToken cancellationToken) where TNode : SyntaxNode
76Func<SemanticModel, SyntaxNode, TNode, SyntaxNode> updateRoot,
77CancellationToken cancellationToken) where TNode : SyntaxNode
98Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
99CancellationToken cancellationToken) where TNode : SyntaxNode
120Func<SemanticModel, SyntaxNode, TNode, SyntaxNode> updateRoot,
121CancellationToken cancellationToken) where TNode : SyntaxNode
154Func<ISyntaxFactsService, SyntaxNode, SyntaxNode> getSemanticBoundary,
156Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
157CancellationToken cancellationToken) where TNode : SyntaxNode
170var originalRoot = editor.OriginalRoot;
173var currentRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
183var replacementRoot = updateRoot(semanticModel, currentRoot, instance, currentNode);
195private static SyntaxNode GetExpressionSemanticBoundary(ISyntaxFactsService syntaxFacts, SyntaxNode node)
202return node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>(
210private static SyntaxNode GetMethodBodySemanticBoundary(ISyntaxFactsService syntaxFacts, SyntaxNode node)
212return node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions.cs (46)
30public static SyntaxNode CreateThrowNotImplementedStatement(
37public static SyntaxNode CreateThrowNotImplementedExpression(
44private static SyntaxNode CreateNewNotImplementedException(SyntaxGenerator codeDefinitionFactory, Compilation compilation)
46var notImplementedExceptionTypeSyntax = compilation.NotImplementedExceptionType() is INamedTypeSymbol symbol
55public static ImmutableArray<SyntaxNode> CreateThrowNotImplementedStatementBlock(
59public static ImmutableArray<SyntaxNode> CreateArguments(
66private static SyntaxNode CreateArgument(
73public static SyntaxNode GetDefaultEqualityComparer(
95public static SyntaxNode IsPatternExpression(this SyntaxGeneratorInternal generator, SyntaxNode expression, SyntaxNode pattern)
102public static SyntaxNode GenerateDelegateThroughMemberStatement(
105var through = generator.MemberAccessExpression(
111var invocationExpression = generator.InvocationExpression(through, generator.CreateArguments(method.Parameters));
117public static SyntaxNode CreateDelegateThroughExpression(
120var name = generator.IdentifierName(throughMember.Name);
121var through = throughMember.IsStatic
167var explicitImplementationCast = generator.CastExpression(
182static SyntaxNode GenerateContainerName(SyntaxGenerator factory, ISymbol throughMember)
191public static ImmutableArray<SyntaxNode> GetGetAccessorStatements(
197var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
198var expression = property.IsIndexer
215public static ImmutableArray<SyntaxNode> GetSetAccessorStatements(
221var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
222var expression = property.IsIndexer
315public static ImmutableArray<SyntaxNode> CreateAssignmentStatements(
325var nullCheckStatements = ArrayBuilder<SyntaxNode>.GetInstance();
326var assignStatements = ArrayBuilder<SyntaxNode>.GetInstance();
338var assignExpression = factory.AssignmentStatement(
341var statement = factory.ExpressionStatement(assignExpression);
351var fieldAccess = factory.MemberAccessExpression(factory.ThisExpression(), factory.IdentifierName(fieldName))
371SyntaxNode fieldAccess,
374ArrayBuilder<SyntaxNode> nullCheckStatements,
375ArrayBuilder<SyntaxNode> assignStatements)
406public static SyntaxNode CreateAssignWithNullCheckStatement(
407this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter, SyntaxNode fieldAccess)
416public static SyntaxNode CreateThrowArgumentNullExpression(this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
419private static SyntaxNode CreateNewArgumentNullException(SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
428public static SyntaxNode CreateNullCheckAndThrowStatement(
434var condition = factory.CreateNullCheckExpression(generatorInternal, semanticModel, parameter.Name);
435var throwStatement = factory.CreateThrowArgumentNullExceptionStatement(semanticModel.Compilation, parameter);
440public static SyntaxNode CreateNullCheckExpression(
443var identifier = factory.IdentifierName(identifierName);
444var nullExpr = factory.NullLiteralExpression();
445var condition = generatorInternal.SupportsPatterns(semanticModel.SyntaxTree.Options)
451public static SyntaxNode CreateThrowArgumentNullExceptionStatement(this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_CreateEqualsMethod.cs (21)
49public static IMethodSymbol CreateEqualsMethod(this Compilation compilation, ImmutableArray<SyntaxNode> statements)
109private static ImmutableArray<SyntaxNode> CreateEqualsMethodStatements(
127using var statements = TemporaryArray<SyntaxNode>.Empty;
136var localNameExpression = factory.IdentifierName(localName);
137var objNameExpression = factory.IdentifierName(ObjName);
141using var _2 = ArrayBuilder<SyntaxNode>.GetInstance(out var expressions);
159var ifStatement = factory.IfStatement(
170var localDeclaration = factory.SimpleLocalDeclarationStatement(generatorInternal,
182var localDeclaration = factory.SimpleLocalDeclarationStatement(generatorInternal,
220ImmutableArray<ISymbol> members, SyntaxNode localNameExpression,
221ArrayBuilder<SyntaxNode> expressions)
231var symbolNameExpression = factory.IdentifierName(member.Name);
232var thisSymbol = factory.MemberAccessExpression(factory.ThisExpression(), symbolNameExpression)
234var otherSymbol = factory.MemberAccessExpression(localNameExpression, symbolNameExpression);
271private static ImmutableArray<SyntaxNode> CreateIEquatableEqualsMethodStatements(
279var statements = ArrayBuilder<SyntaxNode>.GetInstance();
281var otherNameExpression = factory.IdentifierName(OtherName);
285using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var expressions);
323SyntaxGenerator factory, SyntaxGeneratorInternal generatorInternal, Compilation compilation, ParseOptions parseOptions, SyntaxNode otherNameExpression, ArrayBuilder<SyntaxNode> expressions)
325var nullLiteral = factory.NullLiteralExpression();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (34)
35public static SyntaxNode Negate(
38SyntaxNode expression,
45public static SyntaxNode Negate(
48SyntaxNode expressionOrPattern,
56public static SyntaxNode Negate(
59SyntaxNode expressionOrPattern,
140private static SyntaxNode GetNegationOfBinaryExpression(
141SyntaxNode expressionNode,
194SyntaxNode innerPattern;
203var typeExpression = generatorInternal.Type(isTypeOperation.TypeOperand, typeContext: false);
232private static SyntaxNode GetNegationOfBinaryPattern(
233SyntaxNode pattern,
247var newLeft = generator.Negate(generatorInternal, left, semanticModel, cancellationToken);
248var newRight = generator.Negate(generatorInternal, right, semanticModel, cancellationToken);
262private static SyntaxNode GetNegationOfIsPatternExpression(SyntaxNode isExpression, SyntaxGenerator generator, SyntaxGeneratorInternal generatorInternal, SemanticModel semanticModel, CancellationToken cancellationToken)
269SyntaxNode? negatedPattern = null;
304private static SyntaxNode GetNegationOfRelationalPattern(
305SyntaxNode expressionNode,
331private static bool IsLegalPattern(ISyntaxFacts syntaxFacts, SyntaxNode pattern, bool designatorsLegal)
380private static SyntaxNode NegateRelational(
383SyntaxNode leftOperand,
385SyntaxNode rightOperand)
471private static SyntaxNode GetNegationOfLiteralExpression(
472SyntaxNode expression,
477SyntaxNode newLiteralExpression;
495private static SyntaxNode GetNegationOfConstantPattern(
496SyntaxNode pattern,
520private static SyntaxNode GetNegationOfLogicalNotExpression(
521SyntaxNode expression,
531private static SyntaxNode GetNegationOfUnaryPattern(
532SyntaxNode pattern,
548private static SyntaxNode GetNegationOfNotPattern(
549SyntaxNode pattern,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AbstractAddImportsService.cs (62)
20where TCompilationUnitSyntax : SyntaxNode
21where TNamespaceDeclarationSyntax : SyntaxNode
22where TUsingOrAliasSyntax : SyntaxNode
23where TExternSyntax : SyntaxNode
30protected abstract SyntaxNode? GetAlias(TUsingOrAliasSyntax usingOrAlias);
31protected abstract ImmutableArray<SyntaxNode> GetGlobalImports(Compilation compilation, SyntaxGenerator generator);
32protected abstract SyntaxList<TUsingOrAliasSyntax> GetUsingsAndAliases(SyntaxNode node);
33protected abstract SyntaxList<TExternSyntax> GetExterns(SyntaxNode node);
48private bool HasAliases(SyntaxNode node) => GetUsingsAndAliases(node).Any(IsAlias);
49private bool HasUsings(SyntaxNode node) => GetUsingsAndAliases(node).Any(IsSimpleUsing);
50private bool HasStaticUsings(SyntaxNode node) => GetUsingsAndAliases(node).Any(IsStaticUsing);
51private bool HasExterns(SyntaxNode node) => GetExterns(node).Any();
52private bool HasAnyImports(SyntaxNode node) => GetUsingsAndAliases(node).Any() || GetExterns(node).Any();
56SyntaxNode root,
57SyntaxNode? contextLocation,
58SyntaxNode import,
66private static ImmutableArray<SyntaxNode> GetAllContainers(SyntaxNode root, SyntaxNode? contextLocation)
70var applicableContainer = GetFirstApplicableContainer(contextLocation);
71return applicableContainer.GetAncestorsOrThis<SyntaxNode>().ToImmutableArray();
75SyntaxNode import, ImmutableArray<SyntaxNode> containers, ImmutableArray<SyntaxNode> globalImports)
77foreach (var node in containers)
90foreach (var node in globalImports)
101protected abstract bool IsEquivalentImport(SyntaxNode a, SyntaxNode b);
103public SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, AddImportPlacementOptions options)
107out var externContainer, out var usingContainer, out var staticUsingContainer, out var aliasContainer);
130public SyntaxNode AddImports(
132SyntaxNode root,
133SyntaxNode? contextLocation,
134IEnumerable<SyntaxNode> newImports,
151out var externContainer, out var usingContainer, out var aliasContainer, out var staticUsingContainer);
153var newRoot = Rewrite(
161protected abstract SyntaxNode Rewrite(
163SyntaxNode externContainer, SyntaxNode usingContainer, SyntaxNode staticUsingContainer, SyntaxNode aliasContainer,
164AddImportPlacementOptions options, SyntaxNode root, CancellationToken cancellationToken);
166private void GetContainers(SyntaxNode root, SyntaxNode contextLocation, AddImportPlacementOptions options, out SyntaxNode externContainer, out SyntaxNode usingContainer, out SyntaxNode staticUsingContainer, out SyntaxNode aliasContainer)
168var applicableContainer = GetFirstApplicableContainer(contextLocation);
169var contextSpine = applicableContainer.GetAncestorsOrThis<SyntaxNode>().ToImmutableArray();
194private static SyntaxNode? GetFirstApplicableContainer(SyntaxNode contextNode)
200(SyntaxNode?)node.GetAncestorOrThis<TCompilationUnitSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\IAddImportsService.cs (15)
29bool HasExistingImport(Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, SyntaxGenerator generator);
35SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, AddImportPlacementOptions options);
37SyntaxNode AddImports(
38Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation,
39IEnumerable<SyntaxNode> newImports, SyntaxGenerator generator, AddImportPlacementOptions options, CancellationToken cancellationToken);
44public static SyntaxNode AddImport(
45this IAddImportsService service, Compilation compilation, SyntaxNode root,
46SyntaxNode contextLocation, SyntaxNode newImport, SyntaxGenerator generator, AddImportPlacementOptions options,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (14)
26where TStatementSyntax : SyntaxNode
28where TVariableDeclaratorSyntax : SyntaxNode
30protected abstract bool IsMeaningfulBlock(SyntaxNode node);
31protected abstract bool CanMoveToBlock(ILocalSymbol localSymbol, SyntaxNode currentBlock, SyntaxNode destinationBlock);
32protected abstract SyntaxNode GetVariableDeclaratorSymbolNode(TVariableDeclaratorSyntax variableDeclarator);
35protected abstract Task<bool> TypesAreCompatibleAsync(Document document, ILocalSymbol localSymbol, TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode right, CancellationToken cancellationToken);
37public async Task<bool> CanMoveDeclarationNearReferenceAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
43private async Task<State> ComputeStateAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
74Document document, SyntaxNode localDeclarationStatement, CancellationToken cancellationToken)
82var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
112var newRoot = editor.GetChangedRoot();
149var originalNextStatement = state.OutermostBlockStatements[statementIndex + 1];
185var blocks = state.InnermostBlock.GetAncestorsOrThis<SyntaxNode>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (35)
40SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
48SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
56SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
64SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
73SyntaxNode location, SyntaxNode containerOpt,
91protected virtual IEnumerable<ISymbol> GetCollidableSymbols(SemanticModel semanticModel, SyntaxNode location, SyntaxNode container, CancellationToken cancellationToken)
179public bool IsWrittenTo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
182public bool IsOnlyWrittenTo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
185public bool IsInOutContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
188public bool IsInRefContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
191public bool IsInInContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
194public bool CanReplaceWithRValue(SemanticModel semanticModel, SyntaxNode expression, CancellationToken cancellationToken)
203public bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, out SemanticModel speculativeModel)
209public ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode forEachStatement)
212public SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
215public IMethodSymbol GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
227public IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken)
230public IParameterSymbol FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
233public IParameterSymbol FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
236public ISymbol FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken)
239public ISymbol FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken)
242public ImmutableArray<ISymbol> GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode node, SyntaxToken token, CancellationToken cancellationToken)
245public bool IsInsideNameOfExpression(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
251public bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, INamedTypeSymbol expressionTypeOpt, CancellationToken cancellationToken)
254public string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken)
257public IPreprocessingSymbol GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\ISemanticFactsService.cs (12)
27SemanticModel semanticModel, SyntaxNode location,
28SyntaxNode? container, string baseName, CancellationToken cancellationToken);
31SemanticModel semanticModel, SyntaxNode location,
32SyntaxNode? container, string baseName, IEnumerable<string> usedNames, CancellationToken cancellationToken);
34SyntaxToken GenerateUniqueName(SemanticModel semanticModel, SyntaxNode location, SyntaxNode? container, string baseName,
38SemanticModel semanticModel, SyntaxNode location,
39SyntaxNode? container, string baseName, CancellationToken cancellationToken);
42SemanticModel semanticModel, SyntaxNode location,
43SyntaxNode? container, string baseName, IEnumerable<string> usedNames, CancellationToken cancellationToken);
47CommonConversion ClassifyConversion(SemanticModel semanticModel, SyntaxNode expression, ITypeSymbol destination);
49IMethodSymbol? TryGetDisposeMethod(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SyntaxGeneratorInternalExtensions\SyntaxGeneratorInternal.cs (68)
36public abstract SyntaxNode LocalDeclarationStatement(
37SyntaxNode? type, SyntaxToken identifier, SyntaxNode? initializer = null, bool isConst = false);
42public SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initializer)
45public abstract SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer);
47public abstract SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value);
51public abstract SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull);
53public abstract SyntaxNode MemberBindingExpression(SyntaxNode name);
55public abstract SyntaxNode RefExpression(SyntaxNode expression);
60public abstract SyntaxNode AddParentheses(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true);
66public abstract SyntaxNode YieldReturnStatement(SyntaxNode expression);
71/// <see cref="LocalDeclarationStatement(SyntaxNode, SyntaxToken, SyntaxNode, bool)"/>.
77public abstract SyntaxNode InterpolatedStringText(SyntaxToken textToken);
78public abstract SyntaxNode Interpolation(SyntaxNode syntaxNode);
79public abstract SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken);
80public abstract SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment);
81public abstract SyntaxNode InterpolationFormatClause(string format);
82public abstract SyntaxNode TypeParameterList(IEnumerable<string> typeParameterNames);
99public abstract SyntaxNode Type(ITypeSymbol typeSymbol, bool typeContext);
101public abstract SyntaxNode NegateEquality(SyntaxGenerator generator, SyntaxNode binaryExpression, SyntaxNode left, BinaryOperatorKind negatedKind, SyntaxNode right);
103public abstract SyntaxNode IsNotTypeExpression(SyntaxNode expression, SyntaxNode type);
108public abstract SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isToken, SyntaxNode pattern);
110public abstract SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right);
111public abstract SyntaxNode ConstantPattern(SyntaxNode expression);
112public abstract SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name);
113public abstract SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression);
114public abstract SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression);
115public abstract SyntaxNode LessThanRelationalPattern(SyntaxNode expression);
116public abstract SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression);
117public abstract SyntaxNode NotPattern(SyntaxNode pattern);
118public abstract SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right);
119public abstract SyntaxNode ParenthesizedPattern(SyntaxNode pattern);
120public abstract SyntaxNode TypePattern(SyntaxNode type);
121public abstract SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\AbstractSimplificationService.cs (31)
26where TCompilationUnitSyntax : SyntaxNode
27where TExpressionSyntax : SyntaxNode
28where TStatementSyntax : SyntaxNode
29where TCrefSyntax : SyntaxNode
31protected static readonly Func<SyntaxNode, bool> s_containsAnnotations = n => n.ContainsAnnotations;
39protected abstract ImmutableArray<NodeOrTokenToReduce> GetNodesAndTokensToReduce(SyntaxNode root, Func<SyntaxNodeOrToken, bool> isNodeOrTokenOutsideSimplifySpans);
40protected abstract SemanticModel GetSpeculativeSemanticModel(ref SyntaxNode nodeToSpeculate, SemanticModel originalSemanticModel, SyntaxNode originalNode);
41protected abstract bool NodeRequiresNonSpeculativeSemanticModel(SyntaxNode node);
42protected abstract void AddImportDeclarations(TCompilationUnitSyntax root, ArrayBuilder<SyntaxNode> importDeclarations);
47protected virtual SyntaxNode TransformReducedNode(SyntaxNode reducedNode, SyntaxNode originalNode)
50public abstract SyntaxNode Expand(SyntaxNode node, SemanticModel semanticModel, SyntaxAnnotation? annotationForReplacedAliasIdentifier, Func<SyntaxNode, bool>? expandInsideNode, bool expandParameter, CancellationToken cancellationToken);
51public abstract SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Func<SyntaxNode, bool>? expandInsideNode, CancellationToken cancellationToken);
76var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
137var reducedNodesMap = new ConcurrentDictionary<SyntaxNode, SyntaxNode>();
174SyntaxNode root,
178ConcurrentDictionary<SyntaxNode, SyntaxNode> reducedNodesMap,
240var replacedParent = isNode
251var currentNode = currentNodeOrToken.AsNode()!;
256var newRoot = root.ReplaceNode(nodeOrToken.AsNode()!, currentNode.WithAdditionalAnnotations(marker));
299using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var importDeclarations);
314var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
316var unusedImports = new HashSet<SyntaxNode>();
325var newRoot = gen.RemoveNodes(root, unusedImports);
334protected abstract void GetUnusedNamespaceImports(SemanticModel model, HashSet<SyntaxNode> namespaceImports, CancellationToken cancellationToken);
Binder\Binder.ValueChecks.cs (31)
674internal bool CheckValueKind(SyntaxNode node, BoundExpression expr, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
954bool checkArrayAccessValueKind(SyntaxNode node, BindValueKind valueKind, ImmutableArray<BoundExpression> indices, BindingDiagnosticBag diagnostics)
976private static void ReportThisLvalueError(SyntaxNode node, BindValueKind valueKind, bool isValueType, bool isPrimaryConstructorParameter, BindingDiagnosticBag diagnostics)
1004private void CheckAddressOfInAsyncOrIteratorMethod(SyntaxNode node, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
1019private bool CheckLocalValueKind(SyntaxNode node, BoundLocal local, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1064private bool CheckLocalRefEscape(SyntaxNode node, BoundLocal local, SafeContext escapeTo, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1109private bool CheckParameterValueKind(SyntaxNode node, BoundParameter parameter, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1172static void reportReadOnlyParameterError(ParameterSymbol parameterSymbol, SyntaxNode node, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1256private bool CheckParameterValEscape(SyntaxNode node, ParameterSymbol parameter, SafeContext escapeTo, BindingDiagnosticBag diagnostics)
1274private bool CheckParameterRefEscape(SyntaxNode node, BoundExpression parameter, ParameterSymbol parameterSymbol, SafeContext escapeTo, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1317private bool CheckFieldValueKind(SyntaxNode node, BoundFieldAccess fieldAccess, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1457private bool CheckSimpleAssignmentValueKind(SyntaxNode node, BoundAssignmentOperator assignment, BindValueKind valueKind, BindingDiagnosticBag diagnostics)
1495private bool CheckFieldRefEscape(SyntaxNode node, BoundFieldAccess fieldAccess, SafeContext escapeFrom, SafeContext escapeTo, BindingDiagnosticBag diagnostics)
1519private bool CheckFieldLikeEventRefEscape(SyntaxNode node, BoundEventAccess eventAccess, SafeContext escapeFrom, SafeContext escapeTo, BindingDiagnosticBag diagnostics)
1544SyntaxNode eventSyntax = GetEventName(boundEvent); //does not include receiver
1605private bool CheckIsValidReceiverForVariable(SyntaxNode node, BoundExpression receiver, BindValueKind kind, BindingDiagnosticBag diagnostics)
1633SyntaxNode callSyntaxOpt,
1634SyntaxNode node,
1676private bool CheckPropertyValueKind(SyntaxNode node, BoundExpression expr, BindValueKind valueKind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
1684SyntaxNode propertySyntax;
1899private bool IsBadBaseAccess(SyntaxNode node, BoundExpression receiverOpt, Symbol member, BindingDiagnosticBag diagnostics,
2111SyntaxNode syntax,
2204SyntaxNode syntax,
2728SyntaxNode syntax,
2769SyntaxNode syntax,
2869SyntaxNode syntax,
3064private static void ReportReadonlyLocalError(SyntaxNode node, LocalSymbol local, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3223private static void ReportReadOnlyFieldError(FieldSymbol field, SyntaxNode node, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3259private static void ReportReadOnlyError(Symbol symbol, SyntaxNode node, BindValueKind kind, bool checkingReceiver, BindingDiagnosticBag diagnostics)
3625internal bool CheckRefEscape(SyntaxNode node, BoundExpression expr, SafeContext escapeFrom, SafeContext escapeTo, bool checkingReceiver, BindingDiagnosticBag diagnostics)
4703internal bool CheckValEscape(SyntaxNode node, BoundExpression expr, SafeContext escapeFrom, SafeContext escapeTo, bool checkingReceiver, BindingDiagnosticBag diagnostics)
Binder\Binder_Await.cs (10)
28private BoundAwaitExpression BindAwait(BoundExpression expression, SyntaxNode node, BindingDiagnosticBag diagnostics)
51internal BoundAwaitableInfo BindAwaitInfo(BoundAwaitableValuePlaceholder placeholder, SyntaxNode node, BindingDiagnosticBag diagnostics, ref bool hasErrors, BoundExpression? expressionOpt = null)
120var syntax = expression.Syntax;
245SyntaxNode node,
259SyntaxNode node,
295private static bool ValidateAwaitedExpression(BoundExpression expression, SyntaxNode node, BindingDiagnosticBag diagnostics)
323private bool GetGetAwaiterMethod(BoundExpression expression, SyntaxNode node, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out BoundExpression? getAwaiterCall)
368private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, TypeSymbol awaitedExpressionType, BindingDiagnosticBag diagnostics, [NotNullWhen(true)] out PropertySymbol? isCompletedProperty)
411private bool AwaiterImplementsINotifyCompletion(TypeSymbol awaiterType, SyntaxNode node, BindingDiagnosticBag diagnostics)
435private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode node, TypeSymbol awaitedExpressionType, BindingDiagnosticBag diagnostics, out MethodSymbol? getResultMethod, [NotNullWhen(true)] out BoundExpression? getAwaiterGetResultCall)
Binder\Binder_Conversions.cs (6)
42SyntaxNode syntax,
54SyntaxNode syntax,
96SyntaxNode syntax,
300void reportUseSiteDiagnostics(SyntaxNode syntax, Conversion conversion, BoundExpression source, TypeSymbol destination, BindingDiagnosticBag diagnostics)
314void ensureAllUnderlyingConversionsChecked(SyntaxNode syntax, BoundExpression source, Conversion conversion, bool wasCompilerGenerated, TypeSymbol destination, BindingDiagnosticBag diagnostics)
407void checkConstraintLanguageVersionAndRuntimeSupportForConversion(SyntaxNode syntax, Conversion conversion, BoundExpression source, TypeSymbol destination, BindingDiagnosticBag diagnostics)
Binder\Binder_Deconstruct.cs (7)
244SyntaxNode syntax,
245SyntaxNode rightSyntax,
436internal DeconstructionVariable(BoundExpression variable, SyntaxNode syntax)
443internal DeconstructionVariable(ArrayBuilder<DeconstructionVariable> variables, SyntaxNode syntax)
614SyntaxNode rightSyntax,
714private BoundBadExpression MissingDeconstruct(BoundExpression receiver, SyntaxNode rightSyntax, int numParameters, BindingDiagnosticBag diagnostics,
852SyntaxNode syntax,
Binder\Binder_Expressions.cs (105)
106private BoundBadExpression BadExpression(SyntaxNode syntax)
114private BoundBadExpression BadExpression(SyntaxNode syntax, BoundExpression childNode)
122private BoundBadExpression BadExpression(SyntaxNode syntax, ImmutableArray<BoundExpression> childNodes)
130protected BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind lookupResultKind)
138protected BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind lookupResultKind, BoundExpression childNode)
146private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols)
159private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols, BoundExpression childNode)
172private BoundBadExpression BadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol> symbols, ImmutableArray<BoundExpression> childNodes, bool wasCompilerGenerated = false)
413var syntax = expr.Syntax;
455TryGetPrimaryConstructorParameterUsedAsValue(primaryConstructor, result) is (ParameterSymbol parameter, SyntaxNode syntax) &&
1199private static string InferTupleElementName(SyntaxNode syntax)
2209var declarator = localSymbol.GetDeclaratorSyntax();
2245private BoundExpression SynthesizeReceiver(SyntaxNode node, Symbol member, BindingDiagnosticBag diagnostics)
2321private BoundExpression TryBindInteractiveReceiver(SyntaxNode syntax, NamedTypeSymbol memberDeclaringType)
2472private BoundThisReference ThisReference(SyntaxNode node, NamedTypeSymbol thisTypeOpt, bool hasErrors = false, bool wasCompilerGenerated = false)
2721SyntaxNode syntax,
2931private static NameSyntax GetNameSyntax(SyntaxNode syntax)
2944internal static NameSyntax GetNameSyntax(SyntaxNode syntax, out string nameString)
3245internal static void CheckRestrictedTypeInAsyncMethod(Symbol containingSymbol, TypeSymbol type, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
3260internal GlobalExpressionVariable LookupDeclaredField(SyntaxNode node, string identifier)
3376SyntaxNode node,
3591SyntaxNode node,
3853SyntaxNode placeholderSyntax;
4522private bool ReportBadStackAllocPosition(SyntaxNode node, BindingDiagnosticBag diagnostics)
4547private TypeSymbol GetStackAllocType(SyntaxNode node, TypeWithAnnotations elementTypeWithAnnotations, BindingDiagnosticBag diagnostics, out bool hasErrors)
4573static bool isStackallocTargetTyped(SyntaxNode node)
4577SyntaxNode equalsValueClause = node.Parent;
4584SyntaxNode variableDeclarator = equalsValueClause.Parent;
4591SyntaxNode variableDeclaration = variableDeclarator.Parent;
4604SyntaxNode node,
4984if (TryGetPrimaryConstructorParameterUsedAsValue(primaryConstructor, analyzedArguments.Argument(i)) is (ParameterSymbol parameter, SyntaxNode syntax))
5079private static (ParameterSymbol, SyntaxNode) TryGetPrimaryConstructorParameterUsedAsValue(SynthesizedPrimaryConstructor primaryConstructor, BoundExpression boundExpression)
5290private BoundExpression BindDelegateCreationExpression(SyntaxNode node, NamedTypeSymbol type, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped, BindingDiagnosticBag diagnostics)
5497SyntaxNode node,
5538private BoundExpression MakeBadExpressionForObjectCreation(SyntaxNode node, TypeSymbol type, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax? initializerOpt, SyntaxNode? typeSyntax, BindingDiagnosticBag diagnostics, bool wasCompilerGenerated = false)
5559SyntaxNode typeSyntax,
5592SyntaxNode typeSyntax,
6063var memberInitializerSyntax = boundMemberInitializer.Syntax;
6096SyntaxNode creationSyntax,
6159private static void ReportMembersRequiringInitialization(SyntaxNode creationSyntax, ImmutableSegmentedDictionary<string, Symbol>.Builder requiredMembersBuilder, BindingDiagnosticBag diagnostics)
6360SyntaxNode elementInitializer,
6412SyntaxNode elementInitializer,
6614SyntaxNode node,
6616SyntaxNode typeNode,
6711SyntaxNode node,
6712SyntaxNode typeNode,
6796SyntaxNode node,
6797SyntaxNode typeNode,
6855private BoundObjectInitializerExpressionBase MakeBoundInitializerOpt(SyntaxNode typeNode, NamedTypeSymbol type, InitializerExpressionSyntax initializerSyntaxOpt, TypeSymbol initializerTypeOpt, BindingDiagnosticBag diagnostics)
6877private BoundExpression BindInterfaceCreationExpression(SyntaxNode node, NamedTypeSymbol type, BindingDiagnosticBag diagnostics, SyntaxNode typeNode, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped)
6903private BoundExpression BindComImportCoClassCreationExpression(SyntaxNode node, NamedTypeSymbol interfaceType, NamedTypeSymbol coClassType, BindingDiagnosticBag diagnostics, SyntaxNode typeNode, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax initializerOpt, bool wasTargetTyped)
6985SyntaxNode node,
6989SyntaxNode typeNode,
7036private static bool TypeParameterHasParameterlessConstructor(SyntaxNode node, TypeParameterSymbol typeParameter, BindingDiagnosticBag diagnostics)
7048SyntaxNode node, TypeParameterSymbol typeParameter, AnalyzedArguments analyzedArguments, InitializerExpressionSyntax? initializerOpt,
7049SyntaxNode typeSyntax, bool wasTargetTyped, BindingDiagnosticBag diagnostics)
7875private void WarnOnAccessOfOffDefault(SyntaxNode node, BoundExpression boundLeft, BindingDiagnosticBag diagnostics)
7924SyntaxNode node,
7925SyntaxNode right,
8022var nameSyntax = node.NameSyntax;
8032SyntaxNode node,
8033SyntaxNode name,
8113var nameSyntax = node.NameSyntax;
8122SyntaxNode node,
8221SyntaxNode node,
8222SyntaxNode right,
8340SyntaxNode expression,
8462SyntaxNode node,
8514SyntaxNode node,
8674SyntaxNode node,
8694private void CheckReceiverAndRuntimeSupportForSymbolAccess(SyntaxNode node, BoundExpression receiverOpt, Symbol symbol, BindingDiagnosticBag diagnostics)
8754SyntaxNode node,
8800SyntaxNode node,
8850private Symbol GetSymbolOrMethodOrPropertyGroup(LookupResult result, SyntaxNode node, string plainName, int arity, ArrayBuilder<Symbol> methodOrPropertyGroup, BindingDiagnosticBag diagnostics, out bool wasError, NamespaceOrTypeSymbol qualifierOpt)
9209static void checkInlineArrayBounds(SyntaxNode location, int index, int end, bool excludeEnd, BindingDiagnosticBag diagnostics)
9219SyntaxNode location;
9229internal static int? InferConstantIndexFromSystemIndex(CSharpCompilation compilation, BoundExpression convertedIndex, int length, out SyntaxNode location)
9262private BoundExpression BadIndexerExpression(SyntaxNode node, BoundExpression expr, AnalyzedArguments analyzedArguments, DiagnosticInfo errorOpt, BindingDiagnosticBag diagnostics)
9274SyntaxNode node,
9308private BoundExpression BindArrayAccess(SyntaxNode node, BoundExpression expr, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
9406var node = index.Syntax;
9458private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, WellKnownType wellKnownType, SyntaxNode node, BindingDiagnosticBag diagnostics)
9479private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, SpecialType specialType, SyntaxNode node, BindingDiagnosticBag diagnostics)
9496private BoundExpression TryImplicitConversionToArrayIndex(BoundExpression expr, TypeSymbol targetType, SyntaxNode node, BindingDiagnosticBag diagnostics)
9520private BoundExpression BindPointerElementAccess(SyntaxNode node, BoundExpression expr, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
9581private BoundExpression BindIndexerAccess(SyntaxNode node, BoundExpression expr, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
9653var syntax = propertyGroup.Syntax;
9681private BoundExpression BindIndexedPropertyAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<PropertySymbol> propertyGroup, AnalyzedArguments arguments, BindingDiagnosticBag diagnostics)
9695SyntaxNode syntax,
9739SyntaxNode syntax,
9779SyntaxNode syntax,
9886SyntaxNode syntax,
9971SyntaxNode syntax,
10004SyntaxNode syntax,
10109void makeCall(SyntaxNode syntax, BoundExpression receiver, MethodSymbol method,
10142SyntaxNode syntax,
10167SyntaxNode syntax,
10182bool tryLookupLengthOrCount(SyntaxNode syntax, string propertyName, [NotNullWhen(true)] out PropertySymbol? valid, BindingDiagnosticBag diagnostics)
10260SyntaxNode expression,
10308SyntaxNode expression,
10793SyntaxNode syntax,
10905Location location = null, SyntaxNode node = null)
Binder\Binder_InterpolatedString.cs (5)
339SyntaxNode syntax = unconvertedSource.Syntax;
370ImmutableArray<BoundExpression> makeInterpolatedStringFactoryArguments(SyntaxNode syntax, ImmutableArray<BoundExpression> parts, BindingDiagnosticBag diagnostics)
515private BoundBinaryOperator UpdateBinaryOperatorWithInterpolatedContents(BoundBinaryOperator originalOperator, ImmutableArray<ImmutableArray<BoundExpression>> appendCalls, InterpolatedStringHandlerData data, SyntaxNode rootSyntax, BindingDiagnosticBag diagnostics)
633SyntaxNode syntax,
817static void populateArguments(SyntaxNode syntax, ImmutableArray<BoundInterpolatedStringArgumentPlaceholder> additionalConstructorArguments, int baseStringLength, int numFormatHoles, NamedTypeSymbol intType, ArrayBuilder<BoundExpression> argumentsBuilder)
Binder\Binder_Invocation.cs (30)
78SyntaxNode node,
158private static void ReportMakeInvocationExpressionBadMemberKind(SyntaxNode node, string methodName, BoundExpression boundExpression, BindingDiagnosticBag diagnostics)
321SyntaxNode node,
322SyntaxNode expression,
391SyntaxNode node,
543SyntaxNode node,
621SyntaxNode node,
622SyntaxNode expression,
677private void ReportMemberNotSupportedByDynamicDispatch<TMember>(SyntaxNode syntax, MemberResolutionResult<TMember> candidate, BindingDiagnosticBag diagnostics)
690SyntaxNode syntax,
691SyntaxNode expression,
846private void ReportDynamicInvocationWarnings(SyntaxNode syntax, BoundMethodGroup methodGroup, BindingDiagnosticBag diagnostics, ImmutableArray<MemberResolutionResult<MethodSymbol>> finalApplicableCandidates)
856private bool IsAmbiguousDynamicParamsArgument<TMethodOrPropertySymbol>(ArrayBuilder<BoundExpression> arguments, MemberResolutionResult<TMethodOrPropertySymbol> candidate, out SyntaxNode argumentSyntax)
882SyntaxNode syntax,
916if (IsAmbiguousDynamicParamsArgument(resolution.AnalyzedArguments.Arguments, methodResolutionResult, out SyntaxNode argumentSyntax))
935SyntaxNode syntax,
936SyntaxNode expression,
971SyntaxNode syntax,
1099SyntaxNode node,
1100SyntaxNode expression,
1348private static SourceLocation GetCallerLocation(SyntaxNode syntax)
1363private BoundExpression GetDefaultParameterSpecialNoConversion(SyntaxNode syntax, ParameterSymbol parameter, BindingDiagnosticBag diagnostics)
1464SyntaxNode node,
1597BoundExpression bindDefaultArgument(SyntaxNode syntax, ParameterSymbol parameter, Symbol? containingMember, bool enableCallerInfo, BindingDiagnosticBag diagnostics, ArrayBuilder<BoundExpression> argumentsBuilder, int argumentsCount, ImmutableArray<int> argsToParamsOpt)
1717private BoundExpression CreateParamsCollection(SyntaxNode node, ParameterSymbol paramsParameter, ImmutableArray<BoundExpression> collectionArgs, BindingDiagnosticBag diagnostics)
1802private static Location GetLocationForOverloadResolutionDiagnostic(SyntaxNode node, SyntaxNode expression)
1913SyntaxNode node,
2167SyntaxNode node,
2342private BoundFunctionPointerInvocation BindFunctionPointerInvocation(SyntaxNode node, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
Binder\Binder_Operators.cs (4)
2380private bool CheckConstraintLanguageVersionAndRuntimeSupportForOperator(SyntaxNode node, MethodSymbol? methodOpt, bool isUnsignedRightShift, TypeSymbol? constrainedToTypeOpt, BindingDiagnosticBag diagnostics)
4375private void ValidateRefConditionalOperator(SyntaxNode node, BoundExpression trueExpr, BoundExpression falseExpr, BindingDiagnosticBag diagnostics)
4434private void CheckNativeIntegerFeatureAvailability(BinaryOperatorKind operatorKind, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
4450private void CheckNativeIntegerFeatureAvailability(UnaryOperatorKind operatorKind, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
Binder\Binder_Patterns.cs (9)
46SyntaxNode node,
346private bool IsCountableAndIndexable(SyntaxNode node, TypeSymbol inputType, out PropertySymbol? lengthProperty)
354private bool BindLengthAndIndexerForListPattern(SyntaxNode node, TypeSymbol inputType, BindingDiagnosticBag diagnostics,
417SyntaxNode node,
722SyntaxNode typeSyntax,
896CheckRestrictedTypeInAsyncMethod(this.ContainingMemberOrLambda, declType.Type, diagnostics, typeSyntax ?? (SyntaxNode)designation);
1234SyntaxNode node,
1296private static FieldSymbol? CheckIsTupleElement(SyntaxNode node, NamedTypeSymbol tupleType, string name, int tupleIndex, BindingDiagnosticBag diagnostics)
1797TypeSymbol? leastSpecificType(SyntaxNode node, ArrayBuilder<TypeSymbol> candidates, BindingDiagnosticBag diagnostics)
Binder\Binder_Statements.cs (21)
754internal MethodSymbol TryFindDisposePatternMethod(BoundExpression expr, SyntaxNode syntaxNode, bool hasAwait, BindingDiagnosticBag diagnostics, out bool isExpanded)
1233SyntaxNode initializerSyntax = initializerOpt.Syntax;
1363SyntaxNode initializerSyntax = initializer.Syntax;
1474SyntaxNode node,
1531SyntaxNode node,
1625internal static PropertySymbol GetPropertySymbol(BoundExpression expr, out BoundExpression receiver, out SyntaxNode propertySyntax)
1678var syntax = expr.Syntax;
1724private static SyntaxNode GetEventName(BoundEventAccess expr)
1726SyntaxNode syntax = expr.Syntax;
1994private static Location GetAnonymousFunctionLocation(SyntaxNode node)
2002internal void GenerateAnonymousFunctionConversionError(BindingDiagnosticBag diagnostics, SyntaxNode syntax,
2231protected static void GenerateImplicitConversionError(BindingDiagnosticBag diagnostics, CSharpCompilation compilation, SyntaxNode syntax,
2301SyntaxNode syntax,
2446var nodeForError = syntax;
3127SyntaxNode syntax,
3372private void ReportCantConvertLambdaReturn(SyntaxNode syntax, BindingDiagnosticBag diagnostics)
3399private static Location GetLocationForDiagnostics(SyntaxNode node)
3416private static bool IsValidStatementExpression(SyntaxNode syntax, BoundExpression expression)
3535private static bool IsValidExpressionBody(SyntaxNode expressionSyntax, BoundExpression expression)
3781internal BoundExpressionStatement? BindImplicitConstructorInitializer(SyntaxNode ctorSyntax, BindingDiagnosticBag diagnostics)
4098SyntaxNode syntaxNode, BindingDiagnosticBag diagnostics, out MethodSymbol result, out bool isExpanded)
Binder\Binder_Symbols.cs (24)
192private NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAliasOrKeyword(SyntaxToken identifier, SyntaxNode syntax, BindingDiagnosticBag diagnostics, out bool isKeyword)
1094private NamespaceOrTypeOrAliasSymbolWithAnnotations UnwrapAlias(in NamespaceOrTypeOrAliasSymbolWithAnnotations symbol, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
1105private NamespaceOrTypeOrAliasSymbolWithAnnotations UnwrapAlias(in NamespaceOrTypeOrAliasSymbolWithAnnotations symbol, out AliasSymbol alias, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
1116private Symbol UnwrapAlias(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
1122private Symbol UnwrapAlias(Symbol symbol, out AliasSymbol alias, BindingDiagnosticBag diagnostics, SyntaxNode syntax, ConsList<TypeSymbol> basesBeingResolved = null)
1372private NamedTypeSymbol ConstructNamedTypeUnlessTypeArgumentOmitted(SyntaxNode typeSyntax, NamedTypeSymbol type, SeparatedSyntaxList<TypeSyntax> typeArgumentsSyntax, ImmutableArray<TypeWithAnnotations> typeArguments, BindingDiagnosticBag diagnostics)
1416SyntaxNode syntax,
1570SyntaxNode typeSyntax,
1649internal NamedTypeSymbol GetSpecialType(SpecialType typeId, BindingDiagnosticBag diagnostics, SyntaxNode node)
1654internal static NamedTypeSymbol GetSpecialType(CSharpCompilation compilation, SpecialType typeId, SyntaxNode node, BindingDiagnosticBag diagnostics)
1674internal Symbol GetSpecialTypeMember(SpecialMember member, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1679internal static Symbol GetSpecialTypeMember(CSharpCompilation compilation, SpecialMember member, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1687internal static bool TryGetSpecialTypeMember<TSymbol>(CSharpCompilation compilation, SpecialMember specialMember, SyntaxNode syntax, BindingDiagnosticBag diagnostics, out TSymbol symbol, bool isOptional = false)
1743internal static bool ReportUseSite(Symbol symbol, BindingDiagnosticBag diagnostics, SyntaxNode node)
1768internal NamedTypeSymbol GetWellKnownType(WellKnownType type, BindingDiagnosticBag diagnostics, SyntaxNode node)
1786internal static NamedTypeSymbol GetWellKnownType(CSharpCompilation compilation, WellKnownType type, BindingDiagnosticBag diagnostics, SyntaxNode node)
1811internal Symbol GetWellKnownTypeMember(WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
1820internal static Symbol GetWellKnownTypeMember(CSharpCompilation compilation, WellKnownMember member, BindingDiagnosticBag diagnostics, Location location = null, SyntaxNode syntax = null, bool isOptional = false)
1906SyntaxNode where,
1935SyntaxNode where,
2304SyntaxNode node = where;
2545private CSDiagnosticInfo NotFound(SyntaxNode where, string simpleName, int arity, string whereText, BindingDiagnosticBag diagnostics, string aliasOpt, NamespaceOrTypeSymbol qualifierOpt, LookupOptions options)
2736internal static bool CheckFeatureAvailability(SyntaxNode syntax, MessageID feature, BindingDiagnosticBag diagnostics, Location? location = null)
2745private static bool CheckFeatureAvailability(SyntaxNode syntax, MessageID feature, DiagnosticBag? diagnostics, Location? location = null)
Binder\DecisionDagBuilder.cs (19)
83SyntaxNode syntax,
99SyntaxNode syntax,
115SyntaxNode syntax,
128SyntaxNode syntax,
142SyntaxNode syntax,
167SyntaxNode syntax,
185SyntaxNode syntax,
324var syntax = pattern.Syntax;
432SyntaxNode syntax,
450SyntaxNode syntax,
540SyntaxNode syntax = pattern.Syntax;
561SyntaxNode syntax = pattern.Syntax;
737private BoundDecisionDag MakeBoundDecisionDag(SyntaxNode syntax, ref TemporaryArray<StateForCase> cases)
1033BoundDecisionDagNode finalState(SyntaxNode syntax, LabelSymbol label, ImmutableArray<BoundPatternBinding> bindings)
1246SyntaxNode syntax,
1410SyntaxNode syntax,
1988public readonly SyntaxNode Syntax;
1995SyntaxNode Syntax,
2146SyntaxNode syntax = test.Syntax;
Binder\ExecutableCodeBinder.cs (10)
28private readonly SyntaxNode _root;
29private readonly Action<Binder, SyntaxNode> _binderUpdatedHandler;
30private SmallDictionary<SyntaxNode, Binder> _lazyBinderMap;
32internal ExecutableCodeBinder(SyntaxNode root, Symbol memberSymbol, Binder next, Action<Binder, SyntaxNode> binderUpdatedHandler = null)
38internal ExecutableCodeBinder(SyntaxNode root, Symbol memberSymbol, Binder next, BinderFlags additionalFlags)
58internal override Binder GetBinder(SyntaxNode node)
66SmallDictionary<SyntaxNode, Binder> map;
83map = SmallDictionary<SyntaxNode, Binder>.Empty;
90private SmallDictionary<SyntaxNode, Binder> BinderMap
Binder\ExpressionVariableFinder.cs (10)
21private SyntaxNode _nodeToBind;
76SyntaxNode previousNodeToBind = _nodeToBind;
105SyntaxNode previousNodeToBind = _nodeToBind;
146SyntaxNode previousNodeToBind = _nodeToBind;
287protected abstract TFieldOrLocalSymbol MakePatternVariable(TypeSyntax type, SingleVariableDesignationSyntax designation, SyntaxNode nodeToBind);
532protected abstract TFieldOrLocalSymbol MakeDeclarationExpressionVariable(DeclarationExpressionSyntax node, SingleVariableDesignationSyntax designation, BaseArgumentListSyntax argumentListSyntax, SyntaxNode nodeToBind);
592protected override LocalSymbol MakePatternVariable(TypeSyntax type, SingleVariableDesignationSyntax designation, SyntaxNode nodeToBind)
618protected override LocalSymbol MakeDeclarationExpressionVariable(DeclarationExpressionSyntax node, SingleVariableDesignationSyntax designation, BaseArgumentListSyntax argumentListSyntaxOpt, SyntaxNode nodeToBind)
705protected override Symbol MakePatternVariable(TypeSyntax type, SingleVariableDesignationSyntax designation, SyntaxNode nodeToBind)
713protected override Symbol MakeDeclarationExpressionVariable(DeclarationExpressionSyntax node, SingleVariableDesignationSyntax designation, BaseArgumentListSyntax argumentListSyntaxOpt, SyntaxNode nodeToBind)
Binder\ForEachLoopBinder.cs (32)
47internal override ImmutableArray<LocalSymbol> GetDeclaredLocalsForScope(SyntaxNode scopeDesignator)
62internal override SyntaxNode ScopeDesignator
105SyntaxNode deconstructionStatement,
142SyntaxNode deconstructionStatement,
660SyntaxNode syntax,
661SyntaxNode collectionSyntax,
706SyntaxNode exprSyntax = collectionExpr.Syntax;
756SyntaxNode syntax,
757SyntaxNode collectionSyntax,
812private EnumeratorResult GetEnumeratorInfoCore(SyntaxNode syntax, SyntaxNode collectionSyntax, ref BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, out ForEachEnumeratorInfo.Builder builder)
914EnumeratorResult getEnumeratorInfo(SyntaxNode syntax, SyntaxNode collectionSyntax, ref BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, out ForEachEnumeratorInfo.Builder builder)
1042private EnumeratorResult SatisfiesIEnumerableInterfaces(SyntaxNode collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, BoundExpression collectionExpr, bool isAsync, BindingDiagnosticBag diagnostics, TypeSymbol unwrappedCollectionExprType)
1054SyntaxNode errorLocationSyntax = collectionSyntax;
1185private void GetDisposalInfoForEnumerator(SyntaxNode syntax, ref ForEachEnumeratorInfo.Builder builder, BoundExpression expr, bool isAsync, BindingDiagnosticBag diagnostics)
1278private ForEachEnumeratorInfo.Builder GetDefaultEnumeratorInfo(SyntaxNode syntax, ForEachEnumeratorInfo.Builder builder, BindingDiagnosticBag diagnostics, TypeSymbol collectionExprType)
1323private bool SatisfiesGetEnumeratorPattern(SyntaxNode syntax, SyntaxNode collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, BoundExpression collectionExpr, bool isAsync, bool viaExtensionMethod, BindingDiagnosticBag diagnostics)
1352private MethodArgumentInfo FindForEachPatternMethod(SyntaxNode syntax, SyntaxNode collectionSyntax, TypeSymbol patternType, string methodName, LookupResult lookupResult, bool warningsOnly, BindingDiagnosticBag diagnostics, bool isAsync)
1419private MethodArgumentInfo PerformForEachPatternOverloadResolution(SyntaxNode syntax, SyntaxNode collectionSyntax, TypeSymbol patternType, ArrayBuilder<MethodSymbol> candidateMethods, bool warningsOnly, BindingDiagnosticBag diagnostics, bool isAsync)
1497private MethodArgumentInfo FindForEachPatternMethodViaExtension(SyntaxNode syntax, SyntaxNode collectionSyntax, BoundExpression collectionExpr, string methodName, BindingDiagnosticBag diagnostics)
1592private bool SatisfiesForEachPattern(SyntaxNode syntax, SyntaxNode collectionSyntax, ref ForEachEnumeratorInfo.Builder builder, bool isAsync, BindingDiagnosticBag diagnostics)
1710private void ReportEnumerableWarning(SyntaxNode collectionSyntax, BindingDiagnosticBag diagnostics, TypeSymbol enumeratorType, Symbol patternMemberCandidate)
1750SyntaxNode collectionSyntax,
1858private void ReportPatternMemberLookupDiagnostics(SyntaxNode collectionSyntax, LookupResult lookupResult, TypeSymbol patternType, string memberName, bool warningsOnly, BindingDiagnosticBag diagnostics)
1896private MethodArgumentInfo GetParameterlessSpecialTypeMemberInfo(SpecialMember member, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1906private MethodArgumentInfo BindDefaultArguments(MethodSymbol method, BoundExpression extensionReceiverOpt, bool expanded, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
BoundTree\Constructors.cs (48)
15SyntaxNode syntax,
25SyntaxNode syntax,
37SyntaxNode syntax,
87SyntaxNode syntax,
122SyntaxNode node,
168public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method)
173public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, BoundExpression arg0)
178public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, BoundExpression arg0, BoundExpression arg1)
183public static BoundCall Synthesized(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<RefKind> argumentRefKindsOpt = default)
253public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, params BoundExpression[] arguments)
257public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray<BoundExpression> arguments)
266SyntaxNode node,
291SyntaxNode syntax,
328public static BoundConversion SynthesizedNonUserDefined(SyntaxNode syntax, BoundExpression operand, Conversion conversion, TypeSymbol type, ConstantValue? constantValueOpt = null)
350SyntaxNode syntax,
376SyntaxNode syntax,
400SyntaxNode syntax,
428SyntaxNode syntax,
451SyntaxNode syntax,
487SyntaxNode syntax,
530public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol, bool hasErrors = false)
535public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol)
543public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
549public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
554public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
559public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, TypeSymbol type, bool hasErrors = false)
564public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, ImmutableArray<BoundExpression> dimensionsOpt, TypeWithAnnotations typeWithAnnotations, bool hasErrors = false)
572public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, bool hasErrors = false)
577public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol)
590public BoundAssignmentOperator(SyntaxNode syntax, BoundExpression left, BoundExpression right,
599public BoundBadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol?> symbols, ImmutableArray<BoundExpression> childBoundNodes, TypeSymbol type)
608public static BoundStatementList Synthesized(SyntaxNode syntax, params BoundStatement[] statements)
613public static BoundStatementList Synthesized(SyntaxNode syntax, bool hasErrors, params BoundStatement[] statements)
618public static BoundStatementList Synthesized(SyntaxNode syntax, ImmutableArray<BoundStatement> statements)
623public static BoundStatementList Synthesized(SyntaxNode syntax, bool hasErrors, ImmutableArray<BoundStatement> statements)
631public static BoundReturnStatement Synthesized(SyntaxNode syntax, RefKind refKind, BoundExpression expression, bool hasErrors = false)
639public static BoundYieldBreakStatement Synthesized(SyntaxNode syntax, bool hasErrors = false)
647public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors = false)
655public BoundBlock(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
660public static BoundBlock SynthesizedNoLocals(SyntaxNode syntax, BoundStatement statement)
666public static BoundBlock SynthesizedNoLocals(SyntaxNode syntax, ImmutableArray<BoundStatement> statements)
671public static BoundBlock SynthesizedNoLocals(SyntaxNode syntax, params BoundStatement[] statements)
679public BoundDefaultExpression(SyntaxNode syntax, TypeSymbol type, bool hasErrors = false)
687public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray<BoundCatchBlock> catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt = null)
695public BoundAddressOfOperator(SyntaxNode syntax, BoundExpression operand, TypeSymbol type, bool hasErrors = false)
703public BoundDagTemp(SyntaxNode syntax, TypeSymbol type, BoundDagEvaluation? source)
713public BoundCompoundAssignmentOperator(SyntaxNode syntax,
743SyntaxNode syntax,
BoundTree\UnboundLambda.cs (6)
24SyntaxNode Syntax { get; }
33SyntaxNode IBoundLambdaOrFunction.Syntax { get { return Syntax; } }
80SyntaxNode IBoundLambdaOrFunction.Syntax { get { return Syntax; } }
82public BoundLambda(SyntaxNode syntax, UnboundLambda unboundLambda, BoundBlock body, ReadOnlyBindingDiagnostic<AssemblySymbol> diagnostics, Binder binder, TypeSymbol? delegateType, InferredLambdaReturnType inferredReturnType)
420private UnboundLambda(SyntaxNode syntax, UnboundLambdaState state, FunctionTypeSymbol? functionType, bool withDependencies, NullableWalker.VariableState? nullableState, bool hasErrors) :
1502var syntax = UnboundLambda.Syntax;
CodeGen\EmitExpression.cs (14)
834var syntax = node.Syntax;
1431private void EmitLoadIndirect(TypeSymbol type, SyntaxNode syntaxNode)
3195private void EmitArrayElementStore(ArrayTypeSymbol arrayType, SyntaxNode syntaxNode)
3210private void EmitVectorElementStore(ArrayTypeSymbol arrayType, SyntaxNode syntaxNode)
3310private void EmitIndirectStore(TypeSymbol type, SyntaxNode syntaxNode)
3431private void EmitDefaultValue(TypeSymbol type, bool used, SyntaxNode syntaxNode)
3475private void EmitConstantExpression(TypeSymbol type, ConstantValue constantValue, bool used, SyntaxNode syntaxNode)
3491private void EmitInitObj(TypeSymbol type, bool used, SyntaxNode syntaxNode)
3573private void EmitHoistedVariableId(FieldSymbol field, SyntaxNode syntax)
3609private void EmitThrowIfModuleCancellationRequested(SyntaxNode syntax)
3631private void EmitModuleCancellationTokenLoad(SyntaxNode syntax)
3986private void EmitStaticCast(TypeSymbol to, SyntaxNode syntax)
4006private void EmitBox(TypeSymbol type, SyntaxNode syntaxNode)
4044private void EmitCallCleanup(SyntaxNode syntax, UseKind useKind, MethodSymbol method)
CodeGen\EmitStatement.cs (13)
1117var localSyntax = !declaringReferences.IsEmpty ? (CSharpSyntaxNode)declaringReferences[0].GetSyntax() : catchBlock.Syntax;
1344SyntaxNode syntaxNode,
1382void emitLengthDispatch(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1416void emitCharDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1454void emitFinalDispatches(LengthBasedStringSwitchData lengthBasedSwitchInfo, LocalOrParameter keyTemp, TypeSymbol keyType, LabelSymbol fallThroughLabel, SyntaxNode syntaxNode)
1483SyntaxNode syntaxNode,
1624private Cci.IMethodReference? GetLengthMethodRef(SyntaxNode syntaxNode, TypeSymbol keyType, bool isReadOnlySpan, bool isSpanOrReadOnlySpan)
1648private Microsoft.Cci.IMethodReference? GetIndexerRef(SyntaxNode syntaxNode, TypeSymbol keyType, bool isReadOnlySpan, bool isSpanOrReadOnlySpan)
1683private void EmitStringCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNode, ConstantValue stringConstant, object targetLabel, Microsoft.Cci.IReference stringEqualityMethodRef)
1721private void EmitCharCompareAndBranch(LocalOrParameter key, SyntaxNode syntaxNode, ConstantValue stringConstant, object targetLabel, Cci.IReference sequenceEqualsRef, Cci.IReference asSpanRef)
1756private LocalDefinition DefineLocal(LocalSymbol local, SyntaxNode syntaxNode)
1867var syntax = local.GetDeclaratorSyntax();
1900private LocalDefinition AllocateTemp(TypeSymbol type, SyntaxNode syntaxNode, LocalSlotConstraints slotConstraints = LocalSlotConstraints.None)
Compilation\CSharpSemanticModel.cs (35)
474protected override IOperation GetOperationCore(SyntaxNode node, CancellationToken cancellationToken)
1008public Conversion GetConversion(SyntaxNode expression, CancellationToken cancellationToken = default(CancellationToken))
1229internal abstract MemberSemanticModel GetMemberModel(SyntaxNode node);
1231internal bool IsInTree(SyntaxNode node)
1310protected int GetAdjustedNodePosition(SyntaxNode node)
1844var curr = token.Parent;
3973SyntaxNode parentSyntax = boundNodeForSyntacticParent.Syntax;
4948protected sealed override SyntaxNode RootCore => this.Root;
4950private SymbolInfo GetSymbolInfoFromNode(SyntaxNode node, CancellationToken cancellationToken)
4977private TypeInfo GetTypeInfoFromNode(SyntaxNode node, CancellationToken cancellationToken)
4998private ImmutableArray<ISymbol> GetMemberGroupFromNode(SyntaxNode node, CancellationToken cancellationToken)
5015protected sealed override ImmutableArray<ISymbol> GetMemberGroupCore(SyntaxNode node, CancellationToken cancellationToken)
5021protected sealed override SymbolInfo GetSpeculativeSymbolInfoCore(int position, SyntaxNode node, SpeculativeBindingOption bindingOption)
5040protected sealed override TypeInfo GetSpeculativeTypeInfoCore(int position, SyntaxNode node, SpeculativeBindingOption bindingOption)
5047protected sealed override IAliasSymbol GetSpeculativeAliasInfoCore(int position, SyntaxNode nameSyntax, SpeculativeBindingOption bindingOption)
5054protected sealed override SymbolInfo GetSymbolInfoCore(SyntaxNode node, CancellationToken cancellationToken)
5059protected sealed override TypeInfo GetTypeInfoCore(SyntaxNode node, CancellationToken cancellationToken)
5064protected sealed override IAliasSymbol GetAliasInfoCore(SyntaxNode node, CancellationToken cancellationToken)
5069protected sealed override PreprocessingSymbolInfo GetPreprocessingSymbolInfoCore(SyntaxNode node)
5076protected sealed override ISymbol GetDeclaredSymbolCore(SyntaxNode node, CancellationToken cancellationToken)
5164protected sealed override ImmutableArray<ISymbol> GetDeclaredSymbolsCore(SyntaxNode declaration, CancellationToken cancellationToken = default(CancellationToken))
5221internal InterceptableLocation GetInterceptableLocationInternal(SyntaxNode nameSyntax, CancellationToken cancellationToken)
5253internal override void ComputeDeclarationsInNode(SyntaxNode node, ISymbol associatedSymbol, bool getSymbol, ArrayBuilder<DeclarationInfo> builder, CancellationToken cancellationToken, int? levelsToCompute = null)
5258internal abstract override Func<SyntaxNode, bool> GetSyntaxNodesToAnalyzeFilter(SyntaxNode declaredNode, ISymbol declaredSymbol);
5259internal abstract override bool ShouldSkipSyntaxNodeAnalysis(SyntaxNode node, ISymbol containingSymbol);
5261protected internal override SyntaxNode GetTopmostNodeForDiagnosticAnalysis(ISymbol symbol, SyntaxNode declaringSyntax)
5304protected sealed override ControlFlowAnalysis AnalyzeControlFlowCore(SyntaxNode firstStatement, SyntaxNode lastStatement)
5329protected sealed override ControlFlowAnalysis AnalyzeControlFlowCore(SyntaxNode statement)
5344protected sealed override DataFlowAnalysis AnalyzeDataFlowCore(SyntaxNode firstStatement, SyntaxNode lastStatement)
5369protected sealed override DataFlowAnalysis AnalyzeDataFlowCore(SyntaxNode statementOrExpression)
5388protected sealed override Optional<object> GetConstantValueCore(SyntaxNode node, CancellationToken cancellationToken)
Compilation\MemberSemanticModel.cs (21)
32private readonly Dictionary<SyntaxNode, OneOrMany<BoundNode>> _guardedBoundNodeMap = new Dictionary<SyntaxNode, OneOrMany<BoundNode>>();
33private readonly Dictionary<SyntaxNode, IOperation> _guardedIOperationNodeMap = new Dictionary<SyntaxNode, IOperation>();
34private Dictionary<SyntaxNode, BoundStatement> _lazyGuardedSynthesizedStatementsMap;
145internal override MemberSemanticModel GetMemberModel(SyntaxNode node)
214private Binder GetEnclosingBinderInternalWithinRoot(SyntaxNode node, int position)
220private static Binder GetEnclosingBinderInternalWithinRoot(SyntaxNode node, int position, Binder rootBinder, SyntaxNode root)
234for (var current = node; binder == null; current = current.ParentOrStructuredTriviaParent)
1415_lazyGuardedSynthesizedStatementsMap = new Dictionary<SyntaxNode, BoundStatement>();
1473protected void UnguardedAddBoundTreeForStandaloneSyntax(SyntaxNode syntax, BoundNode bound, NullableWalker.SnapshotManager manager = null, ImmutableDictionary<Symbol, Symbol> remappedSymbols = null)
1481protected void GuardedAddBoundTreeForStandaloneSyntax(SyntaxNode syntax, BoundNode bound, NullableWalker.SnapshotManager manager = null, ImmutableDictionary<Symbol, Symbol> remappedSymbols = null)
1876private static SyntaxNode AdjustStartingNodeAccordingToNewRoot(SyntaxNode startingNode, SyntaxNode root)
1878SyntaxNode result = startingNode.Contains(root) ? root : startingNode;
2361internal sealed override Func<SyntaxNode, bool> GetSyntaxNodesToAnalyzeFilter(SyntaxNode declaredNode, ISymbol declaredSymbol)
2366internal sealed override bool ShouldSkipSyntaxNodeAnalysis(SyntaxNode node, ISymbol containingSymbol)
2405internal override Binder GetBinder(SyntaxNode node)
CSharpExtensions.cs (19)
42/// Determines if <see cref="SyntaxNode"/> is of a specified kind.
47public static bool IsKind([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind)
63/// <inheritdoc cref="SyntaxNode.ContainsDirective"/>
64public static bool ContainsDirective(this SyntaxNode node, SyntaxKind kind)
84where TNode : SyntaxNode
93where TNode : SyntaxNode
105where TNode : SyntaxNode
114where TNode : SyntaxNode
205/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNode"/> from <see cref="SyntaxNode.RawKind"/> property.
207public static SyntaxKind Kind(this SyntaxNode node)
214/// Returns <see cref="SyntaxKind"/> for <see cref="SyntaxNode"/> from <see cref="SyntaxNodeOrToken.RawKind"/> property.
322internal static Syntax.InternalSyntax.DirectiveStack ApplyDirectives(this SyntaxNode node, Syntax.InternalSyntax.DirectiveStack stack)
352internal static SeparatedSyntaxList<TOther> AsSeparatedList<TOther>(this SyntaxNodeOrTokenList list) where TOther : SyntaxNode
357var node = i.AsNode();
372internal static IList<DirectiveTriviaSyntax> GetDirectives(this SyntaxNode node, Func<DirectiveTriviaSyntax, bool>? filter = null)
380public static DirectiveTriviaSyntax? GetFirstDirective(this SyntaxNode node, Func<DirectiveTriviaSyntax, bool>? predicate = null)
388public static DirectiveTriviaSyntax? GetLastDirective(this SyntaxNode node, Func<DirectiveTriviaSyntax, bool>? predicate = null)
764public static Conversion GetConversion(this SemanticModel? semanticModel, SyntaxNode expression, CancellationToken cancellationToken = default(CancellationToken))
Emitter\Model\PEModuleBuilder.cs (24)
26internal abstract class PEModuleBuilder : PEModuleBuilder<CSharpCompilation, SourceModuleSymbol, AssemblySymbol, TypeSymbol, NamedTypeSymbol, MethodSymbol, SyntaxNode, NoPia.EmbeddedTypesManager, ModuleCompilationState>
814private NamedTypeSymbol GetUntranslatedSpecialType(SpecialType specialType, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
831internal sealed override Cci.INamedTypeReference GetSpecialType(SpecialType specialType, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
956SyntaxNode syntaxNodeOpt,
1077private void CheckTupleUnderlyingType(NamedTypeSymbol namedTypeSymbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
1137SyntaxNode syntaxNodeOpt,
1169SyntaxNode syntaxNodeOpt,
1210SyntaxNode syntaxNodeOpt,
1244SyntaxNode syntaxNodeOpt,
1436SyntaxNode syntaxNodeOpt,
1485protected override Cci.IMethodDefinition CreatePrivateImplementationDetailsStaticConstructor(SyntaxNode syntaxOpt, DiagnosticBag diagnostics)
1820internal MethodSymbol EnsureThrowSwitchExpressionExceptionExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, DiagnosticBag diagnostics)
1833private MethodSymbol EnsurePrivateImplClassMethodExists<TArg>(SyntaxNode syntaxNode, string methodName, Func<SynthesizedPrivateImplementationDetailsType, TArg, MethodSymbol> createMethodSymbol, TArg arg, DiagnosticBag diagnostics)
1851internal new SynthesizedPrivateImplementationDetailsType GetPrivateImplClass(SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
1867internal MethodSymbol EnsureThrowSwitchExpressionExceptionParameterlessExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, DiagnosticBag diagnostics)
1887internal MethodSymbol EnsureThrowInvalidOperationExceptionExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, DiagnosticBag diagnostics)
1904internal MethodSymbol EnsureInlineArrayAsSpanExists(SyntaxNode syntaxNode, NamedTypeSymbol spanType, NamedTypeSymbol intType, DiagnosticBag diagnostics)
1921internal NamedTypeSymbol EnsureInlineArrayTypeExists(SyntaxNode syntaxNode, SyntheticBoundNodeFactory factory, int arrayLength, DiagnosticBag diagnostics)
1944internal NamedTypeSymbol EnsureReadOnlyListTypeExists(SyntaxNode syntaxNode, SynthesizedReadOnlyListKind kind, DiagnosticBag diagnostics)
1973internal MethodSymbol EnsureInlineArrayAsReadOnlySpanExists(SyntaxNode syntaxNode, NamedTypeSymbol spanType, NamedTypeSymbol intType, DiagnosticBag diagnostics)
1990internal MethodSymbol EnsureInlineArrayElementRefExists(SyntaxNode syntaxNode, NamedTypeSymbol intType, DiagnosticBag diagnostics)
2006internal MethodSymbol EnsureInlineArrayElementRefReadOnlyExists(SyntaxNode syntaxNode, NamedTypeSymbol intType, DiagnosticBag diagnostics)
2022internal MethodSymbol EnsureInlineArrayFirstElementRefExists(SyntaxNode syntaxNode, DiagnosticBag diagnostics)
2035internal MethodSymbol EnsureInlineArrayFirstElementRefReadOnlyExists(SyntaxNode syntaxNode, DiagnosticBag diagnostics)
Emitter\NoPia\EmbeddedTypesManager.cs (17)
33EmbeddedTypesManager<PEModuleBuilder, ModuleCompilationState, EmbeddedTypesManager, SyntaxNode, CSharpAttributeData,
55public NamedTypeSymbol GetSystemStringType(SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
82public MethodSymbol GetWellKnownMethod(WellKnownMember method, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
90private MethodSymbol LazyGetWellKnownTypeMethod(ref MethodSymbol lazyMethod, WellKnownMember member, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
124internal override CSharpAttributeData CreateSynthesizedAttribute(WellKnownMember constructor, ImmutableArray<TypedConstant> constructorArguments, ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
156internal override bool TryGetAttributeArguments(CSharpAttributeData attrData, out ImmutableArray<TypedConstant> constructorArguments, out ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
253SyntaxNode syntaxNodeOpt,
329private static void ReportNotEmbeddableSymbol(ErrorCode error, Symbol symbol, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics, EmbeddedTypesManager optTypeManager)
338internal static void Error(DiagnosticBag diagnostics, ErrorCode code, SyntaxNode syntaxOpt, params object[] args)
343private static void Error(DiagnosticBag diagnostics, SyntaxNode syntaxOpt, DiagnosticInfo info)
351SyntaxNode syntaxNodeOpt,
368SyntaxNode syntaxNodeOpt,
434SyntaxNode syntaxNodeOpt,
470SyntaxNode syntaxNodeOpt,
531SyntaxNode syntaxNodeOpt,
565SyntaxNode syntaxNodeOpt,
604protected override EmbeddedType GetEmbeddedTypeForMember(SymbolAdapter member, SyntaxNode syntaxNodeOpt, DiagnosticBag diagnostics)
Errors\MessageProvider.cs (7)
258protected override void ReportInvalidAttributeArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, AttributeData attribute)
264protected override void ReportInvalidNamedArgument(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int namedArgumentIndex, ITypeSymbol attributeClass, string parameterName)
270protected override void ReportParameterNotValidForType(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int namedArgumentIndex)
276protected override void ReportMarshalUnmanagedTypeNotValidForFields(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, string unmanagedTypeName, AttributeData attribute)
281protected override void ReportMarshalUnmanagedTypeOnlyValidForFields(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, int parameterIndex, string unmanagedTypeName, AttributeData attribute)
286protected override void ReportAttributeParameterRequired(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, string parameterName)
292protected override void ReportAttributeParameterRequired(DiagnosticBag diagnostics, SyntaxNode attributeSyntax, string parameterName1, string parameterName2)
FlowAnalysis\DefiniteAssignment.cs (8)
449protected virtual void ReportUnassignedOutParameter(ParameterSymbol parameter, SyntaxNode node, Location location)
1151protected void CheckAssigned(Symbol symbol, SyntaxNode node)
1170private void ReportUnassignedIfNotCapturedInLocalFunction(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration = true)
1187protected virtual void ReportUnassigned(Symbol symbol, SyntaxNode node, int slot, bool skipIfUseBeforeDeclaration)
1368protected virtual void CheckAssigned(BoundExpression expr, FieldSymbol fieldSymbol, SyntaxNode node)
1932protected override void LeaveParameters(ImmutableArray<ParameterSymbol> parameters, SyntaxNode syntax, Location location)
1943protected override void LeaveParameter(ParameterSymbol parameter, SyntaxNode syntax, Location location)
2590protected void CheckAssigned(BoundExpression expr, SyntaxNode node)
FlowAnalysis\NullableWalker.cs (24)
622void enforceMemberNotNull(SyntaxNode? syntaxOpt, LocalState state)
980private void EnforceMemberNotNullOnMember(SyntaxNode? syntaxOpt, LocalState state, MethodSymbol method, string memberName)
1030void enforceMemberNotNullWhenIfAffected(SyntaxNode? syntaxOpt, bool sense, ImmutableArray<Symbol> members, LocalState state, LocalState otherState)
1042void enforceMemberNotNullWhen(SyntaxNode? syntaxOpt, bool sense, LocalState state)
1058private void ReportFailedMemberNotNullIfNeeded(SyntaxNode? syntaxOpt, bool sense, Symbol member, LocalState state)
1191private void EnforceParameterNotNullOnExit(SyntaxNode? syntaxOpt, LocalState state)
1231private void EnforceParameterNotNullWhenOnExit(SyntaxNode syntax, ImmutableArray<ParameterSymbol> parameters, bool sense, LocalState stateWhen)
1244private void ReportParameterIfBadConditionalState(SyntaxNode syntax, ParameterSymbol parameter, bool sense, LocalState stateWhen)
1291private void EnforceNotNullIfNotNull(SyntaxNode? syntaxOpt, LocalState state, ImmutableArray<ParameterSymbol> parameters, ImmutableHashSet<string> inputParamNames, NullableFlowState outputState, ParameterSymbol? outputParam)
1320private void EnforceDoesNotReturn(SyntaxNode? syntaxOpt)
1632internal static bool NeedsAnalysis(CSharpCompilation compilation, SyntaxNode syntaxNode)
1643SyntaxNode syntax,
2505private void ReportNullabilityMismatchInAssignment(SyntaxNode syntaxNode, object sourceType, object destinationType)
2572private void ReportDiagnostic(ErrorCode errorCode, SyntaxNode syntaxNode, params object[] arguments)
3334void enforceMemberNotNull(SyntaxNode? syntax, LocalState state)
3350SyntaxNode syntax,
6687var syntax = node.Syntax;
6696private static bool HasImplicitTypeArguments(SyntaxNode syntax)
6835var syntax = node.Syntax;
7431private bool CheckDisallowedNullAssignment(TypeWithState state, FlowAnalysisAnnotations annotations, SyntaxNode node, BoundExpression? boundValueOpt = null)
8003private void CheckMethodConstraints(SyntaxNode syntax, MethodSymbol method)
9810var syntax = group.Syntax;
10621private void ReportNullabilityMismatchInArgument(SyntaxNode argument, TypeSymbol argumentType, ParameterSymbol parameter, TypeSymbol parameterType, bool forOutput)
11816private bool ReportPossibleNullReceiverIfNeeded(TypeSymbol type, NullableFlowState state, bool checkNullableValueType, SyntaxNode syntax, out bool reportedDiagnostic)
Generated\BoundNodes.xml.Generated.cs (333)
278protected BoundInitializer(BoundKind kind, SyntaxNode syntax, bool hasErrors)
283protected BoundInitializer(BoundKind kind, SyntaxNode syntax)
292protected BoundEqualsValue(BoundKind kind, SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression value, bool hasErrors = false)
309public BoundFieldEqualsValue(SyntaxNode syntax, FieldSymbol field, ImmutableArray<LocalSymbol> locals, BoundExpression value, bool hasErrors = false)
339public BoundPropertyEqualsValue(SyntaxNode syntax, PropertySymbol property, ImmutableArray<LocalSymbol> locals, BoundExpression value, bool hasErrors = false)
369public BoundParameterEqualsValue(SyntaxNode syntax, ParameterSymbol parameter, ImmutableArray<LocalSymbol> locals, BoundExpression value, bool hasErrors = false)
399public BoundGlobalStatementInitializer(SyntaxNode syntax, BoundStatement statement, bool hasErrors = false)
427protected BoundExpression(BoundKind kind, SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
433protected BoundExpression(BoundKind kind, SyntaxNode syntax, TypeSymbol? type)
444protected BoundValuePlaceholderBase(BoundKind kind, SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
449protected BoundValuePlaceholderBase(BoundKind kind, SyntaxNode syntax, TypeSymbol? type)
458protected BoundEarlyValuePlaceholderBase(BoundKind kind, SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
463protected BoundEarlyValuePlaceholderBase(BoundKind kind, SyntaxNode syntax, TypeSymbol? type)
472public BoundValuePlaceholder(SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
477public BoundValuePlaceholder(SyntaxNode syntax, TypeSymbol? type)
500public BoundCapturedReceiverPlaceholder(SyntaxNode syntax, BoundExpression receiver, SafeContext localScopeDepth, TypeSymbol? type, bool hasErrors = false)
530public BoundDeconstructValuePlaceholder(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression, TypeSymbol type, bool hasErrors)
540public BoundDeconstructValuePlaceholder(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression, TypeSymbol type)
571public BoundTupleOperandPlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
579public BoundTupleOperandPlaceholder(SyntaxNode syntax, TypeSymbol type)
606public BoundAwaitableValuePlaceholder(SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
611public BoundAwaitableValuePlaceholder(SyntaxNode syntax, TypeSymbol? type)
635public BoundDisposableValuePlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
643public BoundDisposableValuePlaceholder(SyntaxNode syntax, TypeSymbol type)
670public BoundObjectOrCollectionValuePlaceholder(SyntaxNode syntax, bool isNewInstance, TypeSymbol type, bool hasErrors)
679public BoundObjectOrCollectionValuePlaceholder(SyntaxNode syntax, bool isNewInstance, TypeSymbol type)
708public BoundImplicitIndexerValuePlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
716public BoundImplicitIndexerValuePlaceholder(SyntaxNode syntax, TypeSymbol type)
743public BoundImplicitIndexerReceiverPlaceholder(SyntaxNode syntax, bool isEquivalentToThisReference, TypeSymbol type, bool hasErrors)
752public BoundImplicitIndexerReceiverPlaceholder(SyntaxNode syntax, bool isEquivalentToThisReference, TypeSymbol type)
781public BoundListPatternReceiverPlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
789public BoundListPatternReceiverPlaceholder(SyntaxNode syntax, TypeSymbol type)
816public BoundListPatternIndexPlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
824public BoundListPatternIndexPlaceholder(SyntaxNode syntax, TypeSymbol type)
851public BoundSlicePatternReceiverPlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
859public BoundSlicePatternReceiverPlaceholder(SyntaxNode syntax, TypeSymbol type)
886public BoundSlicePatternRangePlaceholder(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
894public BoundSlicePatternRangePlaceholder(SyntaxNode syntax, TypeSymbol type)
921public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol? type, bool hasErrors)
927public BoundDup(SyntaxNode syntax, RefKind refKind, TypeSymbol? type)
952public BoundPassByCopy(SyntaxNode syntax, BoundExpression expression, TypeSymbol? type, bool hasErrors = false)
980public BoundBadExpression(SyntaxNode syntax, LookupResultKind resultKind, ImmutableArray<Symbol?> symbols, ImmutableArray<BoundExpression> childBoundNodes, TypeSymbol? type, bool hasErrors = false)
1013public BoundBadStatement(SyntaxNode syntax, ImmutableArray<BoundNode> childBoundNodes, bool hasErrors = false)
1041public BoundExtractedFinallyBlock(SyntaxNode syntax, BoundBlock finallyBlock, bool hasErrors = false)
1069public BoundTypeExpression(SyntaxNode syntax, AliasSymbol? aliasOpt, BoundTypeExpression? boundContainingTypeOpt, ImmutableArray<BoundExpression> boundDimensionsOpt, TypeWithAnnotations typeWithAnnotations, TypeSymbol type, bool hasErrors = false)
1104public BoundTypeOrValueExpression(SyntaxNode syntax, BoundTypeOrValueData data, TypeSymbol type, bool hasErrors)
1113public BoundTypeOrValueExpression(SyntaxNode syntax, BoundTypeOrValueData data, TypeSymbol type)
1142public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, AliasSymbol? aliasOpt, bool hasErrors)
1152public BoundNamespaceExpression(SyntaxNode syntax, NamespaceSymbol namespaceSymbol, AliasSymbol? aliasOpt)
1183public BoundUnaryOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, ConstantValue? constantValueOpt, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false)
1225public BoundIncrementOperator(SyntaxNode syntax, UnaryOperatorKind operatorKind, BoundExpression operand, MethodSymbol? methodOpt, TypeSymbol? constrainedToTypeOpt, BoundValuePlaceholder? operandPlaceholder, BoundExpression? operandConversion, BoundValuePlaceholder? resultPlaceholder, BoundExpression? resultConversion, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false)
1273public BoundAddressOfOperator(SyntaxNode syntax, BoundExpression operand, bool isManaged, TypeSymbol type, bool hasErrors = false)
1305public BoundUnconvertedAddressOfOperator(SyntaxNode syntax, BoundMethodGroup operand, bool hasErrors = false)
1334public BoundFunctionPointerLoad(SyntaxNode syntax, MethodSymbol targetMethod, TypeSymbol? constrainedToTypeOpt, TypeSymbol type, bool hasErrors)
1345public BoundFunctionPointerLoad(SyntaxNode syntax, MethodSymbol targetMethod, TypeSymbol? constrainedToTypeOpt, TypeSymbol type)
1377public BoundPointerIndirectionOperator(SyntaxNode syntax, BoundExpression operand, bool refersToLocation, TypeSymbol type, bool hasErrors = false)
1409public BoundPointerElementAccess(SyntaxNode syntax, BoundExpression expression, BoundExpression index, bool @checked, bool refersToLocation, TypeSymbol type, bool hasErrors = false)
1446public BoundFunctionPointerInvocation(SyntaxNode syntax, BoundExpression invokedExpression, ImmutableArray<BoundExpression> arguments, ImmutableArray<RefKind> argumentRefKindsOpt, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false)
1483public BoundRefTypeOperator(SyntaxNode syntax, BoundExpression operand, MethodSymbol? getTypeFromHandle, TypeSymbol type, bool hasErrors = false)
1515public BoundMakeRefOperator(SyntaxNode syntax, BoundExpression operand, TypeSymbol type, bool hasErrors = false)
1545public BoundRefValueOperator(SyntaxNode syntax, NullableAnnotation nullableAnnotation, BoundExpression operand, TypeSymbol type, bool hasErrors = false)
1577public BoundFromEndIndexExpression(SyntaxNode syntax, BoundExpression operand, MethodSymbol? methodOpt, TypeSymbol type, bool hasErrors = false)
1609public BoundRangeExpression(SyntaxNode syntax, BoundExpression? leftOperandOpt, BoundExpression? rightOperandOpt, MethodSymbol? methodOpt, TypeSymbol type, bool hasErrors = false)
1642protected BoundBinaryOperatorBase(BoundKind kind, SyntaxNode syntax, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false)
1661public BoundBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundBinaryOperator.UncommonData? data, LookupResultKind resultKind, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false)
1695public BoundTupleBinaryOperator(SyntaxNode syntax, BoundExpression left, BoundExpression right, BinaryOperatorKind operatorKind, TupleBinaryOperatorInfo.Multiple operators, TypeSymbol type, bool hasErrors = false)
1733public BoundUserDefinedConditionalLogicalOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, MethodSymbol logicalOperator, MethodSymbol trueOperator, MethodSymbol falseOperator, TypeSymbol? constrainedToTypeOpt, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, BoundExpression left, BoundExpression right, TypeSymbol type, bool hasErrors = false)
1778public BoundCompoundAssignmentOperator(SyntaxNode syntax, BinaryOperatorSignature @operator, BoundExpression left, BoundExpression right, BoundValuePlaceholder? leftPlaceholder, BoundExpression? leftConversion, BoundValuePlaceholder? finalPlaceholder, BoundExpression? finalConversion, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt, TypeSymbol type, bool hasErrors = false)
1825public BoundAssignmentOperator(SyntaxNode syntax, BoundExpression left, BoundExpression right, bool isRef, TypeSymbol type, bool hasErrors = false)
1859public BoundDeconstructionAssignmentOperator(SyntaxNode syntax, BoundTupleExpression left, BoundConversion right, bool isUsed, TypeSymbol type, bool hasErrors = false)
1894public BoundNullCoalescingOperator(SyntaxNode syntax, BoundExpression leftOperand, BoundExpression rightOperand, BoundValuePlaceholder? leftPlaceholder, BoundExpression? leftConversion, BoundNullCoalescingOperatorResultKind operatorResultKind, bool @checked, TypeSymbol type, bool hasErrors = false)
1935public BoundNullCoalescingAssignmentOperator(SyntaxNode syntax, BoundExpression leftOperand, BoundExpression rightOperand, TypeSymbol? type, bool hasErrors = false)
1966public BoundUnconvertedConditionalOperator(SyntaxNode syntax, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, ErrorCode noCommonTypeError, bool hasErrors = false)
2005public BoundConditionalOperator(SyntaxNode syntax, bool isRef, BoundExpression condition, BoundExpression consequence, BoundExpression alternative, ConstantValue? constantValueOpt, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
2049public BoundArrayAccess(SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundExpression> indices, TypeSymbol type, bool hasErrors = false)
2082public BoundRefArrayAccess(SyntaxNode syntax, BoundArrayAccess arrayAccess, bool hasErrors = false)
2111public BoundArrayLength(SyntaxNode syntax, BoundExpression expression, TypeSymbol type, bool hasErrors = false)
2141public BoundAwaitableInfo(SyntaxNode syntax, BoundAwaitableValuePlaceholder? awaitableInstancePlaceholder, bool isDynamic, BoundExpression? getAwaiter, PropertySymbol? isCompleted, MethodSymbol? getResult, bool hasErrors = false)
2174public BoundAwaitExpression(SyntaxNode syntax, BoundExpression expression, BoundAwaitableInfo awaitableInfo, BoundAwaitExpressionDebugInfo debugInfo, TypeSymbol type, bool hasErrors = false)
2209protected BoundTypeOf(BoundKind kind, SyntaxNode syntax, MethodSymbol? getTypeFromHandle, TypeSymbol type, bool hasErrors)
2218protected BoundTypeOf(BoundKind kind, SyntaxNode syntax, MethodSymbol? getTypeFromHandle, TypeSymbol type)
2233public BoundTypeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, MethodSymbol? getTypeFromHandle, TypeSymbol type, bool hasErrors = false)
2262public BoundBlockInstrumentation(SyntaxNode syntax, OneOrMany<LocalSymbol> locals, BoundStatement? prologue, BoundStatement? epilogue, bool hasErrors = false)
2294public BoundMethodDefIndex(SyntaxNode syntax, MethodSymbol method, TypeSymbol type, bool hasErrors)
2304public BoundMethodDefIndex(SyntaxNode syntax, MethodSymbol method, TypeSymbol type)
2334public BoundLocalId(SyntaxNode syntax, LocalSymbol local, FieldSymbol? hoistedField, TypeSymbol type, bool hasErrors)
2345public BoundLocalId(SyntaxNode syntax, LocalSymbol local, FieldSymbol? hoistedField, TypeSymbol type)
2377public BoundParameterId(SyntaxNode syntax, ParameterSymbol parameter, FieldSymbol? hoistedField, TypeSymbol type, bool hasErrors)
2388public BoundParameterId(SyntaxNode syntax, ParameterSymbol parameter, FieldSymbol? hoistedField, TypeSymbol type)
2420public BoundStateMachineInstanceId(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
2428public BoundStateMachineInstanceId(SyntaxNode syntax, TypeSymbol type)
2455public BoundMaximumMethodDefIndex(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
2463public BoundMaximumMethodDefIndex(SyntaxNode syntax, TypeSymbol type)
2490public BoundInstrumentationPayloadRoot(SyntaxNode syntax, int analysisKind, TypeSymbol type, bool hasErrors)
2499public BoundInstrumentationPayloadRoot(SyntaxNode syntax, int analysisKind, TypeSymbol type)
2528public BoundThrowIfModuleCancellationRequested(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
2536public BoundThrowIfModuleCancellationRequested(SyntaxNode syntax, TypeSymbol type)
2563public ModuleCancellationTokenExpression(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
2571public ModuleCancellationTokenExpression(SyntaxNode syntax, TypeSymbol type)
2598public BoundModuleVersionId(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
2606public BoundModuleVersionId(SyntaxNode syntax, TypeSymbol type)
2633public BoundModuleVersionIdString(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
2641public BoundModuleVersionIdString(SyntaxNode syntax, TypeSymbol type)
2668public BoundSourceDocumentIndex(SyntaxNode syntax, Cci.DebugSourceDocument document, TypeSymbol type, bool hasErrors)
2678public BoundSourceDocumentIndex(SyntaxNode syntax, Cci.DebugSourceDocument document, TypeSymbol type)
2708public BoundMethodInfo(SyntaxNode syntax, MethodSymbol method, MethodSymbol? getMethodFromHandle, TypeSymbol type, bool hasErrors)
2719public BoundMethodInfo(SyntaxNode syntax, MethodSymbol method, MethodSymbol? getMethodFromHandle, TypeSymbol type)
2751public BoundFieldInfo(SyntaxNode syntax, FieldSymbol field, MethodSymbol? getFieldFromHandle, TypeSymbol type, bool hasErrors)
2762public BoundFieldInfo(SyntaxNode syntax, FieldSymbol field, MethodSymbol? getFieldFromHandle, TypeSymbol type)
2794public BoundDefaultLiteral(SyntaxNode syntax, bool hasErrors)
2799public BoundDefaultLiteral(SyntaxNode syntax)
2817public BoundDefaultExpression(SyntaxNode syntax, BoundTypeExpression? targetType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false)
2848public BoundIsOperator(SyntaxNode syntax, BoundExpression operand, BoundTypeExpression targetType, ConversionKind conversionKind, TypeSymbol type, bool hasErrors = false)
2883public BoundAsOperator(SyntaxNode syntax, BoundExpression operand, BoundTypeExpression targetType, BoundValuePlaceholder? operandPlaceholder, BoundExpression? operandConversion, TypeSymbol type, bool hasErrors = false)
2920public BoundSizeOfOperator(SyntaxNode syntax, BoundTypeExpression sourceType, ConstantValue? constantValueOpt, TypeSymbol type, bool hasErrors = false)
2952public BoundConversion(SyntaxNode syntax, BoundExpression operand, Conversion conversion, bool isBaseConversion, bool @checked, bool explicitCastInCode, ConstantValue? constantValueOpt, ConversionGroup? conversionGroupOpt, ImmutableArray<MethodSymbol> originalUserDefinedConversionsOpt, TypeSymbol type, bool hasErrors = false)
2996public BoundReadOnlySpanFromArray(SyntaxNode syntax, BoundExpression operand, MethodSymbol conversionMethod, TypeSymbol type, bool hasErrors = false)
3029public BoundArgList(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
3037public BoundArgList(SyntaxNode syntax, TypeSymbol type)
3064public BoundArgListOperator(SyntaxNode syntax, ImmutableArray<BoundExpression> arguments, ImmutableArray<RefKind> argumentRefKindsOpt, TypeSymbol? type, bool hasErrors = false)
3095public BoundFixedLocalCollectionInitializer(SyntaxNode syntax, TypeSymbol elementPointerType, BoundValuePlaceholder? elementPointerPlaceholder, BoundExpression? elementPointerConversion, BoundExpression expression, MethodSymbol? getPinnableOpt, TypeSymbol type, bool hasErrors = false)
3134protected BoundStatement(BoundKind kind, SyntaxNode syntax, bool hasErrors)
3139protected BoundStatement(BoundKind kind, SyntaxNode syntax)
3148public BoundSequencePoint(SyntaxNode syntax, BoundStatement? statementOpt, bool hasErrors = false)
3173public BoundSequencePointWithSpan(SyntaxNode syntax, BoundStatement? statementOpt, TextSpan span, bool hasErrors = false)
3200public BoundSavePreviousSequencePoint(SyntaxNode syntax, object identifier, bool hasErrors)
3209public BoundSavePreviousSequencePoint(SyntaxNode syntax, object identifier)
3237public BoundRestorePreviousSequencePoint(SyntaxNode syntax, object identifier, bool hasErrors)
3246public BoundRestorePreviousSequencePoint(SyntaxNode syntax, object identifier)
3274public BoundStepThroughSequencePoint(SyntaxNode syntax, TextSpan span, bool hasErrors)
3280public BoundStepThroughSequencePoint(SyntaxNode syntax, TextSpan span)
3305public BoundBlock(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, ImmutableArray<LocalFunctionSymbol> localFunctions, bool hasUnsafeModifier, BoundBlockInstrumentation? instrumentation, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
3341public BoundScope(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
3370public BoundStateMachineScope(SyntaxNode syntax, ImmutableArray<StateMachineFieldSymbol> fields, BoundStatement statement, bool hasErrors = false)
3401public BoundLocalDeclaration(SyntaxNode syntax, LocalSymbol localSymbol, BoundTypeExpression? declaredTypeOpt, BoundExpression? initializerOpt, ImmutableArray<BoundExpression> argumentsOpt, bool inferredType, bool hasErrors = false)
3437protected BoundMultipleLocalDeclarationsBase(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundLocalDeclaration> localDeclarations, bool hasErrors = false)
3451public BoundMultipleLocalDeclarations(SyntaxNode syntax, ImmutableArray<BoundLocalDeclaration> localDeclarations, bool hasErrors = false)
3477public BoundUsingLocalDeclarations(SyntaxNode syntax, MethodArgumentInfo? patternDisposeInfoOpt, BoundAwaitableInfo? awaitOpt, ImmutableArray<BoundLocalDeclaration> localDeclarations, bool hasErrors = false)
3507public BoundLocalFunctionStatement(SyntaxNode syntax, LocalFunctionSymbol symbol, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false)
3539public BoundNoOpStatement(SyntaxNode syntax, NoOpStatementFlavor flavor, bool hasErrors)
3545public BoundNoOpStatement(SyntaxNode syntax, NoOpStatementFlavor flavor)
3570public BoundReturnStatement(SyntaxNode syntax, RefKind refKind, BoundExpression? expressionOpt, bool @checked, bool hasErrors = false)
3599public BoundYieldReturnStatement(SyntaxNode syntax, BoundExpression expression, bool hasErrors = false)
3627public BoundYieldBreakStatement(SyntaxNode syntax, bool hasErrors)
3632public BoundYieldBreakStatement(SyntaxNode syntax)
3644public BoundThrowStatement(SyntaxNode syntax, BoundExpression? expressionOpt, bool hasErrors = false)
3669public BoundExpressionStatement(SyntaxNode syntax, BoundExpression expression, bool hasErrors = false)
3697public BoundBreakStatement(SyntaxNode syntax, GeneratedLabelSymbol label, bool hasErrors)
3706public BoundBreakStatement(SyntaxNode syntax, GeneratedLabelSymbol label)
3734public BoundContinueStatement(SyntaxNode syntax, GeneratedLabelSymbol label, bool hasErrors)
3743public BoundContinueStatement(SyntaxNode syntax, GeneratedLabelSymbol label)
3771public BoundSwitchStatement(SyntaxNode syntax, BoundExpression expression, ImmutableArray<LocalSymbol> innerLocals, ImmutableArray<LocalFunctionSymbol> innerLocalFunctions, ImmutableArray<BoundSwitchSection> switchSections, BoundDecisionDag reachabilityDecisionDag, BoundSwitchLabel? defaultLabel, GeneratedLabelSymbol breakLabel, bool hasErrors = false)
3816public BoundSwitchDispatch(SyntaxNode syntax, BoundExpression expression, ImmutableArray<(ConstantValue value, LabelSymbol label)> cases, LabelSymbol defaultLabel, LengthBasedStringSwitchData? lengthBasedStringSwitchDataOpt, bool hasErrors = false)
3852public BoundIfStatement(SyntaxNode syntax, BoundExpression condition, BoundStatement consequence, BoundStatement? alternativeOpt, bool hasErrors = false)
3885protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors)
3896protected BoundLoopStatement(BoundKind kind, SyntaxNode syntax, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel)
3913protected BoundConditionalLoopStatement(BoundKind kind, SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false)
3935public BoundDoStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false)
3965public BoundWhileStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression condition, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false)
3995public BoundForStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> outerLocals, BoundStatement? initializer, ImmutableArray<LocalSymbol> innerLocals, BoundExpression? condition, BoundStatement? increment, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false)
4037public BoundForEachStatement(SyntaxNode syntax, ForEachEnumeratorInfo? enumeratorInfoOpt, BoundValuePlaceholder? elementPlaceholder, BoundExpression? elementConversion, BoundTypeExpression iterationVariableType, ImmutableArray<LocalSymbol> iterationVariables, BoundExpression? iterationErrorExpressionOpt, BoundExpression expression, BoundForEachDeconstructStep? deconstructionOpt, BoundAwaitableInfo? awaitOpt, BoundStatement body, GeneratedLabelSymbol breakLabel, GeneratedLabelSymbol continueLabel, bool hasErrors = false)
4088public BoundForEachDeconstructStep(SyntaxNode syntax, BoundDeconstructionAssignmentOperator deconstructionAssignment, BoundDeconstructValuePlaceholder targetPlaceholder, bool hasErrors = false)
4119public BoundUsingStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundMultipleLocalDeclarations? declarationsOpt, BoundExpression? expressionOpt, BoundStatement body, BoundAwaitableInfo? awaitOpt, MethodArgumentInfo? patternDisposeInfoOpt, bool hasErrors = false)
4158public BoundFixedStatement(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundMultipleLocalDeclarations declarations, BoundStatement body, bool hasErrors = false)
4192public BoundLockStatement(SyntaxNode syntax, BoundExpression argument, BoundStatement body, bool hasErrors = false)
4223public BoundTryStatement(SyntaxNode syntax, BoundBlock tryBlock, ImmutableArray<BoundCatchBlock> catchBlocks, BoundBlock? finallyBlockOpt, LabelSymbol? finallyLabelOpt, bool preferFaultHandler, bool hasErrors = false)
4260public BoundCatchBlock(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundExpression? exceptionSourceOpt, TypeSymbol? exceptionTypeOpt, BoundStatementList? exceptionFilterPrologueOpt, BoundExpression? exceptionFilterOpt, BoundBlock body, bool isSynthesizedAsyncCatchAll, bool hasErrors = false)
4301public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors)
4307public BoundLiteral(SyntaxNode syntax, ConstantValue? constantValueOpt, TypeSymbol? type)
4332public BoundUtf8String(SyntaxNode syntax, string value, TypeSymbol type, bool hasErrors)
4342public BoundUtf8String(SyntaxNode syntax, string value, TypeSymbol type)
4372public BoundThisReference(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
4380public BoundThisReference(SyntaxNode syntax, TypeSymbol type)
4407public BoundPreviousSubmissionReference(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
4415public BoundPreviousSubmissionReference(SyntaxNode syntax, TypeSymbol type)
4442public BoundHostObjectMemberReference(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
4450public BoundHostObjectMemberReference(SyntaxNode syntax, TypeSymbol type)
4477public BoundBaseReference(SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
4482public BoundBaseReference(SyntaxNode syntax, TypeSymbol? type)
4506public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type, bool hasErrors)
4519public BoundLocal(SyntaxNode syntax, LocalSymbol localSymbol, BoundLocalDeclarationKind declarationKind, ConstantValue? constantValueOpt, bool isNullableUnknown, TypeSymbol type)
4555public BoundPseudoVariable(SyntaxNode syntax, LocalSymbol localSymbol, PseudoVariableExpressions emitExpressions, TypeSymbol type, bool hasErrors)
4567public BoundPseudoVariable(SyntaxNode syntax, LocalSymbol localSymbol, PseudoVariableExpressions emitExpressions, TypeSymbol type)
4600public BoundRangeVariable(SyntaxNode syntax, RangeVariableSymbol rangeVariableSymbol, BoundExpression value, TypeSymbol type, bool hasErrors = false)
4633public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol, TypeSymbol type, bool hasErrors)
4643public BoundParameter(SyntaxNode syntax, ParameterSymbol parameterSymbol, TypeSymbol type)
4673public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
4682public BoundLabelStatement(SyntaxNode syntax, LabelSymbol label)
4710public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, BoundExpression? caseExpressionOpt, BoundLabel? labelExpressionOpt, bool hasErrors = false)
4742public BoundLabeledStatement(SyntaxNode syntax, LabelSymbol label, BoundStatement body, bool hasErrors = false)
4773public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type, bool hasErrors)
4782public BoundLabel(SyntaxNode syntax, LabelSymbol label, TypeSymbol? type)
4810protected BoundStatementList(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
4819public BoundStatementList(SyntaxNode syntax, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
4847public BoundConditionalGoto(SyntaxNode syntax, BoundExpression condition, bool jumpIfTrue, LabelSymbol label, bool hasErrors = false)
4880protected BoundSwitchExpression(BoundKind kind, SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false)
4904public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label, bool hasErrors = false)
4943public BoundUnconvertedSwitchExpression(SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol? type, bool hasErrors = false)
4971public BoundConvertedSwitchExpression(SyntaxNode syntax, TypeSymbol? naturalTypeOpt, bool wasTargetTyped, BoundExpression expression, ImmutableArray<BoundSwitchExpressionArm> switchArms, BoundDecisionDag reachabilityDecisionDag, LabelSymbol? defaultLabel, bool reportedNotExhaustive, TypeSymbol type, bool hasErrors = false)
5005public BoundDecisionDag(SyntaxNode syntax, BoundDecisionDagNode rootNode, bool hasErrors = false)
5033protected BoundDecisionDagNode(BoundKind kind, SyntaxNode syntax, bool hasErrors)
5038protected BoundDecisionDagNode(BoundKind kind, SyntaxNode syntax)
5047public BoundEvaluationDecisionDagNode(SyntaxNode syntax, BoundDagEvaluation evaluation, BoundDecisionDagNode next, bool hasErrors = false)
5078public BoundTestDecisionDagNode(SyntaxNode syntax, BoundDagTest test, BoundDecisionDagNode whenTrue, BoundDecisionDagNode whenFalse, bool hasErrors = false)
5112public BoundWhenDecisionDagNode(SyntaxNode syntax, ImmutableArray<BoundPatternBinding> bindings, BoundExpression? whenExpression, BoundDecisionDagNode whenTrue, BoundDecisionDagNode? whenFalse, bool hasErrors = false)
5147public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label, bool hasErrors)
5156public BoundLeafDecisionDagNode(SyntaxNode syntax, LabelSymbol label)
5184protected BoundDagTest(BoundKind kind, SyntaxNode syntax, BoundDagTemp input, bool hasErrors = false)
5198public BoundDagTemp(SyntaxNode syntax, TypeSymbol type, BoundDagEvaluation? source, int index, bool hasErrors = false)
5230public BoundDagTypeTest(SyntaxNode syntax, TypeSymbol type, BoundDagTemp input, bool hasErrors = false)
5259public BoundDagNonNullTest(SyntaxNode syntax, bool isExplicitTest, BoundDagTemp input, bool hasErrors = false)
5287public BoundDagExplicitNullTest(SyntaxNode syntax, BoundDagTemp input, bool hasErrors = false)
5313public BoundDagValueTest(SyntaxNode syntax, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5342public BoundDagRelationalTest(SyntaxNode syntax, BinaryOperatorKind operatorKind, ConstantValue value, BoundDagTemp input, bool hasErrors = false)
5373protected BoundDagEvaluation(BoundKind kind, SyntaxNode syntax, BoundDagTemp input, bool hasErrors = false)
5385public BoundDagDeconstructEvaluation(SyntaxNode syntax, MethodSymbol deconstructMethod, BoundDagTemp input, bool hasErrors = false)
5414public BoundDagTypeEvaluation(SyntaxNode syntax, TypeSymbol type, BoundDagTemp input, bool hasErrors = false)
5443public BoundDagFieldEvaluation(SyntaxNode syntax, FieldSymbol field, BoundDagTemp input, bool hasErrors = false)
5472public BoundDagPropertyEvaluation(SyntaxNode syntax, PropertySymbol property, bool isLengthOrCount, BoundDagTemp input, bool hasErrors = false)
5503public BoundDagIndexEvaluation(SyntaxNode syntax, PropertySymbol property, int index, BoundDagTemp input, bool hasErrors = false)
5534public BoundDagIndexerEvaluation(SyntaxNode syntax, TypeSymbol indexerType, BoundDagTemp lengthTemp, int index, BoundExpression indexerAccess, BoundListPatternReceiverPlaceholder receiverPlaceholder, BoundListPatternIndexPlaceholder argumentPlaceholder, BoundDagTemp input, bool hasErrors = false)
5581public BoundDagSliceEvaluation(SyntaxNode syntax, TypeSymbol sliceType, BoundDagTemp lengthTemp, int startIndex, int endIndex, BoundExpression indexerAccess, BoundSlicePatternReceiverPlaceholder receiverPlaceholder, BoundSlicePatternRangePlaceholder argumentPlaceholder, BoundDagTemp input, bool hasErrors = false)
5630public BoundDagAssignmentEvaluation(SyntaxNode syntax, BoundDagTemp target, BoundDagTemp input, bool hasErrors = false)
5659public BoundSwitchSection(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, ImmutableArray<BoundSwitchLabel> switchLabels, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
5691public BoundSwitchLabel(SyntaxNode syntax, LabelSymbol label, BoundPattern pattern, BoundExpression? whenClause, bool hasErrors = false)
5724protected BoundMethodOrPropertyGroup(BoundKind kind, SyntaxNode syntax, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false)
5738public BoundSequencePointExpression(SyntaxNode syntax, BoundExpression expression, TypeSymbol? type, bool hasErrors = false)
5766public BoundSequence(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, ImmutableArray<BoundExpression> sideEffects, BoundExpression value, TypeSymbol type, bool hasErrors = false)
5802public BoundSpillSequence(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, ImmutableArray<BoundStatement> sideEffects, BoundExpression value, TypeSymbol type, bool hasErrors = false)
5838public BoundDynamicMemberAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, bool invoked, bool indexed, TypeSymbol type, bool hasErrors = false)
5877protected BoundDynamicInvocableBase(BoundKind kind, SyntaxNode syntax, BoundExpression expression, ImmutableArray<BoundExpression> arguments, TypeSymbol? type, bool hasErrors = false)
5894public BoundDynamicInvocation(SyntaxNode syntax, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, ImmutableArray<MethodSymbol> applicableMethods, BoundExpression expression, ImmutableArray<BoundExpression> arguments, TypeSymbol type, bool hasErrors = false)
5930public BoundConditionalAccess(SyntaxNode syntax, BoundExpression receiver, BoundExpression accessExpression, TypeSymbol type, bool hasErrors = false)
5963public BoundLoweredConditionalAccess(SyntaxNode syntax, BoundExpression receiver, MethodSymbol? hasValueMethodOpt, BoundExpression whenNotNull, BoundExpression? whenNullOpt, int id, bool forceCopyOfNullableValueType, TypeSymbol type, bool hasErrors = false)
6004public BoundConditionalReceiver(SyntaxNode syntax, int id, TypeSymbol type, bool hasErrors)
6013public BoundConditionalReceiver(SyntaxNode syntax, int id, TypeSymbol type)
6042public BoundComplexConditionalReceiver(SyntaxNode syntax, BoundExpression valueTypeReceiver, BoundExpression referenceTypeReceiver, TypeSymbol type, bool hasErrors = false)
6075public BoundMethodGroup(SyntaxNode syntax, ImmutableArray<TypeWithAnnotations> typeArgumentsOpt, string name, ImmutableArray<MethodSymbol> methods, Symbol? lookupSymbolOpt, DiagnosticInfo? lookupError, BoundMethodGroupFlags? flags, FunctionTypeSymbol? functionType, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false)
6116public BoundPropertyGroup(SyntaxNode syntax, ImmutableArray<PropertySymbol> properties, BoundExpression? receiverOpt, LookupResultKind resultKind, bool hasErrors = false)
6144public BoundCall(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, MethodSymbol method, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool isDelegateCall, bool expanded, bool invokedAsExtensionMethod, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, ImmutableArray<MethodSymbol> originalMethodsOpt, TypeSymbol type, bool hasErrors = false)
6199public BoundEventAssignmentOperator(SyntaxNode syntax, EventSymbol @event, bool isAddition, bool isDynamic, BoundExpression? receiverOpt, BoundExpression argument, TypeSymbol type, bool hasErrors = false)
6238public BoundAttribute(SyntaxNode syntax, MethodSymbol? constructor, ImmutableArray<BoundExpression> constructorArguments, ImmutableArray<string?> constructorArgumentNamesOpt, ImmutableArray<int> constructorArgumentsToParamsOpt, bool constructorExpanded, BitVector constructorDefaultArguments, ImmutableArray<BoundAssignmentOperator> namedArguments, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false)
6283public BoundUnconvertedObjectCreationExpression(SyntaxNode syntax, ImmutableArray<BoundExpression> arguments, ImmutableArray<(string Name, Location Location)?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, InitializerExpressionSyntax? initializerOpt, Binder binder, bool hasErrors = false)
6321protected BoundObjectCreationExpressionBase(BoundKind kind, SyntaxNode syntax, TypeSymbol type, bool hasErrors)
6329protected BoundObjectCreationExpressionBase(BoundKind kind, SyntaxNode syntax, TypeSymbol type)
6342public BoundObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray<MethodSymbol> constructorsGroup, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, ConstantValue? constantValueOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
6393protected BoundCollectionExpressionBase(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundNode> elements, TypeSymbol? type, bool hasErrors = false)
6407public BoundUnconvertedCollectionExpression(SyntaxNode syntax, ImmutableArray<BoundNode> elements, bool hasErrors = false)
6434public BoundCollectionExpression(SyntaxNode syntax, CollectionExpressionTypeKind collectionTypeKind, BoundObjectOrCollectionValuePlaceholder? placeholder, BoundExpression? collectionCreation, MethodSymbol? collectionBuilderMethod, BoundValuePlaceholder? collectionBuilderInvocationPlaceholder, BoundExpression? collectionBuilderInvocationConversion, bool wasTargetTyped, BoundUnconvertedCollectionExpression unconvertedCollectionExpression, ImmutableArray<BoundNode> elements, TypeSymbol type, bool hasErrors = false)
6479public BoundCollectionExpressionSpreadExpressionPlaceholder(SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
6484public BoundCollectionExpressionSpreadExpressionPlaceholder(SyntaxNode syntax, TypeSymbol? type)
6507public BoundCollectionExpressionSpreadElement(SyntaxNode syntax, BoundExpression expression, BoundCollectionExpressionSpreadExpressionPlaceholder? expressionPlaceholder, BoundExpression? conversion, ForEachEnumeratorInfo? enumeratorInfoOpt, BoundExpression? lengthOrCount, BoundValuePlaceholder? elementPlaceholder, BoundStatement? iteratorBody, bool hasErrors = false)
6547protected BoundTupleExpression(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<bool> inferredNamesOpt, TypeSymbol? type, bool hasErrors = false)
6565public BoundTupleLiteral(SyntaxNode syntax, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<bool> inferredNamesOpt, TypeSymbol? type, bool hasErrors = false)
6592public BoundConvertedTupleLiteral(SyntaxNode syntax, BoundTupleLiteral? sourceTuple, bool wasTargetTyped, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<bool> inferredNamesOpt, TypeSymbol? type, bool hasErrors = false)
6622public BoundDynamicObjectCreationExpression(SyntaxNode syntax, string name, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, BoundObjectInitializerExpressionBase? initializerExpressionOpt, ImmutableArray<MethodSymbol> applicableMethods, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
6665public BoundNoPiaObjectCreationExpression(SyntaxNode syntax, string? guidString, BoundObjectInitializerExpressionBase? initializerExpressionOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
6697protected BoundObjectInitializerExpressionBase(BoundKind kind, SyntaxNode syntax, BoundObjectOrCollectionValuePlaceholder placeholder, ImmutableArray<BoundExpression> initializers, TypeSymbol type, bool hasErrors = false)
6716public BoundObjectInitializerExpression(SyntaxNode syntax, BoundObjectOrCollectionValuePlaceholder placeholder, ImmutableArray<BoundExpression> initializers, TypeSymbol type, bool hasErrors = false)
6744public BoundObjectInitializerMember(SyntaxNode syntax, Symbol? memberSymbol, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, LookupResultKind resultKind, AccessorKind accessorKind, TypeSymbol receiverType, TypeSymbol type, bool hasErrors = false)
6793public BoundDynamicObjectInitializerMember(SyntaxNode syntax, string memberName, TypeSymbol receiverType, TypeSymbol type, bool hasErrors)
6805public BoundDynamicObjectInitializerMember(SyntaxNode syntax, string memberName, TypeSymbol receiverType, TypeSymbol type)
6838public BoundCollectionInitializerExpression(SyntaxNode syntax, BoundObjectOrCollectionValuePlaceholder placeholder, ImmutableArray<BoundExpression> initializers, TypeSymbol type, bool hasErrors = false)
6866public BoundCollectionElementInitializer(SyntaxNode syntax, MethodSymbol addMethod, ImmutableArray<BoundExpression> arguments, BoundExpression? implicitReceiverOpt, bool expanded, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, bool invokedAsExtensionMethod, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false)
6911public BoundDynamicCollectionElementInitializer(SyntaxNode syntax, ImmutableArray<MethodSymbol> applicableMethods, BoundExpression expression, ImmutableArray<BoundExpression> arguments, TypeSymbol type, bool hasErrors = false)
6943public BoundImplicitReceiver(SyntaxNode syntax, TypeSymbol type, bool hasErrors)
6951public BoundImplicitReceiver(SyntaxNode syntax, TypeSymbol type)
6978public BoundAnonymousObjectCreationExpression(SyntaxNode syntax, MethodSymbol constructor, ImmutableArray<BoundExpression> arguments, ImmutableArray<BoundAnonymousPropertyDeclaration> declarations, TypeSymbol type, bool hasErrors = false)
7014public BoundAnonymousPropertyDeclaration(SyntaxNode syntax, PropertySymbol property, TypeSymbol type, bool hasErrors)
7024public BoundAnonymousPropertyDeclaration(SyntaxNode syntax, PropertySymbol property, TypeSymbol type)
7054public BoundNewT(SyntaxNode syntax, BoundObjectInitializerExpressionBase? initializerExpressionOpt, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
7084public BoundDelegateCreationExpression(SyntaxNode syntax, BoundExpression argument, MethodSymbol? methodOpt, bool isExtensionMethod, bool wasTargetTyped, TypeSymbol type, bool hasErrors = false)
7120public BoundArrayCreation(SyntaxNode syntax, ImmutableArray<BoundExpression> bounds, BoundArrayInitialization? initializerOpt, TypeSymbol type, bool hasErrors = false)
7152public BoundArrayInitialization(SyntaxNode syntax, bool isInferred, ImmutableArray<BoundExpression> initializers, bool hasErrors = false)
7183protected BoundStackAllocArrayCreationBase(BoundKind kind, SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol? type, bool hasErrors = false)
7202public BoundStackAllocArrayCreation(SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol? type, bool hasErrors = false)
7229public BoundConvertedStackAllocExpression(SyntaxNode syntax, TypeSymbol elementType, BoundExpression count, BoundArrayInitialization? initializerOpt, TypeSymbol type, bool hasErrors = false)
7258public BoundFieldAccess(SyntaxNode syntax, BoundExpression? receiverOpt, FieldSymbol fieldSymbol, ConstantValue? constantValueOpt, LookupResultKind resultKind, bool isByValue, bool isDeclaration, TypeSymbol type, bool hasErrors = false)
7298public BoundHoistedFieldAccess(SyntaxNode syntax, FieldSymbol fieldSymbol, TypeSymbol type, bool hasErrors)
7308public BoundHoistedFieldAccess(SyntaxNode syntax, FieldSymbol fieldSymbol, TypeSymbol type)
7338public BoundPropertyAccess(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, PropertySymbol propertySymbol, AccessorKind autoPropertyAccessorKind, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false)
7376public BoundEventAccess(SyntaxNode syntax, BoundExpression? receiverOpt, EventSymbol eventSymbol, bool isUsableAsField, LookupResultKind resultKind, TypeSymbol type, bool hasErrors = false)
7412public BoundIndexerAccess(SyntaxNode syntax, BoundExpression? receiverOpt, ThreeState initialBindingReceiverIsSubjectToCloning, PropertySymbol indexer, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, bool expanded, AccessorKind accessorKind, ImmutableArray<int> argsToParamsOpt, BitVector defaultArguments, ImmutableArray<PropertySymbol> originalIndexersOpt, TypeSymbol type, bool hasErrors = false)
7463public BoundImplicitIndexerAccess(SyntaxNode syntax, BoundExpression receiver, BoundExpression argument, BoundExpression lengthOrCountAccess, BoundImplicitIndexerReceiverPlaceholder receiverPlaceholder, BoundExpression indexerOrSliceAccess, ImmutableArray<BoundImplicitIndexerValuePlaceholder> argumentPlaceholders, TypeSymbol type, bool hasErrors = false)
7512public BoundInlineArrayAccess(SyntaxNode syntax, BoundExpression expression, BoundExpression argument, bool isValue, WellKnownMember getItemOrSliceHelper, TypeSymbol type, bool hasErrors = false)
7553public BoundDynamicIndexerAccess(SyntaxNode syntax, BoundExpression receiver, ImmutableArray<BoundExpression> arguments, ImmutableArray<string?> argumentNamesOpt, ImmutableArray<RefKind> argumentRefKindsOpt, ImmutableArray<PropertySymbol> applicableIndexers, TypeSymbol type, bool hasErrors = false)
7593public BoundLambda(SyntaxNode syntax, UnboundLambda unboundLambda, LambdaSymbol symbol, BoundBlock body, ReadOnlyBindingDiagnostic<AssemblySymbol> diagnostics, Binder binder, TypeSymbol? type, bool hasErrors = false)
7633public UnboundLambda(SyntaxNode syntax, UnboundLambdaState data, FunctionTypeSymbol? functionType, Boolean withDependencies, bool hasErrors)
7644public UnboundLambda(SyntaxNode syntax, UnboundLambdaState data, FunctionTypeSymbol? functionType, Boolean withDependencies)
7677public BoundQueryClause(SyntaxNode syntax, BoundExpression value, RangeVariableSymbol? definedSymbol, BoundExpression? operation, BoundExpression? cast, Binder binder, BoundExpression? unoptimizedForm, TypeSymbol type, bool hasErrors = false)
7718public BoundTypeOrInstanceInitializers(SyntaxNode syntax, ImmutableArray<BoundStatement> statements, bool hasErrors = false)
7744public BoundNameOfOperator(SyntaxNode syntax, BoundExpression argument, ConstantValue constantValueOpt, TypeSymbol type, bool hasErrors = false)
7777protected BoundInterpolatedStringBase(BoundKind kind, SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7793public BoundUnconvertedInterpolatedString(SyntaxNode syntax, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7819public BoundInterpolatedString(SyntaxNode syntax, InterpolatedStringHandlerData? interpolationData, ImmutableArray<BoundExpression> parts, ConstantValue? constantValueOpt, TypeSymbol? type, bool hasErrors = false)
7847public BoundInterpolatedStringHandlerPlaceholder(SyntaxNode syntax, TypeSymbol? type, bool hasErrors)
7852public BoundInterpolatedStringHandlerPlaceholder(SyntaxNode syntax, TypeSymbol? type)
7875public BoundInterpolatedStringArgumentPlaceholder(SyntaxNode syntax, int argumentIndex, TypeSymbol type, bool hasErrors)
7884public BoundInterpolatedStringArgumentPlaceholder(SyntaxNode syntax, int argumentIndex, TypeSymbol type)
7913public BoundStringInsert(SyntaxNode syntax, BoundExpression value, BoundExpression? alignment, BoundLiteral? format, bool isInterpolatedStringHandlerAppendCall, bool hasErrors = false)
7948public BoundIsPatternExpression(SyntaxNode syntax, BoundExpression expression, BoundPattern pattern, bool isNegated, BoundDecisionDag reachabilityDecisionDag, LabelSymbol whenTrueLabel, LabelSymbol whenFalseLabel, TypeSymbol? type, bool hasErrors = false)
7990protected BoundPattern(BoundKind kind, SyntaxNode syntax, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors)
8001protected BoundPattern(BoundKind kind, SyntaxNode syntax, TypeSymbol inputType, TypeSymbol narrowedType)
8018public BoundConstantPattern(SyntaxNode syntax, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8051public BoundDiscardPattern(SyntaxNode syntax, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors)
8060public BoundDiscardPattern(SyntaxNode syntax, TypeSymbol inputType, TypeSymbol narrowedType)
8087protected BoundObjectPattern(BoundKind kind, SyntaxNode syntax, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8104public BoundDeclarationPattern(SyntaxNode syntax, BoundTypeExpression declaredType, bool isVar, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8136public BoundRecursivePattern(SyntaxNode syntax, BoundTypeExpression? declaredType, MethodSymbol? deconstructMethod, ImmutableArray<BoundPositionalSubpattern> deconstruction, ImmutableArray<BoundPropertySubpattern> properties, bool isExplicitNotNullTest, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8173public BoundListPattern(SyntaxNode syntax, ImmutableArray<BoundPattern> subpatterns, bool hasSlice, BoundExpression? lengthAccess, BoundExpression? indexerAccess, BoundListPatternReceiverPlaceholder? receiverPlaceholder, BoundListPatternIndexPlaceholder? argumentPlaceholder, Symbol? variable, BoundExpression? variableAccess, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8217public BoundSlicePattern(SyntaxNode syntax, BoundPattern? pattern, BoundExpression? indexerAccess, BoundSlicePatternReceiverPlaceholder? receiverPlaceholder, BoundSlicePatternRangePlaceholder? argumentPlaceholder, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8256public BoundITuplePattern(SyntaxNode syntax, MethodSymbol getLengthMethod, MethodSymbol getItemMethod, ImmutableArray<BoundPositionalSubpattern> subpatterns, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8292protected BoundSubpattern(BoundKind kind, SyntaxNode syntax, BoundPattern pattern, bool hasErrors = false)
8306public BoundPositionalSubpattern(SyntaxNode syntax, Symbol? symbol, BoundPattern pattern, bool hasErrors = false)
8334public BoundPropertySubpattern(SyntaxNode syntax, BoundPropertySubpatternMember? member, bool isLengthOrCount, BoundPattern pattern, bool hasErrors = false)
8364public BoundPropertySubpatternMember(SyntaxNode syntax, BoundPropertySubpatternMember? receiver, Symbol? symbol, TypeSymbol type, bool hasErrors = false)
8396public BoundTypePattern(SyntaxNode syntax, BoundTypeExpression declaredType, bool isExplicitNotNullTest, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8428public BoundBinaryPattern(SyntaxNode syntax, bool disjunction, BoundPattern left, BoundPattern right, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8463public BoundNegatedPattern(SyntaxNode syntax, BoundPattern negated, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8493public BoundRelationalPattern(SyntaxNode syntax, BinaryOperatorKind relation, BoundExpression value, ConstantValue constantValue, TypeSymbol inputType, TypeSymbol narrowedType, bool hasErrors = false)
8528public BoundDiscardExpression(SyntaxNode syntax, NullableAnnotation nullableAnnotation, bool isInferred, TypeSymbol? type, bool hasErrors)
8535public BoundDiscardExpression(SyntaxNode syntax, NullableAnnotation nullableAnnotation, bool isInferred, TypeSymbol? type)
8563public BoundThrowExpression(SyntaxNode syntax, BoundExpression expression, TypeSymbol? type, bool hasErrors = false)
8591protected VariablePendingInference(BoundKind kind, SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false)
8608public OutVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false)
8634public DeconstructionVariablePendingInference(SyntaxNode syntax, Symbol variableSymbol, BoundExpression? receiverOpt, bool hasErrors = false)
8660public OutDeconstructVarPendingInference(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression, bool hasErrors)
8667public OutDeconstructVarPendingInference(SyntaxNode syntax, Symbol? variableSymbol, bool isDiscardExpression)
8695protected BoundMethodBodyBase(BoundKind kind, SyntaxNode syntax, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false)
8708public BoundNonConstructorMethodBody(SyntaxNode syntax, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false)
8731public BoundConstructorMethodBody(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundStatement? initializer, BoundBlock? blockBody, BoundBlock? expressionBody, bool hasErrors = false)
8761public BoundExpressionWithNullability(SyntaxNode syntax, BoundExpression expression, NullableAnnotation nullableAnnotation, TypeSymbol? type, bool hasErrors = false)
8792public BoundWithExpression(SyntaxNode syntax, BoundExpression receiver, MethodSymbol? cloneMethod, BoundObjectInitializerExpressionBase initializerExpression, TypeSymbol type, bool hasErrors = false)
Lowering\ClosureConversion\ClosureConversion.cs (15)
367var syntax = scopeBoundNode.Syntax;
410var syntax = originalMethod.DeclaringSyntaxReferences[0].GetSyntax();
504private SynthesizedClosureEnvironment GetStaticFrame(BindingDiagnosticBag diagnostics, SyntaxNode syntax)
577private BoundExpression FrameOfType(SyntaxNode syntax, NamedTypeSymbol frameType)
592protected override BoundExpression FramePointer(SyntaxNode syntax, NamedTypeSymbol frameClass)
668SyntaxNode syntax = node.Syntax;
744private void InitVariableProxy(SyntaxNode syntax, Symbol symbol, LocalSymbol framePointer, ArrayBuilder<BoundExpression> prologue)
869SyntaxNode syntax,
1011SyntaxNode syntax,
1439private DebugId GetLambdaId(SyntaxNode syntax, ClosureKind closureKind, int closureOrdinal, ImmutableArray<DebugId> structClosureIds, RuntimeRudeEdit? closureRudeEdit)
1445SyntaxNode? lambdaOrLambdaBodySyntax;
1455lambdaOrLambdaBodySyntax = (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody?.Expression;
1765private static bool InLoopOrLambda(SyntaxNode lambdaSyntax, SyntaxNode scopeSyntax)
1767var curSyntax = lambdaSyntax.Parent;
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (15)
128SyntaxNode syntax = MethodDeclarationIfAvailable(methodBody.Syntax);
167SyntaxNode methodBodySyntax,
476private static Cci.DebugSourceDocument GetSourceDocument(DebugDocumentProvider debugDocumentProvider, SyntaxNode syntax)
481private static Cci.DebugSourceDocument GetSourceDocument(DebugDocumentProvider debugDocumentProvider, SyntaxNode syntax, FileLinePositionSpan span)
493private BoundStatement AddAnalysisPoint(SyntaxNode syntaxForSpan, Text.TextSpan alternateSpan, SyntheticBoundNodeFactory statementFactory)
498private BoundStatement AddAnalysisPoint(SyntaxNode syntaxForSpan, SyntheticBoundNodeFactory statementFactory)
503private BoundStatement AddAnalysisPoint(SyntaxNode syntaxForSpan, FileLinePositionSpan span, SyntheticBoundNodeFactory statementFactory)
523private static SyntaxNode SyntaxForSpan(BoundStatement statement)
525SyntaxNode syntaxForSpan;
564private static MethodSymbol GetCreatePayloadOverload(CSharpCompilation compilation, WellKnownMember overload, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
569private static SyntaxNode MethodDeclarationIfAvailable(SyntaxNode body)
571SyntaxNode? parent = body.Parent;
593private static TextSpan SkipAttributes(SyntaxNode syntax)
623private static TextSpan SkipAttributes(SyntaxNode syntax, SyntaxList<AttributeListSyntax> attributes, SyntaxTokenList modifiers, SyntaxToken keyword, TypeSyntax? type)
Lowering\LocalRewriter\LocalRewriter.cs (11)
581private static BoundExpression BadExpression(SyntaxNode syntax, TypeSymbol resultType, BoundExpression child)
586private static BoundExpression BadExpression(SyntaxNode syntax, TypeSymbol resultType, BoundExpression child1, BoundExpression child2)
591private static BoundExpression BadExpression(SyntaxNode syntax, TypeSymbol resultType, ImmutableArray<BoundExpression> children)
596private bool TryGetWellKnownTypeMember<TSymbol>(SyntaxNode? syntax, WellKnownMember member, [NotNullWhen(true)] out TSymbol? symbol, bool isOptional = false, Location? location = null) where TSymbol : Symbol
606/// Recommendation: Do not use, use <see cref="TryGetSpecialTypeMethod(SyntaxNode, SpecialMember, out MethodSymbol, bool)"/> instead!
609private MethodSymbol UnsafeGetSpecialTypeMethod(SyntaxNode syntax, SpecialMember specialMember)
616/// Recommendation: Do not use, use <see cref="TryGetSpecialTypeMethod(SyntaxNode, SpecialMember, CSharpCompilation, BindingDiagnosticBag, out MethodSymbol, bool)"/> instead!
619private static MethodSymbol UnsafeGetSpecialTypeMethod(SyntaxNode syntax, SpecialMember specialMember, CSharpCompilation compilation, BindingDiagnosticBag diagnostics)
636private bool TryGetSpecialTypeMethod(SyntaxNode syntax, SpecialMember specialMember, out MethodSymbol method, bool isOptional = false)
641private static bool TryGetSpecialTypeMethod(SyntaxNode syntax, SpecialMember specialMember, CSharpCompilation compilation, BindingDiagnosticBag diagnostics, out MethodSymbol method, bool isOptional = false)
863var syntax = initializer.Syntax;
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.ValueDispatchNode.cs (7)
28public readonly SyntaxNode Syntax;
30public ValueDispatchNode(SyntaxNode syntax) => Syntax = syntax;
40public SwitchDispatch(SyntaxNode syntax, ImmutableArray<(ConstantValue value, LabelSymbol label)> dispatches, LabelSymbol otherwise) : base(syntax)
54public LeafDispatchNode(SyntaxNode syntax, LabelSymbol Label) : base(syntax) => this.Label = Label;
86private RelationalDispatch(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode left, ValueDispatchNode right) : base(syntax)
133public static ValueDispatchNode CreateBalanced(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode whenTrue, ValueDispatchNode whenFalse)
140private static ValueDispatchNode CreateBalancedCore(SyntaxNode syntax, ConstantValue value, BinaryOperatorKind op, ValueDispatchNode left, ValueDispatchNode right)
Lowering\LocalRewriter\LocalRewriter.PatternLocalRewriter.cs (6)
30public PatternLocalRewriter(SyntaxNode node, LocalRewriter localRewriter, bool generateInstrumentation)
58private readonly SyntaxNode _node;
62public DagTempAllocator(SyntheticBoundNodeFactory factory, SyntaxNode node, bool generateSequencePoints)
367private BoundExpression MakeNullCheck(SyntaxNode syntax, BoundExpression rewrittenExpr, BinaryOperatorKind operatorKind)
387protected BoundExpression MakeValueTest(SyntaxNode syntax, BoundExpression input, ConstantValue value)
401protected BoundExpression MakeRelationalTest(SyntaxNode syntax, BoundExpression input, BinaryOperatorKind operatorKind, ConstantValue value)
Lowering\LocalRewriter\LocalRewriter_BinaryOperator.cs (36)
71var syntax = node.Syntax;
175SyntaxNode syntax,
191SyntaxNode syntax,
537private BoundExpression RewriteLiftedBinaryOperator(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, MethodSymbol? method, TypeSymbol? constrainedToTypeOpt)
596SyntaxNode syntax,
725private BoundExpression MakeTruthTestForDynamicLogicalOperator(SyntaxNode syntax, BoundExpression loweredLeft, TypeSymbol boolean, MethodSymbol? leftTruthOperator, TypeSymbol? constrainedToTypeOpt, bool negative)
768SyntaxNode syntax,
796SyntaxNode syntax,
888private BoundExpression MakeOptimizedGetValueOrDefault(SyntaxNode syntax, BoundExpression expression)
906private BoundExpression MakeBooleanConstant(SyntaxNode syntax, bool value)
911private BoundExpression MakeOptimizedHasValue(SyntaxNode syntax, BoundExpression expression)
925private BoundExpression MakeNullableHasValue(SyntaxNode syntax, BoundExpression expression)
936SyntaxNode syntax,
1126SyntaxNode syntax,
1294SyntaxNode syntax,
1334SyntaxNode syntax,
1360SyntaxNode syntax,
1403SyntaxNode syntax,
1505SyntaxNode syntax,
1640private BoundExpression MakeNewNullableBoolean(SyntaxNode syntax, bool? value)
1656SyntaxNode syntax,
1741SyntaxNode syntax,
1802SyntaxNode syntax,
1894private MethodSymbol UnsafeGetNullableMethod(SyntaxNode syntax, TypeSymbol nullableType, SpecialMember member)
1904internal static MethodSymbol UnsafeGetNullableMethod(SyntaxNode syntax, TypeSymbol nullableType, SpecialMember member, CSharpCompilation compilation, BindingDiagnosticBag diagnostics)
1911private bool TryGetNullableMethod(SyntaxNode syntax, TypeSymbol nullableType, SpecialMember member, out MethodSymbol result, bool isOptional = false)
1924SyntaxNode syntax,
1995private BoundExpression RewriteStringEquality(BoundBinaryOperator? oldNode, SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, SpecialMember member)
2008private BoundExpression RewriteDelegateOperation(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type, SpecialMember member)
2038private BoundExpression RewriteDecimalBinaryOperation(SyntaxNode syntax, BoundExpression loweredLeft, BoundExpression loweredRight, BinaryOperatorKind operatorKind)
2069private BoundExpression MakeNullCheck(SyntaxNode syntax, BoundExpression rewrittenExpr, BinaryOperatorKind operatorKind)
2128SyntaxNode syntax,
2135SyntaxNode rightSyntax = loweredRight.Syntax;
2190SyntaxNode syntax,
2213var oldSyntax = _factory.Syntax;
2250SyntaxNode syntax,
Lowering\LocalRewriter\LocalRewriter_Call.cs (6)
97private void EmbedIfNeedTo(BoundExpression receiver, ImmutableArray<MethodSymbol> methods, SyntaxNode syntaxNode)
116private void EmbedIfNeedTo(BoundExpression receiver, ImmutableArray<PropertySymbol> properties, SyntaxNode syntaxNode)
439SyntaxNode syntax,
522private BoundExpression MakeCall(SyntaxNode syntax, BoundExpression? rewrittenReceiver, MethodSymbol method, ImmutableArray<BoundExpression> rewrittenArguments)
1398private BoundExpression CreateEmptyArray(SyntaxNode syntax, ArrayTypeSymbol arrayType)
1418private BoundExpression? CreateArrayEmptyCallIfAvailable(SyntaxNode syntax, TypeSymbol elementType)
Lowering\LocalRewriter\LocalRewriter_Conversion.cs (22)
99var save_Syntax = _factory.Syntax;
142private BoundArrayCreation MakeUnderlyingArrayForUtf8Span(SyntaxNode syntax, ArrayTypeSymbol byteArray, IReadOnlyList<byte> bytes, out int length)
264SyntaxNode syntax,
299SyntaxNode syntax,
568var oldSyntax = _factory.Syntax;
740private void EnsureParamCollectionAttributeExists(SyntaxNode node, TypeSymbol delegateType)
837SyntaxNode syntax,
947SyntaxNode syntax,
1034SyntaxNode syntax,
1090SyntaxNode syntax,
1142SyntaxNode syntax,
1204SyntaxNode syntax,
1236SyntaxNode syntax,
1276SyntaxNode syntax,
1338SyntaxNode syntax,
1392SyntaxNode syntax,
1480SyntaxNode syntax,
1695private BoundExpression RewriteDecimalConversion(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool @checked, bool isImplicit, ConstantValue? constantValueOpt)
1726private BoundExpression RewriteDecimalConversionCore(SyntaxNode syntax, BoundExpression operand, TypeSymbol fromType, TypeSymbol toType, bool isImplicit, ConstantValue? constantValueOpt)
1752private Conversion TryMakeConversion(SyntaxNode syntax, Conversion conversion, TypeSymbol fromType, TypeSymbol toType, bool @checked)
1853private Conversion TryMakeConversion(SyntaxNode syntax, TypeSymbol fromType, TypeSymbol toType, bool @checked)
1864private Conversion TryMakeUserDefinedConversion(SyntaxNode syntax, MethodSymbol meth, TypeSymbol fromType, TypeSymbol toType, bool @checked, bool isImplicit)
Lowering\LocalRewriter\LocalRewriter_ForEachStatement.cs (12)
70private bool CanRewriteForEachAsFor(SyntaxNode forEachSyntax, TypeSymbol nodeExpressionType, [NotNullWhen(true)] out MethodSymbol? indexerGet, [NotNullWhen(true)] out MethodSymbol? lengthGet)
290private bool TryGetDisposeMethod(SyntaxNode forEachSyntax, ForEachEnumeratorInfo enumeratorInfo, out MethodSymbol disposeMethod)
475private BoundStatement WrapWithAwait(SyntaxNode forEachSyntax, BoundExpression disposeCall, BoundAwaitableInfo disposeAwaitableInfoOpt)
707private delegate BoundStatement? GetForEachStatementAsForPreamble(LocalRewriter rewriter, SyntaxNode syntax, ForEachEnumeratorInfo enumeratorInfo, ref BoundExpression rewrittenExpression, out LocalSymbol? preambleLocal, out RefKind collectionTempRefKind);
708private delegate BoundExpression GetForEachStatementAsForItem<TArg>(LocalRewriter rewriter, SyntaxNode syntax, ForEachEnumeratorInfo enumeratorInfo, BoundLocal boundArrayVar, BoundLocal boundPositionVar, TArg arg);
709private delegate BoundExpression GetForEachStatementAsForLength<TArg>(LocalRewriter rewriter, SyntaxNode syntax, BoundLocal boundArrayVar, TArg arg);
715getItem: static (LocalRewriter rewriter, SyntaxNode syntax, ForEachEnumeratorInfo enumeratorInfo, BoundLocal boundArrayVar, BoundLocal boundPositionVar, (MethodSymbol indexerGet, MethodSymbol lengthGet) arg) =>
724getLength: static (LocalRewriter rewriter, SyntaxNode syntax, BoundLocal boundArrayVar, (MethodSymbol indexerGet, MethodSymbol lengthGet) arg) =>
746return static (LocalRewriter rewriter, SyntaxNode syntax, ForEachEnumeratorInfo enumeratorInfo, ref BoundExpression rewrittenExpression, out LocalSymbol? preambleLocal, out RefKind collectionTempRefKind) =>
767return static (LocalRewriter rewriter, SyntaxNode syntax, ForEachEnumeratorInfo enumeratorInfo, BoundLocal boundArrayVar, BoundLocal boundPositionVar, object? _) =>
793return static (LocalRewriter rewriter, SyntaxNode syntax, BoundLocal boundArrayVar, object? _) =>
841SyntaxNode forEachSyntax)
Lowering\LocalRewriter\LocalRewriter_StringConcat.cs (11)
37private BoundExpression RewriteStringConcatenation(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type)
369private BoundExpression RewriteStringConcatenationTwoExprs(SyntaxNode syntax, BoundExpression loweredLeft, BoundExpression loweredRight)
380private BoundExpression RewriteStringConcatenationThreeExprs(SyntaxNode syntax, BoundExpression loweredFirst, BoundExpression loweredSecond, BoundExpression loweredThird)
392private BoundExpression RewriteStringConcatenationFourExprs(SyntaxNode syntax, BoundExpression loweredFirst, BoundExpression loweredSecond, BoundExpression loweredThird, BoundExpression loweredFourth)
405private BoundExpression RewriteStringConcatenationManyExprs(SyntaxNode syntax, ImmutableArray<BoundExpression> loweredArgs)
418private bool TryRewriteStringConcatenationWithSpanBasedConcat(SyntaxNode syntax, ArrayBuilder<BoundExpression> args, [NotNullWhen(true)] out BoundExpression? result)
496SyntaxNode syntax,
525SyntaxNode syntax,
576var oldSyntax = factory.Syntax;
593private BoundExpression RewriteStringConcatInExpressionLambda(SyntaxNode syntax, BinaryOperatorKind operatorKind, BoundExpression loweredLeft, BoundExpression loweredRight, TypeSymbol type)
611var syntax = expr.Syntax;
Lowering\LocalRewriter\LocalRewriter_UnaryOperator.cs (11)
64SyntaxNode syntax,
76SyntaxNode syntax,
180SyntaxNode syntax,
244SyntaxNode syntax,
353private BoundExpression GetLiftedUnaryOperatorConsequence(UnaryOperatorKind kind, SyntaxNode syntax, MethodSymbol? method, TypeSymbol? constrainedToTypeOpt, TypeSymbol type, BoundExpression nonNullOperand)
434SyntaxNode syntax = node.Syntax;
507SyntaxNode syntax,
535SyntaxNode syntax,
638SyntaxNode syntax = node.Syntax;
824private BoundExpression MakeDecimalIncDecOperator(SyntaxNode syntax, BinaryOperatorKind oper, BoundExpression operand)
831private BoundExpression MakeLiftedDecimalIncDecOperator(SyntaxNode syntax, BinaryOperatorKind oper, BoundExpression operand)
Lowering\StateMachineRewriter\CapturedSymbol.cs (4)
26public abstract BoundExpression Replacement<TArg>(SyntaxNode node, Func<NamedTypeSymbol, TArg, BoundExpression> makeFrame, TArg arg);
39public override BoundExpression Replacement<TArg>(SyntaxNode node, Func<NamedTypeSymbol, TArg, BoundExpression> makeFrame, TArg arg)
57public override BoundExpression Replacement<TArg>(SyntaxNode node, Func<NamedTypeSymbol, TArg, BoundExpression> makeFrame, TArg arg)
77public override BoundExpression Replacement<TArg>(SyntaxNode node, Func<NamedTypeSymbol, TArg, BoundExpression> makeFrame, TArg arg)
Lowering\StateMachineRewriter\MethodToStateMachineRewriter.cs (8)
204protected override BoundExpression FramePointer(SyntaxNode syntax, NamedTypeSymbol frameClass)
206var oldSyntax = F.Syntax;
214protected void AddResumableState(SyntaxNode awaitOrYieldReturnSyntax, AwaitDebugId awaitId, out StateMachineState state, out GeneratedLabelSymbol resumeLabel)
217protected void AddResumableState(ResumableStateMachineStateAllocator allocator, SyntaxNode awaitOrYieldReturnSyntax, AwaitDebugId awaitId, out StateMachineState stateNumber, out GeneratedLabelSymbol resumeLabel)
224protected void AddStateDebugInfo(SyntaxNode node, AwaitDebugId awaitId, StateMachineState state)
528SyntaxNode awaitSyntaxOpt;
576SyntaxNode awaitSyntaxOpt,
726var oldSyntax = F.Syntax;
Lowering\SyntheticBoundNodeFactory.cs (15)
45public SyntaxNode Syntax { get; set; }
103public SyntheticBoundNodeFactory(MethodSymbol topLevelMethod, SyntaxNode node, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics, InstrumentationState? instrumentationState = null)
114public SyntheticBoundNodeFactory(MethodSymbol? topLevelMethodOpt, NamedTypeSymbol? currentClassOpt, SyntaxNode node, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics, InstrumentationState? instrumentationState = null)
429public BoundExpression AssignmentExpression(SyntaxNode syntax, BoundExpression left, BoundExpression right, bool isRef = false, bool hasErrors = false, bool wasCompilerGenerated = false)
583SyntaxNode? syntax = null,
605SyntaxNode syntax
1192public BoundStatement SequencePoint(SyntaxNode syntax, BoundStatement statement)
1229public static BoundExpression Null(TypeSymbol type, SyntaxNode syntax)
1570internal static BoundExpression Default(TypeSymbol type, SyntaxNode syntax)
1615internal static BoundExpression NullOrDefault(TypeSymbol typeSymbol, SyntaxNode syntax)
1636SyntaxNode? syntaxOpt = null
1675var syntax = argument.Syntax;
1741internal BoundExpression MakeNullCheck(SyntaxNode syntax, BoundExpression rewrittenExpr, BinaryOperatorKind operatorKind)
1793internal BoundExpression MakeNullableHasValue(SyntaxNode syntax, BoundExpression expression)
1804SyntaxNode syntax,
Symbols\Source\ParameterHelpers.cs (5)
986internal static ImmutableArray<CustomModifier> ConditionallyCreateInModifiers(RefKind refKind, bool addRefReadOnlyModifier, Binder binder, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
998internal static ImmutableArray<CustomModifier> CreateInModifiers(Binder binder, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1004private static ImmutableArray<CustomModifier> CreateRefReadonlyParameterModifiers(Binder binder, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1010internal static ImmutableArray<CustomModifier> CreateOutModifiers(Binder binder, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
1015private static ImmutableArray<CustomModifier> CreateModifiers(WellKnownType modifier, Binder binder, BindingDiagnosticBag diagnostics, SyntaxNode syntax)
Symbols\TypeWithAnnotations.cs (6)
539public void ReportDiagnosticsIfObsolete(Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics) =>
547private void ReportDiagnosticsIfObsoleteCore(Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
877internal abstract void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics);
940internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1033internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
1176internal override void ReportDiagnosticsIfObsolete(TypeWithAnnotations type, Binder binder, SyntaxNode syntax, BindingDiagnosticBag diagnostics)
Syntax\CSharpSyntaxNode.cs (19)
28internal CSharpSyntaxNode(GreenNode green, SyntaxNode? parent, int position)
187public static SyntaxNode DeserializeFrom(Stream stream, CancellationToken cancellationToken = default)
451protected override bool EquivalentToCore(SyntaxNode other)
464protected internal override SyntaxNode ReplaceCore<TNode>(
466Func<TNode, TNode, SyntaxNode>? computeReplacementNode = null,
475protected internal override SyntaxNode ReplaceNodeInListCore(SyntaxNode originalNode, IEnumerable<SyntaxNode> replacementNodes)
480protected internal override SyntaxNode InsertNodesInListCore(SyntaxNode nodeInList, IEnumerable<SyntaxNode> nodesToInsert, bool insertBefore)
485protected internal override SyntaxNode ReplaceTokenInListCore(SyntaxToken originalToken, IEnumerable<SyntaxToken> newTokens)
490protected internal override SyntaxNode InsertTokensInListCore(SyntaxToken originalToken, IEnumerable<SyntaxToken> newTokens, bool insertBefore)
495protected internal override SyntaxNode ReplaceTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia)
500protected internal override SyntaxNode InsertTriviaInListCore(SyntaxTrivia originalTrivia, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore)
505protected internal override SyntaxNode? RemoveNodesCore(IEnumerable<SyntaxNode> nodes, SyntaxRemoveOptions options)
510protected internal override SyntaxNode NormalizeWhitespaceCore(string indentation, string eol, bool elasticTrivia)
515protected override bool IsEquivalentToCore(SyntaxNode node, bool topLevel = false)
Syntax\SyntaxFactory.cs (19)
1228public static SyntaxList<TNode> List<TNode>() where TNode : SyntaxNode
1239public static SyntaxList<TNode> SingletonList<TNode>(TNode node) where TNode : SyntaxNode
1249public static SyntaxList<TNode> List<TNode>(IEnumerable<TNode> nodes) where TNode : SyntaxNode
1333public static SeparatedSyntaxList<TNode> SeparatedList<TNode>() where TNode : SyntaxNode
1343public static SeparatedSyntaxList<TNode> SingletonSeparatedList<TNode>(TNode node) where TNode : SyntaxNode
1353public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(IEnumerable<TNode>? nodes) where TNode : SyntaxNode
1405public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(IEnumerable<TNode>? nodes, IEnumerable<SyntaxToken>? separators) where TNode : SyntaxNode
1453public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(IEnumerable<SyntaxNodeOrToken> nodesAndTokens) where TNode : SyntaxNode
1464public static SeparatedSyntaxList<TNode> SeparatedList<TNode>(SyntaxNodeOrTokenList nodesAndTokens) where TNode : SyntaxNode
1547public static SyntaxTree SyntaxTree(SyntaxNode root, ParseOptions? options = null, string path = "", Encoding? encoding = null)
1648/// Since this API does not create a <see cref="SyntaxNode"/> that owns all produced tokens,
1963public static bool AreEquivalent(SyntaxNode? oldNode, SyntaxNode? newNode, bool topLevel)
1977public static bool AreEquivalent(SyntaxNode? oldNode, SyntaxNode? newNode, Func<SyntaxKind, bool>? ignoreChildNode = null)
2028where TNode : SyntaxNode
2044where TNode : SyntaxNode
2059where TNode : SyntaxNode
2348var lastNode = compilation.ChildNodes().LastOrDefault();
Syntax\SyntaxReplacer.cs (44)
17internal static SyntaxNode Replace<TNode>(
18SyntaxNode root,
20Func<TNode, TNode, SyntaxNode>? computeReplacementNode = null,
25where TNode : SyntaxNode
44IEnumerable<SyntaxNode>? nodes = null,
45Func<SyntaxNode, SyntaxNode, SyntaxNode>? computeReplacementNode = null,
51var replacer = new Replacer<SyntaxNode>(
66private class Replacer<TNode> : CSharpSyntaxRewriter where TNode : SyntaxNode
68private readonly Func<TNode, TNode, SyntaxNode>? _computeReplacementNode;
72private readonly HashSet<SyntaxNode> _nodeSet;
83Func<TNode, TNode, SyntaxNode>? computeReplacementNode,
93_nodeSet = nodes != null ? new HashSet<SyntaxNode>(nodes) : s_noNodes;
112private static readonly HashSet<SyntaxNode> s_noNodes = new HashSet<SyntaxNode>();
180public override SyntaxNode? Visit(SyntaxNode? node)
182SyntaxNode? rewritten = node;
235internal static SyntaxNode ReplaceNodeInList(SyntaxNode root, SyntaxNode originalNode, IEnumerable<SyntaxNode> newNodes)
240internal static SyntaxNode InsertNodeInList(SyntaxNode root, SyntaxNode nodeInList, IEnumerable<SyntaxNode> nodesToInsert, bool insertBefore)
245public static SyntaxNode ReplaceTokenInList(SyntaxNode root, SyntaxToken tokenInList, IEnumerable<SyntaxToken> newTokens)
250public static SyntaxNode InsertTokenInList(SyntaxNode root, SyntaxToken tokenInList, IEnumerable<SyntaxToken> newTokens, bool insertBefore)
255public static SyntaxNode ReplaceTriviaInList(SyntaxNode root, SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia)
260public static SyntaxNode InsertTriviaInList(SyntaxNode root, SyntaxTrivia triviaInList, IEnumerable<SyntaxTrivia> newTrivia, bool insertBefore)
328public override SyntaxNode? Visit(SyntaxNode? node)
330SyntaxNode? rewritten = node;
370private readonly SyntaxNode _originalNode;
371private readonly IEnumerable<SyntaxNode> _newNodes;
374SyntaxNode originalNode,
375IEnumerable<SyntaxNode> replacementNodes,
384public override SyntaxNode? Visit(SyntaxNode? node)
src\Analyzers\CSharp\Analyzers\RemoveConfusingSuppression\CSharpRemoveConfusingSuppressionDiagnosticAnalyzer.cs (1)
32var node = context.Node;
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper.cs (8)
25public abstract BlockSyntax? GetBody(SyntaxNode declaration);
26public abstract ArrowExpressionClauseSyntax? GetExpressionBody(SyntaxNode declaration);
27public abstract bool IsRelevantDeclarationNode(SyntaxNode node);
29public abstract bool CanOfferUseExpressionBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, CancellationToken cancellationToken);
30public abstract bool CanOfferUseBlockBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, out bool fixesError, [NotNullWhen(true)] out ArrowExpressionClauseSyntax? expressionBody);
31public abstract SyntaxNode Update(SemanticModel semanticModel, SyntaxNode declaration, bool useExpressionBody, CancellationToken cancellationToken);
33public abstract Location GetDiagnosticLocation(SyntaxNode declaration);
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (10)
28where TDeclaration : SyntaxNode
63public override BlockSyntax? GetBody(SyntaxNode declaration)
66public override ArrowExpressionClauseSyntax? GetExpressionBody(SyntaxNode declaration)
69public override bool IsRelevantDeclarationNode(SyntaxNode node)
72public override bool CanOfferUseExpressionBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, CancellationToken cancellationToken)
75public override bool CanOfferUseBlockBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, out bool fixesError, [NotNullWhen(true)] out ArrowExpressionClauseSyntax? expressionBody)
78public sealed override SyntaxNode Update(SemanticModel semanticModel, SyntaxNode declaration, bool useExpressionBody, CancellationToken cancellationToken)
81public override Location GetDiagnosticLocation(SyntaxNode declaration)
131SyntaxNode declaration, ExpressionBodyPreference conversionPreference, CancellationToken cancellationToken,
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (3)
118private void ReportParameterArrayDiagnostic(OperationAnalysisContext context, SyntaxNode syntaxNode, ImmutableArray<IOperation> elements, NotificationOption2 notificationOption, ArrayCreationOperationLocation operationLocation)
130private void ReportArrayCreationDiagnostic(OperationAnalysisContext context, SyntaxNode syntaxNode, NotificationOption2 notificationOption)
138private void ReportDiagnostic(OperationAnalysisContext context, SyntaxNode syntaxNode, NotificationOption2 notificationOption, Location location, ArrayCreationOperationLocation operationLocation)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (74)
23public static LanguageVersion GetLanguageVersion(this SyntaxNode node)
26public static void Deconstruct(this SyntaxNode node, out SyntaxKind kind)
29public static bool IsKind<TNode>([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind, [NotNullWhen(true)] out TNode? result)
30where TNode : SyntaxNode
42public static bool IsParentKind([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind)
45public static bool IsParentKind<TNode>([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind, [NotNullWhen(true)] out TNode? result)
46where TNode : SyntaxNode
59this SyntaxNode node, SourceText? sourceText = null,
88public static bool IsAnyArgumentList([NotNullWhen(true)] this SyntaxNode? node)
97public static (SyntaxToken openBrace, SyntaxToken closeBrace) GetBraces(this SyntaxNode? node)
114public static bool IsEmbeddedStatementOwner([NotNullWhen(true)] this SyntaxNode? node)
128public static StatementSyntax? GetEmbeddedStatement(this SyntaxNode? node)
144public static BaseParameterListSyntax? GetParameterList(this SyntaxNode? declaration)
157public static SyntaxList<AttributeListSyntax> GetAttributeLists(this SyntaxNode? declaration)
170public static ConditionalAccessExpressionSyntax? GetParentConditionalAccessExpression(this SyntaxNode? node)
182var current = node;
249/// <inheritdoc cref="ISyntaxFacts.GetRootConditionalAccessExpression(SyntaxNode)"/>
251public static ConditionalAccessExpressionSyntax? GetRootConditionalAccessExpression(this SyntaxNode? node)
268public static ConditionalAccessExpressionSyntax? GetInnerMostConditionalAccessExpression(this SyntaxNode node)
279public static bool IsAsyncSupportingFunctionSyntax([NotNullWhen(true)] this SyntaxNode? node)
282public static bool IsCompoundAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
285public static bool IsLeftSideOfAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
289public static bool IsLeftSideOfAnyAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
292public static bool IsRightSideOfAnyAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
295public static bool IsLeftSideOfCompoundAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
306public static IEnumerable<UsingDirectiveSyntax> GetEnclosingUsingDirectives(this SyntaxNode node)
314public static IEnumerable<ExternAliasDirectiveSyntax> GetEnclosingExternAliasDirectives(this SyntaxNode node)
322public static bool IsUnsafeContext(this SyntaxNode node)
333public static bool IsInStaticContext(this SyntaxNode node)
335for (var current = node; current != null; current = current.Parent)
370public static BaseNamespaceDeclarationSyntax? GetInnermostNamespaceDeclarationWithUsings(this SyntaxNode contextNode)
393public static bool IsBreakableConstruct(this SyntaxNode node)
409public static bool IsContinuableConstruct(this SyntaxNode node)
424public static bool IsReturnableConstruct(this SyntaxNode node)
448public static bool ContainsYield(this SyntaxNode node)
451public static bool IsReturnableConstructOrTopLevelCompilationUnit(this SyntaxNode node)
454public static bool SpansPreprocessorDirective<TSyntaxNode>(this IEnumerable<TSyntaxNode> list) where TSyntaxNode : SyntaxNode
459where TNode : SyntaxNode
507public static bool ContainsInterleavedDirective(this SyntaxNode syntaxNode, CancellationToken cancellationToken)
511/// Similar to <see cref="ContainsInterleavedDirective(SyntaxNode, CancellationToken)"/> except that the span to check
514public static bool ContainsInterleavedDirective(this SyntaxNode syntaxNode, TextSpan span, CancellationToken cancellationToken)
553var structure = trivia.GetStructure()!;
595where TSyntaxNode : SyntaxNode
655public static ImmutableArray<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
658public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
661public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode
664public static ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
667public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
670public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode
673public static bool IsVariableDeclaratorValue([NotNullWhen(true)] this SyntaxNode? node)
677public static BlockSyntax? FindInnermostCommonBlock(this IEnumerable<SyntaxNode> nodes)
680public static IEnumerable<SyntaxNode> GetAncestorsOrThis(this SyntaxNode? node, Func<SyntaxNode, bool> predicate)
682var current = node;
694public static (SyntaxToken openParen, SyntaxToken closeParen) GetParentheses(this SyntaxNode node)
724public static (SyntaxToken openBracket, SyntaxToken closeBracket) GetBrackets(this SyntaxNode? node)
737public static SyntaxTokenList GetModifiers(this SyntaxNode? member)
749public static SyntaxNode? WithModifiers(this SyntaxNode? member, SyntaxTokenList modifiers)
760public static void ForEachMember<TArg>(this SyntaxNode? node, Action<MemberDeclarationSyntax, TArg> callback, TArg arg)
785[NotNullWhen(true)] this SyntaxNode? node,
792for (var current = node; current != null; current = current.Parent)
837[NotNullWhen(true)] this SyntaxNode? node,
838[NotNullWhen(true)] out SyntaxNode? deconstructionLeft)
840SyntaxNode? previous = null;
841for (var current = node; current != null; current = current.Parent)
863where T : SyntaxNode
872where T : SyntaxNode
880where T : SyntaxNode
886public static T KeepCommentsAndAddElasticMarkers<T>(this T node) where T : SyntaxNode
891public static SyntaxNode WithPrependedNonIndentationTriviaFrom(
892this SyntaxNode to, SyntaxNode from)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\CSharpFormatEngine.cs (1)
16SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (10)
46public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
65private static void AddTypeParameterConstraintClauseOperation(List<IndentBlockOperation> list, SyntaxNode node)
74private void AddSwitchIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
134private void AddLabelIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
150private static void AddAlignmentBlockOperation(List<IndentBlockOperation> list, SyntaxNode node)
205private static void SetAlignmentBlockOperation(List<IndentBlockOperation> list, SyntaxNode baseNode, SyntaxNode body)
216private void AddBlockIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
253private static void AddBracketIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
288private static void AddEmbeddedStatementsIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\Precedence\AbstractCSharpPrecedenceService.cs (1)
13where TSyntax : SyntaxNode
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (29)
40public bool IsWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
43public bool IsOnlyWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
46public bool IsInOutContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
49public bool IsInRefContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
52public bool IsInInContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
55public bool CanReplaceWithRValue(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? expression, CancellationToken cancellationToken)
62foreach (var ancestor in token.GetAncestors<SyntaxNode>())
112SyntaxNode oldNode,
113SyntaxNode newNode,
169public ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode node)
183public SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
186public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
197public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
209public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
234var node = syntaxRef.GetSyntax(cancellationToken);
245public IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken)
255public IParameterSymbol? FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
258public IParameterSymbol? FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
262public ISymbol? FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken)
265public ISymbol? FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken)
270public ImmutableArray<ISymbol> GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode? node, SyntaxToken token, CancellationToken cancellationToken)
292/// cref="ModelExtensions.GetSymbolInfo(SemanticModel, SyntaxNode, CancellationToken)"/>, but sometimes employs
296private ImmutableArray<ISymbol> GetSymbolInfo(SemanticModel semanticModel, SyntaxNode node, SyntaxToken token, CancellationToken cancellationToken)
368public bool IsInsideNameOfExpression(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
377var node = syntaxReference.GetSyntax(cancellationToken);
392public bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, [NotNullWhen(true)] INamedTypeSymbol? expressionType, CancellationToken cancellationToken)
395public string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken)
398public IPreprocessingSymbol? GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node)
410private static bool IsInPreprocessingSymbolContext(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (18)
24public override bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
38public override bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration)
51public override bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter)
64public override bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method)
77public override bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction)
90public override bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration)
105public override bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement)
118public override bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement)
131public override bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (311)
29private static readonly ObjectPool<List<SyntaxNode>> s_syntaxNodeListPool = new ObjectPool<List<SyntaxNode>>(() => [], trimOnFree: false);
130public bool IsDirective([NotNullWhen(true)] SyntaxNode? node)
133public bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? node, out ExternalSourceInfo info)
154public bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
160public bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
163public bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
170public SyntaxNode? GetStandaloneExpression(SyntaxNode? node)
173public SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node)
176public bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node)
179public bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node)
182public bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node)
185public SyntaxNode? GetParameterList(SyntaxNode node)
188public bool IsParameterList([NotNullWhen(true)] SyntaxNode? node)
191public bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node)
195public bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node)
198public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name)
206public bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node)
209public bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node)
212public Location GetDeconstructionReferenceLocation(SyntaxNode node)
222public bool IsStatement([NotNullWhen(true)] SyntaxNode? node)
225public bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node)
228public bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node)
231public SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node)
234public bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement)
253public bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node)
265public SyntaxNode GetExpressionOfRefExpression(SyntaxNode node)
268public SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node)
312public bool IsPredefinedType(SyntaxNode? node)
315public bool IsPredefinedType(SyntaxNode? node, PredefinedType type)
535public bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node)
538public bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node)
541public bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
544public bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
547public void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity)
554public bool LooksGeneric(SyntaxNode simpleName)
558public SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName)
561public SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node)
564public SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node)
567public SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget)
570public void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList)
577public SyntaxNode GetExpressionOfInterpolation(SyntaxNode node)
580public bool IsInStaticContext(SyntaxNode node)
583public bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node)
586public bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node)
589public SyntaxNode GetExpressionOfArgument(SyntaxNode node)
592public SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node)
595public RefKind GetRefKindOfArgument(SyntaxNode node)
598public bool IsArgument([NotNullWhen(true)] SyntaxNode? node)
601public bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node)
604public bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node)
611public bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node)
614public bool IsInConstructor(SyntaxNode node)
617public bool IsUnsafeContext(SyntaxNode node)
620public bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node)
623public SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position)
627.GetAncestors<SyntaxNode>()
631public SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node)
634public bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node)
639public bool IsPropertyPatternClause(SyntaxNode node)
643[NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance)
674public bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression)
689public bool IsElementAccessExpression(SyntaxNode? node)
693public SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false)
696public SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
699public SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
702private static SyntaxNode? GetContainingMemberDeclaration<TMemberDeclarationSyntax>(SyntaxNode root, int position, bool useFullSpan = true)
715var node = root.FindToken(position).Parent;
733public bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node)
741public bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node)
750public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null)
812private static string? GetName(SyntaxNode node, DisplayNameOptions options)
899public PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root)
909public PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root)
919public SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration)
922private void AppendMembers(SyntaxNode? node, List<SyntaxNode> list, bool topLevel, bool methodLevel)
946public TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node)
953var member = GetContainingMemberDeclaration(node, node.SpanStart);
973public bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span)
996public SyntaxNode? TryGetBindableParent(SyntaxToken token)
998var node = token.Parent;
1001var parent = node.Parent;
1070public IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken)
1075var constructors = new List<SyntaxNode>();
1080private static void AppendConstructors(SyntaxList<MemberDeclarationSyntax> members, List<SyntaxNode> constructors, CancellationToken cancellationToken)
1144public string GetNameForArgument(SyntaxNode? argument)
1147public string GetNameForAttributeArgument(SyntaxNode? argument)
1150public bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node)
1153public SyntaxNode? GetRightSideOfDot(SyntaxNode? node)
1159public SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget)
1165public bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node)
1168public bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node)
1171public bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node)
1174public bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node)
1177public SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node)
1180public bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node)
1184public bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node)
1187public static bool IsOperandOfDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1190public bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1193public SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString)
1202public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode objectCreationExpression)
1207public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode argumentList)
1210public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode argumentList)
1222public bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes)
1228public bool IsDocumentationComment(SyntaxNode node)
1231public bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node)
1234public bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node)
1237public bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node)
1240private static bool IsGlobalAttribute([NotNullWhen(true)] SyntaxNode? node, SyntaxKind attributeTarget)
1245public bool IsDeclaration(SyntaxNode? node)
1294public bool IsTypeDeclaration(SyntaxNode node)
1297public bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement)
1302SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1309SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1311var expression = statement;
1324public bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? node)
1327public SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node)
1330public SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node)
1333public SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node)
1341public bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement)
1348public bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2)
1351public static SyntaxNode GetExpressionOfInvocationExpression(SyntaxNode node)
1354public bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node)
1357public SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node)
1360public void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
1361out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
1365arguments = (SeparatedSyntaxList<TArgumentSyntax>)(SeparatedSyntaxList<SyntaxNode>)tupleExpression.Arguments;
1375public SyntaxTokenList GetModifiers(SyntaxNode? node)
1379public SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers)
1382public SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node)
1385public SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node)
1388public SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node)
1391public SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node)
1394public SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node)
1397public bool IsEqualsValueOfPropertyDeclaration(SyntaxNode? node)
1400public bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node)
1403public bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node)
1406public void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression)
1423public SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node)
1426public bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node)
1430public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia)
1440public void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type)
1447public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right)
1455public bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node)
1458public SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node)
1461public void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation)
1468public void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation)
1484public bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node)
1487public bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node)
1490public void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen)
1498public void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1506public void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern)
1513public void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression)
1520public SyntaxNode GetTypeOfTypePattern(SyntaxNode node)
1523public bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node)
1538public bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node)
1541public bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node)
1544public bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node)
1547public bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node)
1550public bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
1553public bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node)
1556public bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node)
1559public bool IsAnyName([NotNullWhen(true)] SyntaxNode? node)
1562public bool IsAnyType([NotNullWhen(true)] SyntaxNode? node)
1565public bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1568public bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node)
1571public bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1574public bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node)
1581public void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken)
1589public void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList)
1596public void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1603public void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1611public void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members)
1620SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull)
1628public void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse)
1636public SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement)
1642public void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments)
1649public void GetPartsOfInterpolationExpression(SyntaxNode node,
1650out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken)
1658public void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList)
1665public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
1673public void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members)
1681public void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode identifier, out SyntaxNode expression)
1688public void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1697public void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer)
1705public void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default)
1713SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen)
1721public void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand)
1728public void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1740public SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node)
1743public SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node)
1746public SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node)
1749public SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node)
1752public SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node)
1755public SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node)
1758public SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node)
1761public SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (19)
71protected override SyntaxNode GetSemanticRootForSpeculation(ExpressionSyntax expression)
75SyntaxNode previousNode = null;
76SyntaxNode parentNodeToSpeculate = null;
77foreach (var node in expression.AncestorsAndSelf(ascendOutOfTrivia: false))
95public static bool CanSpeculateOnNode(SyntaxNode node)
104protected override void ValidateSpeculativeSemanticModel(SemanticModel speculativeSemanticModel, SyntaxNode nodeToSpeculate)
113protected override SemanticModel CreateSpeculativeSemanticModel(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel)
116public static SemanticModel CreateSpeculativeSemanticModelForNode(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel)
123public static SemanticModel CreateSpeculativeSemanticModelForNode(SyntaxNode nodeToSpeculate, SemanticModel semanticModel, int position, bool isInNamespaceOrTypeContext)
196SyntaxNode originalLambdaBody, replacedLambdaBody;
275SyntaxNode originalRoot)
295protected override bool ReplacementChangesSemanticsForNodeLanguageSpecific(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode previousOriginalNode, SyntaxNode previousReplacedNode)
580protected override bool ExpressionMightReferenceMember(SyntaxNode node)
662protected override bool IsParenthesizedExpression(SyntaxNode node)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (20)
47protected abstract void TryRegisterFix(CodeFixContext context, Document document, SyntaxNode container, SyntaxNode location);
49private static (SyntaxNode container, SyntaxNode exprOrStatement) GetContainer(SyntaxNode root, TextSpan span)
51var location = root.FindNode(span);
54var container = GetContainer(location);
64private static bool IsValidLocation(SyntaxNode location)
81private static SyntaxNode? GetContainer(SyntaxNode node)
83for (var current = node; current != null; current = current.Parent)
95private static async Task<MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol>)>> GetUnassignedParametersAsync(
105var result = new MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol>)>();
150SyntaxEditor editor, SyntaxNode container,
151MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol> unassignedParameters)>.ValueSet values,
154protected static ImmutableArray<SyntaxNode> GenerateAssignmentStatements(
157var result = ArrayBuilder<SyntaxNode>.GetInstance();
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (7)
26protected override void TryRegisterFix(CodeFixContext context, Document document, SyntaxNode container, SyntaxNode location)
32SyntaxEditor editor, SyntaxNode container,
33MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol> unassignedParameters)>.ValueSet values,
44SyntaxEditor editor, SyntaxNode exprOrStatement, ImmutableArray<SyntaxNode> statements)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (6)
81private static (SyntaxNode root, TextSpan semicolonSpan) ReplaceWithFileScopedNamespace(
119(SyntaxNode stringNode, int closeTerminatorIndentationLength) lastRawStringLiteralData = default;
135SyntaxNode stringNode;
214SyntaxTree tree, SyntaxNode root, string indentation, TextLine textLine, CancellationToken cancellationToken)
245var updatedRoot = ReplaceWithBlockScopedNamespace(parsedDocument, fileScopedNamespace, options.NewLine, options.NewLines, annotation);
259private static SyntaxNode ReplaceWithBlockScopedNamespace(
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (7)
34protected override bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
37protected override bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
40protected override bool IsImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
45SyntaxNode node,
83SyntaxNode node,
115SyntaxNode node,
150SyntaxNode node,
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (12)
62var originalRoot = editor.OriginalRoot;
69static t => (t.invocationOrCreation, ImmutableArray.Create<SyntaxNode>(t.identifier, t.declarator)),
78private static (VariableDeclaratorSyntax declarator, IdentifierNameSyntax identifier, SyntaxNode invocationOrCreation) FindDiagnosticNodes(
94private static SyntaxNode ReplaceIdentifierWithInlineDeclaration(
97SyntaxNode currentRoot, VariableDeclaratorSyntax declarator,
98IdentifierNameSyntax identifier, SyntaxNode currentNode,
118var block = CSharpInlineDeclarationDiagnosticAnalyzer.GetEnclosingPseudoBlock(localDeclarationStatement.Parent);
240private static ImmutableArray<StatementSyntax> GetStatements(SyntaxNode pseudoBlock)
338SyntaxNode nodeToReplace,
387private static SyntaxNode GetTopmostContainer(SyntaxNode expression)
398int position, SyntaxNode topmostContainer,
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (15)
45protected override SyntaxNode? TryUpdateNameForFlaggedNode(SyntaxNode node, SyntaxToken newName)
92protected override SyntaxNode? TryUpdateParentOfUpdatedNode(SyntaxNode parent, SyntaxNode newNameNode, SyntaxEditor editor, ISyntaxFacts syntaxFacts, SemanticModel semanticModel)
142protected override SyntaxNode ComputeReplacementNode(SyntaxNode originalOldNode, SyntaxNode changedOldNode, SyntaxNode proposedReplacementNode)
184protected override SyntaxNode GetReplacementNodeForCompoundAssignment(
185SyntaxNode originalCompoundAssignment,
186SyntaxNode newAssignmentTarget,
242protected override SyntaxNode GetReplacementNodeForVarPattern(SyntaxNode originalVarPattern, SyntaxNode newNameNode)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (8)
44var root = editor.OriginalRoot;
48var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
55SyntaxNode node, CancellationToken cancellationToken)
57var declarationContext = node.Parent;
128private static async Task UpdateTypeSyntaxAsync(Document document, SyntaxEditor editor, TypeSyntax typeSyntax, SyntaxNode declarationSyntax, CancellationToken cancellationToken)
147SyntaxNode declarationSyntax,
207private static SyntaxNode GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
218private static ITypeSymbol GetConvertedType(SemanticModel semanticModel, SyntaxNode typeSyntax, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (23)
40public override CodeGenerationDestination GetDestination(SyntaxNode node)
43protected override IComparer<SyntaxNode> GetMemberComparer()
46protected override IList<bool>? GetAvailableInsertionIndices(SyntaxNode destination, CancellationToken cancellationToken)
311var finalMember = editor.GetChangedRoot();
341protected override TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> members)
375var attributeSyntaxToRemove = attributeToRemove.ApplicationSyntaxReference.GetSyntax(cancellationToken);
381SyntaxNode attributeToRemove,
441SyntaxNode attributeToRemove,
477IEnumerable<SyntaxNode> statements,
529IEnumerable<SyntaxNode> statements,
531CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
568TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, BaseMethodDeclarationSyntax baseMethodDeclaration) where TDeclarationNode : SyntaxNode
589TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode
610TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, AnonymousFunctionExpressionSyntax anonymousFunctionSyntax) where TDeclarationNode : SyntaxNode
634public override SyntaxNode CreateEventDeclaration(
640public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
648public override SyntaxNode? CreateMethodDeclaration(
697public override SyntaxNode CreatePropertyDeclaration(
704public override SyntaxNode CreateNamedTypeDeclaration(
710public override SyntaxNode CreateNamespaceDeclaration(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (27)
40protected override ImmutableArray<SyntaxNode> GetGlobalImports(Compilation compilation, SyntaxGenerator generator)
43protected override SyntaxNode? GetAlias(UsingDirectiveSyntax usingOrAlias)
49protected override SyntaxNode Rewrite(
54SyntaxNode externContainer,
55SyntaxNode usingContainer,
56SyntaxNode staticUsingContainer,
57SyntaxNode aliasContainer,
59SyntaxNode root,
67var newRoot = rewriter.Visit(root);
71protected override SyntaxList<UsingDirectiveSyntax> GetUsingsAndAliases(SyntaxNode node)
79protected override SyntaxList<ExternAliasDirectiveSyntax> GetExterns(SyntaxNode node)
87protected override bool IsEquivalentImport(SyntaxNode a, SyntaxNode b)
94private readonly SyntaxNode _externContainer;
95private readonly SyntaxNode _usingContainer;
96private readonly SyntaxNode _aliasContainer;
97private readonly SyntaxNode _staticUsingContainer;
108SyntaxNode externContainer,
109SyntaxNode usingContainer,
110SyntaxNode aliasContainer,
111SyntaxNode staticUsingContainer,
128public override SyntaxNode? Visit(SyntaxNode? node)
131public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
134public override SyntaxNode? VisitFileScopedNamespaceDeclaration(FileScopedNamespaceDeclarationSyntax node)
137private SyntaxNode VisitBaseNamespaceDeclaration(
171public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (68)
54public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst)
61public override SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer)
64public override SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
67internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode? type, SyntaxToken name, SyntaxNode? expression)
79public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
82public override SyntaxNode MemberBindingExpression(SyntaxNode name)
85public override SyntaxNode RefExpression(SyntaxNode expression)
88public override SyntaxNode AddParentheses(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
91internal static SyntaxNode Parenthesize(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
99public override SyntaxNode YieldReturnStatement(SyntaxNode expression)
108public override SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
111public override SyntaxNode InterpolatedStringText(SyntaxToken textToken)
121public override SyntaxNode Interpolation(SyntaxNode syntaxNode)
124public override SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment)
127public override SyntaxNode InterpolationFormatClause(string format)
132public override SyntaxNode TypeParameterList(IEnumerable<string> typeParameterNames)
150public override SyntaxNode Type(ITypeSymbol typeSymbol, bool typeContext)
153public override SyntaxNode NegateEquality(SyntaxGenerator generator, SyntaxNode binaryExpression, SyntaxNode left, BinaryOperatorKind negatedKind, SyntaxNode right)
161public override SyntaxNode IsNotTypeExpression(SyntaxNode expression, SyntaxNode type)
169public override SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isKeyword, SyntaxNode pattern)
175public override SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right)
178public override SyntaxNode ConstantPattern(SyntaxNode expression)
181public override SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name)
186public override SyntaxNode LessThanRelationalPattern(SyntaxNode expression)
189public override SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression)
192public override SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression)
195public override SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression)
198public override SyntaxNode NotPattern(SyntaxNode pattern)
201public override SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right)
204public override SyntaxNode ParenthesizedPattern(SyntaxNode pattern)
207public override SyntaxNode TypePattern(SyntaxNode type)
210public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern)
AddImport\CSharpAddImportFeatureService.cs (25)
43protected override bool CanAddImport(SyntaxNode node, bool allowInHiddenRegions, CancellationToken cancellationToken)
50string diagnosticId, ISyntaxFacts syntaxFacts, SyntaxNode node, out SimpleNameSyntax nameNode)
139protected override bool CanAddImportForDeconstruct(string diagnosticId, SyntaxNode node)
142protected override bool CanAddImportForGetAwaiter(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node)
148protected override bool CanAddImportForGetEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node)
151protected override bool CanAddImportForGetAsyncEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node)
154protected override bool CanAddImportForNamespace(string diagnosticId, SyntaxNode node, out SimpleNameSyntax nameNode)
160protected override bool CanAddImportForQuery(string diagnosticId, SyntaxNode node)
165protected override bool CanAddImportForType(string diagnosticId, SyntaxNode node, out SimpleNameSyntax nameNode)
200private static bool TryFindStandaloneType(SyntaxNode node, out SimpleNameSyntax nameNode)
229SyntaxNode node,
236SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
243SyntaxNode node,
290SyntaxNode contextNode,
336SyntaxNode contextNode,
348Document document, CompilationUnitSyntax root, SyntaxNode contextNode, INamespaceOrTypeSymbol namespaceOrTypeSymbol,
359using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var newImports);
384SyntaxNode contextNode, IReadOnlyList<string> namespaceParts,
418SyntaxNode contextNode)
437SyntaxNode contextNode)
555SyntaxNode contextNode)
581private static bool HasExistingExternAlias(string alias, SyntaxNode contextNode)
596SyntaxNode contextNode, CancellationToken cancellationToken)
601protected override bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
624protected override bool IsAddMethodContext(SyntaxNode node, SemanticModel semanticModel)
ChangeSignature\CSharpChangeSignatureService.cs (30)
135var matchingNode = GetMatchingNode(token.Parent, restrictToDeclarations);
187private static int TryGetSelectedIndexFromDeclaration(int position, SyntaxNode matchingNode)
193private static SyntaxNode? GetMatchingNode(SyntaxNode node, bool restrictToDeclarations)
199for (var current = node; current != null; current = current.Parent)
216private static bool InSymbolHeader(SyntaxNode matchingNode, int position)
219var lastAttributes = matchingNode.ChildNodes().LastOrDefault(n => n is AttributeListSyntax);
229var parameterList = matchingNode.ChildNodes().LastOrDefault(n => n is ParameterListSyntax);
239public override SyntaxNode? FindNodeToUpdate(Document document, SyntaxNode node)
247var matchingNode = node.AncestorsAndSelf().FirstOrDefault(n => _updatableAncestorKinds.Contains(n.Kind()));
253var nodeContainingOriginal = GetNodeContainingTargetNode(matchingNode);
262private static SyntaxNode? GetNodeContainingTargetNode(SyntaxNode matchingNode)
289public override async Task<SyntaxNode> ChangeSignatureAsync(
292SyntaxNode potentiallyUpdatedNode,
293SyntaxNode originalNode,
581private static bool IsParamsArrayExpanded(SemanticModel semanticModel, SyntaxNode node, SymbolInfo symbolInfo, CancellationToken cancellationToken)
668Func<AddedParameter, T> createNewParameterMethod) where T : SyntaxNode
674protected override T TransferLeadingWhitespaceTrivia<T>(T newArgument, SyntaxNode oldArgument)
701where TArgumentSyntax : SyntaxNode
751where T : SyntaxNode
752where U : SyntaxNode
791private ImmutableArray<SyntaxNode> VerifyAndPermuteParamNodes(IEnumerable<XmlElementSyntax> paramNodes, ISymbol declarationSymbol, SignatureChange updatedSignature)
831var permutedParams = ArrayBuilder<SyntaxNode>.GetInstance();
859using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var convertedMethodNodes);
897ArgumentSyntax a => (TArgumentSyntax)(SyntaxNode)a.WithNameColon(NameColon(name)),
898AttributeArgumentSyntax a => (TArgumentSyntax)(SyntaxNode)a.WithNameColon(NameColon(name)),
908var listOfArguments = SeparatedList(newArguments.Skip(indexInExistingList).Select(a => ((ArgumentSyntax)(SyntaxNode)a).Expression), newArguments.GetSeparators().Skip(indexInExistingList));
911return (TArgumentSyntax)(SyntaxNode)Argument(objectCreation);
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (14)
37protected override SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken)
44Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken)
51SyntaxToken disableOrRestoreKeyword, Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken)
86protected override bool IsAttributeListWithAssemblyAttributes(SyntaxNode node)
99protected override SyntaxNode AddGlobalSuppressMessageAttribute(
100SyntaxNode newRoot,
129protected override SyntaxNode AddLocalSuppressMessageAttribute(
130SyntaxNode targetNode, ISymbol targetSymbol, INamedTypeSymbol suppressMessageAttribute, Diagnostic diagnostic)
212protected override bool IsSingleAttributeInAttributeList(SyntaxNode attribute)
247protected override SyntaxNode GetContainingStatement(SyntaxToken token)
250=> (SyntaxNode)token.GetAncestor<StatementSyntax>() ?? token.GetAncestor<ArrowExpressionClauseSyntax>();
ConvertAutoPropertyToFullProperty\CSharpConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (22)
49protected override (SyntaxNode newGetAccessor, SyntaxNode newSetAccessor) GetNewAccessors(
50CSharpCodeGenerationContextInfo info, SyntaxNode property,
58var getAccessorStatement = generator.ReturnStatement(generator.IdentifierName(fieldName));
59var newGetter = GetUpdatedAccessor(info, getAccessor, getAccessorStatement, cancellationToken);
61SyntaxNode newSetter = null;
64var setAccessorStatement = generator.ExpressionStatement(generator.AssignmentStatement(
78private static SyntaxNode GetUpdatedAccessor(CSharpCodeGenerationContextInfo info,
79SyntaxNode accessor, SyntaxNode statement, CancellationToken cancellationToken)
81var newAccessor = AddStatement(accessor, statement);
104internal static SyntaxNode AddStatement(SyntaxNode accessor, SyntaxNode statement)
115protected override SyntaxNode ConvertPropertyToExpressionBodyIfDesired(
116CSharpCodeGenerationContextInfo info, SyntaxNode property)
142protected override SyntaxNode GetTypeBlock(SyntaxNode syntaxNode)
145protected override SyntaxNode GetInitializerValue(SyntaxNode property)
148protected override SyntaxNode GetPropertyWithoutInitializer(SyntaxNode property)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (183)
29internal sealed class CSharpEditAndContinueAnalyzer(Action<SyntaxNode>? testFaultInjector = null) : AbstractEditAndContinueAnalyzer(testFaultInjector)
77internal override bool TryFindMemberDeclaration(SyntaxNode? root, SyntaxNode node, TextSpan activeSpan, out OneOrMany<SyntaxNode> declarations)
79var current = node;
180internal override MemberBody? TryGetDeclarationBody(SyntaxNode node, ISymbol? symbol)
183internal override bool IsDeclarationWithSharedBody(SyntaxNode declaration, ISymbol member)
189protected override IEnumerable<SyntaxNode> GetVariableUseSites(IEnumerable<SyntaxNode> roots, ISymbol localOrParameter, SemanticModel model, CancellationToken cancellationToken)
205internal static SyntaxNode FindStatementAndPartner(
207SyntaxNode body,
208SyntaxNode? partnerBody,
209out SyntaxNode? partnerStatement,
220SyntaxNode node;
375private static bool AreEquivalentIgnoringLambdaBodies(SyntaxNode left, SyntaxNode right)
386internal override bool IsClosureScope(SyntaxNode node)
389internal override SyntaxNode GetCapturedParameterScope(SyntaxNode methodOrLambda)
397BaseMethodDeclarationSyntax method => method.Body ?? (SyntaxNode?)method.ExpressionBody!,
405protected override LambdaBody? FindEnclosingLambdaBody(SyntaxNode encompassingAncestor, SyntaxNode node)
407var current = node;
421protected override Match<SyntaxNode> ComputeTopLevelMatch(SyntaxNode oldCompilationUnit, SyntaxNode newCompilationUnit)
424protected override BidirectionalMap<SyntaxNode>? ComputeParameterMap(SyntaxNode oldDeclaration, SyntaxNode newDeclaration)
426BidirectionalMap<SyntaxNode>.FromMatch(SyntaxComparer.TopLevel.ComputeMatch(oldParameterList, newParameterList)) : null;
428private static SyntaxNode? GetDeclarationParameterList(SyntaxNode declaration)
437internal static Match<SyntaxNode> ComputeBodyMatch(SyntaxNode oldBody, SyntaxNode newBody, IEnumerable<KeyValuePair<SyntaxNode, SyntaxNode>>? knownMatches)
463static SyntaxNode GetMatchingRoot(SyntaxNode body)
465var parent = body.Parent!;
471var oldRoot = GetMatchingRoot(oldBody);
472var newRoot = GetMatchingRoot(newBody);
481private static IEnumerable<SyntaxNode> GetChildNodes(SyntaxNode root, SyntaxNode body)
519SyntaxNode oldBody,
520SyntaxNode newBody,
521SyntaxNode oldStatement,
522[NotNullWhen(true)] out SyntaxNode? newStatement)
543protected override bool IsNamespaceDeclaration(SyntaxNode node)
546private static bool IsTypeDeclaration(SyntaxNode node)
549protected override bool IsCompilationUnitWithGlobalStatements(SyntaxNode node)
552protected override bool IsGlobalStatement(SyntaxNode node)
555protected override IEnumerable<SyntaxNode> GetTopLevelTypeDeclarations(SyntaxNode compilationUnit)
587protected override IEnumerable<SequenceEdit> GetSyntaxSequenceEdits(ImmutableArray<SyntaxNode> oldNodes, ImmutableArray<SyntaxNode> newNodes)
590internal override SyntaxNode EmptyCompilationUnit
597protected override bool StatementLabelEquals(SyntaxNode node1, SyntaxNode node2)
603protected override bool TryGetActiveSpan(SyntaxNode node, int statementPart, int minLength, out TextSpan span)
687public static (SyntaxNode node, int part) GetFirstBodyActiveStatement(SyntaxNode memberBody)
690protected override IEnumerable<(SyntaxNode statement, int statementPart)> EnumerateNearStatements(SyntaxNode statement)
702var parent = statement.Parent;
747var node = nodeOrToken.AsNode();
781protected override bool AreEquivalentActiveStatements(SyntaxNode oldStatement, SyntaxNode newStatement, int statementPart)
893(SyntaxNode?)oldNode.Declaration ?? oldNode.Expression!,
894(SyntaxNode?)newNode.Declaration ?? newNode.Expression!);
930internal override bool IsInterfaceDeclaration(SyntaxNode node)
933internal override bool IsRecordDeclaration(SyntaxNode node)
936internal override SyntaxNode? TryGetContainingTypeDeclaration(SyntaxNode node)
939internal override bool IsDeclarationWithInitializer(SyntaxNode declaration)
942internal override bool IsPrimaryConstructorDeclaration(SyntaxNode declaration)
997protected override SyntaxNode? GetSymbolDeclarationSyntax(ISymbol symbol, Func<ImmutableArray<SyntaxReference>, SyntaxReference?> selector, CancellationToken cancellationToken)
1002var syntax = symbol switch
1022protected override ISymbol? GetDeclaredSymbol(SemanticModel model, SyntaxNode declaration, CancellationToken cancellationToken)
1037SyntaxNode? oldNode,
1038SyntaxNode? newNode,
1081SyntaxNode? oldNode,
1083SyntaxNode? newNode,
1087Match<SyntaxNode> topMatch,
1088IReadOnlyDictionary<SyntaxNode, EditKind> editMap,
1315var node = oldNode ?? newNode;
1393SyntaxNode node,
1429private ISymbol? GetParameterContainingMemberOrType(SyntaxNode? node, SyntaxNode? otherNode, SemanticModel? model, IReadOnlyDictionary<SyntaxNode, SyntaxNode> fromOtherMap, CancellationToken cancellationToken)
1434SyntaxNode? declaration;
1456static SyntaxNode GetContainingDeclaration(SyntaxNode node)
1460private static bool SupportsMove(SyntaxNode node)
1465internal override Func<SyntaxNode, bool> IsLambda
1468internal override Func<SyntaxNode, bool> IsNotLambda
1471internal override bool IsLocalFunction(SyntaxNode node)
1474internal override bool IsGenericLocalFunction(SyntaxNode node)
1477internal override bool IsNestedFunction(SyntaxNode node)
1480internal override bool TryGetLambdaBodies(SyntaxNode node, [NotNullWhen(true)] out LambdaBody? body1, out LambdaBody? body2)
1494internal override IMethodSymbol GetLambdaExpressionSymbol(SemanticModel model, SyntaxNode lambdaExpression, CancellationToken cancellationToken)
1500internal override SyntaxNode? GetContainingQueryExpression(SyntaxNode node)
1503internal override bool QueryClauseLambdasTypeEquivalent(SemanticModel oldModel, SyntaxNode oldNode, SemanticModel newModel, SyntaxNode newNode, CancellationToken cancellationToken)
1604protected override TextSpan? TryGetDiagnosticSpan(SyntaxNode node, EditKind editKind)
1607internal static new TextSpan GetDiagnosticSpan(SyntaxNode node, EditKind editKind)
1610private static TextSpan? TryGetDiagnosticSpanImpl(SyntaxNode node, EditKind editKind)
1614internal static TextSpan? TryGetDiagnosticSpanImpl(SyntaxKind kind, SyntaxNode node, EditKind editKind)
1623var globalNode =
1749var startNode = parameter.Type ?? (SyntaxNode)parameter;
1945internal override TextSpan GetLambdaParameterDiagnosticSpan(SyntaxNode lambda, int ordinal)
1995protected override string? TryGetDisplayName(SyntaxNode node, EditKind editKind)
1998internal static new string? GetDisplayName(SyntaxNode node, EditKind editKind)
2001internal static string? TryGetDisplayNameImpl(SyntaxNode node, EditKind editKind)
2265protected override string GetSuspensionPointDisplayName(SyntaxNode node, EditKind editKind)
2290private readonly Match<SyntaxNode>? _match;
2291private readonly SyntaxNode? _oldNode;
2292private readonly SyntaxNode? _newNode;
2299SyntaxNode? oldNode,
2300SyntaxNode? newNode,
2302Match<SyntaxNode>? match = null,
2319private void ReportError(RudeEditKind kind, SyntaxNode? spanNode = null, SyntaxNode? displayNode = null)
2322var node = displayNode ?? _newNode ?? _oldNode;
2372private void ClassifyMove(SyntaxNode newNode)
2382private void ClassifyReorder(SyntaxNode newNode)
2403private void ClassifyInsert(SyntaxNode node)
2427private void ClassifyDelete(SyntaxNode oldNode)
2453private void ClassifyUpdate(SyntaxNode newNode)
2479Match<SyntaxNode> match,
2480Edit<SyntaxNode> edit,
2481Dictionary<SyntaxNode, EditKind> editMap)
2492internal override bool HasUnsupportedOperation(IEnumerable<SyntaxNode> nodes, [NotNullWhen(true)] out SyntaxNode? unsupportedNode, out RudeEditKind rudeEdit)
2497foreach (var node in nodes)
2516internal override void ReportInsertedMemberSymbolRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, ISymbol newSymbol, SyntaxNode newNode, bool insertingIntoExistingContainingType)
2578protected override List<SyntaxNode> GetExceptionHandlingAncestors(SyntaxNode node, SyntaxNode root, bool isNonLeaf)
2580var result = new List<SyntaxNode>();
2582var current = node;
2631IEnumerable<Edit<SyntaxNode>> exceptionHandlingEdits,
2632SyntaxNode oldStatement,
2647private static bool AreExceptionClausesEquivalent(SyntaxNode oldNode, SyntaxNode newNode)
2680protected override TextSpan GetExceptionHandlingRegion(SyntaxNode node, out bool coversAllChildren)
2719internal override bool IsStateMachineMethod(SyntaxNode declaration)
2722internal override void ReportStateMachineSuspensionPointRudeEdits(DiagnosticContext diagnosticContext, SyntaxNode oldNode, SyntaxNode newNode)
2726var oldContainingStatementPart = FindContainingStatementPart(oldNode);
2727var newContainingStatementPart = FindContainingStatementPart(newNode);
2738private static SyntaxNode FindContainingStatementPart(SyntaxNode node)
2772private static bool HasNoSpilledState(SyntaxNode awaitExpression, SyntaxNode containingStatementPart)
2813private static ExpressionSyntax GetExpressionFromStatementPart(SyntaxNode statement)
2829private static bool IsSimpleAwaitAssignment(SyntaxNode node, SyntaxNode awaitExpression)
2845IReadOnlyDictionary<SyntaxNode, SyntaxNode> reverseMap,
2846SyntaxNode oldActiveStatement,
2849SyntaxNode newActiveStatement,
2867private void ReportRudeEditsForSwitchWhenClauses(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldActiveStatement, SyntaxNode newActiveStatement)
2924SyntaxNode oldActiveStatement,
2925SyntaxNode newActiveStatement,
2958private static CheckedStatementSyntax? TryGetCheckedStatementAncestor(SyntaxNode? node)
2979IReadOnlyDictionary<SyntaxNode, SyntaxNode> reverseMap,
2980SyntaxNode oldActiveStatement,
2981SyntaxNode oldEncompassingAncestor,
2983SyntaxNode newActiveStatement,
2984SyntaxNode newEncompassingAncestor,
3007getTypedNodes: static n => OneOrMany.OneOrNone<SyntaxNode>(n.Expression),
3038getTypedNodes: static n => OneOrMany.Create<SyntaxNode>(n.Expression!),
3053getTypedNodes: static n => OneOrMany.OneOrNone<SyntaxNode>(n.Expression),
3058static OneOrMany<SyntaxNode> GetTypedNodes(VariableDeclarationSyntax declaration)
3060? OneOrMany.Create<SyntaxNode>(initializer.Value)
3061: OneOrMany.Create(declaration.Variables.Select(static v => (SyntaxNode?)v.Initializer?.Value).WhereNotNull().ToImmutableArray());
EditAndContinue\DeclarationBody\InstanceConstructorDeclarationBody.cs (13)
18public abstract SyntaxNode InitializerActiveStatement { get; }
19public abstract SyntaxNode? MatchRoot { get; }
24public abstract SyntaxNode? ExplicitBody { get; }
29public abstract SyntaxNode? ParameterClosure { get; }
37public sealed override SyntaxNode FindStatementAndPartner(TextSpan span, MemberBody? partnerDeclarationBody, out SyntaxNode? partnerStatement, out int statementPart)
74public sealed override bool TryMatchActiveStatement(DeclarationBody newBody, SyntaxNode oldStatement, ref int statementPart, [NotNullWhen(true)] out SyntaxNode? newStatement)
102public sealed override Match<SyntaxNode>? ComputeSingleRootMatch(DeclarationBody newBody, IEnumerable<KeyValuePair<SyntaxNode, SyntaxNode>>? knownMatches)
107public override DeclarationBodyMap ComputeMap(DeclarationBody newBody, IEnumerable<KeyValuePair<SyntaxNode, SyntaxNode>>? knownMatches)
EditAndContinue\SyntaxComparer.cs (50)
27SyntaxNode? oldRoot,
28SyntaxNode? newRoot,
29IEnumerable<SyntaxNode>? oldRootChildren,
30IEnumerable<SyntaxNode>? newRootChildren,
36protected override bool IsLambdaBodyStatementOrExpression(SyntaxNode node)
234internal override int Classify(int kind, SyntaxNode? node, out bool isLeaf)
237internal Label Classify(SyntaxKind kind, SyntaxNode? node, out bool isLeaf)
293private static Label ClassifyStatementSyntax(SyntaxKind kind, SyntaxNode? node, out bool isLeaf)
560private static Label ClassifyTopSyntax(SyntaxKind kind, SyntaxNode? node, out bool isLeaf)
706public override bool ValuesEqual(SyntaxNode left, SyntaxNode right)
765private static SyntaxNode? GetBody(SyntaxNode node)
769case BaseMethodDeclarationSyntax baseMethodDeclarationSyntax: return baseMethodDeclarationSyntax.Body ?? (SyntaxNode?)baseMethodDeclarationSyntax.ExpressionBody?.Expression;
770case AccessorDeclarationSyntax accessorDeclarationSyntax: return accessorDeclarationSyntax.Body ?? (SyntaxNode?)accessorDeclarationSyntax.ExpressionBody?.Expression;
775protected override bool TryComputeWeightedDistance(SyntaxNode leftNode, SyntaxNode rightNode, out double distance)
817(SyntaxNode?)leftUsing.Expression ?? leftUsing.Declaration!,
819(SyntaxNode?)rightUsing.Expression ?? rightUsing.Declaration!,
938private static double ComputeWeightedDistanceOfNestedFunctions(SyntaxNode leftNode, SyntaxNode rightNode)
965SyntaxNode nestedFunction,
968out SyntaxNode body,
1021body = (SyntaxNode?)localFunction.Body ?? localFunction.ExpressionBody!;
1203SyntaxNode? leftHeader,
1205SyntaxNode? rightHeader,
1281foreach (var child in block.ChildNodes())
1376SyntaxNode? left1,
1377SyntaxNode? right1,
1378SyntaxNode? left2,
1379SyntaxNode? right2,
1411private static SyntaxNodeOrToken? TryGetName(SyntaxNode node)
1506public sealed override double GetDistance(SyntaxNode oldNode, SyntaxNode newNode)
1528internal static double ComputeValueDistance(SyntaxNode? oldNode, SyntaxNode? newNode)
1557var leftNode = oldNodeOrToken.AsNode();
1558var rightNode = newNodeOrToken.AsNode();
1571where TSyntaxNode : SyntaxNode
1588public static double ComputeDistance(SyntaxNode? oldNode, SyntaxNode? newNode)
1627public static double ComputeDistance(IEnumerable<SyntaxNode>? oldNodes, IEnumerable<SyntaxNode>? newNodes)
1633public static IEnumerable<SequenceEdit> GetSequenceEdits(IEnumerable<SyntaxNode>? oldNodes, IEnumerable<SyntaxNode>? newNodes)
1639public static IEnumerable<SequenceEdit> GetSequenceEdits(ImmutableArray<SyntaxNode> oldNodes, ImmutableArray<SyntaxNode> newNodes)
1662private sealed class LcsNodes : LongestCommonImmutableArraySubsequence<SyntaxNode>
1666protected override bool Equals(SyntaxNode oldElement, SyntaxNode newElement)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (37)
37private abstract partial class CSharpCodeGenerator : CodeGenerator<StatementSyntax, SyntaxNode, CSharpCodeGenerationOptions>
87public override OperationStatus<ImmutableArray<SyntaxNode>> GetNewMethodStatements(SyntaxNode insertionPointNode, CancellationToken cancellationToken)
91return status.With(statements.CastArray<SyntaxNode>());
95SyntaxNode insertionPointNode, CancellationToken cancellationToken)
110statements: statements.CastArray<SyntaxNode>(),
117protected override async Task<SyntaxNode> GenerateBodyForCallSiteContainerAsync(
118SyntaxNode insertionPointNode,
119SyntaxNode container,
124var firstStatementToRemove = GetFirstStatementOrInitializerSelectedAtCallSite();
125var lastStatementToRemove = GetLastStatementOrInitializerSelectedAtCallSite();
143private async Task<ImmutableArray<SyntaxNode>> CreateStatementsOrInitializerToInsertAtCallSiteAsync(
144SyntaxNode insertionPointNode, CancellationToken cancellationToken)
146var selectedNode = GetFirstStatementOrInitializerSelectedAtCallSite();
167return statements.CastArray<SyntaxNode>();
170protected override bool ShouldLocalFunctionCaptureParameter(SyntaxNode node)
173private static bool IsExpressionBodiedMember(SyntaxNode node)
176private static bool IsExpressionBodiedAccessor(SyntaxNode node)
194protected override SyntaxNode GetCallSiteContainerFromOutermostMoveInVariable(CancellationToken cancellationToken)
263SyntaxNode insertionPoint, CancellationToken cancellationToken)
425var replacements = new Dictionary<SyntaxNode, SyntaxNode>();
430foreach (var node in declarations)
509SyntaxNode insertionPointNode,
532var lastStatement = GetLastStatementOrInitializerSelectedAtCallSite();
533var container = lastStatement.GetAncestorsOrThis<SyntaxNode>().FirstOrDefault(n => n.IsReturnableConstruct());
648var root = newDocument.Root;
649var methodDefinition = root.GetAnnotatedNodes<SyntaxNode>(MethodDefinitionAnnotation).First();
651SyntaxNode newMethodDefinition = methodDefinition switch
670private static TDeclarationNode TweakNewLinesInMethod<TDeclarationNode>(TDeclarationNode method, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody) where TDeclarationNode : SyntaxNode
728static bool ReturnOperationBelongsToMethod(SyntaxNode returnOperationSyntax, SyntaxNode methodSyntax)
730var enclosingMethod = returnOperationSyntax.FirstAncestorOrSelf<SyntaxNode>(n => n switch
742SyntaxNode node,
758var syntax = returnOperation.ReturnedValue?.Syntax ?? returnOperation.Syntax;
ExtractMethod\CSharpSelectionValidator.cs (16)
36var root = SemanticDocument.Root;
169var firstValidNode = node.GetAncestors<SyntaxNode>().FirstOrDefault(n => Check(semanticModel, n, cancellationToken));
186private SelectionInfo GetInitialSelectionInfo(SyntaxNode root, SourceText text)
268=> token.GetAncestors<SyntaxNode>().Any(n => CheckTopLevel(n, token.Span));
270private static bool CheckTopLevel(SyntaxNode node, TextSpan span)
324SyntaxNode root)
381private static SelectionInfo AssignInitialFinalTokens(SelectionInfo selectionInfo, SyntaxNode root, CancellationToken cancellationToken)
445public override bool ContainsNonReturnExitPointsStatements(IEnumerable<SyntaxNode> jumpsOutOfRegion)
448public override IEnumerable<SyntaxNode> GetOuterReturnStatements(SyntaxNode commonRoot, IEnumerable<SyntaxNode> jumpsOutOfRegion)
452var container = commonRoot.GetAncestorsOrThis<SyntaxNode>().Where(a => a.IsReturnableConstruct()).FirstOrDefault();
456var returnableConstructPairs = returnStatements.Select(r => (r, r.GetAncestors<SyntaxNode>().Where(a => a.IsReturnableConstruct()).FirstOrDefault()))
464SyntaxNode root, TextSpan textSpan,
465IEnumerable<SyntaxNode> returnStatements, CancellationToken cancellationToken)
479var container = lastToken.GetAncestors<SyntaxNode>().FirstOrDefault(n => n.IsReturnableConstruct());
GenerateType\CSharpGenerateTypeService.cs (9)
501? genericName.TypeArgumentList.Arguments.OfType<SyntaxNode>().ToList()
502: Enumerable.Repeat<SyntaxNode>(null, state.SimpleName.Arity);
568INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken)
687var node = expression as SyntaxNode;
688SyntaxNode previousNode = null;
724private static bool IsAllContainingTypeDeclsPublic(SyntaxNode node)
739Solution updatedSolution, SyntaxNode modifiedRoot, Document document, SimpleNameSyntax simpleName, string includeUsingsOrImports, CancellationToken cancellationToken)
747SyntaxNode root = null;
ImplementInterface\AbstractChangeImplementationCodeRefactoringProvider.cs (8)
44protected abstract SyntaxNode ChangeImplementation(SyntaxGenerator generator, SyntaxNode currentDecl, ISymbol implMember, ISymbol interfaceMember);
128private static async Task<(SyntaxNode?, ExplicitInterfaceSpecifierSyntax?, SyntaxToken)> GetContainerAsync(CodeRefactoringContext context)
155private static (SyntaxNode? declaration, ExplicitInterfaceSpecifierSyntax?, SyntaxToken) GetContainer(SyntaxToken token)
157for (var node = token.Parent; node != null; node = node.Parent)
164_ => default((SyntaxNode member, ExplicitInterfaceSpecifierSyntax?, SyntaxToken)),
230var documentToImplDeclarations = new OrderedMultiDictionary<Document, (SyntaxNode, ISymbol impl, SetWithInsertionOrder<ISymbol> interfaceMembers)>();
240var decl = GetContainer(declToken).declaration;
SignatureHelp\ElementAccessExpressionSignatureHelpProvider.cs (6)
46private static bool TryGetElementAccessExpression(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
136private static SignatureHelpState? GetCurrentArgumentState(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken)
306internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
341internal static TextSpan GetTextSpan(SyntaxNode expression, SyntaxToken openBracket)
347internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
384internal static bool TryGetSyntax(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, SignatureHelpTriggerReason triggerReason, CancellationToken cancellationToken, [NotNullWhen(true)] out ExpressionSyntax? identifier, out SyntaxToken openBrace)
SignatureHelp\TupleConstructionSignatureHelpProvider.cs (8)
37private SignatureHelpState? GetCurrentArgumentState(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken)
63private bool GetOuterMostTupleExpressionInSpan(SyntaxNode root, int position,
82private bool GetOuterMostParenthesizedExpressionInSpan(SyntaxNode root, int position,
125private IEnumerable<INamedTypeSymbol>? FindNearestTupleConstructionWithInferrableType(SyntaxNode root, SemanticModel semanticModel, int position, SignatureHelpTriggerInfo triggerInfo,
150private SignatureHelpItems? CreateItems(int position, SyntaxNode root, ISyntaxFactsService syntaxFacts,
151SyntaxNode targetExpression, SemanticModel semanticModel, IEnumerable<INamedTypeSymbol> tupleTypes, CancellationToken cancellationToken)
202private bool TryGetTupleExpression(SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position,
219private bool TryGetParenthesizedExpression(SignatureHelpTriggerReason triggerReason, SyntaxNode root, int position,
SplitOrMergeIfStatements\CSharpIfLikeStatementGenerator.cs (33)
29public bool IsIfOrElseIf(SyntaxNode node) => node is IfStatementSyntax;
31public bool IsCondition(SyntaxNode expression, out SyntaxNode ifOrElseIf)
43public bool IsElseIfClause(SyntaxNode node, out SyntaxNode parentIfOrElseIf)
55public bool HasElseIfClause(SyntaxNode ifOrElseIf, out SyntaxNode elseIfClause)
68public SyntaxNode GetCondition(SyntaxNode ifOrElseIf)
74public SyntaxNode GetRootIfStatement(SyntaxNode ifOrElseIf)
86public ImmutableArray<SyntaxNode> GetElseIfAndElseClauses(SyntaxNode ifOrElseIf)
90var builder = ImmutableArray.CreateBuilder<SyntaxNode>();
106public SyntaxNode WithCondition(SyntaxNode ifOrElseIf, SyntaxNode condition)
112public SyntaxNode WithStatementInBlock(SyntaxNode ifOrElseIf, SyntaxNode statement)
118public SyntaxNode WithStatementsOf(SyntaxNode ifOrElseIf, SyntaxNode otherIfOrElseIf)
125public SyntaxNode WithElseIfAndElseClausesOf(SyntaxNode ifStatement, SyntaxNode otherIfStatement)
128public SyntaxNode ToIfStatement(SyntaxNode ifOrElseIf)
131public SyntaxNode ToElseIfClause(SyntaxNode ifOrElseIf)
134public void InsertElseIfClause(SyntaxEditor editor, SyntaxNode afterIfOrElseIf, SyntaxNode elseIfClause)
156public void RemoveElseIfClause(SyntaxEditor editor, SyntaxNode elseIfClause)
src\Analyzers\CSharp\Analyzers\RemoveConfusingSuppression\CSharpRemoveConfusingSuppressionDiagnosticAnalyzer.cs (1)
32var node = context.Node;
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper.cs (8)
25public abstract BlockSyntax? GetBody(SyntaxNode declaration);
26public abstract ArrowExpressionClauseSyntax? GetExpressionBody(SyntaxNode declaration);
27public abstract bool IsRelevantDeclarationNode(SyntaxNode node);
29public abstract bool CanOfferUseExpressionBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, CancellationToken cancellationToken);
30public abstract bool CanOfferUseBlockBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, out bool fixesError, [NotNullWhen(true)] out ArrowExpressionClauseSyntax? expressionBody);
31public abstract SyntaxNode Update(SemanticModel semanticModel, SyntaxNode declaration, bool useExpressionBody, CancellationToken cancellationToken);
33public abstract Location GetDiagnosticLocation(SyntaxNode declaration);
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyHelper`1.cs (10)
28where TDeclaration : SyntaxNode
63public override BlockSyntax? GetBody(SyntaxNode declaration)
66public override ArrowExpressionClauseSyntax? GetExpressionBody(SyntaxNode declaration)
69public override bool IsRelevantDeclarationNode(SyntaxNode node)
72public override bool CanOfferUseExpressionBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, CancellationToken cancellationToken)
75public override bool CanOfferUseBlockBody(CodeStyleOption2<ExpressionBodyPreference> preference, SyntaxNode declaration, bool forAnalyzer, out bool fixesError, [NotNullWhen(true)] out ArrowExpressionClauseSyntax? expressionBody)
78public sealed override SyntaxNode Update(SemanticModel semanticModel, SyntaxNode declaration, bool useExpressionBody, CancellationToken cancellationToken)
81public override Location GetDiagnosticLocation(SyntaxNode declaration)
131SyntaxNode declaration, ExpressionBodyPreference conversionPreference, CancellationToken cancellationToken,
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (3)
118private void ReportParameterArrayDiagnostic(OperationAnalysisContext context, SyntaxNode syntaxNode, ImmutableArray<IOperation> elements, NotificationOption2 notificationOption, ArrayCreationOperationLocation operationLocation)
130private void ReportArrayCreationDiagnostic(OperationAnalysisContext context, SyntaxNode syntaxNode, NotificationOption2 notificationOption)
138private void ReportDiagnostic(OperationAnalysisContext context, SyntaxNode syntaxNode, NotificationOption2 notificationOption, Location location, ArrayCreationOperationLocation operationLocation)
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (20)
47protected abstract void TryRegisterFix(CodeFixContext context, Document document, SyntaxNode container, SyntaxNode location);
49private static (SyntaxNode container, SyntaxNode exprOrStatement) GetContainer(SyntaxNode root, TextSpan span)
51var location = root.FindNode(span);
54var container = GetContainer(location);
64private static bool IsValidLocation(SyntaxNode location)
81private static SyntaxNode? GetContainer(SyntaxNode node)
83for (var current = node; current != null; current = current.Parent)
95private static async Task<MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol>)>> GetUnassignedParametersAsync(
105var result = new MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol>)>();
150SyntaxEditor editor, SyntaxNode container,
151MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol> unassignedParameters)>.ValueSet values,
154protected static ImmutableArray<SyntaxNode> GenerateAssignmentStatements(
157var result = ArrayBuilder<SyntaxNode>.GetInstance();
src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AssignOutParametersAboveReturnCodeFixProvider.cs (7)
26protected override void TryRegisterFix(CodeFixContext context, Document document, SyntaxNode container, SyntaxNode location)
32SyntaxEditor editor, SyntaxNode container,
33MultiDictionary<SyntaxNode, (SyntaxNode exprOrStatement, ImmutableArray<IParameterSymbol> unassignedParameters)>.ValueSet values,
44SyntaxEditor editor, SyntaxNode exprOrStatement, ImmutableArray<SyntaxNode> statements)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (8)
81private static (SyntaxNode root, TextSpan semicolonSpan) ReplaceWithFileScopedNamespace(
113var root = document.Root;
119(SyntaxNode stringNode, int closeTerminatorIndentationLength) lastRawStringLiteralData = default;
135SyntaxNode stringNode;
199var root = document.Root;
214SyntaxTree tree, SyntaxNode root, string indentation, TextLine textLine, CancellationToken cancellationToken)
245var updatedRoot = ReplaceWithBlockScopedNamespace(parsedDocument, fileScopedNamespace, options.NewLine, options.NewLines, annotation);
259private static SyntaxNode ReplaceWithBlockScopedNamespace(
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (7)
34protected override bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
37protected override bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
40protected override bool IsImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
45SyntaxNode node,
83SyntaxNode node,
115SyntaxNode node,
150SyntaxNode node,
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (12)
62var originalRoot = editor.OriginalRoot;
69static t => (t.invocationOrCreation, ImmutableArray.Create<SyntaxNode>(t.identifier, t.declarator)),
78private static (VariableDeclaratorSyntax declarator, IdentifierNameSyntax identifier, SyntaxNode invocationOrCreation) FindDiagnosticNodes(
94private static SyntaxNode ReplaceIdentifierWithInlineDeclaration(
97SyntaxNode currentRoot, VariableDeclaratorSyntax declarator,
98IdentifierNameSyntax identifier, SyntaxNode currentNode,
118var block = CSharpInlineDeclarationDiagnosticAnalyzer.GetEnclosingPseudoBlock(localDeclarationStatement.Parent);
240private static ImmutableArray<StatementSyntax> GetStatements(SyntaxNode pseudoBlock)
338SyntaxNode nodeToReplace,
387private static SyntaxNode GetTopmostContainer(SyntaxNode expression)
398int position, SyntaxNode topmostContainer,
src\Analyzers\CSharp\CodeFixes\RemoveUnusedParametersAndValues\CSharpRemoveUnusedValuesCodeFixProvider.cs (15)
45protected override SyntaxNode? TryUpdateNameForFlaggedNode(SyntaxNode node, SyntaxToken newName)
92protected override SyntaxNode? TryUpdateParentOfUpdatedNode(SyntaxNode parent, SyntaxNode newNameNode, SyntaxEditor editor, ISyntaxFacts syntaxFacts, SemanticModel semanticModel)
142protected override SyntaxNode ComputeReplacementNode(SyntaxNode originalOldNode, SyntaxNode changedOldNode, SyntaxNode proposedReplacementNode)
184protected override SyntaxNode GetReplacementNodeForCompoundAssignment(
185SyntaxNode originalCompoundAssignment,
186SyntaxNode newAssignmentTarget,
242protected override SyntaxNode GetReplacementNodeForVarPattern(SyntaxNode originalVarPattern, SyntaxNode newNameNode)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (8)
44var root = editor.OriginalRoot;
48var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
55SyntaxNode node, CancellationToken cancellationToken)
57var declarationContext = node.Parent;
128private static async Task UpdateTypeSyntaxAsync(Document document, SyntaxEditor editor, TypeSyntax typeSyntax, SyntaxNode declarationSyntax, CancellationToken cancellationToken)
147SyntaxNode declarationSyntax,
207private static SyntaxNode GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
218private static ITypeSymbol GetConvertedType(SemanticModel semanticModel, SyntaxNode typeSyntax, CancellationToken cancellationToken)
Structure\CSharpStructureHelpers.cs (14)
84public static SyntaxToken GetLastInlineMethodBlockToken(SyntaxNode node)
211SyntaxNode node,
233static bool TryGetLeadingCollapsibleSpan(SyntaxNode node, out BlockSpan span)
267static SyntaxToken GetEndToken(SyntaxNode node)
287static SyntaxToken GetHintTextEndToken(SyntaxNode node)
320SyntaxNode node, string bannerText, bool autoCollapse,
332SyntaxNode node, SyntaxToken syntaxToken, bool compressEmptyLines,
342SyntaxNode node, SyntaxToken startToken,
369private static TextSpan GetHintSpan(SyntaxNode node, int endPos)
387SyntaxNode node, SyntaxToken startToken,
398SyntaxNode node, bool autoCollapse, string type, bool isCollapsible)
411SyntaxNode node, SyntaxToken syntaxToken, bool compressEmptyLines,
425SyntaxNode node, SyntaxToken startToken, SyntaxToken endToken, bool compressEmptyLines,
440IEnumerable<SyntaxNode> syntaxList, bool compressEmptyLines, bool autoCollapse,
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (24)
93private static SyntaxNode? TryGetDeclaration(
94UseExpressionBodyHelper helper, SourceText text, SyntaxNode node, int position)
114CodeRefactoringContext context, SyntaxNode root, SyntaxNode declaration,
150private static SyntaxNode? GetDeclaration(SyntaxNode node, UseExpressionBodyHelper helper)
152for (var current = node; current != null; current = current.Parent)
162Document document, SyntaxNode root, SyntaxNode declaration,
171private static SyntaxNode GetUpdatedRoot(
172SemanticModel semanticModel, SyntaxNode root, SyntaxNode declaration,
175var updatedDeclaration = helper.Update(semanticModel, declaration, useExpressionBody, cancellationToken);
177var parent = declaration is AccessorDeclarationSyntax
181var updatedParent = parent.ReplaceNode(declaration, updatedDeclaration)
204static IEnumerable<SyntaxNode> GetDeclarationsToFix(
206SyntaxNode root,
215var spanNode = root.FindNode(span);
217foreach (var node in spanNode.DescendantNodesAndSelf())
237SyntaxNode root,
238ImmutableArray<SyntaxNode> declarationsToFix,
244var currentRoot = root.TrackNodes(declarationsToFix);
247foreach (var declaration in declarationsToFix.Reverse())
253var currentDeclaration = currentRoot.GetCurrentNodes(declaration).Single();
Classification\SyntaxClassification\FunctionPointerUnmanagedCallingConventionClassifier.cs (1)
22SyntaxNode syntax,
CodeGeneration\CSharpSyntaxGenerator.cs (632)
68internal override SyntaxTrivia Trivia(SyntaxNode node)
78internal override SyntaxNode DocumentationCommentTrivia(IEnumerable<SyntaxNode> nodes, SyntaxTriviaList trailingTrivia, string endOfLineString)
91internal override SyntaxNode? DocumentationCommentTriviaWithUpdatedContent(SyntaxTrivia trivia, IEnumerable<SyntaxNode> content)
104public override SyntaxNode CompilationUnit(IEnumerable<SyntaxNode> declarations)
111private SyntaxList<UsingDirectiveSyntax> AsUsingDirectives(IEnumerable<SyntaxNode> declarations)
118private SyntaxNode? AsUsingDirective(SyntaxNode node)
128private static SyntaxList<MemberDeclarationSyntax> AsNamespaceMembers(IEnumerable<SyntaxNode> declarations)
135private static SyntaxNode? AsNamespaceMember(SyntaxNode declaration)
154public override SyntaxNode NamespaceImportDeclaration(SyntaxNode name)
157public override SyntaxNode AliasImportDeclaration(string aliasIdentifierName, SyntaxNode name)
160public override SyntaxNode NamespaceDeclaration(SyntaxNode name, IEnumerable<SyntaxNode> declarations)
169public override SyntaxNode FieldDeclaration(
171SyntaxNode type,
174SyntaxNode? initializer)
190private protected override SyntaxNode ParameterDeclaration(
191string name, SyntaxNode? type, SyntaxNode? initializer, RefKind refKind, bool isExtension, bool isParams, bool isScoped)
229private protected override SyntaxNode MethodDeclaration(
231IEnumerable<SyntaxNode>? parameters,
232IEnumerable<SyntaxNode>? typeParameters,
233SyntaxNode? returnType,
236IEnumerable<SyntaxNode>? statements)
266public override SyntaxNode OperatorDeclaration(OperatorKind kind, IEnumerable<SyntaxNode>? parameters = null, SyntaxNode? returnType = null, Accessibility accessibility = Accessibility.NotApplicable, DeclarationModifiers modifiers = default, IEnumerable<SyntaxNode>? statements = null)
272private protected override SyntaxNode OperatorDeclaration(string operatorName, bool isImplicitConversion, IEnumerable<SyntaxNode>? parameters = null, SyntaxNode? returnType = null, Accessibility accessibility = Accessibility.NotApplicable, DeclarationModifiers modifiers = default, IEnumerable<SyntaxNode>? statements = null)
349private static ParameterListSyntax AsParameterList(IEnumerable<SyntaxNode>? parameters)
356public override SyntaxNode ConstructorDeclaration(
358IEnumerable<SyntaxNode>? parameters,
361IEnumerable<SyntaxNode>? baseConstructorArguments,
362IEnumerable<SyntaxNode>? statements)
373private protected override SyntaxNode DestructorDeclaration(IMethodSymbol destructorMethod)
376public override SyntaxNode PropertyDeclaration(
378SyntaxNode type,
381IEnumerable<SyntaxNode>? getAccessorStatements,
382IEnumerable<SyntaxNode>? setAccessorStatements)
384SyntaxNode? getAccessor = null;
385SyntaxNode? setAccessor = null;
396private protected override SyntaxNode PropertyDeclaration(
398SyntaxNode type,
399SyntaxNode? getAccessor,
400SyntaxNode? setAccessor,
422public override SyntaxNode GetAccessorDeclaration(Accessibility accessibility, IEnumerable<SyntaxNode>? statements)
425private protected override SyntaxNode SetAccessorDeclaration(Accessibility accessibility, bool isInitOnly, IEnumerable<SyntaxNode>? statements)
428private static SyntaxNode AccessorDeclaration(
429SyntaxKind kind, Accessibility accessibility, IEnumerable<SyntaxNode>? statements)
442public override SyntaxNode WithAccessorDeclarations(SyntaxNode declaration, IEnumerable<SyntaxNode> accessorDeclarations)
456private static AccessorListSyntax CreateAccessorList(AccessorListSyntax? accessorList, IEnumerable<SyntaxNode> accessorDeclarations)
464public override SyntaxNode IndexerDeclaration(
465IEnumerable<SyntaxNode> parameters,
466SyntaxNode type,
469IEnumerable<SyntaxNode>? getAccessorStatements,
470IEnumerable<SyntaxNode>? setAccessorStatements)
511private static BracketedParameterListSyntax AsBracketedParameterList(IEnumerable<SyntaxNode> parameters)
518private static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, IEnumerable<SyntaxNode>? statements)
532public override SyntaxNode EventDeclaration(
534SyntaxNode type,
546public override SyntaxNode CustomEventDeclaration(
548SyntaxNode type,
551IEnumerable<SyntaxNode>? parameters,
552IEnumerable<SyntaxNode>? addAccessorStatements,
553IEnumerable<SyntaxNode>? removeAccessorStatements)
579public override SyntaxNode? AsPublicInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceTypeName, string? interfaceMemberName)
596public override SyntaxNode? AsPrivateInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceTypeName, string? interfaceMemberName)
612private SyntaxNode WithoutConstraints(SyntaxNode declaration)
625private static SyntaxNode WithInterfaceSpecifier(SyntaxNode declaration, ExplicitInterfaceSpecifierSyntax? specifier)
637private SyntaxNode AsImplementation(SyntaxNode declaration, Accessibility requiredAccess)
645private static SyntaxNode WithBodies(SyntaxNode declaration)
694private protected override SyntaxNode ClassDeclaration(
697IEnumerable<SyntaxNode>? typeParameters,
700SyntaxNode? baseType,
701IEnumerable<SyntaxNode>? interfaceTypes,
702IEnumerable<SyntaxNode>? members)
726private SyntaxList<MemberDeclarationSyntax> AsClassMembers(string className, IEnumerable<SyntaxNode>? members)
733private MemberDeclarationSyntax? AsClassMember(SyntaxNode node, string className)
750private protected override SyntaxNode StructDeclaration(
753IEnumerable<SyntaxNode>? typeParameters,
756IEnumerable<SyntaxNode>? interfaceTypes,
757IEnumerable<SyntaxNode>? members)
773private protected override SyntaxNode InterfaceDeclaration(
775IEnumerable<SyntaxNode>? typeParameters,
777IEnumerable<SyntaxNode>? interfaceTypes = null,
778IEnumerable<SyntaxNode>? members = null)
796private SyntaxList<MemberDeclarationSyntax> AsInterfaceMembers(IEnumerable<SyntaxNode>? members)
803internal override SyntaxNode AsInterfaceMember(SyntaxNode m)
866var type = GetType(f);
878public override SyntaxNode EnumDeclaration(
882IEnumerable<SyntaxNode>? members)
887internal override SyntaxNode EnumDeclaration(string name, SyntaxNode? underlyingType, Accessibility accessibility = Accessibility.NotApplicable, DeclarationModifiers modifiers = default, IEnumerable<SyntaxNode>? members = null)
897public override SyntaxNode EnumMember(string name, SyntaxNode? expression)
905private EnumMemberDeclarationSyntax AsEnumMember(SyntaxNode node)
927private SeparatedSyntaxList<EnumMemberDeclarationSyntax> AsEnumMembers(IEnumerable<SyntaxNode>? members)
930private protected override SyntaxNode DelegateDeclaration(
932IEnumerable<SyntaxNode>? parameters,
933IEnumerable<SyntaxNode>? typeParameters,
934SyntaxNode? returnType,
948public override SyntaxNode Attribute(SyntaxNode name, IEnumerable<SyntaxNode>? attributeArguments)
951public override SyntaxNode AttributeArgument(string? name, SyntaxNode expression)
958private static AttributeArgumentListSyntax? AsAttributeArgumentList(IEnumerable<SyntaxNode>? arguments)
961private static AttributeArgumentSyntax AsAttributeArgument(SyntaxNode node)
990private static SyntaxList<AttributeListSyntax> AsAttributeLists(IEnumerable<SyntaxNode> attributes)
995private static AttributeListSyntax AsAttributeList(SyntaxNode node)
1000private static readonly ConditionalWeakTable<SyntaxNode, IReadOnlyList<SyntaxNode>> s_declAttributes = new();
1002public override IReadOnlyList<SyntaxNode> GetAttributes(SyntaxNode declaration)
1013private static readonly ConditionalWeakTable<SyntaxNode, IReadOnlyList<SyntaxNode>> s_declReturnAttributes = new();
1015public override IReadOnlyList<SyntaxNode> GetReturnAttributes(SyntaxNode declaration)
1029public override SyntaxNode InsertAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes)
1032private SyntaxNode InsertAttributesInternal(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes)
1053public override SyntaxNode InsertReturnAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes)
1067private SyntaxNode InsertReturnAttributesInternal(SyntaxNode d, int index, IEnumerable<SyntaxNode> attributes)
1088private static IEnumerable<AttributeListSyntax> AsReturnAttributes(IEnumerable<SyntaxNode> attributes)
1099private static SyntaxList<AttributeListSyntax> WithRequiredTargetSpecifier(SyntaxList<AttributeListSyntax> attributes, SyntaxNode declaration)
1109public override IReadOnlyList<SyntaxNode> GetAttributeArguments(SyntaxNode attributeDeclaration)
1134public override SyntaxNode InsertAttributeArguments(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributeArguments)
1137private static SyntaxNode InsertAttributeArgumentsInternal(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributeArguments)
1157private static AttributeArgumentListSyntax? GetAttributeArgumentList(SyntaxNode declaration)
1177private static SyntaxNode WithAttributeArgumentList(SyntaxNode declaration, AttributeArgumentListSyntax? argList)
1197internal static SyntaxList<AttributeListSyntax> GetAttributeLists(SyntaxNode declaration)
1208private static SyntaxNode WithAttributeLists(SyntaxNode declaration, SyntaxList<AttributeListSyntax> attributeLists)
1221internal override SyntaxNode? GetPrimaryConstructorParameterList(SyntaxNode declaration)
1224internal override ImmutableArray<SyntaxNode> GetTypeInheritance(SyntaxNode declaration)
1227: ImmutableArray<SyntaxNode>.Empty;
1229public override IReadOnlyList<SyntaxNode> GetNamespaceImports(SyntaxNode declaration)
1237public override SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports)
1239var result = PreserveTrivia(declaration, d => InsertNamespaceImportsInternal(d, index, imports));
1244private SyntaxNode InsertNamespaceImportsInternal(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports)
1256public override IReadOnlyList<SyntaxNode> GetMembers(SyntaxNode declaration)
1266private static ImmutableArray<SyntaxNode> Flatten(IEnumerable<SyntaxNode> declarations)
1268var builder = ArrayBuilder<SyntaxNode>.GetInstance();
1270foreach (var declaration in declarations)
1311static void FlattenDeclaration(ArrayBuilder<SyntaxNode> builder, SyntaxNode declaration, VariableDeclarationSyntax variableDeclaration)
1324private static int GetDeclarationCount(SyntaxNode declaration)
1335private static SyntaxNode EnsureTypeDeclarationHasBody(SyntaxNode declaration)
1348public override SyntaxNode InsertMembers(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> members)
1376private IEnumerable<MemberDeclarationSyntax>? AsMembersOf(SyntaxNode declaration, IEnumerable<SyntaxNode>? members)
1379private SyntaxNode? AsMemberOf(SyntaxNode declaration, SyntaxNode member)
1390private static bool CanHaveAccessibility(SyntaxNode declaration)
1398public override Accessibility GetAccessibility(SyntaxNode declaration)
1404public override SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibility accessibility)
1606public override DeclarationModifiers GetModifiers(SyntaxNode declaration)
1613private static SyntaxTokenList GetModifierTokens(SyntaxNode declaration)
1616public override SyntaxNode WithModifiers(SyntaxNode declaration, DeclarationModifiers modifiers)
1619private SyntaxNode WithModifiersInternal(SyntaxNode declaration, DeclarationModifiers modifiers)
1651private static SyntaxNode SetModifierTokens(SyntaxNode declaration, SyntaxTokenList modifiers)
1748private protected override SyntaxNode TypeParameter(string name)
1751private protected override SyntaxNode TypeParameter(ITypeParameterSymbol typeParameter)
1764private static TypeParameterListSyntax? AsTypeParameterList(IEnumerable<SyntaxNode>? typeParameterNodes)
1773private protected override SyntaxNode WithTypeParameters(SyntaxNode declaration, IEnumerable<SyntaxNode> typeParameters)
1786internal override SyntaxNode WithExplicitInterfaceImplementations(
1787SyntaxNode declaration,
1811private static SyntaxNode RemoveDefaultValue(ParameterSyntax parameter, bool removeDefaults)
1829private protected override SyntaxNode WithTypeConstraint(
1830SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, bool isUnmanagedType, IEnumerable<SyntaxNode>? types)
1839private protected override SyntaxNode WithDefaultConstraint(SyntaxNode declaration, string typeParameterName)
1851IEnumerable<SyntaxNode>? types)
1897public override DeclarationKind GetDeclarationKind(SyntaxNode declaration)
1900public override string GetName(SyntaxNode declaration)
1922public override SyntaxNode WithName(SyntaxNode declaration, string name)
1925private SyntaxNode WithNameInternal(SyntaxNode declaration, string name)
1962public override SyntaxNode? GetType(SyntaxNode declaration)
2001public override SyntaxNode WithType(SyntaxNode declaration, SyntaxNode type)
2004private static SyntaxNode WithTypeInternal(SyntaxNode declaration, SyntaxNode type)
2020private SyntaxNode Isolate(SyntaxNode declaration, Func<SyntaxNode, SyntaxNode> editor)
2023private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration)
2059private static SyntaxNode WithVariable(SyntaxNode declaration, VariableDeclaratorSyntax variable)
2070private static VariableDeclarationSyntax? GetVariableDeclaration(SyntaxNode declaration)
2079private static SyntaxNode WithVariableDeclaration(SyntaxNode declaration, VariableDeclarationSyntax variables)
2088private static SyntaxNode GetFullDeclaration(SyntaxNode declaration)
2119private SyntaxNode? AsNodeLike(SyntaxNode existingNode, SyntaxNode newNode)
2129var container = GetDeclaration(existingNode.Parent);
2144public override IReadOnlyList<SyntaxNode> GetParameters(SyntaxNode declaration)
2154public override SyntaxNode InsertParameters(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> parameters)
2167public override IReadOnlyList<SyntaxNode> GetSwitchSections(SyntaxNode switchStatement)
2173public override SyntaxNode InsertSwitchSections(SyntaxNode switchStatement, int index, IEnumerable<SyntaxNode> switchSections)
2200public override SyntaxNode? Visit(SyntaxNode? node)
2223internal override SyntaxNode? GetParameterListNode(SyntaxNode declaration)
2226private static SyntaxNode WithParameterList(SyntaxNode declaration, BaseParameterListSyntax list)
2272public override SyntaxNode? GetExpression(SyntaxNode declaration)
2322public override SyntaxNode WithExpression(SyntaxNode declaration, SyntaxNode expression)
2325private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxNode expression)
2398private static EqualsValueClauseSyntax? GetEqualsValue(SyntaxNode declaration)
2438private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueClauseSyntax? initializer)
2478public override IReadOnlyList<SyntaxNode> GetStatements(SyntaxNode declaration)
2500public override SyntaxNode WithStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
2536public override IReadOnlyList<SyntaxNode> GetAccessors(SyntaxNode declaration)
2542public override SyntaxNode InsertAccessors(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> accessors)
2563internal static AccessorListSyntax? GetAccessorList(SyntaxNode declaration)
2566private static bool CanHaveAccessors(SyntaxNode declaration)
2575private static SyntaxNode WithAccessorList(SyntaxNode declaration, AccessorListSyntax accessorList)
2582private static AccessorListSyntax AsAccessorList(IEnumerable<SyntaxNode> nodes, SyntaxKind parentKind)
2585private static AccessorDeclarationSyntax? AsAccessor(SyntaxNode node, SyntaxKind parentKind)
2613private static AccessorDeclarationSyntax? GetAccessor(SyntaxNode declaration, SyntaxKind kind)
2619private SyntaxNode WithAccessor(SyntaxNode declaration, SyntaxKind kind, AccessorDeclarationSyntax accessor)
2622private SyntaxNode WithAccessor(SyntaxNode declaration, AccessorListSyntax? accessorList, SyntaxKind kind, AccessorDeclarationSyntax? accessor)
2640public override IReadOnlyList<SyntaxNode> GetGetAccessorStatements(SyntaxNode declaration)
2646public override IReadOnlyList<SyntaxNode> GetSetAccessorStatements(SyntaxNode declaration)
2652public override SyntaxNode WithGetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
2655public override SyntaxNode WithSetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
2658private SyntaxNode WithAccessorStatements(SyntaxNode declaration, SyntaxKind kind, IEnumerable<SyntaxNode> statements)
2672public override IReadOnlyList<SyntaxNode> GetBaseAndInterfaceTypes(SyntaxNode declaration)
2685public override SyntaxNode AddBaseType(SyntaxNode declaration, SyntaxNode baseType)
2699public override SyntaxNode AddInterfaceType(SyntaxNode declaration, SyntaxNode interfaceType)
2713private static SyntaxNode AddBaseList(SyntaxNode declaration, BaseListSyntax baseList)
2715var newDecl = WithBaseList(declaration, baseList);
2721private static BaseListSyntax? GetBaseList(SyntaxNode declaration)
2726private static SyntaxNode WithBaseList(SyntaxNode declaration, BaseListSyntax baseList)
2735public override SyntaxNode ReplaceNode(SyntaxNode root, SyntaxNode declaration, SyntaxNode? newDeclaration)
2750var newFullDecl = AsIsolatedDeclaration(newDeclaration);
2751var fullDecl = GetFullDeclaration(declaration);
2759var newSubDecl = GetSubDeclarations(newFullDecl)[0];
2783private static bool AreInlineReplaceableSubDeclarations(SyntaxNode decl1, SyntaxNode decl2)
2799private static bool AreSimilarExceptForSubDeclarations(SyntaxNode? decl1, SyntaxNode? decl2)
2848private IEnumerable<SyntaxNode> SplitAndReplace(SyntaxNode multiPartDeclaration, int index, IEnumerable<SyntaxNode> newDeclarations)
2854var newNodes = new List<SyntaxNode>();
2878public override SyntaxNode InsertNodesBefore(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2897private SyntaxNode InsertNodesBeforeInternal(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2899var fullDecl = GetFullDeclaration(declaration);
2917public override SyntaxNode InsertNodesAfter(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2936private SyntaxNode InsertNodesAfterInternal(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2938var fullDecl = GetFullDeclaration(declaration);
2957private IEnumerable<SyntaxNode> SplitAndInsert(SyntaxNode multiPartDeclaration, int index, IEnumerable<SyntaxNode> newDeclarations)
2960var newNodes = new List<SyntaxNode>
2969private SyntaxNode WithSubDeclarationsRemoved(SyntaxNode declaration, int index, int count)
2972private static IReadOnlyList<SyntaxNode> GetSubDeclarations(SyntaxNode declaration)
2983public override SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node)
2986public override SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node, SyntaxRemoveOptions options)
3007private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, SyntaxRemoveOptions options)
3033var full = GetFullDeclaration(declaration);
3052var parent = declaration.Parent;
3071private static SyntaxNode ShiftTrivia(SyntaxNode root, SyntaxNode node)
3077var newNode = node.WithTrailingTrivia(node.GetTrailingTrivia().AddRange(previousToken.TrailingTrivia));
3095public override SyntaxNode AddEventHandler(SyntaxNode @event, SyntaxNode handler)
3098public override SyntaxNode RemoveEventHandler(SyntaxNode @event, SyntaxNode handler)
3101public override SyntaxNode AwaitExpression(SyntaxNode expression)
3104public override SyntaxNode NameOfExpression(SyntaxNode expression)
3107public override SyntaxNode ReturnStatement(SyntaxNode? expression = null)
3110public override SyntaxNode ThrowStatement(SyntaxNode? expression = null)
3113public override SyntaxNode ThrowExpression(SyntaxNode expression)
3116public override SyntaxNode IfStatement(SyntaxNode condition, IEnumerable<SyntaxNode> trueStatements, IEnumerable<SyntaxNode>? falseStatements = null)
3137private static BlockSyntax CreateBlock(IEnumerable<SyntaxNode>? statements = null)
3140private static SyntaxList<StatementSyntax> AsStatementList(IEnumerable<SyntaxNode>? nodes)
3143private static StatementSyntax AsStatement(SyntaxNode node)
3153public override SyntaxNode ExpressionStatement(SyntaxNode expression)
3156internal override SyntaxNode MemberAccessExpressionWorker(SyntaxNode? expression, SyntaxNode simpleName)
3167public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
3170public override SyntaxNode MemberBindingExpression(SyntaxNode name)
3173public override SyntaxNode ElementBindingExpression(IEnumerable<SyntaxNode> arguments)
3198private static SeparatedSyntaxList<ExpressionSyntax> AsExpressionList(IEnumerable<SyntaxNode> expressions)
3201public override SyntaxNode ArrayCreationExpression(SyntaxNode elementType, SyntaxNode size)
3207public override SyntaxNode ArrayCreationExpression(SyntaxNode elementType, IEnumerable<SyntaxNode> elements)
3215public override SyntaxNode ObjectCreationExpression(SyntaxNode type, IEnumerable<SyntaxNode> arguments)
3218internal override SyntaxNode ObjectCreationExpression(SyntaxNode type, SyntaxToken openParen, SeparatedSyntaxList<SyntaxNode> arguments, SyntaxToken closeParen)
3224private static ArgumentListSyntax CreateArgumentList(IEnumerable<SyntaxNode> arguments)
3227private static SeparatedSyntaxList<ArgumentSyntax> CreateArguments(IEnumerable<SyntaxNode> arguments)
3230private static ArgumentSyntax AsArgument(SyntaxNode argOrExpression)
3233public override SyntaxNode InvocationExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments)
3236public override SyntaxNode ElementAccessExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments)
3242public override SyntaxNode DefaultExpression(SyntaxNode type)
3245public override SyntaxNode DefaultExpression(ITypeSymbol type)
3280private static SyntaxNode Parenthesize(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
3283public override SyntaxNode IsTypeExpression(SyntaxNode expression, SyntaxNode type)
3286public override SyntaxNode TypeOfExpression(SyntaxNode type)
3289public override SyntaxNode TryCastExpression(SyntaxNode expression, SyntaxNode type)
3292public override SyntaxNode CastExpression(SyntaxNode type, SyntaxNode expression)
3295public override SyntaxNode ConvertExpression(SyntaxNode type, SyntaxNode expression)
3298public override SyntaxNode AssignmentStatement(SyntaxNode left, SyntaxNode right)
3301private static SyntaxNode CreateBinaryExpression(SyntaxKind syntaxKind, SyntaxNode left, SyntaxNode right)
3304public override SyntaxNode ValueEqualsExpression(SyntaxNode left, SyntaxNode right)
3307public override SyntaxNode ReferenceEqualsExpression(SyntaxNode left, SyntaxNode right)
3310public override SyntaxNode ValueNotEqualsExpression(SyntaxNode left, SyntaxNode right)
3313public override SyntaxNode ReferenceNotEqualsExpression(SyntaxNode left, SyntaxNode right)
3316public override SyntaxNode LessThanExpression(SyntaxNode left, SyntaxNode right)
3319public override SyntaxNode LessThanOrEqualExpression(SyntaxNode left, SyntaxNode right)
3322public override SyntaxNode GreaterThanExpression(SyntaxNode left, SyntaxNode right)
3325public override SyntaxNode GreaterThanOrEqualExpression(SyntaxNode left, SyntaxNode right)
3328public override SyntaxNode NegateExpression(SyntaxNode expression)
3331public override SyntaxNode AddExpression(SyntaxNode left, SyntaxNode right)
3334public override SyntaxNode SubtractExpression(SyntaxNode left, SyntaxNode right)
3337public override SyntaxNode MultiplyExpression(SyntaxNode left, SyntaxNode right)
3340public override SyntaxNode DivideExpression(SyntaxNode left, SyntaxNode right)
3343public override SyntaxNode ModuloExpression(SyntaxNode left, SyntaxNode right)
3346public override SyntaxNode BitwiseAndExpression(SyntaxNode left, SyntaxNode right)
3349public override SyntaxNode BitwiseOrExpression(SyntaxNode left, SyntaxNode right)
3352public override SyntaxNode BitwiseNotExpression(SyntaxNode operand)
3355public override SyntaxNode LogicalAndExpression(SyntaxNode left, SyntaxNode right)
3358public override SyntaxNode LogicalOrExpression(SyntaxNode left, SyntaxNode right)
3361public override SyntaxNode LogicalNotExpression(SyntaxNode expression)
3364public override SyntaxNode ConditionalExpression(SyntaxNode condition, SyntaxNode whenTrue, SyntaxNode whenFalse)
3367public override SyntaxNode CoalesceExpression(SyntaxNode left, SyntaxNode right)
3370public override SyntaxNode ThisExpression()
3373public override SyntaxNode BaseExpression()
3376public override SyntaxNode TypedConstantExpression(TypedConstant value)
3379private protected override SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
3382public override SyntaxNode IdentifierName(string identifier)
3385public override SyntaxNode GenericName(string identifier, IEnumerable<SyntaxNode> typeArguments)
3388internal override SyntaxNode GenericName(SyntaxToken identifier, IEnumerable<SyntaxNode> typeArguments)
3392public override SyntaxNode WithTypeArguments(SyntaxNode expression, IEnumerable<SyntaxNode> typeArguments)
3422public override SyntaxNode QualifiedName(SyntaxNode left, SyntaxNode right)
3425internal override SyntaxNode GlobalAliasedName(SyntaxNode name)
3430public override SyntaxNode NameExpression(INamespaceOrTypeSymbol namespaceOrTypeSymbol)
3433private protected override SyntaxNode TypeExpression(ITypeSymbol typeSymbol, RefKind refKind)
3444public override SyntaxNode TypeExpression(SpecialType specialType)
3465public override SyntaxNode ArrayTypeExpression(SyntaxNode type)
3468public override SyntaxNode NullableTypeExpression(SyntaxNode type)
3480internal override SyntaxNode CreateTupleType(IEnumerable<SyntaxNode> elements)
3483public override SyntaxNode TupleElementExpression(SyntaxNode type, string? name = null)
3486public override SyntaxNode Argument(string? name, RefKind refKind, SyntaxNode expression)
3494public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, string name, SyntaxNode? initializer, bool isConst)
3497public override SyntaxNode UsingStatement(SyntaxNode? type, string name, SyntaxNode expression, IEnumerable<SyntaxNode> statements)
3505public override SyntaxNode UsingStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements)
3513public override SyntaxNode LockStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements)
3520public override SyntaxNode TryCatchStatement(IEnumerable<SyntaxNode>? tryStatements, IEnumerable<SyntaxNode>? catchClauses, IEnumerable<SyntaxNode>? finallyStatements = null)
3528public override SyntaxNode CatchClause(SyntaxNode type, string name, IEnumerable<SyntaxNode> statements)
3536public override SyntaxNode WhileStatement(SyntaxNode condition, IEnumerable<SyntaxNode> statements)
3539public override SyntaxNode SwitchStatement(SyntaxNode expression, IEnumerable<SyntaxNode> caseClauses)
3560public override SyntaxNode SwitchSection(IEnumerable<SyntaxNode> expressions, IEnumerable<SyntaxNode> statements)
3563internal override SyntaxNode SwitchSectionFromLabels(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements)
3570public override SyntaxNode DefaultSwitchSection(IEnumerable<SyntaxNode> statements)
3573private static SyntaxList<SwitchLabelSyntax> AsSwitchLabels(IEnumerable<SyntaxNode> expressions)
3585public override SyntaxNode ExitSwitchStatement()
3588internal override SyntaxNode ScopeBlock(IEnumerable<SyntaxNode> statements)
3591internal override SyntaxNode GlobalStatement(SyntaxNode statement)
3594public override SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? parameterDeclarations, SyntaxNode expression)
3603private static bool IsSimpleLambdaParameter(SyntaxNode node)
3606public override SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, SyntaxNode expression)
3609public override SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? parameterDeclarations, IEnumerable<SyntaxNode> statements)
3612public override SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, IEnumerable<SyntaxNode> statements)
3615public override SyntaxNode LambdaParameter(string identifier, SyntaxNode? type = null)
3618internal override SyntaxNode IdentifierName(SyntaxToken identifier)
3621internal override SyntaxNode NamedAnonymousObjectMemberDeclarator(SyntaxNode identifier, SyntaxNode expression)
3628public override SyntaxNode TupleExpression(IEnumerable<SyntaxNode> arguments)
3631internal override SyntaxNode RemoveAllComments(SyntaxNode node)
3671internal override SyntaxNode ParseExpression(string stringToParse)
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (8)
92private static void AddAliasMaps(SyntaxNode node, List<Dictionary<string, string>> aliasMaps)
94for (var current = node; current != null; current = current.Parent)
204SyntaxNode container,
246SyntaxNode container,
267SyntaxNode container,
410SyntaxNode container,
597private static Accessibility GetAccessibility(SyntaxNode container, SyntaxTokenList modifiers)
695private static bool TryGetSimpleTypeName(SyntaxNode node, ImmutableArray<string>? typeParameterNames, out string simpleTypeName, out bool isArray)
Simplification\CSharpSimplificationService.cs (20)
53public override SyntaxNode Expand(SyntaxNode node, SemanticModel semanticModel, SyntaxAnnotation? annotationForReplacedAliasIdentifier, Func<SyntaxNode, bool>? expandInsideNode, bool expandParameter, CancellationToken cancellationToken)
78public override SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Func<SyntaxNode, bool>? expandInsideNode, CancellationToken cancellationToken)
96public static SyntaxToken TryEscapeIdentifierToken(SyntaxToken syntaxToken, SyntaxNode parentOfToken)
114var parent = parentOfToken.Parent;
138public static T AppendElasticTriviaIfNecessary<T>(T rewrittenNode, T originalNode) where T : SyntaxNode
170protected override SemanticModel GetSpeculativeSemanticModel(ref SyntaxNode nodeToSpeculate, SemanticModel originalSemanticModel, SyntaxNode originalNode)
172var syntaxNodeToSpeculate = nodeToSpeculate;
178protected override ImmutableArray<NodeOrTokenToReduce> GetNodesAndTokensToReduce(SyntaxNode root, Func<SyntaxNodeOrToken, bool> isNodeOrTokenOutsideSimplifySpans)
181protected override bool NodeRequiresNonSpeculativeSemanticModel(SyntaxNode node)
186protected override void GetUnusedNamespaceImports(SemanticModel model, HashSet<SyntaxNode> namespaceImports, CancellationToken cancellationToken)
188var root = model.SyntaxTree.GetRoot(cancellationToken);
204private static bool IsTupleInDeconstruction(SyntaxNode tuple)
207var currentTuple = tuple;
210var parent = currentTuple.Parent;
221var grandParent = parent.Parent;
232protected override void AddImportDeclarations(CompilationUnitSyntax root, ArrayBuilder<SyntaxNode> importDeclarations)
242static void AddImportDeclarations(BaseNamespaceDeclarationSyntax baseNamespace, ArrayBuilder<SyntaxNode> importDeclarations)
Simplification\Reducers\CSharpMiscellaneousReducer.cs (7)
25private static readonly Func<ParameterSyntax, SemanticModel, SimplifierOptions, CancellationToken, SyntaxNode> s_simplifyParameter = SimplifyParameter;
67private static SyntaxNode SimplifyParameter(
83private static readonly Func<ParenthesizedLambdaExpressionSyntax, SemanticModel, SimplifierOptions, CancellationToken, SyntaxNode> s_simplifyParenthesizedLambdaExpression = SimplifyParenthesizedLambdaExpression;
85private static SyntaxNode SimplifyParenthesizedLambdaExpression(
111private static readonly Func<BlockSyntax, SemanticModel, CSharpSimplifierOptions, CancellationToken, SyntaxNode> s_simplifyBlock = SimplifyBlock;
113private static SyntaxNode SimplifyBlock(
176private static bool CanHaveEmbeddedStatement(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (74)
23public static LanguageVersion GetLanguageVersion(this SyntaxNode node)
26public static void Deconstruct(this SyntaxNode node, out SyntaxKind kind)
29public static bool IsKind<TNode>([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind, [NotNullWhen(true)] out TNode? result)
30where TNode : SyntaxNode
42public static bool IsParentKind([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind)
45public static bool IsParentKind<TNode>([NotNullWhen(true)] this SyntaxNode? node, SyntaxKind kind, [NotNullWhen(true)] out TNode? result)
46where TNode : SyntaxNode
59this SyntaxNode node, SourceText? sourceText = null,
88public static bool IsAnyArgumentList([NotNullWhen(true)] this SyntaxNode? node)
97public static (SyntaxToken openBrace, SyntaxToken closeBrace) GetBraces(this SyntaxNode? node)
114public static bool IsEmbeddedStatementOwner([NotNullWhen(true)] this SyntaxNode? node)
128public static StatementSyntax? GetEmbeddedStatement(this SyntaxNode? node)
144public static BaseParameterListSyntax? GetParameterList(this SyntaxNode? declaration)
157public static SyntaxList<AttributeListSyntax> GetAttributeLists(this SyntaxNode? declaration)
170public static ConditionalAccessExpressionSyntax? GetParentConditionalAccessExpression(this SyntaxNode? node)
182var current = node;
249/// <inheritdoc cref="ISyntaxFacts.GetRootConditionalAccessExpression(SyntaxNode)"/>
251public static ConditionalAccessExpressionSyntax? GetRootConditionalAccessExpression(this SyntaxNode? node)
268public static ConditionalAccessExpressionSyntax? GetInnerMostConditionalAccessExpression(this SyntaxNode node)
279public static bool IsAsyncSupportingFunctionSyntax([NotNullWhen(true)] this SyntaxNode? node)
282public static bool IsCompoundAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
285public static bool IsLeftSideOfAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
289public static bool IsLeftSideOfAnyAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
292public static bool IsRightSideOfAnyAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
295public static bool IsLeftSideOfCompoundAssignExpression([NotNullWhen(true)] this SyntaxNode? node)
306public static IEnumerable<UsingDirectiveSyntax> GetEnclosingUsingDirectives(this SyntaxNode node)
314public static IEnumerable<ExternAliasDirectiveSyntax> GetEnclosingExternAliasDirectives(this SyntaxNode node)
322public static bool IsUnsafeContext(this SyntaxNode node)
333public static bool IsInStaticContext(this SyntaxNode node)
335for (var current = node; current != null; current = current.Parent)
370public static BaseNamespaceDeclarationSyntax? GetInnermostNamespaceDeclarationWithUsings(this SyntaxNode contextNode)
393public static bool IsBreakableConstruct(this SyntaxNode node)
409public static bool IsContinuableConstruct(this SyntaxNode node)
424public static bool IsReturnableConstruct(this SyntaxNode node)
448public static bool ContainsYield(this SyntaxNode node)
451public static bool IsReturnableConstructOrTopLevelCompilationUnit(this SyntaxNode node)
454public static bool SpansPreprocessorDirective<TSyntaxNode>(this IEnumerable<TSyntaxNode> list) where TSyntaxNode : SyntaxNode
459where TNode : SyntaxNode
507public static bool ContainsInterleavedDirective(this SyntaxNode syntaxNode, CancellationToken cancellationToken)
511/// Similar to <see cref="ContainsInterleavedDirective(SyntaxNode, CancellationToken)"/> except that the span to check
514public static bool ContainsInterleavedDirective(this SyntaxNode syntaxNode, TextSpan span, CancellationToken cancellationToken)
553var structure = trivia.GetStructure()!;
595where TSyntaxNode : SyntaxNode
655public static ImmutableArray<SyntaxTrivia> GetLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
658public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
661public static TSyntaxNode GetNodeWithoutLeadingBlankLines<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode
664public static ImmutableArray<SyntaxTrivia> GetLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
667public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node) where TSyntaxNode : SyntaxNode
670public static TSyntaxNode GetNodeWithoutLeadingBannerAndPreprocessorDirectives<TSyntaxNode>(this TSyntaxNode node, out ImmutableArray<SyntaxTrivia> strippedTrivia) where TSyntaxNode : SyntaxNode
673public static bool IsVariableDeclaratorValue([NotNullWhen(true)] this SyntaxNode? node)
677public static BlockSyntax? FindInnermostCommonBlock(this IEnumerable<SyntaxNode> nodes)
680public static IEnumerable<SyntaxNode> GetAncestorsOrThis(this SyntaxNode? node, Func<SyntaxNode, bool> predicate)
682var current = node;
694public static (SyntaxToken openParen, SyntaxToken closeParen) GetParentheses(this SyntaxNode node)
724public static (SyntaxToken openBracket, SyntaxToken closeBracket) GetBrackets(this SyntaxNode? node)
737public static SyntaxTokenList GetModifiers(this SyntaxNode? member)
749public static SyntaxNode? WithModifiers(this SyntaxNode? member, SyntaxTokenList modifiers)
760public static void ForEachMember<TArg>(this SyntaxNode? node, Action<MemberDeclarationSyntax, TArg> callback, TArg arg)
785[NotNullWhen(true)] this SyntaxNode? node,
792for (var current = node; current != null; current = current.Parent)
837[NotNullWhen(true)] this SyntaxNode? node,
838[NotNullWhen(true)] out SyntaxNode? deconstructionLeft)
840SyntaxNode? previous = null;
841for (var current = node; current != null; current = current.Parent)
863where T : SyntaxNode
872where T : SyntaxNode
880where T : SyntaxNode
886public static T KeepCommentsAndAddElasticMarkers<T>(this T node) where T : SyntaxNode
891public static SyntaxNode WithPrependedNonIndentationTriviaFrom(
892this SyntaxNode to, SyntaxNode from)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\CSharpFormatEngine.cs (1)
16SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\IndentBlockFormattingRule.cs (10)
46public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
65private static void AddTypeParameterConstraintClauseOperation(List<IndentBlockOperation> list, SyntaxNode node)
74private void AddSwitchIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
134private void AddLabelIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
150private static void AddAlignmentBlockOperation(List<IndentBlockOperation> list, SyntaxNode node)
205private static void SetAlignmentBlockOperation(List<IndentBlockOperation> list, SyntaxNode baseNode, SyntaxNode body)
216private void AddBlockIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
253private static void AddBracketIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
288private static void AddEmbeddedStatementsIndentationOperation(List<IndentBlockOperation> list, SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\Precedence\AbstractCSharpPrecedenceService.cs (1)
13where TSyntax : SyntaxNode
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (29)
40public bool IsWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
43public bool IsOnlyWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
46public bool IsInOutContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
49public bool IsInRefContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
52public bool IsInInContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
55public bool CanReplaceWithRValue(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? expression, CancellationToken cancellationToken)
62foreach (var ancestor in token.GetAncestors<SyntaxNode>())
112SyntaxNode oldNode,
113SyntaxNode newNode,
169public ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode node)
183public SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
186public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
197public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
209public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
234var node = syntaxRef.GetSyntax(cancellationToken);
245public IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken)
255public IParameterSymbol? FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
258public IParameterSymbol? FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
262public ISymbol? FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken)
265public ISymbol? FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken)
270public ImmutableArray<ISymbol> GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode? node, SyntaxToken token, CancellationToken cancellationToken)
292/// cref="ModelExtensions.GetSymbolInfo(SemanticModel, SyntaxNode, CancellationToken)"/>, but sometimes employs
296private ImmutableArray<ISymbol> GetSymbolInfo(SemanticModel semanticModel, SyntaxNode node, SyntaxToken token, CancellationToken cancellationToken)
368public bool IsInsideNameOfExpression(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken)
377var node = syntaxReference.GetSyntax(cancellationToken);
392public bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, [NotNullWhen(true)] INamedTypeSymbol? expressionType, CancellationToken cancellationToken)
395public string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken)
398public IPreprocessingSymbol? GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node)
410private static bool IsInPreprocessingSymbolContext(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (18)
24public override bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
38public override bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration)
51public override bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter)
64public override bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method)
77public override bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction)
90public override bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration)
105public override bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement)
118public override bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement)
131public override bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (311)
29private static readonly ObjectPool<List<SyntaxNode>> s_syntaxNodeListPool = new ObjectPool<List<SyntaxNode>>(() => [], trimOnFree: false);
130public bool IsDirective([NotNullWhen(true)] SyntaxNode? node)
133public bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? node, out ExternalSourceInfo info)
154public bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
160public bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
163public bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
170public SyntaxNode? GetStandaloneExpression(SyntaxNode? node)
173public SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node)
176public bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node)
179public bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node)
182public bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node)
185public SyntaxNode? GetParameterList(SyntaxNode node)
188public bool IsParameterList([NotNullWhen(true)] SyntaxNode? node)
191public bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node)
195public bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node)
198public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name)
206public bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node)
209public bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node)
212public Location GetDeconstructionReferenceLocation(SyntaxNode node)
222public bool IsStatement([NotNullWhen(true)] SyntaxNode? node)
225public bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node)
228public bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node)
231public SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node)
234public bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement)
253public bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node)
265public SyntaxNode GetExpressionOfRefExpression(SyntaxNode node)
268public SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node)
312public bool IsPredefinedType(SyntaxNode? node)
315public bool IsPredefinedType(SyntaxNode? node, PredefinedType type)
535public bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node)
538public bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node)
541public bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
544public bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
547public void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity)
554public bool LooksGeneric(SyntaxNode simpleName)
558public SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName)
561public SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node)
564public SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node)
567public SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget)
570public void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList)
577public SyntaxNode GetExpressionOfInterpolation(SyntaxNode node)
580public bool IsInStaticContext(SyntaxNode node)
583public bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node)
586public bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node)
589public SyntaxNode GetExpressionOfArgument(SyntaxNode node)
592public SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node)
595public RefKind GetRefKindOfArgument(SyntaxNode node)
598public bool IsArgument([NotNullWhen(true)] SyntaxNode? node)
601public bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node)
604public bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node)
611public bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node)
614public bool IsInConstructor(SyntaxNode node)
617public bool IsUnsafeContext(SyntaxNode node)
620public bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node)
623public SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position)
627.GetAncestors<SyntaxNode>()
631public SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node)
634public bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node)
639public bool IsPropertyPatternClause(SyntaxNode node)
643[NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance)
674public bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression)
689public bool IsElementAccessExpression(SyntaxNode? node)
693public SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false)
696public SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
699public SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
702private static SyntaxNode? GetContainingMemberDeclaration<TMemberDeclarationSyntax>(SyntaxNode root, int position, bool useFullSpan = true)
715var node = root.FindToken(position).Parent;
733public bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node)
741public bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node)
750public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null)
812private static string? GetName(SyntaxNode node, DisplayNameOptions options)
899public PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root)
909public PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root)
919public SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration)
922private void AppendMembers(SyntaxNode? node, List<SyntaxNode> list, bool topLevel, bool methodLevel)
946public TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node)
953var member = GetContainingMemberDeclaration(node, node.SpanStart);
973public bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span)
996public SyntaxNode? TryGetBindableParent(SyntaxToken token)
998var node = token.Parent;
1001var parent = node.Parent;
1070public IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken)
1075var constructors = new List<SyntaxNode>();
1080private static void AppendConstructors(SyntaxList<MemberDeclarationSyntax> members, List<SyntaxNode> constructors, CancellationToken cancellationToken)
1144public string GetNameForArgument(SyntaxNode? argument)
1147public string GetNameForAttributeArgument(SyntaxNode? argument)
1150public bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node)
1153public SyntaxNode? GetRightSideOfDot(SyntaxNode? node)
1159public SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget)
1165public bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node)
1168public bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node)
1171public bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node)
1174public bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node)
1177public SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node)
1180public bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node)
1184public bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node)
1187public static bool IsOperandOfDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1190public bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1193public SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString)
1202public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode objectCreationExpression)
1207public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode argumentList)
1210public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode argumentList)
1222public bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes)
1228public bool IsDocumentationComment(SyntaxNode node)
1231public bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node)
1234public bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node)
1237public bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node)
1240private static bool IsGlobalAttribute([NotNullWhen(true)] SyntaxNode? node, SyntaxKind attributeTarget)
1245public bool IsDeclaration(SyntaxNode? node)
1294public bool IsTypeDeclaration(SyntaxNode node)
1297public bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement)
1302SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1309SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1311var expression = statement;
1324public bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? node)
1327public SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node)
1330public SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node)
1333public SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node)
1341public bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement)
1348public bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2)
1351public static SyntaxNode GetExpressionOfInvocationExpression(SyntaxNode node)
1354public bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node)
1357public SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node)
1360public void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
1361out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
1365arguments = (SeparatedSyntaxList<TArgumentSyntax>)(SeparatedSyntaxList<SyntaxNode>)tupleExpression.Arguments;
1375public SyntaxTokenList GetModifiers(SyntaxNode? node)
1379public SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers)
1382public SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node)
1385public SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node)
1388public SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node)
1391public SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node)
1394public SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node)
1397public bool IsEqualsValueOfPropertyDeclaration(SyntaxNode? node)
1400public bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node)
1403public bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node)
1406public void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression)
1423public SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node)
1426public bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node)
1430public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia)
1440public void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type)
1447public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right)
1455public bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node)
1458public SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node)
1461public void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation)
1468public void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation)
1484public bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node)
1487public bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node)
1490public void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen)
1498public void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1506public void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern)
1513public void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression)
1520public SyntaxNode GetTypeOfTypePattern(SyntaxNode node)
1523public bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node)
1538public bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node)
1541public bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node)
1544public bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node)
1547public bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node)
1550public bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
1553public bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node)
1556public bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node)
1559public bool IsAnyName([NotNullWhen(true)] SyntaxNode? node)
1562public bool IsAnyType([NotNullWhen(true)] SyntaxNode? node)
1565public bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1568public bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node)
1571public bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1574public bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node)
1581public void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken)
1589public void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList)
1596public void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1603public void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1611public void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members)
1620SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull)
1628public void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse)
1636public SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement)
1642public void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments)
1649public void GetPartsOfInterpolationExpression(SyntaxNode node,
1650out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken)
1658public void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList)
1665public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
1673public void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members)
1681public void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode identifier, out SyntaxNode expression)
1688public void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1697public void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer)
1705public void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default)
1713SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen)
1721public void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand)
1728public void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1740public SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node)
1743public SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node)
1746public SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node)
1749public SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node)
1752public SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node)
1755public SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node)
1758public SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node)
1761public SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (19)
71protected override SyntaxNode GetSemanticRootForSpeculation(ExpressionSyntax expression)
75SyntaxNode previousNode = null;
76SyntaxNode parentNodeToSpeculate = null;
77foreach (var node in expression.AncestorsAndSelf(ascendOutOfTrivia: false))
95public static bool CanSpeculateOnNode(SyntaxNode node)
104protected override void ValidateSpeculativeSemanticModel(SemanticModel speculativeSemanticModel, SyntaxNode nodeToSpeculate)
113protected override SemanticModel CreateSpeculativeSemanticModel(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel)
116public static SemanticModel CreateSpeculativeSemanticModelForNode(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel)
123public static SemanticModel CreateSpeculativeSemanticModelForNode(SyntaxNode nodeToSpeculate, SemanticModel semanticModel, int position, bool isInNamespaceOrTypeContext)
196SyntaxNode originalLambdaBody, replacedLambdaBody;
275SyntaxNode originalRoot)
295protected override bool ReplacementChangesSemanticsForNodeLanguageSpecific(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode previousOriginalNode, SyntaxNode previousReplacedNode)
580protected override bool ExpressionMightReferenceMember(SyntaxNode node)
662protected override bool IsParenthesizedExpression(SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (23)
40public override CodeGenerationDestination GetDestination(SyntaxNode node)
43protected override IComparer<SyntaxNode> GetMemberComparer()
46protected override IList<bool>? GetAvailableInsertionIndices(SyntaxNode destination, CancellationToken cancellationToken)
311var finalMember = editor.GetChangedRoot();
341protected override TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> members)
375var attributeSyntaxToRemove = attributeToRemove.ApplicationSyntaxReference.GetSyntax(cancellationToken);
381SyntaxNode attributeToRemove,
441SyntaxNode attributeToRemove,
477IEnumerable<SyntaxNode> statements,
529IEnumerable<SyntaxNode> statements,
531CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
568TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, BaseMethodDeclarationSyntax baseMethodDeclaration) where TDeclarationNode : SyntaxNode
589TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode
610TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, AnonymousFunctionExpressionSyntax anonymousFunctionSyntax) where TDeclarationNode : SyntaxNode
634public override SyntaxNode CreateEventDeclaration(
640public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
648public override SyntaxNode? CreateMethodDeclaration(
697public override SyntaxNode CreatePropertyDeclaration(
704public override SyntaxNode CreateNamedTypeDeclaration(
710public override SyntaxNode CreateNamespaceDeclaration(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (27)
40protected override ImmutableArray<SyntaxNode> GetGlobalImports(Compilation compilation, SyntaxGenerator generator)
43protected override SyntaxNode? GetAlias(UsingDirectiveSyntax usingOrAlias)
49protected override SyntaxNode Rewrite(
54SyntaxNode externContainer,
55SyntaxNode usingContainer,
56SyntaxNode staticUsingContainer,
57SyntaxNode aliasContainer,
59SyntaxNode root,
67var newRoot = rewriter.Visit(root);
71protected override SyntaxList<UsingDirectiveSyntax> GetUsingsAndAliases(SyntaxNode node)
79protected override SyntaxList<ExternAliasDirectiveSyntax> GetExterns(SyntaxNode node)
87protected override bool IsEquivalentImport(SyntaxNode a, SyntaxNode b)
94private readonly SyntaxNode _externContainer;
95private readonly SyntaxNode _usingContainer;
96private readonly SyntaxNode _aliasContainer;
97private readonly SyntaxNode _staticUsingContainer;
108SyntaxNode externContainer,
109SyntaxNode usingContainer,
110SyntaxNode aliasContainer,
111SyntaxNode staticUsingContainer,
128public override SyntaxNode? Visit(SyntaxNode? node)
131public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
134public override SyntaxNode? VisitFileScopedNamespaceDeclaration(FileScopedNamespaceDeclarationSyntax node)
137private SyntaxNode VisitBaseNamespaceDeclaration(
171public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (68)
54public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst)
61public override SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer)
64public override SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
67internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode? type, SyntaxToken name, SyntaxNode? expression)
79public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
82public override SyntaxNode MemberBindingExpression(SyntaxNode name)
85public override SyntaxNode RefExpression(SyntaxNode expression)
88public override SyntaxNode AddParentheses(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
91internal static SyntaxNode Parenthesize(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
99public override SyntaxNode YieldReturnStatement(SyntaxNode expression)
108public override SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
111public override SyntaxNode InterpolatedStringText(SyntaxToken textToken)
121public override SyntaxNode Interpolation(SyntaxNode syntaxNode)
124public override SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment)
127public override SyntaxNode InterpolationFormatClause(string format)
132public override SyntaxNode TypeParameterList(IEnumerable<string> typeParameterNames)
150public override SyntaxNode Type(ITypeSymbol typeSymbol, bool typeContext)
153public override SyntaxNode NegateEquality(SyntaxGenerator generator, SyntaxNode binaryExpression, SyntaxNode left, BinaryOperatorKind negatedKind, SyntaxNode right)
161public override SyntaxNode IsNotTypeExpression(SyntaxNode expression, SyntaxNode type)
169public override SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isKeyword, SyntaxNode pattern)
175public override SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right)
178public override SyntaxNode ConstantPattern(SyntaxNode expression)
181public override SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name)
186public override SyntaxNode LessThanRelationalPattern(SyntaxNode expression)
189public override SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression)
192public override SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression)
195public override SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression)
198public override SyntaxNode NotPattern(SyntaxNode pattern)
201public override SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right)
204public override SyntaxNode ParenthesizedPattern(SyntaxNode pattern)
207public override SyntaxNode TypePattern(SyntaxNode type)
210public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern)
AddImport\AbstractAddImportFeatureService.cs (31)
32where TSimpleNameSyntax : SyntaxNode
40protected abstract bool CanAddImport(SyntaxNode node, bool allowInHiddenRegions, CancellationToken cancellationToken);
41protected abstract bool CanAddImportForMethod(string diagnosticId, ISyntaxFacts syntaxFacts, SyntaxNode node, out TSimpleNameSyntax nameNode);
42protected abstract bool CanAddImportForNamespace(string diagnosticId, SyntaxNode node, out TSimpleNameSyntax nameNode);
43protected abstract bool CanAddImportForDeconstruct(string diagnosticId, SyntaxNode node);
44protected abstract bool CanAddImportForGetAwaiter(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node);
45protected abstract bool CanAddImportForGetEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node);
46protected abstract bool CanAddImportForGetAsyncEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node);
47protected abstract bool CanAddImportForQuery(string diagnosticId, SyntaxNode node);
48protected abstract bool CanAddImportForType(string diagnosticId, SyntaxNode node, out TSimpleNameSyntax nameNode);
50protected abstract ISet<INamespaceSymbol> GetImportNamespacesInScope(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
51protected abstract ITypeSymbol GetDeconstructInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
52protected abstract ITypeSymbol GetQueryClauseInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
53protected abstract bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken);
55protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, INamespaceOrTypeSymbol symbol, Document document, AddImportPlacementOptions options, CancellationToken cancellationToken);
56protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, IReadOnlyList<string> nameSpaceParts, Document document, AddImportPlacementOptions options, CancellationToken cancellationToken);
58protected abstract bool IsAddMethodContext(SyntaxNode node, SemanticModel semanticModel);
61protected abstract (string description, bool hasExistingImport) GetDescription(Document document, AddImportPlacementOptions options, INamespaceOrTypeSymbol symbol, SemanticModel semanticModel, SyntaxNode root, CancellationToken cancellationToken);
129Document document, SemanticModel semanticModel, string diagnosticId, SyntaxNode node, int maxResults, ISymbolSearchService symbolSearchService,
623private static ITypeSymbol? GetAwaitInfo(SemanticModel semanticModel, ISyntaxFacts syntaxFactsService, SyntaxNode node)
625var awaitExpression = FirstAwaitExpressionAncestor(syntaxFactsService, node);
630var innerExpression = syntaxFactsService.GetExpressionOfAwaitExpression(awaitExpression);
635private static ITypeSymbol? GetCollectionExpressionType(SemanticModel semanticModel, ISyntaxFacts syntaxFactsService, SyntaxNode node)
637var collectionExpression = FirstForeachCollectionExpressionAncestor(syntaxFactsService, node);
647protected static bool AncestorOrSelfIsAwaitExpression(ISyntaxFacts syntaxFactsService, SyntaxNode node)
650private static SyntaxNode? FirstAwaitExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node)
651=> node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFacts>((n, syntaxFactsService) => syntaxFactsService.IsAwaitExpression(n), syntaxFactsService);
653private static SyntaxNode? FirstForeachCollectionExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node)
654=> node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFacts>((n, syntaxFactsService) => syntaxFactsService.IsExpressionOfForeach(n), syntaxFactsService);
ChangeSignature\AbstractChangeSignatureService.cs (40)
47public abstract SyntaxNode? FindNodeToUpdate(Document document, SyntaxNode node);
52public abstract Task<SyntaxNode> ChangeSignatureAsync(
55SyntaxNode potentiallyUpdatedNode,
56SyntaxNode originalNode,
62protected abstract T TransferLeadingWhitespaceTrivia<T>(T newArgument, SyntaxNode oldArgument) where T : SyntaxNode;
71where TArgumentSyntax : SyntaxNode;
74where TArgumentSyntax : SyntaxNode;
172var syntax = await reference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
255var nodesToUpdate = new Dictionary<DocumentId, List<SyntaxNode>>();
256var definitionToUse = new Dictionary<SyntaxNode, ISymbol>();
337if (!TryGetNodeWithEditableSignatureOrAttributes(def, currentSolution, out var nodeToUpdate, out var documentId))
361if (!TryGetNodeWithEditableSignatureOrAttributes(location.Location, currentSolution, out var nodeToUpdate2, out var documentId2))
377var updatedRoots = new Dictionary<DocumentId, SyntaxNode>();
401var annotatedNodes = newRoot.GetAnnotatedNodes<SyntaxNode>(syntaxAnnotation: changeSignatureFormattingAnnotation);
404var formattedRoot = Formatter.Format(
416var changedDocuments = await ProducerConsumer<(DocumentId documentId, SyntaxNode newRoot)>.RunParallelAsync(
443private static void AddUpdatableNodeToDictionaries(Dictionary<DocumentId, List<SyntaxNode>> nodesToUpdate, DocumentId documentId, SyntaxNode nodeToUpdate, Dictionary<SyntaxNode, ISymbol> definitionToUse, ISymbol symbolWithSemanticParameters)
454private static bool TryGetNodeWithEditableSignatureOrAttributes(Location location, Solution solution, out SyntaxNode nodeToUpdate, out DocumentId documentId)
460var root = tree.GetRoot();
461var node = root.FindNode(location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);
648where TNode : SyntaxNode
681Func<AddedParameter, T> createNewParameterMethod) where T : SyntaxNode
744protected ImmutableArray<SyntaxToken> GetSeparators<T>(SeparatedSyntaxList<T> arguments, int numSeparatorsToSkip) where T : SyntaxNode
772where TArgumentSyntax : SyntaxNode
811var expression = await GenerateInferredCallsiteExpressionAsync(
916private async Task<SyntaxNode> GenerateInferredCallsiteExpressionAsync(
971protected ImmutableArray<SyntaxTrivia> GetPermutedDocCommentTrivia(SyntaxNode node, ImmutableArray<SyntaxNode> permutedParamNodes, LanguageServices services, LineFormattingOptions options)
986var structuredTrivia = trivia.GetStructure();
993var updatedNodeList = ArrayBuilder<SyntaxNode>.GetInstance();
997var content = structuredContent[i];
1016var newDocComments = Generator.DocumentationCommentTriviaWithUpdatedContent(trivia, updatedNodeList.ToImmutableAndFree());
1022using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var extraNodeList);
1031var extraDocComments = Generator.DocumentationCommentTrivia(
1043protected static bool IsParamsArrayExpandedHelper(ISymbol symbol, int argumentCount, bool lastArgumentIsNamed, SemanticModel semanticModel, SyntaxNode lastArgumentExpression, CancellationToken cancellationToken)
1071protected static int GetParameterIndexFromInvocationArgument(SyntaxNode argument, Document document, SemanticModel semanticModel, CancellationToken cancellationToken)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (21)
47protected abstract SyntaxTriviaList CreatePragmaDisableDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken);
48protected abstract SyntaxTriviaList CreatePragmaRestoreDirectiveTrivia(Diagnostic diagnostic, Func<SyntaxNode, CancellationToken, SyntaxNode> formatNode, bool needsLeadingEndOfLine, bool needsTrailingEndOfLine, CancellationToken cancellationToken);
50protected abstract SyntaxNode AddGlobalSuppressMessageAttribute(
51SyntaxNode newRoot,
60protected abstract SyntaxNode AddLocalSuppressMessageAttribute(
61SyntaxNode targetNode, ISymbol targetSymbol, INamedTypeSymbol suppressMessageAttribute, Diagnostic diagnostic);
65protected abstract bool IsAttributeListWithAssemblyAttributes(SyntaxNode node);
68protected abstract bool IsSingleAttributeInAttributeList(SyntaxNode attribute);
92protected abstract SyntaxNode GetContainingStatement(SyntaxToken token);
95protected SyntaxToken GetAdjustedTokenForPragmaDisable(SyntaxToken token, SyntaxNode root, TextLineCollection lines)
97var containingStatement = GetContainingStatement(token);
117private SyntaxToken GetAdjustedTokenForPragmaRestore(SyntaxToken token, SyntaxNode root, TextLineCollection lines, int indexOfLine)
119var containingStatement = GetContainingStatement(token);
261public SyntaxNode NodeWithTokens { get; set; }
262public SyntaxNode TargetMemberNode { get; set; }
274var root = await syntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
288var nodeWithTokens = GetNodeWithTokens(startToken, endToken, root);
344internal SyntaxNode GetNodeWithTokens(SyntaxToken startToken, SyntaxToken endToken, SyntaxNode root)
CodeLens\CodeLensReferencesService.cs (8)
42private static async Task<T?> FindAsync<T>(Solution solution, DocumentId documentId, SyntaxNode syntaxNode,
89public async Task<ReferenceCount?> GetReferenceCountAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, int maxSearchResults, CancellationToken cancellationToken)
120var node = GetEnclosingCodeElementNode(document, token, langServices, cancellationToken);
170private static SyntaxNode GetEnclosingCodeElementNode(Document document, SyntaxToken token, ICodeLensDisplayInfoService langServices, CancellationToken cancellationToken)
174var node = token.Parent;
202public async Task<ImmutableArray<ReferenceLocationDescriptor>?> FindReferenceLocationsAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, CancellationToken cancellationToken)
259public Task<ImmutableArray<ReferenceMethodDescriptor>?> FindReferenceMethodsAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode, CancellationToken cancellationToken)
275public async Task<string> GetFullyQualifiedNameAsync(Solution solution, DocumentId documentId, SyntaxNode syntaxNode,
CodeLens\ICodeLensReferencesService.cs (4)
23Task<ReferenceCount?> GetReferenceCountAsync(Solution solution, DocumentId documentId, SyntaxNode? syntaxNode, int maxSearchResults, CancellationToken cancellationToken);
28Task<ImmutableArray<ReferenceLocationDescriptor>?> FindReferenceLocationsAsync(Solution solution, DocumentId documentId, SyntaxNode? syntaxNode, CancellationToken cancellationToken);
33Task<ImmutableArray<ReferenceMethodDescriptor>?> FindReferenceMethodsAsync(Solution solution, DocumentId documentId, SyntaxNode? syntaxNode, CancellationToken cancellationToken);
38Task<string?> GetFullyQualifiedNameAsync(Solution solution, DocumentId documentId, SyntaxNode? syntaxNode, CancellationToken cancellationToken);
CodeRefactorings\CodeRefactoringContextExtensions.cs (12)
40public static Task<TSyntaxNode?> TryGetRelevantNodeAsync<TSyntaxNode>(this CodeRefactoringContext context) where TSyntaxNode : SyntaxNode
43public static async Task<TSyntaxNode?> TryGetRelevantNodeAsync<TSyntaxNode>(this CodeRefactoringContext context, bool allowEmptyNode) where TSyntaxNode : SyntaxNode
49public static Task<ImmutableArray<TSyntaxNode>> GetRelevantNodesAsync<TSyntaxNode>(this CodeRefactoringContext context) where TSyntaxNode : SyntaxNode
52public static async Task<ImmutableArray<TSyntaxNode>> GetRelevantNodesAsync<TSyntaxNode>(this CodeRefactoringContext context, bool allowEmptyNodes) where TSyntaxNode : SyntaxNode
58public static async Task<TSyntaxNode?> TryGetRelevantNodeAsync<TSyntaxNode>(this Document document, TextSpan span, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
64public static TSyntaxNode? TryGetRelevantNode<TSyntaxNode>(this ParsedDocument document, TextSpan span, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
67public static TSyntaxNode? TryGetRelevantNode<TSyntaxNode>(this ParsedDocument document, TextSpan span, bool allowEmptyNode, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
75this Document document, TextSpan span, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
81this Document document, TextSpan span, bool allowEmptyNodes, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
88this ParsedDocument document, TextSpan span, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
92this ParsedDocument document, TextSpan span, bool allowEmptyNodes, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
101this ParsedDocument document, TextSpan span, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
CodeRefactorings\SyncNamespace\AbstractChangeNamespaceService.cs (45)
39public abstract Task<bool> CanChangeNamespaceAsync(Document document, SyntaxNode container, CancellationToken cancellationToken);
41public abstract Task<Solution> ChangeNamespaceAsync(Document document, SyntaxNode container, string targetNamespace, CancellationToken cancellationToken);
57public abstract bool TryGetReplacementReferenceSyntax(SyntaxNode reference, ImmutableArray<string> newNamespaceParts, ISyntaxFactsService syntaxFacts, [NotNullWhen(returnValue: true)] out SyntaxNode? old, [NotNullWhen(returnValue: true)] out SyntaxNode? @new);
62where TNamespaceDeclarationSyntax : SyntaxNode
63where TCompilationUnitSyntax : SyntaxNode
64where TMemberDeclarationSyntax : SyntaxNode
80protected abstract SyntaxList<TMemberDeclarationSyntax> GetMemberDeclarationsInContainer(SyntaxNode compilationUnitOrNamespaceDecl);
82protected abstract Task<SyntaxNode?> TryGetApplicableContainerFromSpanAsync(Document document, TextSpan span, CancellationToken cancellationToken);
84protected abstract string GetDeclaredNamespace(SyntaxNode container);
88/// <see cref="IChangeNamespaceService.CanChangeNamespaceAsync(Document, SyntaxNode, CancellationToken)"/>
95protected abstract Task<ImmutableArray<(DocumentId id, SyntaxNode container)>> GetValidContainersFromAllLinkedDocumentsAsync(Document document, SyntaxNode container, CancellationToken cancellationToken);
97private static bool IsValidContainer(SyntaxNode container)
103public override async Task<bool> CanChangeNamespaceAsync(Document document, SyntaxNode container, CancellationToken cancellationToken)
157var namespaceToRename = namespaces[i];
163static async Task<ImmutableArray<SyntaxNode>> GetTopLevelNamespacesAsync(Document document, CancellationToken cancellationToken)
177SyntaxNode container,
267protected async Task<ImmutableArray<(DocumentId, SyntaxNode)>> TryGetApplicableContainersFromAllDocumentsAsync(
279using var _1 = ArrayBuilder<(DocumentId, SyntaxNode)>.GetInstance(ids.Length, out var containers);
310protected static async Task<Solution> AnnotateContainersAsync(Solution solution, ImmutableArray<(DocumentId, SyntaxNode)> containers, CancellationToken cancellationToken)
323Document document, SyntaxNode container, CancellationToken cancellationToken)
367SyntaxNode container,
400private static ImmutableArray<SyntaxNode> CreateImports(Document document, ImmutableArray<string> names, bool withFormatterAnnotation)
403var builder = new FixedSizeArrayBuilder<SyntaxNode>(names.Length);
410private static SyntaxNode CreateImport(SyntaxGenerator syntaxGenerator, string name, bool withFormatterAnnotation)
412var import = syntaxGenerator.NamespaceImportDeclaration(name);
486var fixedDocuments = await ProducerConsumer<(DocumentId documentId, SyntaxNode newRoot)>.RunParallelAsync(
587ImmutableArray<SyntaxNode> containersToAddImports;
680private static async Task<(Document, ImmutableArray<SyntaxNode>)> FixReferencesAsync(
689var root = editor.OriginalRoot;
690using var _ = PooledHashSet<SyntaxNode>.GetInstance(out var containers);
723var refNode = root.FindNode(refLoc.ReferenceLocation.Location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);
729refNode, newNamespaceParts, syntaxFacts, out var oldNode, out var newNode))
738var container = addImportService.GetImportContainer(root, refNode, dummyImport, addImportsOptions);
774var changedDocuments = await ProducerConsumer<(DocumentId documentId, SyntaxNode newRoot)>.RunParallelAsync(
791IEnumerable<SyntaxNode> importsToRemove,
812ImmutableArray<SyntaxNode> containers,
827foreach (var container in containers)
832var contextLocation = container is TNamespaceDeclarationSyntax
852private sealed class SyntaxNodeSpanStartComparer : IComparer<SyntaxNode>
860public int Compare(SyntaxNode? x, SyntaxNode? y)
ConvertForEachToFor\AbstractConvertForEachToForCodeRefactoringProvider.cs (16)
28where TStatementSyntax : SyntaxNode
43protected abstract (SyntaxNode start, SyntaxNode end) GetForEachBody(TForEachStatement foreachStatement);
86ISemanticFactsService semanticFacts, SemanticModel model, SyntaxNode location, string baseName, CancellationToken cancellationToken)
89protected static SyntaxNode GetCollectionVariableName(
91ForEachInfo foreachInfo, SyntaxNode foreachCollectionExpression, CancellationToken cancellationToken)
105SyntaxNode type, SyntaxNode foreachCollectionExpression, SyntaxNode collectionVariable)
119var expression = foreachCollectionExpression.WithoutAnnotations(SimplificationHelpers.DoNotSimplifyAnnotation);
120var collectionStatement = generator.LocalDeclarationStatement(
132SyntaxGenerator generator, SyntaxNode type, SyntaxToken foreachVariable,
133ITypeSymbol castType, SyntaxNode collectionVariable, SyntaxToken indexVariable)
135var memberAccess = generator.ElementAccessExpression(
143var localDecl = generator.LocalDeclarationStatement(
424var newRoot = editor.GetChangedRoot();
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.cs (3)
45if (!ShouldOfferRefactoring(ifStatement, semanticModel, syntaxFactsService, out var analyzer, out var sections, out var target))
75[NotNullWhen(true)] out SyntaxNode? target)
248if (!ShouldOfferRefactoring(ifStatement, semanticModel, syntaxFactsService, out var analyzer, out var sections, out var target))
ConvertToInterpolatedString\AbstractConvertConcatenationToInterpolatedStringRefactoringProvider.cs (22)
25where TExpressionSyntax : SyntaxNode
51var declarator = top.FirstAncestorOrSelf<SyntaxNode>(syntaxFacts.IsVariableDeclarator);
69using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var pieces);
110Document document, SyntaxNode top, bool isVerbatimStringLiteral, ImmutableArray<SyntaxNode> pieces, CancellationToken cancellationToken)
113var interpolatedString = await CreateInterpolatedStringAsync(
119protected async Task<SyntaxNode> CreateInterpolatedStringAsync(
120Document document, bool isVerbatimStringLiteral, ImmutableArray<SyntaxNode> pieces, CancellationToken cancellationToken)
134using var _ = ArrayBuilder<SyntaxNode>.GetInstance(pieces.Length, out var content);
136foreach (var piece in pieces)
157var newText = ConcatenateTextToTextNode(generator, existingInterpolatedStringTextNode, textWithoutQuotes, valueTextWithEscapedBraces);
183var newText = ConcatenateTextToTextNode(generator, content.Last(), contentPart.GetFirstToken().Text, contentPart.GetFirstToken().ValueText);
198var converted = TryRemoveToString(piece);
214SyntaxNode TryRemoveToString(SyntaxNode piece)
244private static SyntaxNode ConcatenateTextToTextNode(SyntaxGenerator generator, SyntaxNode interpolatedStringTextNode, string textWithoutQuotes, string value)
255ArrayBuilder<SyntaxNode> pieces,
256SyntaxNode node,
266syntaxFacts.GetPartsOfBinaryExpression(node, out var left, out var right);
273ISyntaxFactsService syntaxFacts, SyntaxNode? expression,
ConvertTupleToStruct\AbstractConvertTupleToStructCodeRefactoringProvider.cs (32)
48where TExpressionSyntax : SyntaxNode
54where TArgumentSyntax : SyntaxNode
55where TTupleTypeSyntax : SyntaxNode
56where TTypeBlockSyntax : SyntaxNode
57where TNamespaceDeclarationSyntax : SyntaxNode
121SyntaxNode tupleExprOrTypeNode,
127var containingMember = GetContainingMember(context.Document, tupleExprOrTypeNode);
164private static SyntaxNode? GetContainingMember(Document document, SyntaxNode tupleExprOrTypeNode)
167return tupleExprOrTypeNode.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>((node, syntaxFacts) => syntaxFacts.IsMethodLevelMember(node), syntaxFacts);
183private static async Task<(SyntaxNode, INamedTypeSymbol)> TryGetTupleInfoAsync(
198var expressionOrType =
199parsedDocument.TryGetRelevantNode<TTupleTypeSyntax>(span, cancellationToken) as SyntaxNode ??
327SyntaxNode tupleExprOrTypeNode, INamedTypeSymbol tupleType,
419Document document, SyntaxNode tupleExprOrTypeNode,
518Document startingDocument, SyntaxNode tupleExprOrTypeNode, CancellationToken cancellationToken)
543Document document, SyntaxNode tupleExprOrTypeNode)
545var containingMember = GetContainingMember(document, tupleExprOrTypeNode);
553Document document, SyntaxNode tupleExprOrTypeNode, INamedTypeSymbol namedTypeSymbol,
591var newRoot = editor.GetChangedRoot();
615SyntaxNode startingNode, INamedTypeSymbol tupleType, TNameSyntax fullyQualifiedStructName,
617SyntaxNode containerToUpdate, CancellationToken cancellationToken)
635SyntaxNode startingNode, INamedTypeSymbol tupleType, TNameSyntax qualifiedTypeName,
637SyntaxNode containingMember, CancellationToken cancellationToken)
691TNameSyntax qualifiedTypeName, SyntaxNode startingCreationNode, TTupleExpressionSyntax childCreation,
748Document document, SyntaxEditor editor, SyntaxNode startingNode,
751SyntaxNode containingMember, CancellationToken cancellationToken)
781TNameSyntax qualifiedTypeName, SyntaxNode startingNode, TTupleTypeSyntax childTupleType)
885var valueNode = generator.IdentifierName(ValueName);
886var arguments = tupleType.TupleElements.SelectAsArray<IFieldSymbol, SyntaxNode>(
890var convertToTupleStatement = generator.ReturnStatement(
893var convertToStructStatement = generator.ReturnStatement(
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (205)
72private readonly Action<SyntaxNode>? _testFaultInjector;
74protected AbstractEditAndContinueAnalyzer(Action<SyntaxNode>? testFaultInjector)
95internal abstract bool TryFindMemberDeclaration(SyntaxNode? root, SyntaxNode node, TextSpan activeSpan, out OneOrMany<SyntaxNode> declarations);
110internal abstract MemberBody? TryGetDeclarationBody(SyntaxNode node, ISymbol? symbol);
115internal abstract bool IsDeclarationWithSharedBody(SyntaxNode declaration, ISymbol member);
122protected abstract LambdaBody? FindEnclosingLambdaBody(SyntaxNode encompassingAncestor, SyntaxNode node);
124protected abstract Match<SyntaxNode> ComputeTopLevelMatch(SyntaxNode oldCompilationUnit, SyntaxNode newCompilationUnit);
125protected abstract BidirectionalMap<SyntaxNode>? ComputeParameterMap(SyntaxNode oldDeclaration, SyntaxNode newDeclaration);
126protected abstract IEnumerable<SequenceEdit> GetSyntaxSequenceEdits(ImmutableArray<SyntaxNode> oldNodes, ImmutableArray<SyntaxNode> newNodes);
134/// In case there are multiple breakpoint spans starting at the <see cref="SyntaxNode.SpanStart"/> of the <paramref name="node"/>,
145protected abstract bool TryGetActiveSpan(SyntaxNode node, int statementPart, int minLength, out TextSpan span);
155protected abstract IEnumerable<(SyntaxNode statement, int statementPart)> EnumerateNearStatements(SyntaxNode statement);
157protected abstract bool StatementLabelEquals(SyntaxNode node1, SyntaxNode node2);
166protected abstract bool AreEquivalentActiveStatements(SyntaxNode oldStatement, SyntaxNode newStatement, int statementPart);
176protected abstract bool IsNamespaceDeclaration(SyntaxNode node);
177protected abstract bool IsCompilationUnitWithGlobalStatements(SyntaxNode node);
178protected abstract bool IsGlobalStatement(SyntaxNode node);
183protected abstract IEnumerable<SyntaxNode> GetTopLevelTypeDeclarations(SyntaxNode compilationUnit);
193SyntaxNode? oldNode,
195SyntaxNode? newNode,
199Match<SyntaxNode> topMatch,
200IReadOnlyDictionary<SyntaxNode, EditKind> editMap,
209SyntaxNode? oldNode,
210SyntaxNode? newNode,
217SyntaxNode? oldNode,
218SyntaxNode? newNode,
221Match<SyntaxNode> topMatch,
222IReadOnlyDictionary<SyntaxNode, EditKind> editMap,
264protected abstract IEnumerable<SyntaxNode> GetVariableUseSites(IEnumerable<SyntaxNode> roots, ISymbol localOrParameter, SemanticModel model, CancellationToken cancellationToken);
269protected abstract TextSpan? TryGetDiagnosticSpan(SyntaxNode node, EditKind editKind);
271internal TextSpan GetDiagnosticSpan(SyntaxNode node, EditKind editKind)
274protected virtual TextSpan GetBodyDiagnosticSpan(SyntaxNode node, EditKind editKind)
276var current = node.Parent;
294internal abstract TextSpan GetLambdaParameterDiagnosticSpan(SyntaxNode lambda, int ordinal);
316internal string GetDisplayName(SyntaxNode node, EditKind editKind = EditKind.Update)
367protected virtual string GetBodyDisplayName(SyntaxNode node, EditKind editKind = EditKind.Update)
369var current = node.Parent;
397protected abstract string? TryGetDisplayName(SyntaxNode node, EditKind editKind);
399protected virtual string GetSuspensionPointDisplayName(SyntaxNode node, EditKind editKind)
405protected abstract List<SyntaxNode> GetExceptionHandlingAncestors(SyntaxNode node, SyntaxNode root, bool isNonLeaf);
406protected abstract TextSpan GetExceptionHandlingRegion(SyntaxNode node, out bool coversAllChildren);
408internal abstract void ReportTopLevelSyntacticRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, Match<SyntaxNode> match, Edit<SyntaxNode> edit, Dictionary<SyntaxNode, EditKind> editMap);
409internal abstract void ReportEnclosingExceptionHandlingRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, IEnumerable<Edit<SyntaxNode>> exceptionHandlingEdits, SyntaxNode oldStatement, TextSpan newStatementSpan);
411internal abstract bool HasUnsupportedOperation(IEnumerable<SyntaxNode> newNodes, [NotNullWhen(true)] out SyntaxNode? unsupportedNode, out RudeEditKind rudeEdit);
415if (HasUnsupportedOperation(body.GetDescendantNodes(IsNotLambda), out var unsupportedNode, out var rudeEdit))
426IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap,
427SyntaxNode oldActiveStatement,
430SyntaxNode newActiveStatement,
436internal abstract void ReportInsertedMemberSymbolRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, ISymbol newSymbol, SyntaxNode newNode, bool insertingIntoExistingContainingType);
437internal abstract void ReportStateMachineSuspensionPointRudeEdits(DiagnosticContext diagnosticContext, SyntaxNode oldNode, SyntaxNode newNode);
439internal abstract Func<SyntaxNode, bool> IsLambda { get; }
440internal abstract Func<SyntaxNode, bool> IsNotLambda { get; }
442internal abstract bool IsInterfaceDeclaration(SyntaxNode node);
443internal abstract bool IsRecordDeclaration(SyntaxNode node);
448internal abstract bool IsNestedFunction(SyntaxNode node);
450internal abstract bool IsLocalFunction(SyntaxNode node);
451internal abstract bool IsGenericLocalFunction(SyntaxNode node);
452internal abstract bool IsClosureScope(SyntaxNode node);
453internal abstract SyntaxNode GetCapturedParameterScope(SyntaxNode declaringMethodOrLambda);
454internal abstract IMethodSymbol GetLambdaExpressionSymbol(SemanticModel model, SyntaxNode lambdaExpression, CancellationToken cancellationToken);
455internal abstract SyntaxNode? GetContainingQueryExpression(SyntaxNode node);
456internal abstract bool QueryClauseLambdasTypeEquivalent(SemanticModel oldModel, SyntaxNode oldNode, SemanticModel newModel, SyntaxNode newNode, CancellationToken cancellationToken);
474internal abstract bool TryGetLambdaBodies(SyntaxNode node, [NotNullWhen(true)] out LambdaBody? body1, out LambdaBody? body2);
476internal abstract bool IsStateMachineMethod(SyntaxNode declaration);
482internal abstract SyntaxNode? TryGetContainingTypeDeclaration(SyntaxNode node);
488internal abstract bool IsDeclarationWithInitializer(SyntaxNode declaration);
498internal abstract bool IsPrimaryConstructorDeclaration(SyntaxNode declaration);
507internal abstract SyntaxNode EmptyCompilationUnit { get; }
538SyntaxNode oldRoot;
562var newRoot = await newTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
630using var _3 = ArrayBuilder<(SyntaxNode OldNode, SyntaxNode NewNode, TextSpan DiagnosticSpan)>.GetInstance(out var triviaEdits);
736private void ReportTopLevelSyntacticRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, EditScript<SyntaxNode> syntacticEdits, Dictionary<SyntaxNode, EditKind> editMap)
744internal Dictionary<SyntaxNode, EditKind> BuildEditMap(EditScript<SyntaxNode> editScript)
746var map = new Dictionary<SyntaxNode, EditKind>(editScript.Edits.Length);
783Match<SyntaxNode> topMatch,
813var hasPartner = topMatch.TryGetNewNode(oldMember, out var newMember);
827SyntaxNode? newStatement = null;
888internal readonly struct ActiveNode(int activeStatementIndex, SyntaxNode oldNode, LambdaBody? enclosingLambdaBody, int statementPart, SyntaxNode? newTrackedNode)
891public readonly SyntaxNode OldNode = oldNode;
892public readonly SyntaxNode? NewTrackedNode = newTrackedNode;
929SyntaxNode? oldDeclaration,
930SyntaxNode? newDeclaration,
940Match<SyntaxNode> topMatch,
1016var oldStatementSyntax = oldMemberBody.FindStatement(oldStatementSpan, out var statementPart);
1033SyntaxNode? trackedNode = null;
1168SyntaxNode? newStatementSyntax;
1307private static bool TryGetTrackedStatement(ImmutableArray<ActiveStatementLineSpan> activeStatementSpans, ActiveStatementId id, SourceText text, MemberBody body, [NotNullWhen(true)] out SyntaxNode? trackedStatement, out int trackedStatementPart)
1352IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap,
1353SyntaxNode oldStatementSyntax,
1354SyntaxNode oldEncompassingAncestor,
1355SyntaxNode? newStatementSyntax,
1356SyntaxNode newEncompassingAncestor,
1381var edits = new MapBasedLongestCommonSubsequence<SyntaxNode>(forwardMap).GetEdits(oldAncestors, newAncestors);
1401ArrayBuilder<(DeclarationBodyMap map, SyntaxNode? oldLambda)>? lambdaBodyMaps = null;
1402SyntaxNode? currentOldLambda = null;
1418lambdaBodyMaps ??= ArrayBuilder<(DeclarationBodyMap, SyntaxNode?)>.GetInstance();
1452var map = new Dictionary<SyntaxNode, SyntaxNode>();
1453var additionalReverseMap = ImmutableDictionary.CreateBuilder<SyntaxNode, SyntaxNode>();
1558private static List<KeyValuePair<SyntaxNode, SyntaxNode>>? GetMatchingActiveNodes(IEnumerable<ActiveNode> activeNodes)
1561List<KeyValuePair<SyntaxNode, SyntaxNode>>? lazyKnownMatches = null;
1575public ActiveStatementExceptionRegions GetExceptionRegions(SyntaxNode root, TextSpan unmappedActiveStatementSpan, bool isNonLeaf, CancellationToken cancellationToken)
1577var node = root.FindToken(unmappedActiveStatementSpan.Start).Parent;
1584private ActiveStatementExceptionRegions GetExceptionRegions(List<SyntaxNode> exceptionHandlingAncestors, SyntaxTree tree, CancellationToken cancellationToken)
1617SyntaxNode oldEncompassingAncestor,
1618IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap,
1624var oldLambda = oldLambdaBody.GetLambda();
1640private TextSpan FindClosestActiveSpan(SyntaxNode statement, int statementPart)
1667internal TextSpan GetDeletedNodeActiveSpan(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode deletedNode)
1676if (forwardMap.TryGetValue(oldNode, out var newNode))
1685internal TextSpan GetDeletedDeclarationActiveSpan(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode deletedDeclaration)
1707internal TextSpan GetDeletedNodeDiagnosticSpan(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode deletedNode)
1717private static bool TryGetMatchingAncestor(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode? oldNode, [NotNullWhen(true)] out SyntaxNode? newAncestor)
1735protected static bool HasParentEdit(IReadOnlyDictionary<SyntaxNode, EditKind> editMap, Edit<SyntaxNode> edit)
1737SyntaxNode node;
1755protected static bool HasEdit(IReadOnlyDictionary<SyntaxNode, EditKind> editMap, SyntaxNode? node, EditKind editKind)
1767protected void AddAroundActiveStatementRudeDiagnostic(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode? oldNode, SyntaxNode? newNode, TextSpan newActiveStatementSpan)
1785protected void AddRudeTypeUpdateAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newNode, ITypeSymbol oldType, ITypeSymbol newType)
1794protected void AddRudeUpdateAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newNode)
1803protected void AddRudeInsertAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newNode)
1812protected void AddRudeDeleteAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldNode, TextSpan newActiveStatementSpan)
1823IReadOnlyDictionary<SyntaxNode, SyntaxNode> reverseMap,
1824SyntaxNode oldActiveStatement,
1825SyntaxNode oldEncompassingAncestor,
1827SyntaxNode newActiveStatement,
1828SyntaxNode newEncompassingAncestor,
1830Func<SyntaxNode, bool> nodeSelector,
1831Func<TSyntaxNode, OneOrMany<SyntaxNode>> getTypedNodes,
1835where TSyntaxNode : SyntaxNode
1867private void ReportRudeEditsAndInserts(List<SyntaxNode?>? oldNodes, List<SyntaxNode?> newNodes, ArrayBuilder<RudeEditDiagnostic> diagnostics)
1873var newNode = newNodes[i];
1893List<SyntaxNode?> oldNodes,
1895List<SyntaxNode?> newNodes,
1898IReadOnlyDictionary<SyntaxNode, SyntaxNode>? reverseMap,
1899Func<TSyntaxNode, OneOrMany<SyntaxNode>> getTypedNodes,
1903where TSyntaxNode : SyntaxNode
1909var newNode = newNodes[newIndex];
1915SyntaxNode? oldNode;
1939else if (reverseMap.TryGetValue(newNode, out var oldPartner) && comparer((TSyntaxNode)oldPartner, (TSyntaxNode)newNode))
1990private static int IndexOfEquivalent<TSyntaxNode>(SyntaxNode newNode, List<SyntaxNode?> oldNodes, int startIndex, Func<TSyntaxNode, TSyntaxNode, bool> comparer)
1991where TSyntaxNode : SyntaxNode
1995var oldNode = oldNodes[i];
2005private static List<SyntaxNode?>? GetAncestors(SyntaxNode? root, SyntaxNode node, Func<SyntaxNode, bool> nodeSelector)
2007List<SyntaxNode?>? list = null;
2008var current = node;
2039Match<SyntaxNode> topMatch,
2040IReadOnlyDictionary<SyntaxNode, EditKind> editMap,
2041[Out] ArrayBuilder<(SyntaxNode OldNode, SyntaxNode NewNode, TextSpan DiagnosticSpan)> triviaEdits,
2056using var _ = ArrayBuilder<(string filePath, int oldStartLine, int oldEndLine, int delta, SyntaxNode oldNode, SyntaxNode newNode)>.GetInstance(out var segments);
2480public readonly Dictionary<SyntaxNode, SyntaxMaps> ChangedDeclarations = [];
EditAndContinue\DeclarationBodyMap.cs (23)
15SpecializedCollections.EmptyReadOnlyDictionary<SyntaxNode, SyntaxNode>(),
16SpecializedCollections.EmptyReadOnlyDictionary<SyntaxNode, SyntaxNode>(),
17ImmutableDictionary<SyntaxNode, SyntaxNode>.Empty);
19public IReadOnlyDictionary<SyntaxNode, SyntaxNode> Forward { get; }
20public IReadOnlyDictionary<SyntaxNode, SyntaxNode> Reverse { get; }
22public ImmutableDictionary<SyntaxNode, SyntaxNode> AdditionalReverseMapping { get; }
25IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMatch,
26IReadOnlyDictionary<SyntaxNode, SyntaxNode> reverseMatch,
27ImmutableDictionary<SyntaxNode, SyntaxNode> additionalReverseMapping)
36public static DeclarationBodyMap FromMatch(Match<SyntaxNode> match)
37=> new(match.Matches, match.ReverseMatches, ImmutableDictionary<SyntaxNode, SyntaxNode>.Empty);
39public DeclarationBodyMap WithAdditionalMapping(SyntaxNode oldNode, SyntaxNode newNode)
EmbeddedLanguages\AbstractLanguageDetector.cs (5)
30protected abstract bool IsArgumentToWellKnownAPI(SyntaxToken token, SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken, out TOptions options);
37protected abstract bool TryGetOptions(SemanticModel semanticModel, ITypeSymbol exprType, SyntaxNode expr, CancellationToken cancellationToken, out TOptions options);
108SyntaxNode argument,
139protected static string? GetNameOfType(SyntaxNode? typeNode, ISyntaxFacts syntaxFacts)
153protected string? GetNameOfInvokedExpression(SyntaxNode invokedExpression)
EmbeddedLanguages\Json\LanguageServices\AbstractJsonDetectionAnalyzer.cs (1)
61SyntaxNode node,
EmbeddedLanguages\Json\LanguageServices\AbstractJsonDiagnosticAnalyzer.cs (1)
54SyntaxNode node,
ExtractMethod\MethodExtractor.cs (11)
30where TStatementSyntax : SyntaxNode
31where TExpressionSyntax : SyntaxNode
37protected abstract SyntaxNode ParseTypeName(string name);
39protected abstract SyntaxNode GetInsertionPointNode(AnalyzerResult analyzerResult, CancellationToken cancellationToken);
50Document document, SyntaxToken? invocationNameToken, SyntaxNode methodDefinition, CancellationToken cancellationToken);
115bool CanAddTo(Document document, SyntaxNode insertionPointNode, out OperationStatus status)
127var destination = insertionPointNode;
130var mappedPoint = insertionPointNode.RawKind == syntaxKinds.GlobalStatement
189SyntaxNode insertionPointNode,
244SyntaxNode contextNode,
263SemanticModel semanticModel, SyntaxNode contextNode, ITypeSymbol type)
ExtractMethod\SelectionValidator.cs (14)
26where TStatementSyntax : SyntaxNode
34public abstract IEnumerable<SyntaxNode> GetOuterReturnStatements(SyntaxNode commonRoot, IEnumerable<SyntaxNode> jumpsOutOfRegion);
35public abstract bool IsFinalSpanSemanticallyValidSpan(SyntaxNode node, TextSpan textSpan, IEnumerable<SyntaxNode> returnStatements, CancellationToken cancellationToken);
36public abstract bool ContainsNonReturnExitPointsStatements(IEnumerable<SyntaxNode> jumpsOutOfRegion);
39SemanticModel semanticModel, TextSpan textSpan, (SyntaxNode, SyntaxNode) range, CancellationToken cancellationToken)
85SyntaxNode root, TextSpan textSpan, CancellationToken cancellationToken) where T : SyntaxNode
145SyntaxNode root, TextSpan textSpan, CancellationToken cancellationToken) where T : SyntaxNode
187public SyntaxNode CommonRootFromOriginalSpan { get; set; }
GenerateEqualsAndGetHashCodeFromMembers\GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs (4)
199Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> selectedMembers,
239Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
256Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
293Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
GenerateType\AbstractGenerateTypeService.cs (12)
32where TExpressionSyntax : SyntaxNode
33where TTypeDeclarationSyntax : SyntaxNode
34where TArgumentSyntax : SyntaxNode
63Solution updatedSolution, SyntaxNode modifiedRoot, Document document, TSimpleNameSyntax simpleName, string includeUsingsOrImports, CancellationToken cancellationToken);
69public abstract Task<(INamespaceSymbol, INamespaceOrTypeSymbol, Location)> GetOrGenerateEnclosingNamespaceSymbolAsync(INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken);
73SyntaxNode node,
105SyntaxNode node,
143private static bool CanGenerateIntoContainingNamespace(SemanticDocument semanticDocument, SyntaxNode node, CancellationToken cancellationToken)
153.FirstOrDefault(node.GetAncestorsOrThis<SyntaxNode>().Contains);
162SyntaxNode node,
188IEnumerable<SyntaxNode> typeArguments,
201var argument = i < arguments.Count ? arguments[i] : null;
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (26)
40where TTypeDeclarationSyntax : SyntaxNode
41where TParameterSyntax : SyntaxNode
42where TStatementSyntax : SyntaxNode
43where TExpressionSyntax : SyntaxNode
45protected abstract SyntaxNode? TryGetLastStatement(IBlockOperation? blockStatement);
48protected abstract SyntaxNode? GetAccessorBody(IMethodSymbol accessor, CancellationToken cancellationToken);
49protected abstract SyntaxNode RemoveThrowNotImplemented(SyntaxNode propertySyntax);
53Document document, SyntaxNode functionDeclaration, IMethodSymbol method, IBlockOperation? blockStatementOpt,
54ImmutableArray<SyntaxNode> listOfParameterNodes, TextSpan parameterSpan,
64SyntaxNode constructorDeclaration,
109SyntaxNode constructorDeclaration,
160SyntaxNode constructorDeclaration,
194SyntaxNode constructorDeclaration,
243SyntaxNode functionDeclaration,
362SyntaxNode constructorDeclaration,
376var nodesToTrack = new List<SyntaxNode> { constructorDeclaration };
393var currentConstructorDeclaration = currentRoot.GetCurrentNode(constructorDeclaration);
426SyntaxNode constructorDeclaration,
489var withoutThrowNotImplemented = RemoveThrowNotImplemented(propertySyntax);
513SyntaxNode constructorDeclaration,
537var statementToAddAfter = TryGetStatementToAddInitializationAfter(parameter, blockStatement);
544SyntaxNode typeDeclaration, CancellationToken cancellationToken)
555var symbolSyntax = symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
577private SyntaxNode? TryGetStatementToAddInitializationAfter(
750using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var accessors);
InitializeParameter\AbstractInitializeParameterCodeRefactoringProvider.cs (19)
28where TTypeDeclarationSyntax : SyntaxNode
29where TParameterSyntax : SyntaxNode
30where TStatementSyntax : SyntaxNode
31where TExpressionSyntax : SyntaxNode
33protected abstract bool IsFunctionDeclaration(SyntaxNode node);
36protected abstract SyntaxNode GetBody(SyntaxNode functionDeclaration);
40SyntaxNode functionDeclaration,
43ImmutableArray<SyntaxNode> listOfParameterNodes,
51SyntaxNode functionDeclaration,
57SyntaxEditor editor, SyntaxNode functionDeclaration, bool returnsVoid,
58SyntaxNode? statementToAddAfter, TStatementSyntax statement);
71var functionDeclaration = selectedParameter.FirstAncestorOrSelf<SyntaxNode>(IsFunctionDeclaration);
110using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var listOfPotentiallyValidParametersNodes);
111foreach (var parameterNode in parameterNodes)
133SyntaxNode parameterNode,
145SyntaxNode functionDeclaration, SemanticModel semanticModel, ISyntaxFactsService syntaxFacts,
150var functionBody = GetBody(functionDeclaration);
IntroduceParameter\AbstractIntroduceParameterCodeRefactoringProvider.cs (15)
31where TExpressionSyntax : SyntaxNode
35where TArgumentSyntax : SyntaxNode
44protected abstract SyntaxNode GenerateExpressionFromOptionalParameter(IParameterSymbol parameterSymbol);
45protected abstract SyntaxNode UpdateArgumentListSyntax(SyntaxNode argumentList, SeparatedSyntaxList<TArgumentSyntax> arguments);
46protected abstract SyntaxNode? GetLocalDeclarationFromDeclarator(SyntaxNode variableDecl);
64var containingMethod = expression.FirstAncestorOrSelf<SyntaxNode>(node => generator.GetParameterListNode(node) is not null);
116private static bool IsValidExpression(SyntaxNode expression, ISyntaxFactsService syntaxFacts)
131var invalidNode = expression.FirstAncestorOrSelf<SyntaxNode>(node => syntaxFacts.IsAttributeArgument(node) || syntaxFacts.IsParameter(node));
141TExpressionSyntax expression, IMethodSymbol methodSymbol, SyntaxNode containingMethod,
202foreach (var variable in variablesInExpression)
238IMethodSymbol methodSymbol, SyntaxNode containingMethod, Dictionary<Document, List<TExpressionSyntax>> methodCallSites, bool allOccurrences, IntroduceParameterCodeActionKind selectedCodeAction,
245var changedRoots = await ProducerConsumer<(DocumentId documentId, SyntaxNode newRoot)>.RunParallelAsync(
IntroduceParameter\IntroduceParameterDocumentRewriter.cs (44)
28SyntaxNode containingMethod,
39private readonly SyntaxNode _containerMethod = containingMethod;
43public async Task<SyntaxNode> RewriteDocumentAsync(Compilation compilation, Document document, List<TExpressionSyntax> invocations, CancellationToken cancellationToken)
100private bool ShouldRemoveVariableDeclaratorContainingExpression([NotNullWhen(true)] out string? varDeclName, [NotNullWhen(true)] out SyntaxNode? localDeclaration)
102var declarator = _expression?.Parent?.Parent;
137var parameterList = _syntaxFacts.GetParameterList(_containerMethod);
219private async Task<SyntaxNode> ModifyDocumentInvocationsTrampolineOverloadAndIntroduceParameterAsync(Compilation compilation, Document currentDocument,
267var parameter = _generator.ParameterDeclaration(parameterName, _generator.TypeExpression(parameterType));
304SyntaxNode GenerateNewArgumentListSyntaxForTrampoline(Compilation compilation, SemanticModel invocationSemanticModel,
305Dictionary<IParameterSymbol, int> parameterToArgumentMap, SyntaxNode currentArgumentListSyntax,
306SyntaxNode argumentListSyntax, SyntaxNode invocation, ImmutableArray<IParameterSymbol> validParameters,
313var requiredArguments = new List<SyntaxNode>();
323var conditionalRoot = _syntaxFacts.GetRootConditionalAccessExpression(invocation);
325var newMethodInvocation = GenerateNewMethodInvocation(invocation, requiredArguments, newMethodIdentifier);
336var expressionsWithConditionalAccessors = conditionalRoot.ReplaceNode(invocation, newMethodInvocation);
351private SyntaxNode GenerateNewMethodInvocation(SyntaxNode invocation, List<SyntaxNode> arguments, string newMethodIdentifier)
353var methodName = _generator.IdentifierName(newMethodIdentifier);
357var receiverExpression = _syntaxFacts.GetExpressionOfMemberAccessExpression(fullExpression);
388private async Task<SyntaxNode> ExtractMethodAsync(ImmutableArray<IParameterSymbol> validParameters, string newMethodIdentifier, SyntaxGenerator generator, CancellationToken cancellationToken)
391var returnStatement = generator.ReturnStatement(_expression.WithoutTrivia());
393var newMethodDeclaration = await CreateMethodDeclarationAsync(returnStatement,
420private async Task<SyntaxNode> GenerateNewMethodOverloadAsync(int insertionIndex, SyntaxGenerator generator, CancellationToken cancellationToken)
427var memberName = _methodSymbol.IsGenericMethod
430var invocation = generator.InvocationExpression(memberName, arguments);
432var newStatement = _methodSymbol.ReturnsVoid
436var newMethodDeclaration = await CreateMethodDeclarationAsync(newStatement,
441private async Task<SyntaxNode> CreateMethodDeclarationAsync(SyntaxNode newStatement, ImmutableArray<IParameterSymbol>? validParameters,
481private async Task<SyntaxNode> ModifyDocumentInvocationsAndIntroduceParameterAsync(Compilation compilation, Document document, int insertionIndex,
528var parameter = _generator.ParameterDeclaration(name: parameterName, type:
544SeparatedSyntaxList<SyntaxNode> updatedInvocationArguments)
551var updatedInvocationArgument = updatedInvocationArguments[index];
552var argumentExpression = _syntaxFacts.GetExpressionOfArgument(updatedInvocationArgument);
553var parenthesizedArgumentExpression = editor.Generator.AddParentheses(argumentExpression, includeElasticTrivia: false);
558var generatedExpression = _service.GenerateExpressionFromOptionalParameter(mappedParameter);
559var parenthesizedGeneratedExpression = editor.Generator.AddParentheses(generatedExpression, includeElasticTrivia: false);
572SeparatedSyntaxList<TArgumentSyntax> invocationArguments, SyntaxNode newArgumentExpression,
582SeparatedSyntaxList<SyntaxNode> invocationArguments, int methodInsertionIndex,
586foreach (var invocationArgument in invocationArguments)
608Dictionary<IParameterSymbol, int> mapping, SeparatedSyntaxList<SyntaxNode> arguments,
646if (ShouldRemoveVariableDeclaratorContainingExpression(out _, out var localDeclaration))
MetadataAsSource\AbstractMetadataAsSourceService+CompatAbstractMetadataFormattingRule.cs (8)
22public sealed override void AddSuppressOperations(ArrayBuilder<SuppressOperation> list, SyntaxNode node, in NextSuppressOperationAction nextOperation)
30public sealed override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
38public sealed override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
46public sealed override void AddAlignTokensOperations(List<AlignTokensOperation> list, SyntaxNode node, in NextAlignTokensOperationAction nextOperation)
77public virtual void AddSuppressOperationsSlow(ArrayBuilder<SuppressOperation> list, SyntaxNode node, ref NextSuppressOperationAction nextOperation)
83public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, ref NextAnchorIndentationOperationAction nextOperation)
89public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, ref NextIndentBlockOperationAction nextOperation)
95public virtual void AddAlignTokensOperationsSlow(List<AlignTokensOperation> list, SyntaxNode node, ref NextAlignTokensOperationAction nextOperation)
PullMemberUp\MembersPuller.cs (18)
120foreach (var declaration in symbolToDeclarationsMap[analysisResult.Member])
197SyntaxNode memberDeclaration,
226SyntaxNode eventDeclaration,
231var declaration = editor.Generator.GetDeclaration(eventDeclaration);
252var publicAndNonStaticSyntax = codeGenerationService.CreateEventDeclaration(publicAndNonStaticSymbol, CodeGenerationDestination.ClassType, eventGenerationInfo, cancellationToken);
308using var _ = PooledHashSet<SyntaxNode>.GetInstance(out var sourceImports);
327foreach (var syntax in symbolToDeclarations[analysisResult.Member])
345var declarationSyntax = originalMemberEditor.Generator.GetDeclaration(syntax);
388var destinationRoot = AddLeadingTriviaBeforeFirstMember(
403private static SyntaxTriviaList GetLeadingTriviaBeforeFirstMember(SyntaxNode root, ISyntaxFactsService syntaxFacts)
411private static SyntaxNode RemoveLeadingTriviaBeforeFirstMember(SyntaxNode root, ISyntaxFactsService syntaxFacts)
419private static SyntaxNode AddLeadingTriviaBeforeFirstMember(SyntaxNode root, ISyntaxFactsService syntaxFacts, SyntaxTriviaList trivia)
432private static ImmutableArray<SyntaxNode> GetImports(SyntaxNode start, ISyntaxFactsService syntaxFacts)
467private static async Task<ImmutableDictionary<ISymbol, ImmutableArray<SyntaxNode>>> InitializeSymbolToDeclarationsMapAsync(
473var symbolToDeclarationsBuilder = ImmutableDictionary.CreateBuilder<ISymbol, ImmutableArray<SyntaxNode>>();
ReplaceConditionalWithStatements\AbstractReplaceConditionalWithStatementsCodeRefactoringProvider.cs (22)
30where TExpressionSyntax : SyntaxNode
32where TStatementSyntax : SyntaxNode
34where TArgumentSyntax : SyntaxNode
35where TArgumentListSyntax : SyntaxNode
36where TVariableSyntax : SyntaxNode
37where TVariableDeclaratorSyntax : SyntaxNode
38where TEqualsValueClauseSyntax : SyntaxNode
86private static TConditionalExpressionSyntax? TryFindConditional(SyntaxNode? top, CancellationToken cancellationToken)
91foreach (var node in top.DescendantNodesAndSelf(DescendIntoChildren))
100bool DescendIntoChildren(SyntaxNode node)
239var identifier = generator.IdentifierName(symbol.Name);
260SyntaxNode WrapGlobal(TStatementSyntax statement)
267SyntaxNode container,
269Func<SyntaxNode, SyntaxNode> wrapConvertedSyntax,
288syntaxFacts.GetPartsOfConditionalExpression(conditionalExpression, out var condition, out var whenTrue, out var whenFalse);
295SyntaxNode Rewrite(TExpressionSyntax expression)
300var containerWithConditionalReplaced = container.ReplaceNode(conditionalExpression, TryConvert(expression, conditionalType).WithTriviaFrom(conditionalExpression));
305SyntaxNode TryConvert(SyntaxNode expression, ITypeSymbol? conditionalType)
ReplacePropertyWithMethods\AbstractReplacePropertyWithMethodsService.cs (32)
23where TExpressionSyntax : SyntaxNode
24where TCrefSyntax : SyntaxNode
25where TStatementSyntax : SyntaxNode
26where TPropertySyntax : SyntaxNode
28public abstract SyntaxNode GetPropertyNodeToReplace(SyntaxNode propertyDeclaration);
29public abstract Task<ImmutableArray<SyntaxNode>> GetReplacementMembersAsync(
30Document document, IPropertySymbol property, SyntaxNode propertyDeclaration, IFieldSymbol propertyBackingField, string desiredGetMethodName, string desiredSetMethodName, CancellationToken cancellationToken);
33protected abstract TCrefSyntax CreateCrefSyntax(TCrefSyntax originalCref, SyntaxToken identifierToken, SyntaxNode? parameterType);
35protected abstract TExpressionSyntax UnwrapCompoundAssignment(SyntaxNode compoundAssignment, TExpressionSyntax readExpression);
36public async Task<SyntaxNode?> GetPropertyDeclarationAsync(CodeRefactoringContext context)
39protected static SyntaxNode GetFieldReference(SyntaxGenerator generator, IFieldSymbol propertyBackingField)
41var memberName = generator.IdentifierName(propertyBackingField.Name);
56SyntaxEditor editor, SyntaxNode identifierName,
72private delegate TExpressionSyntax GetWriteValue(ReferenceReplacer replacer, SyntaxNode parent);
163var literalOne = replacer.Generator.LiteralExpression(1);
165var writeValue = replacer._syntaxFacts.IsOperandOfIncrementExpression(replacer._expression)
185private static readonly Func<SyntaxNode, SyntaxGenerator, ReplaceParentArgs, SyntaxNode> replaceParentCallback =
255var declarator = _expression.Parent;
258var newDeclarator = Generator.NamedAnonymousObjectMemberDeclarator(
304SyntaxNode? parameterType;
319private SyntaxNode QualifyIfAppropriate(SyntaxNode newIdentifierName)
324var container = _propertyBackingField.IsStatic
341var newIdentifierName = QualifyIfAppropriate(Generator.IdentifierName(newIdentifierToken));
356private SyntaxNode GetWriteExpression(
364var newIdentifierName = QualifyIfAppropriate(Generator.IdentifierName(newIdentifierToken));
388string desiredName, SyntaxNode? argument, bool keepTrivia, string? conflictMessage)
393var newIdentifierName = Generator.IdentifierName(newIdentifier);
405var invocation = Generator.InvocationExpression(updatedExpression, arguments);
417private SyntaxNode GetSetInvocationExpression(
SolutionCrawler\AbstractDocumentDifferenceService.cs (13)
18public async Task<SyntaxNode?> GetChangedMemberAsync(Document oldDocument, Document newDocument, CancellationToken cancellationToken)
55if (!oldDocument.TryGetSyntaxRoot(out var oldRoot) ||
56!newDocument.TryGetSyntaxRoot(out var newRoot))
103private static SyntaxNode? GetChangedMember(
104ISyntaxFactsService syntaxFactsService, SyntaxNode oldRoot, SyntaxNode newRoot, TextChangeRange range)
112var oldMember = syntaxFactsService.GetContainingMemberDeclaration(oldRoot, range.Span.Start);
113var newMember = syntaxFactsService.GetContainingMemberDeclaration(newRoot, range.Span.Start);
137private static SyntaxNode? GetBestGuessChangedMember(
138ISyntaxFactsService syntaxFactsService, SyntaxNode oldRoot, SyntaxNode newRoot, TextChangeRange range)
153var oldMember = syntaxFactsService.GetContainingMemberDeclaration(oldRoot, range.Span.Start);
154var newMember = syntaxFactsService.GetContainingMemberDeclaration(newRoot, range.Span.Start);
SplitOrMergeIfStatements\AbstractMergeIfStatementsCodeRefactoringProvider.cs (25)
23protected abstract bool IsApplicableSpan(SyntaxNode node, TextSpan span, out SyntaxNode ifOrElseIf);
29Document document, SyntaxNode ifOrElseIf, CancellationToken cancellationToken, out SyntaxNode upperIfOrElseIf);
32Document document, SyntaxNode ifOrElseIf, CancellationToken cancellationToken, out SyntaxNode lowerIfOrElseIf);
34protected abstract SyntaxNode GetChangedRoot(Document document, SyntaxNode root, SyntaxNode upperIfOrElseIf, SyntaxNode lowerIfOrElseIf);
42if (IsApplicableSpan(node, textSpan, out var ifOrElseIf))
47if (await CanBeMergedUpAsync(document, ifOrElseIf, cancellationToken, out var upperIfOrElseIf).ConfigureAwait(false))
50if (await CanBeMergedDownAsync(document, ifOrElseIf, cancellationToken, out var lowerIfOrElseIf).ConfigureAwait(false))
69var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
71var upperIfOrElseIf = FindIfOrElseIf(upperIfOrElseIfSpan, ifGenerator, root);
72var lowerIfOrElseIf = FindIfOrElseIf(lowerIfOrElseIfSpan, ifGenerator, root);
77var newRoot = GetChangedRoot(document, root, upperIfOrElseIf, lowerIfOrElseIf);
80static SyntaxNode FindIfOrElseIf(TextSpan span, IIfLikeStatementGenerator ifGenerator, SyntaxNode root)
82var innerMatch = root.FindNode(span, getInnermostNodeForTie: true);
83return innerMatch?.FirstAncestorOrSelf<SyntaxNode>(
88protected static IReadOnlyList<SyntaxNode> WalkDownScopeBlocks(
90IReadOnlyList<SyntaxNode> statements)
101protected static IReadOnlyList<SyntaxNode> WalkUpScopeBlocks(
103IReadOnlyList<SyntaxNode> statements)
SplitOrMergeIfStatements\AbstractSplitIfStatementCodeRefactoringProvider.cs (17)
25protected abstract Task<SyntaxNode> GetChangedRootAsync(
27SyntaxNode root,
28SyntaxNode ifOrElseIf,
29SyntaxNode leftCondition,
30SyntaxNode rightCondition,
49if (IsPartOfBinaryExpressionChain(token, GetLogicalExpressionKind(syntaxKinds), out var rootExpression) &&
65var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
68var ifOrElseIf = root.FindNode(ifOrElseIfSpan);
74var newRoot = await GetChangedRootAsync(document, root, ifOrElseIf, left, right, cancellationToken).ConfigureAwait(false);
78private static bool IsPartOfBinaryExpressionChain(SyntaxToken token, int syntaxKind, out SyntaxNode rootExpression)
94private static (SyntaxNode left, SyntaxNode right) SplitBinaryExpressionChain(
95SyntaxToken token, SyntaxNode rootExpression, ISyntaxFactsService syntaxFacts)
104syntaxFacts.GetPartsOfBinaryExpression(token.Parent, out var parentLeft, out _, out var parentRight);
106var left = parentLeft;
107var right = rootExpression.ReplaceNode(token.Parent, parentRight);
SplitOrMergeIfStatements\Consecutive\AbstractMergeConsecutiveIfStatementsCodeRefactoringProvider.cs (23)
56Document document, SyntaxNode ifOrElseIf, CancellationToken cancellationToken, out SyntaxNode firstIfOrElseIf)
69Document document, SyntaxNode ifOrElseIf, CancellationToken cancellationToken, out SyntaxNode secondIfOrElseIf)
81protected sealed override SyntaxNode GetChangedRoot(Document document, SyntaxNode root, SyntaxNode firstIfOrElseIf, SyntaxNode secondIfOrElseIf)
140SyntaxNode ifOrElseIf,
141out SyntaxNode parentIfOrElseIf)
151SyntaxNode ifOrElseIf,
152out SyntaxNode elseIfClause)
163SyntaxNode ifOrElseIf,
165out SyntaxNode previousStatement)
177SyntaxNode ifOrElseIf,
179out SyntaxNode nextStatement)
191SyntaxNode firstStatement,
192SyntaxNode secondStatement,
229SyntaxNode ifOrElseIf,
231out SyntaxNode statement)
249SyntaxNode ifStatement1,
250SyntaxNode ifStatement2,
251out IReadOnlyList<SyntaxNode> statements)
SplitOrMergeIfStatements\IIfLikeStatementGenerator.cs (32)
20bool IsIfOrElseIf(SyntaxNode node);
22bool IsCondition(SyntaxNode expression, out SyntaxNode ifOrElseIf);
24bool IsElseIfClause(SyntaxNode node, out SyntaxNode parentIfOrElseIf);
26bool HasElseIfClause(SyntaxNode ifOrElseIf, out SyntaxNode elseIfClause);
28SyntaxNode GetCondition(SyntaxNode ifOrElseIf);
33SyntaxNode GetRootIfStatement(SyntaxNode ifOrElseIf);
38ImmutableArray<SyntaxNode> GetElseIfAndElseClauses(SyntaxNode ifOrElseIf);
40SyntaxNode WithCondition(SyntaxNode ifOrElseIf, SyntaxNode condition);
42SyntaxNode WithStatementInBlock(SyntaxNode ifOrElseIf, SyntaxNode statement);
44SyntaxNode WithStatementsOf(SyntaxNode ifOrElseIf, SyntaxNode otherIfOrElseIf);
46SyntaxNode WithElseIfAndElseClausesOf(SyntaxNode ifStatement, SyntaxNode otherIfStatement);
51SyntaxNode ToIfStatement(SyntaxNode ifOrElseIf);
56SyntaxNode ToElseIfClause(SyntaxNode ifOrElseIf);
62void InsertElseIfClause(SyntaxEditor editor, SyntaxNode afterIfOrElseIf, SyntaxNode elseIfClause);
67void RemoveElseIfClause(SyntaxEditor editor, SyntaxNode elseIfClause);
SplitOrMergeIfStatements\Nested\AbstractMergeNestedIfStatementsCodeRefactoringProvider.cs (19)
44Document document, SyntaxNode ifOrElseIf, CancellationToken cancellationToken, out SyntaxNode outerIfOrElseIf)
57Document document, SyntaxNode ifOrElseIf, CancellationToken cancellationToken, out SyntaxNode innerIfStatement)
69protected sealed override SyntaxNode GetChangedRoot(Document document, SyntaxNode root, SyntaxNode outerIfOrElseIf, SyntaxNode innerIfStatement)
91SyntaxNode statement,
92out SyntaxNode ifOrElseIf)
120SyntaxNode ifOrElseIf,
121out SyntaxNode ifStatement)
149SyntaxNode outerIfOrElseIf,
150SyntaxNode innerIfStatement,
200var outerIfStatement = ifGenerator.GetRootIfStatement(outerIfOrElseIf);
232SyntaxNode elseIfOrElseClause1,
233SyntaxNode elseIfOrElseClause2)
247var condition1 = ifGenerator.GetCondition(elseIfOrElseClause1);
248var condition2 = ifGenerator.GetCondition(elseIfOrElseClause2);
src\Analyzers\Core\Analyzers\AddAccessibilityModifiers\IAddAccessibilityModifiersService.cs (1)
19SyntaxNode member,
src\Analyzers\Core\Analyzers\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesDiagnosticAnalyzer.cs (1)
48SyntaxNode node,
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (17)
49protected abstract bool ContainsPragmaDirective(SyntaxNode root);
127var root = tree.GetRoot(cancellationToken);
166using var _5 = PooledDictionary<string, List<SyntaxNode>>.GetInstance(out var idToSuppressMessageAttributesMap);
167using var _6 = PooledDictionary<SyntaxNode, bool>.GetInstance(out var suppressMessageAttributesToIsUsedMap);
226SyntaxNode root,
297SyntaxNode idNode,
391SyntaxNode root,
512PooledDictionary<string, List<SyntaxNode>> idToSuppressMessageAttributesMap,
513PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
586PooledDictionary<string, List<SyntaxNode>> idToSuppressMessageAttributesMap,
587PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
596var attributeNode = await attribute.ApplicationSyntaxReference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
611PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
663PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
733SyntaxNode root,
736PooledDictionary<string, List<SyntaxNode>> idToSuppressMessageAttributesMap,
737PooledDictionary<SyntaxNode, bool> suppressMessageAttributesToIsUsedMap,
src\Analyzers\Core\Analyzers\SimplifyTypeNames\SimplifyTypeNamesDiagnosticAnalyzerBase.cs (6)
78internal abstract bool IsCandidate(SyntaxNode node);
80SemanticModel model, SyntaxNode node, TSimplifierOptions options,
110protected abstract bool IsIgnoredCodeBlock(SyntaxNode codeBlock);
111protected abstract ImmutableArray<Diagnostic> AnalyzeCodeBlock(CodeBlockAnalysisContext context, SyntaxNode root);
112protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SyntaxNode root, TextSpanMutableIntervalTree? codeBlockIntervalTree);
114public bool TrySimplify(SemanticModel model, SyntaxNode node, [NotNullWhen(true)] out Diagnostic? diagnostic, TSimplifierOptions options, AnalyzerOptions analyzerOptions, CancellationToken cancellationToken)
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (25)
33where TPropertyDeclaration : SyntaxNode
34where TConstructorDeclaration : SyntaxNode
35where TFieldDeclaration : SyntaxNode
36where TVariableDeclarator : SyntaxNode
37where TExpression : SyntaxNode
44private static readonly ObjectPool<ConcurrentSet<SyntaxNode>> s_nodeSetPool = new(() => []);
46private static readonly ObjectPool<ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>>> s_fieldToUsageLocationPool = new(() => []);
63protected static void AddFieldUsage(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites, IFieldSymbol field, SyntaxNode location)
66private static void ClearAndFree(ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> multiMap)
98protected abstract SyntaxNode GetFieldNode(TFieldDeclaration fieldDeclaration, TVariableDeclarator variableDeclarator);
103HashSet<string> fieldNames, ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty, SemanticModel semanticModel, SyntaxNode codeBlock, CancellationToken cancellationToken);
219if (!shouldAnalyze && analysisRoot.FirstAncestorOrSelf<SyntaxNode>(node => node is TPropertyDeclaration or TFieldDeclaration) == null)
229ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads,
230ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites,
232SyntaxNode codeBlock,
539ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> ineligibleFieldUsageIfOutsideProperty,
540ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldReads,
541ConcurrentDictionary<IFieldSymbol, ConcurrentSet<SyntaxNode>> fieldWrites,
626static bool NotWithinProperty(IEnumerable<SyntaxNode> nodes, TPropertyDeclaration propertyDeclaration)
628foreach (var node in nodes)
637static IEnumerable<SyntaxNode> NonConstructorLocations(IEnumerable<SyntaxNode> nodes)
644var fieldNode = GetFieldNode(result.FieldDeclaration, variableDeclarator);
src\Analyzers\Core\Analyzers\UseCompoundAssignment\UseCompoundAssignmentUtilities.cs (6)
41ISyntaxFacts syntaxFacts, SyntaxNode expr, SemanticModel semanticModel, CancellationToken cancellationToken)
47ISyntaxFacts syntaxFacts, SyntaxNode expr, SemanticModel semanticModel,
74out _, out var expression, out _);
82out var subExpr, out _);
90out var expression, out var whenNotNull);
100SyntaxNode expr, SemanticModel semanticModel, bool isTopLevel, CancellationToken cancellationToken)
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (11)
22where TExpressionSyntax : SyntaxNode
31protected abstract void GetPartsOfCastOrConversionExpression(TExpressionSyntax expression, out SyntaxNode type, out TExpressionSyntax castedExpression);
49Document document, SemanticModel semanticModel, SyntaxNode root,
61Document document, SemanticModel semanticModel, SyntaxNode root,
116private (SyntaxNode finalTarget, SyntaxNode finalReplacement) ApplyFix(
136(SyntaxNode finalTarget, SyntaxNode finalReplacement) ApplyFixWorker()
141GetPartsOfCastOrConversionExpression(targetNode, out var castTypeNode, out var castedExpression);
161protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
src\Analyzers\Core\CodeFixes\ConvertToAsync\AbstractConvertToAsyncCodeFixProvider.cs (10)
20protected abstract Task<string> GetDescriptionAsync(Diagnostic diagnostic, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken);
21protected abstract Task<Tuple<SyntaxTree, SyntaxNode>> GetRootInOtherSyntaxTreeAsync(SyntaxNode node, SemanticModel semanticModel, Diagnostic diagnostic, CancellationToken cancellationToken);
32var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
33if (!TryGetNode(root, context.Span, out var node))
48private static bool TryGetNode(SyntaxNode root, TextSpan span, out SyntaxNode node)
51var ancestors = root.FindToken(span.Start).GetAncestors<SyntaxNode>();
62SyntaxNode node, Document document, Diagnostic diagnostic, CancellationToken cancellationToken)
71var newRoot = result.Item2;
src\Analyzers\Core\CodeFixes\FileHeaders\AbstractFileHeaderCodeFixProvider.cs (7)
49private async Task<SyntaxNode> GetTransformedSyntaxRootAsync(Document document, CancellationToken cancellationToken)
58internal static async Task<SyntaxNode> GetTransformedSyntaxRootAsync(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, Document document, string? fileHeaderTemplate, CancellationToken cancellationToken)
81SyntaxNode newSyntaxRoot;
94private static SyntaxNode ReplaceHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader)
176private static SyntaxNode AddHeader(ISyntaxFacts syntaxFacts, AbstractFileHeaderHelper fileHeaderHelper, SyntaxTrivia newLineTrivia, SyntaxNode root, string expectedFileHeader)
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.cs (9)
26where TExpressionSyntax : SyntaxNode
29protected abstract bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
30protected abstract bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
31protected abstract bool IsImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken);
33protected abstract bool TryInitializeImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
78public async Task<ImmutableArray<CodeAction>> GenerateConstructorAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (6)
21where TExpressionSyntax : SyntaxNode
24protected abstract bool IsImplicitConversionGeneration(SyntaxNode node);
25protected abstract bool IsExplicitConversionGeneration(SyntaxNode node);
26protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
27protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
31SyntaxNode node,
src\Analyzers\Core\CodeFixes\GenerateVariable\AbstractGenerateVariableService.cs (6)
25where TExpressionSyntax : SyntaxNode
31protected abstract bool IsExplicitInterfaceGeneration(SyntaxNode node);
32protected abstract bool IsIdentifierNameGeneration(SyntaxNode node);
34protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn);
37protected abstract bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, SemanticModel semanticModel, CancellationToken cancellationToken, out SyntaxNode newRoot);
41SyntaxNode node,
src\Analyzers\Core\CodeFixes\ImplementAbstractClass\ImplementAbstractClassData.cs (7)
33Document document, ImplementTypeOptions options, SyntaxNode classNode, SyntaxToken classIdentifier,
39private readonly SyntaxNode _classNode = classNode;
47Document document, SyntaxNode classNode, SyntaxToken classIdentifier, CancellationToken cancellationToken)
79Document document, SyntaxNode classNode, SyntaxToken classIdentifier, CancellationToken cancellationToken)
250Func<SyntaxNode, SyntaxNode, SyntaxNode> createAddOrRemoveHandler)
src\Analyzers\Core\CodeFixes\ImplementInterface\AbstractImplementInterfaceService.cs (10)
30protected abstract bool TryInitializeState(Document document, SemanticModel model, SyntaxNode interfaceNode, CancellationToken cancellationToken, out SyntaxNode classOrStructDecl, out INamedTypeSymbol classOrStructType, out ImmutableArray<INamedTypeSymbol> interfaceTypes);
33protected abstract SyntaxNode AddCommentInsideIfStatement(SyntaxNode ifDisposingStatement, SyntaxTriviaList trivia);
34protected abstract SyntaxNode CreateFinalizer(SyntaxGenerator generator, INamedTypeSymbol classType, string disposeMethodDisplayString);
37Document document, ImplementTypeOptions options, SyntaxNode node, CancellationToken cancellationToken)
57public async Task<IImplementInterfaceInfo?> AnalyzeAsync(Document document, SyntaxNode interfaceType, CancellationToken cancellationToken)
63protected TNode AddComment<TNode>(string comment, TNode node) where TNode : SyntaxNode
66protected TNode AddComments<TNode>(string comment1, string comment2, TNode node) where TNode : SyntaxNode
69protected TNode AddComments<TNode>(string[] comments, TNode node) where TNode : SyntaxNode
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (11)
21protected abstract bool IsAsyncSupportingFunctionSyntax(SyntaxNode node);
28protected abstract SyntaxNode AddAsyncTokenAndFixReturnType(
29bool keepVoid, IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes, CancellationToken cancellationToken);
42var node = GetContainingFunction(diagnostic, cancellationToken);
87private static IMethodSymbol? GetMethodSymbol(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
109var node = GetContainingFunction(diagnostic, cancellationToken);
147private SyntaxNode? GetContainingFunction(Diagnostic diagnostic, CancellationToken cancellationToken)
157SyntaxNode node,
174if (syntaxPath.TryResolve(newRoot, out SyntaxNode? newNode))
189SyntaxNode node,
192var newNode = AddAsyncTokenAndFixReturnType(keepVoid, methodSymbol, node, knownTypes, cancellationToken);
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (11)
24protected abstract bool IsAsyncSupportingFunctionSyntax(SyntaxNode node);
25protected abstract SyntaxNode RemoveAsyncTokenAndFixReturnType(IMethodSymbol methodSymbol, SyntaxNode node, KnownTaskTypes knownTypes);
52Document document, SyntaxNode node, CancellationToken cancellationToken)
73private async Task<Solution> RenameThenRemoveAsyncTokenAsync(Document document, SyntaxNode node, IMethodSymbol methodSymbol, CancellationToken cancellationToken)
86if (syntaxPath.TryResolve(newRoot, out SyntaxNode? newNode))
97Document document, IMethodSymbol methodSymbol, SyntaxNode node, CancellationToken cancellationToken)
103var newNode = RemoveAsyncTokenAndFixReturnType(methodSymbol, node, knownTypes)
182var newRoot = editor.GetChangedRoot();
249var currentConfigureAwaitInvocation = syntaxFacts.GetExpressionOfAwaitExpression(currentAwaitExpression);
251var currentInvocationExpression = syntaxFacts.GetExpressionOfMemberAccessExpression(currentMemberAccess);
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (36)
22where TReturnStatementSyntax : SyntaxNode
23where TExpressionSyntax : SyntaxNode
25protected abstract bool IsAsyncSupportingFunctionSyntax(SyntaxNode node);
26protected abstract SyntaxNode RemoveAsyncModifier(SyntaxGenerator generator, SyntaxNode methodLikeNode);
27protected abstract SyntaxNode? ConvertToBlockBody(SyntaxNode node, TExpressionSyntax expressionBody);
104private static IMethodSymbol? GetMethodSymbol(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken)
117private SyntaxNode RemoveAsyncModifier(
121SyntaxNode node,
128var expression = generator.GetExpression(node);
134var blockBodiedNode = ConvertToBlockBody(node, expressionBody);
146var newExpressionBody = WrapExpressionWithTaskFromResult(generator, expressionBody, returnType, knownTypes);
166private static ControlFlowAnalysis? GetControlFlowAnalysis(SyntaxGenerator generator, SemanticModel semanticModel, SyntaxNode node)
177private static SyntaxNode AddReturnStatement(SyntaxGenerator generator, SyntaxNode node)
180private SyntaxNode ChangeReturnStatements(
184SyntaxNode node,
196var returnExpression = syntaxFacts.GetExpressionOfReturnStatement(returnSyntax);
200var returnTaskCompletedTask = GetReturnTaskCompletedTaskStatement(generator, returnType, knownTypes);
206var newExpression = WrapExpressionWithTaskFromResult(generator, returnExpression, returnType, knownTypes);
214private static SyntaxNode GetReturnTaskCompletedTaskStatement(SyntaxGenerator generator, ITypeSymbol returnType, KnownTaskTypes knownTypes)
216SyntaxNode invocation;
219var taskTypeExpression = TypeExpressionForStaticMemberAccess(generator, knownTypes.TaskType);
227var statement = generator.ReturnStatement(invocation);
231private static SyntaxNode WrapExpressionWithTaskFromResult(SyntaxGenerator generator, SyntaxNode expression, ITypeSymbol returnType, KnownTaskTypes knownTypes)
235var taskTypeExpression = TypeExpressionForStaticMemberAccess(generator, knownTypes.TaskType!);
237var memberName = generator.GenericName(nameof(Task.FromResult), unwrappedReturnType);
238var taskFromResult = generator.MemberAccessExpression(taskTypeExpression, memberName);
249private static SyntaxNode TypeExpressionForStaticMemberAccess(SyntaxGenerator generator, INamedTypeSymbol typeSymbol)
254var typeExpression = generator.TypeExpression(typeSymbol);
258static SyntaxNode QualifiedNameToMemberAccess(int qualifiedNameSyntaxKind, int memberAccessExpressionSyntaxKind, SyntaxNode expression, SyntaxGenerator generator)
262var left = QualifiedNameToMemberAccess(qualifiedNameSyntaxKind, memberAccessExpressionSyntaxKind, expression.ChildNodes().First(), generator);
263var right = expression.ChildNodes().Last();
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (63)
48where TExpressionSyntax : SyntaxNode
49where TStatementSyntax : SyntaxNode
54where TVariableDeclaratorSyntax : SyntaxNode
55where TSwitchCaseBlockSyntax : SyntaxNode
56where TSwitchCaseLabelOrClauseSyntax : SyntaxNode
76protected abstract SyntaxNode? TryUpdateNameForFlaggedNode(SyntaxNode node, SyntaxToken newName);
100protected abstract SyntaxNode GetReplacementNodeForCompoundAssignment(
101SyntaxNode originalCompoundAssignment,
102SyntaxNode newAssignmentTarget,
110protected abstract SyntaxNode GetReplacementNodeForVarPattern(SyntaxNode originalVarPattern, SyntaxNode newNameNode);
122protected virtual SyntaxNode? TryUpdateParentOfUpdatedNode(SyntaxNode parent, SyntaxNode newNameNode, SyntaxEditor editor, ISyntaxFacts syntaxFacts, SemanticModel semanticModel) => null;
131protected abstract SyntaxNode ComputeReplacementNode(SyntaxNode originalOldNode, SyntaxNode changedOldNode, SyntaxNode proposedReplacementNode);
240private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
243SyntaxNode root,
265private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
268SyntaxNode root)
293private async Task<SyntaxNode> GetNewRootAsync(
325var containingMemberDeclaration = diagnosticsToFix.Key;
335var currentRoot = editor.GetChangedRoot();
336var newRoot = await PostProcessDocumentAsync(document, options, currentRoot,
350SyntaxNode root,
351SyntaxNode containingMemberDeclaration,
387SyntaxNode root,
430var localDecl = editor.Generator.LocalDeclarationStatement(
446SyntaxNode root,
447SyntaxNode containingMemberDeclaration,
470using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var nodeReplacementMap);
471using var _2 = PooledHashSet<SyntaxNode>.GetInstance(out var nodesToRemove);
472using var _3 = PooledHashSet<(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)>.GetInstance(out var nodesToAdd);
474using var _4 = PooledHashSet<SyntaxNode>.GetInstance(out var processedNodes);
550var newNameNode = TryUpdateNameForFlaggedNode(node, newNameToken);
570var newParentNode = TryUpdateParentOfUpdatedNode(node.GetRequiredParent(), newNameNode, editor, syntaxFacts, semanticModel);
674IEnumerable<(SyntaxNode node, bool isUnusedLocalAssignment)> GetNodesToFix()
678var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
692void InsertLocalDeclarationStatement(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)
695var insertionNode = node.FirstAncestorOrSelf<SyntaxNode>(
726bool ShouldRemoveStatement(TLocalDeclarationStatementSyntax localDeclarationStatement, out SeparatedSyntaxList<SyntaxNode> variables)
732foreach (var variable in variables)
746private async Task<SyntaxNode> PostProcessDocumentAsync(
749SyntaxNode currentRoot,
775private static async Task<SyntaxNode> PostProcessDocumentCoreAsync(
776Func<SyntaxNode, Document, SyntaxFormattingOptions, CancellationToken, Task<SyntaxNode>> processMemberDeclarationAsync,
777SyntaxNode currentRoot,
787using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var memberDeclReplacementsMap);
807private async Task<SyntaxNode> ReplaceDiscardDeclarationsWithAssignmentsAsync(SyntaxNode memberDeclaration, Document document, SyntaxFormattingOptions options, CancellationToken cancellationToken)
823private async Task<SyntaxNode> AdjustLocalDeclarationsAsync(
824SyntaxNode memberDeclaration,
927SyntaxNode memberDeclaration,
932private readonly SyntaxNode _memberDeclaration = memberDeclaration;
938public SyntaxToken GenerateUniqueNameAtSpanStart(SyntaxNode node)
src\Analyzers\Core\CodeFixes\UseCoalesceExpression\UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (16)
62var root = editor.OriginalRoot;
63var conditionalExpression = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true);
64var conditionalPartHigh = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan);
65var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan);
67conditionalExpression, out var condition, out var whenTrue, out var whenFalse);
74c, out var currentCondition, out var currentWhenTrue, out var currentWhenFalse);
92private static SyntaxNode GetCoalesceExpression(
94SyntaxNode whenPart, SyntaxNode whenTrue,
95SyntaxNode conditionalPartLow,
96SyntaxNode currentWhenTrue, SyntaxNode currentWhenFalse)
src\Compilers\Core\AnalyzerDriver\DeclarationComputer.cs (12)
15internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNode node, bool getSymbol, IEnumerable<SyntaxNode>? executableCodeBlocks, CancellationToken cancellationToken)
21internal static DeclarationInfo GetDeclarationInfo(SyntaxNode node, ISymbol? declaredSymbol, IEnumerable<SyntaxNode>? executableCodeBlocks)
23var codeBlocks = executableCodeBlocks?.Where(c => c != null).AsImmutableOrEmpty() ?? ImmutableArray<SyntaxNode>.Empty;
27internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNode node, bool getSymbol, CancellationToken cancellationToken)
29return GetDeclarationInfo(model, node, getSymbol, (IEnumerable<SyntaxNode>?)null, cancellationToken);
32internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNode node, bool getSymbol, SyntaxNode executableCodeBlock, CancellationToken cancellationToken)
37internal static DeclarationInfo GetDeclarationInfo(SemanticModel model, SyntaxNode node, bool getSymbol, CancellationToken cancellationToken, params SyntaxNode[] executableCodeBlocks)
42private static ISymbol? GetDeclaredSymbol(SemanticModel model, SyntaxNode node, bool getSymbol, CancellationToken cancellationToken)
Wrapping\BinaryExpression\AbstractBinaryExpressionWrapper.cs (6)
22where TBinaryExpressionSyntax : SyntaxNode
44Document document, int position, SyntaxNode node, SyntaxWrappingOptions options, bool containsSyntaxError, CancellationToken cancellationToken)
104PrecedenceKind precedence, SyntaxNode expr, ArrayBuilder<SyntaxNodeOrToken> result)
115_syntaxFacts.GetPartsOfBinaryExpression(currentNodeOrToken.AsNode()!, out var left, out var opToken, out var right);
127bool IsValidBinaryExpression(PrecedenceKind precedence, SyntaxNode? node)
src\Analyzers\VisualBasic\CodeFixes\ConvertToAsync\VisualBasicConvertToAsyncFunctionCodeFixProvider.vb (5)
35Protected Overrides Async Function GetDescriptionAsync(diagnostic As Diagnostic, node As SyntaxNode, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Task(Of String)
40Protected Overrides Async Function GetRootInOtherSyntaxTreeAsync(node As SyntaxNode, semanticModel As SemanticModel, diagnostic As Diagnostic, cancellationToken As CancellationToken) As Task(Of Tuple(Of SyntaxTree, SyntaxNode))
53Private Shared Async Function GetMethodFromExpressionAsync(oldNode As SyntaxNode, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Task(Of Tuple(Of SyntaxNode, MethodBlockSyntax))
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (7)
25Protected Overrides Function IsImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
29Protected Overrides Function TryInitializeImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken, ByRef token As SyntaxToken, ByRef arguments As ImmutableArray(Of Argument), ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
51Protected Overrides Function IsConstructorInitializerGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
59node As SyntaxNode,
88Protected Overrides Function IsSimpleNameGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
94node As SyntaxNode,
129node As SyntaxNode,
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateConversionService.vb (9)
32Protected Overrides Function IsExplicitConversionGeneration(node As SyntaxNode) As Boolean
36Protected Overrides Function IsImplicitConversionGeneration(node As SyntaxNode) As Boolean
43Private Shared Function IsInImplementsClause(node As SyntaxNode) As Boolean
47Private Shared Function IsInMemberAccessExpression(node As SyntaxNode) As Boolean
55Protected Overrides Function TryInitializeExplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
69Protected Overrides Function TryInitializeImplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
83Private Shared Function TryGetConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
109Private Shared Function IsCastExpression(node As SyntaxNode) As Boolean
129Private Shared Function TryGetImplicitConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationService.vb (37)
41Public Overloads Overrides Function GetDestination(containerNode As SyntaxNode) As CodeGenerationDestination
45Protected Overrides Function GetMemberComparer() As IComparer(Of SyntaxNode)
49Protected Overrides Function GetAvailableInsertionIndices(destination As SyntaxNode, cancellationToken As CancellationToken) As IList(Of Boolean)
92Protected Overrides Function AddEvent(Of TDeclarationNode As SyntaxNode)(
102Protected Overrides Function AddField(Of TDeclarationNode As SyntaxNode)(
118Protected Overrides Function AddProperty(Of TDeclarationNode As SyntaxNode)(
133Protected Overrides Function AddMethod(Of TDeclarationNode As SyntaxNode)(
177Protected Overloads Overrides Function AddNamedType(Of TDeclarationNode As SyntaxNode)(
193Protected Overrides Function AddNamespace(Of TDeclarationNode As SyntaxNode)(
208Public Overrides Function AddParameters(Of TDeclarationNode As SyntaxNode)(
236Protected Overrides Function AddMembers(Of TDeclarationNode As SyntaxNode)(destination As TDeclarationNode, members As IEnumerable(Of SyntaxNode)) As TDeclarationNode
249Private Overloads Function AddParametersToMethod(Of TDeclarationNode As SyntaxNode)(
284Private Overloads Function AddParametersToProperty(Of TDeclarationNode As SyntaxNode)(
291Dim newPropertyBlock As SyntaxNode = propertyBlock.WithPropertyStatement(newPropertyStatement)
325Public Overrides Function AddAttributes(Of TDeclarationNode As SyntaxNode)(
359Public Overrides Function RemoveAttribute(Of TDeclarationNode As SyntaxNode)(destination As TDeclarationNode, attributeToRemove As AttributeData, options As VisualBasicCodeGenerationContextInfo, cancellationToken As CancellationToken) As TDeclarationNode
368Public Overrides Function RemoveAttribute(Of TDeclarationNode As SyntaxNode)(destination As TDeclarationNode, attributeToRemove As SyntaxNode, options As VisualBasicCodeGenerationContextInfo, cancellationToken As CancellationToken) As TDeclarationNode
409Private Shared Function RemoveAttributeFromAttributeLists(attributeLists As SyntaxList(Of AttributeListSyntax), attributeToRemove As SyntaxNode,
438Private Shared Function RemoveAttributeFromAttributeStatements(attributeStatements As SyntaxList(Of AttributesStatementSyntax), attributeToRemove As SyntaxNode,
459Public Overrides Function AddStatements(Of TDeclarationNode As SyntaxNode)(
461statements As IEnumerable(Of SyntaxNode),
492Private Shared Function AddStatementsWorker(Of TDeclarationNode As SyntaxNode)(
494statements As IEnumerable(Of SyntaxNode),
509Dim newBlock As SyntaxNode
530cancellationToken As CancellationToken) As SyntaxNode
551cancellationToken As CancellationToken) As SyntaxNode
558cancellationToken As CancellationToken) As SyntaxNode
569cancellationToken As CancellationToken) As SyntaxNode
576cancellationToken As CancellationToken) As SyntaxNode
583cancellationToken As CancellationToken) As SyntaxNode
587Private Overloads Shared Function UpdateDeclarationModifiers(Of TDeclarationNode As SyntaxNode)(declaration As TDeclarationNode, computeNewModifiersList As Func(Of SyntaxTokenList, SyntaxTokenList)) As TDeclarationNode
633Public Overrides Function UpdateDeclarationModifiers(Of TDeclarationNode As SyntaxNode)(declaration As TDeclarationNode, newModifiers As IEnumerable(Of SyntaxToken), options As VisualBasicCodeGenerationContextInfo, cancellationToken As CancellationToken) As TDeclarationNode
641Public Overrides Function UpdateDeclarationAccessibility(Of TDeclarationNode As SyntaxNode)(declaration As TDeclarationNode, newAccessibility As Accessibility, options As VisualBasicCodeGenerationContextInfo, cancellationToken As CancellationToken) As TDeclarationNode
696Public Overrides Function UpdateDeclarationType(Of TDeclarationNode As SyntaxNode)(declaration As TDeclarationNode, newType As ITypeSymbol, options As VisualBasicCodeGenerationContextInfo, cancellationToken As CancellationToken) As TDeclarationNode
758Public Overrides Function UpdateDeclarationMembers(Of TDeclarationNode As SyntaxNode)(declaration As TDeclarationNode, newMembers As IList(Of ISymbol), options As VisualBasicCodeGenerationContextInfo, cancellationToken As CancellationToken) As TDeclarationNode
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Editing\VisualBasicImportAdder.vb (7)
25Protected Overrides Function GetExplicitNamespaceSymbol(node As SyntaxNode, model As SemanticModel) As INamespaceSymbol
39Protected Overrides Function AddPotentiallyConflictingImportsAsync(model As SemanticModel, container As SyntaxNode, namespaceSymbols As ImmutableArray(Of INamespaceSymbol), conflicts As HashSet(Of INamespaceSymbol), cancellationToken As CancellationToken) As Task
128Public Async Function AddPotentiallyConflictingImportsAsync(container As SyntaxNode, conflicts As HashSet(Of INamespaceSymbol), cancellationToken As CancellationToken) As Task
129Dim nodes = ArrayBuilder(Of SyntaxNode).GetInstance()
135Function(node As SyntaxNode, onItemsFound As Action(Of INamespaceSymbol), conflictFinder As ConflictFinder, cancellationToken1 As CancellationToken) As Task
155Private Sub CollectInfoFromContainer(container As SyntaxNode, nodes As ArrayBuilder(Of SyntaxNode), ByRef containsAnonymousMethods As Boolean)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\Indentation\SpecialFormattingOperation.vb (10)
22Public Overrides Sub AddSuppressOperationsSlow(list As ArrayBuilder(Of SuppressOperation), node As SyntaxNode, ByRef nextOperation As NextSuppressOperationAction)
57Public Overrides Sub AddIndentBlockOperationsSlow(list As List(Of IndentBlockOperation), node As SyntaxNode, ByRef nextOperation As NextIndentBlockOperationAction)
83Private Overloads Shared Sub AddIndentBlockOperations(Of T As SyntaxNode)(list As List(Of IndentBlockOperation), node As SyntaxNode, predicate As Func(Of T, Boolean), Optional indentationDelta As Integer = 0)
96Private Overloads Shared Sub AddIndentBlockOperations(list As List(Of IndentBlockOperation), parameterOrArgumentList As SyntaxNode, indentationDelta As Integer)
113Private Shared Sub AddArgumentListIndentBlockOperations(operations As List(Of IndentBlockOperation), node As SyntaxNode)
169Public Overrides Sub AddAlignTokensOperationsSlow(operations As List(Of AlignTokensOperation), node As SyntaxNode, ByRef nextAction As NextAlignTokensOperationAction)
184Private Shared Sub AddCaseClauseAlignTokensOperations(operations As List(Of AlignTokensOperation), node As SyntaxNode)
201Private Overloads Shared Sub AddAlignTokensOperations(Of T As SyntaxNode)(operations As List(Of AlignTokensOperation), node As SyntaxNode, baseTokenGetter As Func(Of T, SyntaxToken))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSemanticFactsService.vb (12)
107semanticModel As SemanticModel, location As SyntaxNode, containerOpt As SyntaxNode, baseName As String, cancellationToken As CancellationToken) As SyntaxToken Implements ISemanticFactsService.GenerateUniqueName
112semanticModel As SemanticModel, location As SyntaxNode, containerOpt As SyntaxNode, baseName As String, usedNames As IEnumerable(Of String), cancellationToken As CancellationToken) As SyntaxToken Implements ISemanticFactsService.GenerateUniqueName
117semanticModel As SemanticModel, location As SyntaxNode, containerOpt As SyntaxNode, baseName As String, cancellationToken As CancellationToken) As SyntaxToken Implements ISemanticFactsService.GenerateUniqueLocalName
122semanticModel As SemanticModel, location As SyntaxNode, containerOpt As SyntaxNode, baseName As String, usedName As IEnumerable(Of String), cancellationToken As CancellationToken) As SyntaxToken Implements ISemanticFactsService.GenerateUniqueLocalName
126Private Function ISemanticFactsService_GenerateUniqueName(semanticModel As SemanticModel, location As SyntaxNode, containerOpt As SyntaxNode, baseName As String, filter As Func(Of ISymbol, Boolean), usedNames As IEnumerable(Of String), cancellationToken As CancellationToken) As SyntaxToken Implements ISemanticFactsService.GenerateUniqueName
134Public Function ClassifyConversion(semanticModel As SemanticModel, expression As SyntaxNode, destination As ITypeSymbol) As CommonConversion Implements ISemanticFactsService.ClassifyConversion
138Public Function TryGetDisposeMethod(semanticModel As SemanticModel, node As SyntaxNode, cancellationToken As CancellationToken) As IMethodSymbol Implements ISemanticFactsService.TryGetDisposeMethod
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSyntaxGeneratorInternal.vb (86)
57Public Overloads Overrides Function LocalDeclarationStatement(type As SyntaxNode, identifier As SyntaxToken, Optional initializer As SyntaxNode = Nothing, Optional isConst As Boolean = False) As SyntaxNode
63Public Overrides Function WithInitializer(variableDeclarator As SyntaxNode, initializer As SyntaxNode) As SyntaxNode
67Public Overrides Function EqualsValueClause(operatorToken As SyntaxToken, value As SyntaxNode) As SyntaxNode
71Friend Shared Function VariableDeclarator(type As SyntaxNode, name As ModifiedIdentifierSyntax, Optional expression As SyntaxNode = Nothing) As VariableDeclaratorSyntax
84Public Overrides Function ConditionalAccessExpression(expression As SyntaxNode, whenNotNull As SyntaxNode) As SyntaxNode
90Public Overrides Function MemberBindingExpression(name As SyntaxNode) As SyntaxNode
94Public Overrides Function RefExpression(expression As SyntaxNode) As SyntaxNode
98Public Overrides Function AddParentheses(expression As SyntaxNode, Optional includeElasticTrivia As Boolean = True, Optional addSimplifierAnnotation As Boolean = True) As SyntaxNode
102Friend Shared Function Parenthesize(expression As SyntaxNode, Optional addSimplifierAnnotation As Boolean = True) As ParenthesizedExpressionSyntax
106Public Overrides Function YieldReturnStatement(expression As SyntaxNode) As SyntaxNode
116Public Overrides Function InterpolatedStringExpression(startToken As SyntaxToken, content As IEnumerable(Of SyntaxNode), endToken As SyntaxToken) As SyntaxNode
121Public Overrides Function InterpolatedStringText(textToken As SyntaxToken) As SyntaxNode
129Public Overrides Function Interpolation(syntaxNode As SyntaxNode) As SyntaxNode
133Public Overrides Function InterpolationAlignmentClause(alignment As SyntaxNode) As SyntaxNode
139Public Overrides Function InterpolationFormatClause(format As String) As SyntaxNode
145Public Overrides Function TypeParameterList(typeParameterNames As IEnumerable(Of String)) As SyntaxNode
151Public Overrides Function Type(typeSymbol As ITypeSymbol, typeContext As Boolean) As SyntaxNode
155Public Overrides Function NegateEquality(generator As SyntaxGenerator, node As SyntaxNode, left As SyntaxNode, negatedKind As Operations.BinaryOperatorKind, right As SyntaxNode) As SyntaxNode
170Public Overrides Function IsNotTypeExpression(expression As SyntaxNode, type As SyntaxNode) As SyntaxNode
176type As SyntaxNode,
179Optional parameters As IEnumerable(Of SyntaxNode) = Nothing,
180Optional addAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing,
181Optional removeAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing,
182Optional raiseAccessorStatements As IEnumerable(Of SyntaxNode) = Nothing) As SyntaxNode
192addAccessorStatements = SpecializedCollections.EmptyEnumerable(Of SyntaxNode)()
196removeAccessorStatements = SpecializedCollections.EmptyEnumerable(Of SyntaxNode)()
200raiseAccessorStatements = SpecializedCollections.EmptyEnumerable(Of SyntaxNode)()
224Friend Shared Function CreateAddHandlerAccessorBlock(delegateType As SyntaxNode, statements As IEnumerable(Of SyntaxNode)) As AccessorBlockSyntax
246Friend Shared Function CreateRemoveHandlerAccessorBlock(delegateType As SyntaxNode, statements As IEnumerable(Of SyntaxNode)) As AccessorBlockSyntax
268Friend Shared Function CreateRaiseEventAccessorBlock(parameters As IEnumerable(Of SyntaxNode), statements As IEnumerable(Of SyntaxNode)) As AccessorBlockSyntax
283Friend Shared Function GetStatementList(nodes As IEnumerable(Of SyntaxNode)) As SyntaxList(Of StatementSyntax)
291Friend Shared Function AsStatement(node As SyntaxNode) As StatementSyntax
360Friend Shared Function GetParameterList(parameters As IEnumerable(Of SyntaxNode)) As ParameterListSyntax
364Friend Shared Function GetModifierList(accessibility As Accessibility, modifiers As DeclarationModifiers, declaration As SyntaxNode, kind As DeclarationKind, Optional isDefault As Boolean = False) As SyntaxTokenList
465Public Overrides Function IsPatternExpression(expression As SyntaxNode, isToken As SyntaxToken, pattern As SyntaxNode) As SyntaxNode
469Public Overrides Function AndPattern(left As SyntaxNode, right As SyntaxNode) As SyntaxNode
473Public Overrides Function ConstantPattern(expression As SyntaxNode) As SyntaxNode
477Public Overrides Function DeclarationPattern(type As INamedTypeSymbol, name As String) As SyntaxNode
481Public Overrides Function LessThanRelationalPattern(expression As SyntaxNode) As SyntaxNode
485Public Overrides Function LessThanEqualsRelationalPattern(expression As SyntaxNode) As SyntaxNode
489Public Overrides Function GreaterThanRelationalPattern(expression As SyntaxNode) As SyntaxNode
493Public Overrides Function GreaterThanEqualsRelationalPattern(expression As SyntaxNode) As SyntaxNode
497Public Overrides Function NotPattern(pattern As SyntaxNode) As SyntaxNode
501Public Overrides Function OrPattern(left As SyntaxNode, right As SyntaxNode) As SyntaxNode
505Public Overrides Function ParenthesizedPattern(pattern As SyntaxNode) As SyntaxNode
509Public Overrides Function TypePattern(type As SyntaxNode) As SyntaxNode
513Public Overrides Function UnaryPattern(operatorToken As SyntaxToken, pattern As SyntaxNode) As SyntaxNode
AddImport\VisualBasicAddImportFeatureService.vb (20)
28Protected Overrides Function CanAddImport(node As SyntaxNode, allowInHiddenRegions As Boolean, cancellationToken As CancellationToken) As Boolean
36node As SyntaxNode,
96Protected Overrides Function CanAddImportForNamespace(diagnosticId As String, node As SyntaxNode, ByRef nameNode As SimpleNameSyntax) As Boolean
109Protected Overrides Function CanAddImportForDeconstruct(diagnosticId As String, node As SyntaxNode) As Boolean
114Protected Overrides Function CanAddImportForGetAwaiter(diagnosticId As String, syntaxFactsService As ISyntaxFacts, node As SyntaxNode) As Boolean
119Protected Overrides Function CanAddImportForGetEnumerator(diagnosticId As String, syntaxFactsService As ISyntaxFacts, node As SyntaxNode) As Boolean
123Protected Overrides Function CanAddImportForGetAsyncEnumerator(diagnosticId As String, syntaxFactsService As ISyntaxFacts, node As SyntaxNode) As Boolean
127Protected Overrides Function CanAddImportForQuery(diagnosticId As String, node As SyntaxNode) As Boolean
133diagnosticId As String, node As SyntaxNode, ByRef nameNode As SimpleNameSyntax) As Boolean
159Private Shared Function CanAddImportForTypeOrNamespaceCore(node As SyntaxNode, ByRef nameNode As SimpleNameSyntax) As Boolean
192root As SyntaxNode,
217Protected Overrides Function GetImportNamespacesInScope(semanticModel As SemanticModel, node As SyntaxNode, cancellationToken As CancellationToken) As ISet(Of INamespaceSymbol)
221Protected Overrides Function GetDeconstructInfo(semanticModel As SemanticModel, node As SyntaxNode, cancellationToken As CancellationToken) As ITypeSymbol
227node As SyntaxNode,
277contextNode As SyntaxNode,
289contextNode As SyntaxNode,
308contextNode As SyntaxNode,
327expression As SyntaxNode,
335Dim leftExpression As SyntaxNode
353Protected Overrides Function IsAddMethodContext(node As SyntaxNode, semanticModel As SemanticModel) As Boolean
ChangeSignature\VisualBasicChangeSignatureService.vb (29)
152Private Shared Function TryGetSelectedIndexFromDeclaration(position As Integer, matchingNode As SyntaxNode) As Integer
157Private Shared Function GetMatchingNode(node As SyntaxNode, restrictToDeclarations As Boolean) As SyntaxNode
176Private Shared Function IsInSymbolHeader(matchingNode As SyntaxNode, position As Integer) As Boolean
204matchingNode As SyntaxNode,
228Public Overrides Function FindNodeToUpdate(document As Document, node As SyntaxNode) As SyntaxNode
243Private Shared Function GetNodeContainingTargetNode(originalNode As SyntaxNode, matchingNode As SyntaxNode) As SyntaxNode
262Private Shared Function GetUpdatableNode(matchingNode As SyntaxNode) As SyntaxNode
277potentiallyUpdatedNode As SyntaxNode,
278originalNode As SyntaxNode,
280cancellationToken As CancellationToken) As Task(Of SyntaxNode)
521Private Shared Function IsParamsArrayExpanded(semanticModel As SemanticModel, node As SyntaxNode, symbolInfo As SymbolInfo, cancellationToken As CancellationToken) As Boolean
579Private Function UpdateDeclaration(Of T As SyntaxNode)(
632Private Function VerifyAndPermuteParamNodes(paramNodes As ImmutableArray(Of XmlElementSyntax), declarationSymbol As ISymbol, updatedSignature As SignatureChange) As ImmutableArray(Of SyntaxNode)
640Return ImmutableArray(Of SyntaxNode).Empty
644Return ImmutableArray(Of SyntaxNode).Empty
652Return ImmutableArray(Of SyntaxNode).Empty
657Return ImmutableArray(Of SyntaxNode).Empty
665Dim permutedParams = ArrayBuilder(Of SyntaxNode).GetInstance()
744Protected Overrides Function TransferLeadingWhitespaceTrivia(Of T As SyntaxNode)(newArgument As T, oldArgument As SyntaxNode) As T
760Protected Overrides Function CreateExplicitParamsArrayFromIndividualArguments(Of TArgumentSyntax As SyntaxNode)(newArguments As SeparatedSyntaxList(Of TArgumentSyntax), indexInExistingList As Integer, parameterSymbol As IParameterSymbol) As TArgumentSyntax
766Protected Overrides Function AddNameToArgument(Of TArgumentSyntax As SyntaxNode)(newArgument As TArgumentSyntax, name As String) As TArgumentSyntax
769Return CType(CType(simpleArgument.WithNameColonEquals(NameColonEquals(IdentifierName(name))), SyntaxNode), TArgumentSyntax)
774Return CType(CType(omittedArgument, SyntaxNode), TArgumentSyntax)
CodeFixes\GenerateEndConstruct\GenerateEndConstructCodeFixProvider.vb (13)
72Dim beginStatement = token.GetAncestors(Of SyntaxNode) _
114Private Shared Function IsCandidate(node As SyntaxNode) As Boolean
127Private Shared Function GetBeginStatement(node As SyntaxNode) As SyntaxNode
142(Function(n As TryBlockSyntax) DirectCast(n, SyntaxNode)),
147Private Shared Function GetEndStatement(node As SyntaxNode) As SyntaxNode
149(Function(n As MultiLineIfBlockSyntax) DirectCast(n.EndIfStatement, SyntaxNode)),
188updatedProperty = DirectCast(gen.WithGetAccessorStatements(updatedProperty, Array.Empty(Of SyntaxNode)()), PropertyBlockSyntax)
192updatedProperty = DirectCast(gen.WithSetAccessorStatements(updatedProperty, Array.Empty(Of SyntaxNode)()), PropertyBlockSyntax)
199Public Shared Function GetDescription(node As SyntaxNode) As String
213Private Shared Async Function GenerateEndConstructAsync(document As Document, endStatement As SyntaxNode, cancellationToken As CancellationToken) As Task(Of Document)
231Private Shared Async Function InsertEndConstructAsync(document As Document, endStatement As SyntaxNode, cancellationToken As CancellationToken) As Task(Of Document)
CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.AddKeywordCodeAction.vb (8)
15Private ReadOnly _node As SyntaxNode
16Private ReadOnly _containingBlock As SyntaxNode
18Private ReadOnly _updateNode As Func(Of SyntaxNode, SyntaxNode, SyntaxKind, Document, CancellationToken, StatementSyntax)
21Public Sub New(node As SyntaxNode,
23containingBlock As SyntaxNode,
25updateNode As Func(Of SyntaxNode, SyntaxNode, SyntaxKind, Document, CancellationToken, StatementSyntax))
CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.ReplaceKeywordCodeAction.vb (8)
16Private ReadOnly _node As SyntaxNode
18Private ReadOnly _updateNode As Func(Of SyntaxNode, SyntaxNode, SyntaxKind, Document, CancellationToken, StatementSyntax)
19Private ReadOnly _containingBlock As SyntaxNode
22Public Sub New(createBlockKind As SyntaxKind, invalidToken As SyntaxToken, syntax As SyntaxNode, containingBlock As SyntaxNode, document As Document,
23updateNode As Func(Of SyntaxNode, SyntaxNode, SyntaxKind, Document, CancellationToken, StatementSyntax))
CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.vb (20)
69Dim node = token.GetAncestors(Of SyntaxNode) _
94Private Sub CreateContinueCodeActions(document As SemanticDocument, node As SyntaxNode, enclosingblocks As IEnumerable(Of SyntaxNode), ByRef codeActions As List(Of CodeAction), cancellationToken As CancellationToken)
126Private Sub CreateExitCodeActions(document As SemanticDocument, node As SyntaxNode, enclosingblocks As IEnumerable(Of SyntaxNode), ByRef codeActions As List(Of CodeAction), cancellationToken As CancellationToken)
158Private Shared Function GetEnclosingBlockKinds(enclosingblocks As IEnumerable(Of SyntaxNode), enclosingDeclaration As ISymbol) As IEnumerable(Of SyntaxKind)
179Private Shared Function GetEnclosingContinuableBlockKinds(enclosingblocks As IEnumerable(Of SyntaxNode)) As IEnumerable(Of SyntaxKind)
191Private Function CreateExitStatement(exitSyntax As SyntaxNode, containingBlock As SyntaxNode,
210Private Function CreateContinueStatement(continueSyntax As SyntaxNode, containingBlock As SyntaxNode,
305Private Shared Sub CreateAddKeywordActions(node As SyntaxNode,
307enclosingBlock As SyntaxNode,
309updateNode As Func(Of SyntaxNode, SyntaxNode, SyntaxKind, Document, CancellationToken, StatementSyntax),
316node As SyntaxNode,
317enclosingBlock As SyntaxNode,
319updateNode As Func(Of SyntaxNode, SyntaxNode, SyntaxKind, Document, CancellationToken, StatementSyntax),
329Private Shared Function CreateDeleteString(node As SyntaxNode) As String
CodeFixes\Suppression\VisualBasicSuppressionCodeFixProvider.vb (13)
28Protected Overrides Function CreatePragmaRestoreDirectiveTrivia(diagnostic As Diagnostic, formatNode As Func(Of SyntaxNode, CancellationToken, SyntaxNode), needsLeadingEndOfLine As Boolean, needsTrailingEndOfLine As Boolean, cancellationToken As CancellationToken) As SyntaxTriviaList
35Protected Overrides Function CreatePragmaDisableDirectiveTrivia(diagnostic As Diagnostic, formatNode As Func(Of SyntaxNode, CancellationToken, SyntaxNode), needsLeadingEndOfLine As Boolean, needsTrailingEndOfLine As Boolean, cancellationToken As CancellationToken) As SyntaxTriviaList
55formatNode As Func(Of SyntaxNode, CancellationToken, SyntaxNode),
82Protected Overrides Function GetContainingStatement(token As SyntaxToken) As SyntaxNode
102Protected Overrides Function IsAttributeListWithAssemblyAttributes(node As SyntaxNode) As Boolean
117newRoot As SyntaxNode,
124cancellationToken As CancellationToken) As SyntaxNode
152targetNode As SyntaxNode,
155diagnostic As Diagnostic) As SyntaxNode
209Protected Overrides Function IsSingleAttributeInAttributeList(attribute As SyntaxNode) As Boolean
CodeRefactorings\SyncNamespace\VisualBasicChangeNamespaceService.vb (9)
24Public Overrides Function TryGetReplacementReferenceSyntax(reference As SyntaxNode, newNamespaceParts As ImmutableArray(Of String), syntaxFacts As ISyntaxFactsService, ByRef old As SyntaxNode, ByRef [new] As SyntaxNode) As Boolean
60Protected Overrides Function GetValidContainersFromAllLinkedDocumentsAsync(document As Document, container As SyntaxNode, cancellationToken As CancellationToken) As Task(Of ImmutableArray(Of (DocumentId, SyntaxNode)))
61Return SpecializedTasks.Default(Of ImmutableArray(Of (DocumentId, SyntaxNode)))()
70Protected Overrides Function GetMemberDeclarationsInContainer(container As SyntaxNode) As SyntaxList(Of StatementSyntax)
75Protected Overrides Function TryGetApplicableContainerFromSpanAsync(document As Document, span As TextSpan, cancellationToken As CancellationToken) As Task(Of SyntaxNode)
80Protected Overrides Function GetDeclaredNamespace(container As SyntaxNode) As String
Completion\CompletionProviders\ImplementsClauseCompletionProvider.vb (3)
191Private Function GetInterfacesAndContainers(position As Integer, node As SyntaxNode, semanticModel As SemanticModel, kind As SyntaxKind, cancellationToken As CancellationToken) As ImmutableArray(Of ISymbol)
228Private Shared Sub AddAliasesAndContainers(symbol As ISymbol, interfacesAndContainers As ICollection(Of ISymbol), node As SyntaxNode, semanticModel As SemanticModel)
246Private Shared Sub AddAlias(symbol As ISymbol, interfacesAndContainers As ICollection(Of ISymbol), node As SyntaxNode, semanticModel As SemanticModel)
EditAndContinue\SyntaxComparer.vb (45)
20Public Sub New(oldRoot As SyntaxNode, newRoot As SyntaxNode, oldRootChildren As IEnumerable(Of SyntaxNode), newRootChildren As IEnumerable(Of SyntaxNode), Optional matchingLambdas As Boolean = False, Optional compareStatementSyntax As Boolean = False)
26Protected Overrides Function IsLambdaBodyStatementOrExpression(node As SyntaxNode) As Boolean
307Friend Overrides Function Classify(kind As Integer, node As SyntaxNode, ByRef isLeaf As Boolean) As Integer
312Friend Overloads Function Classify(kind As SyntaxKind, nodeOpt As SyntaxNode, ByRef isLeaf As Boolean, ignoreVariableDeclarations As Boolean) As Label
320Friend Shared Function ClassifyStatementSyntax(kind As SyntaxKind, nodeOpt As SyntaxNode, ByRef isLeaf As Boolean) As Label
726Private Shared Function ClassifyTopSyntax(kind As SyntaxKind, nodeOpt As SyntaxNode, ByRef isLeaf As Boolean, ignoreVariableDeclarations As Boolean) As Label
870Protected Overrides Function GetLabel(node As SyntaxNode) As Integer
878Friend Function GetLabelImpl(node As SyntaxNode) As Label
903Public Overrides Function ValuesEqual(left As SyntaxNode, right As SyntaxNode) As Boolean
939Protected Overrides Function TryComputeWeightedDistance(leftNode As SyntaxNode, rightNode As SyntaxNode, ByRef distance As Double) As Boolean
948Dim getParts = Function(node As SyntaxNode)
1032Dim ifParts = Function(node As SyntaxNode)
1056Dim elseStatements = Function(node As SyntaxNode)
1080Dim getParts = Function(node As SyntaxNode)
1138Private Shared Function ComputeWeightedDistance(leftHeader As SyntaxNode,
1140rightHeader As SyntaxNode,
1145Private Shared Function ComputeWeightedDistance(leftControlVariable As SyntaxNode,
1146leftHeader As SyntaxNode,
1148rightControlVariable As SyntaxNode,
1149rightHeader As SyntaxNode,
1211Private Shared Function TryGetName(node As SyntaxNode) As SyntaxNodeOrToken?
1294Public Overrides Function GetDistance(oldNode As SyntaxNode, newNode As SyntaxNode) As Double
1313Friend Shared Function ComputeValueDistance(leftNode As SyntaxNode, rightNode As SyntaxNode) As Double
1343Friend Overloads Shared Function ComputeDistance(Of TSyntaxNode As SyntaxNode)(oldList As SyntaxList(Of TSyntaxNode), newList As SyntaxList(Of TSyntaxNode)) As Double
1347Friend Overloads Shared Function ComputeDistance(Of TSyntaxNode As SyntaxNode)(oldList As SeparatedSyntaxList(Of TSyntaxNode), newList As SeparatedSyntaxList(Of TSyntaxNode)) As Double
1354Friend Shared Iterator Function GetDescendantTokensIgnoringSeparators(Of TSyntaxNode As SyntaxNode)(list As SyntaxList(Of TSyntaxNode)) As IEnumerable(Of SyntaxToken)
1365Private Shared Iterator Function GetDescendantTokensIgnoringSeparators(Of TSyntaxNode As SyntaxNode)(list As SeparatedSyntaxList(Of TSyntaxNode)) As IEnumerable(Of SyntaxToken)
1379Public Overloads Shared Function ComputeDistance(oldNode As SyntaxNode, newNode As SyntaxNode) As Double
1419Public Overloads Shared Function ComputeDistance(oldTokens As IEnumerable(Of SyntaxNode), newTokens As IEnumerable(Of SyntaxNode)) As Double
1426Public Shared Function GetSequenceEdits(oldNodes As IEnumerable(Of SyntaxNode), newNodes As IEnumerable(Of SyntaxNode)) As IEnumerable(Of SequenceEdit)
1433Public Shared Function GetSequenceEdits(oldNodes As ImmutableArray(Of SyntaxNode), newNodes As ImmutableArray(Of SyntaxNode)) As IEnumerable(Of SequenceEdit)
1462Inherits LongestCommonImmutableArraySubsequence(Of SyntaxNode)
1466Protected Overrides Function Equals(oldElement As SyntaxNode, newElement As SyntaxNode) As Boolean
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (155)
37Public Sub New(Optional testFaultInjector As Action(Of SyntaxNode) = Nothing)
43Friend Overrides Function TryFindMemberDeclaration(rootOpt As SyntaxNode, node As SyntaxNode, activeSpan As TextSpan, <Out> ByRef declarations As OneOrMany(Of SyntaxNode)) As Boolean
72declarations = OneOrMany.Create(Of SyntaxNode)(variableDeclarator.Names(0))
74declarations = OneOrMany.Create(variableDeclarator.Names.SelectAsArray(Function(n) CType(n, SyntaxNode)))
101Friend Overrides Function TryGetDeclarationBody(node As SyntaxNode, symbol As ISymbol) As MemberBody
105Friend Overrides Function IsDeclarationWithSharedBody(declaration As SyntaxNode, member As ISymbol) As Boolean
114Protected Overrides Function GetVariableUseSites(roots As IEnumerable(Of SyntaxNode), localOrParameter As ISymbol, model As SemanticModel, cancellationToken As CancellationToken) As IEnumerable(Of SyntaxNode)
131body As SyntaxNode,
132partnerBody As SyntaxNode,
133<Out> ByRef partnerStatement As SyntaxNode,
134<Out> ByRef statementPart As Integer) As SyntaxNode
143Dim node As SyntaxNode = Nothing
186Friend Overrides Function IsClosureScope(node As SyntaxNode) As Boolean
190Friend Overrides Function GetCapturedParameterScope(methodOrLambda As SyntaxNode) As SyntaxNode
194Protected Overrides Function FindEnclosingLambdaBody(encompassingAncestor As SyntaxNode, node As SyntaxNode) As LambdaBody
196Dim body As SyntaxNode = Nothing
207Protected Overrides Function ComputeTopLevelMatch(oldCompilationUnit As SyntaxNode, newCompilationUnit As SyntaxNode) As Match(Of SyntaxNode)
211Protected Overrides Function ComputeParameterMap(oldDeclaration As SyntaxNode, newDeclaration As SyntaxNode) As BidirectionalMap(Of SyntaxNode)?
222Dim map = BidirectionalMap(Of SyntaxNode).FromMatch(If(primaryMatch, secondaryMatch))
231Private Shared Function GetTopLevelMatch(oldNode As SyntaxNode, newNode As SyntaxNode) As Match(Of SyntaxNode)
235Private Shared Function GetDeclarationParameterLists(declaration As SyntaxNode) As (Primary As SyntaxNode, Secondary As SyntaxNode)
254Protected Overrides Function IsNamespaceDeclaration(node As SyntaxNode) As Boolean
259Private Shared Function IsTypeDeclaration(node As SyntaxNode) As Boolean
263Protected Overrides Function IsCompilationUnitWithGlobalStatements(node As SyntaxNode) As Boolean
267Protected Overrides Function IsGlobalStatement(node As SyntaxNode) As Boolean
271Protected Overrides Iterator Function GetTopLevelTypeDeclarations(compilationUnit As SyntaxNode) As IEnumerable(Of SyntaxNode)
305Protected Overrides Function GetSyntaxSequenceEdits(oldNodes As ImmutableArray(Of SyntaxNode), newNodes As ImmutableArray(Of SyntaxNode)) As IEnumerable(Of SequenceEdit)
309Friend Overrides ReadOnly Property EmptyCompilationUnit As SyntaxNode
320Protected Overrides Function StatementLabelEquals(node1 As SyntaxNode, node2 As SyntaxNode) As Boolean
324Private Shared Function ChildrenCompiledInBody(node As SyntaxNode) As Boolean
335Protected Overrides Function TryGetActiveSpan(node As SyntaxNode, statementPart As Integer, minLength As Integer, <Out> ByRef span As TextSpan) As Boolean
339Protected Overrides Iterator Function EnumerateNearStatements(statement As SyntaxNode) As IEnumerable(Of ValueTuple(Of SyntaxNode, Integer))
347Dim lastBlockStatement As SyntaxNode = Nothing
411Private Shared Function GetFieldOrPropertyModifiers(node As SyntaxNode) As SyntaxTokenList?
421Private Shared Function AreEquivalentIgnoringLambdaBodies(left As SyntaxNode, right As SyntaxNode) As Boolean
430Protected Overrides Function AreEquivalentActiveStatements(oldStatement As SyntaxNode, newStatement As SyntaxNode, statementPart As Integer) As Boolean
463Private Shared Function HasMultiInitializer(modifiedIdentifier As SyntaxNode) As Boolean
472Friend Overrides Function IsInterfaceDeclaration(node As SyntaxNode) As Boolean
476Friend Overrides Function IsRecordDeclaration(node As SyntaxNode) As Boolean
481Friend Overrides Function TryGetContainingTypeDeclaration(node As SyntaxNode) As SyntaxNode
485Friend Overrides Function IsDeclarationWithInitializer(declaration As SyntaxNode) As Boolean
510Friend Overrides Function IsPrimaryConstructorDeclaration(declaration As SyntaxNode) As Boolean
532Protected Overrides Function GetSymbolDeclarationSyntax(symbol As ISymbol, selector As Func(Of ImmutableArray(Of SyntaxReference), SyntaxReference), cancellationToken As CancellationToken) As SyntaxNode
637Protected Overrides Function GetDeclaredSymbol(model As SemanticModel, declaration As SyntaxNode, cancellationToken As CancellationToken) As ISymbol
707oldNode As SyntaxNode,
708newNode As SyntaxNode,
748oldNode As SyntaxNode,
750newNode As SyntaxNode,
754topMatch As Match(Of SyntaxNode),
755editMap As IReadOnlyDictionary(Of SyntaxNode, EditKind),
895node As SyntaxNode,
943Private Function GetParameterContainingMemberOrType(node As SyntaxNode, otherNode As SyntaxNode, model As SemanticModel, fromOtherMap As IReadOnlyDictionary(Of SyntaxNode, SyntaxNode), cancellationToken As CancellationToken) As ISymbol
950Dim declaration As SyntaxNode = Nothing
960Private Shared Function GetContainingDeclaration(node As SyntaxNode) As SyntaxNode
964Friend Overrides ReadOnly Property IsLambda As Func(Of SyntaxNode, Boolean)
970Friend Overrides ReadOnly Property IsNotLambda As Func(Of SyntaxNode, Boolean)
976Friend Overrides Function IsNestedFunction(node As SyntaxNode) As Boolean
980Friend Overrides Function IsLocalFunction(node As SyntaxNode) As Boolean
984Friend Overrides Function IsGenericLocalFunction(node As SyntaxNode) As Boolean
988Friend Overrides Function TryGetLambdaBodies(node As SyntaxNode, <Out> ByRef body1 As LambdaBody, <Out> ByRef body2 As LambdaBody) As Boolean
989Dim bodyNode1 As SyntaxNode = Nothing
990Dim bodyNode2 As SyntaxNode = Nothing
1000Friend Overrides Function GetLambdaExpressionSymbol(model As SemanticModel, lambdaExpression As SyntaxNode, cancellationToken As CancellationToken) As IMethodSymbol
1007Friend Overrides Function GetContainingQueryExpression(node As SyntaxNode) As SyntaxNode
1011Friend Overrides Function QueryClauseLambdasTypeEquivalent(oldModel As SemanticModel, oldNode As SyntaxNode, newModel As SemanticModel, newNode As SyntaxNode, cancellationToken As CancellationToken) As Boolean
1069Protected Overrides Function TryGetDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan?
1073Protected Overloads Shared Function GetDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan
1077Private Shared Function TryGetDiagnosticSpanImpl(node As SyntaxNode, editKind As EditKind) As TextSpan?
1081Protected Overrides Function GetBodyDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan
1086Friend Shared Function TryGetDiagnosticSpanImpl(kind As SyntaxKind, node As SyntaxNode, editKind As EditKind) As TextSpan?
1318Private Overloads Shared Function GetDiagnosticSpan(ifKeyword As SyntaxToken, condition As SyntaxNode, thenKeywordOpt As SyntaxToken) As TextSpan
1415Friend Overrides Function GetLambdaParameterDiagnosticSpan(lambda As SyntaxNode, ordinal As Integer) As TextSpan
1458Protected Overrides Function TryGetDisplayName(node As SyntaxNode, editKind As EditKind) As String
1462Protected Overloads Shared Function GetDisplayName(node As SyntaxNode, editKind As EditKind) As String
1472Protected Overrides Function GetBodyDisplayName(node As SyntaxNode, Optional editKind As EditKind = EditKind.Update) As String
1476Private Shared Function TryGetDisplayNameImpl(node As SyntaxNode, editKind As EditKind) As String
1705Private ReadOnly _match As Match(Of SyntaxNode)
1706Private ReadOnly _oldNode As SyntaxNode
1707Private ReadOnly _newNode As SyntaxNode
1713oldNode As SyntaxNode,
1714newNode As SyntaxNode,
1716Optional match As Match(Of SyntaxNode) = Nothing,
1776Private Sub ClassifyMove(newNode As SyntaxNode)
1799Private Sub ClassifyReorder(oldNode As SyntaxNode, newNode As SyntaxNode)
1822Private Sub ClassifyInsert(node As SyntaxNode)
1854Private Sub ClassifyDelete(oldNode As SyntaxNode)
1881Private Sub ClassifyUpdate(newNode As SyntaxNode)
1905match As Match(Of SyntaxNode),
1906edit As Edit(Of SyntaxNode),
1907editMap As Dictionary(Of SyntaxNode, EditKind))
1938Friend Overrides Function HasUnsupportedOperation(nodes As IEnumerable(Of SyntaxNode), <Out> ByRef unsupportedNode As SyntaxNode, <Out> ByRef rudeEdit As RudeEditKind) As Boolean
1981Friend Overrides Sub ReportInsertedMemberSymbolRudeEdits(diagnostics As ArrayBuilder(Of RudeEditDiagnostic), newSymbol As ISymbol, newNode As SyntaxNode, insertingIntoExistingContainingType As Boolean)
2056Protected Overrides Function GetExceptionHandlingAncestors(node As SyntaxNode, root As SyntaxNode, isNonLeaf As Boolean) As List(Of SyntaxNode)
2057Dim result = New List(Of SyntaxNode)()
2093exceptionHandlingEdits As IEnumerable(Of Edit(Of SyntaxNode)),
2094oldStatement As SyntaxNode,
2105Private Shared Function AreExceptionHandlingPartsEquivalent(oldNode As SyntaxNode, newNode As SyntaxNode) As Boolean
2127Protected Overrides Function GetExceptionHandlingRegion(node As SyntaxNode, <Out> ByRef coversAllChildren As Boolean) As TextSpan
2157Friend Overrides Function IsStateMachineMethod(declaration As SyntaxNode) As Boolean
2162Friend Shared Function GetStateMachineInfo(body As SyntaxNode) As StateMachineInfo
2173Friend Overrides Sub ReportStateMachineSuspensionPointRudeEdits(diagnosticContext As DiagnosticContext, oldNode As SyntaxNode, newNode As SyntaxNode)
2188Private Shared Function FindContainingStatementPart(node As SyntaxNode) As SyntaxNode
2214Private Shared Function HasNoSpilledState(awaitExpression As SyntaxNode, containingStatementPart As SyntaxNode) As Boolean
2259Private Shared Function GetExpressionFromStatementPart(statement As SyntaxNode) As ExpressionSyntax
2272Private Shared Function IsSimpleAwaitAssignment(node As SyntaxNode, awaitExpression As SyntaxNode) As Boolean
2285forwardMap As IReadOnlyDictionary(Of SyntaxNode, SyntaxNode),
2286oldActiveStatement As SyntaxNode,
2289newActiveStatement As SyntaxNode,
2303Private Shared Function FindOnErrorOrResumeStatement(newBody As DeclarationBody) As SyntaxNode
2323forwardMap As IReadOnlyDictionary(Of SyntaxNode, SyntaxNode),
2324oldActiveStatement As SyntaxNode,
2325oldEncompassingAncestor As SyntaxNode,
2327newActiveStatement As SyntaxNode,
2328newEncompassingAncestor As SyntaxNode,
2343getTypedNodes:=Function(n) OneOrMany.Create(Of SyntaxNode)(n.SyncLockStatement.Expression),
2350getTypedNodes:=Function(n) OneOrMany.Create(Of SyntaxNode)(n.WithStatement.Expression),
2357getTypedNodes:=Function(n) OneOrMany.Create(Of SyntaxNode)(n.UsingStatement.Expression),
2364getTypedNodes:=Function(n) OneOrMany.Create(Of SyntaxNode)(n.ForEachStatement.Expression),
ExtractMethod\Extensions.vb (26)
17Public Function GetUnparenthesizedExpression(node As SyntaxNode) As ExpressionSyntax
27Public Function GetStatementContainer(node As SyntaxNode) As SyntaxNode
39Public Function GetStatementUnderContainer(node As SyntaxNode) As ExecutableStatementSyntax
56Public Function ContainStatement(node As SyntaxNode, statement As StatementSyntax) As Boolean
68Public Function GetOutermostNodeWithSameSpan(initialNode As SyntaxNode, predicate As Func(Of SyntaxNode, Boolean)) As SyntaxNode
87Return CType(If(lastNode, initialNode), SyntaxNode)
91Public Function PartOfConstantInitializerExpression(node As SyntaxNode) As Boolean
97Private Function PartOfConstantInitializerExpression(Of T As SyntaxNode)(node As SyntaxNode, modifiersGetter As Func(Of T, SyntaxTokenList)) As Boolean
117Public Function IsArgumentForByRefParameter(node As SyntaxNode, model As SemanticModel, cancellationToken As CancellationToken) As Boolean
225Public Function ContainsFieldInitializer(node As SyntaxNode) As Boolean
232Public Function ContainsDotMemberAccess(node As SyntaxNode) As Boolean
233Dim predicate = Function(n As SyntaxNode)
269Dim predicate As Func(Of SyntaxNode, Boolean) =
295Return token.GetAncestors(Of SyntaxNode)().Any(predicate)
299Public Function ContainedInValidType(node As SyntaxNode) As Boolean
325Public Function UnderValidContext(ByVal node As SyntaxNode) As Boolean
328Dim predicate As Func(Of SyntaxNode, Boolean) =
339If Not node.GetAncestorsOrThis(Of SyntaxNode)().Any(predicate) Then
351Public Function IsReturnableConstruct(node As SyntaxNode) As Boolean
358Public Function HasSyntaxAnnotation([set] As HashSet(Of SyntaxAnnotation), node As SyntaxNode) As Boolean
370Public Function ToSeparatedList(Of T As SyntaxNode)(nodes As IEnumerable(Of Tuple(Of T, SyntaxToken))) As SeparatedSyntaxList(Of T)
463Public Function IsExpressionInCast(node As SyntaxNode) As Boolean
GenerateType\VisualBasicGenerateTypeService.vb (8)
381genericName.TypeArgumentList.Arguments.OfType(Of SyntaxNode)().ToList(),
382Enumerable.Repeat(Of SyntaxNode)(Nothing, state.SimpleName.Arity))
426Public Overrides Async Function GetOrGenerateEnclosingNamespaceSymbolAsync(namedTypeSymbol As INamedTypeSymbol, containers() As String, selectedDocument As Document, selectedDocumentRoot As SyntaxNode, cancellationToken As CancellationToken) As Task(Of (INamespaceSymbol, INamespaceOrTypeSymbol, Location))
468Private Shared Function GetDeclaringNamespace(containers As List(Of String), indexDone As Integer, localRoot As SyntaxNode) As NamespaceStatementSyntax
563Dim node As SyntaxNode = expression
595Private Shared Function IsAllContainingTypeBlocksPublic(node As SyntaxNode) As Boolean
620modifiedRoot As SyntaxNode,
631Dim root As SyntaxNode = Nothing
SignatureHelp\AbstractIntrinsicOperatorSignatureHelpProvider.vb (4)
12Friend MustInherit Class AbstractIntrinsicOperatorSignatureHelpProvider(Of TSyntaxNode As SyntaxNode)
19Private Function TryGetSyntaxNode(root As SyntaxNode, position As Integer, syntaxFacts As ISyntaxFactsService, triggerReason As SignatureHelpTriggerReason, cancellationToken As CancellationToken, ByRef node As TSyntaxNode) As Boolean
83Protected Overridable Function GetCurrentArgumentStateWorker(node As SyntaxNode, position As Integer) As SignatureHelpState
104Private Function GetCurrentArgumentState(root As SyntaxNode, position As Integer, syntaxFacts As ISyntaxFactsService, currentSpan As TextSpan, cancellationToken As CancellationToken) As SignatureHelpState
SplitOrMergeIfStatements\VisualBasicIfLikeStatementGenerator.vb (36)
22Public Function IsIfOrElseIf(node As SyntaxNode) As Boolean Implements IIfLikeStatementGenerator.IsIfOrElseIf
27Public Function IsCondition(expression As SyntaxNode, ByRef ifOrElseIf As SyntaxNode) As Boolean Implements IIfLikeStatementGenerator.IsCondition
46Public Function IsElseIfClause(node As SyntaxNode, ByRef parentIfOrElseIf As SyntaxNode) As Boolean Implements IIfLikeStatementGenerator.IsElseIfClause
50parentIfOrElseIf = If(index > 0, ifBlock.ElseIfBlocks(index - 1), DirectCast(ifBlock, SyntaxNode))
58Public Function HasElseIfClause(ifOrElseIf As SyntaxNode, ByRef elseIfClause As SyntaxNode) As Boolean Implements IIfLikeStatementGenerator.HasElseIfClause
77Public Function GetCondition(ifOrElseIf As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.GetCondition
87Public Function GetRootIfStatement(ifOrElseIf As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.GetRootIfStatement
97Public Function GetElseIfAndElseClauses(ifOrElseIf As SyntaxNode) As ImmutableArray(Of SyntaxNode) Implements IIfLikeStatementGenerator.GetElseIfAndElseClauses
111Private Shared Function AddIfNotNull(list As SyntaxList(Of SyntaxNode), node As SyntaxNode) As SyntaxList(Of SyntaxNode)
115Public Function WithCondition(ifOrElseIf As SyntaxNode, condition As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.WithCondition
127Public Function WithStatementInBlock(ifOrElseIf As SyntaxNode, statement As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.WithStatementInBlock
131Public Function WithStatementsOf(ifOrElseIf As SyntaxNode, otherIfOrElseIf As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.WithStatementsOf
135Public Function WithElseIfAndElseClausesOf(ifStatement As SyntaxNode, otherIfStatement As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.WithElseIfAndElseClausesOf
141Public Function ToIfStatement(ifOrElseIf As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.ToIfStatement
163Public Function ToElseIfClause(ifOrElseIf As SyntaxNode) As SyntaxNode Implements IIfLikeStatementGenerator.ToElseIfClause
180Public Sub InsertElseIfClause(editor As SyntaxEditor, afterIfOrElseIf As SyntaxNode, elseIfClause As SyntaxNode) Implements IIfLikeStatementGenerator.InsertElseIfClause
196Public Sub RemoveElseIfClause(editor As SyntaxEditor, elseIfClause As SyntaxNode) Implements IIfLikeStatementGenerator.RemoveElseIfClause
src\Analyzers\VisualBasic\Analyzers\OrderModifiers\VisualBasicOrderModifiersDiagnosticAnalyzer.vb (1)
31root As SyntaxNode)
src\Analyzers\VisualBasic\CodeFixes\ConvertToAsync\VisualBasicConvertToAsyncFunctionCodeFixProvider.vb (5)
35Protected Overrides Async Function GetDescriptionAsync(diagnostic As Diagnostic, node As SyntaxNode, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Task(Of String)
40Protected Overrides Async Function GetRootInOtherSyntaxTreeAsync(node As SyntaxNode, semanticModel As SemanticModel, diagnostic As Diagnostic, cancellationToken As CancellationToken) As Task(Of Tuple(Of SyntaxTree, SyntaxNode))
53Private Shared Async Function GetMethodFromExpressionAsync(oldNode As SyntaxNode, semanticModel As SemanticModel, cancellationToken As CancellationToken) As Task(Of Tuple(Of SyntaxNode, MethodBlockSyntax))
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (7)
25Protected Overrides Function IsImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
29Protected Overrides Function TryInitializeImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken, ByRef token As SyntaxToken, ByRef arguments As ImmutableArray(Of Argument), ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
51Protected Overrides Function IsConstructorInitializerGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
59node As SyntaxNode,
88Protected Overrides Function IsSimpleNameGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
94node As SyntaxNode,
129node As SyntaxNode,
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateConversionService.vb (9)
32Protected Overrides Function IsExplicitConversionGeneration(node As SyntaxNode) As Boolean
36Protected Overrides Function IsImplicitConversionGeneration(node As SyntaxNode) As Boolean
43Private Shared Function IsInImplementsClause(node As SyntaxNode) As Boolean
47Private Shared Function IsInMemberAccessExpression(node As SyntaxNode) As Boolean
55Protected Overrides Function TryInitializeExplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
69Protected Overrides Function TryInitializeImplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
83Private Shared Function TryGetConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
109Private Shared Function IsCastExpression(node As SyntaxNode) As Boolean
129Private Shared Function TryGetImplicitConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
CaseCorrection\AbstractCaseCorrectionService.cs (7)
20protected abstract void AddReplacements(SemanticModel? semanticModel, SyntaxNode root, ImmutableArray<TextSpan> spans, ConcurrentDictionary<SyntaxToken, SyntaxToken> replacements, CancellationToken cancellationToken);
29var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
37var newRoot = CaseCorrect(semanticModel, root, spans, cancellationToken);
41public SyntaxNode CaseCorrect(SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
44private SyntaxNode CaseCorrect(SemanticModel? semanticModel, SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
Classification\AbstractClassificationService.cs (6)
28private Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>>? _getNodeClassifiers;
186(Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>>, Func<SyntaxToken, ImmutableArray<ISyntaxClassifier>>) GetExtensionClassifiers(
204var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
209SolutionServices services, SyntaxNode? root, ImmutableArray<TextSpan> textSpans, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken)
232public TextChangeRange? ComputeSyntacticChangeRange(SolutionServices services, SyntaxNode oldRoot, SyntaxNode newRoot, TimeSpan timeout, CancellationToken cancellationToken)
Classification\SyntaxClassification\AbstractSyntaxClassificationService.cs (5)
20public abstract void AddSyntacticClassifications(SyntaxNode root, ImmutableArray<TextSpan> textSpans, SegmentedList<ClassifiedSpan> result, CancellationToken cancellationToken);
30Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>> getNodeClassifiers,
51Func<SyntaxNode, ImmutableArray<ISyntaxClassifier>> getNodeClassifiers,
60public TextChangeRange? ComputeSyntacticChangeRange(SyntaxNode oldRoot, SyntaxNode newRoot, TimeSpan timeout, CancellationToken cancellationToken)
CodeCleanup\AbstractCodeCleanerService.cs (28)
27protected abstract ImmutableArray<TextSpan> GetSpansToAvoid(SyntaxNode root);
42var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
62var annotatedRoot = newNode;
73public async Task<SyntaxNode> CleanupAsync(SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SolutionServices services, ImmutableArray<ICodeCleanupProvider> providers, CancellationToken cancellationToken)
104var annotatedRoot = newNode;
115SyntaxNode node,
149SyntaxNode node,
269private static (SyntaxNode newNode, List<(SyntaxAnnotation previous, SyntaxAnnotation next)> annotations) AnnotateNodeForTextSpans(
270SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
313var newNode = InjectAnnotations(root, tokenAnnotationMap);
321SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
359SyntaxNode root, TextSpan span,
382SyntaxNode root, TextSpan span,
404private static SyntaxToken FindTokenOnRightOfPosition(SyntaxNode root, int position)
418private static SyntaxToken FindTokenOnLeftOfPosition(SyntaxNode root, int position)
458Func<SyntaxNode, ImmutableArray<TextSpan>> spanGetter,
483var root = await currentDocument.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
521SyntaxNode root, Func<SyntaxNode, ImmutableArray<TextSpan>> spanGetter)
535private async Task<SyntaxNode> IterateAllCodeCleanupProvidersAsync(
536SyntaxNode originalRoot,
537SyntaxNode annotatedRoot,
539Func<SyntaxNode, ImmutableArray<TextSpan>> spanGetter,
546var currentRoot = annotatedRoot;
547SyntaxNode? previousRoot = null;
593private static SyntaxNode InjectAnnotations(SyntaxNode node, Dictionary<SyntaxToken, List<SyntaxAnnotation>> map)
CodeCleanup\CodeCleaner.cs (5)
62var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
87public static Task<SyntaxNode> CleanupAsync(SyntaxNode root, TextSpan span, SyntaxFormattingOptions options, SolutionServices services, ImmutableArray<ICodeCleanupProvider> providers = default, CancellationToken cancellationToken = default)
94public static Task<SyntaxNode> CleanupAsync(SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SolutionServices services, ImmutableArray<ICodeCleanupProvider> providers = default, CancellationToken cancellationToken = default)
Differencing\AbstractSyntaxComparer.cs (38)
12internal abstract class AbstractSyntaxComparer : TreeComparer<SyntaxNode>
19protected readonly SyntaxNode? _oldRoot;
20protected readonly SyntaxNode? _newRoot;
21private readonly IEnumerable<SyntaxNode>? _oldRootChildren;
22private readonly IEnumerable<SyntaxNode>? _newRootChildren;
31SyntaxNode? oldRoot,
32SyntaxNode? newRoot,
33IEnumerable<SyntaxNode>? oldRootChildren,
34IEnumerable<SyntaxNode>? newRootChildren,
45protected internal sealed override bool TreesEqual(SyntaxNode oldNode, SyntaxNode newNode)
48protected internal sealed override TextSpan GetSpan(SyntaxNode node)
55protected abstract bool TryComputeWeightedDistance(SyntaxNode oldNode, SyntaxNode newNode, out double distance);
57protected abstract bool IsLambdaBodyStatementOrExpression(SyntaxNode node);
59protected internal override bool TryGetParent(SyntaxNode node, [NotNullWhen(true)] out SyntaxNode? parent)
76protected internal override IEnumerable<SyntaxNode>? GetChildren(SyntaxNode node)
91private IEnumerable<SyntaxNode> EnumerateChildren(SyntaxNode node)
93foreach (var child in node.ChildNodes())
106foreach (var descendant in child.DescendantNodes(DescendIntoChildren))
116private bool DescendIntoChildren(SyntaxNode node)
119protected internal sealed override IEnumerable<SyntaxNode> GetDescendants(SyntaxNode node)
125private IEnumerable<SyntaxNode> EnumerateDescendants(IEnumerable<SyntaxNode> nodes)
127foreach (var node in nodes)
134foreach (var descendant in EnumerateDescendants(node))
144private IEnumerable<SyntaxNode> EnumerateDescendants(SyntaxNode node)
150var descendantNode = descendant.AsNode();
160bool ShouldEnumerateChildren(SyntaxNode child)
179protected bool HasChildren(SyntaxNode node)
195internal bool HasLabel(SyntaxNode node)
198internal abstract int Classify(int kind, SyntaxNode? node, out bool isLeaf);
200protected internal override int GetLabel(SyntaxNode node)
Editing\SyntaxEditor.cs (51)
15/// particular tree <em>in order</em>. Changes are given a <see cref="SyntaxNode"/> they will apply to in the
24/// Each change has its given <see cref="SyntaxNode"/> tracked, using a <see cref="SyntaxAnnotation"/>, producing a
32/// A change first attempts to find its <see cref="SyntaxNode"/> in the 'current' root. If that node cannot be
38/// cref="SyntaxNode"/> found in the current root. The 'current' root will then be updated by replacing the current
52/// <para/> If a client wants to make a replacement, then find the <em>value</em> <see cref="SyntaxNode"/> put into
64public SyntaxEditor(SyntaxNode root, Workspace workspace)
72public SyntaxEditor(SyntaxNode root, HostWorkspaceServices services)
80public SyntaxEditor(SyntaxNode root, SolutionServices services)
86internal SyntaxEditor(SyntaxNode root, SyntaxGenerator generator)
93/// The <see cref="SyntaxNode"/> that was specified when the <see cref="SyntaxEditor"/> was constructed.
95public SyntaxNode OriginalRoot { get; }
98/// A <see cref="SyntaxGenerator"/> to use to create and change <see cref="SyntaxNode"/>'s.
105public SyntaxNode GetChangedRoot()
109var newRoot = OriginalRoot.TrackNodes(nodes);
120public void TrackNode(SyntaxNode node)
130public void RemoveNode(SyntaxNode node)
138public void RemoveNode(SyntaxNode node, SyntaxRemoveOptions options)
150public void ReplaceNode(SyntaxNode node, Func<SyntaxNode, SyntaxGenerator, SyntaxNode> computeReplacement)
159internal void ReplaceNode(SyntaxNode node, Func<SyntaxNode, SyntaxGenerator, IEnumerable<SyntaxNode>> computeReplacement)
168internal void ReplaceNode<TArgument>(SyntaxNode node, Func<SyntaxNode, SyntaxGenerator, TArgument, SyntaxNode> computeReplacement, TArgument argument)
182public void ReplaceNode(SyntaxNode node, SyntaxNode newNode)
196public void InsertBefore(SyntaxNode node, IEnumerable<SyntaxNode> newNodes)
210public void InsertBefore(SyntaxNode node, SyntaxNode newNode)
218public void InsertAfter(SyntaxNode node, IEnumerable<SyntaxNode> newNodes)
232public void InsertAfter(SyntaxNode node, SyntaxNode newNode)
235private void CheckNodeInOriginalTree(SyntaxNode node)
246private abstract class Change(SyntaxNode node)
248internal readonly SyntaxNode OriginalNode = node;
250public SyntaxNode Apply(SyntaxNode root, SyntaxGenerator generator)
252var currentNode = root.GetCurrentNode(OriginalNode);
259protected static SyntaxNode ValidateNewRoot(SyntaxNode? root)
262protected abstract SyntaxNode Apply(SyntaxNode root, SyntaxNode currentNode, SyntaxGenerator generator);
265private sealed class NoChange(SyntaxNode node) : Change(node)
267protected override SyntaxNode Apply(SyntaxNode root, SyntaxNode currentNode, SyntaxGenerator generator)
Editing\SyntaxEditorExtensions.cs (38)
13public static void SetAccessibility(this SyntaxEditor editor, SyntaxNode declaration, Accessibility accessibility)
16public static void SetModifiers(this SyntaxEditor editor, SyntaxNode declaration, DeclarationModifiers modifiers)
19internal static void RemoveAllAttributes(this SyntaxEditor editor, SyntaxNode declaration)
22internal static void RemoveAllComments(this SyntaxEditor editor, SyntaxNode declaration)
25internal static void RemoveAllTypeInheritance(this SyntaxEditor editor, SyntaxNode declaration)
28public static void SetName(this SyntaxEditor editor, SyntaxNode declaration, string name)
31public static void SetType(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode type)
34public static void SetTypeParameters(this SyntaxEditor editor, SyntaxNode declaration, IEnumerable<string> typeParameters)
37public static void SetTypeConstraint(this SyntaxEditor editor, SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kind, IEnumerable<SyntaxNode> types)
40public static void SetExpression(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode expression)
43public static void SetStatements(this SyntaxEditor editor, SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
46public static void SetGetAccessorStatements(this SyntaxEditor editor, SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
49public static void SetSetAccessorStatements(this SyntaxEditor editor, SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
52public static void AddParameter(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode parameter)
55public static void InsertParameter(this SyntaxEditor editor, SyntaxNode declaration, int index, SyntaxNode parameter)
58public static void AddAttribute(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode attribute)
61public static void AddReturnAttribute(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode attribute)
64public static void AddAttributeArgument(this SyntaxEditor editor, SyntaxNode attributeDeclaration, SyntaxNode attributeArgument)
67public static void AddMember(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode member)
70public static void InsertMembers(this SyntaxEditor editor, SyntaxNode declaration, int index, IEnumerable<SyntaxNode> members)
73public static void AddInterfaceType(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode interfaceType)
76public static void AddBaseType(this SyntaxEditor editor, SyntaxNode declaration, SyntaxNode baseType)
79internal static void RemovePrimaryConstructor(this SyntaxEditor editor, SyntaxNode declaration)
Editing\SyntaxGenerator.cs (800)
28/// possible. For example, generating <see cref="MemberAccessExpression(SyntaxNode, string)"/>
85public SyntaxNode? GetDeclaration(SyntaxNode? node)
103public SyntaxNode? GetDeclaration(SyntaxNode? node, DeclarationKind kind)
121public abstract SyntaxNode FieldDeclaration(
123SyntaxNode type,
126SyntaxNode? initializer = null);
131public SyntaxNode FieldDeclaration(IFieldSymbol field)
135var initializer = field.HasConstantValue ? this.LiteralExpression(field.ConstantValue, canUseFieldReference) : null;
142public SyntaxNode FieldDeclaration(IFieldSymbol field, SyntaxNode? initializer)
160public SyntaxNode MethodDeclaration(
162IEnumerable<SyntaxNode>? parameters = null,
164SyntaxNode? returnType = null,
167IEnumerable<SyntaxNode>? statements = null)
174private protected abstract SyntaxNode MethodDeclaration(
176IEnumerable<SyntaxNode>? parameters,
177IEnumerable<SyntaxNode>? typeParameters,
178SyntaxNode? returnType,
181IEnumerable<SyntaxNode>? statements);
186public SyntaxNode MethodDeclaration(IMethodSymbol method, IEnumerable<SyntaxNode>? statements = null)
189internal SyntaxNode MethodDeclaration(IMethodSymbol method, string name, IEnumerable<SyntaxNode>? statements = null)
191var decl = MethodDeclaration(
255public virtual SyntaxNode OperatorDeclaration(
257IEnumerable<SyntaxNode>? parameters = null,
258SyntaxNode? returnType = null,
261IEnumerable<SyntaxNode>? statements = null)
266private protected abstract SyntaxNode OperatorDeclaration(
269IEnumerable<SyntaxNode>? parameters = null,
270SyntaxNode? returnType = null,
273IEnumerable<SyntaxNode>? statements = null);
278public SyntaxNode OperatorDeclaration(IMethodSymbol method, IEnumerable<SyntaxNode>? statements = null)
283var decl = OperatorDeclaration(
299public SyntaxNode ParameterDeclaration(
301SyntaxNode? type = null,
302SyntaxNode? initializer = null,
309private protected abstract SyntaxNode ParameterDeclaration(
311SyntaxNode? type,
312SyntaxNode? initializer,
321public SyntaxNode ParameterDeclaration(IParameterSymbol symbol, SyntaxNode? initializer = null)
335private protected abstract SyntaxNode TypeParameter(ITypeParameterSymbol typeParameter);
336private protected abstract SyntaxNode TypeParameter(string name);
338private protected abstract SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference);
353public abstract SyntaxNode PropertyDeclaration(
355SyntaxNode type,
358IEnumerable<SyntaxNode>? getAccessorStatements = null,
359IEnumerable<SyntaxNode>? setAccessorStatements = null);
364public SyntaxNode PropertyDeclaration(
366IEnumerable<SyntaxNode>? getAccessorStatements = null,
367IEnumerable<SyntaxNode>? setAccessorStatements = null)
373SyntaxNode? getAccessor = null;
374SyntaxNode? setAccessor = null;
391var propDecl = PropertyDeclaration(
408private protected abstract SyntaxNode PropertyDeclaration(
410SyntaxNode type,
411SyntaxNode? getAccessor,
412SyntaxNode? setAccessor,
416public SyntaxNode WithAccessorDeclarations(SyntaxNode declaration, params SyntaxNode[] accessorDeclarations)
417=> WithAccessorDeclarations(declaration, (IEnumerable<SyntaxNode>)accessorDeclarations);
419public abstract SyntaxNode WithAccessorDeclarations(SyntaxNode declaration, IEnumerable<SyntaxNode> accessorDeclarations);
421public abstract SyntaxNode GetAccessorDeclaration(
423IEnumerable<SyntaxNode>? statements = null);
425public SyntaxNode SetAccessorDeclaration(
427IEnumerable<SyntaxNode>? statements = null)
430private protected abstract SyntaxNode SetAccessorDeclaration(
431Accessibility accessibility, bool isInitOnly, IEnumerable<SyntaxNode>? statements);
436public abstract SyntaxNode IndexerDeclaration(
437IEnumerable<SyntaxNode> parameters,
438SyntaxNode type,
441IEnumerable<SyntaxNode>? getAccessorStatements = null,
442IEnumerable<SyntaxNode>? setAccessorStatements = null);
447public SyntaxNode IndexerDeclaration(
449IEnumerable<SyntaxNode>? getAccessorStatements = null,
450IEnumerable<SyntaxNode>? setAccessorStatements = null)
452var indexerDecl = IndexerDeclaration(
472public abstract SyntaxNode AddEventHandler(SyntaxNode @event, SyntaxNode handler);
477public abstract SyntaxNode RemoveEventHandler(SyntaxNode @event, SyntaxNode handler);
482public abstract SyntaxNode EventDeclaration(
484SyntaxNode type,
491public SyntaxNode EventDeclaration(IEventSymbol symbol)
493var ev = EventDeclaration(
511public abstract SyntaxNode CustomEventDeclaration(
513SyntaxNode type,
516IEnumerable<SyntaxNode>? parameters = null,
517IEnumerable<SyntaxNode>? addAccessorStatements = null,
518IEnumerable<SyntaxNode>? removeAccessorStatements = null);
523public SyntaxNode CustomEventDeclaration(
525IEnumerable<SyntaxNode>? addAccessorStatements = null,
526IEnumerable<SyntaxNode>? removeAccessorStatements = null)
544public abstract SyntaxNode ConstructorDeclaration(
546IEnumerable<SyntaxNode>? parameters = null,
549IEnumerable<SyntaxNode>? baseConstructorArguments = null,
550IEnumerable<SyntaxNode>? statements = null);
555public SyntaxNode ConstructorDeclaration(
557IEnumerable<SyntaxNode>? baseConstructorArguments = null,
558IEnumerable<SyntaxNode>? statements = null)
569private protected abstract SyntaxNode DestructorDeclaration(IMethodSymbol destructorMethod);
575public SyntaxNode? AsPublicInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType)
582public abstract SyntaxNode? AsPublicInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType, string? interfaceMemberName);
588public SyntaxNode? AsPrivateInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType)
595public abstract SyntaxNode? AsPrivateInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType, string? interfaceMemberName);
600public SyntaxNode ClassDeclaration(
605SyntaxNode? baseType = null,
606IEnumerable<SyntaxNode>? interfaceTypes = null,
607IEnumerable<SyntaxNode>? members = null)
613private protected abstract SyntaxNode ClassDeclaration(
616IEnumerable<SyntaxNode>? typeParameters,
619SyntaxNode? baseType,
620IEnumerable<SyntaxNode>? interfaceTypes,
621IEnumerable<SyntaxNode>? members);
626public SyntaxNode StructDeclaration(
631IEnumerable<SyntaxNode>? interfaceTypes = null,
632IEnumerable<SyntaxNode>? members = null)
638private protected abstract SyntaxNode StructDeclaration(
641IEnumerable<SyntaxNode>? typeParameters,
644IEnumerable<SyntaxNode>? interfaceTypes,
645IEnumerable<SyntaxNode>? members);
650public SyntaxNode InterfaceDeclaration(
654IEnumerable<SyntaxNode>? interfaceTypes = null,
655IEnumerable<SyntaxNode>? members = null)
661private protected abstract SyntaxNode InterfaceDeclaration(
663IEnumerable<SyntaxNode>? typeParameters,
665IEnumerable<SyntaxNode>? interfaceTypes,
666IEnumerable<SyntaxNode>? members);
671public abstract SyntaxNode EnumDeclaration(
675IEnumerable<SyntaxNode>? members = null);
680internal abstract SyntaxNode EnumDeclaration(
682SyntaxNode? underlyingType,
685IEnumerable<SyntaxNode>? members = null);
690public abstract SyntaxNode EnumMember(string name, SyntaxNode? expression = null);
695public SyntaxNode DelegateDeclaration(
697IEnumerable<SyntaxNode>? parameters = null,
699SyntaxNode? returnType = null,
707private protected abstract SyntaxNode DelegateDeclaration(
709IEnumerable<SyntaxNode>? parameters,
710IEnumerable<SyntaxNode>? typeParameters,
711SyntaxNode? returnType,
718public SyntaxNode Declaration(ISymbol symbol)
759var declaration = type.TypeKind switch
861private SyntaxNode WithTypeParametersAndConstraints(SyntaxNode declaration, ImmutableArray<ITypeParameterSymbol> typeParameters)
887internal abstract SyntaxNode WithExplicitInterfaceImplementations(
888SyntaxNode declaration, ImmutableArray<ISymbol> explicitInterfaceImplementations, bool removeDefaults = true);
893public SyntaxNode WithTypeParameters(SyntaxNode declaration, IEnumerable<string> typeParameters)
896private protected abstract SyntaxNode WithTypeParameters(SyntaxNode declaration, IEnumerable<SyntaxNode> typeParameters);
901public SyntaxNode WithTypeParameters(SyntaxNode declaration, params string[] typeParameters)
908public SyntaxNode WithTypeConstraint(SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, IEnumerable<SyntaxNode>? types = null)
912private protected abstract SyntaxNode WithTypeConstraint(
913SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, bool isUnamangedType, IEnumerable<SyntaxNode>? types);
915private protected abstract SyntaxNode WithDefaultConstraint(SyntaxNode declaration, string typeParameterName);
920public SyntaxNode WithTypeConstraint(SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, params SyntaxNode[] types)
921=> WithTypeConstraint(declaration, typeParameterName, kinds, (IEnumerable<SyntaxNode>)types);
926public SyntaxNode WithTypeConstraint(SyntaxNode declaration, string typeParameterName, params SyntaxNode[] types)
927=> WithTypeConstraint(declaration, typeParameterName, SpecialTypeConstraintKind.None, (IEnumerable<SyntaxNode>)types);
934public abstract SyntaxNode NamespaceDeclaration(SyntaxNode name, IEnumerable<SyntaxNode> declarations);
941public SyntaxNode NamespaceDeclaration(SyntaxNode name, params SyntaxNode[] declarations)
942=> NamespaceDeclaration(name, (IEnumerable<SyntaxNode>)declarations);
949public SyntaxNode NamespaceDeclaration(string name, IEnumerable<SyntaxNode> declarations)
957public SyntaxNode NamespaceDeclaration(string name, params SyntaxNode[] declarations)
958=> NamespaceDeclaration(DottedName(name), (IEnumerable<SyntaxNode>)declarations);
964public abstract SyntaxNode CompilationUnit(IEnumerable<SyntaxNode> declarations);
970public SyntaxNode CompilationUnit(params SyntaxNode[] declarations)
971=> CompilationUnit((IEnumerable<SyntaxNode>)declarations);
977public abstract SyntaxNode NamespaceImportDeclaration(SyntaxNode name);
983public SyntaxNode NamespaceImportDeclaration(string name)
991public SyntaxNode AliasImportDeclaration(string aliasIdentifierName, INamespaceOrTypeSymbol symbol)
999public abstract SyntaxNode AliasImportDeclaration(string aliasIdentifierName, SyntaxNode name);
1004public abstract SyntaxNode Attribute(SyntaxNode name, IEnumerable<SyntaxNode>? attributeArguments = null);
1009public SyntaxNode Attribute(string name, IEnumerable<SyntaxNode>? attributeArguments = null)
1015public SyntaxNode Attribute(string name, params SyntaxNode[] attributeArguments)
1016=> Attribute(name, (IEnumerable<SyntaxNode>)attributeArguments);
1021public SyntaxNode Attribute(AttributeData attribute)
1037public abstract SyntaxNode AttributeArgument(string? name, SyntaxNode expression);
1042public SyntaxNode AttributeArgument(SyntaxNode expression)
1048public SyntaxNode RemoveAllAttributes(SyntaxNode declaration)
1055internal abstract SyntaxNode RemoveAllComments(SyntaxNode node);
1057internal SyntaxNode RemovePrimaryConstructor(SyntaxNode declaration)
1059var node = GetPrimaryConstructorParameterList(declaration);
1063internal abstract SyntaxNode? GetPrimaryConstructorParameterList(SyntaxNode declaration);
1065internal SyntaxNode RemoveLeadingAndTrailingComments(SyntaxNode node)
1081internal SyntaxNode RemoveAllTypeInheritance(SyntaxNode declaration)
1084internal abstract ImmutableArray<SyntaxNode> GetTypeInheritance(SyntaxNode declaration);
1089public abstract IReadOnlyList<SyntaxNode> GetAttributes(SyntaxNode declaration);
1094public abstract SyntaxNode InsertAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes);
1099public SyntaxNode InsertAttributes(SyntaxNode declaration, int index, params SyntaxNode[] attributes)
1100=> this.InsertAttributes(declaration, index, (IEnumerable<SyntaxNode>)attributes);
1105public SyntaxNode AddAttributes(SyntaxNode declaration, IEnumerable<SyntaxNode> attributes)
1111public SyntaxNode AddAttributes(SyntaxNode declaration, params SyntaxNode[] attributes)
1112=> AddAttributes(declaration, (IEnumerable<SyntaxNode>)attributes);
1117public abstract IReadOnlyList<SyntaxNode> GetReturnAttributes(SyntaxNode declaration);
1122public abstract SyntaxNode InsertReturnAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes);
1127public SyntaxNode InsertReturnAttributes(SyntaxNode declaration, int index, params SyntaxNode[] attributes)
1128=> this.InsertReturnAttributes(declaration, index, (IEnumerable<SyntaxNode>)attributes);
1133public SyntaxNode AddReturnAttributes(SyntaxNode declaration, IEnumerable<SyntaxNode> attributes)
1139public SyntaxNode AddReturnAttributes(SyntaxNode declaration, params SyntaxNode[] attributes)
1140=> AddReturnAttributes(declaration, (IEnumerable<SyntaxNode>)attributes);
1145public abstract IReadOnlyList<SyntaxNode> GetAttributeArguments(SyntaxNode attributeDeclaration);
1150public abstract SyntaxNode InsertAttributeArguments(SyntaxNode attributeDeclaration, int index, IEnumerable<SyntaxNode> attributeArguments);
1155public SyntaxNode AddAttributeArguments(SyntaxNode attributeDeclaration, IEnumerable<SyntaxNode> attributeArguments)
1161public abstract IReadOnlyList<SyntaxNode> GetNamespaceImports(SyntaxNode declaration);
1166public abstract SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports);
1171public SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, params SyntaxNode[] imports)
1172=> this.InsertNamespaceImports(declaration, index, (IEnumerable<SyntaxNode>)imports);
1177public SyntaxNode AddNamespaceImports(SyntaxNode declaration, IEnumerable<SyntaxNode> imports)
1183public SyntaxNode AddNamespaceImports(SyntaxNode declaration, params SyntaxNode[] imports)
1184=> this.AddNamespaceImports(declaration, (IEnumerable<SyntaxNode>)imports);
1189public abstract IReadOnlyList<SyntaxNode> GetMembers(SyntaxNode declaration);
1194public abstract SyntaxNode InsertMembers(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> members);
1199public SyntaxNode InsertMembers(SyntaxNode declaration, int index, params SyntaxNode[] members)
1200=> this.InsertMembers(declaration, index, (IEnumerable<SyntaxNode>)members);
1205public SyntaxNode AddMembers(SyntaxNode declaration, IEnumerable<SyntaxNode> members)
1211public SyntaxNode AddMembers(SyntaxNode declaration, params SyntaxNode[] members)
1212=> this.AddMembers(declaration, (IEnumerable<SyntaxNode>)members);
1217public abstract Accessibility GetAccessibility(SyntaxNode declaration);
1222public abstract SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibility accessibility);
1227public abstract DeclarationModifiers GetModifiers(SyntaxNode declaration);
1232public abstract SyntaxNode WithModifiers(SyntaxNode declaration, DeclarationModifiers modifiers);
1237public abstract DeclarationKind GetDeclarationKind(SyntaxNode declaration);
1242public abstract string GetName(SyntaxNode declaration);
1247public abstract SyntaxNode WithName(SyntaxNode declaration, string name);
1252public abstract SyntaxNode? GetType(SyntaxNode declaration);
1257public abstract SyntaxNode WithType(SyntaxNode declaration, SyntaxNode type);
1262public abstract IReadOnlyList<SyntaxNode> GetParameters(SyntaxNode declaration);
1264internal abstract SyntaxNode? GetParameterListNode(SyntaxNode declaration);
1269public abstract SyntaxNode InsertParameters(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> parameters);
1274public SyntaxNode AddParameters(SyntaxNode declaration, IEnumerable<SyntaxNode> parameters)
1280public abstract IReadOnlyList<SyntaxNode> GetSwitchSections(SyntaxNode switchStatement);
1285public abstract SyntaxNode InsertSwitchSections(SyntaxNode switchStatement, int index, IEnumerable<SyntaxNode> switchSections);
1290public SyntaxNode AddSwitchSections(SyntaxNode switchStatement, IEnumerable<SyntaxNode> switchSections)
1296public abstract SyntaxNode? GetExpression(SyntaxNode declaration);
1301public abstract SyntaxNode WithExpression(SyntaxNode declaration, SyntaxNode expression);
1306public abstract IReadOnlyList<SyntaxNode> GetStatements(SyntaxNode declaration);
1311public abstract SyntaxNode WithStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements);
1316public abstract IReadOnlyList<SyntaxNode> GetAccessors(SyntaxNode declaration);
1321public SyntaxNode? GetAccessor(SyntaxNode declaration, DeclarationKind kind)
1327public abstract SyntaxNode InsertAccessors(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> accessors);
1332public SyntaxNode AddAccessors(SyntaxNode declaration, IEnumerable<SyntaxNode> accessors)
1338public abstract IReadOnlyList<SyntaxNode> GetGetAccessorStatements(SyntaxNode declaration);
1343public abstract SyntaxNode WithGetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements);
1348public abstract IReadOnlyList<SyntaxNode> GetSetAccessorStatements(SyntaxNode declaration);
1353public abstract SyntaxNode WithSetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements);
1358public abstract IReadOnlyList<SyntaxNode> GetBaseAndInterfaceTypes(SyntaxNode declaration);
1363public abstract SyntaxNode AddBaseType(SyntaxNode declaration, SyntaxNode baseType);
1368public abstract SyntaxNode AddInterfaceType(SyntaxNode declaration, SyntaxNode interfaceType);
1370internal abstract SyntaxNode AsInterfaceMember(SyntaxNode member);
1379public virtual SyntaxNode ReplaceNode(SyntaxNode root, SyntaxNode node, SyntaxNode? newDeclaration)
1382internal static SyntaxNode ReplaceNode(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> newDeclarations)
1391public virtual SyntaxNode InsertNodesBefore(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> newDeclarations)
1397public virtual SyntaxNode InsertNodesAfter(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> newDeclarations)
1403public virtual SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node)
1409public virtual SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node, SyntaxRemoveOptions options)
1415public SyntaxNode RemoveNodes(SyntaxNode root, IEnumerable<SyntaxNode> declarations)
1417var newRoot = root.TrackNodes(declarations);
1419foreach (var declaration in declarations)
1421var newDeclaration = newRoot.GetCurrentNode(declaration);
1437internal abstract SeparatedSyntaxList<TElement> SeparatedList<TElement>(SyntaxNodeOrTokenList list) where TElement : SyntaxNode;
1439internal abstract SeparatedSyntaxList<TElement> SeparatedList<TElement>(IEnumerable<TElement> nodes, IEnumerable<SyntaxToken> separators) where TElement : SyntaxNode;
1464protected static SyntaxNode? PreserveTrivia<TNode>(TNode? node, Func<TNode, SyntaxNode> nodeChanger) where TNode : SyntaxNode
1473var changedNode = nodeChanger(nodeWithoutTrivia);
1484protected static SyntaxNode ReplaceWithTrivia(SyntaxNode root, SyntaxNode original, SyntaxNode replacement)
1486var combinedTriviaReplacement =
1493protected static SyntaxNode ReplaceWithTrivia<TNode>(SyntaxNode root, TNode original, Func<TNode, SyntaxNode> replacer)
1494where TNode : SyntaxNode
1499protected static SyntaxNode ReplaceWithTrivia(SyntaxNode root, SyntaxToken original, SyntaxToken replacement)
1512public abstract TNode ClearTrivia<TNode>([MaybeNull] TNode node) where TNode : SyntaxNode;
1529protected static SyntaxNode ReplaceRange(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> replacements)
1531var first = replacements.First();
1532var trackedFirst = first.TrackNodes(first);
1533var newRoot = root.ReplaceNode(node, trackedFirst);
1534var currentFirst = newRoot.GetCurrentNode(first);
1541where TNode : SyntaxNode
1552where TNode : SyntaxNode
1570public abstract SyntaxNode ExpressionStatement(SyntaxNode expression);
1576public abstract SyntaxNode ReturnStatement(SyntaxNode? expression = null);
1582internal SyntaxNode YieldReturnStatement(SyntaxNode expression)
1589public abstract SyntaxNode ThrowStatement(SyntaxNode? expression = null);
1594public abstract SyntaxNode ThrowExpression(SyntaxNode expression);
1605/// <see cref="LocalDeclarationStatement(ITypeSymbol, string, SyntaxNode, bool)"/>.
1613public abstract SyntaxNode LocalDeclarationStatement(
1614SyntaxNode? type, string identifier, SyntaxNode? initializer = null, bool isConst = false);
1616internal SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken identifier, SyntaxNode? initializer = null, bool isConst = false)
1619internal SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer)
1622internal SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
1628public SyntaxNode LocalDeclarationStatement(ITypeSymbol type, string name, SyntaxNode? initializer = null, bool isConst = false)
1634public SyntaxNode LocalDeclarationStatement(string name, SyntaxNode initializer)
1635=> LocalDeclarationStatement(type: (SyntaxNode?)null, name, initializer);
1640internal SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initializer)
1649public abstract SyntaxNode IfStatement(
1650SyntaxNode condition, IEnumerable<SyntaxNode> trueStatements, IEnumerable<SyntaxNode>? falseStatements = null);
1658public SyntaxNode IfStatement(SyntaxNode condition, IEnumerable<SyntaxNode> trueStatements, SyntaxNode falseStatement)
1664public abstract SyntaxNode SwitchStatement(SyntaxNode expression, IEnumerable<SyntaxNode> sections);
1669public SyntaxNode SwitchStatement(SyntaxNode expression, params SyntaxNode[] sections)
1670=> SwitchStatement(expression, (IEnumerable<SyntaxNode>)sections);
1675public abstract SyntaxNode SwitchSection(IEnumerable<SyntaxNode> caseExpressions, IEnumerable<SyntaxNode> statements);
1677internal abstract SyntaxNode SwitchSectionFromLabels(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements);
1682public SyntaxNode SwitchSection(SyntaxNode caseExpression, IEnumerable<SyntaxNode> statements)
1688public abstract SyntaxNode DefaultSwitchSection(IEnumerable<SyntaxNode> statements);
1693public abstract SyntaxNode ExitSwitchStatement();
1698public abstract SyntaxNode UsingStatement(SyntaxNode? type, string name, SyntaxNode expression, IEnumerable<SyntaxNode> statements);
1703public SyntaxNode UsingStatement(string name, SyntaxNode expression, IEnumerable<SyntaxNode> statements)
1709public abstract SyntaxNode UsingStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements);
1714public abstract SyntaxNode LockStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements);
1719public abstract SyntaxNode TryCatchStatement(IEnumerable<SyntaxNode> tryStatements, IEnumerable<SyntaxNode>? catchClauses, IEnumerable<SyntaxNode>? finallyStatements = null);
1724public SyntaxNode TryCatchStatement(IEnumerable<SyntaxNode> tryStatements, params SyntaxNode[] catchClauses)
1725=> TryCatchStatement(tryStatements, (IEnumerable<SyntaxNode>?)catchClauses);
1730public SyntaxNode TryFinallyStatement(IEnumerable<SyntaxNode> tryStatements, IEnumerable<SyntaxNode> finallyStatements)
1736public abstract SyntaxNode CatchClause(SyntaxNode type, string identifier, IEnumerable<SyntaxNode> statements);
1741public SyntaxNode CatchClause(ITypeSymbol type, string identifier, IEnumerable<SyntaxNode> statements)
1747public abstract SyntaxNode WhileStatement(SyntaxNode condition, IEnumerable<SyntaxNode> statements);
1752internal abstract SyntaxNode ScopeBlock(IEnumerable<SyntaxNode> statements);
1754internal abstract SyntaxNode GlobalStatement(SyntaxNode statement);
1764internal SyntaxNode InterpolatedStringText(SyntaxToken textToken)
1766internal SyntaxNode Interpolation(SyntaxNode syntaxNode)
1768internal SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
1770internal SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment)
1772internal SyntaxNode InterpolationFormatClause(string format)
1779public abstract SyntaxNode DefaultExpression(SyntaxNode type);
1780public abstract SyntaxNode DefaultExpression(ITypeSymbol type);
1785public abstract SyntaxNode ThisExpression();
1790public abstract SyntaxNode BaseExpression();
1795public SyntaxNode LiteralExpression(object? value)
1801private SyntaxNode LiteralExpression(object? value, bool canUseFieldReference)
1807public abstract SyntaxNode TypedConstantExpression(TypedConstant value);
1812public SyntaxNode FalseLiteralExpression()
1818public SyntaxNode TrueLiteralExpression()
1824public SyntaxNode NullLiteralExpression()
1832public abstract SyntaxNode IdentifierName(string identifier);
1834internal abstract SyntaxNode IdentifierName(SyntaxToken identifier);
1836internal abstract SyntaxNode NamedAnonymousObjectMemberDeclarator(SyntaxNode identifier, SyntaxNode expression);
1841public abstract SyntaxNode GenericName(string identifier, IEnumerable<SyntaxNode> typeArguments);
1843internal abstract SyntaxNode GenericName(SyntaxToken identifier, IEnumerable<SyntaxNode> typeArguments);
1848public SyntaxNode GenericName(string identifier, IEnumerable<ITypeSymbol> typeArguments)
1854public SyntaxNode GenericName(string identifier, params SyntaxNode[] typeArguments)
1855=> GenericName(identifier, (IEnumerable<SyntaxNode>)typeArguments);
1860public SyntaxNode GenericName(string identifier, params ITypeSymbol[] typeArguments)
1867public abstract SyntaxNode WithTypeArguments(SyntaxNode expression, IEnumerable<SyntaxNode> typeArguments);
1873public SyntaxNode WithTypeArguments(SyntaxNode expression, params SyntaxNode[] typeArguments)
1874=> WithTypeArguments(expression, (IEnumerable<SyntaxNode>)typeArguments);
1881public abstract SyntaxNode QualifiedName(SyntaxNode left, SyntaxNode right);
1886internal abstract SyntaxNode GlobalAliasedName(SyntaxNode name);
1891public SyntaxNode DottedName(string dottedName)
1901SyntaxNode? name = null;
1925public abstract SyntaxNode NameExpression(INamespaceOrTypeSymbol namespaceOrTypeSymbol);
1930public SyntaxNode TypeExpression(ITypeSymbol typeSymbol)
1933private protected abstract SyntaxNode TypeExpression(ITypeSymbol typeSymbol, RefKind refKind);
1940public SyntaxNode TypeExpression(ITypeSymbol typeSymbol, bool addImport)
1942var expression = TypeExpression(typeSymbol);
1951public abstract SyntaxNode TypeExpression(SpecialType specialType);
1956public abstract SyntaxNode ArrayTypeExpression(SyntaxNode type);
1961public abstract SyntaxNode NullableTypeExpression(SyntaxNode type);
1966public SyntaxNode TupleTypeExpression(IEnumerable<SyntaxNode> elements)
1981internal abstract SyntaxNode CreateTupleType(IEnumerable<SyntaxNode> elements);
1986public SyntaxNode TupleTypeExpression(params SyntaxNode[] elements)
1987=> TupleTypeExpression((IEnumerable<SyntaxNode>)elements);
1992public SyntaxNode TupleTypeExpression(IEnumerable<ITypeSymbol> elementTypes, IEnumerable<string>? elementNames = null)
2016public abstract SyntaxNode TupleElementExpression(SyntaxNode type, string? name = null);
2021public SyntaxNode TupleElementExpression(ITypeSymbol type, string? name = null)
2028public abstract SyntaxNode AssignmentStatement(SyntaxNode left, SyntaxNode right);
2033public abstract SyntaxNode ValueEqualsExpression(SyntaxNode left, SyntaxNode right);
2038public abstract SyntaxNode ReferenceEqualsExpression(SyntaxNode left, SyntaxNode right);
2043public abstract SyntaxNode ValueNotEqualsExpression(SyntaxNode left, SyntaxNode right);
2048public abstract SyntaxNode ReferenceNotEqualsExpression(SyntaxNode left, SyntaxNode right);
2053public abstract SyntaxNode LessThanExpression(SyntaxNode left, SyntaxNode right);
2058public abstract SyntaxNode LessThanOrEqualExpression(SyntaxNode left, SyntaxNode right);
2063public abstract SyntaxNode GreaterThanExpression(SyntaxNode left, SyntaxNode right);
2068public abstract SyntaxNode GreaterThanOrEqualExpression(SyntaxNode left, SyntaxNode right);
2073public abstract SyntaxNode NegateExpression(SyntaxNode expression);
2078public abstract SyntaxNode AddExpression(SyntaxNode left, SyntaxNode right);
2083public abstract SyntaxNode SubtractExpression(SyntaxNode left, SyntaxNode right);
2088public abstract SyntaxNode MultiplyExpression(SyntaxNode left, SyntaxNode right);
2093public abstract SyntaxNode DivideExpression(SyntaxNode left, SyntaxNode right);
2098public abstract SyntaxNode ModuloExpression(SyntaxNode left, SyntaxNode right);
2103public abstract SyntaxNode BitwiseAndExpression(SyntaxNode left, SyntaxNode right);
2108public abstract SyntaxNode BitwiseOrExpression(SyntaxNode left, SyntaxNode right);
2113public abstract SyntaxNode BitwiseNotExpression(SyntaxNode operand);
2118public abstract SyntaxNode LogicalAndExpression(SyntaxNode left, SyntaxNode right);
2123public abstract SyntaxNode LogicalOrExpression(SyntaxNode left, SyntaxNode right);
2128public abstract SyntaxNode LogicalNotExpression(SyntaxNode expression);
2133public abstract SyntaxNode ConditionalExpression(SyntaxNode condition, SyntaxNode whenTrue, SyntaxNode whenFalse);
2138/// cref="ElementBindingExpression(IEnumerable{SyntaxNode})"/> to generate the <paramref
2141public abstract SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull);
2146public abstract SyntaxNode MemberBindingExpression(SyntaxNode name);
2151public abstract SyntaxNode ElementBindingExpression(IEnumerable<SyntaxNode> arguments);
2156public SyntaxNode ElementBindingExpression(params SyntaxNode[] arguments)
2157=> ElementBindingExpression((IEnumerable<SyntaxNode>)arguments);
2162public abstract SyntaxNode CoalesceExpression(SyntaxNode left, SyntaxNode right);
2167public virtual SyntaxNode MemberAccessExpression(SyntaxNode? expression, SyntaxNode memberName)
2173internal abstract SyntaxNode MemberAccessExpressionWorker(SyntaxNode? expression, SyntaxNode memberName);
2175internal SyntaxNode RefExpression(SyntaxNode expression)
2181public SyntaxNode MemberAccessExpression(SyntaxNode? expression, string memberName)
2187public abstract SyntaxNode ArrayCreationExpression(SyntaxNode elementType, SyntaxNode size);
2192public abstract SyntaxNode ArrayCreationExpression(SyntaxNode elementType, IEnumerable<SyntaxNode> elements);
2197public abstract SyntaxNode ObjectCreationExpression(SyntaxNode namedType, IEnumerable<SyntaxNode> arguments);
2199internal abstract SyntaxNode ObjectCreationExpression(
2200SyntaxNode namedType, SyntaxToken openParen, SeparatedSyntaxList<SyntaxNode> arguments, SyntaxToken closeParen);
2205public SyntaxNode ObjectCreationExpression(ITypeSymbol type, IEnumerable<SyntaxNode> arguments)
2211public SyntaxNode ObjectCreationExpression(SyntaxNode type, params SyntaxNode[] arguments)
2212=> ObjectCreationExpression(type, (IEnumerable<SyntaxNode>)arguments);
2217public SyntaxNode ObjectCreationExpression(ITypeSymbol type, params SyntaxNode[] arguments)
2218=> ObjectCreationExpression(type, (IEnumerable<SyntaxNode>)arguments);
2223public abstract SyntaxNode InvocationExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments);
2228public SyntaxNode InvocationExpression(SyntaxNode expression, params SyntaxNode[] arguments)
2229=> InvocationExpression(expression, (IEnumerable<SyntaxNode>)arguments);
2234public abstract SyntaxNode Argument(string? name, RefKind refKind, SyntaxNode expression);
2239public SyntaxNode Argument(RefKind refKind, SyntaxNode expression)
2245public SyntaxNode Argument(SyntaxNode expression)
2251public abstract SyntaxNode ElementAccessExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments);
2256public SyntaxNode ElementAccessExpression(SyntaxNode expression, params SyntaxNode[] arguments)
2257=> ElementAccessExpression(expression, (IEnumerable<SyntaxNode>)arguments);
2262public abstract SyntaxNode TypeOfExpression(SyntaxNode type);
2267public abstract SyntaxNode IsTypeExpression(SyntaxNode expression, SyntaxNode type);
2272public SyntaxNode IsTypeExpression(SyntaxNode expression, ITypeSymbol type)
2278public abstract SyntaxNode TryCastExpression(SyntaxNode expression, SyntaxNode type);
2283public SyntaxNode TryCastExpression(SyntaxNode expression, ITypeSymbol type)
2289public abstract SyntaxNode CastExpression(SyntaxNode type, SyntaxNode expression);
2294public SyntaxNode CastExpression(ITypeSymbol type, SyntaxNode expression)
2300public abstract SyntaxNode ConvertExpression(SyntaxNode type, SyntaxNode expression);
2305public SyntaxNode ConvertExpression(ITypeSymbol type, SyntaxNode expression)
2311public abstract SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, SyntaxNode expression);
2316public abstract SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, SyntaxNode expression);
2321public abstract SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, IEnumerable<SyntaxNode> statements);
2326public abstract SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, IEnumerable<SyntaxNode> statements);
2331public SyntaxNode ValueReturningLambdaExpression(string parameterName, SyntaxNode expression)
2337public SyntaxNode VoidReturningLambdaExpression(string parameterName, SyntaxNode expression)
2343public SyntaxNode ValueReturningLambdaExpression(string parameterName, IEnumerable<SyntaxNode> statements)
2349public SyntaxNode VoidReturningLambdaExpression(string parameterName, IEnumerable<SyntaxNode> statements)
2355public SyntaxNode ValueReturningLambdaExpression(SyntaxNode expression)
2356=> ValueReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, expression);
2361public SyntaxNode VoidReturningLambdaExpression(SyntaxNode expression)
2362=> VoidReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, expression);
2367public SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode> statements)
2368=> ValueReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, statements);
2373public SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode> statements)
2374=> VoidReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, statements);
2379public abstract SyntaxNode LambdaParameter(string identifier, SyntaxNode? type = null);
2384public SyntaxNode LambdaParameter(string identifier, ITypeSymbol type)
2390public abstract SyntaxNode AwaitExpression(SyntaxNode expression);
2395internal SyntaxNode AddParentheses(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
2401public abstract SyntaxNode NameOfExpression(SyntaxNode expression);
2406public abstract SyntaxNode TupleExpression(IEnumerable<SyntaxNode> arguments);
2411internal abstract SyntaxNode ParseExpression(string stringToParse);
2413internal abstract SyntaxTrivia Trivia(SyntaxNode node);
2415internal abstract SyntaxNode DocumentationCommentTrivia(IEnumerable<SyntaxNode> nodes, SyntaxTriviaList trailingTrivia, string endOfLineString);
2417internal abstract SyntaxNode? DocumentationCommentTriviaWithUpdatedContent(SyntaxTrivia trivia, IEnumerable<SyntaxNode> content);
FindSymbols\FindReferences\Finders\AbstractReferenceFinder.cs (15)
54ISymbol searchSymbol, FindReferencesDocumentState state, SyntaxNode node, CancellationToken cancellationToken)
218SyntaxNode node,
227var directive = node.GetRequiredParent();
368SyntaxNode node, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData);
403SyntaxNode node, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData)
442SyntaxNode node, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData)
485SyntaxNode node, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData)
523SyntaxNode node, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData)
554SyntaxNode node, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData)
598SyntaxNode node,
606var topNameNode = node;
627else if (node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>((node, syntaxFacts) => syntaxFacts.IsUsingOrExternOrImport(node), syntaxFacts) != null)
731private static bool IsNodeOrAnyAncestorLeftSideOfDot(SyntaxNode node, ISyntaxFactsService syntaxFacts)
749SyntaxNode node, FindReferencesDocumentState state)
766void TryAddAdditionalProperty(SyntaxNode? node, string key)
FindSymbols\FindReferences\Finders\PropertySymbolReferenceFinder.cs (12)
89var constructorSyntax = constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
232private static (bool matched, CandidateReason reason, SyntaxNode indexerReference) ComputeIndexerInformation(
235SyntaxNode node,
260private static (bool matched, CandidateReason reason, SyntaxNode indexerReference) ComputeIndexerMemberCRefInformation(
261IPropertySymbol symbol, FindReferencesDocumentState state, SyntaxNode node, CancellationToken cancellationToken)
269private static (bool matched, CandidateReason reason, SyntaxNode indexerReference) ComputeConditionalAccessInformation(
270IPropertySymbol symbol, SyntaxNode node, FindReferencesDocumentState state, CancellationToken cancellationToken)
274syntaxFacts.GetPartsOfConditionalAccessExpression(node, out _, out var indexerReference);
288private static (bool matched, CandidateReason reason, SyntaxNode? indexerReference) ComputeElementAccessInformation(
289IPropertySymbol symbol, SyntaxNode node, FindReferencesDocumentState state, CancellationToken cancellationToken)
305private static (bool matched, CandidateReason reason, SyntaxNode indexerReference) ComputeImplicitElementAccessInformation(
306IPropertySymbol symbol, SyntaxNode node, FindReferencesDocumentState state, CancellationToken cancellationToken)
FindSymbols\SyntaxTree\SyntaxTreeIndex_Create.cs (16)
41ProjectState project, SyntaxNode root, Checksum checksum, CancellationToken _)
87var node = current.AsNode();
213private static bool IsGlobalSuppressMessageAttribute(ISyntaxFactsService syntaxFacts, SyntaxNode node)
218var name = syntaxFacts.GetNameOfAttribute(node);
221syntaxFacts.GetPartsOfQualifiedName(name, out _, out _, out var right);
239SyntaxNode node)
256foreach (var attributeList in attributeLists)
258foreach (var attribute in syntaxFacts.GetAttributesOfAttributeList(attributeList))
260syntaxFacts.GetPartsOfAttribute(attribute, out var attributeName, out var argumentList);
268var versionArg = syntaxFacts.GetExpressionOfAttributeArgument(arguments[0]);
269var dataArg = syntaxFacts.GetExpressionOfAttributeArgument(arguments[1]);
284syntaxFacts.GetPartsOfQualifiedName(attributeName, out _, out _, out var right);
308SyntaxNode node)
313syntaxFacts.GetPartsOfUsingAliasDirective(node, out var globalToken, out var alias, out var usingTarget);
318syntaxFacts.GetPartsOfQualifiedName(usingTarget, out _, out _, out var right);
Formatting\Formatter.cs (35)
94var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
115var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
132var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
151public static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
154internal static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken)
157private static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, Workspace workspace, OptionSet? options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
177internal static SyntaxNode Format(SyntaxNode node, SyntaxAnnotation annotation, SolutionServices services, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
188public static SyntaxNode Format(SyntaxNode node, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
191internal static SyntaxNode Format(SyntaxNode node, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken)
203public static SyntaxNode Format(SyntaxNode node, TextSpan span, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
206internal static SyntaxNode Format(SyntaxNode node, TextSpan span, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken)
218public static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
221private static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
227internal static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
230private static IFormattingResult? GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
254internal static IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
268public static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
271internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken)
283public static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, TextSpan span, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
286internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, TextSpan span, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken = default)
298public static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
301internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken = default)
304private static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
312internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken = default)
LanguageServices\DeclaredSymbolFactoryService\AbstractDeclaredSymbolInfoFactoryService.cs (10)
25where TCompilationUnitSyntax : SyntaxNode
26where TUsingDirectiveSyntax : SyntaxNode
31where TMemberDeclarationSyntax : SyntaxNode
32where TNameSyntax : SyntaxNode
68SyntaxNode container, TTypeDeclarationSyntax typeDeclaration, StringTable stringTable, string containerDisplayName, string fullyQualifiedContainerName);
70SyntaxNode container, TEnumDeclarationSyntax enumDeclaration, StringTable stringTable, string containerDisplayName, string fullyQualifiedContainerName);
72SyntaxNode container, TMemberDeclarationSyntax memberDeclaration, StringTable stringTable, ArrayBuilder<DeclaredSymbolInfo> declaredSymbolInfos, string containerDisplayName, string fullyQualifiedContainerName);
76SyntaxNode container, TMemberDeclarationSyntax memberDeclaration, StringTable stringTable, ArrayBuilder<DeclaredSymbolInfo> declaredSymbolInfos, string containerDisplayName, string fullyQualifiedContainerName, CancellationToken cancellationToken);
154SyntaxNode root,
175SyntaxNode container,
SemanticModelReuse\AbstractSemanticModelReuseLanguageService.cs (15)
19where TMemberDeclarationSyntax : SyntaxNode
21where TAccessorDeclarationSyntax : SyntaxNode
27public abstract SyntaxNode? TryGetContainingMethodBodyForSpeculation(SyntaxNode node);
29protected abstract SemanticModel? TryGetSpeculativeSemanticModelWorker(SemanticModel previousSemanticModel, SyntaxNode previousBodyNode, SyntaxNode currentBodyNode);
42public async Task<SemanticModel?> TryGetSpeculativeSemanticModelAsync(SemanticModel previousSemanticModel, SyntaxNode currentBodyNode, CancellationToken cancellationToken)
56var previousRoot = await previousSemanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
57var currentRoot = await currentBodyNode.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
58var previousBodyNode = GetPreviousBodyNode(previousRoot, currentRoot, currentBodyNode);
80protected SyntaxNode GetPreviousBodyNode(SyntaxNode previousRoot, SyntaxNode currentRoot, SyntaxNode currentBodyNode)
88var previousContainer = GetPreviousBodyNode(previousRoot, currentRoot, currentContainer);
Simplification\Simplifier.cs (15)
62public static async Task<TNode> ExpandAsync<TNode>(TNode node, Document document, Func<SyntaxNode, bool>? expandInsideNode = null, bool expandParameter = false, CancellationToken cancellationToken = default) where TNode : SyntaxNode
81public static TNode Expand<TNode>(TNode node, SemanticModel semanticModel, Workspace workspace, Func<SyntaxNode, bool>? expandInsideNode = null, bool expandParameter = false, CancellationToken cancellationToken = default) where TNode : SyntaxNode
92internal static TNode Expand<TNode>(TNode node, SemanticModel semanticModel, SolutionServices services, Func<SyntaxNode, bool>? expandInsideNode = null, bool expandParameter = false, CancellationToken cancellationToken = default) where TNode : SyntaxNode
103var result = services.GetRequiredLanguageService<ISimplificationService>(node.Language)
112public static async Task<SyntaxToken> ExpandAsync(SyntaxToken token, Document document, Func<SyntaxNode, bool>? expandInsideNode = null, CancellationToken cancellationToken = default)
126public static SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Workspace workspace, Func<SyntaxNode, bool>? expandInsideNode = null, CancellationToken cancellationToken = default)
137internal static SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, SolutionServices services, Func<SyntaxNode, bool>? expandInsideNode = null, CancellationToken cancellationToken = default)
159var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
167var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
187var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
195var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
248var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (10)
150public static SyntaxNode GetAnalysisRoot(this SyntaxTreeAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
156public static SyntaxNode GetAnalysisRoot(this SemanticModelAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
164public static SyntaxNode GetAnalysisRoot(this SymbolStartAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
176public static SyntaxNode GetAnalysisRoot(this SymbolAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
186public static SyntaxNode GetAnalysisRoot(this OperationBlockStartAnalysisContext context, IOperation operationBlock, bool findInTrivia, bool getInnermostNodeForTie = false)
192public static SyntaxNode GetAnalysisRoot(this OperationBlockAnalysisContext context, IOperation operationBlock, bool findInTrivia, bool getInnermostNodeForTie = false)
198public static SyntaxNode GetAnalysisRoot(this OperationAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
204public static SyntaxNode GetAnalysisRoot(this SyntaxNodeAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
210public static SyntaxNode GetAnalysisRoot<TSyntaxKind>(this CodeBlockStartAnalysisContext<TSyntaxKind> context, bool findInTrivia, bool getInnermostNodeForTie = false) where TSyntaxKind : struct
216public static SyntaxNode GetAnalysisRoot(this CodeBlockAnalysisContext context, bool findInTrivia, bool getInnermostNodeForTie = false)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SemanticModelExtensions.cs (18)
35public static DataFlowAnalysis AnalyzeRequiredDataFlow(this SemanticModel semanticModel, SyntaxNode statementOrExpression)
38public static DataFlowAnalysis AnalyzeRequiredDataFlow(this SemanticModel semanticModel, SyntaxNode firstStatement, SyntaxNode lastStatement)
41public static ControlFlowAnalysis AnalyzeRequiredControlFlow(this SemanticModel semanticModel, SyntaxNode statement)
44public static ControlFlowAnalysis AnalyzeRequiredControlFlow(this SemanticModel semanticModel, SyntaxNode firstStatement, SyntaxNode lastStatement)
47public static ISymbol GetRequiredDeclaredSymbol(this SemanticModel semanticModel, SyntaxNode declaration, CancellationToken cancellationToken)
53public static IOperation GetRequiredOperation(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
94this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func<SyntaxNode, bool>? descendInto = null)
116this SemanticModel semanticModel, SyntaxNode? container, CancellationToken cancellationToken, Func<SyntaxNode, bool>? filter = null)
128SemanticModel semanticModel, SyntaxNode node,
129HashSet<ISymbol> symbols, CancellationToken cancellationToken, Func<SyntaxNode, bool>? descendInto = null)
140if (child.AsNode(out var childNode) &&
147static bool ShouldDescendInto(SyntaxNode node, Func<SyntaxNode, bool>? filter)
233SyntaxNode expression,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (111)
23public static SyntaxNode GetRequiredParent(this SyntaxNode node)
26public static IEnumerable<SyntaxNodeOrToken> DepthFirstTraversal(this SyntaxNode node)
29public static IEnumerable<SyntaxNode> DepthFirstTraversalNodes(this SyntaxNode node)
32public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxNode node)
34var current = node.Parent;
44public static IEnumerable<TNode> GetAncestors<TNode>(this SyntaxNode node)
45where TNode : SyntaxNode
47var current = node.Parent;
59public static TNode? GetAncestor<TNode>(this SyntaxNode node)
60where TNode : SyntaxNode
62var current = node.Parent;
76public static TNode? GetAncestorOrThis<TNode>(this SyntaxNode? node)
77where TNode : SyntaxNode
82public static IEnumerable<TNode> GetAncestorsOrThis<TNode>(this SyntaxNode? node)
83where TNode : SyntaxNode
85var current = node;
97public static bool HasAncestor<TNode>(this SyntaxNode node)
98where TNode : SyntaxNode
104this SyntaxNode node, TextSpan searchSpan, Func<SyntaxNode, bool> predicate)
105where TSyntaxNode : SyntaxNode
109var nodes = new LinkedList<SyntaxNode>();
114var currentNode = nodes.First!.Value;
129public static bool CheckParent<T>([NotNullWhen(returnValue: true)] this SyntaxNode? node, Func<T, bool> valueChecker) where T : SyntaxNode
145public static bool IsChildNode<TParent>(this SyntaxNode node, Func<TParent, SyntaxNode?> childGetter)
146where TParent : SyntaxNode
154var ancestorNode = childGetter(ancestor);
162public static bool IsFoundUnder<TParent>(this SyntaxNode node, Func<TParent, SyntaxNode?> childGetter)
163where TParent : SyntaxNode
171var child = childGetter(ancestor);
174return node.GetAncestorsOrThis<SyntaxNode>().Contains(child);
177public static SyntaxNode GetCommonRoot(this SyntaxNode node1, SyntaxNode node2)
183using var _ = PooledHashSet<SyntaxNode>.GetInstance(out var set);
184set.AddRange(node2.GetAncestorsOrThis<SyntaxNode>());
186foreach (var ancestor in node1.AncestorsAndSelf())
195public static int Width(this SyntaxNode node)
198public static int FullWidth(this SyntaxNode node)
201public static SyntaxNode? FindInnermostCommonNode(this IEnumerable<SyntaxNode> nodes, Func<SyntaxNode, bool> predicate)
204public static SyntaxNode? FindInnermostCommonNode(this IEnumerable<SyntaxNode> nodes)
214using var _1 = ArrayBuilder<SyntaxNode>.GetInstance(out var commonAncestorsStack);
215using var _2 = PooledHashSet<SyntaxNode>.GetInstance(out var commonAncestorsSet);
218foreach (var node in nodes)
239var commonAncestor = FindCommonAncestor(node, commonAncestorsSet);
281static SyntaxNode? FindCommonAncestor(SyntaxNode node, HashSet<SyntaxNode> commonAncestorsSet)
293public static TSyntaxNode? FindInnermostCommonNode<TSyntaxNode>(this IEnumerable<SyntaxNode> nodes) where TSyntaxNode : SyntaxNode
296public static TextSpan GetContainedSpan(this IEnumerable<SyntaxNode> nodes)
302foreach (var node in nodes)
312public static bool OverlapsHiddenPosition(this SyntaxNode node, CancellationToken cancellationToken)
315public static bool OverlapsHiddenPosition(this SyntaxNode node, TextSpan span, CancellationToken cancellationToken)
318public static bool OverlapsHiddenPosition(this SyntaxNode declaration, SyntaxNode startNode, SyntaxNode endNode, CancellationToken cancellationToken)
327public static IEnumerable<T> GetAnnotatedNodes<T>(this SyntaxNode node, SyntaxAnnotation syntaxAnnotation) where T : SyntaxNode
341IEnumerable<SyntaxNode> nodes,
342Func<SyntaxNode, SyntaxNode, CancellationToken, Task<SyntaxNode>> computeReplacementAsync,
343CancellationToken cancellationToken) where TRootNode : SyntaxNode
365CancellationToken cancellationToken) where TRootNode : SyntaxNode
378CancellationToken cancellationToken) where TRoot : SyntaxNode
389IEnumerable<SyntaxNode>? nodes,
390Func<SyntaxNode, SyntaxNode, CancellationToken, Task<SyntaxNode>>? computeReplacementNodeAsync,
396where TRoot : SyntaxNode
403var nodeReplacements = new Dictionary<SyntaxNode, SyntaxNode>();
441var original = (SyntaxNode?)retryAnnotations.GetAnnotations(currentNode).SingleOrDefault() ?? currentNode;
472if (rewritten != original || !nodeReplacements.TryGetValue(original, out var replaced))
598SyntaxNode root,
614this SyntaxNode root,
653this SyntaxNode root,
690params SyntaxTrivia[] trivia) where T : SyntaxNode
702SyntaxTriviaList trivia) where T : SyntaxNode
714IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode
724params SyntaxTrivia[] trivia) where T : SyntaxNode
736SyntaxTriviaList trivia) where T : SyntaxNode
748IEnumerable<SyntaxTrivia> trivia) where T : SyntaxNode
759IEnumerable<SyntaxTrivia> trailingTrivia) where T : SyntaxNode
784public static SyntaxNode FindNode(this SyntaxNode root, TextSpan? span, bool findInTrivia, bool getInnermostNodeForTie)
792public static SyntaxNode? GetParent(this SyntaxNode node, bool ascendOutOfTrivia)
794var parent = node.Parent;
806public static TNode? FirstAncestorOrSelfUntil<TNode>(this SyntaxNode? node, Func<SyntaxNode, bool> predicate)
807where TNode : SyntaxNode
809for (var current = node; current != null; current = current.GetParent(ascendOutOfTrivia: true))
826SyntaxNode root,
829where TDirectiveTriviaSyntax : SyntaxNode
835where TDirectiveTriviaSyntax : SyntaxNode
855SyntaxNode root,
946public static ValueAncestorsAndSelfEnumerable ValueAncestorsAndSelf(this SyntaxNode syntaxNode, bool ascendOutOfTrivia = true)
949public readonly struct ValueAncestorsAndSelfEnumerable(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
954public struct Enumerator(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
956public SyntaxNode Current { get; private set; } = null!;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxTokenExtensions.cs (12)
15public static SyntaxNode? GetAncestor(this SyntaxToken token, Func<SyntaxNode, bool>? predicate)
16=> token.GetAncestor<SyntaxNode>(predicate);
18public static T? GetAncestor<T>(this SyntaxToken token, Func<T, bool>? predicate = null) where T : SyntaxNode
21public static T GetRequiredAncestor<T>(this SyntaxToken token, Func<T, bool>? predicate = null) where T : SyntaxNode
25where T : SyntaxNode
32public static IEnumerable<SyntaxNode> GetAncestors(this SyntaxToken token, Func<SyntaxNode, bool> predicate)
39public static SyntaxNode? GetCommonRoot(this SyntaxToken token1, SyntaxToken token2)
53public static bool CheckParent<T>(this SyntaxToken token, Func<T, bool> valueChecker) where T : SyntaxNode
69public static SyntaxToken FindTokenFromEnd(this SyntaxNode root, int position, bool includeZeroWidth = true, bool findInsideTrivia = false)
164public static SyntaxNode GetRequiredParent(this SyntaxToken token)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\AbstractSyntaxFormatting.cs (3)
28protected abstract IFormattingResult CreateAggregatedFormattingResult(SyntaxNode node, IList<AbstractFormattingResult> results, TextSpanMutableIntervalTree? formattingSpans = null);
30protected abstract AbstractFormattingResult Format(SyntaxNode node, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, SyntaxToken startToken, SyntaxToken endToken, CancellationToken cancellationToken);
32public IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan>? spans, SyntaxFormattingOptions options, ImmutableArray<AbstractFormattingRule> rules, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\BaseIndentationFormattingRule.cs (7)
19private readonly SyntaxNode? _commonNode;
22public BaseIndentationFormattingRule(SyntaxNode root, TextSpan span, int baseIndentation, AbstractFormattingRule? vbHelperFormattingRule = null)
31public override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
54private void AddNextIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
133private static void SetInnermostNodeForSpan(SyntaxNode root, ref TextSpan span, out SyntaxToken token1, out SyntaxToken token2, out SyntaxNode? commonNode)
149private static void GetTokens(SyntaxNode root, TextSpan span, out SyntaxToken token1, out SyntaxToken token2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\CompatAbstractFormattingRule.cs (8)
17public sealed override void AddSuppressOperations(ArrayBuilder<SuppressOperation> list, SyntaxNode node, in NextSuppressOperationAction nextOperation)
25public sealed override void AddAnchorIndentationOperations(List<AnchorIndentationOperation> list, SyntaxNode node, in NextAnchorIndentationOperationAction nextOperation)
33public sealed override void AddIndentBlockOperations(List<IndentBlockOperation> list, SyntaxNode node, in NextIndentBlockOperationAction nextOperation)
41public sealed override void AddAlignTokensOperations(List<AlignTokensOperation> list, SyntaxNode node, in NextAlignTokensOperationAction nextOperation)
72public virtual void AddSuppressOperationsSlow(ArrayBuilder<SuppressOperation> list, SyntaxNode node, ref NextSuppressOperationAction nextOperation)
78public virtual void AddAnchorIndentationOperationsSlow(List<AnchorIndentationOperation> list, SyntaxNode node, ref NextAnchorIndentationOperationAction nextOperation)
84public virtual void AddIndentBlockOperationsSlow(List<IndentBlockOperation> list, SyntaxNode node, ref NextIndentBlockOperationAction nextOperation)
90public virtual void AddAlignTokensOperationsSlow(List<AlignTokensOperation> list, SyntaxNode node, ref NextAlignTokensOperationAction nextOperation)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextAlignTokensOperationAction.cs (1)
15SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextAnchorIndentationOperationAction.cs (1)
15SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextIndentBlockOperationAction.cs (1)
15SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\NextSuppressOperationAction.cs (1)
16SyntaxNode node,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Helpers\RemoveUnnecessaryImports\AbstractUnnecessaryImportsProvider.cs (4)
18where TSyntaxNode : SyntaxNode
21SemanticModel model, Func<SyntaxNode, bool>? predicate, CancellationToken cancellationToken);
27SemanticModel model, TextSpan? span, Func<SyntaxNode, bool>? predicate, CancellationToken cancellationToken)
32var node = model.SyntaxTree.FindNode(span, findInTrivia: false, getInnermostNodeForTie: false, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\HeaderFacts\AbstractHeaderFacts.cs (28)
23public abstract bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
24public abstract bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration);
25public abstract bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter);
26public abstract bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method);
27public abstract bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction);
28public abstract bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration);
29public abstract bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement);
30public abstract bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement);
31public abstract bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement);
33public bool IsOnHeader(SyntaxNode root, int position, SyntaxNode ownerOfHeader, SyntaxNodeOrToken lastTokenOrNodeOfHeader)
34=> IsOnHeader(root, position, ownerOfHeader, lastTokenOrNodeOfHeader, ImmutableArray<SyntaxNode>.Empty);
37SyntaxNode root,
39SyntaxNode ownerOfHeader,
42where THoleSyntax : SyntaxNode
71protected TNode? TryGetAncestorForLocation<TNode>(SyntaxNode root, int position) where TNode : SyntaxNode
89protected int GetStartOfNodeExcludingAttributes(SyntaxNode root, SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\HeaderFacts\IHeaderFacts.cs (18)
16bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
18bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration);
19bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter);
20bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method);
21bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction);
22bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration);
23bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement);
24bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement);
25bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SemanticFacts\ISemanticFacts.cs (23)
53bool IsWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
60bool IsOnlyWrittenTo(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
61bool IsInOutContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
62bool IsInRefContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
63bool IsInInContext(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
65bool CanReplaceWithRValue(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? expression, CancellationToken cancellationToken);
74bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, [NotNullWhen(true)] out SemanticModel? speculativeModel);
81ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode forEachStatement);
82SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
84IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node);
86ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node);
88ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node);
92IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken);
94IParameterSymbol? FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken);
95IParameterSymbol? FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken);
97ISymbol? FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken);
98ISymbol? FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argument, CancellationToken cancellationToken);
100ImmutableArray<ISymbol> GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode? node, SyntaxToken token, CancellationToken cancellationToken);
102bool IsInsideNameOfExpression(SemanticModel semanticModel, [NotNullWhen(true)] SyntaxNode? node, CancellationToken cancellationToken);
109bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, [NotNullWhen(true)] INamedTypeSymbol? expressionType, CancellationToken cancellationToken);
111string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken);
122IPreprocessingSymbol? GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFacts.cs (294)
116bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node);
117bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node, PredefinedType type);
166bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node);
167bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node);
168bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node);
169bool IsDeclaration([NotNullWhen(true)] SyntaxNode? node);
170bool IsTypeDeclaration(SyntaxNode node);
172bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node);
177bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes);
181bool IsDocumentationComment(SyntaxNode node);
188bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? directive, out ExternalSourceInfo info);
190bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node);
192bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node);
193bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node);
195bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node);
196SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement);
198void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
199out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode;
201bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node);
204bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node);
206bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
207bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
208void GetPartsOfAssignmentStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
209void GetPartsOfAssignmentExpressionOrStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
212bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node);
214bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node);
215SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node);
217bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node);
218bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node);
219bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node);
221bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node);
222SyntaxNode? GetRightSideOfDot(SyntaxNode? node);
236SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget = false);
238bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node);
240bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
241bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
242bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
251SyntaxNode? GetStandaloneExpression(SyntaxNode? node);
260SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node);
269SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget = false);
271SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node);
273SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node);
275bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
277bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node);
278bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node);
279SyntaxNode? GetParameterList(SyntaxNode node);
280bool IsParameterList([NotNullWhen(true)] SyntaxNode? node);
284void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList);
286SyntaxNode GetExpressionOfArgument(SyntaxNode node);
287SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node);
288SyntaxNode GetExpressionOfInterpolation(SyntaxNode node);
290bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node);
291bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
292bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node);
294SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node);
295SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node);
296SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node);
297SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node);
303bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node);
304bool IsArgument([NotNullWhen(true)] SyntaxNode? node);
305bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node);
306RefKind GetRefKindOfArgument(SyntaxNode node);
308void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity);
309bool LooksGeneric(SyntaxNode simpleName);
311SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName);
313SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString);
315SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode node);
316SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode node);
317SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode node);
319bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node);
322SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node);
323SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node);
325bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node);
326bool IsMemberInitializerNamedAssignmentIdentifier([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance);
327bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression);
329bool IsDirective([NotNullWhen(true)] SyntaxNode? node);
330bool IsStatement([NotNullWhen(true)] SyntaxNode? node);
331bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node);
332bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node);
333SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node);
334bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement);
336bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node);
337bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node);
351bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node);
353bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement);
354SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node);
355SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node);
356SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node);
361bool IsElementAccessExpression([NotNullWhen(true)] SyntaxNode? node);
379bool IsInStaticContext(SyntaxNode node);
380bool IsUnsafeContext(SyntaxNode node);
382bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node);
384bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node);
386bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node);
387bool IsInConstructor(SyntaxNode node);
388bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node);
389bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node);
392bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2);
394string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null);
397SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position);
398SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
399SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
400SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node);
404SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false);
407PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root);
409PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root);
410SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration);
413bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span);
418/// Given a <see cref="SyntaxNode"/>, return the <see cref="TextSpan"/> representing the span of the member body
424TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node);
432SyntaxNode? TryGetBindableParent(SyntaxToken token);
435IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken);
438/// Given a <see cref="SyntaxNode"/>, that represents and argument return the string representation of
442string GetNameForArgument(SyntaxNode? argument);
445/// Given a <see cref="SyntaxNode"/>, that represents an attribute argument return the string representation of
449string GetNameForAttributeArgument(SyntaxNode? argument);
451bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node);
452bool IsPropertyPatternClause(SyntaxNode node);
454bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node);
455bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node);
456bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node);
458SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node);
459SyntaxNode GetTypeOfTypePattern(SyntaxNode node);
461void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen);
462void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
463void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation);
464void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation);
465void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression);
466void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern);
470SyntaxTokenList GetModifiers(SyntaxNode? node);
474SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers);
477Location GetDeconstructionReferenceLocation(SyntaxNode node);
482bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node);
484SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia);
490bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node);
491bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node);
492bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node);
493bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node);
494bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
495bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node);
496bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node);
497bool IsAnyName([NotNullWhen(true)] SyntaxNode? node);
498bool IsAnyType([NotNullWhen(true)] SyntaxNode? node);
500bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
501bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node);
503bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
504bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node);
510void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type);
511void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken);
512void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList);
513void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members);
514void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer);
515void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
516void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression);
517void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members);
518void GetPartsOfConditionalAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull);
519void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse);
520void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments);
521void GetPartsOfInterpolationExpression(SyntaxNode node, out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken);
522void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList);
523void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right);
524void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name);
525void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode name, out SyntaxNode expression);
526void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer);
527void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer);
528void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default);
529void GetPartsOfParenthesizedExpression(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen);
530void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand);
531void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken dotToken, out SyntaxNode right);
532void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name);
542SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node);
544SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node);
545SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node);
546SyntaxNode GetExpressionOfRefExpression(SyntaxNode node);
547SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node);
548SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node);
549SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node);
551bool IsEqualsValueOfPropertyDeclaration([NotNullWhen(true)] SyntaxNode? node);
552SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node);
554SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node);
555SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node);
557SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (199)
23public static bool IsMemberInitializerNamedAssignmentIdentifier(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
26public static bool IsOnSingleLine(this ISyntaxFacts syntaxFacts, SyntaxNode node, bool fullSpan)
62var currentNode = currentNodeOrToken.AsNode()!;
160this ISyntaxFacts syntaxFacts, ImmutableArray<SyntaxNode> nodes, CancellationToken cancellationToken)
166foreach (var node in nodes)
178public static bool ContainsInterleavedDirective(this ISyntaxFacts syntaxFacts, SyntaxNode node, CancellationToken cancellationToken)
182this ISyntaxFacts syntaxFacts, TextSpan span, SyntaxNode node, CancellationToken cancellationToken)
193public static bool SpansPreprocessorDirective(this ISyntaxFacts syntaxFacts, IEnumerable<SyntaxNode> nodes)
286public static SyntaxNode? WalkDownParentheses(this ISyntaxFacts syntaxFacts, SyntaxNode? node)
290syntaxFacts.GetPartsOfParenthesizedExpression(node, out _, out var child, out _);
298public static SyntaxNode? WalkUpParentheses(this ISyntaxFacts syntaxFacts, SyntaxNode? node)
307this ISyntaxFacts syntaxFacts, SyntaxNode statement,
308out SyntaxNode left, out SyntaxNode right)
313public static SyntaxNode GetExpressionOfInvocationExpression(
314this ISyntaxFacts syntaxFacts, SyntaxNode node)
316syntaxFacts.GetPartsOfInvocationExpression(node, out var expression, out _);
320public static SyntaxNode Unparenthesize(
321this ISyntaxFacts syntaxFacts, SyntaxNode node)
324SyntaxNode operand;
348var resultNode = operand
383public static bool SpansPreprocessorDirective(this ISyntaxFacts service, SyntaxNode node)
386public static bool SpansPreprocessorDirective(this ISyntaxFacts service, params SyntaxNode[] nodes)
387=> service.SpansPreprocessorDirective((IEnumerable<SyntaxNode>)nodes);
392public static void GetPartsOfBinaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node, out SyntaxNode left, out SyntaxNode right)
395public static SyntaxNode GetPatternOfParenthesizedPattern(this ISyntaxFacts syntaxFacts, SyntaxNode node)
397syntaxFacts.GetPartsOfParenthesizedPattern(node, out _, out var pattern, out _);
401public static SyntaxToken GetOperatorTokenOfBinaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
407public static bool IsAnonymousOrLocalFunction(this ISyntaxFacts syntaxFacts, SyntaxNode node)
411public static SyntaxNode? GetExpressionOfElementAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
413syntaxFacts.GetPartsOfElementAccessExpression(node, out var expression, out _);
417public static SyntaxNode? GetArgumentListOfElementAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
419syntaxFacts.GetPartsOfElementAccessExpression(node, out _, out var argumentList);
423public static SyntaxNode GetExpressionOfConditionalAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
425syntaxFacts.GetPartsOfConditionalAccessExpression(node, out var expression, out _);
429public static SyntaxToken GetOperatorTokenOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
435public static void GetPartsOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node, out SyntaxNode expression, out SyntaxNode name)
438public static void GetPartsOfConditionalAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node, out SyntaxNode expression, out SyntaxNode whenNotNull)
441public static TextSpan GetSpanWithoutAttributes(this ISyntaxFacts syntaxFacts, SyntaxNode root, SyntaxNode node)
468/// Similar to <see cref="ISyntaxFacts.GetStandaloneExpression(SyntaxNode)"/>, this gets the containing
478public static SyntaxNode GetRootStandaloneExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
481var standalone = syntaxFacts.GetStandaloneExpression(node);
489public static SyntaxNode? GetArgumentListOfInvocationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
491syntaxFacts.GetPartsOfInvocationExpression(node, out _, out var argumentList);
495public static SeparatedSyntaxList<SyntaxNode> GetArgumentsOfInvocationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
497var argumentList = syntaxFacts.GetArgumentListOfInvocationExpression(node);
501public static SyntaxNode? GetArgumentListOfBaseObjectCreationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
503syntaxFacts.GetPartsOfBaseObjectCreationExpression(node, out var argumentList, out _);
507public static SyntaxNode? GetDefaultOfParameter(this ISyntaxFacts syntaxFacts, SyntaxNode node)
509syntaxFacts.GetPartsOfParameter(node, out _, out var @default);
513public static SyntaxNode GetExpressionOfParenthesizedExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
515syntaxFacts.GetPartsOfParenthesizedExpression(node, out _, out var expression, out _);
519public static SyntaxToken GetIdentifierOfGenericName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
525public static SyntaxToken GetIdentifierOfIdentifierName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
528public static SyntaxToken GetIdentifierOfParameter(this ISyntaxFacts syntaxFacts, SyntaxNode node)
534public static SyntaxList<SyntaxNode> GetImportsOfBaseNamespaceDeclaration(this ISyntaxFacts syntaxFacts, SyntaxNode node)
540public static SyntaxList<SyntaxNode> GetImportsOfCompilationUnit(this ISyntaxFacts syntaxFacts, SyntaxNode node)
546public static SyntaxNode? GetInitializerOfBaseObjectCreationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
548syntaxFacts.GetPartsOfBaseObjectCreationExpression(node, out _, out var initializer);
552public static SyntaxList<SyntaxNode> GetMembersOfBaseNamespaceDeclaration(this ISyntaxFacts syntaxFacts, SyntaxNode node)
558public static SyntaxList<SyntaxNode> GetMembersOfCompilationUnit(this ISyntaxFacts syntaxFacts, SyntaxNode node)
564public static SyntaxNode GetNameOfAttribute(this ISyntaxFacts syntaxFacts, SyntaxNode node)
566syntaxFacts.GetPartsOfAttribute(node, out var name, out _);
570public static SyntaxNode GetNameOfBaseNamespaceDeclaration(this ISyntaxFacts syntaxFacts, SyntaxNode node)
572syntaxFacts.GetPartsOfBaseNamespaceDeclaration(node, out var name, out _, out _);
576public static SyntaxNode GetNameOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
578syntaxFacts.GetPartsOfMemberAccessExpression(node, out _, out var name);
582public static SyntaxNode GetOperandOfPrefixUnaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
584syntaxFacts.GetPartsOfPrefixUnaryExpression(node, out _, out var operand);
588public static SyntaxToken GetOperatorTokenOfPrefixUnaryExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
594public static SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(this ISyntaxFacts syntaxFacts, SyntaxNode node)
600public static SyntaxNode GetTypeOfObjectCreationExpression(this ISyntaxFacts syntaxFacts, SyntaxNode node)
602syntaxFacts.GetPartsOfObjectCreationExpression(node, out _, out var type, out _, out _);
610public static bool IsExpressionOfAwaitExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
612var parent = node?.Parent;
619public static bool IsExpressionOfInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
621var parent = node?.Parent;
625syntaxFacts.GetPartsOfInvocationExpression(parent, out var expression, out _);
629public static bool IsExpressionOfMemberAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
631var parent = node?.Parent;
635syntaxFacts.GetPartsOfMemberAccessExpression(parent, out var expression, out _);
639public static bool IsNameOfAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
644syntaxFacts.GetPartsOfAttribute(node.Parent, out var name, out _);
648public static bool IsRightOfQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
650var parent = node?.Parent;
654syntaxFacts.GetPartsOfQualifiedName(parent, out _, out _, out var right);
658public static bool IsTypeOfObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
660var parent = node?.Parent;
664syntaxFacts.GetPartsOfObjectCreationExpression(parent, out _, out var type, out _, out _);
695public static bool IsSkippedTokensTrivia(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
735public static bool IsGenericName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
738public static bool IsIdentifierName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
741public static bool IsQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
748public static bool IsTupleType(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
755public static bool IsCharacterLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
758public static bool IsDefaultLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
761public static bool IsFalseLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
764public static bool IsNumericLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
767public static bool IsNullLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
770public static bool IsStringLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
773public static bool IsTrueLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
780public static bool IsArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
783public static bool IsAwaitExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
786public static bool IsBaseExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
789public static bool IsConditionalExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
792public static bool IsConditionalAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
795public static bool IsImplicitArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
798public static bool IsImplicitObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
801public static bool IsIndexExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
804public static bool IsInterpolatedStringExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
807public static bool IsInterpolation(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
810public static bool IsInterpolatedStringText(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
813public static bool IsInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
816public static bool IsIsTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
819public static bool IsIsNotTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
822public static bool IsIsPatternExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
825public static bool IsLogicalAndExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
828public static bool IsLogicalOrExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
831public static bool IsLogicalNotExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
834public static bool IsObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
837public static bool IsParenthesizedExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
840public static bool IsQueryExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
843public static bool IsRangeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
846public static bool IsRefExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
849public static bool IsSimpleMemberAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
852public static bool IsThisExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
855public static bool IsThrowExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
858public static bool IsTupleExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
861public static bool ContainsGlobalStatement(this ISyntaxFacts syntaxFacts, SyntaxNode node)
868public static bool IsAndPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
871public static bool IsConstantPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
874public static bool IsDeclarationPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
877public static bool IsListPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
880public static bool IsNotPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
883public static bool IsOrPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
886public static bool IsParenthesizedPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
889public static bool IsRecursivePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
892public static bool IsRelationalPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
895public static bool IsTypePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
898public static bool IsVarPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
905public static bool IsExpressionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
908public static bool IsForEachStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
911public static bool IsForStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
914public static bool IsIfStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
917public static bool IsLocalDeclarationStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
920public static bool IsLocalFunctionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
923public static bool IsLockStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
926public static bool IsReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
929public static bool IsThrowStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
932public static bool IsUsingStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
935public static bool IsWhileStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
938public static bool IsYieldReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
945public static bool IsAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
948public static bool IsClassDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
951public static bool IsConstructorDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
954public static bool IsEnumDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
957public static bool IsGlobalAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
960public static bool IsInterfaceDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
963public static bool IsParameter(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
966public static bool IsTypeConstraint(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
969public static bool IsVariableDeclarator(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
972public static bool IsFieldDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
975public static bool IsPropertyDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
978public static bool IsStructDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
981public static bool IsTypeArgumentList(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
988public static bool IsElseClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
990public static bool IsEqualsValueClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
997public static bool IsImplicitElementAccess(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1000public static bool IsIndexerMemberCref(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (39)
35where TExpressionSyntax : SyntaxNode
37where TAttributeSyntax : SyntaxNode
38where TArgumentSyntax : SyntaxNode
39where TForEachStatementSyntax : SyntaxNode
40where TThrowStatementSyntax : SyntaxNode
49private SyntaxNode? _lazySemanticRootOfOriginalExpression;
51private SyntaxNode? _lazySemanticRootOfReplacedExpression;
97protected abstract SyntaxNode GetSemanticRootForSpeculation(TExpressionSyntax expression);
98protected abstract SemanticModel CreateSpeculativeSemanticModel(SyntaxNode originalNode, SyntaxNode nodeToSpeculate, SemanticModel semanticModel);
101protected abstract bool ExpressionMightReferenceMember([NotNullWhen(true)] SyntaxNode? node);
116protected abstract bool ReplacementChangesSemanticsForNodeLanguageSpecific(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode? previousOriginalNode, SyntaxNode? previousReplacedNode);
118protected abstract bool IsParenthesizedExpression([NotNullWhen(true)] SyntaxNode? node);
130SyntaxNode ISpeculationAnalyzer.OriginalExpression => OriginalExpression;
137public SyntaxNode SemanticRootOfOriginalExpression
170SyntaxNode ISpeculationAnalyzer.ReplacedExpression => ReplacedExpression;
177public SyntaxNode SemanticRootOfReplacedExpression
200protected virtual SyntaxNode GetSemanticRootOfReplacedExpression(SyntaxNode semanticRootOfOriginalExpression, TExpressionSyntax annotatedReplacedExpression)
223protected abstract void ValidateSpeculativeSemanticModel(SemanticModel speculativeSemanticModel, SyntaxNode nodeToSpeculate);
230var nodeToSpeculate = this.SemanticRootOfReplacedExpression;
316protected bool SymbolsAreCompatible(SyntaxNode originalNode, SyntaxNode newNode, bool requireNonNullSymbols = false)
518protected bool ReplacementChangesSemantics(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode originalRoot, bool skipVerificationForCurrentNode)
526SyntaxNode? previousOriginalNode = null, previousReplacedNode = null;
571private bool ReplacementChangesSemanticsForNode(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, SyntaxNode? previousOriginalNode, SyntaxNode? previousReplacedNode)
688var originalExpressionOfMemberAccess = syntaxFacts.GetExpressionOfMemberAccessExpression(originalExpression);
731private bool ReplacementBreaksSystemObjectMethodResolution(SyntaxNode currentOriginalNode, SyntaxNode currentReplacedNode, [NotNullWhen(true)] SyntaxNode? previousOriginalNode, [NotNullWhen(true)] SyntaxNode? previousReplacedNode)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\CommonFormattingHelpers.cs (8)
46public static IEnumerable<(SyntaxToken, SyntaxToken)> ConvertToTokenPairs(this SyntaxNode root, IReadOnlyList<TextSpan> spans)
82public static ValueTuple<SyntaxToken, SyntaxToken> ConvertToTokenPair(this SyntaxNode root, TextSpan textSpan)
128public static bool IsInvalidTokenRange(this SyntaxNode root, SyntaxToken startToken, SyntaxToken endToken)
279var parentNode = GetParentThatContainsGivenSpan(token.Parent, backwardPosition, forward: false);
310var parentNode = GetParentThatContainsGivenSpan(token.Parent, forwardPosition, forward: true);
321private static SyntaxNode? GetParentThatContainsGivenSpan(SyntaxNode? node, int position, bool forward)
358public static TextSpan GetFormattingSpan(SyntaxNode root, TextSpan span)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (83)
48public TDeclarationNode AddEvent<TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
51public TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
54public TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
57public TDeclarationNode AddProperty<TDeclarationNode>(TDeclarationNode destination, IPropertySymbol property, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
60public TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
63public TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationNode destination, INamespaceSymbol @namespace, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
67where TDeclarationNode : SyntaxNode
70private static TNode WithAnnotations<TNode>(TNode node, CodeGenerationContextInfo info) where TNode : SyntaxNode
77public SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
80public SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
83public SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
86public SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
89public SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
92public SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
95public TDeclarationNode AddParameters<TDeclarationNode>(TDeclarationNode destination, IEnumerable<IParameterSymbol> parameters, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
98public TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
101public TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, SyntaxNode attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
104public TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, AttributeData attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
107public TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
110public TDeclarationNode UpdateDeclarationAccessibility<TDeclarationNode>(TDeclarationNode declaration, Accessibility newAccessibility, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
113public TDeclarationNode UpdateDeclarationType<TDeclarationNode>(TDeclarationNode declaration, ITypeSymbol newType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
116public TDeclarationNode UpdateDeclarationMembers<TDeclarationNode>(TDeclarationNode declaration, IList<ISymbol> newMembers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
119public TDeclarationNode AddStatements<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> statements, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
124protected abstract TDeclarationNode AddEvent<TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
125protected abstract TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
126protected abstract TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
127protected abstract TDeclarationNode AddProperty<TDeclarationNode>(TDeclarationNode destination, IPropertySymbol property, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
128protected abstract TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
129protected abstract TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationNode destination, INamespaceSymbol @namespace, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
130protected abstract TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> members) where TDeclarationNode : SyntaxNode;
132public abstract TDeclarationNode AddParameters<TDeclarationNode>(TDeclarationNode destinationMember, IEnumerable<IParameterSymbol> parameters, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
133public abstract TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
134public abstract TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, SyntaxNode attributeToRemove, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
135public abstract TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, AttributeData attributeToRemove, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
136public abstract TDeclarationNode AddStatements<TDeclarationNode>(TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
138public abstract TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
139public abstract TDeclarationNode UpdateDeclarationAccessibility<TDeclarationNode>(TDeclarationNode declaration, Accessibility newAccessibility, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
140public abstract TDeclarationNode UpdateDeclarationType<TDeclarationNode>(TDeclarationNode declaration, ITypeSymbol newType, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
141public abstract TDeclarationNode UpdateDeclarationMembers<TDeclarationNode>(TDeclarationNode declaration, IList<ISymbol> newMembers, TCodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
143public abstract CodeGenerationDestination GetDestination(SyntaxNode node);
144public abstract SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
145public abstract SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
148public abstract SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
150public abstract SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
151public abstract SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
152public abstract SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
157protected static void CheckDeclarationNode<TDeclarationNode>(SyntaxNode destination) where TDeclarationNode : SyntaxNode
172protected static void CheckDeclarationNode<TDeclarationNode1, TDeclarationNode2>(SyntaxNode destination)
173where TDeclarationNode1 : SyntaxNode
174where TDeclarationNode2 : SyntaxNode
191protected static void CheckDeclarationNode<TDeclarationNode1, TDeclarationNode2, TDeclarationNode3>(SyntaxNode destination)
192where TDeclarationNode1 : SyntaxNode
193where TDeclarationNode2 : SyntaxNode
194where TDeclarationNode3 : SyntaxNode
212protected static void CheckDeclarationNode<TDeclarationNode1, TDeclarationNode2, TDeclarationNode3, TDeclarationNode4>(SyntaxNode destination)
213where TDeclarationNode1 : SyntaxNode
214where TDeclarationNode2 : SyntaxNode
215where TDeclarationNode3 : SyntaxNode
216where TDeclarationNode4 : SyntaxNode
233Func<SyntaxNode, TCodeGenerationContextInfo, IList<bool>?, CancellationToken, SyntaxNode> declarationTransform,
248var transformedDeclaration = declarationTransform(destinationDeclaration, info, availableIndices, cancellationToken);
250var root = await destinationTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
251var currentRoot = root.ReplaceNode(destinationDeclaration, transformedDeclaration);
276where TDeclarationNode : SyntaxNode
298where TDeclarationSyntax : SyntaxNode
300var newMembers = new List<SyntaxNode>();
305var newMember = GetNewMember(info, codeGenerationDestination, member, cancellationToken);
330where TDeclarationSyntax : SyntaxNode
343private SyntaxNode? GetNewMember(TCodeGenerationContextInfo info, CodeGenerationDestination codeGenerationDestination, ISymbol member, CancellationToken cancellationToken)
360CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
380protected abstract IComparer<SyntaxNode> GetMemberComparer();
482protected static void CheckLocation(SyntaxNode destinationMember, [NotNull] Location? location)
501SyntaxNode attributeList,
521SyntaxNode attributeToRemove,
527var root = attributeToRemove.SyntaxTree.GetRoot();
536where T : SyntaxNode
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (16)
19protected abstract IList<bool>? GetAvailableInsertionIndices(SyntaxNode destination, CancellationToken cancellationToken);
21private IList<bool>? GetAvailableInsertionIndices<TDeclarationNode>(TDeclarationNode destination, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
22=> GetAvailableInsertionIndices((SyntaxNode)destination, cancellationToken);
30protected static SyntaxToken GetEndToken(SyntaxNode node)
46protected static TextSpan GetSpan(SyntaxNode node)
54public bool CanAddTo(SyntaxNode destination, Solution solution, CancellationToken cancellationToken)
57private bool CanAddTo(SyntaxNode? destination, Solution solution, CancellationToken cancellationToken,
126public async Task<SyntaxNode?> FindMostRelevantNameSpaceOrTypeDeclarationAsync(
136private async Task<(SyntaxNode? declaration, IList<bool>? availableIndices)> FindMostRelevantDeclarationAsync(
142var declaration = (SyntaxNode?)null;
149var fallbackDeclaration = (SyntaxNode?)null;
215private static async Task<SyntaxNode?> SelectFirstOrDefaultAsync(IEnumerable<SyntaxReference> references, Func<SyntaxNode, bool> predicate, CancellationToken cancellationToken)
219var node = await r.GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractFlagsEnumGenerator.cs (8)
15protected abstract SyntaxNode CreateExplicitlyCastedLiteralValue(SyntaxGenerator generator, INamedTypeSymbol enumType, SpecialType underlyingSpecialType, object constantValue);
18public SyntaxNode CreateEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
63private SyntaxNode CreateFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
73private SyntaxNode CreateFlagsEnumConstantValue(
106SyntaxNode? finalNode = null;
110var node = CreateMemberAccessExpression(generator, field.field, enumType, underlyingSpecialType);
140private SyntaxNode CreateMemberAccessExpression(
188private SyntaxNode CreateNonFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (16)
60SyntaxNode? initializer = null)
113SyntaxNode? initializer = null)
129ImmutableArray<SyntaxNode> statements = default,
130ImmutableArray<SyntaxNode> baseConstructorArguments = default,
131ImmutableArray<SyntaxNode> thisConstructorArguments = default,
144ImmutableArray<SyntaxNode> statements = default)
162ImmutableArray<SyntaxNode> statements = default,
163ImmutableArray<SyntaxNode> handlesExpressions = default,
183ImmutableArray<SyntaxNode> statements = default,
184ImmutableArray<SyntaxNode> handlesExpressions = default,
202ImmutableArray<SyntaxNode> statements = default,
228ImmutableArray<SyntaxNode> statements = default,
256ImmutableArray<SyntaxNode> statements = default,
365ImmutableArray<SyntaxNode> statements = default)
389ImmutableArray<SyntaxNode> statements)
522ImmutableArray<SyntaxNode> statements = default,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\ICodeGenerationService.cs (26)
23SyntaxNode CreateEventDeclaration(IEventSymbol @event, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
28SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
34SyntaxNode? CreateMethodDeclaration(IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
39SyntaxNode CreatePropertyDeclaration(IPropertySymbol property, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
44SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
49SyntaxNode CreateNamespaceDeclaration(INamespaceSymbol @namespace, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
54TDeclarationNode AddEvent<TDeclarationNode>(TDeclarationNode destination, IEventSymbol @event, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
59TDeclarationNode AddField<TDeclarationNode>(TDeclarationNode destination, IFieldSymbol field, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
64TDeclarationNode AddMethod<TDeclarationNode>(TDeclarationNode destination, IMethodSymbol method, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
69TDeclarationNode AddProperty<TDeclarationNode>(TDeclarationNode destination, IPropertySymbol property, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
74TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
79TDeclarationNode AddNamespace<TDeclarationNode>(TDeclarationNode destination, INamespaceSymbol @namespace, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
84TDeclarationNode AddMembers<TDeclarationNode>(TDeclarationNode destination, IEnumerable<ISymbol> members, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
89TDeclarationNode AddParameters<TDeclarationNode>(TDeclarationNode destination, IEnumerable<IParameterSymbol> parameters, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
94TDeclarationNode AddAttributes<TDeclarationNode>(TDeclarationNode destination, IEnumerable<AttributeData> attributes, SyntaxToken? target, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
99TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, SyntaxNode attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
104TDeclarationNode RemoveAttribute<TDeclarationNode>(TDeclarationNode destination, AttributeData attributeToRemove, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
109TDeclarationNode UpdateDeclarationModifiers<TDeclarationNode>(TDeclarationNode declaration, IEnumerable<SyntaxToken> newModifiers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
114TDeclarationNode UpdateDeclarationAccessibility<TDeclarationNode>(TDeclarationNode declaration, Accessibility newAccessibility, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
119TDeclarationNode UpdateDeclarationType<TDeclarationNode>(TDeclarationNode declaration, ITypeSymbol newType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
124TDeclarationNode UpdateDeclarationMembers<TDeclarationNode>(TDeclarationNode declaration, IList<ISymbol> newMembers, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
129TDeclarationNode AddStatements<TDeclarationNode>(TDeclarationNode destination, IEnumerable<SyntaxNode> statements, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
184bool CanAddTo(SyntaxNode destination, Solution solution, CancellationToken cancellationToken);
192Task<SyntaxNode?> FindMostRelevantNameSpaceOrTypeDeclarationAsync(Solution solution, INamespaceOrTypeSymbol namespaceOrType, Location? location, CancellationToken cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeRefactorings\AbstractRefactoringHelpersService.cs (62)
18where TExpressionSyntax : SyntaxNode
19where TArgumentSyntax : SyntaxNode
20where TExpressionStatementSyntax : SyntaxNode
24public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
26private static void AddNode<TSyntaxNode>(bool allowEmptyNodes, ref TemporaryArray<TSyntaxNode> result, TSyntaxNode node) where TSyntaxNode : SyntaxNode
35ParsedDocument document, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
42var root = document.Root;
137private static bool IsWantedTypeExpressionLike<TSyntaxNode>() where TSyntaxNode : SyntaxNode
157SyntaxNode root,
268CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
275var leftNode = tokenToLeft.Parent;
302SyntaxNode root,
307CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
313var rightNode = tokenToRightOrIn.Parent;
347SyntaxNode root,
352CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
354var selectionNode = root.FindNode(selectionTrimmed, getInnermostNodeForTie: true);
355var prevNode = selectionNode;
393protected virtual IEnumerable<SyntaxNode> ExtractNodesSimple(SyntaxNode? node, ISyntaxFactsService syntaxFacts)
411var localDeclarationStatement = syntaxFacts.IsLocalDeclarationStatement(node) ? node : node.Parent!;
421var declaredVariable = variables.First();
427var initializer = syntaxFacts.GetInitializerOfVariableDeclarator(declaredVariable);
430var value = syntaxFacts.GetValueOfEqualsValueClause(initializer);
443var initializer = syntaxFacts.GetInitializerOfVariableDeclarator(node);
446var value = syntaxFacts.GetValueOfEqualsValueClause(initializer);
458syntaxFacts.GetPartsOfAssignmentExpressionOrStatement(node, out _, out _, out var rightSide);
480protected virtual IEnumerable<SyntaxNode> ExtractNodesInHeader(SyntaxNode root, int location, IHeaderFactsService headerFacts)
483if (headerFacts.IsOnPropertyDeclarationHeader(root, location, out var propertyDeclaration))
487if (headerFacts.IsOnParameterHeader(root, location, out var parameter))
491if (headerFacts.IsOnMethodHeader(root, location, out var method))
495if (headerFacts.IsOnLocalFunctionHeader(root, location, out var localFunction))
499if (headerFacts.IsOnLocalDeclarationHeader(root, location, out var localDeclaration))
503if (headerFacts.IsOnIfStatementHeader(root, location, out var ifStatement))
507if (headerFacts.IsOnForeachHeader(root, location, out var foreachStatement))
510if (headerFacts.IsOnTypeHeader(root, location, out var typeDeclaration))
520CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
524var root = document.Root;
531var ancestor = token.Parent;
559IEnumerable<SyntaxNode> nodes, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
561foreach (var node in nodes)
573public bool IsOnTypeHeader(SyntaxNode root, int position, bool fullHeader, [NotNullWhen(true)] out SyntaxNode? typeDeclaration)
576public bool IsOnPropertyDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? propertyDeclaration)
579public bool IsOnParameterHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? parameter)
582public bool IsOnMethodHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? method)
585public bool IsOnLocalFunctionHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localFunction)
588public bool IsOnLocalDeclarationHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? localDeclaration)
591public bool IsOnIfStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? ifStatement)
594public bool IsOnWhileStatementHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? whileStatement)
597public bool IsOnForeachHeader(SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? foreachStatement)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Editing\ImportAdderService.cs (22)
39var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
66bool OverlapsWithSpan(SyntaxNode n) => spansTree.HasIntervalThatOverlapsWith(n.FullSpan.Start, n.FullSpan.Length);
69protected abstract INamespaceSymbol? GetExplicitNamespaceSymbol(SyntaxNode node, SemanticModel model);
73SyntaxNode container,
91SyntaxNode container,
96private static SyntaxNode GenerateNamespaceImportDeclaration(INamespaceSymbol namespaceSymbol, SyntaxGenerator generator)
107IEnumerable<SyntaxNode> syntaxNodes,
113using var _1 = ArrayBuilder<SyntaxNode>.GetInstance(out var importsToAdd);
114using var _2 = ArrayBuilder<SyntaxNode>.GetInstance(out var nodesToSimplify);
116var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
135var namespaceSyntax = GenerateNamespaceImportDeclaration(namespaceSymbol, generator);
155var first = root.DescendantNodesAndSelf().First(x => x.HasAnnotation(annotation));
156var last = root.DescendantNodesAndSelf().Last(x => x.HasAnnotation(annotation));
158var context = first.GetCommonRoot(last);
168IEnumerable<SyntaxNode> syntaxNodes,
174using var _ = PooledDictionary<INamespaceSymbol, SyntaxNode>.GetInstance(out var importToSyntax);
184SyntaxNode? first = null, last = null;
187foreach (var annotatedNode in annotatedNodes)
215var namespaceSyntax = GenerateNamespaceImportDeclaration(namespaceSymbol, generator);
230var context = first.GetCommonRoot(last);
233var importContainer = addImportsService.GetImportContainer(root, context, importToSyntax.First().Value, options);
254private static bool IsInsideNamespace(SyntaxNode node, INamespaceSymbol symbol, SemanticModel model, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxEditorExtensions.cs (29)
31Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
32CancellationToken cancellationToken) where TNode : SyntaxNode
54Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
55CancellationToken cancellationToken) where TNode : SyntaxNode
76Func<SemanticModel, SyntaxNode, TNode, SyntaxNode> updateRoot,
77CancellationToken cancellationToken) where TNode : SyntaxNode
98Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
99CancellationToken cancellationToken) where TNode : SyntaxNode
120Func<SemanticModel, SyntaxNode, TNode, SyntaxNode> updateRoot,
121CancellationToken cancellationToken) where TNode : SyntaxNode
154Func<ISyntaxFactsService, SyntaxNode, SyntaxNode> getSemanticBoundary,
156Func<SemanticModel, SyntaxNode, TType, TNode, SyntaxNode> updateRoot,
157CancellationToken cancellationToken) where TNode : SyntaxNode
170var originalRoot = editor.OriginalRoot;
173var currentRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
183var replacementRoot = updateRoot(semanticModel, currentRoot, instance, currentNode);
195private static SyntaxNode GetExpressionSemanticBoundary(ISyntaxFactsService syntaxFacts, SyntaxNode node)
202return node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>(
210private static SyntaxNode GetMethodBodySemanticBoundary(ISyntaxFactsService syntaxFacts, SyntaxNode node)
212return node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions.cs (47)
30public static SyntaxNode CreateThrowNotImplementedStatement(
37public static SyntaxNode CreateThrowNotImplementedExpression(
44private static SyntaxNode CreateNewNotImplementedException(SyntaxGenerator codeDefinitionFactory, Compilation compilation)
46var notImplementedExceptionTypeSyntax = compilation.NotImplementedExceptionType() is INamedTypeSymbol symbol
55public static ImmutableArray<SyntaxNode> CreateThrowNotImplementedStatementBlock(
59public static ImmutableArray<SyntaxNode> CreateArguments(
66private static SyntaxNode CreateArgument(
73public static SyntaxNode GetDefaultEqualityComparer(
80var typeExpression = equalityComparerType == null
95public static SyntaxNode IsPatternExpression(this SyntaxGeneratorInternal generator, SyntaxNode expression, SyntaxNode pattern)
102public static SyntaxNode GenerateDelegateThroughMemberStatement(
105var through = generator.MemberAccessExpression(
111var invocationExpression = generator.InvocationExpression(through, generator.CreateArguments(method.Parameters));
117public static SyntaxNode CreateDelegateThroughExpression(
120var name = generator.IdentifierName(throughMember.Name);
121var through = throughMember.IsStatic
167var explicitImplementationCast = generator.CastExpression(
182static SyntaxNode GenerateContainerName(SyntaxGenerator factory, ISymbol throughMember)
191public static ImmutableArray<SyntaxNode> GetGetAccessorStatements(
197var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
198var expression = property.IsIndexer
215public static ImmutableArray<SyntaxNode> GetSetAccessorStatements(
221var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
222var expression = property.IsIndexer
315public static ImmutableArray<SyntaxNode> CreateAssignmentStatements(
325var nullCheckStatements = ArrayBuilder<SyntaxNode>.GetInstance();
326var assignStatements = ArrayBuilder<SyntaxNode>.GetInstance();
338var assignExpression = factory.AssignmentStatement(
341var statement = factory.ExpressionStatement(assignExpression);
351var fieldAccess = factory.MemberAccessExpression(factory.ThisExpression(), factory.IdentifierName(fieldName))
371SyntaxNode fieldAccess,
374ArrayBuilder<SyntaxNode> nullCheckStatements,
375ArrayBuilder<SyntaxNode> assignStatements)
406public static SyntaxNode CreateAssignWithNullCheckStatement(
407this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter, SyntaxNode fieldAccess)
416public static SyntaxNode CreateThrowArgumentNullExpression(this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
419private static SyntaxNode CreateNewArgumentNullException(SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
428public static SyntaxNode CreateNullCheckAndThrowStatement(
434var condition = factory.CreateNullCheckExpression(generatorInternal, semanticModel, parameter.Name);
435var throwStatement = factory.CreateThrowArgumentNullExceptionStatement(semanticModel.Compilation, parameter);
440public static SyntaxNode CreateNullCheckExpression(
443var identifier = factory.IdentifierName(identifierName);
444var nullExpr = factory.NullLiteralExpression();
445var condition = generatorInternal.SupportsPatterns(semanticModel.SyntaxTree.Options)
451public static SyntaxNode CreateThrowArgumentNullExceptionStatement(this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_CreateEqualsMethod.cs (21)
49public static IMethodSymbol CreateEqualsMethod(this Compilation compilation, ImmutableArray<SyntaxNode> statements)
109private static ImmutableArray<SyntaxNode> CreateEqualsMethodStatements(
127using var statements = TemporaryArray<SyntaxNode>.Empty;
136var localNameExpression = factory.IdentifierName(localName);
137var objNameExpression = factory.IdentifierName(ObjName);
141using var _2 = ArrayBuilder<SyntaxNode>.GetInstance(out var expressions);
159var ifStatement = factory.IfStatement(
170var localDeclaration = factory.SimpleLocalDeclarationStatement(generatorInternal,
182var localDeclaration = factory.SimpleLocalDeclarationStatement(generatorInternal,
220ImmutableArray<ISymbol> members, SyntaxNode localNameExpression,
221ArrayBuilder<SyntaxNode> expressions)
231var symbolNameExpression = factory.IdentifierName(member.Name);
232var thisSymbol = factory.MemberAccessExpression(factory.ThisExpression(), symbolNameExpression)
234var otherSymbol = factory.MemberAccessExpression(localNameExpression, symbolNameExpression);
271private static ImmutableArray<SyntaxNode> CreateIEquatableEqualsMethodStatements(
279var statements = ArrayBuilder<SyntaxNode>.GetInstance();
281var otherNameExpression = factory.IdentifierName(OtherName);
285using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var expressions);
323SyntaxGenerator factory, SyntaxGeneratorInternal generatorInternal, Compilation compilation, ParseOptions parseOptions, SyntaxNode otherNameExpression, ArrayBuilder<SyntaxNode> expressions)
325var nullLiteral = factory.NullLiteralExpression();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\SyntaxGeneratorExtensions_Negate.cs (58)
35public static SyntaxNode Negate(
38SyntaxNode expression,
45public static SyntaxNode Negate(
48SyntaxNode expressionOrPattern,
56public static SyntaxNode Negate(
59SyntaxNode expressionOrPattern,
116syntaxFacts.GetPartsOfAnyIsTypeExpression(expressionOrPattern, out var expression, out var type);
126syntaxFacts.GetPartsOfAnyIsTypeExpression(expressionOrPattern, out var expression, out var type);
140private static SyntaxNode GetNegationOfBinaryExpression(
141SyntaxNode expressionNode,
148syntaxFacts.GetPartsOfBinaryExpression(expressionNode, out var leftOperand, out var operatorToken, out var rightOperand);
176var newBinaryExpressionSyntax = negatedKind is BinaryOperatorKind.Equals or BinaryOperatorKind.NotEquals
194SyntaxNode innerPattern;
203var typeExpression = generatorInternal.Type(isTypeOperation.TypeOperand, typeContext: false);
232private static SyntaxNode GetNegationOfBinaryPattern(
233SyntaxNode pattern,
245syntaxFacts.GetPartsOfBinaryPattern(pattern, out var left, out var operatorToken, out var right);
247var newLeft = generator.Negate(generatorInternal, left, semanticModel, cancellationToken);
248var newRight = generator.Negate(generatorInternal, right, semanticModel, cancellationToken);
250var newPattern =
262private static SyntaxNode GetNegationOfIsPatternExpression(SyntaxNode isExpression, SyntaxGenerator generator, SyntaxGeneratorInternal generatorInternal, SemanticModel semanticModel, CancellationToken cancellationToken)
267syntaxFacts.GetPartsOfIsPatternExpression(isExpression, out var left, out var isToken, out var pattern);
269SyntaxNode? negatedPattern = null;
291var type = syntaxFacts.GetTypeOfTypePattern(negatedPattern);
304private static SyntaxNode GetNegationOfRelationalPattern(
305SyntaxNode expressionNode,
316syntaxFacts.GetPartsOfRelationalPattern(expressionNode, out var operatorToken, out var expression);
331private static bool IsLegalPattern(ISyntaxFacts syntaxFacts, SyntaxNode pattern, bool designatorsLegal)
336syntaxFacts.GetPartsOfBinaryPattern(pattern, out var left, out _, out var right);
346syntaxFacts.GetPartsOfUnaryPattern(pattern, out _, out var subPattern);
358syntaxFacts.GetPartsOfParenthesizedPattern(pattern, out _, out var subPattern, out _);
364syntaxFacts.GetPartsOfDeclarationPattern(pattern, out _, out var designator);
370syntaxFacts.GetPartsOfRecursivePattern(pattern, out _, out _, out _, out var designator);
380private static SyntaxNode NegateRelational(
383SyntaxNode leftOperand,
385SyntaxNode rightOperand)
471private static SyntaxNode GetNegationOfLiteralExpression(
472SyntaxNode expression,
477SyntaxNode newLiteralExpression;
495private static SyntaxNode GetNegationOfConstantPattern(
496SyntaxNode pattern,
508var expression = syntaxFacts.GetExpressionOfConstantPattern(pattern);
520private static SyntaxNode GetNegationOfLogicalNotExpression(
521SyntaxNode expression,
525var operand = syntaxFacts.GetOperandOfPrefixUnaryExpression(expression);
531private static SyntaxNode GetNegationOfUnaryPattern(
532SyntaxNode pattern,
548private static SyntaxNode GetNegationOfNotPattern(
549SyntaxNode pattern,
556syntaxFacts.GetPartsOfUnaryPattern(pattern, out var opToken, out var subPattern);
562var type = syntaxFacts.GetTypeOfTypePattern(subPattern);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\AbstractAddImportsService.cs (64)
20where TCompilationUnitSyntax : SyntaxNode
21where TNamespaceDeclarationSyntax : SyntaxNode
22where TUsingOrAliasSyntax : SyntaxNode
23where TExternSyntax : SyntaxNode
30protected abstract SyntaxNode? GetAlias(TUsingOrAliasSyntax usingOrAlias);
31protected abstract ImmutableArray<SyntaxNode> GetGlobalImports(Compilation compilation, SyntaxGenerator generator);
32protected abstract SyntaxList<TUsingOrAliasSyntax> GetUsingsAndAliases(SyntaxNode node);
33protected abstract SyntaxList<TExternSyntax> GetExterns(SyntaxNode node);
48private bool HasAliases(SyntaxNode node) => GetUsingsAndAliases(node).Any(IsAlias);
49private bool HasUsings(SyntaxNode node) => GetUsingsAndAliases(node).Any(IsSimpleUsing);
50private bool HasStaticUsings(SyntaxNode node) => GetUsingsAndAliases(node).Any(IsStaticUsing);
51private bool HasExterns(SyntaxNode node) => GetExterns(node).Any();
52private bool HasAnyImports(SyntaxNode node) => GetUsingsAndAliases(node).Any() || GetExterns(node).Any();
56SyntaxNode root,
57SyntaxNode? contextLocation,
58SyntaxNode import,
66private static ImmutableArray<SyntaxNode> GetAllContainers(SyntaxNode root, SyntaxNode? contextLocation)
70var applicableContainer = GetFirstApplicableContainer(contextLocation);
71return applicableContainer.GetAncestorsOrThis<SyntaxNode>().ToImmutableArray();
75SyntaxNode import, ImmutableArray<SyntaxNode> containers, ImmutableArray<SyntaxNode> globalImports)
77foreach (var node in containers)
90foreach (var node in globalImports)
101protected abstract bool IsEquivalentImport(SyntaxNode a, SyntaxNode b);
103public SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, AddImportPlacementOptions options)
107out var externContainer, out var usingContainer, out var staticUsingContainer, out var aliasContainer);
130public SyntaxNode AddImports(
132SyntaxNode root,
133SyntaxNode? contextLocation,
134IEnumerable<SyntaxNode> newImports,
151out var externContainer, out var usingContainer, out var aliasContainer, out var staticUsingContainer);
153var newRoot = Rewrite(
161protected abstract SyntaxNode Rewrite(
163SyntaxNode externContainer, SyntaxNode usingContainer, SyntaxNode staticUsingContainer, SyntaxNode aliasContainer,
164AddImportPlacementOptions options, SyntaxNode root, CancellationToken cancellationToken);
166private void GetContainers(SyntaxNode root, SyntaxNode contextLocation, AddImportPlacementOptions options, out SyntaxNode externContainer, out SyntaxNode usingContainer, out SyntaxNode staticUsingContainer, out SyntaxNode aliasContainer)
168var applicableContainer = GetFirstApplicableContainer(contextLocation);
169var contextSpine = applicableContainer.GetAncestorsOrThis<SyntaxNode>().ToImmutableArray();
174var fallbackNode = contextSpine.FirstOrDefault(HasAnyImports);
194private static SyntaxNode? GetFirstApplicableContainer(SyntaxNode contextNode)
198var node = usingDirective != null ? usingDirective.Parent! : contextNode;
200(SyntaxNode?)node.GetAncestorOrThis<TCompilationUnitSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\AddImports\IAddImportsService.cs (15)
29bool HasExistingImport(Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, SyntaxGenerator generator);
35SyntaxNode GetImportContainer(SyntaxNode root, SyntaxNode? contextLocation, SyntaxNode import, AddImportPlacementOptions options);
37SyntaxNode AddImports(
38Compilation compilation, SyntaxNode root, SyntaxNode? contextLocation,
39IEnumerable<SyntaxNode> newImports, SyntaxGenerator generator, AddImportPlacementOptions options, CancellationToken cancellationToken);
44public static SyntaxNode AddImport(
45this IAddImportsService service, Compilation compilation, SyntaxNode root,
46SyntaxNode contextLocation, SyntaxNode newImport, SyntaxGenerator generator, AddImportPlacementOptions options,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.cs (20)
26where TStatementSyntax : SyntaxNode
28where TVariableDeclaratorSyntax : SyntaxNode
30protected abstract bool IsMeaningfulBlock(SyntaxNode node);
31protected abstract bool CanMoveToBlock(ILocalSymbol localSymbol, SyntaxNode currentBlock, SyntaxNode destinationBlock);
32protected abstract SyntaxNode GetVariableDeclaratorSymbolNode(TVariableDeclaratorSyntax variableDeclarator);
35protected abstract Task<bool> TypesAreCompatibleAsync(Document document, ILocalSymbol localSymbol, TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode right, CancellationToken cancellationToken);
37public async Task<bool> CanMoveDeclarationNearReferenceAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
43private async Task<State> ComputeStateAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
74Document document, SyntaxNode localDeclarationStatement, CancellationToken cancellationToken)
82var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
112var newRoot = editor.GetChangedRoot();
149var originalNextStatement = state.OutermostBlockStatements[statementIndex + 1];
185var blocks = state.InnermostBlock.GetAncestorsOrThis<SyntaxNode>();
186foreach (var block in blocks)
209var initializer = syntaxFacts.GetInitializerOfVariableDeclarator(state.VariableDeclarator);
216syntaxFacts.GetPartsOfAssignmentStatement(firstStatement, out var left, out var right);
241out var _, out var operatorToken, out var right);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\AbstractSemanticFactsService.cs (36)
40SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
48SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
56SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
64SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt,
73SyntaxNode location, SyntaxNode containerOpt,
77var container = containerOpt ?? location.AncestorsAndSelf().FirstOrDefault(
91protected virtual IEnumerable<ISymbol> GetCollidableSymbols(SemanticModel semanticModel, SyntaxNode location, SyntaxNode container, CancellationToken cancellationToken)
179public bool IsWrittenTo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
182public bool IsOnlyWrittenTo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
185public bool IsInOutContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
188public bool IsInRefContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
191public bool IsInInContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
194public bool CanReplaceWithRValue(SemanticModel semanticModel, SyntaxNode expression, CancellationToken cancellationToken)
203public bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, out SemanticModel speculativeModel)
209public ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode forEachStatement)
212public SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
215public IMethodSymbol GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node)
218public ImmutableArray<IMethodSymbol> GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node)
221public ImmutableArray<IMethodSymbol> GetDeconstructionForEachMethods(SemanticModel semanticModel, SyntaxNode node)
227public IEnumerable<ISymbol> GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken)
230public IParameterSymbol FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
233public IParameterSymbol FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken)
236public ISymbol FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken)
239public ISymbol FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken)
242public ImmutableArray<ISymbol> GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode node, SyntaxToken token, CancellationToken cancellationToken)
245public bool IsInsideNameOfExpression(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
251public bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, INamedTypeSymbol expressionTypeOpt, CancellationToken cancellationToken)
254public string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken)
257public IPreprocessingSymbol GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SemanticsFactsService\ISemanticFactsService.cs (12)
27SemanticModel semanticModel, SyntaxNode location,
28SyntaxNode? container, string baseName, CancellationToken cancellationToken);
31SemanticModel semanticModel, SyntaxNode location,
32SyntaxNode? container, string baseName, IEnumerable<string> usedNames, CancellationToken cancellationToken);
34SyntaxToken GenerateUniqueName(SemanticModel semanticModel, SyntaxNode location, SyntaxNode? container, string baseName,
38SemanticModel semanticModel, SyntaxNode location,
39SyntaxNode? container, string baseName, CancellationToken cancellationToken);
42SemanticModel semanticModel, SyntaxNode location,
43SyntaxNode? container, string baseName, IEnumerable<string> usedNames, CancellationToken cancellationToken);
47CommonConversion ClassifyConversion(SemanticModel semanticModel, SyntaxNode expression, ITypeSymbol destination);
49IMethodSymbol? TryGetDisposeMethod(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\SyntaxGeneratorInternalExtensions\SyntaxGeneratorInternal.cs (68)
36public abstract SyntaxNode LocalDeclarationStatement(
37SyntaxNode? type, SyntaxToken identifier, SyntaxNode? initializer = null, bool isConst = false);
42public SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initializer)
45public abstract SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer);
47public abstract SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value);
51public abstract SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull);
53public abstract SyntaxNode MemberBindingExpression(SyntaxNode name);
55public abstract SyntaxNode RefExpression(SyntaxNode expression);
60public abstract SyntaxNode AddParentheses(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true);
66public abstract SyntaxNode YieldReturnStatement(SyntaxNode expression);
71/// <see cref="LocalDeclarationStatement(SyntaxNode, SyntaxToken, SyntaxNode, bool)"/>.
77public abstract SyntaxNode InterpolatedStringText(SyntaxToken textToken);
78public abstract SyntaxNode Interpolation(SyntaxNode syntaxNode);
79public abstract SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken);
80public abstract SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment);
81public abstract SyntaxNode InterpolationFormatClause(string format);
82public abstract SyntaxNode TypeParameterList(IEnumerable<string> typeParameterNames);
99public abstract SyntaxNode Type(ITypeSymbol typeSymbol, bool typeContext);
101public abstract SyntaxNode NegateEquality(SyntaxGenerator generator, SyntaxNode binaryExpression, SyntaxNode left, BinaryOperatorKind negatedKind, SyntaxNode right);
103public abstract SyntaxNode IsNotTypeExpression(SyntaxNode expression, SyntaxNode type);
108public abstract SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isToken, SyntaxNode pattern);
110public abstract SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right);
111public abstract SyntaxNode ConstantPattern(SyntaxNode expression);
112public abstract SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name);
113public abstract SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression);
114public abstract SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression);
115public abstract SyntaxNode LessThanRelationalPattern(SyntaxNode expression);
116public abstract SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression);
117public abstract SyntaxNode NotPattern(SyntaxNode pattern);
118public abstract SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right);
119public abstract SyntaxNode ParenthesizedPattern(SyntaxNode pattern);
120public abstract SyntaxNode TypePattern(SyntaxNode type);
121public abstract SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\AbstractSimplificationService.cs (31)
26where TCompilationUnitSyntax : SyntaxNode
27where TExpressionSyntax : SyntaxNode
28where TStatementSyntax : SyntaxNode
29where TCrefSyntax : SyntaxNode
31protected static readonly Func<SyntaxNode, bool> s_containsAnnotations = n => n.ContainsAnnotations;
39protected abstract ImmutableArray<NodeOrTokenToReduce> GetNodesAndTokensToReduce(SyntaxNode root, Func<SyntaxNodeOrToken, bool> isNodeOrTokenOutsideSimplifySpans);
40protected abstract SemanticModel GetSpeculativeSemanticModel(ref SyntaxNode nodeToSpeculate, SemanticModel originalSemanticModel, SyntaxNode originalNode);
41protected abstract bool NodeRequiresNonSpeculativeSemanticModel(SyntaxNode node);
42protected abstract void AddImportDeclarations(TCompilationUnitSyntax root, ArrayBuilder<SyntaxNode> importDeclarations);
47protected virtual SyntaxNode TransformReducedNode(SyntaxNode reducedNode, SyntaxNode originalNode)
50public abstract SyntaxNode Expand(SyntaxNode node, SemanticModel semanticModel, SyntaxAnnotation? annotationForReplacedAliasIdentifier, Func<SyntaxNode, bool>? expandInsideNode, bool expandParameter, CancellationToken cancellationToken);
51public abstract SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Func<SyntaxNode, bool>? expandInsideNode, CancellationToken cancellationToken);
76var root = await semanticModel.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
137var reducedNodesMap = new ConcurrentDictionary<SyntaxNode, SyntaxNode>();
174SyntaxNode root,
178ConcurrentDictionary<SyntaxNode, SyntaxNode> reducedNodesMap,
240var replacedParent = isNode
251var currentNode = currentNodeOrToken.AsNode()!;
256var newRoot = root.ReplaceNode(nodeOrToken.AsNode()!, currentNode.WithAdditionalAnnotations(marker));
299using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var importDeclarations);
314var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
316var unusedImports = new HashSet<SyntaxNode>();
325var newRoot = gen.RemoveNodes(root, unusedImports);
334protected abstract void GetUnusedNamespaceImports(SemanticModel model, HashSet<SyntaxNode> namespaceImports, CancellationToken cancellationToken);
Workspace\Solution\Solution.cs (4)
964/// document instance defined by its name and root <see cref="SyntaxNode"/>.
966public Solution AddDocument(DocumentId documentId, string name, SyntaxNode syntaxRoot, IEnumerable<string>? folders = null, string? filePath = null, bool isGenerated = false, PreservationMode preservationMode = PreservationMode.PreserveValue)
1366public Solution WithDocumentSyntaxRoot(DocumentId documentId, SyntaxNode root, PreservationMode mode = PreservationMode.PreserveValue)
1370internal Solution WithDocumentSyntaxRoots(ImmutableArray<(DocumentId documentId, SyntaxNode root)> syntaxRoots, PreservationMode mode = PreservationMode.PreserveValue)