Completion\CompletionProviders\DeclarationName\DeclarationNameRecommender.NameGenerator.cs (7)
25using var parts = TemporaryArray<TextSpan>.Empty;
42using var breaks = TemporaryArray<TextSpan>.Empty;
49in TemporaryArray<TextSpan> breaks, string baseName, bool pluralize)
67private static Words GetLongestBackwardSubsequence(int length, in TemporaryArray<TextSpan> breaks, string baseName, bool pluralize)
74private static Words GetLongestForwardSubsequence(int length, in TemporaryArray<TextSpan> breaks, string baseName, bool pluralize)
77private static Words GetWords(int start, int end, in TemporaryArray<TextSpan> breaks, string baseName, bool pluralize)
83var @break = breaks[start];
CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs (16)
83private static ImmutableArray<TextSpan> AnalyzeCodeBlock(CodeBlockAnalysisContext context, int positionOfFirstReducingNullableDirective)
90private ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, int positionOfFirstReducingNullableDirective, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? possibleNullableImpactIntervalTree)
97possibleNullableImpactIntervalTree ??= new SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>(new TextSpanIntervalIntrospector(), values: null);
98foreach (var interval in simplifier.Spans)
148possibleNullableImpactIntervalTree ??= new SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>(new TextSpanIntervalIntrospector(), values: null);
177IntervalTree = SimpleIntervalTree.Create(new TextSpanIntervalIntrospector(), Array.Empty<TextSpan>());
178PossibleNullableImpactIntervalTree = SimpleIntervalTree.Create(new TextSpanIntervalIntrospector(), Array.Empty<TextSpan>());
185public SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? IntervalTree { get; }
186public SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? PossibleNullableImpactIntervalTree { get; }
218public bool TryProceedWithInterval(TextSpan span)
222public bool TryReportNullableImpactingSpans(TextSpan span, ImmutableArray<TextSpan> nullableImpactingSpans)
226private bool TryProceedOrReportNullableImpactingSpans(TextSpan span, ImmutableArray<TextSpan>? nullableImpactingSpans)
241foreach (var nullableImpactingSpan in spans)
EditAndContinue\BreakpointSpans.cs (30)
17public static bool TryGetBreakpointSpan(SyntaxTree tree, int position, CancellationToken cancellationToken, out TextSpan breakpointSpan)
63public static bool TryGetClosestBreakpointSpan(SyntaxNode root, int position, out TextSpan span)
82private static TextSpan CreateSpan(SyntaxToken startToken, SyntaxToken endToken)
83=> TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End);
85private static TextSpan CreateSpan(SyntaxNode node)
88private static TextSpan CreateSpan(SyntaxNode node, SyntaxToken token)
89=> TextSpan.FromBounds(node.SpanStart, token.Span.End);
91private static TextSpan CreateSpan(SyntaxToken token)
92=> TextSpan.FromBounds(token.SpanStart, token.Span.End);
94private static TextSpan CreateSpan(SyntaxTokenList startOpt, SyntaxNodeOrToken startFallbackOpt, SyntaxNodeOrToken endOpt)
122return TextSpan.FromBounds(startPos, endPos);
137private static TextSpan? TryCreateSpanForNode(SyntaxNode node, int position)
193TextSpan createSpanForSwitchArm(SwitchExpressionArmSyntax switchArm)
333private static TextSpan? CreateSpanForConstructorDeclaration(ConstructorDeclarationSyntax constructorSyntax, int position)
366private static TextSpan CreateSpanForConstructorInitializer(ConstructorInitializerSyntax constructorInitializer)
369private static TextSpan? TryCreateSpanForFieldDeclaration(BaseFieldDeclarationSyntax fieldDeclaration, int position)
372private static TextSpan? TryCreateSpanForSwitchLabel(SwitchLabelSyntax switchLabel, int position)
382private static TextSpan CreateSpanForBlock(BlockSyntax block, int position)
396private static TextSpan? TryCreateSpanForStatement(StatementSyntax statement, int position)
591private static TextSpan? TryCreateSpanForVariableDeclaration(VariableDeclarationSyntax declaration, int position)
600private static TextSpan? TryCreateSpanForVariableDeclaration(
614return default(TextSpan);
621return default(TextSpan);
635return default(TextSpan);
646private static TextSpan CreateSpanForVariableDeclarator(
716private static TextSpan CreateSpanForCatchClause(CatchClauseSyntax catchClause)
776private static TextSpan? CreateSpanForAccessors(SyntaxList<AccessorDeclarationSyntax> accessors, int position)
795internal static TextSpan GetEnvelope(SyntaxNode declaration)
816return TextSpan.FromBounds(firstSpan.Value.Start, constructorBody.Span.End);
821return TextSpan.FromBounds(unit.Members[0].SpanStart, unit.Members.OfType<GlobalStatementSyntax>().Last().Span.End);
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (44)
292internal override (TextSpan envelope, TextSpan hole) GetActiveSpanEnvelope(SyntaxNode declaration)
326protected override SyntaxNode FindStatementAndPartner(SyntaxNode declarationBody, TextSpan span, SyntaxNode? partnerDeclarationBody, out SyntaxNode? partner, out int statementPart)
478private static TextSpan GetActiveSpan(BlockSyntax node, BlockPart part)
492private static TextSpan GetActiveSpan(ForEachStatementSyntax node, ForEachPart part)
496ForEachPart.VariableDeclaration => TextSpan.FromBounds(node.Type.SpanStart, node.Identifier.Span.End),
502private static TextSpan GetActiveSpan(ForEachVariableStatementSyntax node, ForEachPart part)
506ForEachPart.VariableDeclaration => TextSpan.FromBounds(node.Variable.SpanStart, node.Variable.Span.End),
512private static TextSpan GetActiveSpan(SwitchExpressionSyntax node, SwitchExpressionPart part)
516SwitchExpressionPart.SwitchBody => TextSpan.FromBounds(node.SwitchKeyword.SpanStart, node.CloseBraceToken.Span.End),
789protected override TextSpan GetGlobalStatementDiagnosticSpan(SyntaxNode node)
845protected override bool TryGetEnclosingBreakpointSpan(SyntaxNode root, int position, out TextSpan span)
848protected override bool TryGetActiveSpan(SyntaxNode node, int statementPart, int minLength, out TextSpan span)
1585protected override TextSpan? TryGetDiagnosticSpan(SyntaxNode node, EditKind editKind)
1588internal static new TextSpan GetDiagnosticSpan(SyntaxNode node, EditKind editKind)
1591private static TextSpan? TryGetDiagnosticSpanImpl(SyntaxNode node, EditKind editKind)
1595internal static TextSpan? TryGetDiagnosticSpanImpl(SyntaxKind kind, SyntaxNode node, EditKind editKind)
1600return default(TextSpan);
1612return TextSpan.FromBounds(ns.NamespaceKeyword.SpanStart, ns.Name.Span.End);
1691return TextSpan.FromBounds(constraint.WhereKeyword.SpanStart, constraint.Constraints.Last().Span.End);
1734return TextSpan.FromBounds(usingStatement.UsingKeyword.SpanStart, usingStatement.CloseParenToken.Span.End);
1738return TextSpan.FromBounds(fixedStatement.FixedKeyword.SpanStart, fixedStatement.CloseParenToken.Span.End);
1742return TextSpan.FromBounds(lockStatement.LockKeyword.SpanStart, lockStatement.CloseParenToken.Span.End);
1765return TextSpan.FromBounds(ifStatement.IfKeyword.SpanStart, ifStatement.CloseParenToken.Span.End);
1772return TextSpan.FromBounds(switchStatement.SwitchKeyword.SpanStart,
1780return TextSpan.FromBounds(whileStatement.WhileKeyword.SpanStart, whileStatement.CloseParenToken.Span.End);
1787return TextSpan.FromBounds(forStatement.ForKeyword.SpanStart, forStatement.CloseParenToken.Span.End);
1792return TextSpan.FromBounds(
1904private static TextSpan GetDiagnosticSpan(SyntaxTokenList modifiers, SyntaxNodeOrToken start, SyntaxNodeOrToken end)
1905=> TextSpan.FromBounds((modifiers.Count != 0) ? modifiers.First().SpanStart : start.SpanStart, end.Span.End);
1907private static TextSpan CombineSpans(TextSpan first, TextSpan second, TextSpan defaultSpan)
1908=> (first.Length > 0 && second.Length > 0) ? TextSpan.FromBounds(first.Start, second.End) : (first.Length > 0) ? first : (second.Length > 0) ? second : defaultSpan;
1910internal override TextSpan GetLambdaParameterDiagnosticSpan(SyntaxNode lambda, int ordinal)
2249private readonly TextSpan? _span;
2258TextSpan? span = null)
2276var span = (spanNode != null) ? GetDiagnosticSpan(spanNode, _kind) : GetSpan();
2283private TextSpan GetSpan()
2469internal override void ReportMemberBodyUpdateRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newMember, TextSpan? span)
2598TextSpan newStatementSpan)
2645protected override TextSpan GetExceptionHandlingRegion(SyntaxNode node, out bool coversAllChildren)
2660return TextSpan.FromBounds(
ExtractMethod\CSharpSelectionValidator.cs (14)
29TextSpan textSpan,
63var controlFlowSpan = GetControlFlowSpan(selectionInfo);
158private static TextSpan GetControlFlowSpan(SelectionInfo selectionInfo)
159=> TextSpan.FromBounds(selectionInfo.FirstTokenInFinalSpan.SpanStart, selectionInfo.LastTokenInFinalSpan.Span.End);
205var adjustedSpan = GetAdjustedSpan(text, OriginalSpan);
367root, TextSpan.FromBounds(selectionInfo.FirstTokenInOriginalSpan.SpanStart, selectionInfo.LastTokenInOriginalSpan.Span.End),
416return selectionInfo.With(s => s.FinalSpan = GetAdjustedSpan(text, TextSpan.FromBounds(start, end)));
440SyntaxNode root, TextSpan textSpan,
493private static TextSpan GetAdjustedSpan(SourceText text, TextSpan textSpan)
516return TextSpan.FromBounds(textSpan.Start, previousLine.EndIncludingLineBreak);
519return TextSpan.FromBounds(textSpan.Start, previousLine.End);
526public TextSpan OriginalSpan { get; set; }
527public TextSpan FinalSpan { get; set; }
SignatureHelp\TupleConstructionSignatureHelpProvider.cs (3)
37private SignatureHelpState? GetCurrentArgumentState(SyntaxNode root, int position, ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken)
64ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken, [NotNullWhen(true)] out TupleExpressionSyntax? result)
83ISyntaxFactsService syntaxFacts, TextSpan currentSpan, CancellationToken cancellationToken, [NotNullWhen(true)] out ParenthesizedExpressionSyntax? result)
StringIndentation\CSharpStringIndentationService.cs (8)
31Document document, TextSpan textSpan, CancellationToken cancellationToken)
46TextSpan textSpan,
95if (!TryGetIndentSpan(text, (ExpressionSyntax)token.GetRequiredParent(), out _, out var indentSpan))
116if (!TryGetIndentSpan(text, interpolatedString, out var offset, out var indentSpan))
119using var _ = ArrayBuilder<TextSpan>.GetInstance(out var builder);
133private static bool IsInHole(InterpolatedStringExpressionSyntax interpolatedString, TextSpan sourceSpan)
165private static bool TryGetIndentSpan(SourceText text, ExpressionSyntax expression, out int offset, out TextSpan indentSpan)
186indentSpan = TextSpan.FromBounds(firstLine.Start, lastLine.Start + offset);
Structure\CSharpStructureHelpers.cs (15)
176var span = TextSpan.FromBounds(startComment.SpanStart, endComment.Span.End);
278textSpan: TextSpan.FromBounds(startPosition, endPosition),
279hintSpan: TextSpan.FromBounds(startPosition, hintTextEndToken.Span.End),
319TextSpan textSpan, string bannerText, bool autoCollapse,
327TextSpan textSpan, TextSpan hintSpan,
378var span = TextSpan.FromBounds(GetCollapsibleStart(startToken), spanEndPos);
379var hintSpan = GetHintSpan(node, hintEndPos);
391private static TextSpan GetHintSpan(SyntaxNode node, int endPos)
401return TextSpan.FromBounds(child.SpanStart, endPos);
405return TextSpan.FromBounds(node.SpanStart, endPos);
483textSpan: TextSpan.FromBounds(spanStart, spanEnd),
484hintSpan: TextSpan.FromBounds(hintSpanStart, hintSpanEnd),
CommentSelection\AbstractToggleBlockCommentBase.cs (39)
60protected abstract ImmutableArray<TextSpan> GetBlockCommentsInDocument(Document document, ITextSnapshot snapshot,
61TextSpan linesContainingSelections, CommentSelectionInfo commentInfo, CancellationToken cancellationToken);
101var linesContainingSelection = TextSpan.FromBounds(firstLineAroundSelection, lastLineAroundSelection);
135private static bool TryUncommentBlockComment(ImmutableArray<TextSpan> blockCommentedSpans,
141&& blockCommentSelection.TryGetBlockCommentOnSameLine(blockCommentedSpans, out var blockCommentOnSameLine))
151foreach (var spanToRemove in intersectingBlockComments)
156var trackingSpan = TextSpan.FromBounds(intersectingBlockComments.First().Start, intersectingBlockComments.Last().End);
177var spanToAdd = blockCommentSelection.SelectedSpan;
181spanToAdd = TextSpan.FromBounds(caretLocation, caretLocation);
208if (blockCommentSelection.IsSpanWhitespace(TextSpan.FromBounds(extent.Span.Start, extent.Span.End)))
223var selectedSpan = blockCommentSelection.SelectedSpan;
229foreach (var uncommentedSpan in blockCommentSelection.UncommentedSpansInSelection)
257private static void AddBlockComment(CommentSelectionInfo commentInfo, TextSpan span, ArrayBuilder<TextChange> textChanges)
263private static void DeleteBlockComment(BlockCommentSelectionHelper blockCommentSelection, TextSpan spanToRemove,
285public TextSpan SelectedSpan { get; }
287public ImmutableArray<TextSpan> IntersectingBlockComments { get; }
289public ImmutableArray<TextSpan> UncommentedSpansInSelection { get; }
291public BlockCommentSelectionHelper(ImmutableArray<TextSpan> allBlockComments, SnapshotSpan selectedSnapshotSpan)
296SelectedSpan = TextSpan.FromBounds(selectedSnapshotSpan.Start, selectedSnapshotSpan.End);
304public bool IsSpanWhitespace(TextSpan span)
363public bool TryGetBlockCommentOnSameLine(ImmutableArray<TextSpan> allBlockComments, out TextSpan commentedSpanOnSameLine)
367var lineStartToCaretIsWhitespace = IsSpanWhitespace(TextSpan.FromBounds(selectedLine.Start, SelectedSpan.Start));
368var caretToLineEndIsWhitespace = IsSpanWhitespace(TextSpan.FromBounds(SelectedSpan.Start, selectedLine.End));
369foreach (var blockComment in allBlockComments)
375if (IsSpanWhitespace(TextSpan.FromBounds(SelectedSpan.Start, blockComment.Start)))
385if (IsSpanWhitespace(TextSpan.FromBounds(blockComment.End, SelectedSpan.Start)))
401private static ImmutableArray<TextSpan> GetIntersectingBlockComments(ImmutableArray<TextSpan> allBlockComments, TextSpan span)
407private ImmutableArray<TextSpan> GetUncommentedSpansInSelection()
409var uncommentedSpans = new List<TextSpan>();
413foreach (var commentedSpan in IntersectingBlockComments)
418var possibleUncommentedSpan = TextSpan.FromBounds(spanStart, commentedSpan.Start);
432var uncommentedSpan = TextSpan.FromBounds(spanStart, SelectedSpan.End);
Navigation\IDocumentNavigationServiceExtensions.cs (3)
30this IDocumentNavigationService service, IThreadingContext threadingContext, Workspace workspace, DocumentId documentId, TextSpan textSpan, NavigationOptions options, bool allowInvalidSpan, CancellationToken cancellationToken)
37this IDocumentNavigationService service, IThreadingContext threadingContext, Workspace workspace, DocumentId documentId, TextSpan textSpan, NavigationOptions options, CancellationToken cancellationToken)
44this IDocumentNavigationService service, IThreadingContext threadingContext, Workspace workspace, DocumentId documentId, TextSpan textSpan, CancellationToken cancellationToken)
AbstractConflictMarkerCodeFixProvider.cs (8)
320edits.Add(new TextChange(TextSpan.FromBounds(startPos, startEnd), ""));
324edits.Add(new TextChange(TextSpan.FromBounds(firstMiddlePos, bottomEnd), ""));
333edits.Add(new TextChange(TextSpan.FromBounds(startPos, equalsEnd), ""));
337edits.Add(new TextChange(TextSpan.FromBounds(endPos, bottomEnd), ""));
346edits.Add(new TextChange(TextSpan.FromBounds(startPos, startEnd), ""));
352edits.Add(new TextChange(TextSpan.FromBounds(secondMiddlePos, equalsEnd), ""));
358edits.Add(new TextChange(TextSpan.FromBounds(firstMiddlePos, equalsEnd), ""));
363edits.Add(new TextChange(TextSpan.FromBounds(endPos, bottomEnd), ""));
AddImport\AbstractAddImportFeatureService.cs (5)
58Document document, TextSpan span, string diagnosticId, int maxResults,
82Document document, TextSpan span, string diagnosticId, int maxResults,
486Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, int maxResultsPerDiagnostic,
509Document document, TextSpan span, ImmutableArray<string> diagnosticIds,
534TextSpan span,
AddImport\IAddImportFeatureService.cs (4)
31Document document, TextSpan span, string diagnosticId, int maxResults,
40Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, int maxResultsPerDiagnostic,
54/// Similar to <see cref="GetFixesAsync(Document, TextSpan, string, int, ISymbolSearchService, AddImportOptions, ImmutableArray{PackageSource}, CancellationToken)"/>
58Document document, TextSpan span, ImmutableArray<string> diagnosticIds,
AddImport\Remote\IRemoteMissingImportDiscoveryService.cs (2)
27Checksum solutionChecksum, RemoteServiceCallbackId callbackId, DocumentId documentId, TextSpan span, string diagnosticId, int maxResults,
31Checksum solutionChecksum, RemoteServiceCallbackId callbackId, DocumentId id, TextSpan span, ImmutableArray<string> diagnosticIds,
ClassifiedSpansAndHighlightSpanFactory.cs (14)
19Document document, TextSpan sourceSpan, ClassificationOptions options, CancellationToken cancellationToken)
47Document document, TextSpan sourceSpan, ClassificationOptions options, CancellationToken cancellationToken)
51var narrowSpan = sourceSpan;
52var lineSpan = GetLineSpanForReference(sourceText, narrowSpan);
59private static TextSpan GetLineSpanForReference(SourceText sourceText, TextSpan referenceSpan)
68return TextSpan.FromBounds(Math.Min(firstNonWhitespacePosition, referenceSpan.Start), sourceLine.End);
72Document document, TextSpan narrowSpan, TextSpan widenedSpan, ClassificationOptions options, CancellationToken cancellationToken)
74var highlightSpan = new TextSpan(
84Document document, TextSpan narrowSpan, TextSpan widenedSpan, ClassificationOptions options, CancellationToken cancellationToken)
97new ClassifiedSpan(ClassificationTypeNames.Text, TextSpan.FromBounds(widenedSpan.Start, narrowSpan.Start)),
99new ClassifiedSpan(ClassificationTypeNames.Text, TextSpan.FromBounds(narrowSpan.End, widenedSpan.End)));
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (6)
142TextDocument textDocument, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
150internal async Task<ImmutableArray<PragmaWarningCodeAction>> GetPragmaSuppressionsAsync(Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, CancellationToken cancellationToken)
159Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CodeActionOptionsProvider fallbackOptions, bool skipSuppressMessage, bool skipUnsuppress, CancellationToken cancellationToken)
265private async Task<SuppressionTargetInfo> GetSuppressionTargetInfoAsync(Document document, TextSpan span, CancellationToken cancellationToken)
322TextSpan? minContainingSpan = null;
325var declSpan = decl.DeclaredNode.Span;
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaHelpers.cs (6)
26TextSpan diagnosticSpan,
28Func<SyntaxToken, TextSpan, SyntaxToken> getNewStartToken,
29Func<SyntaxToken, TextSpan, SyntaxToken> getNewEndToken,
65private static int GetPositionForPragmaInsertion(ImmutableArray<SyntaxTrivia> triviaList, TextSpan currentDiagnosticSpan, AbstractSuppressionCodeFixProvider fixer, bool isStartToken, out SyntaxTrivia triviaAtIndex)
104TextSpan currentDiagnosticSpan,
156TextSpan currentDiagnosticSpan,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (6)
87SyntaxToken getNewStartToken(SyntaxToken startToken, TextSpan currentDiagnosticSpan) => includeStartTokenChange
91SyntaxToken getNewEndToken(SyntaxToken endToken, TextSpan currentDiagnosticSpan) => includeEndTokenChange
124var diagnosticSpan = diagnostic.Location.SourceSpan;
158private SyntaxToken GetNewTokenWithModifiedPragma(SyntaxToken token, TextSpan currentDiagnosticSpan, bool add, bool toggle, int indexOfTriviaToRemoveOrToggle, bool isStartToken, CancellationToken cancellationToken)
165private SyntaxToken GetNewTokenWithAddedPragma(SyntaxToken token, TextSpan currentDiagnosticSpan, bool isStartToken, CancellationToken cancellationToken)
208var spanToCheck = new TextSpan(
CodeLens\IRemoteCodeLensReferencesService.cs (4)
17ValueTask<ReferenceCount?> GetReferenceCountAsync(Checksum solutionChecksum, DocumentId documentId, TextSpan textSpan, int maxResultCount, CancellationToken cancellationToken);
18ValueTask<ImmutableArray<ReferenceLocationDescriptor>?> FindReferenceLocationsAsync(Checksum solutionChecksum, DocumentId documentId, TextSpan textSpan, CancellationToken cancellationToken);
19ValueTask<ImmutableArray<ReferenceMethodDescriptor>?> FindReferenceMethodsAsync(Checksum solutionChecksum, DocumentId documentId, TextSpan textSpan, CancellationToken cancellationToken);
20ValueTask<string> GetFullyQualifiedNameAsync(Checksum solutionChecksum, DocumentId documentId, TextSpan textSpan, CancellationToken cancellationToken);
CodeRefactorings\AbstractRefactoringHelpersService.cs (6)
29Document document, TextSpan selectionRaw, bool allowEmptyNodes, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
49Document document, TextSpan selectionRaw, ArrayBuilder<TSyntaxNode> relevantNodes, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
60var selectionTrimmed = await CodeRefactoringHelpers.GetTrimmedTextSpanAsync(document, selectionRaw, cancellationToken).ConfigureAwait(false);
337var rightNodeSpanWithoutAttributes = syntaxFacts.GetSpanWithoutAttributes(root, rightNode);
349TextSpan selectionTrimmed,
365var spanWithoutAttributes = syntaxFacts.GetSpanWithoutAttributes(root, nonHiddenExtractedNode);
CodeRefactorings\AddMissingImports\AbstractAddMissingImportsFeatureService.cs (5)
32public async Task<Document> AddMissingImportsAsync(Document document, TextSpan textSpan, AddMissingImportsOptions options, CancellationToken cancellationToken)
52public async Task<AddMissingImportsAnalysisResult> AnalyzeAsync(Document document, TextSpan textSpan, AddMissingImportsOptions options, CancellationToken cancellationToken)
147private async Task<Document> CleanUpNewLinesAsync(Document document, IEnumerable<TextSpan> insertSpans, SyntaxFormattingOptions formattingOptions, CancellationToken cancellationToken)
154foreach (var insertSpan in insertSpans)
162private async Task<Document> CleanUpNewLinesAsync(Document document, TextSpan insertSpan, SyntaxFormattingOptions options, CancellationToken cancellationToken)
CodeRefactorings\CodeRefactoringContextExtensions.cs (5)
22this CodeRefactoringContext context, ImmutableArray<TCodeAction> actions, TextSpan? applicableToSpan = null)
53public static Task<TSyntaxNode?> TryGetRelevantNodeAsync<TSyntaxNode>(this Document document, TextSpan span, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
56public static async Task<TSyntaxNode?> TryGetRelevantNodeAsync<TSyntaxNode>(this Document document, TextSpan span, bool allowEmptyNode, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
63this Document document, TextSpan span, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
67this Document document, TextSpan span, bool allowEmptyNodes, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
CodeRefactorings\ICodeRefactoringService.cs (3)
16Task<bool> HasRefactoringsAsync(TextDocument document, TextSpan textSpan, CodeActionOptionsProvider options, CancellationToken cancellationToken);
18Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(TextDocument document, TextSpan textSpan, CodeActionRequestPriority priority, CodeActionOptionsProvider options, bool isBlocking, Func<string, IDisposable?> addOperationScope, CancellationToken cancellationToken);
23public static Task<ImmutableArray<CodeRefactoring>> GetRefactoringsAsync(this ICodeRefactoringService service, TextDocument document, TextSpan state, CodeActionOptionsProvider options, bool isBlocking, CancellationToken cancellationToken)
CodeRefactorings\MoveType\AbstractMoveTypeService.cs (6)
33public abstract Task<Solution> GetModifiedSolutionAsync(Document document, TextSpan textSpan, MoveTypeOperationKind operationKind, CodeCleanupOptionsProvider fallbackOptions, CancellationToken cancellationToken);
34public abstract Task<ImmutableArray<CodeAction>> GetRefactoringAsync(Document document, TextSpan textSpan, CodeCleanupOptionsProvider fallbackOptions, CancellationToken cancellationToken);
46Document document, TextSpan textSpan, CodeCleanupOptionsProvider fallbackOptions, CancellationToken cancellationToken)
59public override async Task<Solution> GetModifiedSolutionAsync(Document document, TextSpan textSpan, MoveTypeOperationKind operationKind, CodeCleanupOptionsProvider fallbackOptions, CancellationToken cancellationToken)
81protected abstract Task<TTypeDeclarationSyntax> GetRelevantNodeAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken);
83private async Task<State> CreateStateAsync(Document document, TextSpan textSpan, CodeCleanupOptionsProvider fallbackOptions, CancellationToken cancellationToken)
CodeRefactorings\SyncNamespace\AbstractSyncNamespaceCodeRefactoringProvider.State.cs (1)
69TextSpan textSpan,
Completion\Providers\AbstractPartialMethodCompletionProvider.cs (3)
83Document document, int position, TextSpan span, DeclarationModifiers modifiers, SyntaxToken token, CancellationToken cancellationToken)
100var lineSpan = text.Lines.GetLineFromPosition(position).Span;
104private CompletionItem CreateItem(IMethodSymbol method, int line, TextSpan span, SemanticModel semanticModel, DeclarationModifiers modifiers, SyntaxToken token)
ConvertTupleToStruct\AbstractConvertTupleToStructCodeRefactoringProvider.cs (6)
121TextSpan span,
172private CodeAction CreateAction(Document document, TextSpan span, Scope scope, CleanCodeGenerationOptionsProvider fallbackOptions, bool isRecord)
186Document document, TextSpan span, CancellationToken cancellationToken)
208Document document, TextSpan span, Scope scope, CleanCodeGenerationOptionsProvider fallbackOptions, bool isRecord, CancellationToken cancellationToken)
243(DocumentId documentId, TextSpan span) renamedToken,
255Document document, TextSpan span, Scope scope, CleanCodeGenerationOptionsProvider fallbackOptions, bool isRecord, CancellationToken cancellationToken)
Diagnostics\IDiagnosticAnalyzerService.cs (5)
77/// Use <see cref="GetDiagnosticsForSpanAsync(TextDocument, TextSpan?, Func{string, bool}?, bool, bool, CodeActionRequestPriority, Func{string, IDisposable?}?, DiagnosticKind, CancellationToken)"/>
81TextDocument document, TextSpan range, Func<string, bool>? shouldIncludeDiagnostic,
96TextDocument document, TextSpan? range, Func<string, bool>? shouldIncludeDiagnostic,
107TextDocument document, TextSpan range, string? diagnosticId = null,
122TextDocument document, TextSpan? range, string? diagnosticId = null,
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (52)
149internal abstract (TextSpan envelope, TextSpan hole) GetActiveSpanEnvelope(SyntaxNode declaration);
179protected abstract SyntaxNode FindStatementAndPartner(SyntaxNode declarationBody, TextSpan span, SyntaxNode? partnerDeclarationBody, out SyntaxNode? partner, out int statementPart);
181private SyntaxNode FindStatement(SyntaxNode declarationBody, TextSpan span, out int statementPart)
224protected abstract bool TryGetEnclosingBreakpointSpan(SyntaxNode root, int position, out TextSpan span);
232protected abstract bool TryGetActiveSpan(SyntaxNode node, int statementPart, int minLength, out TextSpan span);
263protected abstract TextSpan GetGlobalStatementDiagnosticSpan(SyntaxNode node);
297protected abstract TextSpan? TryGetDiagnosticSpan(SyntaxNode node, EditKind editKind);
299internal TextSpan GetDiagnosticSpan(SyntaxNode node, EditKind editKind)
302protected virtual TextSpan GetBodyDiagnosticSpan(SyntaxNode node, EditKind editKind)
322internal abstract TextSpan GetLambdaParameterDiagnosticSpan(SyntaxNode lambda, int ordinal);
412protected abstract TextSpan GetExceptionHandlingRegion(SyntaxNode node, out bool coversAllChildren);
415internal abstract void ReportEnclosingExceptionHandlingRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, IEnumerable<Edit<SyntaxNode>> exceptionHandlingEdits, SyntaxNode oldStatement, TextSpan newStatementSpan);
417internal abstract void ReportMemberBodyUpdateRudeEdits(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newMember, TextSpan? span);
620using var _3 = ArrayBuilder<(SyntaxNode OldNode, SyntaxNode NewNode, TextSpan DiagnosticSpan)>.GetInstance(out var triviaEdits);
710lineText = text.ToString(TextSpan.FromBounds(diagnostic.Span.Start, Math.Min(diagnostic.Span.Start + 120, line.End)));
815var oldStatementSpan = oldActiveStatements[i].UnmappedSpan;
876var newStatementSpan = FindClosestActiveSpan(newStatement, statementPart);
973var newSpan = FindClosestActiveSpan(newDeclaration, DefaultStatementPart);
1008var oldStatementSpan = oldActiveStatements[activeStatementIndex].UnmappedSpan;
1113TextSpan newSpan;
1239var bodySpan = GetBodyDiagnosticSpan(newBody, EditKind.Update);
1280var trackedSpan = text.Lines.GetTextSpan(trackedLineSpan);
1296private ActiveStatement GetActiveStatementWithSpan(UnmappedActiveStatement oldStatement, SyntaxTree newTree, TextSpan newSpan, ArrayBuilder<RudeEditDiagnostic> diagnostics, CancellationToken cancellationToken)
1316TextSpan newStatementSyntaxSpan,
1570public ActiveStatementExceptionRegions GetExceptionRegions(SyntaxNode syntaxRoot, TextSpan unmappedActiveStatementSpan, bool isNonLeaf, CancellationToken cancellationToken)
1589var span = GetExceptionHandlingRegion(exceptionHandlingAncestors[i], out var coversAllChildren);
1608private TextSpan GetDeletedNodeDiagnosticSpan(SyntaxNode deletedLambdaBody, Match<SyntaxNode> match, Dictionary<SyntaxNode, LambdaInfo> lambdaInfos)
1628private TextSpan FindClosestActiveSpan(SyntaxNode statement, int statementPart)
1630if (TryGetActiveSpan(statement, statementPart, minLength: statement.Span.Length, out var span))
1655internal TextSpan GetDeletedNodeActiveSpan(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode deletedNode)
1673internal TextSpan GetDeletedNodeDiagnosticSpan(IReadOnlyDictionary<SyntaxNode, SyntaxNode> forwardMap, SyntaxNode deletedNode)
1756protected void AddAroundActiveStatementRudeDiagnostic(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode? oldNode, SyntaxNode? newNode, TextSpan newActiveStatementSpan)
1792protected void AddRudeDeleteAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode oldNode, TextSpan newActiveStatementSpan)
1981[Out] ArrayBuilder<(SyntaxNode OldNode, SyntaxNode NewNode, TextSpan DiagnosticSpan)> triviaEdits,
2034var rudeEditSpan = default(TextSpan);
2047if (!TryGetEnclosingBreakpointSpan(oldNode, oldNode.SpanStart, out var oldBreakpointSpan) ||
2048!TryGetEnclosingBreakpointSpan(newNode, newNode.SpanStart, out var newBreakpointSpan))
2100var oldSpan = oldTokensEnum.Current.Span;
2101var newSpan = newTokensEnum.Current.Span;
2156rudeEditSpan = TextSpan.FromBounds(
2407IReadOnlyList<(SyntaxNode OldNode, SyntaxNode NewNode, TextSpan DiagnosticSpan)> triviaEdits,
2615var newSpan = IsDeclarationWithInitializer(oldDeclaration)
2693var diagnosticSpan = GetDeletedNodeDiagnosticSpan(editScript.Match.Matches, oldDeclaration);
4605var span = (rudeEdit == RudeEditKind.ChangeImplicitMainReturnType) ? GetGlobalStatementDiagnosticSpan(node) : GetDiagnosticSpan(node, EditKind.Update);
4968var firstSpan = updatesInCurrentDocument.ChangedDeclarations.Keys.Where(IsDeclarationWithInitializer).Aggregate(
4969(min: int.MaxValue, span: default(TextSpan)),
5444TextSpan errorSpan;
5516private static TextSpan GetThisParameterDiagnosticSpan(ISymbol member)
5519private static TextSpan GetVariableDiagnosticSpan(ISymbol local)
5769TextSpan span;
EmbeddedLanguages\Classification\AbstractEmbeddedLanguageClassificationService.cs (4)
38Document document, TextSpan textSpan, ClassificationOptions options, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken)
45Project? project, SemanticModel semanticModel, TextSpan textSpan, ClassificationOptions options, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken)
60private readonly TextSpan _textSpan;
69TextSpan textSpan,
EmbeddedLanguages\RegularExpressions\RegexParser.CaptureInfoAnalyzer.cs (12)
32private readonly ImmutableDictionary<int, TextSpan>.Builder _captureNumberToSpan;
33private readonly ImmutableDictionary<string, TextSpan>.Builder _captureNameToSpan;
41_captureNumberToSpan = ImmutableDictionary.CreateBuilder<int, TextSpan>();
42_captureNameToSpan = ImmutableDictionary.CreateBuilder<string, TextSpan>();
50public static (ImmutableDictionary<string, TextSpan>, ImmutableDictionary<int, TextSpan>) Analyze(
57private (ImmutableDictionary<string, TextSpan>, ImmutableDictionary<int, TextSpan>) Analyze(
139private readonly TextSpan GetGroupingSpan(RegexGroupingNode grouping)
181private readonly void RecordCapture(RegexToken token, TextSpan span)
197ImmutableDictionary<T, TextSpan>.Builder mapping,
199T val, TextSpan span)
EncapsulateField\AbstractEncapsulateFieldService.cs (7)
35protected abstract Task<ImmutableArray<IFieldSymbol>> GetFieldsAsync(Document document, TextSpan span, CancellationToken cancellationToken);
37public async Task<EncapsulateFieldResult> EncapsulateFieldsInSpanAsync(Document document, TextSpan span, CleanCodeGenerationOptionsProvider fallbackOptions, bool useDefaultBehavior, CancellationToken cancellationToken)
50public async Task<ImmutableArray<CodeAction>> GetEncapsulateFieldCodeActionsAsync(Document document, TextSpan span, CleanCodeGenerationOptionsProvider fallbackOptions, CancellationToken cancellationToken)
304Func<DocumentId, TextSpan, bool> filter,
325private static bool IntersectsWithAny(DocumentId documentId, TextSpan span, ISet<(DocumentId documentId, TextSpan span)> constructorLocations)
339private ISet<(DocumentId documentId, TextSpan span)> GetConstructorLocations(Solution solution, INamedTypeSymbol containingType)
ExtractMethod\SelectionValidator.cs (6)
26protected readonly TextSpan OriginalSpan;
31TextSpan textSpan,
51public abstract bool IsFinalSpanSemanticallyValidSpan(SyntaxNode node, TextSpan textSpan, IEnumerable<SyntaxNode> returnStatements, CancellationToken cancellationToken);
55SemanticModel semanticModel, TextSpan textSpan, Tuple<SyntaxNode, SyntaxNode> range, CancellationToken cancellationToken)
103SyntaxNode root, TextSpan textSpan, CancellationToken cancellationToken) where T : SyntaxNode
163SyntaxNode root, TextSpan textSpan, CancellationToken cancellationToken) where T : SyntaxNode
FormatterHelper.cs (4)
35public static SyntaxNode Format(SyntaxNode node, TextSpan spanToFormat, ISyntaxFormatting syntaxFormattingService, SyntaxFormattingOptions options, CancellationToken cancellationToken)
49internal static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan> spans, ISyntaxFormatting syntaxFormattingService, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
52internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan> spans, ISyntaxFormatting syntaxFormattingService, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
55internal static IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan> spans, ISyntaxFormatting syntaxFormattingService, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
GenerateConstructorFromMembers\AbstractGenerateConstructorFromMembersCodeRefactoringProvider.cs (6)
76public async Task<ImmutableArray<IntentProcessorResult>> ComputeIntentAsync(Document priorDocument, TextSpan priorSelection, Document currentDocument, IntentDataProvider intentDataProvider, CancellationToken cancellationToken)
148TextSpan textSpan,
149Action<CodeAction, TextSpan> registerSingleAction,
177private async Task<(CodeAction CodeAction, TextSpan ApplicableToSpan)?> HandleNonSelectionAsync(
179TextSpan textSpan,
249Document document, TextSpan textSpan, bool addNullChecks, Accessibility? desiredAccessibility, CleanCodeGenerationOptionsProvider fallbackOptions, CancellationToken cancellationToken)
GenerateEqualsAndGetHashCodeFromMembers\GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs (1)
171TextSpan textSpan,
Highlighting\Keywords\AbstractKeywordHighlighter.cs (9)
18protected sealed override void AddHighlightsForNode(SyntaxNode node, List<TextSpan> highlights, CancellationToken cancellationToken)
21protected abstract void AddHighlights(TNode node, List<TextSpan> highlights, CancellationToken cancellationToken);
26private static readonly ObjectPool<List<TextSpan>> s_textSpanListPool = new(() => new List<TextSpan>());
32SyntaxNode root, int position, List<TextSpan> highlights, CancellationToken cancellationToken)
59private static bool AnyIntersects(int position, List<TextSpan> highlights)
61foreach (var highlight in highlights)
72protected abstract void AddHighlightsForNode(SyntaxNode node, List<TextSpan> highlights, CancellationToken cancellationToken);
74protected static TextSpan EmptySpan(int position)
Navigation\IDocumentNavigationService.cs (4)
19Task<bool> CanNavigateToSpanAsync(Workspace workspace, DocumentId documentId, TextSpan textSpan, bool allowInvalidSpan, CancellationToken cancellationToken);
31Task<INavigableLocation?> GetLocationForSpanAsync(Workspace workspace, DocumentId documentId, TextSpan textSpan, bool allowInvalidSpan, CancellationToken cancellationToken);
38public static Task<bool> CanNavigateToSpanAsync(this IDocumentNavigationService service, Workspace workspace, DocumentId documentId, TextSpan textSpan, CancellationToken cancellationToken)
44public static Task<INavigableLocation?> GetLocationForSpanAsync(this IDocumentNavigationService service, Workspace workspace, DocumentId documentId, TextSpan textSpan, CancellationToken cancellationToken)
ReplaceDocCommentTextWithTag\AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs (8)
42var singleWordSpan = ExpandSpan(sourceText, span, fullyQualifiedName: false);
64var fullyQualifiedSpan = ExpandSpan(sourceText, span, fullyQualifiedName: true);
111CodeRefactoringContext context, SemanticModel semanticModel, SyntaxToken token, TextSpan replacementSpan, CancellationToken cancellationToken)
142CodeRefactoringContext context, TextSpan expandedSpan, string replacement)
153Document document, TextSpan span, string replacement, CancellationToken cancellationToken)
161private static TextSpan ExpandSpan(SourceText sourceText, TextSpan span, bool fullyQualifiedName)
182return TextSpan.FromBounds(startInclusive, endExclusive);
SimplifyTypeNames\AbstractSimplifyTypeNamesCodeFixProvider.cs (4)
45SyntaxNode root, SemanticModel model, TextSpan span,
78var span = context.Span;
124private bool CanSimplifyTypeNameExpression(SemanticModel model, SyntaxNode node, TSimplifierOptions options, TextSpan span, out string diagnosticId, CancellationToken cancellationToken)
129model, node, options, out var issueSpan, out diagnosticId, out _, cancellationToken))
SimplifyTypeNamesDiagnosticAnalyzerBase.cs (9)
76out TextSpan issueSpan, out string diagnosticId, out bool inDeclaration,
111protected abstract ImmutableArray<Diagnostic> AnalyzeSemanticModel(SemanticModelAnalysisContext context, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? codeBlockIntervalTree);
117out var issueSpan, out var diagnosticId, out var inDeclaration,
134internal static Diagnostic CreateDiagnostic(SemanticModel model, TSimplifierOptions options, TextSpan issueSpan, string diagnosticId, bool inDeclaration)
205/// indicate that <c>intervalTree</c> may be updated by adding a new non-overlapping <see cref="TextSpan"/>
221private readonly ConcurrentDictionary<SyntaxTree, (StrongBox<bool> completed, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector>? intervalTree)> _codeBlockIntervals
232var (completed, intervalTree) = _codeBlockIntervals.GetOrAdd(context.CodeBlock.SyntaxTree, _ => (new StrongBox<bool>(false), SimpleIntervalTree.Create(new TextSpanIntervalIntrospector(), Array.Empty<TextSpan>())));
251static bool TryProceedWithInterval(bool addIfAvailable, TextSpan span, StrongBox<bool> completed, SimpleIntervalTree<TextSpan, TextSpanIntervalIntrospector> intervalTree)
Snippets\SnippetFunctionService.cs (9)
38public static async Task<string?> GetSimplifiedTypeNameAsync(Document document, TextSpan fieldSpan, string fullyQualifiedTypeName, SimplifierOptions simplifierOptions, CancellationToken cancellationToken)
41var updatedTextSpan = new TextSpan(fieldSpan.Start, fullyQualifiedTypeName.Length);
56public async Task<string?> GetSwitchExpansionAsync(Document document, TextSpan caseGenerationLocation, TextSpan switchExpressionLocation, SimplifierOptions simplifierOptions, CancellationToken cancellationToken)
120protected abstract Task<ITypeSymbol?> GetEnumSymbolAsync(Document document, TextSpan switchExpressionSpan, CancellationToken cancellationToken);
122protected abstract Task<(Document, TextSpan)> GetDocumentWithEnumCaseAsync(Document document, string fullyQualifiedTypeName, string firstEnumMemberName, TextSpan caseGenerationLocation, CancellationToken cancellationToken);
128TextSpan caseGenerationLocation,
140private static async Task<string?> GetSimplifiedTypeNameAtSpanAsync(Document documentWithFullyQualifiedTypeName, TextSpan fullyQualifiedTypeSpan, SimplifierOptions simplifierOptions, CancellationToken cancellationToken)
Structure\BlockSpan.cs (9)
23public TextSpan TextSpan { get; }
28public TextSpan HintSpan { get; }
51string type, bool isCollapsible, TextSpan textSpan, string bannerText = Ellipses, bool autoCollapse = false, bool isDefaultCollapsed = false)
57string type, bool isCollapsible, TextSpan textSpan, TextSpan hintSpan, string bannerText = Ellipses, bool autoCollapse = false, bool isDefaultCollapsed = false)
83Optional<TextSpan> textSpan = default,
84Optional<TextSpan> hintSpan = default,
91var newTextSpan = textSpan.HasValue ? textSpan.Value : TextSpan;
92var newHintSpan = hintSpan.HasValue ? hintSpan.Value : HintSpan;
EditAndContinue\BreakpointSpans.vb (28)
13Friend Function TryGetBreakpointSpan(tree As SyntaxTree, position As Integer, cancellationToken As CancellationToken, <Out> ByRef breakpointSpan As TextSpan) As Boolean
58Public Function TryGetEnclosingBreakpointSpan(root As SyntaxNode, position As Integer, minLength As Integer, <Out> ByRef span As TextSpan) As Boolean
61Dim candidate As TextSpan? = Nothing
91Private Function CreateSpan(node As SyntaxNode) As TextSpan
92Return TextSpan.FromBounds(node.SpanStart, node.Span.End)
95Private Function TryCreateSpan(Of TNode As SyntaxNode)(list As SeparatedSyntaxList(Of TNode)) As TextSpan?
100Return TextSpan.FromBounds(list.First.SpanStart, list.Last.Span.End)
103Private Function TryCreateSpanForNode(node As SyntaxNode, position As Integer) As TextSpan?
174Return TextSpan.FromBounds(asSingleLine.IfKeyword.SpanStart, asSingleLine.ThenKeyword.Span.End)
235Private Function CreateSpanForMethodBase(methodBase As MethodBaseSyntax) As TextSpan
237Return TextSpan.FromBounds(methodBase.DeclarationKeyword.SpanStart, methodBase.Span.End)
240Return TextSpan.FromBounds(methodBase.Modifiers.First().SpanStart, methodBase.Span.End)
243Private Function TryCreateSpanForPropertyStatement(node As PropertyStatementSyntax) As TextSpan?
250Return TextSpan.FromBounds(node.Identifier.Span.Start, node.Initializer.Span.End)
254Return TextSpan.FromBounds(node.Identifier.Span.Start, node.AsClause.Span.End)
260Private Function TryCreateSpanForVariableDeclaration(modifiers As SyntaxTokenList, declarators As SeparatedSyntaxList(Of VariableDeclaratorSyntax), position As Integer) As TextSpan?
334Private Function TryCreateSpanForFromClause(fromClause As FromClauseSyntax, position As Integer) As TextSpan?
352Private Function TryCreateSpanForFunctionAggregation(functionAggregation As FunctionAggregationSyntax) As TextSpan?
360Private Function TryCreateSpanForOrderByClause(orderByClause As OrderByClauseSyntax, position As Integer) As TextSpan?
368Private Function TryCreateSpanForOrderingSyntax(orderingSyntax As OrderingSyntax) As TextSpan?
372Private Function TryCreateSpanForPartitionWhileClauseSyntax(partitionWhileClause As PartitionWhileClauseSyntax) As TextSpan?
376Private Function TryCreateSpanForCollectionRangeVariable(collectionRangeVariable As CollectionRangeVariableSyntax) As TextSpan?
392Private Function TryCreateSpanForWhereClause(clause As WhereClauseSyntax) As TextSpan?
396Private Function TryCreateSpanForGroupByClause(clause As GroupByClauseSyntax, position As Integer) As TextSpan?
417Return TextSpan.FromBounds(clause.Keys.First.SpanStart, clause.Span.End)
420Private Function TryCreateSpanForSelectClause(clause As SelectClauseSyntax) As TextSpan?
428Private Function TryCreateSpanForLetClause(clause As LetClauseSyntax, position As Integer) As TextSpan?
432Private Function TryCreateSpanForExpression(expression As ExpressionSyntax) As TextSpan?
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (38)
378Friend Overrides Function GetActiveSpanEnvelope(declaration As SyntaxNode) As (envelope As TextSpan, hole As TextSpan)
397Return (TextSpan.FromBounds(propertyStatement.Identifier.Span.Start, propertyStatement.Initializer.Span.End), Nothing)
401Return (TextSpan.FromBounds(propertyStatement.Identifier.Span.Start, propertyStatement.AsClause.Span.End), Nothing)
445Return (envelope:=TextSpan.FromBounds(declaration.Span.Start, asNewClause.NewExpression.Span.End),
446hole:=TextSpan.FromBounds(declaration.Span.End, asNewClause.NewExpression.Span.Start))
495span As TextSpan,
818Protected Overrides Function GetGlobalStatementDiagnosticSpan(node As SyntaxNode) As TextSpan
892Protected Overrides Function TryGetEnclosingBreakpointSpan(root As SyntaxNode, position As Integer, <Out> ByRef span As TextSpan) As Boolean
896Protected Overrides Function TryGetActiveSpan(node As SyntaxNode, statementPart As Integer, minLength As Integer, <Out> ByRef span As TextSpan) As Boolean
1499Protected Overrides Function TryGetDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan?
1503Protected Overloads Shared Function GetDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan
1507Private Shared Function TryGetDiagnosticSpanImpl(node As SyntaxNode, editKind As EditKind) As TextSpan?
1511Protected Overrides Function GetBodyDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan
1516Friend Shared Function TryGetDiagnosticSpanImpl(kind As SyntaxKind, node As SyntaxNode, editKind As EditKind) As TextSpan?
1680Return TextSpan.FromBounds(newWith.NewKeyword.Span.Start,
1712Return TextSpan.FromBounds(groupJoin.GroupKeyword.SpanStart, groupJoin.JoinKeyword.Span.End)
1727Return TextSpan.FromBounds(partition.SkipOrTakeKeyword.SpanStart, partition.WhileKeyword.Span.End)
1741Private Overloads Shared Function GetDiagnosticSpan(ifKeyword As SyntaxToken, condition As SyntaxNode, thenKeywordOpt As SyntaxToken) As TextSpan
1742Return TextSpan.FromBounds(ifKeyword.Span.Start,
1746Private Overloads Shared Function GetDiagnosticSpan(node As NamespaceStatementSyntax) As TextSpan
1747Return TextSpan.FromBounds(node.NamespaceKeyword.SpanStart, node.Name.Span.End)
1750Private Overloads Shared Function GetDiagnosticSpan(node As TypeStatementSyntax) As TextSpan
1756Private Overloads Shared Function GetDiagnosticSpan(modifiers As SyntaxTokenList, start As SyntaxNodeOrToken, endNode As SyntaxNodeOrToken) As TextSpan
1757Return TextSpan.FromBounds(If(modifiers.Count <> 0, modifiers.First.SpanStart, start.SpanStart),
1761Private Overloads Shared Function GetDiagnosticSpan(header As MethodBaseSyntax) As TextSpan
1822Return TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End)
1825Private Overloads Shared Function GetDiagnosticSpan(lambda As LambdaHeaderSyntax) As TextSpan
1835Return TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End)
1838Friend Overrides Function GetLambdaParameterDiagnosticSpan(lambda As SyntaxNode, ordinal As Integer) As TextSpan
2130Private ReadOnly _span As TextSpan?
2138Optional span As TextSpan? = Nothing)
2161Private Function GetSpan() As TextSpan
2434Friend Overrides Sub ReportMemberBodyUpdateRudeEdits(diagnostics As ArrayBuilder(Of RudeEditDiagnostic), newMember As SyntaxNode, span As TextSpan?)
2573newStatementSpan As TextSpan)
2605Protected Overrides Function GetExceptionHandlingRegion(node As SyntaxNode, <Out> ByRef coversAllChildren As Boolean) As TextSpan
2613Return TextSpan.FromBounds(tryBlock.FinallyBlock.SpanStart, tryBlock.EndTryStatement.Span.End)
2616Return TextSpan.FromBounds(tryBlock.CatchBlocks.First().SpanStart, tryBlock.EndTryStatement.Span.End)
ExtractMethod\VisualBasicSelectionValidator.vb (11)
19textSpan As TextSpan,
76Private Shared Function GetControlFlowSpan(selectionInfo As SelectionInfo) As TextSpan
77Return TextSpan.FromBounds(selectionInfo.FirstTokenInFinalSpan.SpanStart, selectionInfo.LastTokenInFinalSpan.Span.End)
254.FinalSpan = GetAdjustedSpan(root, TextSpan.FromBounds(start, [end]))
386root, TextSpan.FromBounds(selectionInfo.FirstTokenInOriginalSpan.SpanStart, selectionInfo.LastTokenInOriginalSpan.Span.End),
597textSpan As TextSpan,
640Private Shared Function GetAdjustedSpan(root As SyntaxNode, textSpan As TextSpan) As TextSpan
662Return TextSpan.FromBounds(textSpan.Start, previousLine.End)
668Public Property OriginalSpan() As TextSpan
669Public Property FinalSpan() As TextSpan
AbstractSelectedMembers.cs (4)
35SyntaxTree tree, TextSpan textSpan, bool allowPartialSelection, CancellationToken cancellationToken)
39SyntaxTree tree, TextSpan textSpan, bool allowPartialSelection, CancellationToken cancellationToken)
43SyntaxTree tree, TextSpan textSpan, bool allowPartialSelection,
78SyntaxNode root, SourceText text, TextSpan textSpan,
AbstractTriviaFormatter.cs (13)
46private delegate void WhitespaceAppender<T>(LineColumn lineColumn, LineColumnDelta delta, TextSpan span, ArrayBuilder<T> changes);
388var span = GetTextSpan(trivia1, trivia2);
500var span = TextSpan.FromBounds(start, end);
716var insertionPoint = GetInsertionSpan(changes);
731private TextSpan GetInsertionSpan(ArrayBuilder<TextChange> changes)
766TextSpan notUsed,
823private TextChange GetWhitespaceTextChange(LineColumn lineColumn, LineColumnDelta delta, TextSpan span)
826private void AddWhitespaceTextChange(LineColumn lineColumn, LineColumnDelta delta, TextSpan span, ArrayBuilder<TextChange> changes)
832private TextSpan GetTextSpan(SyntaxTrivia trivia1, SyntaxTrivia trivia2)
836return TextSpan.FromBounds(this.StartPosition, trivia2.FullSpan.Start);
841return TextSpan.FromBounds(trivia1.FullSpan.End, this.EndPosition);
844return TextSpan.FromBounds(trivia1.FullSpan.End, trivia2.FullSpan.Start);
BaseIndentationFormattingRule.cs (10)
20private readonly TextSpan _span;
22public BaseIndentationFormattingRule(SyntaxNode root, TextSpan span, int baseIndentation, AbstractFormattingRule? vbHelperFormattingRule = null)
130private TextSpan AdjustTextSpan(TextSpan textSpan)
131=> TextSpan.FromBounds(Math.Max(_span.Start, textSpan.Start), Math.Min(_span.End, textSpan.End));
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)
168private static TextSpan GetSpanFromTokens(TextSpan span, SyntaxToken token1, SyntaxToken token2)
217return TextSpan.FromBounds(start, end);
CaseCorrection\AbstractCaseCorrectionService.cs (4)
22protected abstract void AddReplacements(SemanticModel? semanticModel, SyntaxNode root, ImmutableArray<TextSpan> spans, ConcurrentDictionary<SyntaxToken, SyntaxToken> replacements, CancellationToken cancellationToken);
24public async Task<Document> CaseCorrectAsync(Document document, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
43public SyntaxNode CaseCorrect(SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
46private SyntaxNode CaseCorrect(SemanticModel? semanticModel, SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
Classification\AbstractClassificationService.cs (9)
23public abstract void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken);
27Document document, TextSpan textSpan, ClassificationOptions options, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken)
33Document document, TextSpan textSpan, ClassificationOptions options, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken)
40TextSpan textSpan,
113TextSpan textSpan,
143TextSpan textSpan,
166foreach (var span in reassignedVariableSpans)
185public async Task AddSyntacticClassificationsAsync(Document document, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken)
192SolutionServices services, SyntaxNode? root, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken)
Classification\IClassificationService.cs (5)
27void AddLexicalClassifications(SourceText text, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken);
33void AddSyntacticClassifications(SolutionServices services, SyntaxNode root, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken);
41Task AddSyntacticClassificationsAsync(Document document, TextSpan textSpan, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken);
53Task AddSemanticClassificationsAsync(Document document, TextSpan textSpan, ClassificationOptions options, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken);
59Task AddEmbeddedLanguageClassificationsAsync(Document document, TextSpan textSpan, ClassificationOptions options, ArrayBuilder<ClassifiedSpan> result, CancellationToken cancellationToken);
Classification\SyntaxClassification\AbstractNameSyntaxClassifier.cs (1)
32TextSpan span,
CodeCleanup\AbstractCodeCleanerService.cs (30)
28protected abstract ImmutableArray<TextSpan> GetSpansToAvoid(SyntaxNode root);
30public async Task<Document> CleanupAsync(Document document, ImmutableArray<TextSpan> spans, CodeCleanupOptions options, ImmutableArray<ICodeCleanupProvider> providers, CancellationToken cancellationToken)
74public async Task<SyntaxNode> CleanupAsync(SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SolutionServices services, ImmutableArray<ICodeCleanupProvider> providers, CancellationToken cancellationToken)
115private static ImmutableArray<TextSpan> GetTextSpansFromAnnotation(
121var builder = ArrayBuilder<TextSpan>.GetInstance();
138out var span))
153out TextSpan span)
220span = TextSpan.FromBounds(node.SpanStart, GetNextTokenEndPosition(nextTokenMarker.Type, nextToken));
227span = TextSpan.FromBounds(GetPreviousTokenStartPosition(previousTokenMarker.Type, previousToken), node.Span.End);
271SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
279foreach (var span in nonOverlappingSpans)
321private static ImmutableArray<TextSpan> GetNonOverlappingSpans(
322SyntaxNode root, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)
328var tokenSpans = new List<TextSpan>();
329foreach (var span in spans)
348tokenSpans.Add(TextSpan.FromBounds(start, end));
360SyntaxNode root, TextSpan span,
382private static TextSpan GetSpanAlignedToTokens(
383SyntaxNode root, TextSpan span,
392return TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End);
445private static bool CleanupWholeNode(TextSpan nodeSpan, ImmutableArray<TextSpan> spans)
459Func<SyntaxNode, ImmutableArray<TextSpan>> spanGetter,
467var spans = ImmutableArray<TextSpan>.Empty;
521private ImmutableArray<TextSpan> GetSpans(
522SyntaxNode root, Func<SyntaxNode, ImmutableArray<TextSpan>> spanGetter)
540Func<SyntaxNode, ImmutableArray<TextSpan>> spanGetter,
549var spans = ImmutableArray<TextSpan>.Empty;
600private static bool TryCreateTextSpan(int start, int end, out TextSpan span)
609span = TextSpan.FromBounds(start, end);
CodeCleanup\CodeCleaner.cs (4)
72public static Task<Document> CleanupAsync(Document document, TextSpan span, CodeCleanupOptions options, ImmutableArray<ICodeCleanupProvider> providers = default, CancellationToken cancellationToken = default)
79public static async Task<Document> CleanupAsync(Document document, ImmutableArray<TextSpan> spans, CodeCleanupOptions options, ImmutableArray<ICodeCleanupProvider> providers = default, CancellationToken cancellationToken = default)
89public static Task<SyntaxNode> CleanupAsync(SyntaxNode root, TextSpan span, SyntaxFormattingOptions options, SolutionServices services, ImmutableArray<ICodeCleanupProvider> providers = default, CancellationToken cancellationToken = default)
96public static Task<SyntaxNode> CleanupAsync(SyntaxNode root, ImmutableArray<TextSpan> spans, SyntaxFormattingOptions options, SolutionServices services, ImmutableArray<ICodeCleanupProvider> providers = default, CancellationToken cancellationToken = default)
CodeRefactorings\CodeRefactoringContext.cs (12)
52public TextSpan Span { get; }
70private readonly Action<CodeAction, TextSpan?> _registerRefactoring;
78TextSpan span,
89TextSpan span,
100TextSpan span,
101Action<CodeAction, TextSpan?> registerRefactoring,
126/// <param name="applicableToSpan">The <see cref="TextSpan"/> within original document the <paramref name="action"/> is applicable to.</param>
129/// applicable to. It doesn't have to precisely represent the exact <see cref="TextSpan"/> that will get changed.
131internal void RegisterRefactoring(CodeAction action, TextSpan applicableToSpan) => RegisterRefactoring(action, new Nullable<TextSpan>(applicableToSpan));
133private void RegisterRefactoring(CodeAction action, TextSpan? applicableToSpan)
143internal void Deconstruct(out Document document, out TextSpan span, out CancellationToken cancellationToken)
CodeRefactorings\FixAllOccurences\FixAllProvider.cs (5)
59public static FixAllProvider Create(Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> fixAllAsync)
79Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> fixAllAsync,
96private readonly Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> _fixAllAsync;
99Func<FixAllContext, Document, Optional<ImmutableArray<TextSpan>>, Task<Document?>> fixAllAsync,
106protected override Task<Document?> FixAllAsync(FixAllContext context, Document document, Optional<ImmutableArray<TextSpan>> fixAllSpans)
CommonFormattingHelpers.cs (10)
42public static IEnumerable<(SyntaxToken, SyntaxToken)> ConvertToTokenPairs(this SyntaxNode root, IReadOnlyList<TextSpan> spans)
78public static ValueTuple<SyntaxToken, SyntaxToken> ConvertToTokenPair(this SyntaxNode root, TextSpan textSpan)
154=> (token1.RawKind == 0) ? text.ToString(TextSpan.FromBounds(0, token2.SpanStart)) : text.ToString(TextSpan.FromBounds(token1.Span.End, token2.SpanStart));
256public static TextSpan GetSpanIncludingTrailingAndLeadingTriviaOfAdjacentTokens(SyntaxToken startToken, SyntaxToken endToken)
263return TextSpan.FromBounds(startPosition, endPosition);
321var fullSpan = node.FullSpan;
360public static TextSpan GetFormattingSpan(SyntaxNode root, TextSpan span)
370return TextSpan.FromBounds(startPosition, endPosition);
Editing\ImportAdder.cs (7)
20private static async ValueTask<IEnumerable<TextSpan>> GetSpansAsync(Document document, CancellationToken cancellationToken)
26private static async ValueTask<IEnumerable<TextSpan>> GetSpansAsync(Document document, SyntaxAnnotation annotation, CancellationToken cancellationToken)
41public static Task<Document> AddImportsAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default)
53public static Task<Document> AddImportsAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? options = null, CancellationToken cancellationToken = default)
56private static async Task<Document> AddImportsFromSyntaxesAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? _, CancellationToken cancellationToken)
84internal static Task<Document> AddImportsFromSyntaxesAsync(Document document, IEnumerable<TextSpan> spans, AddImportPlacementOptions options, CancellationToken cancellationToken)
99internal static Task<Document> AddImportsFromSymbolAnnotationAsync(Document document, IEnumerable<TextSpan> spans, AddImportPlacementOptions options, CancellationToken cancellationToken)
Formatting\Formatter.cs (17)
65public static Task<Document> FormatAsync(Document document, TextSpan span, OptionSet? options = null, CancellationToken cancellationToken = default)
70internal static Task<Document> FormatAsync(Document document, TextSpan span, SyntaxFormattingOptions options, CancellationToken cancellationToken)
81public static async Task<Document> FormatAsync(Document document, IEnumerable<TextSpan>? spans, OptionSet? options = null, CancellationToken cancellationToken = default)
93internal static async Task<Document> FormatAsync(Document document, IEnumerable<TextSpan>? spans, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
204public static SyntaxNode Format(SyntaxNode node, TextSpan span, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
207internal static SyntaxNode Format(SyntaxNode node, TextSpan span, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken)
219public static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
222private static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
228internal static SyntaxNode Format(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
231private static IFormattingResult? GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
255internal static IFormattingResult GetFormattingResult(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
284public static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, TextSpan span, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
287internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, TextSpan span, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken = default)
299public static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options = null, CancellationToken cancellationToken = default)
302internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, CancellationToken cancellationToken = default)
305private static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, Workspace workspace, OptionSet? options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken)
313internal static IList<TextChange> GetFormattedTextChanges(SyntaxNode node, IEnumerable<TextSpan>? spans, SolutionServices services, SyntaxFormattingOptions options, IEnumerable<AbstractFormattingRule>? rules, CancellationToken cancellationToken = default)
FormattingContext.IndentationData.cs (14)
20public IndentationData(TextSpan textSpan)
23public TextSpan TextSpan { get; }
26public IndentationData WithTextSpan(TextSpan span)
29protected abstract IndentationData WithTextSpanCore(TextSpan span);
36public SimpleIndentationData(TextSpan textSpan, int indentation)
44protected override IndentationData WithTextSpanCore(TextSpan span)
68public RelativeIndentationData(FormattingContext formattingContext, int inseparableRegionSpanStart, TextSpan textSpan, IndentBlockOperation operation, Func<FormattingContext, IndentBlockOperation, SyntaxToken> effectiveBaseTokenGetter, Func<FormattingContext, IndentBlockOperation, SyntaxToken, int> indentationDeltaGetter, Func<FormattingContext, SyntaxToken, int> baseIndentationGetter)
79this.InseparableRegionSpan = TextSpan.FromBounds(inseparableRegionSpanStart, textSpan.End);
82private RelativeIndentationData(FormattingContext formattingContext, int inseparableRegionSpanStart, TextSpan textSpan, IndentBlockOperation operation, Func<FormattingContext, IndentBlockOperation, SyntaxToken> effectiveBaseTokenGetter, Func<FormattingContext, IndentBlockOperation, SyntaxToken, int> indentationDeltaGetter, Func<FormattingContext, SyntaxToken, int> baseIndentationGetter, int lazyIndentationDelta)
93this.InseparableRegionSpan = TextSpan.FromBounds(inseparableRegionSpanStart, textSpan.End);
96public TextSpan InseparableRegionSpan { get; }
118protected override IndentationData WithTextSpanCore(TextSpan span)
130public AdjustedIndentationData(TextSpan textSpan, IndentationData baseIndentationData, int adjustment)
153protected override IndentationData WithTextSpanCore(TextSpan span)
FormattingOperations.cs (8)
31=> CreateAnchorIndentationOperation(anchorToken, endToken, TextSpan.FromBounds(anchorToken.Span.End, endToken.Span.End));
36public static AnchorIndentationOperation CreateAnchorIndentationOperation(SyntaxToken anchorToken, SyntaxToken endToken, TextSpan textSpan)
43=> CreateSuppressOperation(startToken, endToken, TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End), option);
48private static SuppressOperation CreateSuppressOperation(SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, SuppressOption option)
56var span = CommonFormattingHelpers.GetSpanIncludingTrailingAndLeadingTriviaOfAdjacentTokens(startToken, endToken);
63public static IndentBlockOperation CreateIndentBlockOperation(SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, int indentationDelta, IndentBlockOption option)
71var span = CommonFormattingHelpers.GetSpanIncludingTrailingAndLeadingTriviaOfAdjacentTokens(startToken, endToken);
79public static IndentBlockOperation CreateRelativeIndentBlockOperation(SyntaxToken baseToken, SyntaxToken startToken, SyntaxToken endToken, TextSpan textSpan, int indentationDelta, IndentBlockOption option)
LanguageServices\FixAllSpanMappingService\AbstractFixAllSpanMappingService.cs (9)
19protected abstract Task<ImmutableDictionary<Document, ImmutableArray<TextSpan>>> GetFixAllSpansIfWithinGlobalStatementAsync(
20Document document, TextSpan span, CancellationToken cancellationToken);
22public Task<ImmutableDictionary<Document, ImmutableArray<TextSpan>>> GetFixAllSpansAsync(
23Document document, TextSpan triggerSpan, FixAllScope fixAllScope, CancellationToken cancellationToken)
31private async Task<ImmutableDictionary<Document, ImmutableArray<TextSpan>>> GetFixAllSpansAsync(
32Document document, TextSpan span, bool fixAllInContainingMember, CancellationToken cancellationToken)
50var builder = PooledDictionary<Document, ArrayBuilder<TextSpan>>.GetInstance();
56var partialDeclSpan = syntaxFacts.GetContainingTypeDeclaration(root, syntaxRef.Span.Start)!.FullSpan;
73TextSpan span,
NamingStyle.cs (21)
159var spanToCheck = TextSpan.FromBounds(0, name.Length - Suffix.Length);
173private WordSpanEnumerable GetWordSpans(string name, TextSpan nameSpan)
176private static string Substring(string name, TextSpan wordSpan)
179private static readonly Func<string, TextSpan, bool> s_firstCharIsLowerCase = (val, span) => !DoesCharacterHaveCasing(val[span.Start]) || char.IsLower(val[span.Start]);
180private static readonly Func<string, TextSpan, bool> s_firstCharIsUpperCase = (val, span) => !DoesCharacterHaveCasing(val[span.Start]) || char.IsUpper(val[span.Start]);
182private static readonly Func<string, TextSpan, bool> s_wordIsAllUpperCase = (val, span) =>
195private static readonly Func<string, TextSpan, bool> s_wordIsAllLowerCase = (val, span) =>
209string name, TextSpan nameSpan, Func<string, TextSpan, bool> wordCheck,
215foreach (var wordSpan in GetWordSpans(name, nameSpan))
231private bool CheckPascalCase(string name, TextSpan nameSpan, out string reason)
236private bool CheckAllUpper(string name, TextSpan nameSpan, out string reason)
241private bool CheckAllLower(string name, TextSpan nameSpan, out string reason)
247string name, TextSpan nameSpan,
248Func<string, TextSpan, bool> firstWordCheck,
249Func<string, TextSpan, bool> restWordCheck,
259foreach (var wordSpan in GetWordSpans(name, nameSpan))
290private bool CheckCamelCase(string name, TextSpan nameSpan, out string reason)
297private bool CheckFirstUpper(string name, TextSpan nameSpan, out string reason)
405using var parts = TemporaryArray<TextSpan>.Empty;
NormalizedTextSpanCollection.cs (42)
14internal class NormalizedTextSpanCollection : ReadOnlyCollection<TextSpan>
21: base(new List<TextSpan>(0))
29public NormalizedTextSpanCollection(TextSpan span)
42public NormalizedTextSpanCollection(IEnumerable<TextSpan> spans)
93var span1 = left[index1];
94var span2 = right[index2];
122spans.Add(TextSpan.FromBounds(start, end));
161var span1 = left[index1];
162var span2 = right[index2];
221var span1 = left[index1];
222var span2 = right[index2];
283var span1 = left[index1];
284var span2 = right[index2];
296spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span1.End));
307spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span2.Start));
333var span1 = left[index1++];
334spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span1.End));
398var span1 = this[index1];
399var span2 = set[index2];
429public bool OverlapsWith(TextSpan span)
458var span1 = this[index1];
459var span2 = set[index2];
483public bool IntersectsWith(TextSpan span)
506foreach (var s in this)
533foreach (var s in this)
546private static IList<TextSpan> ListFromSpan(TextSpan span)
548IList<TextSpan> list = new List<TextSpan>(1);
562private static void UpdateSpanUnion(TextSpan span, IList<TextSpan> spans, ref int start, ref int end)
566spans.Add(TextSpan.FromBounds(start, end));
583private static IList<TextSpan> NormalizeSpans(IEnumerable<TextSpan> spans)
590var sorted = new List<TextSpan>(spans);
597sorted.Sort(delegate (TextSpan s1, TextSpan s2) { return s1.Start.CompareTo(s2.Start); });
599IList<TextSpan> normalized = new List<TextSpan>(sorted.Count);
609normalized.Add(TextSpan.FromBounds(oldStart, oldEnd));
619normalized.Add(TextSpan.FromBounds(oldStart, oldEnd));
624private class OrderedSpanList : List<TextSpan>
PatternMatching\AllLowerCamelCaseMatcher.cs (14)
49in TemporaryArray<TextSpan> candidateHumps, out ImmutableArray<TextSpan> matchedSpans)
64matchedSpans = ImmutableArray<TextSpan>.Empty;
70: ImmutableArray<TextSpan>.Empty;
76private static PatternMatchKind GetKind(CamelCaseResult result, in TemporaryArray<TextSpan> candidateHumps)
80int patternIndex, int candidateHumpIndex, bool? contiguous, in TemporaryArray<TextSpan> candidateHumps)
86var matchedSpansInReverse = _includeMatchedSpans ? ArrayBuilder<TextSpan>.GetInstance() : null;
106var candidateHump = candidateHumps[humpIndex];
160int patternIndex, int humpIndex, bool contiguous, in TemporaryArray<TextSpan> candidateHumps)
164var candidateHump = candidateHumps[humpIndex];
202var matchSpanToAdd = new TextSpan(candidateHump.Start, possibleHumpMatchLength);
222CamelCaseResult result, ref CamelCaseResult? bestResult, TextSpan? matchSpanToAdd, in TemporaryArray<TextSpan> candidateHumps)
251private static bool IsBetter(CamelCaseResult result, CamelCaseResult? currentBestResult, in TemporaryArray<TextSpan> candidateHumps)
PatternMatching\PatternMatcher.cs (17)
176using var candidateHumps = TemporaryArray<TextSpan>.Empty;
229var hump = TextSpan.FromBounds(candidateHumps[i].Start, candidateLength);
272private TextSpan? GetMatchedSpan(int start, int length)
394private bool PartStartsWith(string candidate, TextSpan candidatePart, string pattern, TextSpan patternPart, CompareOptions compareOptions)
415private bool PartStartsWith(string candidate, TextSpan candidatePart, string pattern, CompareOptions compareOptions)
423in TemporaryArray<TextSpan> candidateHumps)
467in TemporaryArray<TextSpan> candidateHumps,
469out ImmutableArray<TextSpan> matchedSpans)
477in TemporaryArray<TextSpan> candidateHumps,
480out ImmutableArray<TextSpan> matchedSpans)
497using var _ = ArrayBuilder<TextSpan>.GetInstance(out var matchSpans);
509: ImmutableArray<TextSpan>.Empty;
517matchedSpans = ImmutableArray<TextSpan>.Empty;
521var candidateHump = candidateHumps[currentCandidateHump];
530var patternChunkCharacterSpan = patternHumps[currentPatternHump];
Rename\ConflictEngine\RenamedSpansTracker.cs (28)
25private readonly Dictionary<DocumentId, List<(TextSpan oldSpan, TextSpan newSpan)>> _documentToModifiedSpansMap = new();
31internal void AddModifiedSpan(DocumentId documentId, TextSpan oldSpan, TextSpan newSpan)
35spans = new List<(TextSpan oldSpan, TextSpan newSpan)>();
42internal void AddComplexifiedSpan(DocumentId documentId, TextSpan oldSpan, TextSpan newSpan, List<(TextSpan oldSpan, TextSpan newSpan)> modifiedSubSpans)
58SpecializedCollections.EmptyEnumerable<(TextSpan oldSpan, TextSpan newSpan)>();
70var appliedTextSpans = new HashSet<TextSpan>();
123public TextSpan OriginalSpan;
124public TextSpan NewSpan;
125public List<(TextSpan oldSpan, TextSpan newSpan)> ModifiedSubSpans;
128TextSpan originalSpan, TextSpan newSpan, List<(TextSpan oldSpan, TextSpan newSpan)> modifiedSubSpans)
190var oldSpan = annotationAndNode.Item1.OriginalTextSpan;
196var modifiedSubSpans = new List<(TextSpan oldSpan, TextSpan newSpan)>();
231public ImmutableDictionary<DocumentId, ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>> GetDocumentToModifiedSpansMap()
233var builder = ImmutableDictionary.CreateBuilder<DocumentId, ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>>();
Rename\ConflictResolution.cs (16)
49private readonly ImmutableDictionary<DocumentId, ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>> _documentToModifiedSpansMap;
65_documentToModifiedSpansMap = ImmutableDictionary<DocumentId, ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>>.Empty;
76ImmutableDictionary<DocumentId, ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>> documentToModifiedSpansMap,
98public ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)> GetComplexifiedSpans(DocumentId documentId)
101: ImmutableArray<(TextSpan oldSpan, TextSpan newSpan)>.Empty;
103public ImmutableDictionary<TextSpan, TextSpan> GetModifiedSpanMap(DocumentId documentId)
105var result = ImmutableDictionary.CreateBuilder<TextSpan, TextSpan>();
129internal TextSpan GetResolutionTextSpan(TextSpan originalSpan, DocumentId documentId)
Simplification\Simplifier.cs (4)
203public static Task<Document> ReduceAsync(Document document, TextSpan span, OptionSet? optionSet = null, CancellationToken cancellationToken = default)
215internal static Task<Document> ReduceAsync(Document document, TextSpan span, SimplifierOptions options, CancellationToken cancellationToken)
222public static async Task<Document> ReduceAsync(Document document, IEnumerable<TextSpan> spans, OptionSet? optionSet = null, CancellationToken cancellationToken = default)
240internal static Task<Document> ReduceAsync(Document document, IEnumerable<TextSpan> spans, SimplifierOptions options, CancellationToken cancellationToken)
SourceTextExtensions_SharedWithCodeStyle.cs (2)
33this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
45this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
StringBreaker.cs (10)
16public static void AddWordParts(string identifier, ref TemporaryArray<TextSpan> parts)
19public static void AddCharacterParts(string identifier, ref TemporaryArray<TextSpan> parts)
22public static void AddParts(string text, bool word, ref TemporaryArray<TextSpan> parts)
26var span = StringBreaker.GenerateSpan(text, start, word);
40public static TextSpan GenerateSpan(string identifier, int wordStart, bool word)
80private static TextSpan ScanCharacterRun(string identifier, int length, int wordStart)
101private static TextSpan ScanWordRun(string identifier, int length, int wordStart)
150private static TextSpan ScanLowerCaseRun(string identifier, int length, int wordStart)
161private static TextSpan ScanNumber(string identifier, int length, int wordStart)
169return TextSpan.FromBounds(wordStart, current);
TextSpanExtensions.cs (22)
18public static IEnumerable<TextSpan> ToNormalizedSpans(this IEnumerable<TextSpan> spans)
21public static ImmutableArray<TextSpan> ToNormalizedSpans(this ImmutableArray<TextSpan> spans)
24public static TextSpan Collapse(this IEnumerable<TextSpan> spans)
29foreach (var span in spans)
48return TextSpan.FromBounds(start, end);
54public static bool IsAround(this TextSpan span, SyntaxNodeOrToken node) => IsAround(span, node, node);
60public static bool IsAround(this TextSpan span, SyntaxNodeOrToken startNode, SyntaxNodeOrToken endNode)
62var innerSpan = TextSpan.FromBounds(startNode.Span.Start, endNode.Span.End);
63var outerSpan = TextSpan.FromBounds(startNode.FullSpan.Start, endNode.FullSpan.End);
67public static IEnumerable<TextSpan> Subtract(this TextSpan span, TextSpan except)
81yield return TextSpan.FromBounds(span.Start, startSegmentEnd);
85yield return TextSpan.FromBounds(endSegmentStart, span.End);
88public static IEnumerable<TextSpan> Subtract(this IEnumerable<TextSpan> spans, TextSpan except)
Workspace\Host\DocumentService\IDocumentExcerptService.cs (8)
21/// return <see cref="ExcerptResult"/> of given <see cref="Document"/> and <see cref="TextSpan"/>
25Task<ExcerptResult?> TryExcerptAsync(Document document, TextSpan span, ExcerptMode mode, ClassificationOptions classificationOptions, CancellationToken cancellationToken);
50public readonly TextSpan MappedSpan;
60/// should be same document in <see cref="IDocumentExcerptService.TryExcerptAsync(Document, TextSpan, ExcerptMode, ClassificationOptions, CancellationToken)" />
67/// should be same text span in <see cref="IDocumentExcerptService.TryExcerptAsync(Document, TextSpan, ExcerptMode, ClassificationOptions, CancellationToken)" />
69public readonly TextSpan Span;
71public ExcerptResult(SourceText content, TextSpan mappedSpan, ImmutableArray<ClassifiedSpan> classifiedSpans, Document document, TextSpan span)