MCPcopy
hub / github.com/microsoft/vscode / scanNext

Function scanNext

src/vs/base/common/json.ts:365–520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

363 }
364
365 function scanNext(): SyntaxKind {
366
367 value = '';
368 scanError = ScanError.None;
369
370 tokenOffset = pos;
371
372 if (pos >= len) {
373 // at the end
374 tokenOffset = len;
375 return token = SyntaxKind.EOF;
376 }
377
378 let code = text.charCodeAt(pos);
379 // trivia: whitespace
380 if (isWhitespace(code)) {
381 do {
382 pos++;
383 value += String.fromCharCode(code);
384 code = text.charCodeAt(pos);
385 } while (isWhitespace(code));
386
387 return token = SyntaxKind.Trivia;
388 }
389
390 // trivia: newlines
391 if (isLineBreak(code)) {
392 pos++;
393 value += String.fromCharCode(code);
394 if (code === CharacterCodes.carriageReturn && text.charCodeAt(pos) === CharacterCodes.lineFeed) {
395 pos++;
396 value += '\n';
397 }
398 return token = SyntaxKind.LineBreakTrivia;
399 }
400
401 switch (code) {
402 // tokens: []{}:,
403 case CharacterCodes.openBrace:
404 pos++;
405 return token = SyntaxKind.OpenBraceToken;
406 case CharacterCodes.closeBrace:
407 pos++;
408 return token = SyntaxKind.CloseBraceToken;
409 case CharacterCodes.openBracket:
410 pos++;
411 return token = SyntaxKind.OpenBracketToken;
412 case CharacterCodes.closeBracket:
413 pos++;
414 return token = SyntaxKind.CloseBracketToken;
415 case CharacterCodes.colon:
416 pos++;
417 return token = SyntaxKind.ColonToken;
418 case CharacterCodes.comma:
419 pos++;
420 return token = SyntaxKind.CommaToken;
421
422 // strings

Callers 8

scanNextNonTriviaFunction · 0.70
handleErrorFunction · 0.70
parseStringFunction · 0.70
parseLiteralFunction · 0.70
parsePropertyFunction · 0.70
parseObjectFunction · 0.70
parseArrayFunction · 0.70
visitFunction · 0.70

Calls 10

isWhitespaceFunction · 0.70
isLineBreakFunction · 0.70
scanStringFunction · 0.70
isDigitFunction · 0.70
scanNumberFunction · 0.70
handleErrorFunction · 0.70
substringMethod · 0.65
scanMethod · 0.65
getTokenErrorMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…