Spaces:
Sleeping
Sleeping
File size: 7,942 Bytes
cc651f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArrayExpression = isArrayExpression;
exports.isArrowFunctionExpression = isArrowFunctionExpression;
exports.isAssignmentPattern = isAssignmentPattern;
exports.isClassDeclaration = isClassDeclaration;
exports.isClassExpression = isClassExpression;
exports.isExportDefaultDeclaration = isExportDefaultDeclaration;
exports.isExpression = isExpression;
exports.isFunctionDeclaration = isFunctionDeclaration;
exports.isFunctionExpression = isFunctionExpression;
exports.isIdentifier = isIdentifier;
exports.isLiteral = isLiteral;
exports.isMethodDefinition = isMethodDefinition;
exports.isObjectExpression = isObjectExpression;
exports.isPrivateIdentifier = isPrivateIdentifier;
exports.isProperty = isProperty;
exports.isPropertyDefinition = isPropertyDefinition;
exports.isTSEnumDeclaration = isTSEnumDeclaration;
exports.isTSInterfaceDeclaration = isTSInterfaceDeclaration;
exports.isTSModuleDeclaration = isTSModuleDeclaration;
exports.isTSQualifiedName = isTSQualifiedName;
exports.isTSTypeAliasDeclaration = isTSTypeAliasDeclaration;
exports.isVariableDeclarator = isVariableDeclarator;
exports.isClassDeclarationWithName = isClassDeclarationWithName;
exports.isClassPropertyNameNonComputed = isClassPropertyNameNonComputed;
exports.isFunctionDeclarationWithName = isFunctionDeclarationWithName;
exports.isNumberLiteral = isNumberLiteral;
exports.isPropertyNameNonComputed = isPropertyNameNonComputed;
exports.isStringLiteral = isStringLiteral;
exports.isClassExpressionWithName = isClassExpressionWithName;
exports.isFunctionExpressionWithName = isFunctionExpressionWithName;
exports.isNormalAnonymousExpression = isNormalAnonymousExpression;
exports.isNormalAssignmentPattern = isNormalAssignmentPattern;
exports.isNormalClassPropertyDefinition = isNormalClassPropertyDefinition;
exports.isNormalMethodDefinition = isNormalMethodDefinition;
exports.isNormalObjectProperty = isNormalObjectProperty;
exports.isNormalVariableDeclarator = isNormalVariableDeclarator;
exports.isNormalAssignmentPatternWithAnonymousExpressionAssigned = isNormalAssignmentPatternWithAnonymousExpressionAssigned;
exports.isNormalVariableDeclaratorWithAnonymousExpressionAssigned = isNormalVariableDeclaratorWithAnonymousExpressionAssigned;
exports.isNormalObjectPropertyWithAnonymousExpressionAssigned = isNormalObjectPropertyWithAnonymousExpressionAssigned;
exports.isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned = isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned;
exports.isNodeWithName = isNodeWithName;
function isArrayExpression(node) {
return node.type === 'ArrayExpression';
}
function isArrowFunctionExpression(node) {
return node.type === 'ArrowFunctionExpression';
}
/** default parameters */
function isAssignmentPattern(node) {
return node.type === 'AssignmentPattern';
}
function isClassDeclaration(node) {
return node.type === 'ClassDeclaration';
}
function isClassExpression(node) {
return node.type === 'ClassExpression';
}
function isExportDefaultDeclaration(node) {
return node.type === 'ExportDefaultDeclaration';
}
function isExpression(node) {
return node.type.includes('Expression');
}
function isFunctionDeclaration(node) {
return node.type === 'FunctionDeclaration';
}
function isFunctionExpression(node) {
return node.type === 'FunctionExpression';
}
function isIdentifier(node) {
return node.type === 'Identifier';
}
function isLiteral(node) {
return node.type === 'Literal';
}
function isMethodDefinition(node) {
return node.type === 'MethodDefinition';
}
function isObjectExpression(node) {
return node.type === 'ObjectExpression';
}
function isPrivateIdentifier(node) {
return node.type === 'PrivateIdentifier';
}
function isProperty(node) {
return node.type === 'Property';
}
function isPropertyDefinition(node) {
return node.type === 'PropertyDefinition';
}
function isTSEnumDeclaration(node) {
return node.type === 'TSEnumDeclaration';
}
function isTSInterfaceDeclaration(node) {
return node.type === 'TSInterfaceDeclaration';
}
function isTSModuleDeclaration(node) {
return node.type === 'TSModuleDeclaration';
}
function isTSQualifiedName(node) {
return node.type === 'TSQualifiedName';
}
function isTSTypeAliasDeclaration(node) {
return node.type === 'TSTypeAliasDeclaration';
}
function isVariableDeclarator(node) {
return node.type === 'VariableDeclarator';
}
// Compound Type Guards for @typescript-eslint/types ast-spec compound types
function isClassDeclarationWithName(node) {
return isClassDeclaration(node) && node.id !== null;
}
function isClassPropertyNameNonComputed(node) {
return isPrivateIdentifier(node) || isPropertyNameNonComputed(node);
}
function isFunctionDeclarationWithName(node) {
return isFunctionDeclaration(node) && node.id !== null;
}
function isNumberLiteral(node) {
return isLiteral(node) && typeof node.value === 'number';
}
function isPropertyNameNonComputed(node) {
return isIdentifier(node) || isNumberLiteral(node) || isStringLiteral(node);
}
function isStringLiteral(node) {
return isLiteral(node) && typeof node.value === 'string';
}
function isClassExpressionWithName(node) {
return isClassExpression(node) && node.id !== null;
}
function isFunctionExpressionWithName(node) {
return isFunctionExpression(node) && node.id !== null;
}
function isNormalAnonymousExpression(node) {
const ANONYMOUS_EXPRESSION_GUARDS = [
isArrowFunctionExpression,
isClassExpression,
isFunctionExpression,
isObjectExpression
];
return ANONYMOUS_EXPRESSION_GUARDS.some((guard) => guard(node));
}
function isNormalAssignmentPattern(node) {
return isAssignmentPattern(node) && isIdentifier(node.left);
}
function isNormalClassPropertyDefinition(node) {
return (isPropertyDefinition(node) &&
(isIdentifier(node.key) || isPrivateIdentifier(node.key)) &&
node.value !== null);
}
function isNormalMethodDefinition(node) {
return isMethodDefinition(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
function isNormalObjectProperty(node) {
return isProperty(node) && (isIdentifier(node.key) || isPrivateIdentifier(node.key));
}
function isNormalVariableDeclarator(node) {
return isVariableDeclarator(node) && isIdentifier(node.id) && node.init !== null;
}
function isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) {
return isNormalAssignmentPattern(node) && isNormalAnonymousExpression(node.right);
}
function isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) {
return isNormalVariableDeclarator(node) && isNormalAnonymousExpression(node.init);
}
function isNormalObjectPropertyWithAnonymousExpressionAssigned(node) {
return isNormalObjectProperty(node) && isNormalAnonymousExpression(node.value);
}
function isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) {
return isNormalClassPropertyDefinition(node) && isNormalAnonymousExpression(node.value);
}
function isNodeWithName(node) {
return (isClassDeclarationWithName(node) ||
isFunctionDeclarationWithName(node) ||
isClassExpressionWithName(node) ||
isFunctionExpressionWithName(node) ||
isNormalVariableDeclaratorWithAnonymousExpressionAssigned(node) ||
isNormalObjectPropertyWithAnonymousExpressionAssigned(node) ||
isNormalClassPropertyDefinitionWithAnonymousExpressionAssigned(node) ||
isNormalAssignmentPatternWithAnonymousExpressionAssigned(node) ||
isNormalMethodDefinition(node) ||
isTSEnumDeclaration(node) ||
isTSInterfaceDeclaration(node) ||
isTSTypeAliasDeclaration(node));
}
//# sourceMappingURL=ast-guards.js.map |