MCPcopy Index your code
hub / github.com/nodejs/node / parseDeclarationWorker

Function parseDeclarationWorker

test/fixtures/snapshot/typescript.js:36376–36421  ·  view source on GitHub ↗
(pos, hasJSDoc, decorators, modifiers)

Source from the content-addressed store, hash-verified

36374 });
36375 }
36376 function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) {
36377 switch (token()) {
36378 case 113 /* SyntaxKind.VarKeyword */:
36379 case 119 /* SyntaxKind.LetKeyword */:
36380 case 85 /* SyntaxKind.ConstKeyword */:
36381 return parseVariableStatement(pos, hasJSDoc, decorators, modifiers);
36382 case 98 /* SyntaxKind.FunctionKeyword */:
36383 return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers);
36384 case 84 /* SyntaxKind.ClassKeyword */:
36385 return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers);
36386 case 118 /* SyntaxKind.InterfaceKeyword */:
36387 return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers);
36388 case 152 /* SyntaxKind.TypeKeyword */:
36389 return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers);
36390 case 92 /* SyntaxKind.EnumKeyword */:
36391 return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers);
36392 case 157 /* SyntaxKind.GlobalKeyword */:
36393 case 141 /* SyntaxKind.ModuleKeyword */:
36394 case 142 /* SyntaxKind.NamespaceKeyword */:
36395 return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
36396 case 100 /* SyntaxKind.ImportKeyword */:
36397 return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers);
36398 case 93 /* SyntaxKind.ExportKeyword */:
36399 nextToken();
36400 switch (token()) {
36401 case 88 /* SyntaxKind.DefaultKeyword */:
36402 case 63 /* SyntaxKind.EqualsToken */:
36403 return parseExportAssignment(pos, hasJSDoc, decorators, modifiers);
36404 case 127 /* SyntaxKind.AsKeyword */:
36405 return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers);
36406 default:
36407 return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers);
36408 }
36409 default:
36410 if (decorators || modifiers) {
36411 // We reached this point because we encountered decorators and/or modifiers and assumed a declaration
36412 // would follow. For recovery and error reporting purposes, return an incomplete declaration.
36413 var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected);
36414 ts.setTextRangePos(missing, pos);
36415 missing.decorators = decorators;
36416 missing.modifiers = modifiers;
36417 return missing;
36418 }
36419 return undefined; // TODO: GH#18217
36420 }
36421 }
36422 function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
36423 nextToken();
36424 return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */);

Callers 1

parseDeclarationFunction · 0.85

Calls 14

parseVariableStatementFunction · 0.85
parseFunctionDeclarationFunction · 0.85
parseClassDeclarationFunction · 0.85
parseEnumDeclarationFunction · 0.85
parseModuleDeclarationFunction · 0.85
nextTokenFunction · 0.85
parseExportAssignmentFunction · 0.85
parseExportDeclarationFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…