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 (122)
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,
943public static SyntaxTriviaList GetLeadingTriviaIncludingMissingTokens(this SyntaxNode node)
959public static SyntaxTriviaList GetTrailingTriviaIncludingMissingTokens(this SyntaxNode node)
978public static SyntaxNode WithLeadingTriviaFromIncludingMissingTokens(this SyntaxNode node, SyntaxNode other)
983public static SyntaxNode WithTrailingTriviaFromIncludingMissingTokens(this SyntaxNode node, SyntaxNode other)
988public static SyntaxNode WithTriviaFromIncludingMissingTokens(this SyntaxNode node, SyntaxNode other)
997public static ValueAncestorsAndSelfEnumerable ValueAncestorsAndSelf(this SyntaxNode syntaxNode, bool ascendOutOfTrivia = true)
1000public readonly struct ValueAncestorsAndSelfEnumerable(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
1005public struct Enumerator(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
1007public 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 (302)
118bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node);
119bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node, PredefinedType type);
169bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node);
170bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node);
171bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node);
172bool IsDeclaration([NotNullWhen(true)] SyntaxNode? node);
173bool IsTypeDeclaration(SyntaxNode node);
175bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node);
180bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes);
183SyntaxNode? GetMatchingDirective(SyntaxNode directive, CancellationToken cancellationToken);
184ImmutableArray<SyntaxNode> GetMatchingConditionalDirectives(SyntaxNode directive, CancellationToken cancellationToken);
186bool IsDocumentationComment(SyntaxNode node);
193bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? directive, out ExternalSourceInfo info);
195bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node);
197bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node);
198bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node);
200bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node);
201SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement);
203void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
204out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode;
206bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node);
209bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node);
211bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
212bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
213void GetPartsOfAssignmentStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
214void GetPartsOfAssignmentExpressionOrStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
217bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node);
219bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node);
220SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node);
222bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node);
223bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node);
224bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node);
226bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node);
227SyntaxNode? GetRightSideOfDot(SyntaxNode? node);
241SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget = false);
243bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node);
245bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
246bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
247bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
256SyntaxNode? GetStandaloneExpression(SyntaxNode? node);
265SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node);
274SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget = false);
276SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node);
278SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node);
280bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
282bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node);
283bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node);
284SyntaxNode? GetParameterList(SyntaxNode node);
285bool IsParameterList([NotNullWhen(true)] SyntaxNode? node);
289void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList);
291SyntaxNode GetExpressionOfArgument(SyntaxNode node);
292SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node);
293SyntaxNode GetExpressionOfInterpolation(SyntaxNode node);
295bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node);
296bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
297bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node);
299SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node);
300SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node);
301SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node);
302SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node);
308bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node);
309bool IsArgument([NotNullWhen(true)] SyntaxNode? node);
310bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node);
311RefKind GetRefKindOfArgument(SyntaxNode node);
313void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity);
314bool LooksGeneric(SyntaxNode simpleName);
316SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName);
318SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString);
320SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode node);
321SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode node);
322SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode node);
324bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node);
327SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node);
328SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node);
330bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node);
331bool IsMemberInitializerNamedAssignmentIdentifier([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance);
332bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression);
334bool IsDirective([NotNullWhen(true)] SyntaxNode? node);
335bool IsStatement([NotNullWhen(true)] SyntaxNode? node);
336bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node);
337bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node);
338SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node);
339bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement);
341bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node);
342bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node);
343bool IsUsingLocalDeclarationStatement(SyntaxNode node);
357bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node);
359bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement);
360SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node);
361SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node);
362SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node);
367bool IsElementAccessExpression([NotNullWhen(true)] SyntaxNode? node);
385bool IsInStaticContext(SyntaxNode node);
386bool IsUnsafeContext(SyntaxNode node);
388bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node);
390bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node);
392bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node);
393bool IsInConstructor(SyntaxNode node);
394bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node);
395bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node);
398bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2);
400string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null);
403SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position);
404SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
405SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
406SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node);
410SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false);
413PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root);
415PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root);
416SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration);
419bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span);
424/// Given a <see cref="SyntaxNode"/>, return the <see cref="TextSpan"/> representing the span of the member body
430TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node);
438SyntaxNode? TryGetBindableParent(SyntaxToken token);
441IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken);
444/// Given a <see cref="SyntaxNode"/>, that represents and argument return the string representation of
448string GetNameForArgument(SyntaxNode? argument);
451/// Given a <see cref="SyntaxNode"/>, that represents an attribute argument return the string representation of
455string GetNameForAttributeArgument(SyntaxNode? argument);
457bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node);
458bool IsPropertyPatternClause(SyntaxNode node);
460bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node);
461bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node);
462bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node);
464SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node);
465SyntaxNode GetTypeOfTypePattern(SyntaxNode node);
467void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen);
468void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
469void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation);
470void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation);
471void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression);
472void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern);
476SyntaxTokenList GetModifiers(SyntaxNode? node);
480SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers);
483Location GetDeconstructionReferenceLocation(SyntaxNode node);
488bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node);
490SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia);
496bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node);
497bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node);
498bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node);
499bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node);
500bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
501bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node);
502bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node);
503bool IsAnyName([NotNullWhen(true)] SyntaxNode? node);
504bool IsAnyType([NotNullWhen(true)] SyntaxNode? node);
506bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
507bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node);
509bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
510bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node);
516void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name);
517void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type);
518void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken);
519void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList);
520void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members);
521void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer);
522void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
523void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression);
524void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members);
525void GetPartsOfConditionalAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull);
526void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse);
527void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments);
528void GetPartsOfInterpolationExpression(SyntaxNode node, out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken);
529void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList);
530void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right);
531void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name);
532void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode name, out SyntaxNode expression);
533void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer);
534void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer);
535void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default);
536void GetPartsOfParenthesizedExpression(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen);
537void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand);
538void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken dotToken, out SyntaxNode right);
539void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name);
549SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node);
551SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node);
552SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node);
553SyntaxNode GetExpressionOfRefExpression(SyntaxNode node);
554SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node);
555SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node);
556SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node);
558bool IsEqualsValueOfPropertyDeclaration([NotNullWhen(true)] SyntaxNode? node);
559SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node);
561SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node);
562SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node);
564SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (204)
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 IsRightOfAliasQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
660var parent = node?.Parent;
664syntaxFacts.GetPartsOfAliasQualifiedName(parent, out _, out _, out var right);
668public static bool IsTypeOfObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
670var parent = node?.Parent;
674syntaxFacts.GetPartsOfObjectCreationExpression(parent, out _, out var type, out _, out _);
705public static bool IsSkippedTokensTrivia(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
745public static bool IsAliasQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
748public static bool IsGenericName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
751public static bool IsIdentifierName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
754public static bool IsQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
761public static bool IsTupleType(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
768public static bool IsCharacterLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
771public static bool IsDefaultLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
774public static bool IsFalseLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
777public static bool IsNumericLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
780public static bool IsNullLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
783public static bool IsStringLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
786public static bool IsTrueLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
793public static bool IsArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
796public static bool IsAwaitExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
799public static bool IsBaseExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
802public static bool IsConditionalExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
805public static bool IsConditionalAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
808public static bool IsImplicitArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
811public static bool IsImplicitObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
814public static bool IsIndexExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
817public static bool IsInterpolatedStringExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
820public static bool IsInterpolation(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
823public static bool IsInterpolatedStringText(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
826public static bool IsInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
829public static bool IsIsTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
832public static bool IsIsNotTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
835public static bool IsIsPatternExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
838public static bool IsLogicalAndExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
841public static bool IsLogicalOrExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
844public static bool IsLogicalNotExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
847public static bool IsObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
850public static bool IsParenthesizedExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
853public static bool IsQueryExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
856public static bool IsRangeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
859public static bool IsRefExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
862public static bool IsSimpleMemberAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
865public static bool IsThisExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
868public static bool IsThrowExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
871public static bool IsTupleExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
874public static bool ContainsGlobalStatement(this ISyntaxFacts syntaxFacts, SyntaxNode node)
881public static bool IsAndPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
884public static bool IsConstantPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
887public static bool IsDeclarationPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
890public static bool IsListPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
893public static bool IsNotPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
896public static bool IsOrPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
899public static bool IsParenthesizedPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
902public static bool IsRecursivePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
905public static bool IsRelationalPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
908public static bool IsTypePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
911public static bool IsVarPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
918public static bool IsExpressionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
921public static bool IsForEachStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
924public static bool IsForStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
927public static bool IsIfStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
930public static bool IsLocalDeclarationStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
933public static bool IsLocalFunctionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
936public static bool IsLockStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
939public static bool IsReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
942public static bool IsThrowStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
945public static bool IsUsingStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
948public static bool IsWhileStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
951public static bool IsYieldReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
958public static bool IsAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
961public static bool IsClassDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
964public static bool IsConstructorDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
967public static bool IsEnumDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
970public static bool IsGlobalAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
973public static bool IsInterfaceDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
976public static bool IsParameter(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
979public static bool IsTypeConstraint(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
982public static bool IsVariableDeclarator(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
985public static bool IsFieldDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
988public static bool IsPropertyDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
991public static bool IsStructDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
994public static bool IsTypeArgumentList(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1001public static bool IsElseClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1003public static bool IsEqualsValueClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1010public static bool IsImplicitElementAccess(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1013public static bool IsIndexerMemberCref(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1016public static bool IsPrimaryConstructorBaseType(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<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> 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)
22where TExpressionSyntax : SyntaxNode
24protected abstract bool IsExplicitInterfaceGeneration(SyntaxNode node);
25protected abstract bool IsIdentifierNameGeneration(SyntaxNode node);
27protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn);
30protected abstract bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, SemanticModel semanticModel, CancellationToken cancellationToken, out SyntaxNode newRoot);
34SyntaxNode 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)
31protected abstract bool TryInitializeState(Document document, SemanticModel model, SyntaxNode interfaceNode, CancellationToken cancellationToken, out SyntaxNode classOrStructDecl, out INamedTypeSymbol classOrStructType, out ImmutableArray<INamedTypeSymbol> interfaceTypes);
34protected abstract SyntaxNode AddCommentInsideIfStatement(SyntaxNode ifDisposingStatement, SyntaxTriviaList trivia);
35protected abstract SyntaxNode CreateFinalizer(SyntaxGenerator generator, INamedTypeSymbol classType, string disposeMethodDisplayString);
38Document document, ImplementTypeOptions options, SyntaxNode node, CancellationToken cancellationToken)
57public async Task<ImplementInterfaceInfo?> 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)
47where TExpressionSyntax : SyntaxNode
48where TStatementSyntax : SyntaxNode
53where TVariableDeclaratorSyntax : SyntaxNode
54where TSwitchCaseBlockSyntax : SyntaxNode
55where TSwitchCaseLabelOrClauseSyntax : SyntaxNode
75protected abstract SyntaxNode? TryUpdateNameForFlaggedNode(SyntaxNode node, SyntaxToken newName);
99protected abstract SyntaxNode GetReplacementNodeForCompoundAssignment(
100SyntaxNode originalCompoundAssignment,
101SyntaxNode newAssignmentTarget,
109protected abstract SyntaxNode GetReplacementNodeForVarPattern(SyntaxNode originalVarPattern, SyntaxNode newNameNode);
121protected virtual SyntaxNode? TryUpdateParentOfUpdatedNode(SyntaxNode parent, SyntaxNode newNameNode, SyntaxEditor editor, ISyntaxFacts syntaxFacts, SemanticModel semanticModel) => null;
130protected abstract SyntaxNode ComputeReplacementNode(SyntaxNode originalOldNode, SyntaxNode changedOldNode, SyntaxNode proposedReplacementNode);
164var root = await context.Document.GetRequiredSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
165var node = root.FindNode(context.Span, getInnermostNodeForTie: true);
239private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
242SyntaxNode root,
264private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
267SyntaxNode root)
278var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
292private async Task<SyntaxNode> GetNewRootAsync(
298var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
324var containingMemberDeclaration = diagnosticsToFix.Key;
334var currentRoot = editor.GetChangedRoot();
335var newRoot = await PostProcessDocumentAsync(document, options, currentRoot,
349SyntaxNode root,
350SyntaxNode containingMemberDeclaration,
386SyntaxNode root,
429var localDecl = editor.Generator.LocalDeclarationStatement(
445SyntaxNode root,
446SyntaxNode containingMemberDeclaration,
469using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var nodeReplacementMap);
470using var _2 = PooledHashSet<SyntaxNode>.GetInstance(out var nodesToRemove);
471using var _3 = PooledHashSet<(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)>.GetInstance(out var nodesToAdd);
473using var _4 = PooledHashSet<SyntaxNode>.GetInstance(out var processedNodes);
549var newNameNode = TryUpdateNameForFlaggedNode(node, newNameToken);
569var newParentNode = TryUpdateParentOfUpdatedNode(node.GetRequiredParent(), newNameNode, editor, syntaxFacts, semanticModel);
673IEnumerable<(SyntaxNode node, bool isUnusedLocalAssignment)> GetNodesToFix()
677var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
691void InsertLocalDeclarationStatement(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)
694var insertionNode = node.FirstAncestorOrSelf<SyntaxNode>(
724bool ShouldRemoveStatement(TLocalDeclarationStatementSyntax localDeclarationStatement, out SeparatedSyntaxList<SyntaxNode> variables)
730foreach (var variable in variables)
744private async Task<SyntaxNode> PostProcessDocumentAsync(
747SyntaxNode currentRoot,
773private static async Task<SyntaxNode> PostProcessDocumentCoreAsync(
774Func<SyntaxNode, Document, SyntaxFormattingOptions, CancellationToken, Task<SyntaxNode>> processMemberDeclarationAsync,
775SyntaxNode currentRoot,
784var newRoot = await newDocument.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
785using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var memberDeclReplacementsMap);
787foreach (var memberDecl in newRoot.DescendantNodes().Where(n => n.HasAnnotation(s_memberAnnotation)))
789var newMemberDecl = await processMemberDeclarationAsync(memberDecl, newDocument, options, cancellationToken).ConfigureAwait(false);
805private async Task<SyntaxNode> ReplaceDiscardDeclarationsWithAssignmentsAsync(SyntaxNode memberDeclaration, Document document, SyntaxFormattingOptions options, CancellationToken cancellationToken)
821private async Task<SyntaxNode> AdjustLocalDeclarationsAsync(
822SyntaxNode memberDeclaration,
844var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
845var rootWithTrackedNodes = root.TrackNodes(originalDeclStatementsToMoveOrRemove);
903var rootWithRemovedDeclaration = root.RemoveNode(newDecl, SyntaxGenerator.DefaultRemoveOptions | SyntaxRemoveOptions.KeepLeadingTrivia);
930SyntaxNode memberDeclaration,
935private readonly SyntaxNode _memberDeclaration = memberDeclaration;
941public 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 (18)
60SyntaxNode? initializer = null)
86bool isIndexer = false, SyntaxNode? initializer = null)
114SyntaxNode? initializer = null)
130ImmutableArray<SyntaxNode> statements = default,
131ImmutableArray<SyntaxNode> baseConstructorArguments = default,
132ImmutableArray<SyntaxNode> thisConstructorArguments = default,
145ImmutableArray<SyntaxNode> statements = default)
163ImmutableArray<SyntaxNode> statements = default,
164ImmutableArray<SyntaxNode> handlesExpressions = default,
184ImmutableArray<SyntaxNode> statements = default,
185ImmutableArray<SyntaxNode> handlesExpressions = default,
203ImmutableArray<SyntaxNode> statements = default,
229ImmutableArray<SyntaxNode> statements = default,
257ImmutableArray<SyntaxNode> statements = default,
366ImmutableArray<SyntaxNode> statements = default)
390ImmutableArray<SyntaxNode> statements)
523ImmutableArray<SyntaxNode> statements = default,
556SyntaxNode? initializer = null)
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(
201var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
202var expression = property.IsIndexer
230public static ImmutableArray<SyntaxNode> GetSetAccessorStatements(
240var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
241var expression = property.IsIndexer
343public static ImmutableArray<SyntaxNode> CreateAssignmentStatements(
353using var _1 = ArrayBuilder<SyntaxNode>.GetInstance(out var nullCheckStatements);
354using var _2 = ArrayBuilder<SyntaxNode>.GetInstance(out var assignStatements);
366var assignExpression = factory.AssignmentStatement(
369var statement = factory.ExpressionStatement(assignExpression);
379var fieldAccess = factory.MemberAccessExpression(factory.ThisExpression(), factory.IdentifierName(fieldName))
399SyntaxNode fieldAccess,
402ArrayBuilder<SyntaxNode> nullCheckStatements,
403ArrayBuilder<SyntaxNode> assignStatements)
434public static SyntaxNode CreateAssignWithNullCheckStatement(
435this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter, SyntaxNode fieldAccess)
444public static SyntaxNode CreateThrowArgumentNullExpression(this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
447private static SyntaxNode CreateNewArgumentNullException(SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
456public static SyntaxNode CreateNullCheckAndThrowStatement(
462var condition = factory.CreateNullCheckExpression(generatorInternal, semanticModel, parameter.Name);
463var throwStatement = factory.CreateThrowArgumentNullExceptionStatement(semanticModel.Compilation, parameter);
468public static SyntaxNode CreateNullCheckExpression(
471var identifier = factory.IdentifierName(identifierName);
472var nullExpr = factory.NullLiteralExpression();
473var condition = generatorInternal.SupportsPatterns(semanticModel.SyntaxTree.Options)
479public 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\InitializeParameter\AbstractInitializerParameterService.cs (22)
20where TStatementSyntax : SyntaxNode
22protected abstract bool IsFunctionDeclaration(SyntaxNode node);
24protected abstract SyntaxNode? GetAccessorBody(IMethodSymbol accessor, CancellationToken cancellationToken);
26protected abstract SyntaxNode GetBody(SyntaxNode methodNode);
27protected abstract SyntaxNode? TryGetLastStatement(IBlockOperation? blockStatement);
34SyntaxEditor editor, SyntaxNode functionDeclaration, bool returnsVoid, SyntaxNode? statementToAddAfter, TStatementSyntax statement);
37SyntaxNode functionDeclaration,
45var functionBody = GetBody(functionDeclaration);
79public void InsertStatement(SyntaxEditor editor, SyntaxNode functionDeclaration, bool returnsVoid, SyntaxNode? statementToAddAfter, SyntaxNode statement)
90var parameterDeclaration = parameterReference.GetSyntax(cancellationToken);
92var functionDeclaration = parameterDeclaration.FirstAncestorOrSelf<SyntaxNode>(IsFunctionDeclaration);
115SyntaxNode functionDeclaration,
123var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
135SyntaxNode constructorDeclaration,
159var statementToAddAfter = TryGetStatementToAddInitializationAfter(parameter, blockStatement);
164private SyntaxNode? TryGetStatementToAddInitializationAfter(
195using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var accessors);
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 canMove, bool mayChangeSemantics)> CanMoveDeclarationNearReferenceAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
46private async Task<State> ComputeStateAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
77Document document, SyntaxNode localDeclarationStatement, CancellationToken cancellationToken)
83var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
113var newRoot = editor.GetChangedRoot();
150var originalNextStatement = state.OutermostBlockStatements[statementIndex + 1];
186var 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);
112public abstract SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isToken, SyntaxNode pattern);
114public abstract SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right);
115public abstract SyntaxNode ConstantPattern(SyntaxNode expression);
116public abstract SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name);
117public abstract SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression);
118public abstract SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression);
119public abstract SyntaxNode LessThanRelationalPattern(SyntaxNode expression);
120public abstract SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression);
121public abstract SyntaxNode NotPattern(SyntaxNode pattern);
122public abstract SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right);
123public abstract SyntaxNode ParenthesizedPattern(SyntaxNode pattern);
124public abstract SyntaxNode TypePattern(SyntaxNode type);
125public abstract SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\AbstractSimplificationService.cs (30)
30where TCompilationUnitSyntax : SyntaxNode
31where TExpressionSyntax : SyntaxNode
32where TStatementSyntax : SyntaxNode
33where TCrefSyntax : SyntaxNode
35protected static readonly Func<SyntaxNode, bool> s_containsAnnotations = n => n.ContainsAnnotations;
40protected abstract ImmutableArray<NodeOrTokenToReduce> GetNodesAndTokensToReduce(SyntaxNode root, Func<SyntaxNodeOrToken, bool> isNodeOrTokenOutsideSimplifySpans);
41protected abstract SemanticModel GetSpeculativeSemanticModel(ref SyntaxNode nodeToSpeculate, SemanticModel originalSemanticModel, SyntaxNode originalNode);
42protected abstract bool NodeRequiresNonSpeculativeSemanticModel(SyntaxNode node);
43protected abstract void AddImportDeclarations(TCompilationUnitSyntax root, ArrayBuilder<SyntaxNode> importDeclarations);
48protected virtual SyntaxNode TransformReducedNode(SyntaxNode reducedNode, SyntaxNode originalNode)
51public abstract SyntaxNode Expand(SyntaxNode node, SemanticModel semanticModel, SyntaxAnnotation? annotationForReplacedAliasIdentifier, Func<SyntaxNode, bool>? expandInsideNode, bool expandParameter, CancellationToken cancellationToken);
52public abstract SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Func<SyntaxNode, bool>? expandInsideNode, CancellationToken cancellationToken);
115var reducedNodesMap = new ConcurrentDictionary<SyntaxNode, SyntaxNode>();
152SyntaxNode root,
156ConcurrentDictionary<SyntaxNode, SyntaxNode> reducedNodesMap,
218var replacedParent = isNode
229var currentNode = currentNodeOrToken.AsNode()!;
234var newRoot = root.ReplaceNode(nodeOrToken.AsNode()!, currentNode.WithAdditionalAnnotations(marker));
277using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var importDeclarations);
292var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
294var unusedImports = new HashSet<SyntaxNode>();
303var newRoot = gen.RemoveNodes(root, unusedImports);
312protected abstract void GetUnusedNamespaceImports(SemanticModel model, HashSet<SyntaxNode> namespaceImports, CancellationToken cancellationToken);
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)
294private 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 (320)
30private static readonly ObjectPool<List<SyntaxNode>> s_syntaxNodeListPool = new ObjectPool<List<SyntaxNode>>(() => [], trimOnFree: false);
134public bool IsDirective([NotNullWhen(true)] SyntaxNode? node)
137public bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? node, out ExternalSourceInfo info)
158public bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
164public bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
167public bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
174public SyntaxNode? GetStandaloneExpression(SyntaxNode? node)
177public SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node)
180public bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node)
183public bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node)
186public bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node)
189public SyntaxNode? GetParameterList(SyntaxNode node)
192public bool IsParameterList([NotNullWhen(true)] SyntaxNode? node)
195public bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node)
199public bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node)
202public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name)
210public bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node)
213public bool IsUsingLocalDeclarationStatement([NotNullWhen(true)] SyntaxNode? node)
216public bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node)
219public Location GetDeconstructionReferenceLocation(SyntaxNode node)
229public bool IsStatement([NotNullWhen(true)] SyntaxNode? node)
232public bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node)
235public bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node)
238public SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node)
241public bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement)
260public bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node)
272public SyntaxNode GetExpressionOfRefExpression(SyntaxNode node)
275public SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node)
319public bool IsPredefinedType(SyntaxNode? node)
322public bool IsPredefinedType(SyntaxNode? node, PredefinedType type)
543public bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node)
546public bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node)
549public bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
552public bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
555public void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity)
562public bool LooksGeneric(SyntaxNode simpleName)
566public SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName)
569public SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node)
572public SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node)
575public SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget)
578public void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList)
585public SyntaxNode GetExpressionOfInterpolation(SyntaxNode node)
588public bool IsInStaticContext(SyntaxNode node)
591public bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node)
594public bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node)
597public SyntaxNode GetExpressionOfArgument(SyntaxNode node)
600public SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node)
603public RefKind GetRefKindOfArgument(SyntaxNode node)
606public bool IsArgument([NotNullWhen(true)] SyntaxNode? node)
609public bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node)
612public bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node)
619public bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node)
622public bool IsInConstructor(SyntaxNode node)
625public bool IsUnsafeContext(SyntaxNode node)
628public bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node)
631public SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position)
635.GetAncestors<SyntaxNode>()
639public SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node)
642public bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node)
647public bool IsPropertyPatternClause(SyntaxNode node)
651[NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance)
682public bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression)
697public bool IsElementAccessExpression(SyntaxNode? node)
701public SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false)
704public SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
707public SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
710private static SyntaxNode? GetContainingMemberDeclaration<TMemberDeclarationSyntax>(SyntaxNode root, int position, bool useFullSpan = true)
723var node = root.FindToken(position).Parent;
741public bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node)
749public bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node)
758public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null)
820private static string? GetName(SyntaxNode node, DisplayNameOptions options)
907public PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root)
917public PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root)
927public SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration)
930private void AppendMembers(SyntaxNode? node, List<SyntaxNode> list, bool topLevel, bool methodLevel)
954public TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node)
961var member = GetContainingMemberDeclaration(node, node.SpanStart);
981public bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span)
1004public SyntaxNode? TryGetBindableParent(SyntaxToken token)
1006var node = token.Parent;
1009var parent = node.Parent;
1067public IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken)
1072var constructors = new List<SyntaxNode>();
1077private static void AppendConstructors(SyntaxList<MemberDeclarationSyntax> members, List<SyntaxNode> constructors, CancellationToken cancellationToken)
1141public string GetNameForArgument(SyntaxNode? argument)
1144public string GetNameForAttributeArgument(SyntaxNode? argument)
1147public bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node)
1150public SyntaxNode? GetRightSideOfDot(SyntaxNode? node)
1156public SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget)
1162public bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node)
1165public bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node)
1168public bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node)
1171public bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node)
1174public SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node)
1177public bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node)
1181public bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node)
1184public static bool IsOperandOfDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1187public bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1190public SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString)
1206public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode objectCreationExpression)
1211public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode argumentList)
1214public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode argumentList)
1226public bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes)
1232public bool IsDocumentationComment(SyntaxNode node)
1235public bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node)
1238public bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node)
1241public bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node)
1244private static bool IsGlobalAttribute([NotNullWhen(true)] SyntaxNode? node, SyntaxKind attributeTarget)
1249public bool IsDeclaration(SyntaxNode? node)
1298public bool IsTypeDeclaration(SyntaxNode node)
1301public bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement)
1306SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1313SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1315var expression = statement;
1328public bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? node)
1331public SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node)
1334public SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node)
1337public SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node)
1345public bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement)
1352public bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2)
1355public static SyntaxNode GetExpressionOfInvocationExpression(SyntaxNode node)
1358public bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node)
1361public SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node)
1364public void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
1365out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
1369arguments = (SeparatedSyntaxList<TArgumentSyntax>)(SeparatedSyntaxList<SyntaxNode>)tupleExpression.Arguments;
1376public SyntaxNode? GetMatchingDirective(SyntaxNode directive, CancellationToken cancellationToken)
1379public ImmutableArray<SyntaxNode> GetMatchingConditionalDirectives(SyntaxNode directive, CancellationToken cancellationToken)
1380=> ((DirectiveTriviaSyntax)directive).GetMatchingConditionalDirectives(cancellationToken).CastArray<SyntaxNode>();
1385public SyntaxTokenList GetModifiers(SyntaxNode? node)
1389public SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers)
1392public SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node)
1395public SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node)
1398public SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node)
1401public SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node)
1404public SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node)
1407public bool IsEqualsValueOfPropertyDeclaration(SyntaxNode? node)
1410public bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node)
1413public bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node)
1416public void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression)
1433public SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node)
1436public bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node)
1440public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia)
1450public void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type)
1457public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right)
1465public bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node)
1468public SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node)
1471public void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation)
1478public void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation)
1494public bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node)
1497public bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node)
1500public void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen)
1508public void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1516public void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern)
1523public void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression)
1530public SyntaxNode GetTypeOfTypePattern(SyntaxNode node)
1533public bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node)
1548public bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node)
1551public bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node)
1554public bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node)
1557public bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node)
1560public bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
1563public bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node)
1566public bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node)
1569public bool IsAnyName([NotNullWhen(true)] SyntaxNode? node)
1572public bool IsAnyType([NotNullWhen(true)] SyntaxNode? node)
1575public bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1578public bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node)
1581public bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1584public bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node)
1591public void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name)
1599public void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken)
1607public void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList)
1614public void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1621public void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1629public void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members)
1638SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull)
1646public void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse)
1654public SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement)
1660public void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments)
1667public void GetPartsOfInterpolationExpression(SyntaxNode node,
1668out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken)
1676public void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList)
1683public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
1691public void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members)
1699public void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode identifier, out SyntaxNode expression)
1706public void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1715public void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer)
1723public void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default)
1731SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen)
1739public void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand)
1746public void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1758public SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node)
1761public SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node)
1764public SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node)
1767public SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node)
1770public SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node)
1773public SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node)
1776public SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node)
1779public 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)
32protected override bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
35protected override bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
38protected override bool IsImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
43SyntaxNode node,
81SyntaxNode node,
113SyntaxNode node,
148SyntaxNode 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\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (24)
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)
377var attributeSyntaxToRemove = attributeToRemove.ApplicationSyntaxReference.GetSyntax(cancellationToken);
383SyntaxNode attributeToRemove,
443SyntaxNode attributeToRemove,
479IEnumerable<SyntaxNode> statements,
531IEnumerable<SyntaxNode> statements,
533CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
570TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, BaseMethodDeclarationSyntax baseMethodDeclaration) where TDeclarationNode : SyntaxNode
590public static BlockSyntax AddStatementsToBlock(BlockSyntax block, IEnumerable<SyntaxNode> statements)
613TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode
634TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, AnonymousFunctionExpressionSyntax anonymousFunctionSyntax) where TDeclarationNode : SyntaxNode
658public override SyntaxNode CreateEventDeclaration(
664public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
672public override SyntaxNode? CreateMethodDeclaration(
721public override SyntaxNode CreatePropertyDeclaration(
728public override SyntaxNode CreateNamedTypeDeclaration(
734public override SyntaxNode CreateNamespaceDeclaration(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (27)
36protected override ImmutableArray<SyntaxNode> GetGlobalImports(Compilation compilation, SyntaxGenerator generator)
39protected override SyntaxNode? GetAlias(UsingDirectiveSyntax usingOrAlias)
45protected override SyntaxNode Rewrite(
50SyntaxNode externContainer,
51SyntaxNode usingContainer,
52SyntaxNode staticUsingContainer,
53SyntaxNode aliasContainer,
55SyntaxNode root,
63var newRoot = rewriter.Visit(root);
67protected override SyntaxList<UsingDirectiveSyntax> GetUsingsAndAliases(SyntaxNode node)
75protected override SyntaxList<ExternAliasDirectiveSyntax> GetExterns(SyntaxNode node)
83protected override bool IsEquivalentImport(SyntaxNode a, SyntaxNode b)
90private readonly SyntaxNode _externContainer;
91private readonly SyntaxNode _usingContainer;
92private readonly SyntaxNode _aliasContainer;
93private readonly SyntaxNode _staticUsingContainer;
104SyntaxNode externContainer,
105SyntaxNode usingContainer,
106SyntaxNode aliasContainer,
107SyntaxNode staticUsingContainer,
124public override SyntaxNode? Visit(SyntaxNode? node)
127public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
130public override SyntaxNode? VisitFileScopedNamespaceDeclaration(FileScopedNamespaceDeclarationSyntax node)
133private SyntaxNode VisitBaseNamespaceDeclaration(
167public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (68)
51public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst)
58public override SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer)
61public override SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
64internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode? type, SyntaxToken name, SyntaxNode? expression)
76public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
79public override SyntaxNode MemberBindingExpression(SyntaxNode name)
82public override SyntaxNode RefExpression(SyntaxNode expression)
85public override SyntaxNode AddParentheses(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
88internal static SyntaxNode Parenthesize(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
96public override SyntaxNode YieldReturnStatement(SyntaxNode expression)
105public override SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
108public override SyntaxNode InterpolatedStringText(SyntaxToken textToken)
118public override SyntaxNode Interpolation(SyntaxNode syntaxNode)
121public override SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment)
124public override SyntaxNode InterpolationFormatClause(string format)
129public override SyntaxNode TypeParameterList(IEnumerable<string> typeParameterNames)
178public override SyntaxNode Type(ITypeSymbol typeSymbol, bool typeContext)
181public override SyntaxNode NegateEquality(SyntaxGenerator generator, SyntaxNode binaryExpression, SyntaxNode left, BinaryOperatorKind negatedKind, SyntaxNode right)
189public override SyntaxNode IsNotTypeExpression(SyntaxNode expression, SyntaxNode type)
197public override SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isKeyword, SyntaxNode pattern)
203public override SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right)
206public override SyntaxNode ConstantPattern(SyntaxNode expression)
209public override SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name)
214public override SyntaxNode LessThanRelationalPattern(SyntaxNode expression)
217public override SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression)
220public override SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression)
223public override SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression)
226public override SyntaxNode NotPattern(SyntaxNode pattern)
229public override SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right)
232public override SyntaxNode ParenthesizedPattern(SyntaxNode pattern)
235public override SyntaxNode TypePattern(SyntaxNode type)
238public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern)
AddImport\CSharpAddImportFeatureService.cs (26)
39protected override bool IsWithinImport(SyntaxNode node)
42protected override bool CanAddImport(SyntaxNode node, bool allowInHiddenRegions, CancellationToken cancellationToken)
46string diagnosticId, ISyntaxFacts syntaxFacts, SyntaxNode node, out SimpleNameSyntax nameNode)
135protected override bool CanAddImportForDeconstruct(string diagnosticId, SyntaxNode node)
138protected override bool CanAddImportForGetAwaiter(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node)
144protected override bool CanAddImportForGetEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node)
147protected override bool CanAddImportForGetAsyncEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node)
150protected override bool CanAddImportForNamespace(string diagnosticId, SyntaxNode node, out SimpleNameSyntax nameNode)
156protected override bool CanAddImportForQuery(string diagnosticId, SyntaxNode node)
162string diagnosticId, SyntaxNode node, out SimpleNameSyntax nameNode)
207private static bool TryFindStandaloneType(SyntaxNode node, out SimpleNameSyntax nameNode)
236SyntaxNode node,
243SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
250SyntaxNode node,
297SyntaxNode contextNode,
343SyntaxNode contextNode,
355Document document, CompilationUnitSyntax root, SyntaxNode contextNode, INamespaceOrTypeSymbol namespaceOrTypeSymbol,
366using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var newImports);
391SyntaxNode contextNode, IReadOnlyList<string> namespaceParts,
425SyntaxNode contextNode)
444SyntaxNode contextNode)
562SyntaxNode contextNode)
588private static bool HasExistingExternAlias(string alias, SyntaxNode contextNode)
603SyntaxNode contextNode, CancellationToken cancellationToken)
608protected override bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
631protected 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 SyntaxNode ChangeSignature(
292SyntaxNode potentiallyUpdatedNode,
293SyntaxNode originalNode,
583private static bool IsParamsArrayExpanded(SemanticModel semanticModel, SyntaxNode node, SymbolInfo symbolInfo, CancellationToken cancellationToken)
670Func<AddedParameter, T> createNewParameterMethod) where T : SyntaxNode
676protected override T TransferLeadingWhitespaceTrivia<T>(T newArgument, SyntaxNode oldArgument)
703where TArgumentSyntax : SyntaxNode
751where T : SyntaxNode
752where U : SyntaxNode
790private ImmutableArray<SyntaxNode> VerifyAndPermuteParamNodes(IEnumerable<XmlElementSyntax> paramNodes, ISymbol declarationSymbol, SignatureChange updatedSignature)
830var permutedParams = ArrayBuilder<SyntaxNode>.GetInstance();
858using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var convertedMethodNodes);
896ArgumentSyntax a => (TArgumentSyntax)(SyntaxNode)a.WithNameColon(NameColon(name)),
897AttributeArgumentSyntax a => (TArgumentSyntax)(SyntaxNode)a.WithNameColon(NameColon(name)),
907var listOfArguments = SeparatedList(newArguments.Skip(indexInExistingList).Select(a => ((ArgumentSyntax)(SyntaxNode)a).Expression), newArguments.GetSeparators().Skip(indexInExistingList));
910return (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>();
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)
38private abstract partial class CSharpCodeGenerator : CodeGenerator<StatementSyntax, SyntaxNode, CSharpCodeGenerationOptions>
88public override OperationStatus<ImmutableArray<SyntaxNode>> GetNewMethodStatements(SyntaxNode insertionPointNode, CancellationToken cancellationToken)
92return status.With(statements.CastArray<SyntaxNode>());
96SyntaxNode insertionPointNode, CancellationToken cancellationToken)
111statements: statements.CastArray<SyntaxNode>(),
118protected override async Task<SyntaxNode> GenerateBodyForCallSiteContainerAsync(
119SyntaxNode insertionPointNode,
120SyntaxNode container,
125var firstStatementToRemove = GetFirstStatementOrInitializerSelectedAtCallSite();
126var lastStatementToRemove = GetLastStatementOrInitializerSelectedAtCallSite();
144private async Task<ImmutableArray<SyntaxNode>> CreateStatementsOrInitializerToInsertAtCallSiteAsync(
145SyntaxNode insertionPointNode, CancellationToken cancellationToken)
147var selectedNode = GetFirstStatementOrInitializerSelectedAtCallSite();
168return statements.CastArray<SyntaxNode>();
171protected override bool ShouldLocalFunctionCaptureParameter(SyntaxNode node)
174private static bool IsExpressionBodiedMember(SyntaxNode node)
177private static bool IsExpressionBodiedAccessor(SyntaxNode node)
195protected override SyntaxNode GetCallSiteContainerFromOutermostMoveInVariable(CancellationToken cancellationToken)
264SyntaxNode insertionPoint, CancellationToken cancellationToken)
433var replacements = new Dictionary<SyntaxNode, SyntaxNode>();
438foreach (var node in declarations)
517SyntaxNode insertionPointNode,
532var lastStatement = GetLastStatementOrInitializerSelectedAtCallSite();
533var container = lastStatement.GetAncestorsOrThis<SyntaxNode>().FirstOrDefault(n => n.IsReturnableConstruct());
703var root = newDocument.Root;
704var methodDefinition = root.GetAnnotatedNodes<SyntaxNode>(MethodDefinitionAnnotation).First();
706SyntaxNode newMethodDefinition = methodDefinition switch
725private static TDeclarationNode TweakNewLinesInMethod<TDeclarationNode>(TDeclarationNode method, BlockSyntax body, ArrowExpressionClauseSyntax expressionBody) where TDeclarationNode : SyntaxNode
770static bool ReturnOperationBelongsToMethod(SyntaxNode returnOperationSyntax, SyntaxNode methodSyntax)
772var enclosingMethod = returnOperationSyntax.FirstAncestorOrSelf<SyntaxNode>(n => n switch
784SyntaxNode node,
800var syntax = returnOperation.ReturnedValue?.Syntax ?? returnOperation.Syntax;
ExtractMethod\CSharpSelectionValidator.cs (16)
36var root = SemanticDocument.Root;
175var firstValidNode = node.GetAncestors<SyntaxNode>().FirstOrDefault(n => Check(semanticModel, n, cancellationToken));
192private SelectionInfo GetInitialSelectionInfo(SyntaxNode root, SourceText text)
274=> token.GetAncestors<SyntaxNode>().Any(n => CheckTopLevel(n, token.Span));
276private static bool CheckTopLevel(SyntaxNode node, TextSpan span)
336SyntaxNode root)
393private static SelectionInfo AssignInitialFinalTokens(SelectionInfo selectionInfo, SyntaxNode root, CancellationToken cancellationToken)
457public override bool ContainsNonReturnExitPointsStatements(IEnumerable<SyntaxNode> jumpsOutOfRegion)
460public override IEnumerable<SyntaxNode> GetOuterReturnStatements(SyntaxNode commonRoot, IEnumerable<SyntaxNode> jumpsOutOfRegion)
464var container = commonRoot.GetAncestorsOrThis<SyntaxNode>().Where(a => a.IsReturnableConstruct()).FirstOrDefault();
468var returnableConstructPairs = returnStatements.Select(r => (r, r.GetAncestors<SyntaxNode>().Where(a => a.IsReturnableConstruct()).FirstOrDefault()))
476SyntaxNode root, TextSpan textSpan,
477IEnumerable<SyntaxNode> returnStatements, CancellationToken cancellationToken)
491var container = lastToken.GetAncestors<SyntaxNode>().FirstOrDefault(n => n.IsReturnableConstruct());
GenerateType\CSharpGenerateTypeService.cs (9)
477? genericName.TypeArgumentList.Arguments.OfType<SyntaxNode>().ToList()
478: Enumerable.Repeat<SyntaxNode>(null, state.SimpleName.Arity);
544INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken)
663var node = expression as SyntaxNode;
664SyntaxNode previousNode = null;
700private static bool IsAllContainingTypeDeclsPublic(SyntaxNode node)
715Solution updatedSolution, SyntaxNode modifiedRoot, Document document, SimpleNameSyntax simpleName, string includeUsingsOrImports, CancellationToken cancellationToken)
723SyntaxNode root = null;
ImplementInterface\AbstractChangeImplementationCodeRefactoringProvider.cs (8)
43protected abstract SyntaxNode ChangeImplementation(SyntaxGenerator generator, SyntaxNode currentDecl, ISymbol implMember, ISymbol interfaceMember);
127private static async Task<(SyntaxNode?, ExplicitInterfaceSpecifierSyntax?, SyntaxToken)> GetContainerAsync(CodeRefactoringContext context)
154private static (SyntaxNode? declaration, ExplicitInterfaceSpecifierSyntax?, SyntaxToken) GetContainer(SyntaxToken token)
156for (var node = token.Parent; node != null; node = node.Parent)
163_ => default((SyntaxNode member, ExplicitInterfaceSpecifierSyntax?, SyntaxToken)),
229var documentToImplDeclarations = new OrderedMultiDictionary<Document, (SyntaxNode, ISymbol impl, SetWithInsertionOrder<ISymbol> interfaceMembers)>();
239var decl = GetContainer(declToken).declaration;
InlineHints\CSharpInlineParameterNameHintsService.cs (5)
29SyntaxNode node,
30ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> buffer,
45ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> buffer,
61ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> buffer,
98protected override bool IsIndexer(SyntaxNode node, IParameterSymbol parameter)
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)
32protected override bool IsSimpleNameGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
35protected override bool IsConstructorInitializerGeneration(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
38protected override bool IsImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken)
43SyntaxNode node,
81SyntaxNode node,
113SyntaxNode node,
148SyntaxNode node,
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (11)
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,
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)
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)
69internal override SyntaxTrivia Trivia(SyntaxNode node)
79internal override SyntaxNode DocumentationCommentTrivia(IEnumerable<SyntaxNode> nodes, SyntaxTriviaList trailingTrivia, string endOfLineString)
92internal override SyntaxNode? DocumentationCommentTriviaWithUpdatedContent(SyntaxTrivia trivia, IEnumerable<SyntaxNode> content)
105public override SyntaxNode CompilationUnit(IEnumerable<SyntaxNode> declarations)
112private SyntaxList<UsingDirectiveSyntax> AsUsingDirectives(IEnumerable<SyntaxNode> declarations)
119private SyntaxNode? AsUsingDirective(SyntaxNode node)
129private static SyntaxList<MemberDeclarationSyntax> AsNamespaceMembers(IEnumerable<SyntaxNode> declarations)
136private static SyntaxNode? AsNamespaceMember(SyntaxNode declaration)
155public override SyntaxNode NamespaceImportDeclaration(SyntaxNode name)
158public override SyntaxNode AliasImportDeclaration(string aliasIdentifierName, SyntaxNode name)
161public override SyntaxNode NamespaceDeclaration(SyntaxNode name, IEnumerable<SyntaxNode> declarations)
170public override SyntaxNode FieldDeclaration(
172SyntaxNode type,
175SyntaxNode? initializer)
191private protected override SyntaxNode ParameterDeclaration(
192string name, SyntaxNode? type, SyntaxNode? initializer, RefKind refKind, bool isExtension, bool isParams, bool isScoped)
225private protected override SyntaxNode MethodDeclaration(
227IEnumerable<SyntaxNode>? parameters,
228IEnumerable<SyntaxNode>? typeParameters,
229SyntaxNode? returnType,
232IEnumerable<SyntaxNode>? statements)
264public override SyntaxNode OperatorDeclaration(OperatorKind kind, IEnumerable<SyntaxNode>? parameters = null, SyntaxNode? returnType = null, Accessibility accessibility = Accessibility.NotApplicable, DeclarationModifiers modifiers = default, IEnumerable<SyntaxNode>? statements = null)
270private 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)
347private static ParameterListSyntax AsParameterList(IEnumerable<SyntaxNode>? parameters)
354public override SyntaxNode ConstructorDeclaration(
356IEnumerable<SyntaxNode>? parameters,
359IEnumerable<SyntaxNode>? baseConstructorArguments,
360IEnumerable<SyntaxNode>? statements)
371private protected override SyntaxNode DestructorDeclaration(IMethodSymbol destructorMethod)
374public override SyntaxNode PropertyDeclaration(
376SyntaxNode type,
379IEnumerable<SyntaxNode>? getAccessorStatements,
380IEnumerable<SyntaxNode>? setAccessorStatements)
382SyntaxNode? getAccessor = null;
383SyntaxNode? setAccessor = null;
394private protected override SyntaxNode PropertyDeclaration(
396SyntaxNode type,
397SyntaxNode? getAccessor,
398SyntaxNode? setAccessor,
420public override SyntaxNode GetAccessorDeclaration(Accessibility accessibility, IEnumerable<SyntaxNode>? statements)
423private protected override SyntaxNode SetAccessorDeclaration(Accessibility accessibility, bool isInitOnly, IEnumerable<SyntaxNode>? statements)
426private static SyntaxNode AccessorDeclaration(
427SyntaxKind kind, Accessibility accessibility, IEnumerable<SyntaxNode>? statements)
440public override SyntaxNode WithAccessorDeclarations(SyntaxNode declaration, IEnumerable<SyntaxNode> accessorDeclarations)
454private static AccessorListSyntax CreateAccessorList(AccessorListSyntax? accessorList, IEnumerable<SyntaxNode> accessorDeclarations)
462public override SyntaxNode IndexerDeclaration(
463IEnumerable<SyntaxNode> parameters,
464SyntaxNode type,
467IEnumerable<SyntaxNode>? getAccessorStatements,
468IEnumerable<SyntaxNode>? setAccessorStatements)
509private static BracketedParameterListSyntax AsBracketedParameterList(IEnumerable<SyntaxNode> parameters)
516private static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, IEnumerable<SyntaxNode>? statements)
530public override SyntaxNode EventDeclaration(
532SyntaxNode type,
544public override SyntaxNode CustomEventDeclaration(
546SyntaxNode type,
549IEnumerable<SyntaxNode>? parameters,
550IEnumerable<SyntaxNode>? addAccessorStatements,
551IEnumerable<SyntaxNode>? removeAccessorStatements)
577public override SyntaxNode? AsPublicInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceTypeName, string? interfaceMemberName)
594public override SyntaxNode? AsPrivateInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceTypeName, string? interfaceMemberName)
610private SyntaxNode WithoutConstraints(SyntaxNode declaration)
623private static SyntaxNode WithInterfaceSpecifier(SyntaxNode declaration, ExplicitInterfaceSpecifierSyntax? specifier)
635private SyntaxNode AsImplementation(SyntaxNode declaration, Accessibility requiredAccess)
643private static SyntaxNode WithBodies(SyntaxNode declaration)
692private protected override SyntaxNode ClassDeclaration(
695IEnumerable<SyntaxNode>? typeParameters,
698SyntaxNode? baseType,
699IEnumerable<SyntaxNode>? interfaceTypes,
700IEnumerable<SyntaxNode>? members)
724private SyntaxList<MemberDeclarationSyntax> AsClassMembers(string className, IEnumerable<SyntaxNode>? members)
731private MemberDeclarationSyntax? AsClassMember(SyntaxNode node, string className)
748private protected override SyntaxNode StructDeclaration(
751IEnumerable<SyntaxNode>? typeParameters,
754IEnumerable<SyntaxNode>? interfaceTypes,
755IEnumerable<SyntaxNode>? members)
771private protected override SyntaxNode InterfaceDeclaration(
773IEnumerable<SyntaxNode>? typeParameters,
775IEnumerable<SyntaxNode>? interfaceTypes = null,
776IEnumerable<SyntaxNode>? members = null)
794private SyntaxList<MemberDeclarationSyntax> AsInterfaceMembers(IEnumerable<SyntaxNode>? members)
801internal override SyntaxNode AsInterfaceMember(SyntaxNode m)
864var type = GetType(f);
876public override SyntaxNode EnumDeclaration(
880IEnumerable<SyntaxNode>? members)
885internal override SyntaxNode EnumDeclaration(string name, SyntaxNode? underlyingType, Accessibility accessibility = Accessibility.NotApplicable, DeclarationModifiers modifiers = default, IEnumerable<SyntaxNode>? members = null)
895public override SyntaxNode EnumMember(string name, SyntaxNode? expression)
903private EnumMemberDeclarationSyntax AsEnumMember(SyntaxNode node)
925private SeparatedSyntaxList<EnumMemberDeclarationSyntax> AsEnumMembers(IEnumerable<SyntaxNode>? members)
928private protected override SyntaxNode DelegateDeclaration(
930IEnumerable<SyntaxNode>? parameters,
931IEnumerable<SyntaxNode>? typeParameters,
932SyntaxNode? returnType,
946public override SyntaxNode Attribute(SyntaxNode name, IEnumerable<SyntaxNode>? attributeArguments)
949public override SyntaxNode AttributeArgument(string? name, SyntaxNode expression)
956private static AttributeArgumentListSyntax? AsAttributeArgumentList(IEnumerable<SyntaxNode>? arguments)
959private static AttributeArgumentSyntax AsAttributeArgument(SyntaxNode node)
988private static SyntaxList<AttributeListSyntax> AsAttributeLists(IEnumerable<SyntaxNode> attributes)
993private static AttributeListSyntax AsAttributeList(SyntaxNode node)
998private static readonly ConditionalWeakTable<SyntaxNode, IReadOnlyList<SyntaxNode>> s_declAttributes = new();
1000public override IReadOnlyList<SyntaxNode> GetAttributes(SyntaxNode declaration)
1011private static readonly ConditionalWeakTable<SyntaxNode, IReadOnlyList<SyntaxNode>> s_declReturnAttributes = new();
1013public override IReadOnlyList<SyntaxNode> GetReturnAttributes(SyntaxNode declaration)
1027public override SyntaxNode InsertAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes)
1030private SyntaxNode InsertAttributesInternal(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes)
1051public override SyntaxNode InsertReturnAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes)
1065private SyntaxNode InsertReturnAttributesInternal(SyntaxNode d, int index, IEnumerable<SyntaxNode> attributes)
1086private static IEnumerable<AttributeListSyntax> AsReturnAttributes(IEnumerable<SyntaxNode> attributes)
1097private static SyntaxList<AttributeListSyntax> WithRequiredTargetSpecifier(SyntaxList<AttributeListSyntax> attributes, SyntaxNode declaration)
1107public override IReadOnlyList<SyntaxNode> GetAttributeArguments(SyntaxNode attributeDeclaration)
1132public override SyntaxNode InsertAttributeArguments(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributeArguments)
1135private static SyntaxNode InsertAttributeArgumentsInternal(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributeArguments)
1155private static AttributeArgumentListSyntax? GetAttributeArgumentList(SyntaxNode declaration)
1175private static SyntaxNode WithAttributeArgumentList(SyntaxNode declaration, AttributeArgumentListSyntax? argList)
1195internal static SyntaxList<AttributeListSyntax> GetAttributeLists(SyntaxNode declaration)
1206private static SyntaxNode WithAttributeLists(SyntaxNode declaration, SyntaxList<AttributeListSyntax> attributeLists)
1219internal override SyntaxNode? GetPrimaryConstructorParameterList(SyntaxNode declaration)
1222internal override ImmutableArray<SyntaxNode> GetTypeInheritance(SyntaxNode declaration)
1225: ImmutableArray<SyntaxNode>.Empty;
1227public override IReadOnlyList<SyntaxNode> GetNamespaceImports(SyntaxNode declaration)
1235public override SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports)
1237var result = PreserveTrivia(declaration, d => InsertNamespaceImportsInternal(d, index, imports));
1242private SyntaxNode InsertNamespaceImportsInternal(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports)
1254public override IReadOnlyList<SyntaxNode> GetMembers(SyntaxNode declaration)
1264private static ImmutableArray<SyntaxNode> Flatten(IEnumerable<SyntaxNode> declarations)
1266var builder = ArrayBuilder<SyntaxNode>.GetInstance();
1268foreach (var declaration in declarations)
1309static void FlattenDeclaration(ArrayBuilder<SyntaxNode> builder, SyntaxNode declaration, VariableDeclarationSyntax variableDeclaration)
1322private static int GetDeclarationCount(SyntaxNode declaration)
1333private static SyntaxNode EnsureTypeDeclarationHasBody(SyntaxNode declaration)
1346public override SyntaxNode InsertMembers(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> members)
1374private IEnumerable<MemberDeclarationSyntax>? AsMembersOf(SyntaxNode declaration, IEnumerable<SyntaxNode>? members)
1377private SyntaxNode? AsMemberOf(SyntaxNode declaration, SyntaxNode member)
1388private static bool CanHaveAccessibility(SyntaxNode declaration)
1396public override Accessibility GetAccessibility(SyntaxNode declaration)
1402public override SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibility accessibility)
1604public override DeclarationModifiers GetModifiers(SyntaxNode declaration)
1611private static SyntaxTokenList GetModifierTokens(SyntaxNode declaration)
1614public override SyntaxNode WithModifiers(SyntaxNode declaration, DeclarationModifiers modifiers)
1617private SyntaxNode WithModifiersInternal(SyntaxNode declaration, DeclarationModifiers modifiers)
1649private static SyntaxNode SetModifierTokens(SyntaxNode declaration, SyntaxTokenList modifiers)
1725private protected override SyntaxNode TypeParameter(string name)
1728private protected override SyntaxNode TypeParameter(ITypeParameterSymbol typeParameter)
1741private static TypeParameterListSyntax? AsTypeParameterList(IEnumerable<SyntaxNode>? typeParameterNodes)
1750private protected override SyntaxNode WithTypeParameters(SyntaxNode declaration, IEnumerable<SyntaxNode> typeParameters)
1763internal override SyntaxNode WithExplicitInterfaceImplementations(
1764SyntaxNode declaration,
1788private static SyntaxNode RemoveDefaultValue(ParameterSyntax parameter, bool removeDefaults)
1806private protected override SyntaxNode WithTypeConstraint(
1807SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, bool isUnmanagedType, IEnumerable<SyntaxNode>? types)
1816private protected override SyntaxNode WithDefaultConstraint(SyntaxNode declaration, string typeParameterName)
1828IEnumerable<SyntaxNode>? types)
1874public override DeclarationKind GetDeclarationKind(SyntaxNode declaration)
1877public override string GetName(SyntaxNode declaration)
1899public override SyntaxNode WithName(SyntaxNode declaration, string name)
1902private SyntaxNode WithNameInternal(SyntaxNode declaration, string name)
1939public override SyntaxNode? GetType(SyntaxNode declaration)
1978public override SyntaxNode WithType(SyntaxNode declaration, SyntaxNode type)
1981private static SyntaxNode WithTypeInternal(SyntaxNode declaration, SyntaxNode type)
1997private SyntaxNode Isolate(SyntaxNode declaration, Func<SyntaxNode, SyntaxNode> editor)
2000private SyntaxNode AsIsolatedDeclaration(SyntaxNode declaration)
2036private static SyntaxNode WithVariable(SyntaxNode declaration, VariableDeclaratorSyntax variable)
2047private static VariableDeclarationSyntax? GetVariableDeclaration(SyntaxNode declaration)
2056private static SyntaxNode WithVariableDeclaration(SyntaxNode declaration, VariableDeclarationSyntax variables)
2065private static SyntaxNode GetFullDeclaration(SyntaxNode declaration)
2096private SyntaxNode? AsNodeLike(SyntaxNode existingNode, SyntaxNode newNode)
2106var container = GetDeclaration(existingNode.Parent);
2121public override IReadOnlyList<SyntaxNode> GetParameters(SyntaxNode declaration)
2131public override SyntaxNode InsertParameters(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> parameters)
2144public override IReadOnlyList<SyntaxNode> GetSwitchSections(SyntaxNode switchStatement)
2150public override SyntaxNode InsertSwitchSections(SyntaxNode switchStatement, int index, IEnumerable<SyntaxNode> switchSections)
2177public override SyntaxNode? Visit(SyntaxNode? node)
2200internal override SyntaxNode? GetParameterListNode(SyntaxNode declaration)
2203private static SyntaxNode WithParameterList(SyntaxNode declaration, BaseParameterListSyntax list)
2249public override SyntaxNode? GetExpression(SyntaxNode declaration)
2299public override SyntaxNode WithExpression(SyntaxNode declaration, SyntaxNode expression)
2302private static SyntaxNode WithExpressionInternal(SyntaxNode declaration, SyntaxNode expression)
2375private static EqualsValueClauseSyntax? GetEqualsValue(SyntaxNode declaration)
2415private static SyntaxNode WithEqualsValue(SyntaxNode declaration, EqualsValueClauseSyntax? initializer)
2455public override IReadOnlyList<SyntaxNode> GetStatements(SyntaxNode declaration)
2477public override SyntaxNode WithStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
2502public override IReadOnlyList<SyntaxNode> GetAccessors(SyntaxNode declaration)
2508public override SyntaxNode InsertAccessors(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> accessors)
2529internal static AccessorListSyntax? GetAccessorList(SyntaxNode declaration)
2532private static bool CanHaveAccessors(SyntaxNode declaration)
2541private static SyntaxNode WithAccessorList(SyntaxNode declaration, AccessorListSyntax accessorList)
2548private static AccessorListSyntax AsAccessorList(IEnumerable<SyntaxNode> nodes, SyntaxKind parentKind)
2551private static AccessorDeclarationSyntax? AsAccessor(SyntaxNode node, SyntaxKind parentKind)
2579private static AccessorDeclarationSyntax? GetAccessor(SyntaxNode declaration, SyntaxKind kind)
2585private SyntaxNode WithAccessor(SyntaxNode declaration, SyntaxKind kind, AccessorDeclarationSyntax accessor)
2588private SyntaxNode WithAccessor(SyntaxNode declaration, AccessorListSyntax? accessorList, SyntaxKind kind, AccessorDeclarationSyntax? accessor)
2606public override IReadOnlyList<SyntaxNode> GetGetAccessorStatements(SyntaxNode declaration)
2612public override IReadOnlyList<SyntaxNode> GetSetAccessorStatements(SyntaxNode declaration)
2618public override SyntaxNode WithGetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
2621public override SyntaxNode WithSetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements)
2624private SyntaxNode WithAccessorStatements(SyntaxNode declaration, SyntaxKind kind, IEnumerable<SyntaxNode> statements)
2638public override IReadOnlyList<SyntaxNode> GetBaseAndInterfaceTypes(SyntaxNode declaration)
2651public override SyntaxNode AddBaseType(SyntaxNode declaration, SyntaxNode baseType)
2665public override SyntaxNode AddInterfaceType(SyntaxNode declaration, SyntaxNode interfaceType)
2679private static SyntaxNode AddBaseList(SyntaxNode declaration, BaseListSyntax baseList)
2681var newDecl = WithBaseList(declaration, baseList);
2687private static BaseListSyntax? GetBaseList(SyntaxNode declaration)
2692private static SyntaxNode WithBaseList(SyntaxNode declaration, BaseListSyntax baseList)
2701public override SyntaxNode ReplaceNode(SyntaxNode root, SyntaxNode declaration, SyntaxNode? newDeclaration)
2716var newFullDecl = AsIsolatedDeclaration(newDeclaration);
2717var fullDecl = GetFullDeclaration(declaration);
2725var newSubDecl = GetSubDeclarations(newFullDecl)[0];
2749private static bool AreInlineReplaceableSubDeclarations(SyntaxNode decl1, SyntaxNode decl2)
2765private static bool AreSimilarExceptForSubDeclarations(SyntaxNode? decl1, SyntaxNode? decl2)
2814private IEnumerable<SyntaxNode> SplitAndReplace(SyntaxNode multiPartDeclaration, int index, IEnumerable<SyntaxNode> newDeclarations)
2820var newNodes = new List<SyntaxNode>();
2844public override SyntaxNode InsertNodesBefore(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2863private SyntaxNode InsertNodesBeforeInternal(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2865var fullDecl = GetFullDeclaration(declaration);
2883public override SyntaxNode InsertNodesAfter(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2902private SyntaxNode InsertNodesAfterInternal(SyntaxNode root, SyntaxNode declaration, IEnumerable<SyntaxNode> newDeclarations)
2904var fullDecl = GetFullDeclaration(declaration);
2923private IEnumerable<SyntaxNode> SplitAndInsert(SyntaxNode multiPartDeclaration, int index, IEnumerable<SyntaxNode> newDeclarations)
2926var newNodes = new List<SyntaxNode>
2935private SyntaxNode WithSubDeclarationsRemoved(SyntaxNode declaration, int index, int count)
2938private static IReadOnlyList<SyntaxNode> GetSubDeclarations(SyntaxNode declaration)
2949public override SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node)
2952public override SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node, SyntaxRemoveOptions options)
2973private SyntaxNode RemoveNodeInternal(SyntaxNode root, SyntaxNode declaration, SyntaxRemoveOptions options)
2999var full = GetFullDeclaration(declaration);
3018var parent = declaration.Parent;
3037private static SyntaxNode ShiftTrivia(SyntaxNode root, SyntaxNode node)
3043var newNode = node.WithTrailingTrivia(node.GetTrailingTrivia().AddRange(previousToken.TrailingTrivia));
3061public override SyntaxNode AddEventHandler(SyntaxNode @event, SyntaxNode handler)
3064public override SyntaxNode RemoveEventHandler(SyntaxNode @event, SyntaxNode handler)
3067public override SyntaxNode AwaitExpression(SyntaxNode expression)
3070public override SyntaxNode NameOfExpression(SyntaxNode expression)
3073public override SyntaxNode ReturnStatement(SyntaxNode? expression = null)
3076public override SyntaxNode ThrowStatement(SyntaxNode? expression = null)
3079public override SyntaxNode ThrowExpression(SyntaxNode expression)
3082public override SyntaxNode IfStatement(SyntaxNode condition, IEnumerable<SyntaxNode> trueStatements, IEnumerable<SyntaxNode>? falseStatements = null)
3104IEnumerable<SyntaxNode>? statements = null,
3121private static SyntaxList<StatementSyntax> AsStatementList(IEnumerable<SyntaxNode>? nodes)
3124private static StatementSyntax AsStatement(SyntaxNode node)
3134public override SyntaxNode ExpressionStatement(SyntaxNode expression)
3137internal override SyntaxNode MemberAccessExpressionWorker(SyntaxNode? expression, SyntaxNode simpleName)
3148public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
3151public override SyntaxNode MemberBindingExpression(SyntaxNode name)
3154public override SyntaxNode ElementBindingExpression(IEnumerable<SyntaxNode> arguments)
3179private static SeparatedSyntaxList<ExpressionSyntax> AsExpressionList(IEnumerable<SyntaxNode> expressions)
3182public override SyntaxNode ArrayCreationExpression(SyntaxNode elementType, SyntaxNode size)
3188public override SyntaxNode ArrayCreationExpression(SyntaxNode elementType, IEnumerable<SyntaxNode> elements)
3196public override SyntaxNode ObjectCreationExpression(SyntaxNode type, IEnumerable<SyntaxNode> arguments)
3199internal override SyntaxNode ObjectCreationExpression(SyntaxNode type, SyntaxToken openParen, SeparatedSyntaxList<SyntaxNode> arguments, SyntaxToken closeParen)
3205private static ArgumentListSyntax CreateArgumentList(IEnumerable<SyntaxNode> arguments)
3208private static SeparatedSyntaxList<ArgumentSyntax> CreateArguments(IEnumerable<SyntaxNode> arguments)
3211private static ArgumentSyntax AsArgument(SyntaxNode argOrExpression)
3214public override SyntaxNode InvocationExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments)
3217public override SyntaxNode ElementAccessExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments)
3223public override SyntaxNode DefaultExpression(SyntaxNode type)
3226public override SyntaxNode DefaultExpression(ITypeSymbol type)
3261private static SyntaxNode Parenthesize(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
3264public override SyntaxNode IsTypeExpression(SyntaxNode expression, SyntaxNode type)
3267public override SyntaxNode TypeOfExpression(SyntaxNode type)
3270public override SyntaxNode TryCastExpression(SyntaxNode expression, SyntaxNode type)
3273public override SyntaxNode CastExpression(SyntaxNode type, SyntaxNode expression)
3276public override SyntaxNode ConvertExpression(SyntaxNode type, SyntaxNode expression)
3279public override SyntaxNode AssignmentStatement(SyntaxNode left, SyntaxNode right)
3282private static SyntaxNode CreateBinaryExpression(SyntaxKind syntaxKind, SyntaxNode left, SyntaxNode right)
3285public override SyntaxNode ValueEqualsExpression(SyntaxNode left, SyntaxNode right)
3288public override SyntaxNode ReferenceEqualsExpression(SyntaxNode left, SyntaxNode right)
3291public override SyntaxNode ValueNotEqualsExpression(SyntaxNode left, SyntaxNode right)
3294public override SyntaxNode ReferenceNotEqualsExpression(SyntaxNode left, SyntaxNode right)
3297public override SyntaxNode LessThanExpression(SyntaxNode left, SyntaxNode right)
3300public override SyntaxNode LessThanOrEqualExpression(SyntaxNode left, SyntaxNode right)
3303public override SyntaxNode GreaterThanExpression(SyntaxNode left, SyntaxNode right)
3306public override SyntaxNode GreaterThanOrEqualExpression(SyntaxNode left, SyntaxNode right)
3309public override SyntaxNode NegateExpression(SyntaxNode expression)
3312public override SyntaxNode AddExpression(SyntaxNode left, SyntaxNode right)
3315public override SyntaxNode SubtractExpression(SyntaxNode left, SyntaxNode right)
3318public override SyntaxNode MultiplyExpression(SyntaxNode left, SyntaxNode right)
3321public override SyntaxNode DivideExpression(SyntaxNode left, SyntaxNode right)
3324public override SyntaxNode ModuloExpression(SyntaxNode left, SyntaxNode right)
3327public override SyntaxNode BitwiseAndExpression(SyntaxNode left, SyntaxNode right)
3330public override SyntaxNode BitwiseOrExpression(SyntaxNode left, SyntaxNode right)
3333public override SyntaxNode BitwiseNotExpression(SyntaxNode operand)
3336public override SyntaxNode LogicalAndExpression(SyntaxNode left, SyntaxNode right)
3339public override SyntaxNode LogicalOrExpression(SyntaxNode left, SyntaxNode right)
3342public override SyntaxNode LogicalNotExpression(SyntaxNode expression)
3345public override SyntaxNode ConditionalExpression(SyntaxNode condition, SyntaxNode whenTrue, SyntaxNode whenFalse)
3348public override SyntaxNode CoalesceExpression(SyntaxNode left, SyntaxNode right)
3351public override SyntaxNode ThisExpression()
3354public override SyntaxNode BaseExpression()
3357public override SyntaxNode TypedConstantExpression(TypedConstant value)
3360private protected override SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
3363public override SyntaxNode IdentifierName(string identifier)
3366public override SyntaxNode GenericName(string identifier, IEnumerable<SyntaxNode> typeArguments)
3369internal override SyntaxNode GenericName(SyntaxToken identifier, IEnumerable<SyntaxNode> typeArguments)
3373public override SyntaxNode WithTypeArguments(SyntaxNode expression, IEnumerable<SyntaxNode> typeArguments)
3403public override SyntaxNode QualifiedName(SyntaxNode left, SyntaxNode right)
3406internal override SyntaxNode GlobalAliasedName(SyntaxNode name)
3411public override SyntaxNode NameExpression(INamespaceOrTypeSymbol namespaceOrTypeSymbol)
3414private protected override SyntaxNode TypeExpression(ITypeSymbol typeSymbol, RefKind refKind)
3425public override SyntaxNode TypeExpression(SpecialType specialType)
3446public override SyntaxNode ArrayTypeExpression(SyntaxNode type)
3449public override SyntaxNode NullableTypeExpression(SyntaxNode type)
3461internal override SyntaxNode CreateTupleType(IEnumerable<SyntaxNode> elements)
3464public override SyntaxNode TupleElementExpression(SyntaxNode type, string? name = null)
3467public override SyntaxNode Argument(string? name, RefKind refKind, SyntaxNode expression)
3475public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, string name, SyntaxNode? initializer, bool isConst)
3478public override SyntaxNode UsingStatement(SyntaxNode? type, string name, SyntaxNode expression, IEnumerable<SyntaxNode> statements)
3486public override SyntaxNode UsingStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements)
3494public override SyntaxNode LockStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements)
3501public override SyntaxNode TryCatchStatement(IEnumerable<SyntaxNode>? tryStatements, IEnumerable<SyntaxNode>? catchClauses, IEnumerable<SyntaxNode>? finallyStatements = null)
3509public override SyntaxNode CatchClause(SyntaxNode type, string name, IEnumerable<SyntaxNode> statements)
3517public override SyntaxNode WhileStatement(SyntaxNode condition, IEnumerable<SyntaxNode> statements)
3520public override SyntaxNode SwitchStatement(SyntaxNode expression, IEnumerable<SyntaxNode> caseClauses)
3541public override SyntaxNode SwitchSection(IEnumerable<SyntaxNode> expressions, IEnumerable<SyntaxNode> statements)
3544internal override SyntaxNode SwitchSectionFromLabels(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements)
3551public override SyntaxNode DefaultSwitchSection(IEnumerable<SyntaxNode> statements)
3554private static SyntaxList<SwitchLabelSyntax> AsSwitchLabels(IEnumerable<SyntaxNode> expressions)
3566public override SyntaxNode ExitSwitchStatement()
3569internal override SyntaxNode ScopeBlock(IEnumerable<SyntaxNode> statements)
3572internal override SyntaxNode GlobalStatement(SyntaxNode statement)
3575public override SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? parameterDeclarations, SyntaxNode expression)
3584private static bool IsSimpleLambdaParameter(SyntaxNode node)
3587public override SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, SyntaxNode expression)
3590public override SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? parameterDeclarations, IEnumerable<SyntaxNode> statements)
3593public override SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, IEnumerable<SyntaxNode> statements)
3596public override SyntaxNode LambdaParameter(string identifier, SyntaxNode? type = null)
3599internal override SyntaxNode IdentifierName(SyntaxToken identifier)
3602internal override SyntaxNode NamedAnonymousObjectMemberDeclarator(SyntaxNode identifier, SyntaxNode expression)
3609public override SyntaxNode TupleExpression(IEnumerable<SyntaxNode> arguments)
3612internal override SyntaxNode RemoveAllComments(SyntaxNode node)
3652internal 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)
294private 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 (320)
30private static readonly ObjectPool<List<SyntaxNode>> s_syntaxNodeListPool = new ObjectPool<List<SyntaxNode>>(() => [], trimOnFree: false);
134public bool IsDirective([NotNullWhen(true)] SyntaxNode? node)
137public bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? node, out ExternalSourceInfo info)
158public bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
164public bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
167public bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
174public SyntaxNode? GetStandaloneExpression(SyntaxNode? node)
177public SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node)
180public bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node)
183public bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node)
186public bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node)
189public SyntaxNode? GetParameterList(SyntaxNode node)
192public bool IsParameterList([NotNullWhen(true)] SyntaxNode? node)
195public bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node)
199public bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node)
202public void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name)
210public bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node)
213public bool IsUsingLocalDeclarationStatement([NotNullWhen(true)] SyntaxNode? node)
216public bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node)
219public Location GetDeconstructionReferenceLocation(SyntaxNode node)
229public bool IsStatement([NotNullWhen(true)] SyntaxNode? node)
232public bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node)
235public bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node)
238public SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node)
241public bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement)
260public bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node)
272public SyntaxNode GetExpressionOfRefExpression(SyntaxNode node)
275public SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node)
319public bool IsPredefinedType(SyntaxNode? node)
322public bool IsPredefinedType(SyntaxNode? node, PredefinedType type)
543public bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node)
546public bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node)
549public bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node)
552public bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
555public void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity)
562public bool LooksGeneric(SyntaxNode simpleName)
566public SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName)
569public SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node)
572public SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node)
575public SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget)
578public void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList)
585public SyntaxNode GetExpressionOfInterpolation(SyntaxNode node)
588public bool IsInStaticContext(SyntaxNode node)
591public bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node)
594public bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node)
597public SyntaxNode GetExpressionOfArgument(SyntaxNode node)
600public SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node)
603public RefKind GetRefKindOfArgument(SyntaxNode node)
606public bool IsArgument([NotNullWhen(true)] SyntaxNode? node)
609public bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node)
612public bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node)
619public bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node)
622public bool IsInConstructor(SyntaxNode node)
625public bool IsUnsafeContext(SyntaxNode node)
628public bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node)
631public SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position)
635.GetAncestors<SyntaxNode>()
639public SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node)
642public bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node)
647public bool IsPropertyPatternClause(SyntaxNode node)
651[NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance)
682public bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression)
697public bool IsElementAccessExpression(SyntaxNode? node)
701public SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false)
704public SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
707public SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true)
710private static SyntaxNode? GetContainingMemberDeclaration<TMemberDeclarationSyntax>(SyntaxNode root, int position, bool useFullSpan = true)
723var node = root.FindToken(position).Parent;
741public bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node)
749public bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node)
758public string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null)
820private static string? GetName(SyntaxNode node, DisplayNameOptions options)
907public PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root)
917public PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root)
927public SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration)
930private void AppendMembers(SyntaxNode? node, List<SyntaxNode> list, bool topLevel, bool methodLevel)
954public TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node)
961var member = GetContainingMemberDeclaration(node, node.SpanStart);
981public bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span)
1004public SyntaxNode? TryGetBindableParent(SyntaxToken token)
1006var node = token.Parent;
1009var parent = node.Parent;
1067public IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken)
1072var constructors = new List<SyntaxNode>();
1077private static void AppendConstructors(SyntaxList<MemberDeclarationSyntax> members, List<SyntaxNode> constructors, CancellationToken cancellationToken)
1141public string GetNameForArgument(SyntaxNode? argument)
1144public string GetNameForAttributeArgument(SyntaxNode? argument)
1147public bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node)
1150public SyntaxNode? GetRightSideOfDot(SyntaxNode? node)
1156public SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget)
1162public bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node)
1165public bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node)
1168public bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node)
1171public bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node)
1174public SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node)
1177public bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node)
1181public bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node)
1184public static bool IsOperandOfDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1187public bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node)
1190public SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString)
1206public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode objectCreationExpression)
1211public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode argumentList)
1214public SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode argumentList)
1226public bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes)
1232public bool IsDocumentationComment(SyntaxNode node)
1235public bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node)
1238public bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node)
1241public bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node)
1244private static bool IsGlobalAttribute([NotNullWhen(true)] SyntaxNode? node, SyntaxKind attributeTarget)
1249public bool IsDeclaration(SyntaxNode? node)
1298public bool IsTypeDeclaration(SyntaxNode node)
1301public bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement)
1306SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1313SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1315var expression = statement;
1328public bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? node)
1331public SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node)
1334public SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node)
1337public SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node)
1345public bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement)
1352public bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2)
1355public static SyntaxNode GetExpressionOfInvocationExpression(SyntaxNode node)
1358public bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node)
1361public SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node)
1364public void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
1365out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode
1369arguments = (SeparatedSyntaxList<TArgumentSyntax>)(SeparatedSyntaxList<SyntaxNode>)tupleExpression.Arguments;
1376public SyntaxNode? GetMatchingDirective(SyntaxNode directive, CancellationToken cancellationToken)
1379public ImmutableArray<SyntaxNode> GetMatchingConditionalDirectives(SyntaxNode directive, CancellationToken cancellationToken)
1380=> ((DirectiveTriviaSyntax)directive).GetMatchingConditionalDirectives(cancellationToken).CastArray<SyntaxNode>();
1385public SyntaxTokenList GetModifiers(SyntaxNode? node)
1389public SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers)
1392public SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node)
1395public SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node)
1398public SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node)
1401public SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node)
1404public SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node)
1407public bool IsEqualsValueOfPropertyDeclaration(SyntaxNode? node)
1410public bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node)
1413public bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node)
1416public void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression)
1433public SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node)
1436public bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node)
1440public SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia)
1450public void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type)
1457public void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right)
1465public bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node)
1468public SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node)
1471public void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation)
1478public void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation)
1494public bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node)
1497public bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node)
1500public void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen)
1508public void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1516public void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern)
1523public void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression)
1530public SyntaxNode GetTypeOfTypePattern(SyntaxNode node)
1533public bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node)
1548public bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node)
1551public bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node)
1554public bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node)
1557public bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node)
1560public bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node)
1563public bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node)
1566public bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node)
1569public bool IsAnyName([NotNullWhen(true)] SyntaxNode? node)
1572public bool IsAnyType([NotNullWhen(true)] SyntaxNode? node)
1575public bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1578public bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node)
1581public bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node)
1584public bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node)
1591public void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name)
1599public void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken)
1607public void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList)
1614public void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1621public void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1629public void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members)
1638SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull)
1646public void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse)
1654public SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement)
1660public void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments)
1667public void GetPartsOfInterpolationExpression(SyntaxNode node,
1668out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken)
1676public void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList)
1683public void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name)
1691public void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members)
1699public void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode identifier, out SyntaxNode expression)
1706public void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer)
1715public void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer)
1723public void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default)
1731SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen)
1739public void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand)
1746public void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right)
1758public SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node)
1761public SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node)
1764public SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node)
1767public SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node)
1770public SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node)
1773public SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node)
1776public SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node)
1779public 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 (24)
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)
377var attributeSyntaxToRemove = attributeToRemove.ApplicationSyntaxReference.GetSyntax(cancellationToken);
383SyntaxNode attributeToRemove,
443SyntaxNode attributeToRemove,
479IEnumerable<SyntaxNode> statements,
531IEnumerable<SyntaxNode> statements,
533CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
570TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, BaseMethodDeclarationSyntax baseMethodDeclaration) where TDeclarationNode : SyntaxNode
590public static BlockSyntax AddStatementsToBlock(BlockSyntax block, IEnumerable<SyntaxNode> statements)
613TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, LocalFunctionStatementSyntax localFunctionStatement) where TDeclarationNode : SyntaxNode
634TDeclarationNode destinationMember, IEnumerable<SyntaxNode> statements, AnonymousFunctionExpressionSyntax anonymousFunctionSyntax) where TDeclarationNode : SyntaxNode
658public override SyntaxNode CreateEventDeclaration(
664public override SyntaxNode CreateFieldDeclaration(IFieldSymbol field, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
672public override SyntaxNode? CreateMethodDeclaration(
721public override SyntaxNode CreatePropertyDeclaration(
728public override SyntaxNode CreateNamedTypeDeclaration(
734public override SyntaxNode CreateNamespaceDeclaration(
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpAddImportsService.cs (27)
36protected override ImmutableArray<SyntaxNode> GetGlobalImports(Compilation compilation, SyntaxGenerator generator)
39protected override SyntaxNode? GetAlias(UsingDirectiveSyntax usingOrAlias)
45protected override SyntaxNode Rewrite(
50SyntaxNode externContainer,
51SyntaxNode usingContainer,
52SyntaxNode staticUsingContainer,
53SyntaxNode aliasContainer,
55SyntaxNode root,
63var newRoot = rewriter.Visit(root);
67protected override SyntaxList<UsingDirectiveSyntax> GetUsingsAndAliases(SyntaxNode node)
75protected override SyntaxList<ExternAliasDirectiveSyntax> GetExterns(SyntaxNode node)
83protected override bool IsEquivalentImport(SyntaxNode a, SyntaxNode b)
90private readonly SyntaxNode _externContainer;
91private readonly SyntaxNode _usingContainer;
92private readonly SyntaxNode _aliasContainer;
93private readonly SyntaxNode _staticUsingContainer;
104SyntaxNode externContainer,
105SyntaxNode usingContainer,
106SyntaxNode aliasContainer,
107SyntaxNode staticUsingContainer,
124public override SyntaxNode? Visit(SyntaxNode? node)
127public override SyntaxNode VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
130public override SyntaxNode? VisitFileScopedNamespaceDeclaration(FileScopedNamespaceDeclarationSyntax node)
133private SyntaxNode VisitBaseNamespaceDeclaration(
167public override SyntaxNode VisitCompilationUnit(CompilationUnitSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSyntaxGeneratorInternal.cs (68)
51public override SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken name, SyntaxNode? initializer, bool isConst)
58public override SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer)
61public override SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
64internal static VariableDeclarationSyntax VariableDeclaration(SyntaxNode? type, SyntaxToken name, SyntaxNode? expression)
76public override SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull)
79public override SyntaxNode MemberBindingExpression(SyntaxNode name)
82public override SyntaxNode RefExpression(SyntaxNode expression)
85public override SyntaxNode AddParentheses(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
88internal static SyntaxNode Parenthesize(SyntaxNode expressionOrPattern, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
96public override SyntaxNode YieldReturnStatement(SyntaxNode expression)
105public override SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
108public override SyntaxNode InterpolatedStringText(SyntaxToken textToken)
118public override SyntaxNode Interpolation(SyntaxNode syntaxNode)
121public override SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment)
124public override SyntaxNode InterpolationFormatClause(string format)
129public override SyntaxNode TypeParameterList(IEnumerable<string> typeParameterNames)
178public override SyntaxNode Type(ITypeSymbol typeSymbol, bool typeContext)
181public override SyntaxNode NegateEquality(SyntaxGenerator generator, SyntaxNode binaryExpression, SyntaxNode left, BinaryOperatorKind negatedKind, SyntaxNode right)
189public override SyntaxNode IsNotTypeExpression(SyntaxNode expression, SyntaxNode type)
197public override SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isKeyword, SyntaxNode pattern)
203public override SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right)
206public override SyntaxNode ConstantPattern(SyntaxNode expression)
209public override SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name)
214public override SyntaxNode LessThanRelationalPattern(SyntaxNode expression)
217public override SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression)
220public override SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression)
223public override SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression)
226public override SyntaxNode NotPattern(SyntaxNode pattern)
229public override SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right)
232public override SyntaxNode ParenthesizedPattern(SyntaxNode pattern)
235public override SyntaxNode TypePattern(SyntaxNode type)
238public override SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern)
AddImport\AbstractAddImportFeatureService.cs (32)
32where TSimpleNameSyntax : SyntaxNode
40protected abstract bool IsWithinImport(SyntaxNode node);
41protected abstract bool CanAddImport(SyntaxNode node, bool allowInHiddenRegions, CancellationToken cancellationToken);
42protected abstract bool CanAddImportForMethod(string diagnosticId, ISyntaxFacts syntaxFacts, SyntaxNode node, out TSimpleNameSyntax nameNode);
43protected abstract bool CanAddImportForNamespace(string diagnosticId, SyntaxNode node, out TSimpleNameSyntax nameNode);
44protected abstract bool CanAddImportForDeconstruct(string diagnosticId, SyntaxNode node);
45protected abstract bool CanAddImportForGetAwaiter(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node);
46protected abstract bool CanAddImportForGetEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node);
47protected abstract bool CanAddImportForGetAsyncEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node);
48protected abstract bool CanAddImportForQuery(string diagnosticId, SyntaxNode node);
49protected abstract bool CanAddImportForTypeOrNamespace(string diagnosticId, SyntaxNode node, out TSimpleNameSyntax nameNode);
51protected abstract ISet<INamespaceSymbol> GetImportNamespacesInScope(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
52protected abstract ITypeSymbol GetDeconstructInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
53protected abstract ITypeSymbol GetQueryClauseInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken);
54protected abstract bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken);
56protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, INamespaceOrTypeSymbol symbol, Document document, AddImportPlacementOptions options, CancellationToken cancellationToken);
57protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, IReadOnlyList<string> nameSpaceParts, Document document, AddImportPlacementOptions options, CancellationToken cancellationToken);
59protected abstract bool IsAddMethodContext(SyntaxNode node, SemanticModel semanticModel);
62protected abstract (string description, bool hasExistingImport) GetDescription(Document document, AddImportPlacementOptions options, INamespaceOrTypeSymbol symbol, SemanticModel semanticModel, SyntaxNode root, CancellationToken cancellationToken);
135SyntaxNode node,
630private static ITypeSymbol? GetAwaitInfo(SemanticModel semanticModel, ISyntaxFacts syntaxFactsService, SyntaxNode node)
632var awaitExpression = FirstAwaitExpressionAncestor(syntaxFactsService, node);
637var innerExpression = syntaxFactsService.GetExpressionOfAwaitExpression(awaitExpression);
642private static ITypeSymbol? GetCollectionExpressionType(SemanticModel semanticModel, ISyntaxFacts syntaxFactsService, SyntaxNode node)
644var collectionExpression = FirstForeachCollectionExpressionAncestor(syntaxFactsService, node);
654protected static bool AncestorOrSelfIsAwaitExpression(ISyntaxFacts syntaxFactsService, SyntaxNode node)
657private static SyntaxNode? FirstAwaitExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node)
658=> node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFacts>((n, syntaxFactsService) => syntaxFactsService.IsAwaitExpression(n), syntaxFactsService);
660private static SyntaxNode? FirstForeachCollectionExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node)
661=> node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFacts>((n, syntaxFactsService) => syntaxFactsService.IsExpressionOfForeach(n), syntaxFactsService);
ChangeSignature\AbstractChangeSignatureService.cs (40)
47public abstract SyntaxNode? FindNodeToUpdate(Document document, SyntaxNode node);
52public abstract SyntaxNode ChangeSignature(
55SyntaxNode potentiallyUpdatedNode,
56SyntaxNode originalNode,
63protected abstract T TransferLeadingWhitespaceTrivia<T>(T newArgument, SyntaxNode oldArgument) where T : SyntaxNode;
72where TArgumentSyntax : SyntaxNode;
75where TArgumentSyntax : SyntaxNode;
170var syntax = await reference.GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
254var nodesToUpdate = new Dictionary<DocumentId, List<SyntaxNode>>();
255var definitionToUse = new Dictionary<SyntaxNode, ISymbol>();
336if (!TryGetNodeWithEditableSignatureOrAttributes(def, currentSolution, out var nodeToUpdate, out var documentId))
360if (!TryGetNodeWithEditableSignatureOrAttributes(location.Location, currentSolution, out var nodeToUpdate2, out var documentId2))
376var updatedRoots = new Dictionary<DocumentId, SyntaxNode>();
403var annotatedNodes = newRoot.GetAnnotatedNodes<SyntaxNode>(syntaxAnnotation: ChangeSignatureFormattingAnnotation);
406var formattedRoot = Formatter.Format(
418var changedDocuments = await ProducerConsumer<(DocumentId documentId, SyntaxNode newRoot)>.RunParallelAsync(
445private static void AddUpdatableNodeToDictionaries(Dictionary<DocumentId, List<SyntaxNode>> nodesToUpdate, DocumentId documentId, SyntaxNode nodeToUpdate, Dictionary<SyntaxNode, ISymbol> definitionToUse, ISymbol symbolWithSemanticParameters)
456private static bool TryGetNodeWithEditableSignatureOrAttributes(Location location, Solution solution, out SyntaxNode nodeToUpdate, out DocumentId documentId)
462var root = tree.GetRoot();
463var node = root.FindNode(location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);
650where TNode : SyntaxNode
683Func<AddedParameter, T> createNewParameterMethod) where T : SyntaxNode
746protected ImmutableArray<SyntaxToken> GetSeparators<T>(SeparatedSyntaxList<T> arguments, int numSeparatorsToSkip) where T : SyntaxNode
774where TArgumentSyntax : SyntaxNode
813var expression = GenerateInferredCallsiteExpression(
915private SyntaxNode GenerateInferredCallsiteExpression(
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;
684private static async Task<(Document, ImmutableArray<SyntaxNode>)> FixReferencesAsync(
693var root = editor.OriginalRoot;
694using var _ = PooledHashSet<SyntaxNode>.GetInstance(out var containers);
727var refNode = root.FindNode(refLoc.ReferenceLocation.Location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);
733refNode, newNamespaceParts, syntaxFacts, out var oldNode, out var newNode))
742var container = addImportService.GetImportContainer(root, refNode, dummyImport, addImportsOptions);
778var changedDocuments = await ProducerConsumer<(DocumentId documentId, SyntaxNode newRoot)>.RunParallelAsync(
795IEnumerable<SyntaxNode> importsToRemove,
816ImmutableArray<SyntaxNode> containers,
831foreach (var container in containers)
836var contextLocation = container is TNamespaceDeclarationSyntax
856private sealed class SyntaxNodeSpanStartComparer : IComparer<SyntaxNode>
864public 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);
118Document document, SyntaxNode top, bool isVerbatimStringLiteral, ImmutableArray<SyntaxNode> pieces, CancellationToken cancellationToken)
121var interpolatedString = await CreateInterpolatedStringAsync(
127protected async Task<SyntaxNode> CreateInterpolatedStringAsync(
130ImmutableArray<SyntaxNode> pieces,
145using var _ = ArrayBuilder<SyntaxNode>.GetInstance(pieces.Length, out var content);
148foreach (var piece in pieces)
169var newText = ConcatenateTextToTextNode(generator, existingInterpolatedStringTextNode, textWithoutQuotes, valueTextWithEscapedBraces);
195var newText = ConcatenateTextToTextNode(generator, content.Last(), contentPart.GetFirstToken().Text, contentPart.GetFirstToken().ValueText);
210var converted = TryRemoveToString(piece);
226SyntaxNode TryRemoveToString(SyntaxNode piece)
256private static SyntaxNode ConcatenateTextToTextNode(SyntaxGenerator generator, SyntaxNode interpolatedStringTextNode, string textWithoutQuotes, string value)
267ArrayBuilder<SyntaxNode> pieces,
268SyntaxNode node,
278syntaxFacts.GetPartsOfBinaryExpression(node, out var left, out var right);
285ISyntaxFactsService syntaxFacts, SyntaxNode? expression,
ConvertTupleToStruct\AbstractConvertTupleToStructCodeRefactoringProvider.cs (31)
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,
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);
113bool CanAddTo(Document document, SyntaxNode insertionPointNode, out OperationStatus status)
125var destination = insertionPointNode;
128var mappedPoint = insertionPointNode.RawKind == syntaxKinds.GlobalStatement
175SyntaxNode insertionPointNode,
230SyntaxNode contextNode,
249SemanticModel 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)
201Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> selectedMembers,
241Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
258Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
295Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
GenerateType\AbstractGenerateTypeService.cs (12)
32where TExpressionSyntax : SyntaxNode
33where TTypeDeclarationSyntax : SyntaxNode
34where TArgumentSyntax : SyntaxNode
59Solution updatedSolution, SyntaxNode modifiedRoot, Document document, TSimpleNameSyntax simpleName, string includeUsingsOrImports, CancellationToken cancellationToken);
65public abstract Task<(INamespaceSymbol, INamespaceOrTypeSymbol, Location)> GetOrGenerateEnclosingNamespaceSymbolAsync(INamedTypeSymbol namedTypeSymbol, string[] containers, Document selectedDocument, SyntaxNode selectedDocumentRoot, CancellationToken cancellationToken);
69SyntaxNode node,
101SyntaxNode node,
139private static bool CanGenerateIntoContainingNamespace(SemanticDocument semanticDocument, SyntaxNode node, CancellationToken cancellationToken)
149.FirstOrDefault(node.GetAncestorsOrThis<SyntaxNode>().Contains);
158SyntaxNode node,
184IEnumerable<SyntaxNode> typeArguments,
197var argument = i < arguments.Count ? arguments[i] : null;
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (21)
40where TTypeDeclarationSyntax : SyntaxNode
41where TParameterSyntax : SyntaxNode
42where TStatementSyntax : SyntaxNode
43where TExpressionSyntax : SyntaxNode
47protected abstract SyntaxNode RemoveThrowNotImplemented(SyntaxNode propertySyntax);
50Document document, SyntaxNode functionDeclaration, IMethodSymbol method, IBlockOperation? blockStatementOpt,
51ImmutableArray<SyntaxNode> listOfParameterNodes, TextSpan parameterSpan,
61SyntaxNode constructorDeclaration,
105SyntaxNode constructorDeclaration,
156SyntaxNode constructorDeclaration,
190SyntaxNode constructorDeclaration,
239SyntaxNode functionDeclaration,
358SyntaxNode constructorDeclaration,
372var nodesToTrack = new List<SyntaxNode> { constructorDeclaration };
389var currentConstructorDeclaration = currentRoot.GetCurrentNode(constructorDeclaration);
422SyntaxNode constructorDeclaration,
454var withoutThrowNotImplemented = RemoveThrowNotImplemented(propertySyntax);
471SyntaxNode constructorDeclaration,
540SyntaxNode typeDeclaration, CancellationToken cancellationToken)
551var symbolSyntax = symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
InlineHints\AbstractInlineParameterNameHintsService.cs (10)
29SyntaxNode node,
30ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> buffer,
33protected abstract bool IsIndexer(SyntaxNode node, IParameterSymbol parameter);
64using var _2 = ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)>.GetInstance(out var buffer);
80void AddHintsIfAppropriate(SyntaxNode node)
129ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> parameterHints)
139ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> parameterHints)
157ArrayBuilder<(int position, SyntaxNode argument, IParameterSymbol? parameter, HintKind kind)> parameterHints)
283private static bool ParameterMatchesArgumentName(SyntaxNode argument, IParameterSymbol parameter, ISyntaxFactsService syntaxFacts)
289protected static string GetIdentifierNameFromArgument(SyntaxNode argument, ISyntaxFactsService syntaxFacts)
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<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument<TExpressionSyntax>> 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)
22where TExpressionSyntax : SyntaxNode
24protected abstract bool IsExplicitInterfaceGeneration(SyntaxNode node);
25protected abstract bool IsIdentifierNameGeneration(SyntaxNode node);
27protected abstract bool TryInitializeExplicitInterfaceState(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IPropertySymbol propertySymbol, out INamedTypeSymbol typeToGenerateIn);
30protected abstract bool TryConvertToLocalDeclaration(ITypeSymbol type, SyntaxToken identifierToken, SemanticModel semanticModel, CancellationToken cancellationToken, out SyntaxNode newRoot);
34SyntaxNode 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)
31protected abstract bool TryInitializeState(Document document, SemanticModel model, SyntaxNode interfaceNode, CancellationToken cancellationToken, out SyntaxNode classOrStructDecl, out INamedTypeSymbol classOrStructType, out ImmutableArray<INamedTypeSymbol> interfaceTypes);
34protected abstract SyntaxNode AddCommentInsideIfStatement(SyntaxNode ifDisposingStatement, SyntaxTriviaList trivia);
35protected abstract SyntaxNode CreateFinalizer(SyntaxGenerator generator, INamedTypeSymbol classType, string disposeMethodDisplayString);
38Document document, ImplementTypeOptions options, SyntaxNode node, CancellationToken cancellationToken)
57public async Task<ImplementInterfaceInfo?> 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)
47where TExpressionSyntax : SyntaxNode
48where TStatementSyntax : SyntaxNode
53where TVariableDeclaratorSyntax : SyntaxNode
54where TSwitchCaseBlockSyntax : SyntaxNode
55where TSwitchCaseLabelOrClauseSyntax : SyntaxNode
75protected abstract SyntaxNode? TryUpdateNameForFlaggedNode(SyntaxNode node, SyntaxToken newName);
99protected abstract SyntaxNode GetReplacementNodeForCompoundAssignment(
100SyntaxNode originalCompoundAssignment,
101SyntaxNode newAssignmentTarget,
109protected abstract SyntaxNode GetReplacementNodeForVarPattern(SyntaxNode originalVarPattern, SyntaxNode newNameNode);
121protected virtual SyntaxNode? TryUpdateParentOfUpdatedNode(SyntaxNode parent, SyntaxNode newNameNode, SyntaxEditor editor, ISyntaxFacts syntaxFacts, SemanticModel semanticModel) => null;
130protected abstract SyntaxNode ComputeReplacementNode(SyntaxNode originalOldNode, SyntaxNode changedOldNode, SyntaxNode proposedReplacementNode);
239private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
242SyntaxNode root,
264private static IEnumerable<IGrouping<SyntaxNode, Diagnostic>> GetDiagnosticsGroupedByMember(
267SyntaxNode root)
292private async Task<SyntaxNode> GetNewRootAsync(
324var containingMemberDeclaration = diagnosticsToFix.Key;
334var currentRoot = editor.GetChangedRoot();
335var newRoot = await PostProcessDocumentAsync(document, options, currentRoot,
349SyntaxNode root,
350SyntaxNode containingMemberDeclaration,
386SyntaxNode root,
429var localDecl = editor.Generator.LocalDeclarationStatement(
445SyntaxNode root,
446SyntaxNode containingMemberDeclaration,
469using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var nodeReplacementMap);
470using var _2 = PooledHashSet<SyntaxNode>.GetInstance(out var nodesToRemove);
471using var _3 = PooledHashSet<(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)>.GetInstance(out var nodesToAdd);
473using var _4 = PooledHashSet<SyntaxNode>.GetInstance(out var processedNodes);
549var newNameNode = TryUpdateNameForFlaggedNode(node, newNameToken);
569var newParentNode = TryUpdateParentOfUpdatedNode(node.GetRequiredParent(), newNameNode, editor, syntaxFacts, semanticModel);
673IEnumerable<(SyntaxNode node, bool isUnusedLocalAssignment)> GetNodesToFix()
677var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
691void InsertLocalDeclarationStatement(TLocalDeclarationStatementSyntax declarationStatement, SyntaxNode node)
694var insertionNode = node.FirstAncestorOrSelf<SyntaxNode>(
724bool ShouldRemoveStatement(TLocalDeclarationStatementSyntax localDeclarationStatement, out SeparatedSyntaxList<SyntaxNode> variables)
730foreach (var variable in variables)
744private async Task<SyntaxNode> PostProcessDocumentAsync(
747SyntaxNode currentRoot,
773private static async Task<SyntaxNode> PostProcessDocumentCoreAsync(
774Func<SyntaxNode, Document, SyntaxFormattingOptions, CancellationToken, Task<SyntaxNode>> processMemberDeclarationAsync,
775SyntaxNode currentRoot,
785using var _1 = PooledDictionary<SyntaxNode, SyntaxNode>.GetInstance(out var memberDeclReplacementsMap);
805private async Task<SyntaxNode> ReplaceDiscardDeclarationsWithAssignmentsAsync(SyntaxNode memberDeclaration, Document document, SyntaxFormattingOptions options, CancellationToken cancellationToken)
821private async Task<SyntaxNode> AdjustLocalDeclarationsAsync(
822SyntaxNode memberDeclaration,
930SyntaxNode memberDeclaration,
935private readonly SyntaxNode _memberDeclaration = memberDeclaration;
941public 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)
24Protected Overrides Function IsImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
28Protected Overrides Function TryInitializeImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken, ByRef token As SyntaxToken, ByRef arguments As ImmutableArray(Of Argument(Of ExpressionSyntax)), ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
50Protected Overrides Function IsConstructorInitializerGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
58node As SyntaxNode,
87Protected Overrides Function IsSimpleNameGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
93node As SyntaxNode,
128node 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\Extensions\CompilationUnitSyntaxExtensions.vb (1)
20contextNode As SyntaxNode,
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 (21)
27Protected Overrides Function IsWithinImport(node As SyntaxNode) As Boolean
31Protected Overrides Function CanAddImport(node As SyntaxNode, allowInHiddenRegions As Boolean, cancellationToken As CancellationToken) As Boolean
38node As SyntaxNode,
98Protected Overrides Function CanAddImportForNamespace(diagnosticId As String, node As SyntaxNode, ByRef nameNode As SimpleNameSyntax) As Boolean
111Protected Overrides Function CanAddImportForDeconstruct(diagnosticId As String, node As SyntaxNode) As Boolean
116Protected Overrides Function CanAddImportForGetAwaiter(diagnosticId As String, syntaxFactsService As ISyntaxFacts, node As SyntaxNode) As Boolean
121Protected Overrides Function CanAddImportForGetEnumerator(diagnosticId As String, syntaxFactsService As ISyntaxFacts, node As SyntaxNode) As Boolean
125Protected Overrides Function CanAddImportForGetAsyncEnumerator(diagnosticId As String, syntaxFactsService As ISyntaxFacts, node As SyntaxNode) As Boolean
129Protected Overrides Function CanAddImportForQuery(diagnosticId As String, node As SyntaxNode) As Boolean
135diagnosticId As String, node As SyntaxNode, ByRef nameNode As SimpleNameSyntax) As Boolean
161Private Shared Function CanAddImportForTypeOrNamespaceCore(node As SyntaxNode, ByRef nameNode As SimpleNameSyntax) As Boolean
194root As SyntaxNode,
219Protected Overrides Function GetImportNamespacesInScope(semanticModel As SemanticModel, node As SyntaxNode, cancellationToken As CancellationToken) As ISet(Of INamespaceSymbol)
223Protected Overrides Function GetDeconstructInfo(semanticModel As SemanticModel, node As SyntaxNode, cancellationToken As CancellationToken) As ITypeSymbol
229node As SyntaxNode,
279contextNode As SyntaxNode,
291contextNode As SyntaxNode,
310contextNode As SyntaxNode,
329expression As SyntaxNode,
337Dim leftExpression As SyntaxNode
355Protected 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,
281cancellationToken As CancellationToken) As SyntaxNode
523Private Shared Function IsParamsArrayExpanded(semanticModel As SemanticModel, node As SyntaxNode, symbolInfo As SymbolInfo, cancellationToken As CancellationToken) As Boolean
581Private Function UpdateDeclaration(Of T As SyntaxNode)(
633Private Function VerifyAndPermuteParamNodes(paramNodes As ImmutableArray(Of XmlElementSyntax), declarationSymbol As ISymbol, updatedSignature As SignatureChange) As ImmutableArray(Of SyntaxNode)
641Return ImmutableArray(Of SyntaxNode).Empty
645Return ImmutableArray(Of SyntaxNode).Empty
653Return ImmutableArray(Of SyntaxNode).Empty
658Return ImmutableArray(Of SyntaxNode).Empty
666Dim permutedParams = ArrayBuilder(Of SyntaxNode).GetInstance()
745Protected Overrides Function TransferLeadingWhitespaceTrivia(Of T As SyntaxNode)(newArgument As T, oldArgument As SyntaxNode) As T
761Protected Overrides Function CreateExplicitParamsArrayFromIndividualArguments(Of TArgumentSyntax As SyntaxNode)(newArguments As SeparatedSyntaxList(Of TArgumentSyntax), indexInExistingList As Integer, parameterSymbol As IParameterSymbol) As TArgumentSyntax
767Protected Overrides Function AddNameToArgument(Of TArgumentSyntax As SyntaxNode)(newArgument As TArgumentSyntax, name As String) As TArgumentSyntax
770Return CType(CType(simpleArgument.WithNameColonEquals(NameColonEquals(IdentifierName(name))), SyntaxNode), TArgumentSyntax)
775Return 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)
375genericName.TypeArgumentList.Arguments.OfType(Of SyntaxNode)().ToList(),
376Enumerable.Repeat(Of SyntaxNode)(Nothing, state.SimpleName.Arity))
420Public 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))
462Private Shared Function GetDeclaringNamespace(containers As List(Of String), indexDone As Integer, localRoot As SyntaxNode) As NamespaceStatementSyntax
557Dim node As SyntaxNode = expression
589Private Shared Function IsAllContainingTypeBlocksPublic(node As SyntaxNode) As Boolean
614modifiedRoot As SyntaxNode,
625Dim 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)
24Protected Overrides Function IsImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
28Protected Overrides Function TryInitializeImplicitObjectCreation(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken, ByRef token As SyntaxToken, ByRef arguments As ImmutableArray(Of Argument(Of ExpressionSyntax)), ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
50Protected Overrides Function IsConstructorInitializerGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
58node As SyntaxNode,
87Protected Overrides Function IsSimpleNameGeneration(document As SemanticDocument, node As SyntaxNode, cancellationToken As CancellationToken) As Boolean
93node As SyntaxNode,
128node 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)
334private protected abstract SyntaxNode TypeParameter(ITypeParameterSymbol typeParameter);
335private protected abstract SyntaxNode TypeParameter(string name);
337private protected abstract SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference);
352public abstract SyntaxNode PropertyDeclaration(
354SyntaxNode type,
357IEnumerable<SyntaxNode>? getAccessorStatements = null,
358IEnumerable<SyntaxNode>? setAccessorStatements = null);
363public SyntaxNode PropertyDeclaration(
365IEnumerable<SyntaxNode>? getAccessorStatements = null,
366IEnumerable<SyntaxNode>? setAccessorStatements = null)
372SyntaxNode? getAccessor = null;
373SyntaxNode? setAccessor = null;
390var propDecl = PropertyDeclaration(
407private protected abstract SyntaxNode PropertyDeclaration(
409SyntaxNode type,
410SyntaxNode? getAccessor,
411SyntaxNode? setAccessor,
415public SyntaxNode WithAccessorDeclarations(SyntaxNode declaration, params SyntaxNode[] accessorDeclarations)
416=> WithAccessorDeclarations(declaration, (IEnumerable<SyntaxNode>)accessorDeclarations);
418public abstract SyntaxNode WithAccessorDeclarations(SyntaxNode declaration, IEnumerable<SyntaxNode> accessorDeclarations);
420public abstract SyntaxNode GetAccessorDeclaration(
422IEnumerable<SyntaxNode>? statements = null);
424public SyntaxNode SetAccessorDeclaration(
426IEnumerable<SyntaxNode>? statements = null)
429private protected abstract SyntaxNode SetAccessorDeclaration(
430Accessibility accessibility, bool isInitOnly, IEnumerable<SyntaxNode>? statements);
435public abstract SyntaxNode IndexerDeclaration(
436IEnumerable<SyntaxNode> parameters,
437SyntaxNode type,
440IEnumerable<SyntaxNode>? getAccessorStatements = null,
441IEnumerable<SyntaxNode>? setAccessorStatements = null);
446public SyntaxNode IndexerDeclaration(
448IEnumerable<SyntaxNode>? getAccessorStatements = null,
449IEnumerable<SyntaxNode>? setAccessorStatements = null)
451var indexerDecl = IndexerDeclaration(
471public abstract SyntaxNode AddEventHandler(SyntaxNode @event, SyntaxNode handler);
476public abstract SyntaxNode RemoveEventHandler(SyntaxNode @event, SyntaxNode handler);
481public abstract SyntaxNode EventDeclaration(
483SyntaxNode type,
490public SyntaxNode EventDeclaration(IEventSymbol symbol)
492var ev = EventDeclaration(
510public abstract SyntaxNode CustomEventDeclaration(
512SyntaxNode type,
515IEnumerable<SyntaxNode>? parameters = null,
516IEnumerable<SyntaxNode>? addAccessorStatements = null,
517IEnumerable<SyntaxNode>? removeAccessorStatements = null);
522public SyntaxNode CustomEventDeclaration(
524IEnumerable<SyntaxNode>? addAccessorStatements = null,
525IEnumerable<SyntaxNode>? removeAccessorStatements = null)
543public abstract SyntaxNode ConstructorDeclaration(
545IEnumerable<SyntaxNode>? parameters = null,
548IEnumerable<SyntaxNode>? baseConstructorArguments = null,
549IEnumerable<SyntaxNode>? statements = null);
554public SyntaxNode ConstructorDeclaration(
556IEnumerable<SyntaxNode>? baseConstructorArguments = null,
557IEnumerable<SyntaxNode>? statements = null)
568private protected abstract SyntaxNode DestructorDeclaration(IMethodSymbol destructorMethod);
574public SyntaxNode? AsPublicInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType)
581public abstract SyntaxNode? AsPublicInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType, string? interfaceMemberName);
587public SyntaxNode? AsPrivateInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType)
594public abstract SyntaxNode? AsPrivateInterfaceImplementation(SyntaxNode declaration, SyntaxNode interfaceType, string? interfaceMemberName);
599public SyntaxNode ClassDeclaration(
604SyntaxNode? baseType = null,
605IEnumerable<SyntaxNode>? interfaceTypes = null,
606IEnumerable<SyntaxNode>? members = null)
612private protected abstract SyntaxNode ClassDeclaration(
615IEnumerable<SyntaxNode>? typeParameters,
618SyntaxNode? baseType,
619IEnumerable<SyntaxNode>? interfaceTypes,
620IEnumerable<SyntaxNode>? members);
625public SyntaxNode StructDeclaration(
630IEnumerable<SyntaxNode>? interfaceTypes = null,
631IEnumerable<SyntaxNode>? members = null)
637private protected abstract SyntaxNode StructDeclaration(
640IEnumerable<SyntaxNode>? typeParameters,
643IEnumerable<SyntaxNode>? interfaceTypes,
644IEnumerable<SyntaxNode>? members);
649public SyntaxNode InterfaceDeclaration(
653IEnumerable<SyntaxNode>? interfaceTypes = null,
654IEnumerable<SyntaxNode>? members = null)
660private protected abstract SyntaxNode InterfaceDeclaration(
662IEnumerable<SyntaxNode>? typeParameters,
664IEnumerable<SyntaxNode>? interfaceTypes,
665IEnumerable<SyntaxNode>? members);
670public abstract SyntaxNode EnumDeclaration(
674IEnumerable<SyntaxNode>? members = null);
679internal abstract SyntaxNode EnumDeclaration(
681SyntaxNode? underlyingType,
684IEnumerable<SyntaxNode>? members = null);
689public abstract SyntaxNode EnumMember(string name, SyntaxNode? expression = null);
694public SyntaxNode DelegateDeclaration(
696IEnumerable<SyntaxNode>? parameters = null,
698SyntaxNode? returnType = null,
706private protected abstract SyntaxNode DelegateDeclaration(
708IEnumerable<SyntaxNode>? parameters,
709IEnumerable<SyntaxNode>? typeParameters,
710SyntaxNode? returnType,
717public SyntaxNode Declaration(ISymbol symbol)
758var declaration = type.TypeKind switch
860private SyntaxNode WithTypeParametersAndConstraints(SyntaxNode declaration, ImmutableArray<ITypeParameterSymbol> typeParameters)
886internal abstract SyntaxNode WithExplicitInterfaceImplementations(
887SyntaxNode declaration, ImmutableArray<ISymbol> explicitInterfaceImplementations, bool removeDefaults = true);
892public SyntaxNode WithTypeParameters(SyntaxNode declaration, IEnumerable<string> typeParameters)
895private protected abstract SyntaxNode WithTypeParameters(SyntaxNode declaration, IEnumerable<SyntaxNode> typeParameters);
900public SyntaxNode WithTypeParameters(SyntaxNode declaration, params string[] typeParameters)
907public SyntaxNode WithTypeConstraint(SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, IEnumerable<SyntaxNode>? types = null)
911private protected abstract SyntaxNode WithTypeConstraint(
912SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, bool isUnamangedType, IEnumerable<SyntaxNode>? types);
914private protected abstract SyntaxNode WithDefaultConstraint(SyntaxNode declaration, string typeParameterName);
919public SyntaxNode WithTypeConstraint(SyntaxNode declaration, string typeParameterName, SpecialTypeConstraintKind kinds, params SyntaxNode[] types)
920=> WithTypeConstraint(declaration, typeParameterName, kinds, (IEnumerable<SyntaxNode>)types);
925public SyntaxNode WithTypeConstraint(SyntaxNode declaration, string typeParameterName, params SyntaxNode[] types)
926=> WithTypeConstraint(declaration, typeParameterName, SpecialTypeConstraintKind.None, (IEnumerable<SyntaxNode>)types);
933public abstract SyntaxNode NamespaceDeclaration(SyntaxNode name, IEnumerable<SyntaxNode> declarations);
940public SyntaxNode NamespaceDeclaration(SyntaxNode name, params SyntaxNode[] declarations)
941=> NamespaceDeclaration(name, (IEnumerable<SyntaxNode>)declarations);
948public SyntaxNode NamespaceDeclaration(string name, IEnumerable<SyntaxNode> declarations)
956public SyntaxNode NamespaceDeclaration(string name, params SyntaxNode[] declarations)
957=> NamespaceDeclaration(DottedName(name), (IEnumerable<SyntaxNode>)declarations);
963public abstract SyntaxNode CompilationUnit(IEnumerable<SyntaxNode> declarations);
969public SyntaxNode CompilationUnit(params SyntaxNode[] declarations)
970=> CompilationUnit((IEnumerable<SyntaxNode>)declarations);
976public abstract SyntaxNode NamespaceImportDeclaration(SyntaxNode name);
982public SyntaxNode NamespaceImportDeclaration(string name)
990public SyntaxNode AliasImportDeclaration(string aliasIdentifierName, INamespaceOrTypeSymbol symbol)
998public abstract SyntaxNode AliasImportDeclaration(string aliasIdentifierName, SyntaxNode name);
1003public abstract SyntaxNode Attribute(SyntaxNode name, IEnumerable<SyntaxNode>? attributeArguments = null);
1008public SyntaxNode Attribute(string name, IEnumerable<SyntaxNode>? attributeArguments = null)
1014public SyntaxNode Attribute(string name, params SyntaxNode[] attributeArguments)
1015=> Attribute(name, (IEnumerable<SyntaxNode>)attributeArguments);
1020public SyntaxNode Attribute(AttributeData attribute)
1036public abstract SyntaxNode AttributeArgument(string? name, SyntaxNode expression);
1041public SyntaxNode AttributeArgument(SyntaxNode expression)
1047public SyntaxNode RemoveAllAttributes(SyntaxNode declaration)
1054internal abstract SyntaxNode RemoveAllComments(SyntaxNode node);
1056internal SyntaxNode RemovePrimaryConstructor(SyntaxNode declaration)
1058var node = GetPrimaryConstructorParameterList(declaration);
1062internal abstract SyntaxNode? GetPrimaryConstructorParameterList(SyntaxNode declaration);
1064internal SyntaxNode RemoveLeadingAndTrailingComments(SyntaxNode node)
1080internal SyntaxNode RemoveAllTypeInheritance(SyntaxNode declaration)
1083internal abstract ImmutableArray<SyntaxNode> GetTypeInheritance(SyntaxNode declaration);
1088public abstract IReadOnlyList<SyntaxNode> GetAttributes(SyntaxNode declaration);
1093public abstract SyntaxNode InsertAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes);
1098public SyntaxNode InsertAttributes(SyntaxNode declaration, int index, params SyntaxNode[] attributes)
1099=> this.InsertAttributes(declaration, index, (IEnumerable<SyntaxNode>)attributes);
1104public SyntaxNode AddAttributes(SyntaxNode declaration, IEnumerable<SyntaxNode> attributes)
1110public SyntaxNode AddAttributes(SyntaxNode declaration, params SyntaxNode[] attributes)
1111=> AddAttributes(declaration, (IEnumerable<SyntaxNode>)attributes);
1116public abstract IReadOnlyList<SyntaxNode> GetReturnAttributes(SyntaxNode declaration);
1121public abstract SyntaxNode InsertReturnAttributes(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> attributes);
1126public SyntaxNode InsertReturnAttributes(SyntaxNode declaration, int index, params SyntaxNode[] attributes)
1127=> this.InsertReturnAttributes(declaration, index, (IEnumerable<SyntaxNode>)attributes);
1132public SyntaxNode AddReturnAttributes(SyntaxNode declaration, IEnumerable<SyntaxNode> attributes)
1138public SyntaxNode AddReturnAttributes(SyntaxNode declaration, params SyntaxNode[] attributes)
1139=> AddReturnAttributes(declaration, (IEnumerable<SyntaxNode>)attributes);
1144public abstract IReadOnlyList<SyntaxNode> GetAttributeArguments(SyntaxNode attributeDeclaration);
1149public abstract SyntaxNode InsertAttributeArguments(SyntaxNode attributeDeclaration, int index, IEnumerable<SyntaxNode> attributeArguments);
1154public SyntaxNode AddAttributeArguments(SyntaxNode attributeDeclaration, IEnumerable<SyntaxNode> attributeArguments)
1160public abstract IReadOnlyList<SyntaxNode> GetNamespaceImports(SyntaxNode declaration);
1165public abstract SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> imports);
1170public SyntaxNode InsertNamespaceImports(SyntaxNode declaration, int index, params SyntaxNode[] imports)
1171=> this.InsertNamespaceImports(declaration, index, (IEnumerable<SyntaxNode>)imports);
1176public SyntaxNode AddNamespaceImports(SyntaxNode declaration, IEnumerable<SyntaxNode> imports)
1182public SyntaxNode AddNamespaceImports(SyntaxNode declaration, params SyntaxNode[] imports)
1183=> this.AddNamespaceImports(declaration, (IEnumerable<SyntaxNode>)imports);
1188public abstract IReadOnlyList<SyntaxNode> GetMembers(SyntaxNode declaration);
1193public abstract SyntaxNode InsertMembers(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> members);
1198public SyntaxNode InsertMembers(SyntaxNode declaration, int index, params SyntaxNode[] members)
1199=> this.InsertMembers(declaration, index, (IEnumerable<SyntaxNode>)members);
1204public SyntaxNode AddMembers(SyntaxNode declaration, IEnumerable<SyntaxNode> members)
1210public SyntaxNode AddMembers(SyntaxNode declaration, params SyntaxNode[] members)
1211=> this.AddMembers(declaration, (IEnumerable<SyntaxNode>)members);
1216public abstract Accessibility GetAccessibility(SyntaxNode declaration);
1221public abstract SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibility accessibility);
1226public abstract DeclarationModifiers GetModifiers(SyntaxNode declaration);
1231public abstract SyntaxNode WithModifiers(SyntaxNode declaration, DeclarationModifiers modifiers);
1236public abstract DeclarationKind GetDeclarationKind(SyntaxNode declaration);
1241public abstract string GetName(SyntaxNode declaration);
1246public abstract SyntaxNode WithName(SyntaxNode declaration, string name);
1251public abstract SyntaxNode? GetType(SyntaxNode declaration);
1256public abstract SyntaxNode WithType(SyntaxNode declaration, SyntaxNode type);
1261public abstract IReadOnlyList<SyntaxNode> GetParameters(SyntaxNode declaration);
1263internal abstract SyntaxNode? GetParameterListNode(SyntaxNode declaration);
1268public abstract SyntaxNode InsertParameters(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> parameters);
1273public SyntaxNode AddParameters(SyntaxNode declaration, IEnumerable<SyntaxNode> parameters)
1279public abstract IReadOnlyList<SyntaxNode> GetSwitchSections(SyntaxNode switchStatement);
1284public abstract SyntaxNode InsertSwitchSections(SyntaxNode switchStatement, int index, IEnumerable<SyntaxNode> switchSections);
1289public SyntaxNode AddSwitchSections(SyntaxNode switchStatement, IEnumerable<SyntaxNode> switchSections)
1295public abstract SyntaxNode? GetExpression(SyntaxNode declaration);
1300public abstract SyntaxNode WithExpression(SyntaxNode declaration, SyntaxNode expression);
1305public abstract IReadOnlyList<SyntaxNode> GetStatements(SyntaxNode declaration);
1310public abstract SyntaxNode WithStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements);
1315public abstract IReadOnlyList<SyntaxNode> GetAccessors(SyntaxNode declaration);
1320public SyntaxNode? GetAccessor(SyntaxNode declaration, DeclarationKind kind)
1326public abstract SyntaxNode InsertAccessors(SyntaxNode declaration, int index, IEnumerable<SyntaxNode> accessors);
1331public SyntaxNode AddAccessors(SyntaxNode declaration, IEnumerable<SyntaxNode> accessors)
1337public abstract IReadOnlyList<SyntaxNode> GetGetAccessorStatements(SyntaxNode declaration);
1342public abstract SyntaxNode WithGetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements);
1347public abstract IReadOnlyList<SyntaxNode> GetSetAccessorStatements(SyntaxNode declaration);
1352public abstract SyntaxNode WithSetAccessorStatements(SyntaxNode declaration, IEnumerable<SyntaxNode> statements);
1357public abstract IReadOnlyList<SyntaxNode> GetBaseAndInterfaceTypes(SyntaxNode declaration);
1362public abstract SyntaxNode AddBaseType(SyntaxNode declaration, SyntaxNode baseType);
1367public abstract SyntaxNode AddInterfaceType(SyntaxNode declaration, SyntaxNode interfaceType);
1369internal abstract SyntaxNode AsInterfaceMember(SyntaxNode member);
1378public virtual SyntaxNode ReplaceNode(SyntaxNode root, SyntaxNode node, SyntaxNode? newDeclaration)
1381internal static SyntaxNode ReplaceNode(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> newDeclarations)
1390public virtual SyntaxNode InsertNodesBefore(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> newDeclarations)
1396public virtual SyntaxNode InsertNodesAfter(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> newDeclarations)
1402public virtual SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node)
1408public virtual SyntaxNode RemoveNode(SyntaxNode root, SyntaxNode node, SyntaxRemoveOptions options)
1414public SyntaxNode RemoveNodes(SyntaxNode root, IEnumerable<SyntaxNode> declarations)
1416var newRoot = root.TrackNodes(declarations);
1418foreach (var declaration in declarations)
1420var newDeclaration = newRoot.GetCurrentNode(declaration);
1436internal abstract SeparatedSyntaxList<TElement> SeparatedList<TElement>(SyntaxNodeOrTokenList list) where TElement : SyntaxNode;
1438internal abstract SeparatedSyntaxList<TElement> SeparatedList<TElement>(IEnumerable<TElement> nodes, IEnumerable<SyntaxToken> separators) where TElement : SyntaxNode;
1463protected static SyntaxNode? PreserveTrivia<TNode>(TNode? node, Func<TNode, SyntaxNode> nodeChanger) where TNode : SyntaxNode
1472var changedNode = nodeChanger(nodeWithoutTrivia);
1483protected static SyntaxNode ReplaceWithTrivia(SyntaxNode root, SyntaxNode original, SyntaxNode replacement)
1485var combinedTriviaReplacement =
1492protected static SyntaxNode ReplaceWithTrivia<TNode>(SyntaxNode root, TNode original, Func<TNode, SyntaxNode> replacer)
1493where TNode : SyntaxNode
1498protected static SyntaxNode ReplaceWithTrivia(SyntaxNode root, SyntaxToken original, SyntaxToken replacement)
1511public abstract TNode ClearTrivia<TNode>([MaybeNull] TNode node) where TNode : SyntaxNode;
1528protected static SyntaxNode ReplaceRange(SyntaxNode root, SyntaxNode node, IEnumerable<SyntaxNode> replacements)
1530var first = replacements.First();
1531var trackedFirst = first.TrackNodes(first);
1532var newRoot = root.ReplaceNode(node, trackedFirst);
1533var currentFirst = newRoot.GetCurrentNode(first);
1540where TNode : SyntaxNode
1551where TNode : SyntaxNode
1569public abstract SyntaxNode ExpressionStatement(SyntaxNode expression);
1575public abstract SyntaxNode ReturnStatement(SyntaxNode? expression = null);
1581internal SyntaxNode YieldReturnStatement(SyntaxNode expression)
1588public abstract SyntaxNode ThrowStatement(SyntaxNode? expression = null);
1593public abstract SyntaxNode ThrowExpression(SyntaxNode expression);
1604/// <see cref="LocalDeclarationStatement(ITypeSymbol, string, SyntaxNode, bool)"/>.
1612public abstract SyntaxNode LocalDeclarationStatement(
1613SyntaxNode? type, string identifier, SyntaxNode? initializer = null, bool isConst = false);
1615internal SyntaxNode LocalDeclarationStatement(SyntaxNode? type, SyntaxToken identifier, SyntaxNode? initializer = null, bool isConst = false)
1618internal SyntaxNode WithInitializer(SyntaxNode variableDeclarator, SyntaxNode initializer)
1621internal SyntaxNode EqualsValueClause(SyntaxToken operatorToken, SyntaxNode value)
1627public SyntaxNode LocalDeclarationStatement(ITypeSymbol type, string name, SyntaxNode? initializer = null, bool isConst = false)
1633public SyntaxNode LocalDeclarationStatement(string name, SyntaxNode initializer)
1634=> LocalDeclarationStatement(type: (SyntaxNode?)null, name, initializer);
1639internal SyntaxNode LocalDeclarationStatement(SyntaxToken name, SyntaxNode initializer)
1648public abstract SyntaxNode IfStatement(
1649SyntaxNode condition, IEnumerable<SyntaxNode> trueStatements, IEnumerable<SyntaxNode>? falseStatements = null);
1657public SyntaxNode IfStatement(SyntaxNode condition, IEnumerable<SyntaxNode> trueStatements, SyntaxNode falseStatement)
1663public abstract SyntaxNode SwitchStatement(SyntaxNode expression, IEnumerable<SyntaxNode> sections);
1668public SyntaxNode SwitchStatement(SyntaxNode expression, params SyntaxNode[] sections)
1669=> SwitchStatement(expression, (IEnumerable<SyntaxNode>)sections);
1674public abstract SyntaxNode SwitchSection(IEnumerable<SyntaxNode> caseExpressions, IEnumerable<SyntaxNode> statements);
1676internal abstract SyntaxNode SwitchSectionFromLabels(IEnumerable<SyntaxNode> labels, IEnumerable<SyntaxNode> statements);
1681public SyntaxNode SwitchSection(SyntaxNode caseExpression, IEnumerable<SyntaxNode> statements)
1687public abstract SyntaxNode DefaultSwitchSection(IEnumerable<SyntaxNode> statements);
1692public abstract SyntaxNode ExitSwitchStatement();
1697public abstract SyntaxNode UsingStatement(SyntaxNode? type, string name, SyntaxNode expression, IEnumerable<SyntaxNode> statements);
1702public SyntaxNode UsingStatement(string name, SyntaxNode expression, IEnumerable<SyntaxNode> statements)
1708public abstract SyntaxNode UsingStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements);
1713public abstract SyntaxNode LockStatement(SyntaxNode expression, IEnumerable<SyntaxNode> statements);
1718public abstract SyntaxNode TryCatchStatement(IEnumerable<SyntaxNode> tryStatements, IEnumerable<SyntaxNode>? catchClauses, IEnumerable<SyntaxNode>? finallyStatements = null);
1723public SyntaxNode TryCatchStatement(IEnumerable<SyntaxNode> tryStatements, params SyntaxNode[] catchClauses)
1724=> TryCatchStatement(tryStatements, (IEnumerable<SyntaxNode>?)catchClauses);
1729public SyntaxNode TryFinallyStatement(IEnumerable<SyntaxNode> tryStatements, IEnumerable<SyntaxNode> finallyStatements)
1735public abstract SyntaxNode CatchClause(SyntaxNode type, string identifier, IEnumerable<SyntaxNode> statements);
1740public SyntaxNode CatchClause(ITypeSymbol type, string identifier, IEnumerable<SyntaxNode> statements)
1746public abstract SyntaxNode WhileStatement(SyntaxNode condition, IEnumerable<SyntaxNode> statements);
1751internal abstract SyntaxNode ScopeBlock(IEnumerable<SyntaxNode> statements);
1753internal abstract SyntaxNode GlobalStatement(SyntaxNode statement);
1763internal SyntaxNode InterpolatedStringText(SyntaxToken textToken)
1765internal SyntaxNode Interpolation(SyntaxNode syntaxNode)
1767internal SyntaxNode InterpolatedStringExpression(SyntaxToken startToken, IEnumerable<SyntaxNode> content, SyntaxToken endToken)
1769internal SyntaxNode InterpolationAlignmentClause(SyntaxNode alignment)
1771internal SyntaxNode InterpolationFormatClause(string format)
1778public abstract SyntaxNode DefaultExpression(SyntaxNode type);
1779public abstract SyntaxNode DefaultExpression(ITypeSymbol type);
1784public abstract SyntaxNode ThisExpression();
1789public abstract SyntaxNode BaseExpression();
1794public SyntaxNode LiteralExpression(object? value)
1800private SyntaxNode LiteralExpression(object? value, bool canUseFieldReference)
1806public abstract SyntaxNode TypedConstantExpression(TypedConstant value);
1811public SyntaxNode FalseLiteralExpression()
1817public SyntaxNode TrueLiteralExpression()
1823public SyntaxNode NullLiteralExpression()
1831public abstract SyntaxNode IdentifierName(string identifier);
1833internal abstract SyntaxNode IdentifierName(SyntaxToken identifier);
1835internal abstract SyntaxNode NamedAnonymousObjectMemberDeclarator(SyntaxNode identifier, SyntaxNode expression);
1840public abstract SyntaxNode GenericName(string identifier, IEnumerable<SyntaxNode> typeArguments);
1842internal abstract SyntaxNode GenericName(SyntaxToken identifier, IEnumerable<SyntaxNode> typeArguments);
1847public SyntaxNode GenericName(string identifier, IEnumerable<ITypeSymbol> typeArguments)
1853public SyntaxNode GenericName(string identifier, params SyntaxNode[] typeArguments)
1854=> GenericName(identifier, (IEnumerable<SyntaxNode>)typeArguments);
1859public SyntaxNode GenericName(string identifier, params ITypeSymbol[] typeArguments)
1866public abstract SyntaxNode WithTypeArguments(SyntaxNode expression, IEnumerable<SyntaxNode> typeArguments);
1872public SyntaxNode WithTypeArguments(SyntaxNode expression, params SyntaxNode[] typeArguments)
1873=> WithTypeArguments(expression, (IEnumerable<SyntaxNode>)typeArguments);
1880public abstract SyntaxNode QualifiedName(SyntaxNode left, SyntaxNode right);
1885internal abstract SyntaxNode GlobalAliasedName(SyntaxNode name);
1890public SyntaxNode DottedName(string dottedName)
1900SyntaxNode? name = null;
1924public abstract SyntaxNode NameExpression(INamespaceOrTypeSymbol namespaceOrTypeSymbol);
1929public SyntaxNode TypeExpression(ITypeSymbol typeSymbol)
1932private protected abstract SyntaxNode TypeExpression(ITypeSymbol typeSymbol, RefKind refKind);
1939public SyntaxNode TypeExpression(ITypeSymbol typeSymbol, bool addImport)
1941var expression = TypeExpression(typeSymbol);
1950public abstract SyntaxNode TypeExpression(SpecialType specialType);
1955public abstract SyntaxNode ArrayTypeExpression(SyntaxNode type);
1960public abstract SyntaxNode NullableTypeExpression(SyntaxNode type);
1965public SyntaxNode TupleTypeExpression(IEnumerable<SyntaxNode> elements)
1980internal abstract SyntaxNode CreateTupleType(IEnumerable<SyntaxNode> elements);
1985public SyntaxNode TupleTypeExpression(params SyntaxNode[] elements)
1986=> TupleTypeExpression((IEnumerable<SyntaxNode>)elements);
1991public SyntaxNode TupleTypeExpression(IEnumerable<ITypeSymbol> elementTypes, IEnumerable<string>? elementNames = null)
2015public abstract SyntaxNode TupleElementExpression(SyntaxNode type, string? name = null);
2020public SyntaxNode TupleElementExpression(ITypeSymbol type, string? name = null)
2027public abstract SyntaxNode AssignmentStatement(SyntaxNode left, SyntaxNode right);
2032public abstract SyntaxNode ValueEqualsExpression(SyntaxNode left, SyntaxNode right);
2037public abstract SyntaxNode ReferenceEqualsExpression(SyntaxNode left, SyntaxNode right);
2042public abstract SyntaxNode ValueNotEqualsExpression(SyntaxNode left, SyntaxNode right);
2047public abstract SyntaxNode ReferenceNotEqualsExpression(SyntaxNode left, SyntaxNode right);
2052public abstract SyntaxNode LessThanExpression(SyntaxNode left, SyntaxNode right);
2057public abstract SyntaxNode LessThanOrEqualExpression(SyntaxNode left, SyntaxNode right);
2062public abstract SyntaxNode GreaterThanExpression(SyntaxNode left, SyntaxNode right);
2067public abstract SyntaxNode GreaterThanOrEqualExpression(SyntaxNode left, SyntaxNode right);
2072public abstract SyntaxNode NegateExpression(SyntaxNode expression);
2077public abstract SyntaxNode AddExpression(SyntaxNode left, SyntaxNode right);
2082public abstract SyntaxNode SubtractExpression(SyntaxNode left, SyntaxNode right);
2087public abstract SyntaxNode MultiplyExpression(SyntaxNode left, SyntaxNode right);
2092public abstract SyntaxNode DivideExpression(SyntaxNode left, SyntaxNode right);
2097public abstract SyntaxNode ModuloExpression(SyntaxNode left, SyntaxNode right);
2102public abstract SyntaxNode BitwiseAndExpression(SyntaxNode left, SyntaxNode right);
2107public abstract SyntaxNode BitwiseOrExpression(SyntaxNode left, SyntaxNode right);
2112public abstract SyntaxNode BitwiseNotExpression(SyntaxNode operand);
2117public abstract SyntaxNode LogicalAndExpression(SyntaxNode left, SyntaxNode right);
2122public abstract SyntaxNode LogicalOrExpression(SyntaxNode left, SyntaxNode right);
2127public abstract SyntaxNode LogicalNotExpression(SyntaxNode expression);
2132public abstract SyntaxNode ConditionalExpression(SyntaxNode condition, SyntaxNode whenTrue, SyntaxNode whenFalse);
2137/// cref="ElementBindingExpression(IEnumerable{SyntaxNode})"/> to generate the <paramref
2140public abstract SyntaxNode ConditionalAccessExpression(SyntaxNode expression, SyntaxNode whenNotNull);
2145public abstract SyntaxNode MemberBindingExpression(SyntaxNode name);
2150public abstract SyntaxNode ElementBindingExpression(IEnumerable<SyntaxNode> arguments);
2155public SyntaxNode ElementBindingExpression(params SyntaxNode[] arguments)
2156=> ElementBindingExpression((IEnumerable<SyntaxNode>)arguments);
2161public abstract SyntaxNode CoalesceExpression(SyntaxNode left, SyntaxNode right);
2166public virtual SyntaxNode MemberAccessExpression(SyntaxNode? expression, SyntaxNode memberName)
2172internal abstract SyntaxNode MemberAccessExpressionWorker(SyntaxNode? expression, SyntaxNode memberName);
2174internal SyntaxNode RefExpression(SyntaxNode expression)
2180public SyntaxNode MemberAccessExpression(SyntaxNode? expression, string memberName)
2186public abstract SyntaxNode ArrayCreationExpression(SyntaxNode elementType, SyntaxNode size);
2191public abstract SyntaxNode ArrayCreationExpression(SyntaxNode elementType, IEnumerable<SyntaxNode> elements);
2196public abstract SyntaxNode ObjectCreationExpression(SyntaxNode namedType, IEnumerable<SyntaxNode> arguments);
2198internal abstract SyntaxNode ObjectCreationExpression(
2199SyntaxNode namedType, SyntaxToken openParen, SeparatedSyntaxList<SyntaxNode> arguments, SyntaxToken closeParen);
2204public SyntaxNode ObjectCreationExpression(ITypeSymbol type, IEnumerable<SyntaxNode> arguments)
2210public SyntaxNode ObjectCreationExpression(SyntaxNode type, params SyntaxNode[] arguments)
2211=> ObjectCreationExpression(type, (IEnumerable<SyntaxNode>)arguments);
2216public SyntaxNode ObjectCreationExpression(ITypeSymbol type, params SyntaxNode[] arguments)
2217=> ObjectCreationExpression(type, (IEnumerable<SyntaxNode>)arguments);
2222public abstract SyntaxNode InvocationExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments);
2227public SyntaxNode InvocationExpression(SyntaxNode expression, params SyntaxNode[] arguments)
2228=> InvocationExpression(expression, (IEnumerable<SyntaxNode>)arguments);
2233public abstract SyntaxNode Argument(string? name, RefKind refKind, SyntaxNode expression);
2238public SyntaxNode Argument(RefKind refKind, SyntaxNode expression)
2244public SyntaxNode Argument(SyntaxNode expression)
2250public abstract SyntaxNode ElementAccessExpression(SyntaxNode expression, IEnumerable<SyntaxNode> arguments);
2255public SyntaxNode ElementAccessExpression(SyntaxNode expression, params SyntaxNode[] arguments)
2256=> ElementAccessExpression(expression, (IEnumerable<SyntaxNode>)arguments);
2261public abstract SyntaxNode TypeOfExpression(SyntaxNode type);
2266public abstract SyntaxNode IsTypeExpression(SyntaxNode expression, SyntaxNode type);
2271public SyntaxNode IsTypeExpression(SyntaxNode expression, ITypeSymbol type)
2277public abstract SyntaxNode TryCastExpression(SyntaxNode expression, SyntaxNode type);
2282public SyntaxNode TryCastExpression(SyntaxNode expression, ITypeSymbol type)
2288public abstract SyntaxNode CastExpression(SyntaxNode type, SyntaxNode expression);
2293public SyntaxNode CastExpression(ITypeSymbol type, SyntaxNode expression)
2299public abstract SyntaxNode ConvertExpression(SyntaxNode type, SyntaxNode expression);
2304public SyntaxNode ConvertExpression(ITypeSymbol type, SyntaxNode expression)
2310public abstract SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, SyntaxNode expression);
2315public abstract SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, SyntaxNode expression);
2320public abstract SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, IEnumerable<SyntaxNode> statements);
2325public abstract SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode>? lambdaParameters, IEnumerable<SyntaxNode> statements);
2330public SyntaxNode ValueReturningLambdaExpression(string parameterName, SyntaxNode expression)
2336public SyntaxNode VoidReturningLambdaExpression(string parameterName, SyntaxNode expression)
2342public SyntaxNode ValueReturningLambdaExpression(string parameterName, IEnumerable<SyntaxNode> statements)
2348public SyntaxNode VoidReturningLambdaExpression(string parameterName, IEnumerable<SyntaxNode> statements)
2354public SyntaxNode ValueReturningLambdaExpression(SyntaxNode expression)
2355=> ValueReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, expression);
2360public SyntaxNode VoidReturningLambdaExpression(SyntaxNode expression)
2361=> VoidReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, expression);
2366public SyntaxNode ValueReturningLambdaExpression(IEnumerable<SyntaxNode> statements)
2367=> ValueReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, statements);
2372public SyntaxNode VoidReturningLambdaExpression(IEnumerable<SyntaxNode> statements)
2373=> VoidReturningLambdaExpression((IEnumerable<SyntaxNode>?)null, statements);
2378public abstract SyntaxNode LambdaParameter(string identifier, SyntaxNode? type = null);
2383public SyntaxNode LambdaParameter(string identifier, ITypeSymbol type)
2389public abstract SyntaxNode AwaitExpression(SyntaxNode expression);
2394internal SyntaxNode AddParentheses(SyntaxNode expression, bool includeElasticTrivia = true, bool addSimplifierAnnotation = true)
2400public abstract SyntaxNode NameOfExpression(SyntaxNode expression);
2405public abstract SyntaxNode TupleExpression(IEnumerable<SyntaxNode> arguments);
2410internal abstract SyntaxNode ParseExpression(string stringToParse);
2412internal abstract SyntaxTrivia Trivia(SyntaxNode node);
2414internal abstract SyntaxNode DocumentationCommentTrivia(IEnumerable<SyntaxNode> nodes, SyntaxTriviaList trailingTrivia, string endOfLineString);
2416internal 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();
371SyntaxNode 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;
626else if (node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFactsService>((node, syntaxFacts) => syntaxFacts.IsUsingOrExternOrImport(node), syntaxFacts) != null)
733private static bool IsNodeOrAnyAncestorLeftSideOfDot(SyntaxNode node, ISyntaxFactsService syntaxFacts)
751SyntaxNode node, FindReferencesDocumentState state)
768void 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 _)
88var node = current.AsNode();
216private static bool IsGlobalSuppressMessageAttribute(ISyntaxFactsService syntaxFacts, SyntaxNode node)
221var name = syntaxFacts.GetNameOfAttribute(node);
224syntaxFacts.GetPartsOfQualifiedName(name, out _, out _, out var right);
242SyntaxNode node)
259foreach (var attributeList in attributeLists)
261foreach (var attribute in syntaxFacts.GetAttributesOfAttributeList(attributeList))
263syntaxFacts.GetPartsOfAttribute(attribute, out var attributeName, out var argumentList);
271var versionArg = syntaxFacts.GetExpressionOfAttributeArgument(arguments[0]);
272var dataArg = syntaxFacts.GetExpressionOfAttributeArgument(arguments[1]);
287syntaxFacts.GetPartsOfQualifiedName(attributeName, out _, out _, out var right);
311SyntaxNode node)
316syntaxFacts.GetPartsOfUsingAliasDirective(node, out var globalToken, out var alias, out var usingTarget);
321syntaxFacts.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 (122)
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,
943public static SyntaxTriviaList GetLeadingTriviaIncludingMissingTokens(this SyntaxNode node)
959public static SyntaxTriviaList GetTrailingTriviaIncludingMissingTokens(this SyntaxNode node)
978public static SyntaxNode WithLeadingTriviaFromIncludingMissingTokens(this SyntaxNode node, SyntaxNode other)
983public static SyntaxNode WithTrailingTriviaFromIncludingMissingTokens(this SyntaxNode node, SyntaxNode other)
988public static SyntaxNode WithTriviaFromIncludingMissingTokens(this SyntaxNode node, SyntaxNode other)
997public static ValueAncestorsAndSelfEnumerable ValueAncestorsAndSelf(this SyntaxNode syntaxNode, bool ascendOutOfTrivia = true)
1000public readonly struct ValueAncestorsAndSelfEnumerable(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
1005public struct Enumerator(SyntaxNode syntaxNode, bool ascendOutOfTrivia)
1007public 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 (302)
118bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node);
119bool IsPredefinedType([NotNullWhen(true)] SyntaxNode? node, PredefinedType type);
169bool IsUsingOrExternOrImport([NotNullWhen(true)] SyntaxNode? node);
170bool IsGlobalAssemblyAttribute([NotNullWhen(true)] SyntaxNode? node);
171bool IsGlobalModuleAttribute([NotNullWhen(true)] SyntaxNode? node);
172bool IsDeclaration([NotNullWhen(true)] SyntaxNode? node);
173bool IsTypeDeclaration(SyntaxNode node);
175bool IsUsingAliasDirective([NotNullWhen(true)] SyntaxNode? node);
180bool IsPragmaDirective(SyntaxTrivia trivia, out bool isDisable, out bool isActive, out SeparatedSyntaxList<SyntaxNode> errorCodes);
183SyntaxNode? GetMatchingDirective(SyntaxNode directive, CancellationToken cancellationToken);
184ImmutableArray<SyntaxNode> GetMatchingConditionalDirectives(SyntaxNode directive, CancellationToken cancellationToken);
186bool IsDocumentationComment(SyntaxNode node);
193bool TryGetExternalSourceInfo([NotNullWhen(true)] SyntaxNode? directive, out ExternalSourceInfo info);
195bool IsDeclarationExpression([NotNullWhen(true)] SyntaxNode? node);
197bool IsConversionExpression([NotNullWhen(true)] SyntaxNode? node);
198bool IsCastExpression([NotNullWhen(true)] SyntaxNode? node);
200bool IsExpressionOfForeach([NotNullWhen(true)] SyntaxNode? node);
201SyntaxNode GetExpressionOfForeachStatement(SyntaxNode statement);
203void GetPartsOfTupleExpression<TArgumentSyntax>(SyntaxNode node,
204out SyntaxToken openParen, out SeparatedSyntaxList<TArgumentSyntax> arguments, out SyntaxToken closeParen) where TArgumentSyntax : SyntaxNode;
206bool IsVerbatimInterpolatedStringExpression([NotNullWhen(true)] SyntaxNode? node);
209bool IsLeftSideOfAssignment([NotNullWhen(true)] SyntaxNode? node);
211bool IsAnyAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
212bool IsSimpleAssignmentStatement([NotNullWhen(true)] SyntaxNode? statement);
213void GetPartsOfAssignmentStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
214void GetPartsOfAssignmentExpressionOrStatement(SyntaxNode statement, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
217bool IsLeftSideOfAnyAssignment([NotNullWhen(true)] SyntaxNode? node);
219bool IsLeftSideOfCompoundAssignment([NotNullWhen(true)] SyntaxNode? node);
220SyntaxNode GetRightHandSideOfAssignment(SyntaxNode node);
222bool IsInferredAnonymousObjectMemberDeclarator([NotNullWhen(true)] SyntaxNode? node);
223bool IsOperandOfIncrementExpression([NotNullWhen(true)] SyntaxNode? node);
224bool IsOperandOfIncrementOrDecrementExpression([NotNullWhen(true)] SyntaxNode? node);
226bool IsLeftSideOfDot([NotNullWhen(true)] SyntaxNode? node);
227SyntaxNode? GetRightSideOfDot(SyntaxNode? node);
241SyntaxNode? GetLeftSideOfDot(SyntaxNode? node, bool allowImplicitTarget = false);
243bool IsLeftSideOfExplicitInterfaceSpecifier([NotNullWhen(true)] SyntaxNode? node);
245bool IsNameOfSimpleMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
246bool IsNameOfAnyMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
247bool IsNameOfMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
256SyntaxNode? GetStandaloneExpression(SyntaxNode? node);
265SyntaxNode? GetRootConditionalAccessExpression(SyntaxNode? node);
274SyntaxNode? GetExpressionOfMemberAccessExpression(SyntaxNode node, bool allowImplicitTarget = false);
276SyntaxNode? GetTargetOfMemberBinding(SyntaxNode? node);
278SyntaxNode GetNameOfMemberBindingExpression(SyntaxNode node);
280bool IsPointerMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
282bool IsNamedArgument([NotNullWhen(true)] SyntaxNode? node);
283bool IsNameOfNamedArgument([NotNullWhen(true)] SyntaxNode? node);
284SyntaxNode? GetParameterList(SyntaxNode node);
285bool IsParameterList([NotNullWhen(true)] SyntaxNode? node);
289void GetPartsOfElementAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode argumentList);
291SyntaxNode GetExpressionOfArgument(SyntaxNode node);
292SyntaxNode GetExpressionOfAttributeArgument(SyntaxNode node);
293SyntaxNode GetExpressionOfInterpolation(SyntaxNode node);
295bool IsElementBindingExpression([NotNullWhen(true)] SyntaxNode? node);
296bool IsMemberBindingExpression([NotNullWhen(true)] SyntaxNode? node);
297bool IsPostfixUnaryExpression([NotNullWhen(true)] SyntaxNode? node);
299SyntaxToken GetIdentifierOfSimpleName(SyntaxNode node);
300SyntaxToken GetIdentifierOfTypeDeclaration(SyntaxNode node);
301SyntaxToken GetIdentifierOfVariableDeclarator(SyntaxNode node);
302SyntaxNode GetTypeOfVariableDeclarator(SyntaxNode node);
308bool IsSimpleArgument([NotNullWhen(true)] SyntaxNode? node);
309bool IsArgument([NotNullWhen(true)] SyntaxNode? node);
310bool IsAttributeArgument([NotNullWhen(true)] SyntaxNode? node);
311RefKind GetRefKindOfArgument(SyntaxNode node);
313void GetNameAndArityOfSimpleName(SyntaxNode node, out string name, out int arity);
314bool LooksGeneric(SyntaxNode simpleName);
316SeparatedSyntaxList<SyntaxNode> GetTypeArgumentsOfGenericName(SyntaxNode? genericName);
318SyntaxList<SyntaxNode> GetContentsOfInterpolatedString(SyntaxNode interpolatedString);
320SeparatedSyntaxList<SyntaxNode> GetArgumentsOfObjectCreationExpression(SyntaxNode node);
321SeparatedSyntaxList<SyntaxNode> GetArgumentsOfArgumentList(SyntaxNode node);
322SeparatedSyntaxList<SyntaxNode> GetArgumentsOfAttributeArgumentList(SyntaxNode node);
324bool IsUsingDirectiveName([NotNullWhen(true)] SyntaxNode? node);
327SyntaxList<SyntaxNode> GetAttributeLists(SyntaxNode? node);
328SeparatedSyntaxList<SyntaxNode> GetAttributesOfAttributeList(SyntaxNode node);
330bool IsAttributeNamedArgumentIdentifier([NotNullWhen(true)] SyntaxNode? node);
331bool IsMemberInitializerNamedAssignmentIdentifier([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? initializedInstance);
332bool IsAnyInitializerExpression([NotNullWhen(true)] SyntaxNode? node, [NotNullWhen(true)] out SyntaxNode? creationExpression);
334bool IsDirective([NotNullWhen(true)] SyntaxNode? node);
335bool IsStatement([NotNullWhen(true)] SyntaxNode? node);
336bool IsExecutableStatement([NotNullWhen(true)] SyntaxNode? node);
337bool IsGlobalStatement([NotNullWhen(true)] SyntaxNode? node);
338SyntaxNode GetStatementOfGlobalStatement(SyntaxNode node);
339bool AreStatementsInSameContainer(SyntaxNode firstStatement, SyntaxNode secondStatement);
341bool IsDeconstructionAssignment([NotNullWhen(true)] SyntaxNode? node);
342bool IsDeconstructionForEachStatement([NotNullWhen(true)] SyntaxNode? node);
343bool IsUsingLocalDeclarationStatement(SyntaxNode node);
357bool IsMethodBody([NotNullWhen(true)] SyntaxNode? node);
359bool IsDeclaratorOfLocalDeclarationStatement(SyntaxNode declarator, SyntaxNode localDeclarationStatement);
360SeparatedSyntaxList<SyntaxNode> GetVariablesOfLocalDeclarationStatement(SyntaxNode node);
361SyntaxNode? GetInitializerOfVariableDeclarator(SyntaxNode node);
362SyntaxNode? GetInitializerOfPropertyDeclaration(SyntaxNode node);
367bool IsElementAccessExpression([NotNullWhen(true)] SyntaxNode? node);
385bool IsInStaticContext(SyntaxNode node);
386bool IsUnsafeContext(SyntaxNode node);
388bool IsInNamespaceOrTypeContext([NotNullWhen(true)] SyntaxNode? node);
390bool IsBaseTypeList([NotNullWhen(true)] SyntaxNode? node);
392bool IsInConstantContext([NotNullWhen(true)] SyntaxNode? node);
393bool IsInConstructor(SyntaxNode node);
394bool IsMethodLevelMember([NotNullWhen(true)] SyntaxNode? node);
395bool IsTopLevelNodeWithMembers([NotNullWhen(true)] SyntaxNode? node);
398bool AreEquivalent(SyntaxNode? node1, SyntaxNode? node2);
400string GetDisplayName(SyntaxNode? node, DisplayNameOptions options, string? rootNamespace = null);
403SyntaxNode? GetContainingTypeDeclaration(SyntaxNode root, int position);
404SyntaxNode? GetContainingMemberDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
405SyntaxNode? GetContainingMethodDeclaration(SyntaxNode root, int position, bool useFullSpan = true);
406SyntaxNode? GetContainingVariableDeclaratorOfFieldDeclaration(SyntaxNode? node);
410SyntaxNode? ConvertToSingleLine(SyntaxNode? node, bool useElasticTrivia = false);
413PooledObject<List<SyntaxNode>> GetTopLevelAndMethodLevelMembers(SyntaxNode? root);
415PooledObject<List<SyntaxNode>> GetMethodLevelMembers(SyntaxNode? root);
416SyntaxList<SyntaxNode> GetMembersOfTypeDeclaration(SyntaxNode typeDeclaration);
419bool ContainsInMemberBody([NotNullWhen(true)] SyntaxNode? node, TextSpan span);
424/// Given a <see cref="SyntaxNode"/>, return the <see cref="TextSpan"/> representing the span of the member body
430TextSpan GetMemberBodySpanForSpeculativeBinding(SyntaxNode node);
438SyntaxNode? TryGetBindableParent(SyntaxToken token);
441IEnumerable<SyntaxNode> GetConstructors(SyntaxNode? root, CancellationToken cancellationToken);
444/// Given a <see cref="SyntaxNode"/>, that represents and argument return the string representation of
448string GetNameForArgument(SyntaxNode? argument);
451/// Given a <see cref="SyntaxNode"/>, that represents an attribute argument return the string representation of
455string GetNameForAttributeArgument(SyntaxNode? argument);
457bool IsNameOfSubpattern([NotNullWhen(true)] SyntaxNode? node);
458bool IsPropertyPatternClause(SyntaxNode node);
460bool IsAnyPattern([NotNullWhen(true)] SyntaxNode? node);
461bool IsBinaryPattern([NotNullWhen(true)] SyntaxNode? node);
462bool IsUnaryPattern([NotNullWhen(true)] SyntaxNode? node);
464SyntaxNode GetExpressionOfConstantPattern(SyntaxNode node);
465SyntaxNode GetTypeOfTypePattern(SyntaxNode node);
467void GetPartsOfParenthesizedPattern(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode pattern, out SyntaxToken closeParen);
468void GetPartsOfBinaryPattern(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
469void GetPartsOfDeclarationPattern(SyntaxNode node, out SyntaxNode type, out SyntaxNode designation);
470void GetPartsOfRecursivePattern(SyntaxNode node, out SyntaxNode? type, out SyntaxNode? positionalPart, out SyntaxNode? propertyPart, out SyntaxNode? designation);
471void GetPartsOfRelationalPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode expression);
472void GetPartsOfUnaryPattern(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode pattern);
476SyntaxTokenList GetModifiers(SyntaxNode? node);
480SyntaxNode? WithModifiers(SyntaxNode? node, SyntaxTokenList modifiers);
483Location GetDeconstructionReferenceLocation(SyntaxNode node);
488bool IsParameterNameXmlElementSyntax([NotNullWhen(true)] SyntaxNode? node);
490SyntaxList<SyntaxNode> GetContentFromDocumentationCommentTriviaSyntax(SyntaxTrivia trivia);
496bool IsAnonymousFunctionExpression([NotNullWhen(true)] SyntaxNode? node);
497bool IsBaseNamespaceDeclaration([NotNullWhen(true)] SyntaxNode? node);
498bool IsBinaryExpression([NotNullWhen(true)] SyntaxNode? node);
499bool IsLiteralExpression([NotNullWhen(true)] SyntaxNode? node);
500bool IsMemberAccessExpression([NotNullWhen(true)] SyntaxNode? node);
501bool IsMethodDeclaration([NotNullWhen(true)] SyntaxNode? node);
502bool IsSimpleName([NotNullWhen(true)] SyntaxNode? node);
503bool IsAnyName([NotNullWhen(true)] SyntaxNode? node);
504bool IsAnyType([NotNullWhen(true)] SyntaxNode? node);
506bool IsNamedMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
507bool IsElementAccessInitializer([NotNullWhen(true)] SyntaxNode? node);
509bool IsObjectMemberInitializer([NotNullWhen(true)] SyntaxNode? node);
510bool IsObjectCollectionInitializer([NotNullWhen(true)] SyntaxNode? node);
516void GetPartsOfAliasQualifiedName(SyntaxNode node, out SyntaxNode alias, out SyntaxToken colonColonToken, out SyntaxNode name);
517void GetPartsOfAnyIsTypeExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode type);
518void GetPartsOfArgumentList(SyntaxNode node, out SyntaxToken openParenToken, out SeparatedSyntaxList<SyntaxNode> arguments, out SyntaxToken closeParenToken);
519void GetPartsOfAttribute(SyntaxNode node, out SyntaxNode name, out SyntaxNode? argumentList);
520void GetPartsOfBaseNamespaceDeclaration(SyntaxNode node, out SyntaxNode name, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> members);
521void GetPartsOfBaseObjectCreationExpression(SyntaxNode node, out SyntaxNode? argumentList, out SyntaxNode? initializer);
522void GetPartsOfBinaryExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken operatorToken, out SyntaxNode right);
523void GetPartsOfCastExpression(SyntaxNode node, out SyntaxNode type, out SyntaxNode expression);
524void GetPartsOfCompilationUnit(SyntaxNode node, out SyntaxList<SyntaxNode> imports, out SyntaxList<SyntaxNode> attributeLists, out SyntaxList<SyntaxNode> members);
525void GetPartsOfConditionalAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode whenNotNull);
526void GetPartsOfConditionalExpression(SyntaxNode node, out SyntaxNode condition, out SyntaxNode whenTrue, out SyntaxNode whenFalse);
527void GetPartsOfGenericName(SyntaxNode node, out SyntaxToken identifier, out SeparatedSyntaxList<SyntaxNode> typeArguments);
528void GetPartsOfInterpolationExpression(SyntaxNode node, out SyntaxToken stringStartToken, out SyntaxList<SyntaxNode> contents, out SyntaxToken stringEndToken);
529void GetPartsOfInvocationExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxNode? argumentList);
530void GetPartsOfIsPatternExpression(SyntaxNode node, out SyntaxNode left, out SyntaxToken isToken, out SyntaxNode right);
531void GetPartsOfMemberAccessExpression(SyntaxNode node, out SyntaxNode expression, out SyntaxToken operatorToken, out SyntaxNode name);
532void GetPartsOfNamedMemberInitializer(SyntaxNode node, out SyntaxNode name, out SyntaxNode expression);
533void GetPartsOfObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode type, out SyntaxNode? argumentList, out SyntaxNode? initializer);
534void GetPartsOfImplicitObjectCreationExpression(SyntaxNode node, out SyntaxToken keyword, out SyntaxNode argumentList, out SyntaxNode? initializer);
535void GetPartsOfParameter(SyntaxNode node, out SyntaxToken identifier, out SyntaxNode? @default);
536void GetPartsOfParenthesizedExpression(SyntaxNode node, out SyntaxToken openParen, out SyntaxNode expression, out SyntaxToken closeParen);
537void GetPartsOfPrefixUnaryExpression(SyntaxNode node, out SyntaxToken operatorToken, out SyntaxNode operand);
538void GetPartsOfQualifiedName(SyntaxNode node, out SyntaxNode left, out SyntaxToken dotToken, out SyntaxNode right);
539void GetPartsOfUsingAliasDirective(SyntaxNode node, out SyntaxToken globalKeyword, out SyntaxToken alias, out SyntaxNode name);
549SyntaxNode GetArgumentListOfImplicitElementAccess(SyntaxNode node);
551SyntaxNode GetExpressionOfAwaitExpression(SyntaxNode node);
552SyntaxNode GetExpressionOfExpressionStatement(SyntaxNode node);
553SyntaxNode GetExpressionOfRefExpression(SyntaxNode node);
554SyntaxNode? GetExpressionOfReturnStatement(SyntaxNode node);
555SyntaxNode GetExpressionOfThrowExpression(SyntaxNode node);
556SyntaxNode? GetExpressionOfThrowStatement(SyntaxNode node);
558bool IsEqualsValueOfPropertyDeclaration([NotNullWhen(true)] SyntaxNode? node);
559SyntaxNode GetValueOfEqualsValueClause(SyntaxNode node);
561SeparatedSyntaxList<SyntaxNode> GetInitializersOfObjectMemberInitializer(SyntaxNode node);
562SeparatedSyntaxList<SyntaxNode> GetExpressionsOfObjectCollectionInitializer(SyntaxNode node);
564SyntaxToken GetTokenOfLiteralExpression(SyntaxNode node);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (204)
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 IsRightOfAliasQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
660var parent = node?.Parent;
664syntaxFacts.GetPartsOfAliasQualifiedName(parent, out _, out _, out var right);
668public static bool IsTypeOfObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
670var parent = node?.Parent;
674syntaxFacts.GetPartsOfObjectCreationExpression(parent, out _, out var type, out _, out _);
705public static bool IsSkippedTokensTrivia(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
745public static bool IsAliasQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
748public static bool IsGenericName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
751public static bool IsIdentifierName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
754public static bool IsQualifiedName(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
761public static bool IsTupleType(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
768public static bool IsCharacterLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
771public static bool IsDefaultLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
774public static bool IsFalseLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
777public static bool IsNumericLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
780public static bool IsNullLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
783public static bool IsStringLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
786public static bool IsTrueLiteralExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
793public static bool IsArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
796public static bool IsAwaitExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
799public static bool IsBaseExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
802public static bool IsConditionalExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
805public static bool IsConditionalAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
808public static bool IsImplicitArrayCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
811public static bool IsImplicitObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
814public static bool IsIndexExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
817public static bool IsInterpolatedStringExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
820public static bool IsInterpolation(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
823public static bool IsInterpolatedStringText(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
826public static bool IsInvocationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
829public static bool IsIsTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
832public static bool IsIsNotTypeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
835public static bool IsIsPatternExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
838public static bool IsLogicalAndExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
841public static bool IsLogicalOrExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
844public static bool IsLogicalNotExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
847public static bool IsObjectCreationExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
850public static bool IsParenthesizedExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
853public static bool IsQueryExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
856public static bool IsRangeExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
859public static bool IsRefExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
862public static bool IsSimpleMemberAccessExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
865public static bool IsThisExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
868public static bool IsThrowExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
871public static bool IsTupleExpression(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
874public static bool ContainsGlobalStatement(this ISyntaxFacts syntaxFacts, SyntaxNode node)
881public static bool IsAndPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
884public static bool IsConstantPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
887public static bool IsDeclarationPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
890public static bool IsListPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
893public static bool IsNotPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
896public static bool IsOrPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
899public static bool IsParenthesizedPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
902public static bool IsRecursivePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
905public static bool IsRelationalPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
908public static bool IsTypePattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
911public static bool IsVarPattern(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
918public static bool IsExpressionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
921public static bool IsForEachStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
924public static bool IsForStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
927public static bool IsIfStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
930public static bool IsLocalDeclarationStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
933public static bool IsLocalFunctionStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
936public static bool IsLockStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
939public static bool IsReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
942public static bool IsThrowStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
945public static bool IsUsingStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
948public static bool IsWhileStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
951public static bool IsYieldReturnStatement(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
958public static bool IsAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
961public static bool IsClassDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
964public static bool IsConstructorDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
967public static bool IsEnumDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
970public static bool IsGlobalAttribute(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
973public static bool IsInterfaceDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
976public static bool IsParameter(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
979public static bool IsTypeConstraint(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
982public static bool IsVariableDeclarator(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
985public static bool IsFieldDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
988public static bool IsPropertyDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
991public static bool IsStructDeclaration(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
994public static bool IsTypeArgumentList(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1001public static bool IsElseClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1003public static bool IsEqualsValueClause(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1010public static bool IsImplicitElementAccess(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1013public static bool IsIndexerMemberCref(this ISyntaxFacts syntaxFacts, [NotNullWhen(true)] SyntaxNode? node)
1016public static bool IsPrimaryConstructorBaseType(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 (18)
60SyntaxNode? initializer = null)
86bool isIndexer = false, SyntaxNode? initializer = null)
114SyntaxNode? initializer = null)
130ImmutableArray<SyntaxNode> statements = default,
131ImmutableArray<SyntaxNode> baseConstructorArguments = default,
132ImmutableArray<SyntaxNode> thisConstructorArguments = default,
145ImmutableArray<SyntaxNode> statements = default)
163ImmutableArray<SyntaxNode> statements = default,
164ImmutableArray<SyntaxNode> handlesExpressions = default,
184ImmutableArray<SyntaxNode> statements = default,
185ImmutableArray<SyntaxNode> handlesExpressions = default,
203ImmutableArray<SyntaxNode> statements = default,
229ImmutableArray<SyntaxNode> statements = default,
257ImmutableArray<SyntaxNode> statements = default,
366ImmutableArray<SyntaxNode> statements = default)
390ImmutableArray<SyntaxNode> statements)
523ImmutableArray<SyntaxNode> statements = default,
556SyntaxNode? initializer = null)
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(
201var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
202var expression = property.IsIndexer
230public static ImmutableArray<SyntaxNode> GetSetAccessorStatements(
240var throughExpression = CreateDelegateThroughExpression(generator, property, throughMember);
241var expression = property.IsIndexer
343public static ImmutableArray<SyntaxNode> CreateAssignmentStatements(
353using var _1 = ArrayBuilder<SyntaxNode>.GetInstance(out var nullCheckStatements);
354using var _2 = ArrayBuilder<SyntaxNode>.GetInstance(out var assignStatements);
366var assignExpression = factory.AssignmentStatement(
369var statement = factory.ExpressionStatement(assignExpression);
379var fieldAccess = factory.MemberAccessExpression(factory.ThisExpression(), factory.IdentifierName(fieldName))
399SyntaxNode fieldAccess,
402ArrayBuilder<SyntaxNode> nullCheckStatements,
403ArrayBuilder<SyntaxNode> assignStatements)
434public static SyntaxNode CreateAssignWithNullCheckStatement(
435this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter, SyntaxNode fieldAccess)
444public static SyntaxNode CreateThrowArgumentNullExpression(this SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
447private static SyntaxNode CreateNewArgumentNullException(SyntaxGenerator factory, Compilation compilation, IParameterSymbol parameter)
456public static SyntaxNode CreateNullCheckAndThrowStatement(
462var condition = factory.CreateNullCheckExpression(generatorInternal, semanticModel, parameter.Name);
463var throwStatement = factory.CreateThrowArgumentNullExceptionStatement(semanticModel.Compilation, parameter);
468public static SyntaxNode CreateNullCheckExpression(
471var identifier = factory.IdentifierName(identifierName);
472var nullExpr = factory.NullLiteralExpression();
473var condition = generatorInternal.SupportsPatterns(semanticModel.SyntaxTree.Options)
479public 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\InitializeParameter\AbstractInitializerParameterService.cs (23)
20where TStatementSyntax : SyntaxNode
22protected abstract bool IsFunctionDeclaration(SyntaxNode node);
24protected abstract SyntaxNode? GetAccessorBody(IMethodSymbol accessor, CancellationToken cancellationToken);
26protected abstract SyntaxNode GetBody(SyntaxNode methodNode);
27protected abstract SyntaxNode? TryGetLastStatement(IBlockOperation? blockStatement);
34SyntaxEditor editor, SyntaxNode functionDeclaration, bool returnsVoid, SyntaxNode? statementToAddAfter, TStatementSyntax statement);
37SyntaxNode functionDeclaration,
45var functionBody = GetBody(functionDeclaration);
79public void InsertStatement(SyntaxEditor editor, SyntaxNode functionDeclaration, bool returnsVoid, SyntaxNode? statementToAddAfter, SyntaxNode statement)
90var parameterDeclaration = parameterReference.GetSyntax(cancellationToken);
92var functionDeclaration = parameterDeclaration.FirstAncestorOrSelf<SyntaxNode>(IsFunctionDeclaration);
115SyntaxNode functionDeclaration,
123var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
135SyntaxNode constructorDeclaration,
159var statementToAddAfter = TryGetStatementToAddInitializationAfter(parameter, blockStatement);
164private SyntaxNode? TryGetStatementToAddInitializationAfter(
195using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var accessors);
209foreach (var accessorBody in accessors)
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 canMove, bool mayChangeSemantics)> CanMoveDeclarationNearReferenceAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
46private async Task<State> ComputeStateAsync(Document document, SyntaxNode node, CancellationToken cancellationToken)
77Document document, SyntaxNode localDeclarationStatement, CancellationToken cancellationToken)
83var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
113var newRoot = editor.GetChangedRoot();
150var originalNextStatement = state.OutermostBlockStatements[statementIndex + 1];
186var blocks = state.InnermostBlock.GetAncestorsOrThis<SyntaxNode>();
187foreach (var block in blocks)
210var initializer = syntaxFacts.GetInitializerOfVariableDeclarator(state.VariableDeclarator);
217syntaxFacts.GetPartsOfAssignmentStatement(firstStatement, out var left, out var right);
242out 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);
112public abstract SyntaxNode IsPatternExpression(SyntaxNode expression, SyntaxToken isToken, SyntaxNode pattern);
114public abstract SyntaxNode AndPattern(SyntaxNode left, SyntaxNode right);
115public abstract SyntaxNode ConstantPattern(SyntaxNode expression);
116public abstract SyntaxNode DeclarationPattern(INamedTypeSymbol type, string name);
117public abstract SyntaxNode GreaterThanRelationalPattern(SyntaxNode expression);
118public abstract SyntaxNode GreaterThanEqualsRelationalPattern(SyntaxNode expression);
119public abstract SyntaxNode LessThanRelationalPattern(SyntaxNode expression);
120public abstract SyntaxNode LessThanEqualsRelationalPattern(SyntaxNode expression);
121public abstract SyntaxNode NotPattern(SyntaxNode pattern);
122public abstract SyntaxNode OrPattern(SyntaxNode left, SyntaxNode right);
123public abstract SyntaxNode ParenthesizedPattern(SyntaxNode pattern);
124public abstract SyntaxNode TypePattern(SyntaxNode type);
125public abstract SyntaxNode UnaryPattern(SyntaxToken operatorToken, SyntaxNode pattern);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Simplification\AbstractSimplificationService.cs (30)
30where TCompilationUnitSyntax : SyntaxNode
31where TExpressionSyntax : SyntaxNode
32where TStatementSyntax : SyntaxNode
33where TCrefSyntax : SyntaxNode
35protected static readonly Func<SyntaxNode, bool> s_containsAnnotations = n => n.ContainsAnnotations;
40protected abstract ImmutableArray<NodeOrTokenToReduce> GetNodesAndTokensToReduce(SyntaxNode root, Func<SyntaxNodeOrToken, bool> isNodeOrTokenOutsideSimplifySpans);
41protected abstract SemanticModel GetSpeculativeSemanticModel(ref SyntaxNode nodeToSpeculate, SemanticModel originalSemanticModel, SyntaxNode originalNode);
42protected abstract bool NodeRequiresNonSpeculativeSemanticModel(SyntaxNode node);
43protected abstract void AddImportDeclarations(TCompilationUnitSyntax root, ArrayBuilder<SyntaxNode> importDeclarations);
48protected virtual SyntaxNode TransformReducedNode(SyntaxNode reducedNode, SyntaxNode originalNode)
51public abstract SyntaxNode Expand(SyntaxNode node, SemanticModel semanticModel, SyntaxAnnotation? annotationForReplacedAliasIdentifier, Func<SyntaxNode, bool>? expandInsideNode, bool expandParameter, CancellationToken cancellationToken);
52public abstract SyntaxToken Expand(SyntaxToken token, SemanticModel semanticModel, Func<SyntaxNode, bool>? expandInsideNode, CancellationToken cancellationToken);
115var reducedNodesMap = new ConcurrentDictionary<SyntaxNode, SyntaxNode>();
152SyntaxNode root,
156ConcurrentDictionary<SyntaxNode, SyntaxNode> reducedNodesMap,
218var replacedParent = isNode
229var currentNode = currentNodeOrToken.AsNode()!;
234var newRoot = root.ReplaceNode(nodeOrToken.AsNode()!, currentNode.WithAdditionalAnnotations(marker));
277using var _ = ArrayBuilder<SyntaxNode>.GetInstance(out var importDeclarations);
292var root = await model.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
294var unusedImports = new HashSet<SyntaxNode>();
303var newRoot = gen.RemoveNodes(root, unusedImports);
312protected 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)