2 instantiations of VirtualChar
Microsoft.CodeAnalysis.Workspaces (2)
VirtualChar.cs (2)
55
=>
new
(rune, surrogateChar: default, span);
67
return new
VirtualChar
(rune: Rune.ReplacementChar, surrogateChar, span);
214 references to VirtualChar
Microsoft.CodeAnalysis.CSharp.Features (15)
ConvertBetweenRegularAndVerbatimString\AbstractConvertBetweenRegularAndVerbatimStringCodeRefactoringProvider.cs (5)
106
foreach (
var
ch in chars)
117
static bool ShouldDouble(
VirtualChar
ch, bool isInterpolation)
129
private static bool IsOpenOrCloseBrace(
VirtualChar
ch)
138
foreach (
var
ch in chars)
174
foreach (
var
ch in chars)
ConvertToRawString\ConvertRegularStringToRawStringCodeRefactoringProvider.cs (5)
315
foreach (
var
ch in characters)
348
var
ch = characters[i];
402
var result = ImmutableSegmentedList.CreateBuilder<
VirtualChar
>();
425
private static void AddRange(ImmutableSegmentedList<
VirtualChar
>.Builder result, VirtualCharSequence sequence)
427
foreach (
var
c in sequence)
ConvertToRawString\ConvertToRawStringHelpers.cs (5)
34
public static bool IsCSharpNewLine(
VirtualChar
ch)
37
public static bool IsCSharpWhitespace(
VirtualChar
ch)
50
private static bool AllEscapesAre(VirtualCharSequence sequence, Func<
VirtualChar
, bool> predicate)
54
foreach (
var
ch in sequence)
80
public static bool CanConvert(
VirtualChar
ch)
Microsoft.CodeAnalysis.CSharp.Workspaces (9)
CSharpVirtualCharService.cs (8)
133
var result = ImmutableSegmentedList.CreateBuilder<
VirtualChar
>();
201
var result = ImmutableSegmentedList.CreateBuilder<
VirtualChar
>();
288
var runeResults = ImmutableSegmentedList.CreateBuilder<
VirtualChar
>();
295
private static void ConvertCharactersToRunes(ArrayBuilder<(char ch, TextSpan span)> charResults, ImmutableSegmentedList<
VirtualChar
>.Builder runeResults)
304
runeResults.Add(
VirtualChar
.Create(rune, span));
315
runeResults.Add(
VirtualChar
.Create(rune, TextSpan.FromBounds(span.Start, nextSpan.End)));
323
runeResults.Add(
VirtualChar
.Create(ch, span));
338
public override bool TryGetEscapeCharacter(
VirtualChar
ch, out char escapedChar)
RuneExtensions.cs (1)
14
public static bool TryGetEscapeCharacter(this
VirtualChar
ch, out char escapedChar)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (5)
EmbeddedLanguages\VirtualChars\CSharpVirtualCharServiceTests.cs (5)
57
foreach (
var
ch in virtualChars)
84
foreach (
var
ch in virtualChars)
90
private static string ConvertToString(
VirtualChar
vc)
93
private static string ConvertRuneToString(
VirtualChar
c)
98
private static bool PrintAsUnicodeEscape(
VirtualChar
c)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
EmbeddedLanguages\StackFrame\StackFrameParserTests.Utilities.cs (2)
97
List<
VirtualChar
> enumeratedParsedCharacters = new();
101
foreach (
var
ch in charSeq)
Microsoft.CodeAnalysis.ExternalAccess.AspNetCore (11)
EmbeddedLanguages\AspNetCoreVirtualChar.cs (10)
14
internal readonly
VirtualChar
VirtualChar;
16
internal AspNetCoreVirtualChar(
VirtualChar
virtualChar)
31
/// <inheritdoc cref="
VirtualChar
.SurrogateChar"/>
34
/// <inheritdoc cref="
VirtualChar
.Span"/>
37
/// <inheritdoc cref="
VirtualChar
.Value"/>
40
/// <inheritdoc cref="
VirtualChar
.ToString"/>
43
/// <inheritdoc cref="
VirtualChar
.Equals(object)"/>
46
/// <inheritdoc cref="
VirtualChar
.Equals(
VirtualChar
)"/>
49
/// <inheritdoc cref="
VirtualChar
.GetHashCode"/>
EmbeddedLanguages\AspNetCoreVirtualCharSequence.cs (1)
40
public AspNetCoreVirtualChar? Find(int position) => (_virtualCharSequence.Find(position) is
VirtualChar
c) ? new(c) : null;
Microsoft.CodeAnalysis.Features (80)
EmbeddedLanguages\Classification\AbstractFallbackEmbeddedLanguageClassifier.cs (1)
46
foreach (
var
vc in virtualChars)
EmbeddedLanguages\DateAndTime\EmbeddedCompletionContext.cs (1)
62
foreach (
var
ch in virtualChars)
EmbeddedLanguages\Json\JsonLexer.cs (7)
32
public readonly
VirtualChar
CurrentChar => Text[Position];
88
var
openChar = this.CurrentChar;
94
var
currentCh = this.CurrentChar;
131
var
currentCh = this.CurrentChar;
147
var
ch = this.CurrentChar;
162
private static bool IsHexDigit(
VirtualChar
c)
176
static bool IsNotPartOfText(
VirtualChar
ch)
EmbeddedLanguages\Json\JsonParser.cs (3)
26
/// Parser used for reading in a sequence of <see cref="
VirtualChar
"/>s, and producing a <see
491
var
firstChar = token.VirtualChars[0];
544
private static bool IsDigit(
VirtualChar
ch)
EmbeddedLanguages\Json\JsonParser.JsonNetSyntaxChecks.cs (4)
69
var
firstChar = chars[0];
114
foreach (
var
vc in nameToken.VirtualChars)
156
foreach (
var
ch in textToken.VirtualChars)
165
private static bool IsLegalPropertyNameChar(
VirtualChar
ch)
EmbeddedLanguages\Json\JsonParser.StrictSyntaxChecker.cs (1)
91
foreach (
var
ch in trivia.VirtualChars)
EmbeddedLanguages\Json\LanguageServices\JsonBraceMatcher.cs (4)
64
var
ch = virtualChar.Value;
70
private static BraceMatchingResult? FindBraceHighlights(JsonTree tree,
VirtualChar
ch)
73
private static BraceMatchingResult? FindBraceMatchingResult(JsonNode node,
VirtualChar
ch)
112
private static bool Matches(JsonToken openToken, JsonToken closeToken,
VirtualChar
ch)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexBraceMatcher.cs (12)
62
var
ch = virtualChar.Value;
76
private static BraceMatchingResult? FindCommentBraces(RegexTree tree,
VirtualChar
ch)
82
var
firstChar = trivia.Value.VirtualChars[0];
83
var
lastChar = trivia.Value.VirtualChars[trivia.Value.VirtualChars.Length - 1];
89
private static BraceMatchingResult? FindGroupingBraces(RegexTree tree,
VirtualChar
ch)
95
private static BraceMatchingResult? FindCharacterClassBraces(RegexTree tree,
VirtualChar
ch)
101
private static RegexGroupingNode? FindGroupingNode(RegexNode node,
VirtualChar
ch)
105
private static RegexBaseCharacterClassNode? FindCharacterClassNode(RegexNode node,
VirtualChar
ch)
109
private static TNode? FindNode<TNode>(RegexNode node,
VirtualChar
ch, Func<TNode,
VirtualChar
, bool> predicate)
128
private static RegexTrivia? FindTrivia(RegexNode node,
VirtualChar
ch)
152
private static RegexTrivia? TryGetTrivia(ImmutableArray<RegexTrivia> triviaList,
VirtualChar
ch)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexDocumentHighlighter.cs (3)
75
var
ch = virtualChar.Value;
79
private ImmutableArray<HighlightSpan> FindReferenceHighlights(RegexTree tree,
VirtualChar
ch)
126
private RegexEscapeNode? FindReferenceNode(RegexNode node,
VirtualChar
virtualChar)
EmbeddedLanguages\RegularExpressions\LanguageServices\RegexEmbeddedCompletionProvider.cs (5)
175
var
previousVirtualChar = previousVirtualCharOpt.Value;
250
EmbeddedCompletionContext context, RegexTree tree,
VirtualChar
previousVirtualChar)
258
var
escapeChar = tree.Text[index - 1];
395
RegexNode parent,
VirtualChar
ch)
419
private static bool IsInCharacterClass(RegexNode start,
VirtualChar
ch)
EmbeddedLanguages\RegularExpressions\RegexCharClass.cs (1)
192
public static bool IsBoundaryWordChar(
VirtualChar
r)
EmbeddedLanguages\RegularExpressions\RegexHelpers.cs (11)
40
public static
VirtualChar
MapEscapeChar(
VirtualChar
ch)
43
'a' =>
VirtualChar
.Create(new Rune('\u0007'), ch.Span), // bell
44
'b' =>
VirtualChar
.Create(new Rune('\b'), ch.Span), // backspace
45
'e' =>
VirtualChar
.Create(new Rune('\u001B'), ch.Span), // escape
46
'f' =>
VirtualChar
.Create(new Rune('\f'), ch.Span), // form feed
47
'n' =>
VirtualChar
.Create(new Rune('\n'), ch.Span), // new line
48
'r' =>
VirtualChar
.Create(new Rune('\r'), ch.Span), // carriage return
49
't' =>
VirtualChar
.Create(new Rune('\t'), ch.Span), // tab
50
'v' =>
VirtualChar
.Create(new Rune('\u000B'), ch.Span), // vertical tab
58
var
ch = node.TypeToken.VirtualChars[0];
EmbeddedLanguages\RegularExpressions\RegexLexer.cs (10)
23
/// Produces tokens from the sequence of <see cref="
VirtualChar
"/> characters. Unlike the
49
public readonly
VirtualChar
CurrentChar => Position < Text.Length ? Text[Position] : default;
65
var
ch = this.CurrentChar;
71
private static RegexKind GetKind(
VirtualChar
ch)
217
private static bool IsBlank(
VirtualChar
ch)
260
private static bool IsEscapeCategoryChar(
VirtualChar
ch)
352
private static bool IsOptionChar(
VirtualChar
ch)
405
public static bool IsHexChar(
VirtualChar
ch)
410
private static bool IsDecimalDigit(
VirtualChar
ch)
413
private static bool IsOctalDigit(
VirtualChar
ch)
EmbeddedLanguages\RegularExpressions\RegexParser.CaptureInfoAnalyzer.cs (1)
142
var
lastChar = grouping.CloseParenToken.IsMissing
EmbeddedLanguages\RegularExpressions\RegexParser.cs (8)
27
/// Produces a <see cref="RegexTree"/> from a sequence of <see cref="
VirtualChar
"/> characters.
1181
foreach (
var
ch in optionsToken.VirtualChars)
1205
private static RegexOptions OptionFromCode(
VirtualChar
ch)
1410
foreach (
var
vc in hexText.VirtualChars)
1420
private static int HexValue(
VirtualChar
ch)
1485
var
nextChar = _currentToken.VirtualChars[0];
1659
var
ch = _currentToken.VirtualChars[0];
1848
var
ch = _currentToken.VirtualChars[0];
EmbeddedLanguages\StackFrame\StackFrameLexer.cs (8)
49
foreach (
var
c in text)
60
public readonly
VirtualChar
CurrentChar => Position < Text.Length ? Text[Position] : default;
91
var
ch = CurrentChar;
124
var
ch = Text[Position];
380
public static bool IsBlank(
VirtualChar
ch)
396
private static bool IsAsciiAlphaCharacter(
VirtualChar
ch)
479
private static StackFrameKind GetKind(
VirtualChar
ch)
510
private static bool IsNumber(
VirtualChar
ch)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
VisualBasicVirtualCharService.vb (1)
18
Public Overrides Function TryGetEscapeCharacter(ch As
VirtualChar
, ByRef escapedChar As Char) As Boolean
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (1)
EmbeddedLanguages\VirtualChars\VisualBasicVirtualCharServiceTests.vb (1)
90
Private Shared Function ConvertToString(vc As
VirtualChar
) As String
Microsoft.CodeAnalysis.Workspaces (90)
AbstractVirtualCharService.cs (15)
17
public abstract bool TryGetEscapeCharacter(
VirtualChar
ch, out char escapedChar);
85
var
currentVC = result[0];
98
var
nextVC = result[i];
107
var
nextVC = result[i];
113
var
lastVC = result.Last();
161
var result = ImmutableSegmentedList.CreateBuilder<
VirtualChar
>();
168
result.Add(
VirtualChar
.Create(new Rune('"'), new TextSpan(offset + index, 2)));
177
result.Add(
VirtualChar
.Create(new Rune(tokenText[index]), span));
192
protected static int ConvertTextAtIndexToRune(string tokenText, int index, ImmutableSegmentedList<
VirtualChar
>.Builder result, int offset)
195
protected static int ConvertTextAtIndexToRune(SourceText tokenText, int index, ImmutableSegmentedList<
VirtualChar
>.Builder result, int offset)
199
T tokenText, int index, TTextInfo info, ImmutableSegmentedList<
VirtualChar
>.Builder result, int offset)
207
result.Add(
VirtualChar
.Create(rune, new TextSpan(offset + index, 1)));
214
result.Add(
VirtualChar
.Create(rune, new TextSpan(offset + index, 2)));
221
result.Add(
VirtualChar
.Create(ch, new TextSpan(offset + index, 1)));
232
ImmutableSegmentedList<
VirtualChar
>.Builder result)
EmbeddedSyntaxHelpers.cs (2)
18
public static TextSpan GetSpan(
VirtualChar
firstChar,
VirtualChar
lastChar)
EmbeddedSyntaxNode.cs (1)
125
public bool Contains(
VirtualChar
virtualChar)
IVirtualCharService.cs (4)
29
/// Takes in a string token and return the <see cref="
VirtualChar
"/>s corresponding to each
50
/// VirtualChar in the result array with a matching <see cref="
VirtualChar
.Rune"/> property.
51
/// Similarly, each VirtualChar's <see cref="
VirtualChar
.Span"/> will abut each other, and
70
bool TryGetEscapeCharacter(
VirtualChar
ch, out char escapeChar);
VirtualChar.cs (31)
13
/// <see cref="
VirtualChar
"/> provides a uniform view of a language's string token characters regardless if they
17
/// (<c>\</c> and <c>t</c>). <see cref="
VirtualChar
"/> will represent both, providing the raw <see cref="char"/>
27
internal readonly struct VirtualChar : IEquatable<
VirtualChar
>, IComparable<
VirtualChar
>, IComparable<char>
30
/// The value of this <see cref="
VirtualChar
"/> as a <see cref="Rune"/> if such a representation is possible.
46
/// cref="
VirtualChar
"/>.
51
/// Creates a new <see cref="
VirtualChar
"/> from the provided <paramref name="rune"/>. This operation cannot
54
public static
VirtualChar
Create(Rune rune, TextSpan span)
58
/// Creates a new <see cref="
VirtualChar
"/> from an unpaired high or low surrogate character. This will throw
62
public static
VirtualChar
Create(char surrogateChar, TextSpan span)
101
public static bool operator ==(
VirtualChar
char1,
VirtualChar
char2)
104
public static bool operator !=(
VirtualChar
char1,
VirtualChar
char2)
107
public static bool operator ==(
VirtualChar
ch1, char ch2)
110
public static bool operator !=(
VirtualChar
ch1, char ch2)
114
=> obj is
VirtualChar
vc && Equals(vc);
116
public bool Equals(
VirtualChar
other)
158
public int CompareTo(
VirtualChar
other)
161
public static bool operator <(
VirtualChar
ch1,
VirtualChar
ch2)
164
public static bool operator <=(
VirtualChar
ch1,
VirtualChar
ch2)
167
public static bool operator >(
VirtualChar
ch1,
VirtualChar
ch2)
170
public static bool operator >=(
VirtualChar
ch1,
VirtualChar
ch2)
176
public static bool operator <(
VirtualChar
ch1, char ch2)
179
public static bool operator <=(
VirtualChar
ch1, char ch2)
182
public static bool operator >(
VirtualChar
ch1, char ch2)
185
public static bool operator >=(
VirtualChar
ch1, char ch2)
VirtualCharSequence.Chunks.cs (12)
16
/// Abstraction over a contiguous chunk of <see cref="
VirtualChar
"/>s. This
17
/// is used so we can expose <see cref="
VirtualChar
"/>s over an <see cref="ImmutableArray{VirtualChar}"/>
28
public abstract
VirtualChar
this[int index] { get; }
29
public abstract
VirtualChar
? Find(int position);
39
private readonly ImmutableSegmentedList<
VirtualChar
> _array;
41
public ImmutableSegmentedListChunk(ImmutableSegmentedList<
VirtualChar
> array)
45
public override
VirtualChar
this[int index] => _array[index];
47
public override
VirtualChar
? Find(int position)
100
public override
VirtualChar
? Find(int position)
109
public override
VirtualChar
this[int index]
126
?
VirtualChar
.Create(ch, span)
127
:
VirtualChar
.Create(new Rune(ch), span);
VirtualCharSequence.cs (23)
30
public static readonly VirtualCharSequence Empty = Create(ImmutableSegmentedList<
VirtualChar
>.Empty);
32
public static VirtualCharSequence Create(ImmutableSegmentedList<
VirtualChar
> virtualChars)
72
/// Gets the <see cref="
VirtualChar
"/> at the specified index.
74
public
VirtualChar
this[int index] => _leafCharacters[_span.Start + index];
92
public
VirtualChar
First() => this[0];
93
public
VirtualChar
Last() => this[^1];
99
public
VirtualChar
? Find(int position)
102
public bool Contains(
VirtualChar
@char)
105
public int IndexOf(
VirtualChar
@char)
108
foreach (
var
ch in this)
119
public
VirtualChar
? FirstOrNull(Func<
VirtualChar
, bool> predicate)
121
foreach (
var
ch in this)
130
public
VirtualChar
? LastOrNull(Func<
VirtualChar
, bool> predicate)
134
var
ch = this[i];
142
public bool Any(Func<
VirtualChar
, bool> predicate)
144
foreach (
var
ch in this)
153
public bool All(Func<
VirtualChar
, bool> predicate)
155
foreach (
var
ch in this)
167
public VirtualCharSequence SkipWhile(Func<
VirtualChar
, bool> predicate)
170
foreach (
var
ch in this)
187
foreach (
var
ch in this)
VirtualCharSequence.Enumerator.cs (2)
13
public struct Enumerator : IEnumerator<
VirtualChar
>
25
public readonly
VirtualChar
Current => _virtualCharSequence[_position];