You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
22 KiB
1 line
22 KiB
2 years ago
|
{"version":3,"names":["_types","require","_parseError","PlaceholderErrors","ParseErrorEnum","ClassNameIsRequired","UnexpectedSpace","_default","superClass","PlaceholdersParserMixin","parsePlaceholder","expectedNode","match","node","startNode","next","assertNoSpace","name","parseIdentifier","expect","finishPlaceholder","isFinished","type","finishNode","getTokenFromCode","code","input","charCodeAt","state","pos","finishOp","parseExprAtom","refExpressionErrors","liberal","checkReservedWord","word","startLoc","checkKeywords","isBinding","undefined","parseBindingAtom","isValidLVal","isParenthesized","binding","toAssignable","isLHS","chStartsBindingIdentifier","ch","nextToken","lookahead","verifyBreakContinue","isBreak","label","parseExpressionStatement","expr","extra","parenthesized","stmt","body","parseStatementOrSloppyAnnexBFunctionDeclaration","semicolon","parseBlock","allowDirectives","createNewLexicalScope","afterBlockParse","parseFunctionId","requireId","parseClass","isStatement","optionalId","oldStrict","strict","placeholder","id","raise","at","parseClassId","parseClassSuper","parseClassBody","parseExport","decorators","isContextual","specifiers","source","declaration","expectPlugin","specifier","exported","isExportDefaultSpecifier","nextTokenStart","isUnparsedContextual","startsWith","tokenLabelName","nextTokenStartSince","maybeParseExportDefaultSpecifier","maybeDefaultIdentifier","_specifiers","length","checkExport","filter","parseImport","startNodeAtNode","local","push","eat","hasStarImport","maybeParseStarImportSpecifier","parseNamedImportSpecifiers","expectContextual","parseImportSource","start","lastTokEndLoc","index","exports","default"],"sources":["../../src/plugins/placeholders.ts"],"sourcesContent":["import * as charCodes from \"charcodes\";\n\nimport { tokenLabelName, tt } from \"../tokenizer/types\";\nimport type Parser from \"../parser\";\nimport type * as N from \"../types\";\nimport { ParseErrorEnum } from \"../parse-error\";\nimport type { Undone } from \"../parser/node\";\nimport type { ExpressionErrors } from \"../parser/util\";\nimport type { BindingTypes } from \"../util/scopeflags\";\nimport type { Position } from \"../util/location\";\n\ntype PossiblePlaceholders = {\n Identifier: N.Identifier;\n StringLiteral: N.StringLiteral;\n Expression: N.Expression;\n Statement: N.Statement;\n Declaration: N.Declaration;\n BlockStatement: N.BlockStatement;\n ClassBody: N.ClassBody;\n Pattern: N.Pattern;\n};\nexport type PlaceholderTypes = keyof PossiblePlaceholders;\n\ntype NodeOf<T extends keyof PossiblePlaceholders> = PossiblePlaceholders[T];\n// todo: when there is proper union type for Node\n// type NodeOf<T extends PlaceholderTypes> = Extract<N.Node, { type: T }>;\n\n// todo: Placeholder<T> breaks everything, because its type is incompatible with\n// the substituted nodes.\ntype MaybePlaceholder<T extends PlaceholderTypes> = NodeOf<T>; // | Placeholder<T>\n\n/* eslint sort-keys: \"error\" */\nconst PlaceholderErrors = ParseErrorEnum`placeholders`({\n ClassNameIsRequired: \"A class name is required.\",\n UnexpectedSpace: \"Unexpected space in placeholder.\",\n});\n\n/* eslint-disable sort-keys */\n\nexport default (superClass: typeof Parser) =>\n class PlaceholdersParserMixin extends superClass implements Parser {\n parsePlaceholder<T extends PlaceholderTypes>(\n expectedNode: T,\n ): /*?N.Placeholder<T>*/ MaybePlaceholder<T> | undefined | null {\n if (this.match(tt.placeholder)) {\n const node = this.startNode();\n this.next();\n this.assertNoSpace();\n\n // We can't use this.parseIdentifier because\n // we don't want nested placeholders.\n node.name = super.parseIdentifier(/* liberal */ true);\n\n this.assertNoSpace();\n this.expect(tt.placeholder);\n // @ts-expect-error placeholder typings\n return this.finishPlaceholder(node, expectedNode);\n }\n }\n\n finishPlaceholder<T extends PlaceholderTypes>(\n node: N.Node,\n expectedNode: T,\n ): /*N.Placeholder<T>*/ MaybePlaceholder<T> {
|