157 references to JsonKind
Microsoft.CodeAnalysis.Features (157)
EmbeddedLanguages\Json\JsonHelpers.cs (8)
11
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
12
using JsonTrivia = EmbeddedSyntaxTrivia<
JsonKind
>;
17
JsonKind
kind, ImmutableArray<JsonTrivia> leadingTrivia,
21
public static JsonToken CreateToken(
JsonKind
kind,
26
public static JsonToken CreateMissingToken(
JsonKind
kind)
29
public static JsonTrivia CreateTrivia(
JsonKind
kind, VirtualCharSequence virtualChars)
32
public static JsonTrivia CreateTrivia(
JsonKind
kind, VirtualCharSequence virtualChars, EmbeddedDiagnostic diagnostic)
35
public static JsonTrivia CreateTrivia(
JsonKind
kind, VirtualCharSequence virtualChars, ImmutableArray<EmbeddedDiagnostic> diagnostics)
EmbeddedLanguages\Json\JsonLexer.cs (27)
18
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
19
using JsonTrivia = EmbeddedSyntaxTrivia<
JsonKind
>;
46
JsonKind
.EndOfFile, leadingTrivia,
61
private (VirtualCharSequence,
JsonKind
, EmbeddedDiagnostic? diagnostic) ScanNextTokenWorker()
66
'{' => ScanSingleCharToken(
JsonKind
.OpenBraceToken),
67
'}' => ScanSingleCharToken(
JsonKind
.CloseBraceToken),
68
'[' => ScanSingleCharToken(
JsonKind
.OpenBracketToken),
69
']' => ScanSingleCharToken(
JsonKind
.CloseBracketToken),
70
'(' => ScanSingleCharToken(
JsonKind
.OpenParenToken),
71
')' => ScanSingleCharToken(
JsonKind
.CloseParenToken),
72
',' => ScanSingleCharToken(
JsonKind
.CommaToken),
73
':' => ScanSingleCharToken(
JsonKind
.ColonToken),
85
private (VirtualCharSequence,
JsonKind
, EmbeddedDiagnostic?) ScanString()
102
return (GetCharsToCurrentPosition(start),
JsonKind
.StringToken, diagnostic);
116
return (chars,
JsonKind
.StringToken, diagnostic);
167
private (VirtualCharSequence,
JsonKind
, EmbeddedDiagnostic?) ScanText()
174
return (GetCharsToCurrentPosition(start),
JsonKind
.TextToken, null);
188
private (VirtualCharSequence,
JsonKind
, EmbeddedDiagnostic?) ScanSingleCharToken(
JsonKind
kind)
242
return CreateTrivia(
JsonKind
.EndOfLineTrivia, GetCharsToCurrentPosition(start));
247
return CreateTrivia(
JsonKind
.EndOfLineTrivia, GetCharsToCurrentPosition(start));
269
return CreateTrivia(
JsonKind
.SingleLineCommentTrivia, chars,
290
return CreateTrivia(
JsonKind
.SingleLineCommentTrivia, chars,
294
return CreateTrivia(
JsonKind
.SingleLineCommentTrivia, chars);
309
return CreateTrivia(
JsonKind
.MultiLineCommentTrivia, GetCharsToCurrentPosition(start));
313
return CreateTrivia(
JsonKind
.MultiLineCommentTrivia, GetCharsToCurrentPosition(start),
341
return CreateTrivia(
JsonKind
.WhitespaceTrivia, GetCharsToCurrentPosition(start));
EmbeddedLanguages\Json\JsonNode.cs (2)
9
internal abstract class JsonNode : EmbeddedSyntaxNode<
JsonKind
, JsonNode>
11
protected JsonNode(
JsonKind
kind) : base(kind)
EmbeddedLanguages\Json\JsonNodes.cs (17)
12
using JsonNodeOrToken = EmbeddedSyntaxNodeOrToken<
JsonKind
, JsonNode>;
13
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
14
using JsonSeparatedList = EmbeddedSeparatedSyntaxNodeList<
JsonKind
, JsonNode, JsonValueNode>;
19
: base(
JsonKind
.CompilationUnit)
22
Debug.Assert(endOfFileToken.Kind ==
JsonKind
.EndOfFile);
53
protected JsonValueNode(
JsonKind
kind)
66
: base(
JsonKind
.Text)
68
Debug.Assert(textToken.Kind ==
JsonKind
.TextToken);
93
: base(
JsonKind
.Object)
95
Debug.Assert(openBraceToken.Kind ==
JsonKind
.OpenBraceToken);
96
Debug.Assert(closeBraceToken.Kind ==
JsonKind
.CloseBraceToken);
130
: base(
JsonKind
.Array)
132
Debug.Assert(openBracketToken.Kind ==
JsonKind
.OpenBracketToken);
134
Debug.Assert(closeBracketToken.Kind ==
JsonKind
.CloseBracketToken);
165
: base(
JsonKind
.NegativeLiteral)
167
Debug.Assert(minusToken.Kind ==
JsonKind
.MinusToken);
189
internal sealed class JsonLiteralNode(JsonToken literalToken) : JsonValueNode(
JsonKind
.Literal)
EmbeddedLanguages\Json\JsonParser.cs (53)
20
using JsonNodeOrToken = EmbeddedSyntaxNodeOrToken<
JsonKind
, JsonNode>;
21
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
22
using JsonTrivia = EmbeddedSyntaxTrivia<
JsonKind
>;
23
using JsonSeparatedList = EmbeddedSeparatedSyntaxNodeList<
JsonKind
, JsonNode, JsonValueNode>;
125
Debug.Assert(_currentToken.Kind ==
JsonKind
.EndOfFile);
173
t => t.Kind is
JsonKind
.WhitespaceTrivia or
JsonKind
.EndOfLineTrivia))
193
if (child.Kind ==
JsonKind
.CommaValue)
200
else if (child.Kind ==
JsonKind
.Property)
215
JsonKind
.Array => CheckArray((JsonArrayNode)node),
216
JsonKind
.Object => CheckObject((JsonObjectNode)node),
242
if (child.Kind ==
JsonKind
.Property)
257
if (child is JsonLiteralNode { LiteralToken.Kind:
JsonKind
.StringToken })
349
allProperties = allProperties && value.Kind ==
JsonKind
.Property;
357
result.Add(ConsumeToken(
JsonKind
.CommaToken, allProperties ? s_commaExpected : null));
366
JsonKind
.EndOfFile => false,
367
JsonKind
.CloseBraceToken => !_inObject,
368
JsonKind
.CloseBracketToken => !_inArray,
369
JsonKind
.CloseParenToken => !_inConstructor,
382
JsonKind
.OpenBraceToken => ParseObject(),
383
JsonKind
.OpenBracketToken => ParseArray(),
384
JsonKind
.CommaToken => ParseCommaValue(),
397
JsonKind
.MinusToken, literalToken.LeadingTrivia,
410
Debug.Assert(_currentToken.Kind ==
JsonKind
.ColonToken);
413
if (stringLiteralOrText.Kind !=
JsonKind
.StringToken)
414
stringLiteralOrText = stringLiteralOrText.With(kind:
JsonKind
.TextToken);
421
if (_currentToken.Kind ==
JsonKind
.CommaToken)
425
new JsonCommaValueNode(CreateMissingToken(
JsonKind
.CommaToken)));
427
else if (_currentToken.Kind ==
JsonKind
.EndOfFile)
431
new JsonCommaValueNode(CreateMissingToken(
JsonKind
.CommaToken).AddDiagnosticIfNone(new EmbeddedDiagnostic(
437
if (value.Kind ==
JsonKind
.Property)
455
return _currentToken.Kind ==
JsonKind
.ColonToken
462
if (token.Kind ==
JsonKind
.StringToken)
473
if (TryMatch(token, "NaN",
JsonKind
.NaNLiteralToken, out
var
newKind) ||
474
TryMatch(token, "null",
JsonKind
.NullLiteralToken, out newKind) ||
475
TryMatch(token, "true",
JsonKind
.TrueLiteralToken, out newKind) ||
476
TryMatch(token, "false",
JsonKind
.FalseLiteralToken, out newKind) ||
477
TryMatch(token, "Infinity",
JsonKind
.InfinityLiteralToken, out newKind) ||
478
TryMatch(token, "undefined",
JsonKind
.UndefinedLiteralToken, out newKind))
488
minusToken, newLiteralToken.With(kind:
JsonKind
.InfinityLiteralToken));
493
return new JsonLiteralNode(token.With(kind:
JsonKind
.NumberToken));
496
token.With(kind:
JsonKind
.TextToken).AddDiagnosticIfNone(new EmbeddedDiagnostic(
507
token.With(kind:
JsonKind
.NewKeyword),
508
ConsumeToken(
JsonKind
.TextToken, FeaturesResources.Name_expected),
509
ConsumeToken(
JsonKind
.OpenParenToken, s_openParenExpected),
511
ConsumeToken(
JsonKind
.CloseParenToken, s_closeParenExpected));
517
private static bool TryMatch(JsonToken token, string val,
JsonKind
kind, out
JsonKind
newKind)
558
ConsumeToken(
JsonKind
.CloseBracketToken, s_closeBracketExpected));
572
ConsumeToken(
JsonKind
.CloseBraceToken, s_closeBraceExpected));
578
private JsonToken ConsumeToken(
JsonKind
kind, string? error)
591
=> token.Kind ==
JsonKind
.EndOfFile
EmbeddedLanguages\Json\JsonParser.JsonNetSyntaxChecks.cs (13)
15
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
25
JsonKind
.Array => CheckArray((JsonArrayNode)node),
26
JsonKind
.Object => CheckObject((JsonObjectNode)node),
27
JsonKind
.Constructor => CheckConstructor((JsonConstructorNode)node),
28
JsonKind
.Property => CheckProperty((JsonPropertyNode)node),
29
JsonKind
.Literal => CheckLiteral((JsonLiteralNode)node),
30
JsonKind
.NegativeLiteral => CheckNegativeLiteral((JsonNegativeLiteralNode)node),
53
=> node.LiteralToken.Kind ==
JsonKind
.NumberToken
58
=> node.LiteralToken.Kind ==
JsonKind
.NumberToken
167
if (child.Kind !=
JsonKind
.CommaValue && nextChild.Kind !=
JsonKind
.CommaValue)
178
if (child.Kind !=
JsonKind
.Property)
186
=> node.NameToken.Kind !=
JsonKind
.StringToken && !IsLegalPropertyNameText(node.NameToken)
EmbeddedLanguages\Json\JsonParser.StrictSyntaxChecker.cs (21)
14
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
15
using JsonTrivia = EmbeddedSyntaxTrivia<
JsonKind
>;
37
JsonKind
.Constructor => CheckConstructor((JsonConstructorNode)node),
38
JsonKind
.Literal => CheckLiteral((JsonLiteralNode)node, allowComments),
39
JsonKind
.NegativeLiteral => CheckNegativeLiteral((JsonNegativeLiteralNode)node),
40
JsonKind
.Property => CheckProperty((JsonPropertyNode)node, allowComments),
41
JsonKind
.Array => CheckArray((JsonArrayNode)node, allowTrailingCommas),
42
JsonKind
.Object => CheckObject((JsonObjectNode)node, allowTrailingCommas),
83
JsonKind
.MultiLineCommentTrivia or
JsonKind
.SingleLineCommentTrivia when !allowComments
85
JsonKind
.WhitespaceTrivia => CheckWhitespace(trivia),
113
if (child.Kind !=
JsonKind
.Property)
136
if (child.Kind ==
JsonKind
.CommaValue)
141
if (child.Kind !=
JsonKind
.CommaValue)
154
if (node.NameToken.Kind !=
JsonKind
.StringToken)
157
if (node.Value.Kind ==
JsonKind
.CommaValue)
167
JsonKind
.NaNLiteralToken or
JsonKind
.InfinityLiteralToken or
JsonKind
.UndefinedLiteralToken
169
JsonKind
.NumberToken => CheckNumber(node.LiteralToken, allowComments),
170
JsonKind
.StringToken => CheckString(node.LiteralToken, allowComments),
EmbeddedLanguages\Json\JsonTree.cs (1)
14
ImmutableArray<EmbeddedDiagnostic> diagnostics) : EmbeddedSyntaxTree<
JsonKind
, JsonNode, JsonCompilationUnit>(text, root, diagnostics)
EmbeddedLanguages\Json\LanguageServices\JsonBraceMatcher.cs (1)
17
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
EmbeddedLanguages\Json\LanguageServices\JsonClassifier.cs (13)
18
using JsonToken = EmbeddedSyntaxToken<
JsonKind
>;
19
using JsonTrivia = EmbeddedSyntaxTrivia<
JsonKind
>;
97
case
JsonKind
.CommaToken:
109
if (trivia.Kind is
JsonKind
.MultiLineCommentTrivia or
JsonKind
.SingleLineCommentTrivia &&
164
case
JsonKind
.NumberToken:
168
case
JsonKind
.StringToken:
172
case
JsonKind
.TrueLiteralToken:
173
case
JsonKind
.FalseLiteralToken:
174
case
JsonKind
.NullLiteralToken:
175
case
JsonKind
.UndefinedLiteralToken:
176
case
JsonKind
.NaNLiteralToken:
177
case
JsonKind
.InfinityLiteralToken:
EmbeddedLanguages\Json\LanguageServices\JsonLanguageDetector.cs (1)
106
if (node.Kind ==
JsonKind
.Object)