• Home
  • Raw
  • Download

Lines Matching refs:node

61     scopeMap.forEach((scope, node) => {
63 if (isFunctionLikeDeclaration(node)) {
64 if (isStrictMode(node)) {
65 checkDuplicateParameter(node, recorder);
68 if (node.body) {
69 let bodyScope = <Scope>scopeMap.get(node.body);
70 let parameterNames = getParameterNames(node, recorder);
78 …if ((node.kind === ts.SyntaxKind.Block) && (node.parent != undefined && node.parent.kind === ts.Sy…
79 let catchScope = <Scope>scopeMap.get(node.parent);
89 if (ts.isFunctionDeclaration(decls[i].node) && scope instanceof ModuleScope) {
127 exportFuncMap.set(decl.name, hasExportKeywordModifier(decl.node));
129 if (exportFuncMap.get(decl.name) === true || hasExportKeywordModifier(decl.node)) {
130 …throw new DiagnosticError(decl.node, DiagnosticCode.Duplicate_identifier_0, jshelpers.getSourceFil…
142 …decl1 instanceof ConstDecl) || (decl1 instanceof ClassDecl && ts.isClassDeclaration(decl1.node)) ||
143 …ecl2 instanceof ConstDecl) || (decl2 instanceof ClassDecl && ts.isClassDeclaration(decl1.node))) &&
144 !ts.isClassExpression(decl1.node) && !ts.isClassExpression(decl2.node)) {
165 if (scope instanceof LocalScope && isStrictMode(decl1.node) || scope instanceof ModuleScope) {
167 …if (isFunctionLikeDeclaration(decl1.node.parent.parent) || isFunctionLikeDeclaration(decl2.node.pa…
200 function getParameterNames(node: ts.FunctionLikeDeclaration, recorder: Recorder): string[] {
201 let parameters = recorder.getParametersOfFunction(node);
215 function checkDuplicateParameter(node: ts.FunctionLikeDeclaration, recorder: Recorder): void {
216 let parameters = recorder.getParametersOfFunction(node);
257 if (isGlobalIdentifier(decl.name) && isDeclInGlobal(<ts.Identifier>decl.node)) {
258 let sourceNode = jshelpers.getSourceFileOfNode(decl.node);
259 …throw new DiagnosticError(decl.node, DiagnosticCode.Declaration_name_conflicts_with_built_in_globa…
264 let sourceNode = jshelpers.getSourceFileOfNode(decl.node);
265 if (decl.node.kind === ts.SyntaxKind.FunctionDeclaration) {
266 decl.node = <ts.Identifier>(<ts.FunctionDeclaration>decl.node).name;
268 …throw new DiagnosticError(decl.node, DiagnosticCode.Duplicate_identifier_0, sourceNode, [decl.name…
272 export function checkSyntaxError(node: ts.Node, scope:Scope): void {
273 checkSyntaxErrorForSloppyAndStrictMode(node);
274 if (isStrictMode(node) || CmdOptions.isModules()) {
275 checkSyntaxErrorForStrictMode(node, scope);
279 function checkBreakOrContinueStatement(node: ts.BreakOrContinueStatement): boolean {
280 let curNode: ts.Node = node;
283 …throw new DiagnosticError(node, DiagnosticCode.Jump_target_cannot_cross_function_boundary, jshelpe…
288 if (node.kind === ts.SyntaxKind.BreakStatement && !node.label) {
295 … if (node.label && (<ts.LabeledStatement>curNode).label.escapedText === node.label.escapedText) {
299 if (node.kind === ts.SyntaxKind.ContinueStatement &&
305 …throw new DiagnosticError(node, DiagnosticCode.A_continue_statement_can_only_jump_to_a_label_of_an…
314 … if (jshelpers.isIterationStatement(curNode, /*lookInLabeledStatement*/ false) && !node.label) {
327 if (node.label) {
328 if (node.kind === ts.SyntaxKind.BreakStatement) {
334 if (node.kind === ts.SyntaxKind.BreakStatement) {
341 throw new DiagnosticError(node, diagnosticCode, jshelpers.getSourceFileOfNode(node));
344 function checkReturnStatement(node: ts.ReturnStatement): void {
345 let func = jshelpers.getContainingFunction(node);
347 let file = jshelpers.getSourceFileOfNode(node);
348 …throw new DiagnosticError(node, DiagnosticCode.A_return_statement_can_only_be_used_within_a_functi…
352 function checkMetaProperty(node: ts.MetaProperty): void {
353 let text = jshelpers.getTextOfIdentifierOrLiteral(node.name);
354 let file = jshelpers.getSourceFileOfNode(node);
355 switch (node.keywordToken) {
357 let args = [text, jshelpers.tokenToString(node.keywordToken), "target"];
359 …throw new DiagnosticError(node, DiagnosticCode._0_is_not_a_valid_meta_property_for_keyword_1_Did_y…
362 let func = getContainingFunctionDeclaration(node);
364 throw new DiagnosticError(node,
368 throw new DiagnosticError(node,
371 if (ts.isArrowFunction(func) && !jshelpers.getNewTargetContainer(node)) {
372 throw new DiagnosticError(node,
380 let args = [text, jshelpers.tokenToString(node.keywordToken), "meta"];
381 …throw new DiagnosticError(node, DiagnosticCode._0_is_not_a_valid_meta_property_for_keyword_1_Did_y…
406 function checkDisallowedLetOrConstStatement(node: ts.VariableStatement): void {
407 if (allowLetAndConstDeclarations(node.parent)) {
411 if (jshelpers.isLet(node.declarationList)) {
412 …throw new DiagnosticError(node, DiagnosticCode.The_let_declarations_can_only_be_declared_inside_a_…
415 if (jshelpers.isVarConst(node.declarationList)) {
416 …throw new DiagnosticError(node, DiagnosticCode.The_const_declarations_can_only_be_declared_inside_…
420 function checkVariableDeclaration(node: ts.VariableDeclaration): void {
421 let file = jshelpers.getSourceFileOfNode(node);
422 …if (!ts.isForInStatement(node.parent.parent) && !ts.isForOfStatement(node.parent.parent) && !ts.is…
423 if (!node.initializer) {
424 if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) {
425 …throw new DiagnosticError(node, DiagnosticCode.A_destructuring_declaration_must_have_an_initialize…
428 if (jshelpers.isVarConst(node)) {
429 … throw new DiagnosticError(node, DiagnosticCode.The_const_declarations_must_be_initialized, file);
434 …if (node.exclamationToken && (node.parent.parent.kind !== ts.SyntaxKind.VariableStatement || !node
435 if (node.initializer) {
436 throw new DiagnosticError(node.exclamationToken,
439 throw new DiagnosticError(node.exclamationToken,
444 if (jshelpers.isLet(node) || jshelpers.isVarConst(node)) {
445 checkNameInLetOrConstDeclarations(node.name);
446 if (!isInBlockScope(node.parent.parent.parent) &&
447 !ts.isForInStatement(node.parent.parent) &&
448 !ts.isForOfStatement(node.parent.parent) &&
449 !ts.isForStatement(node.parent.parent)) {
450 …throw new DiagnosticError(node, DiagnosticCode.const_and_let_declarations_not_allowed_in_statement…
455 function checkDecorators(node: ts.Node): void {
456 if (!node.decorators) {
460 let file = jshelpers.getSourceFileOfNode(node);
461 if (!jshelpers.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
462 … if (ts.isMethodDeclaration(node) && !jshelpers.nodeIsPresent((<ts.MethodDeclaration>node).body)) {
463 …throw new DiagnosticError(node, DiagnosticCode.A_decorator_can_only_decorate_a_method_implementati…
465 throw new DiagnosticError(node, DiagnosticCode.Decorators_are_not_valid_here, file);
467 } else if (ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node)) {
468 …s.getAllAccessorDeclarations((<ts.ClassDeclaration>node.parent).members, <ts.AccessorDeclaration>n…
469 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
470 …throw new DiagnosticError(node, DiagnosticCode.Decorators_cannot_be_applied_to_multiple_get_Slashs…
475 function checkAsyncModifier(node: ts.Node, asyncModifier: ts.Node): void {
476 switch (node.kind) {
485 let file = jshelpers.getSourceFileOfNode(node);
489 function checkModifiers(node: ts.Node): void {
490 if (!node.modifiers) {
499 let file = jshelpers.getSourceFileOfNode(node);
501 for (let modifier of node.modifiers!) {
503 if (ts.isPropertySignature(node) || ts.isMethodSignature(node)) {
507 if (ts.isIndexSignatureDeclaration(node)) {
514 if (ts.isEnumDeclaration(node)) {
515 … throw new DiagnosticError(node, DiagnosticCode.A_class_member_cannot_have_the_0_keyword,
533 } else if (ts.isModuleBlock(node.parent) || ts.isSourceFile(node.parent)) {
541 } else if (ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
554 } else if (ts.isModuleBlock(node.parent) || ts.isSourceFile(node.parent)) {
556 } else if (ts.isParameter(node)) {
560 } else if (ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
570 } else if (!ts.isPropertyDeclaration(node) && !ts.isPropertySignature(node) &&
571 !ts.isIndexSignatureDeclaration(node) && !ts.isParameter(node)) {
589 } else if (ts.isClassLike(node.parent)) {
591 } else if (ts.isParameter(node)) {
598 let container = ts.isSourceFile(node.parent) ? node.parent : node.parent.parent;
611 } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
613 } else if (ts.isParameter(node)) {
615 } else if (ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
626 if (ts.isClassDeclaration(node) && ts.isConstructorTypeNode(node)) {
627 if (!ts.isMethodDeclaration(node) && !ts.isPropertyDeclaration(node) &&
628 !ts.isGetAccessorDeclaration(node) && !ts.isSetAccessorDeclaration(node)) {
642 let name = (<ts.NamedDeclaration>node).name;
655 } else if (ts.isParameter(node)) {
670 if (ts.isConstructorDeclaration(node)) {
681 …} else if ((ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node)) && flags & ts.Modi…
683 … if (ts.isParameter(node) && (flags & ts.ModifierFlags.ParameterPropertyModifier) && isBindingPatt…
684 …throw new DiagnosticError(node, DiagnosticCode.A_parameter_property_may_not_be_declared_using_a_bi…
685 …} else if (ts.isParameter(node) && (flags & ts.ModifierFlags.ParameterPropertyModifier) && (<ts.Pa…
686 …throw new DiagnosticError(node, DiagnosticCode.A_parameter_property_cannot_be_declared_using_a_res…
690 checkAsyncModifier(node, lastAsync!);
706 function checkVariableStatement(node: ts.VariableStatement): void {
707 checkDecorators(node);
708 checkModifiers(node);
709 checkVariableDeclarationList(node.declarationList);
710 checkDisallowedLetOrConstStatement(node);
770 function checkForInStatement(node: ts.ForInStatement): void {
771 checkForInOrForOfStatement(node);
773 let file = jshelpers.getSourceFileOfNode(node);
775 if (ts.isVariableDeclarationList(node.initializer)) {
776 checkForInOrForOfVariableDeclaration(node);
778 let varExpr = node.initializer;
795 …let node = jshelpers.skipOuterExpressions(expr, OuterExpressionKinds.ASSERTIONS | OuterExpressionK…
796 …if (node.kind !== ts.SyntaxKind.Identifier && node.kind !== ts.SyntaxKind.PropertyAccessExpression…
797 node.kind !== ts.SyntaxKind.ElementAccessExpression) {
801 if (node.flags & ts.NodeFlags.OptionalChain) {
806 function checkReferenceAssignment(node: ts.Expression): void {
810 if (ts.isSpreadAssignment(node.parent)) {
818 checkReferenceExpression(node, invalidReferenceCode, invalidOptionalChainCode);
821 function checkDestructuringAssignment(node: ts.Expression | ts.ShorthandPropertyAssignment): void {
823 if (ts.isShorthandPropertyAssignment(node)) {
824 let prop = <ts.ShorthandPropertyAssignment>node;
827 target = node;
843 function checkForOfStatement(node: ts.ForOfStatement): void {
844 checkForInOrForOfStatement(node);
846 if (ts.isVariableDeclarationList(node.initializer)) {
847 checkForInOrForOfVariableDeclaration(node);
849 let varExpr = node.initializer;
862 function checkClassDeclaration(node: ts.ClassLikeDeclaration): void {
863 checkClassDeclarationHeritageClauses(node);
865 let file = jshelpers.getSourceFileOfNode(node);
866 node.members.forEach(member => {
870 …throw new DiagnosticError(node, DiagnosticCode.Multiple_constructor_implementations_are_not_allowe…
889 if (isStatement(node.parent.kind)) {
890 …throw new DiagnosticError(node, DiagnosticCode.Class_declaration_not_allowed_in_statement_position…
895 function checkClassDeclarationHeritageClauses(node: ts.ClassLikeDeclaration): void {
897 checkDecorators(node);
898 checkModifiers(node);
899 if (node.heritageClauses === undefined) {
903 let file = jshelpers.getSourceFileOfNode(node);
904 for (let heritageClause of node.heritageClauses) {
918 function checkBinaryExpression(node: ts.BinaryExpression): void {
920 if (isAssignmentOperator(node.operatorToken.kind)) {
921 let leftExpr: ts.Expression = node.left;
926 if (node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
945 function checkContextualIdentifier(node: ts.Identifier): void {
946 if (jshelpers.isIdentifierName(node)) {
950 let file = jshelpers.getSourceFileOfNode(node);
951 if (node.originalKeywordKind === ts.SyntaxKind.AwaitKeyword) {
952 if (jshelpers.isExternalOrCommonJsModule(file) && jshelpers.isInTopLevelContext(node)) {
953 …throw new DiagnosticError(node, DiagnosticCode.Identifier_expected_0_is_a_reserved_word_at_the_top…
954 file, jshelpers.declarationNameToString(node));
955 } else if (node.flags & ts.NodeFlags.AwaitContext) {
956 …throw new DiagnosticError(node, DiagnosticCode.Identifier_expected_0_is_a_reserved_word_that_canno…
957 file, jshelpers.declarationNameToString(node));
959 …} else if (node.originalKeywordKind === ts.SyntaxKind.YieldKeyword && node.flags & ts.NodeFlags.Yi…
960 …throw new DiagnosticError(node, DiagnosticCode.Identifier_expected_0_is_a_reserved_word_that_canno…
961 file, jshelpers.declarationNameToString(node));
965 function checkComputedPropertyName(node: ts.Node): void {
966 if (!ts.isComputedPropertyName(node)) {
970 let expression = node.expression;
972 let file = jshelpers.getSourceFileOfNode(node);
986 function checkObjectLiteralExpression(node: ts.ObjectLiteralExpression): void {
987 let inDestructuring = jshelpers.isAssignmentTarget(node);
988 let file = jshelpers.getSourceFileOfNode(node);
991 for (let prop of node.properties) {
1067 function getPropertieDeclaration(node: ts.Node, name: ts.Node): any {
1069 if (ts.isShorthandPropertyAssignment(node)) {
1070 checkInvalidExclamationToken(node.exclamationToken);
1071 } else if (ts.isPropertyAssignment(node)) {
1072 checkInvalidQuestionMark(node.questionToken);
1074 } else if (ts.isMethodDeclaration(node)) {
1076 } else if (ts.isGetAccessor(node)) {
1077 checkGetAccessor(node);
1079 } else if (ts.isSetAccessor(node)) {
1082 LOGE("Unexpected syntax kind:" + node.kind);
1128 function checkArrowFunction(node: ts.Node): void {
1129 if (!ts.isArrowFunction(node)) {
1133 const { equalsGreaterThanToken } = node;
1134 let file = jshelpers.getSourceFileOfNode(node);
1142 function checkFunctionLikeDeclaration(node: ts.FunctionLikeDeclaration | ts.MethodSignature): void {
1143 checkDecorators(node);
1144 checkModifiers(node);
1145 checkParameters(node.parameters);
1146 checkArrowFunction(node);
1149 function checkLabeledStatement(node: ts.LabeledStatement): void {
1150 let file = jshelpers.getSourceFileOfNode(node);
1151 jshelpers.findAncestor(node.parent, current => {
1156 …tatement(current) && (<ts.LabeledStatement>current).label.escapedText === node.label.escapedText) {
1157 …throw new DiagnosticError(node.label, DiagnosticCode.Duplicate_label_0, file, [jshelpers.getTextOf…
1162 let statement = node.statement;
1166 …throw new DiagnosticError(node, DiagnosticCode.Lexical_declaration_let_not_allowed_in_statement_po…
1170 …throw new DiagnosticError(node, DiagnosticCode.Lexical_declaration_const_not_allowed_in_statement_…
1175 function checkGetAccessor(node: ts.GetAccessorDeclaration): void {
1176 checkFunctionLikeDeclaration(node);
1177 if (node.parameters.length != 0) {
1178 throw new DiagnosticError(node, DiagnosticCode.Getter_must_not_have_any_formal_parameters);
1182 function isValidUseSuperExpression(node: ts.Node, isCallExpression: boolean): boolean {
1183 if (!node) {
1188 return ts.isConstructorDeclaration(node);
1191 if (!ts.isClassLike(node.parent) && !ts.isObjectLiteralExpression(node.parent)) {
1195 …return ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isGetAccessor(node) || ts.…
1196 …ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isConstructorDeclaration(node
1199 function checkSuperExpression(node: ts.SuperExpression): void {
1200 let file = jshelpers.getSourceFileOfNode(node);
1202 if (ts.isCallExpression(node.parent) && (<ts.CallExpression>node.parent).expression === node) {
1206 let container = jshelpers.getSuperContainer(node, true);
1217 …let current = jshelpers.findAncestor(node, n => n === container ? "quit" : ts.isComputedPropertyNa…
1219 …throw new DiagnosticError(node, DiagnosticCode.The_super_cannot_be_referenced_in_a_computed_proper…
1221 let containerFunc = jshelpers.findAncestor(node, ts.isConstructorDeclaration);
1226 throw new DiagnosticError(node,
1231 throw new DiagnosticError(node,
1235 throw new DiagnosticError(node,
1240 function checkImportExpression(node: ts.ImportExpression): void {
1241 let args = (<ts.CallExpression>node.parent).arguments;
1243 …throw new DiagnosticError(node, DiagnosticCode.Dynamic_imports_can_only_accept_a_module_specifier_…
1248 …throw new DiagnosticError(node, DiagnosticCode.Argument_of_dynamic_import_cannot_be_spread_element…
1259 function checkThrowStatement(node: ts.ThrowStatement): void {
1260 if (ts.isIdentifier(node.expression) && (<ts.Identifier>node.expression).text === '') {
1261 …throw new DiagnosticError(node, DiagnosticCode.Line_break_not_permitted_here, jshelpers.getSourceF…
1265 function checkSyntaxErrorForSloppyAndStrictMode(node: ts.Node): void {
1266 switch (node.kind) {
1269 checkBreakOrContinueStatement(<ts.BreakOrContinueStatement>node);
1272 checkReturnStatement(<ts.ReturnStatement>node);
1275 checkComputedPropertyName(<ts.ComputedPropertyName>node);
1279 checkBindingPattern(<ts.BindingPattern>node);
1282 checkMetaProperty(<ts.MetaProperty>node);
1285 checkVariableDeclaration(<ts.VariableDeclaration>node);
1288 checkVariableStatement(<ts.VariableStatement>node);
1291 checkForInStatement(<ts.ForInStatement>node);
1294 checkForOfStatement(<ts.ForOfStatement>node);
1298 checkClassDeclaration(<ts.ClassLikeDeclaration>node);
1301 checkSuperExpression(<ts.SuperExpression>node);
1304 checkImportExpression(<ts.ImportExpression>node);
1307 checkBinaryExpression(<ts.BinaryExpression>node);
1310 checkContextualIdentifier(<ts.Identifier>node);
1313 checkObjectLiteralExpression(<ts.ObjectLiteralExpression>node);
1322 checkFunctionLikeDeclaration(<ts.FunctionLikeDeclaration | ts.MethodSignature>node);
1325 checkGetAccessor(<ts.GetAccessorDeclaration>node);
1328 checkLabeledStatement(<ts.LabeledStatement>node);
1331 checkRegularExpression(<ts.RegularExpressionLiteral>node);
1334 checkThrowStatement(<ts.ThrowStatement>node);
1453 function checkBindingPattern(node: ts.BindingPattern): void {
1454 let elements = node.elements;
1464 let file = getSourceFileOfNode(node);