src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\Core\MetaAnalyzers\ReleaseTrackingHelper.cs (8)
46SourceText sourceText,
47Action<string, Version, string, SourceText, TextLine> onDuplicateEntryInRelease,
48Action<TextLine, InvalidEntryKind, string, SourceText> onInvalidEntry,
440public SourceText SourceText { get; }
449TextSpan span, SourceText sourceText,
458TextSpan span, SourceText sourceText,
478TextSpan span, SourceText sourceText,
497TextSpan span, SourceText sourceText,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,
MetaAnalyzers\ReleaseTrackingHelper.cs (8)
46SourceText sourceText,
47Action<string, Version, string, SourceText, TextLine> onDuplicateEntryInRelease,
48Action<TextLine, InvalidEntryKind, string, SourceText> onInvalidEntry,
440public SourceText SourceText { get; }
449TextSpan span, SourceText sourceText,
458TextSpan span, SourceText sourceText,
478TextSpan span, SourceText sourceText,
497TextSpan span, SourceText sourceText,
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,
Completion\CompletionProviders\CompletionUtilities.cs (8)
20internal static TextSpan GetCompletionItemSpan(SourceText text, int position)
60internal static bool IsTriggerCharacter(SourceText text, int characterPosition, in CompletionOptions options)
99internal static bool IsCompilerDirectiveTriggerCharacter(SourceText text, int characterPosition)
117internal static bool IsTriggerCharacterOrArgumentListCharacter(SourceText text, int characterPosition, in CompletionOptions options)
120private static bool IsArgumentListCharacter(SourceText text, int characterPosition)
126internal static bool IsTriggerAfterSpaceOrStartOfWordCharacter(SourceText text, int characterPosition, in CompletionOptions options)
136private static bool SpaceTypedNotBeforeWord(char ch, SourceText text, int characterPosition)
139public static bool IsStartingNewWord(SourceText text, int characterPosition)
StringIndentation\CSharpStringIndentationService.cs (5)
31var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
79SourceText text, SyntaxToken token, ref TemporaryArray<StringIndentationRegion> result, CancellationToken cancellationToken)
94SourceText text, InterpolatedStringExpressionSyntax interpolatedString, ref TemporaryArray<StringIndentationRegion> result, CancellationToken cancellationToken)
137private static bool IgnoreInterpolation(SourceText text, int offset, InterpolationSyntax interpolation)
158private static bool TryGetIndentSpan(SourceText text, ExpressionSyntax expression, out int offset, out TextSpan indentSpan)
Completion\CommonCompletionProvider.cs (4)
34public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
42internal override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions)
45private bool ShouldTriggerCompletionImpl(SourceText text, int caretPosition, CompletionTrigger trigger, in CompletionOptions options)
50public virtual bool IsInsertionTrigger(SourceText text, int insertedCharacterPosition, CompletionOptions options)
Completion\CommonCompletionUtilities.cs (4)
27public static TextSpan GetWordSpan(SourceText text, int position,
33public static TextSpan GetWordSpan(SourceText text, int position,
60public static bool IsStartingNewWord(SourceText text, int characterPosition, Func<char, bool> isWordStartCharacter, Func<char, bool> isWordCharacter)
185internal static bool IsTextualTriggerString(SourceText text, int characterPosition, string value)
Completion\Providers\CompletionUtilities.cs (4)
73public static CompletionItem SetOriginalIdentifierEnd(CompletionItem item, int position, SourceText text, ISyntaxFactsService syntaxFacts)
82public static KeyValuePair<string, string> GetOriginalIdentifierEndProperty(int position, SourceText text, ISyntaxFactsService syntaxFacts)
85private static int ScanForwardThroughIdentifier(int start, SourceText text, ISyntaxFactsService syntaxFacts)
102public static int GetCurrentSpanEnd(CompletionItem item, SourceText text, ISyntaxFactsService syntaxFacts)
DocumentationComments\AbstractDocumentationCommentSnippetService.cs (8)
42private bool IsAtEndOfDocCommentTriviaOnBlankLine(SourceText text, int endPosition)
79var text = document.Text;
103private List<string>? GetDocumentationCommentLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out string? indentText, out int caretOffset, out int spanToReplaceLength)
145private List<string>? GetDocumentationStubLines(SyntaxToken token, SourceText text, in DocumentationCommentOptions options, out int caretOffset, out int spanToReplaceLength, out string? existingCommentText)
189var text = document.Text;
264var text = document.Text;
316var text = document.Text;
356var text = document.Text;
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (9)
500private static readonly SourceText s_emptySource = SourceText.From("");
709void LogRudeEdits(ImmutableArray<RudeEditDiagnostic> diagnostics, SourceText text, string filePath)
732private static async ValueTask<(Document? document, SourceText text)> GetDocumentContentAsync(Project project, DocumentId documentId, CancellationToken cancellationToken)
734SourceText text;
946SourceText newText,
1109SourceText newText,
1484private static bool TryGetTrackedStatement(ImmutableArray<ActiveStatementLineSpan> activeStatementSpans, ActiveStatementId id, SourceText text, MemberBody body, [NotNullWhen(true)] out SyntaxNode? trackedStatement, out int trackedStatementPart)
2702SourceText newText,
EditAndContinue\CommittedSolution.cs (12)
233var sourceText = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
298var matchingSourceText = maybeMatchingSourceText.Value;
325private async ValueTask<(Optional<SourceText?> matchingSourceText, bool? hasDocument)> TryGetMatchingSourceTextAsync(Document document, SourceText sourceText, Document currentDocument, CancellationToken cancellationToken)
365private static async ValueTask<Optional<SourceText?>> TryGetMatchingSourceTextAsync(
367SourceText sourceText,
383var currentDocumentSourceText = await currentDocument.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
398return SourceText.From(text, defaultEncoding, checksumAlgorithm);
440private static bool IsMatchingSourceText(SourceText sourceText, ImmutableArray<byte> requiredChecksum, SourceHashAlgorithm checksumAlgorithm)
443private static Optional<SourceText?> TryGetPdbMatchingSourceTextFromDisk(
454var sourceText = SourceText.From(fileStream, defaultEncoding, checksumAlgorithm);
ExternalAccess\VSTypeScript\Api\VSTypeScriptCompletionProvider.cs (3)
15public sealed override bool ShouldTriggerCompletion(SourceText text, int caretPosition, CompletionTrigger trigger, OptionSet options)
21internal sealed override bool ShouldTriggerCompletion(LanguageServices languageServices, SourceText text, int caretPosition, CompletionTrigger trigger, CompletionOptions options, OptionSet passThroughOptions)
24protected abstract bool ShouldTriggerCompletionImpl(SourceText text, int caretPosition, CompletionTrigger trigger, bool triggerOnTypingLetters);
src\roslyn\src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (15)
75var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
85SyntaxNode root, SourceText text, int position,
146SourceText text, int position,
210var text = startLine.Text!;
228var text = startLine.Text!;
246var text = currentLine.Text!;
316Action<SourceText, ArrayBuilder<TextChange>, int, int, int, int> addEdits,
319var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
324var finalText = text.WithChanges(edits);
329SourceText text, ArrayBuilder<TextChange> edits,
342SourceText text, ArrayBuilder<TextChange> edits,
355SourceText text, ArrayBuilder<TextChange> edits,
389private static int GetEndIncludingLineBreak(SourceText text, int position)
405var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false);
444var finalText = text.WithChanges(edits);
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,
Shared\Extensions\SourceTextExtensions.cs (12)
36public static void GetLineAndOffset(this SourceText text, int position, out int lineNumber, out int offset)
44public static int GetOffset(this SourceText text, int position)
51this SourceText text,
62public static TextChangeRange GetEncompassingTextChangeRange(this SourceText newText, SourceText oldText)
79public static int IndexOf(this SourceText text, string value, int startIndex, bool caseSensitive)
110public static int LastIndexOf(this SourceText text, string value, int startIndex, bool caseSensitive)
146public static bool ContentEquals(this SourceText text, int position, string value)
164public static int IndexOfNonWhiteSpace(this SourceText text, int start, int length)
177public static void WriteTo(this SourceText sourceText, ObjectWriter writer, CancellationToken cancellationToken)
195private static void WriteChunksTo(SourceText sourceText, ObjectWriter writer, int length, CancellationToken cancellationToken)
226public static SourceText ReadFrom(ITextFactoryService textService, ObjectReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,
Workspace\Host\TextFactory\TextFactoryService.cs (4)
25public SourceText CreateText(Stream stream, Encoding? defaultEncoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
31public SourceText CreateText(TextReader reader, Encoding? encoding, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken)
36? SourceText.From(textReaderWithLength, textReaderWithLength.Length, encoding, checksumAlgorithm)
37: SourceText.From(reader.ReadToEnd(), encoding, checksumAlgorithm);
Workspace\Solution\DocumentState.cs (12)
106var text = await this.GetTextAsync(cancellationToken).ConfigureAwait(false);
166var text = textAndVersion.Text;
239var newText = newTextAndVersion.Text;
242var oldText = oldTree.GetText(cancellationToken);
250private static TreeAndVersion MakeNewTreeAndVersion(SyntaxTree oldTree, SourceText oldText, VersionStamp oldVersion, SyntaxTree newTree, SourceText newText, VersionStamp newVersion)
259private static bool TopLevelChanged(SyntaxTree oldTree, SourceText oldText, SyntaxTree newTree, SourceText newText)
444public new DocumentState UpdateText(SourceText newText, PreservationMode mode)
507else if (TryGetText(out var priorText))
672SourceText newText,
674SourceText? oldText = null)
Workspace\Solution\FileTextLoader.cs (7)
68GetType(), _ => new StrongBox<bool>(new Func<Stream, Workspace, SourceText>(CreateText).Method.DeclaringType != typeof(FileTextLoader))).Value;
72/// Creates <see cref="SourceText"/> from <see cref="Stream"/>.
76protected virtual SourceText CreateText(Stream stream, Workspace? workspace)
80/// Creates <see cref="SourceText"/> from <see cref="Stream"/>.
83private protected virtual SourceText CreateText(Stream stream, LoadTextOptions options, CancellationToken cancellationToken)
183var text = t.self.CreateText(readStream, t.options, t.cancellationToken);
207var text = t.self.CreateText(stream, t.options, t.cancellationToken);
Workspace\Solution\Solution.cs (18)
986var sourceText = SourceText.From(text, encoding: null, checksumAlgorithm: project.ChecksumAlgorithm);
995public Solution AddDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null, bool isGenerated = false)
1028var sourceText = SourceText.From(string.Empty, encoding: null, project.ChecksumAlgorithm);
1034private Solution AddDocumentImpl(ProjectState project, DocumentId documentId, string name, SourceText text, IReadOnlyList<string>? folders, string? filePath, bool isGenerated)
1089=> this.AddAdditionalDocument(documentId, name, SourceText.From(text), folders, filePath);
1095public Solution AddAdditionalDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null)
1126public Solution AddAnalyzerConfigDocument(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders = null, string? filePath = null)
1150private DocumentInfo CreateDocumentInfo(DocumentId documentId, string name, SourceText text, IEnumerable<string>? folders, string? filePath)
1288public Solution WithDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue)
1291internal Solution WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode = PreservationMode.PreserveValue)
1311public Solution WithAdditionalDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue)
1332public Solution WithAnalyzerConfigDocumentText(DocumentId documentId, SourceText text, PreservationMode mode = PreservationMode.PreserveValue)
1645public Solution WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode = PreservationMode.PreserveValue)
1671SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text)
1684internal Solution WithFrozenSourceGeneratedDocuments(ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText text)> documents)
1685=> WithCompilationState(CompilationState.WithFrozenSourceGeneratedDocuments(documents.SelectAsArray(d => (d.documentIdentity, d.generationDateTime, (SourceText?)d.text, (SyntaxNode?)null))));
Workspace\Solution\SolutionCompilationState.cs (18)
806internal SolutionCompilationState WithDocumentTexts(ImmutableArray<(DocumentId documentId, SourceText text)> texts, PreservationMode mode)
810return UpdateDocumentsInMultipleProjects<DocumentState, SourceText, PreservationMode>(
817(ImmutableArray<(DocumentId, SourceText)>,
818ImmutableArray<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>) GetOrdinaryAndSourceGeneratedDocuments()
823using var _1 = ArrayBuilder<(DocumentId, SourceText)>.GetInstance(capacity: texts.Length, out var ordinaryDocuments);
824using var _2 = ArrayBuilder<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>.GetInstance(out var sourceGeneratedDocuments);
841private static bool SourceTextIsUnchanged(DocumentState oldDocument, SourceText text)
842=> oldDocument.TryGetText(out var oldText) && text == oldText;
850ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText? sourceText, SyntaxNode? syntaxNode)> sourceGeneratedDocuments,
962/// <inheritdoc cref="SolutionState.WithAdditionalDocumentText(DocumentId, SourceText, PreservationMode)"/>
964DocumentId documentId, SourceText text, PreservationMode mode)
970/// <inheritdoc cref="SolutionState.WithAnalyzerConfigDocumentText(DocumentId, SourceText, PreservationMode)"/>
972DocumentId documentId, SourceText text, PreservationMode mode)
1023ImmutableArray<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>) GetOrdinaryAndSourceGeneratedDocuments()
1029using var _2 = ArrayBuilder<(SourceGeneratedDocumentIdentity, DateTime, SourceText?, SyntaxNode?)>.GetInstance(out var sourceGeneratedDocuments);
1405ImmutableArray<(SourceGeneratedDocumentIdentity documentIdentity, DateTime generationDateTime, SourceText? sourceText, SyntaxNode? syntaxNode)> documents)
1873public SolutionCompilationState WithDocumentText(IEnumerable<DocumentId?> documentIds, SourceText text, PreservationMode mode)
1875using var _ = ArrayBuilder<(DocumentId, SourceText)>.GetInstance(out var changedDocuments);
Workspace\Workspace.cs (18)
1138protected internal void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode)
1141private protected void OnDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode, bool requireDocumentPresent)
1156protected internal void OnAdditionalDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode)
1171protected internal void OnAnalyzerConfigDocumentTextChanged(DocumentId documentId, SourceText newText, PreservationMode mode)
1936var text = document.GetTextSynchronously(CancellationToken.None);
1945var text = document.GetTextSynchronously(CancellationToken.None);
1954var text = document.GetTextSynchronously(CancellationToken.None);
1971var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait
1981var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait
1998if (!oldDoc.TryGetText(out var oldText))
2003var currentText = newDoc.GetTextSynchronously(CancellationToken.None); // needs wait
2006else if (!newDoc.TryGetText(out var newText))
2202protected virtual void ApplyDocumentAdded(DocumentInfo info, SourceText text)
2224protected virtual void ApplyDocumentTextChanged(DocumentId id, SourceText text)
2246protected virtual void ApplyAdditionalDocumentAdded(DocumentInfo info, SourceText text)
2268protected virtual void ApplyAdditionalDocumentTextChanged(DocumentId id, SourceText text)
2279protected virtual void ApplyAnalyzerConfigDocumentAdded(DocumentInfo info, SourceText text)
2301protected virtual void ApplyAnalyzerConfigDocumentTextChanged(DocumentId id, SourceText text)
Workspace\Workspace_Editor.cs (11)
396var newText = textContainer.CurrentText;
397if (oldDocument.TryGetText(out var oldText) &&
486private static TextAndVersion GetProperTextAndVersion(SourceText oldText, SourceText newText, VersionStamp version, string? filePath)
495private void SignupForTextChanges(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext, Action<Workspace, DocumentId, SourceText, PreservationMode> onChangedHandler)
556Func<Solution, DocumentId, SourceText, PreservationMode, Solution> withDocumentText,
558Action<Workspace, DocumentId, SourceText, PreservationMode> onDocumentTextChanged)
588var oldText = oldDocument.GetTextSynchronously(CancellationToken.None);
591var newText = data.textContainer.CurrentText;
850private SourceText GetOpenDocumentText(Solution solution, DocumentId documentId)
855Contract.ThrowIfFalse(doc.TryGetText(out var text));
src\roslyn\src\Compilers\Core\Portable\EncodedStringText.cs (11)
72/// Initializes an instance of <see cref="SourceText"/> from the provided stream. This version differs
73/// from <see cref="SourceText.From(Stream, Encoding, SourceHashAlgorithm, bool)"/> in two ways:
91internal static SourceText Create(Stream stream,
103internal static SourceText Create(Stream stream,
136/// Try to create a <see cref="SourceText"/> from the given stream using the given encoding.
143/// <returns>The <see cref="SourceText"/> decoded from the stream.</returns>
146private static SourceText Decode(
165return SourceText.From(bytes.Array,
175return SourceText.From(data, encoding, checksumAlgorithm, throwIfBinaryDetected, canBeEmbedded);
249internal static SourceText Create(Stream stream, Lazy<Encoding> getEncoding, Encoding defaultEncoding, SourceHashAlgorithm checksumAlgorithm, bool canBeEmbedded)
252internal static SourceText Decode(Stream data, Encoding encoding, SourceHashAlgorithm checksumAlgorithm, bool throwIfBinaryDetected, bool canBeEmbedded)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SourceTextExtensions_SharedWithCodeStyle.cs (5)
16public static string GetLeadingWhitespaceOfLineAtPosition(this SourceText text, int position)
32this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden, CancellationToken cancellationToken)
44this SourceText text, TextSpan span, Func<int, CancellationToken, bool> isPositionHidden,
82public static bool AreOnSameLine(this SourceText text, SyntaxToken token1, SyntaxToken token2)
87public static bool AreOnSameLine(this SourceText text, int pos1, int pos2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\RefactoringHelpers\AbstractRefactoringHelpers.cs (6)
25public abstract bool IsBetweenTypeMembers(SourceText sourceText, SyntaxNode root, int position, [NotNullWhen(true)] out SyntaxNode? typeDeclaration);
42private static TextSpan GetTrimmedTextSpan(SourceText sourceText, TextSpan span)
60SourceText sourceText, SyntaxNode root, TextSpan selectionRaw, bool allowEmptyNodes, int maxCount, ref TemporaryArray<TSyntaxNode> result, CancellationToken cancellationToken) where TSyntaxNode : SyntaxNode
179SourceText sourceText, SyntaxNode root, int location)
251SourceText sourceText, SyntaxToken tokenOnLocation, int location)
533SourceText sourceText,