How to use ast method in stryker-parent

Best JavaScript code snippet using stryker-parent

predicates.d.ts

Source:predicates.d.ts Github

copy

Full Screen

1import { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree } from '../ts-estree';2declare const isOptionalChainPunctuator: (token: TSESTree.Token | null | undefined) => token is TSESTree.PunctuatorToken & {3 type: AST_TOKEN_TYPES.Punctuator;4} & {5 value: "?.";6};7declare const isNotOptionalChainPunctuator: (token: TSESTree.Token | null | undefined) => token is TSESTree.BooleanToken | TSESTree.BlockComment | TSESTree.LineComment | TSESTree.IdentifierToken | TSESTree.JSXIdentifierToken | TSESTree.JSXTextToken | TSESTree.KeywordToken | TSESTree.NullToken | TSESTree.NumericToken | TSESTree.PunctuatorToken | TSESTree.RegularExpressionToken | TSESTree.StringToken | TSESTree.TemplateToken;8declare const isNonNullAssertionPunctuator: (token: TSESTree.Token | null | undefined) => token is TSESTree.PunctuatorToken & {9 type: AST_TOKEN_TYPES.Punctuator;10} & {11 value: "!";12};13declare const isNotNonNullAssertionPunctuator: (token: TSESTree.Token | null | undefined) => token is TSESTree.BooleanToken | TSESTree.BlockComment | TSESTree.LineComment | TSESTree.IdentifierToken | TSESTree.JSXIdentifierToken | TSESTree.JSXTextToken | TSESTree.KeywordToken | TSESTree.NullToken | TSESTree.NumericToken | TSESTree.PunctuatorToken | TSESTree.RegularExpressionToken | TSESTree.StringToken | TSESTree.TemplateToken;14/**15 * Returns true if and only if the node represents: foo?.() or foo.bar?.()16 */17declare const isOptionalCallExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.CallExpression & {18 type: AST_NODE_TYPES.CallExpression;19} & {20 optional: true;21};22/**23 * Returns true if and only if the node represents logical OR24 */25declare const isLogicalOrOperator: (node: TSESTree.Node | null | undefined) => node is TSESTree.LogicalExpression & {26 type: AST_NODE_TYPES.LogicalExpression;27} & {28 operator: "||";29};30/**31 * Checks if a node is a type assertion:32 * ```33 * x as foo34 * <foo>x35 * ```36 */37declare const isTypeAssertion: (node: TSESTree.Node | null | undefined) => node is (TSESTree.TSAsExpression & {38 type: AST_NODE_TYPES.TSAsExpression | AST_NODE_TYPES.TSTypeAssertion;39}) | (TSESTree.TSTypeAssertion & {40 type: AST_NODE_TYPES.TSAsExpression | AST_NODE_TYPES.TSTypeAssertion;41});42declare const isVariableDeclarator: (node: TSESTree.Node | null | undefined) => node is TSESTree.VariableDeclarator & {43 type: AST_NODE_TYPES.VariableDeclarator;44};45declare const isFunction: (node: TSESTree.Node | null | undefined) => node is (TSESTree.ArrowFunctionExpression & {46 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;47}) | (TSESTree.FunctionDeclarationWithName & {48 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;49}) | (TSESTree.FunctionDeclarationWithOptionalName & {50 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;51}) | (TSESTree.FunctionExpression & {52 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression;53});54declare const isFunctionType: (node: TSESTree.Node | null | undefined) => node is (TSESTree.TSCallSignatureDeclaration & {55 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;56}) | (TSESTree.TSConstructorType & {57 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;58}) | (TSESTree.TSConstructSignatureDeclaration & {59 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;60}) | (TSESTree.TSEmptyBodyFunctionExpression & {61 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;62}) | (TSESTree.TSFunctionType & {63 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;64}) | (TSESTree.TSMethodSignatureComputedName & {65 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;66}) | (TSESTree.TSMethodSignatureNonComputedName & {67 type: AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;68});69declare const isFunctionOrFunctionType: (node: TSESTree.Node | null | undefined) => node is (TSESTree.ArrowFunctionExpression & {70 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;71}) | (TSESTree.FunctionDeclarationWithName & {72 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;73}) | (TSESTree.FunctionDeclarationWithOptionalName & {74 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;75}) | (TSESTree.FunctionExpression & {76 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;77}) | (TSESTree.TSCallSignatureDeclaration & {78 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;79}) | (TSESTree.TSConstructorType & {80 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;81}) | (TSESTree.TSConstructSignatureDeclaration & {82 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;83}) | (TSESTree.TSEmptyBodyFunctionExpression & {84 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;85}) | (TSESTree.TSFunctionType & {86 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;87}) | (TSESTree.TSMethodSignatureComputedName & {88 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;89}) | (TSESTree.TSMethodSignatureNonComputedName & {90 type: AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.FunctionDeclaration | AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructorType | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSFunctionType | AST_NODE_TYPES.TSMethodSignature;91});92declare const isTSFunctionType: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSFunctionType & {93 type: AST_NODE_TYPES.TSFunctionType;94};95declare const isTSConstructorType: (node: TSESTree.Node | null | undefined) => node is TSESTree.TSConstructorType & {96 type: AST_NODE_TYPES.TSConstructorType;97};98declare const isClassOrTypeElement: (node: TSESTree.Node | null | undefined) => node is (TSESTree.FunctionExpression & {99 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;100}) | (TSESTree.MethodDefinitionComputedName & {101 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;102}) | (TSESTree.MethodDefinitionNonComputedName & {103 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;104}) | (TSESTree.PropertyDefinitionComputedName & {105 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;106}) | (TSESTree.PropertyDefinitionNonComputedName & {107 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;108}) | (TSESTree.TSAbstractMethodDefinitionComputedName & {109 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;110}) | (TSESTree.TSAbstractMethodDefinitionNonComputedName & {111 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;112}) | (TSESTree.TSAbstractPropertyDefinitionComputedName & {113 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;114}) | (TSESTree.TSAbstractPropertyDefinitionNonComputedName & {115 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;116}) | (TSESTree.TSCallSignatureDeclaration & {117 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;118}) | (TSESTree.TSConstructSignatureDeclaration & {119 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;120}) | (TSESTree.TSEmptyBodyFunctionExpression & {121 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;122}) | (TSESTree.TSIndexSignature & {123 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;124}) | (TSESTree.TSMethodSignatureComputedName & {125 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;126}) | (TSESTree.TSMethodSignatureNonComputedName & {127 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;128}) | (TSESTree.TSPropertySignatureComputedName & {129 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;130}) | (TSESTree.TSPropertySignatureNonComputedName & {131 type: AST_NODE_TYPES.FunctionExpression | AST_NODE_TYPES.MethodDefinition | AST_NODE_TYPES.PropertyDefinition | AST_NODE_TYPES.TSAbstractMethodDefinition | AST_NODE_TYPES.TSAbstractPropertyDefinition | AST_NODE_TYPES.TSCallSignatureDeclaration | AST_NODE_TYPES.TSConstructSignatureDeclaration | AST_NODE_TYPES.TSEmptyBodyFunctionExpression | AST_NODE_TYPES.TSIndexSignature | AST_NODE_TYPES.TSMethodSignature | AST_NODE_TYPES.TSPropertySignature;132});133/**134 * Checks if a node is a constructor method.135 */136declare const isConstructor: (node: TSESTree.Node | null | undefined) => node is (TSESTree.MethodDefinitionComputedName & {137 type: AST_NODE_TYPES.MethodDefinition;138} & {139 kind: "constructor";140}) | (TSESTree.MethodDefinitionNonComputedName & {141 type: AST_NODE_TYPES.MethodDefinition;142} & {143 kind: "constructor";144});145/**146 * Checks if a node is a setter method.147 */148declare function isSetter(node: TSESTree.Node | undefined): node is (TSESTree.MethodDefinition | TSESTree.Property) & {149 kind: 'set';150};151declare const isIdentifier: (node: TSESTree.Node | null | undefined) => node is TSESTree.Identifier & {152 type: AST_NODE_TYPES.Identifier;153};154/**155 * Checks if a node represents an `await …` expression.156 */157declare const isAwaitExpression: (node: TSESTree.Node | null | undefined) => node is TSESTree.AwaitExpression & {158 type: AST_NODE_TYPES.AwaitExpression;159};160/**161 * Checks if a possible token is the `await` keyword.162 */163declare const isAwaitKeyword: (token: TSESTree.Token | null | undefined) => token is TSESTree.IdentifierToken & {164 type: AST_TOKEN_TYPES.Identifier;165} & {166 value: "await";167};168declare const isLoop: (node: TSESTree.Node | null | undefined) => node is (TSESTree.DoWhileStatement & {169 type: AST_NODE_TYPES.DoWhileStatement | AST_NODE_TYPES.ForInStatement | AST_NODE_TYPES.ForOfStatement | AST_NODE_TYPES.ForStatement | AST_NODE_TYPES.WhileStatement;170}) | (TSESTree.ForInStatement & {171 type: AST_NODE_TYPES.DoWhileStatement | AST_NODE_TYPES.ForInStatement | AST_NODE_TYPES.ForOfStatement | AST_NODE_TYPES.ForStatement | AST_NODE_TYPES.WhileStatement;172}) | (TSESTree.ForOfStatement & {173 type: AST_NODE_TYPES.DoWhileStatement | AST_NODE_TYPES.ForInStatement | AST_NODE_TYPES.ForOfStatement | AST_NODE_TYPES.ForStatement | AST_NODE_TYPES.WhileStatement;174}) | (TSESTree.ForStatement & {175 type: AST_NODE_TYPES.DoWhileStatement | AST_NODE_TYPES.ForInStatement | AST_NODE_TYPES.ForOfStatement | AST_NODE_TYPES.ForStatement | AST_NODE_TYPES.WhileStatement;176}) | (TSESTree.WhileStatement & {177 type: AST_NODE_TYPES.DoWhileStatement | AST_NODE_TYPES.ForInStatement | AST_NODE_TYPES.ForOfStatement | AST_NODE_TYPES.ForStatement | AST_NODE_TYPES.WhileStatement;178});179export { isAwaitExpression, isAwaitKeyword, isConstructor, isClassOrTypeElement, isFunction, isFunctionOrFunctionType, isFunctionType, isIdentifier, isLoop, isLogicalOrOperator, isNonNullAssertionPunctuator, isNotNonNullAssertionPunctuator, isNotOptionalChainPunctuator, isOptionalChainPunctuator, isOptionalCallExpression, isSetter, isTSConstructorType, isTSFunctionType, isTypeAssertion, isVariableDeclarator, }; ...

Full Screen

Full Screen

size.js

Source:size.js Github

copy

Full Screen

1import {2 AST_Accessor,3 AST_Array,4 AST_Arrow,5 AST_Await,6 AST_BigInt,7 AST_Binary,8 AST_Block,9 AST_Break,10 AST_Call,11 AST_Case,12 AST_Class,13 AST_ClassPrivateProperty,14 AST_ClassProperty,15 AST_ConciseMethod,16 AST_Conditional,17 AST_Const,18 AST_Continue,19 AST_Debugger,20 AST_Default,21 AST_Defun,22 AST_Destructuring,23 AST_Directive,24 AST_Do,25 AST_Dot,26 AST_DotHash,27 AST_EmptyStatement,28 AST_Expansion,29 AST_Export,30 AST_False,31 AST_For,32 AST_ForIn,33 AST_Function,34 AST_Hole,35 AST_If,36 AST_Import,37 AST_ImportMeta,38 AST_Infinity,39 AST_LabeledStatement,40 AST_Let,41 AST_NameMapping,42 AST_NaN,43 AST_New,44 AST_NewTarget,45 AST_Node,46 AST_Null,47 AST_Number,48 AST_Object,49 AST_ObjectKeyVal,50 AST_ObjectGetter,51 AST_ObjectSetter,52 AST_PrivateGetter,53 AST_PrivateMethod,54 AST_PrivateSetter,55 AST_RegExp,56 AST_Return,57 AST_Sequence,58 AST_String,59 AST_Sub,60 AST_Super,61 AST_Switch,62 AST_Symbol,63 AST_SymbolClassProperty,64 AST_SymbolExportForeign,65 AST_SymbolImportForeign,66 AST_SymbolRef,67 AST_SymbolDeclaration,68 AST_TemplateSegment,69 AST_TemplateString,70 AST_This,71 AST_Throw,72 AST_Toplevel,73 AST_True,74 AST_Try,75 AST_Catch,76 AST_Finally,77 AST_Unary,78 AST_Undefined,79 AST_Var,80 AST_VarDef,81 AST_While,82 AST_With,83 AST_Yield,84 walk_parent85} from "./ast.js";86import { first_in_statement } from "./utils/first_in_statement.js";87let mangle_options = undefined;88AST_Node.prototype.size = function (compressor, stack) {89 mangle_options = compressor && compressor.mangle_options;90 let size = 0;91 walk_parent(this, (node, info) => {92 size += node._size(info);93 // Braceless arrow functions have fake "return" statements94 if (node instanceof AST_Arrow && node.is_braceless()) {95 size += node.body[0].value._size(info);96 return true;97 }98 }, stack || (compressor && compressor.stack));99 // just to save a bit of memory100 mangle_options = undefined;101 return size;102};103AST_Node.prototype._size = () => 0;104AST_Debugger.prototype._size = () => 8;105AST_Directive.prototype._size = function () {106 // TODO string encoding stuff107 return 2 + this.value.length;108};109/** Count commas/semicolons necessary to show a list of expressions/statements */110const list_overhead = (array) => array.length && array.length - 1;111AST_Block.prototype._size = function () {112 return 2 + list_overhead(this.body);113};114AST_Toplevel.prototype._size = function() {115 return list_overhead(this.body);116};117AST_EmptyStatement.prototype._size = () => 1;118AST_LabeledStatement.prototype._size = () => 2; // x:119AST_Do.prototype._size = () => 9;120AST_While.prototype._size = () => 7;121AST_For.prototype._size = () => 8;122AST_ForIn.prototype._size = () => 8;123// AST_ForOf inherits ^124AST_With.prototype._size = () => 6;125AST_Expansion.prototype._size = () => 3;126const lambda_modifiers = func =>127 (func.is_generator ? 1 : 0) + (func.async ? 6 : 0);128AST_Accessor.prototype._size = function () {129 return lambda_modifiers(this) + 4 + list_overhead(this.argnames) + list_overhead(this.body);130};131AST_Function.prototype._size = function (info) {132 const first = !!first_in_statement(info);133 return (first * 2) + lambda_modifiers(this) + 12 + list_overhead(this.argnames) + list_overhead(this.body);134};135AST_Defun.prototype._size = function () {136 return lambda_modifiers(this) + 13 + list_overhead(this.argnames) + list_overhead(this.body);137};138AST_Arrow.prototype._size = function () {139 let args_and_arrow = 2 + list_overhead(this.argnames);140 if (141 !(142 this.argnames.length === 1143 && this.argnames[0] instanceof AST_Symbol144 )145 ) {146 args_and_arrow += 2; // parens around the args147 }148 const body_overhead = this.is_braceless() ? 0 : list_overhead(this.body) + 2;149 return lambda_modifiers(this) + args_and_arrow + body_overhead;150};151AST_Destructuring.prototype._size = () => 2;152AST_TemplateString.prototype._size = function () {153 return 2 + (Math.floor(this.segments.length / 2) * 3); /* "${}" */154};155AST_TemplateSegment.prototype._size = function () {156 return this.value.length;157};158AST_Return.prototype._size = function () {159 return this.value ? 7 : 6;160};161AST_Throw.prototype._size = () => 6;162AST_Break.prototype._size = function () {163 return this.label ? 6 : 5;164};165AST_Continue.prototype._size = function () {166 return this.label ? 9 : 8;167};168AST_If.prototype._size = () => 4;169AST_Switch.prototype._size = function () {170 return 8 + list_overhead(this.body);171};172AST_Case.prototype._size = function () {173 return 5 + list_overhead(this.body);174};175AST_Default.prototype._size = function () {176 return 8 + list_overhead(this.body);177};178AST_Try.prototype._size = function () {179 return 3 + list_overhead(this.body);180};181AST_Catch.prototype._size = function () {182 let size = 7 + list_overhead(this.body);183 if (this.argname) {184 size += 2;185 }186 return size;187};188AST_Finally.prototype._size = function () {189 return 7 + list_overhead(this.body);190};191AST_Var.prototype._size = function () {192 return 4 + list_overhead(this.definitions);193};194AST_Let.prototype._size = function () {195 return 4 + list_overhead(this.definitions);196};197AST_Const.prototype._size = function () {198 return 6 + list_overhead(this.definitions);199};200AST_VarDef.prototype._size = function () {201 return this.value ? 1 : 0;202};203AST_NameMapping.prototype._size = function () {204 // foreign name isn't mangled205 return this.name ? 4 : 0;206};207AST_Import.prototype._size = function () {208 // import209 let size = 6;210 if (this.imported_name) size += 1;211 // from212 if (this.imported_name || this.imported_names) size += 5;213 // braces, and the commas214 if (this.imported_names) {215 size += 2 + list_overhead(this.imported_names);216 }217 return size;218};219AST_ImportMeta.prototype._size = () => 11;220AST_Export.prototype._size = function () {221 let size = 7 + (this.is_default ? 8 : 0);222 if (this.exported_value) {223 size += this.exported_value._size();224 }225 if (this.exported_names) {226 // Braces and commas227 size += 2 + list_overhead(this.exported_names);228 }229 if (this.module_name) {230 // "from "231 size += 5;232 }233 return size;234};235AST_Call.prototype._size = function () {236 if (this.optional) {237 return 4 + list_overhead(this.args);238 }239 return 2 + list_overhead(this.args);240};241AST_New.prototype._size = function () {242 return 6 + list_overhead(this.args);243};244AST_Sequence.prototype._size = function () {245 return list_overhead(this.expressions);246};247AST_Dot.prototype._size = function () {248 if (this.optional) {249 return this.property.length + 2;250 }251 return this.property.length + 1;252};253AST_DotHash.prototype._size = function () {254 if (this.optional) {255 return this.property.length + 3;256 }257 return this.property.length + 2;258};259AST_Sub.prototype._size = function () {260 return this.optional ? 4 : 2;261};262AST_Unary.prototype._size = function () {263 if (this.operator === "typeof") return 7;264 if (this.operator === "void") return 5;265 return this.operator.length;266};267AST_Binary.prototype._size = function (info) {268 if (this.operator === "in") return 4;269 let size = this.operator.length;270 if (271 (this.operator === "+" || this.operator === "-")272 && this.right instanceof AST_Unary && this.right.operator === this.operator273 ) {274 // 1+ +a > needs space between the +275 size += 1;276 }277 if (this.needs_parens(info)) {278 size += 2;279 }280 return size;281};282AST_Conditional.prototype._size = () => 3;283AST_Array.prototype._size = function () {284 return 2 + list_overhead(this.elements);285};286AST_Object.prototype._size = function (info) {287 let base = 2;288 if (first_in_statement(info)) {289 base += 2; // parens290 }291 return base + list_overhead(this.properties);292};293/*#__INLINE__*/294const key_size = key =>295 typeof key === "string" ? key.length : 0;296AST_ObjectKeyVal.prototype._size = function () {297 return key_size(this.key) + 1;298};299/*#__INLINE__*/300const static_size = is_static => is_static ? 7 : 0;301AST_ObjectGetter.prototype._size = function () {302 return 5 + static_size(this.static) + key_size(this.key);303};304AST_ObjectSetter.prototype._size = function () {305 return 5 + static_size(this.static) + key_size(this.key);306};307AST_ConciseMethod.prototype._size = function () {308 return static_size(this.static) + key_size(this.key) + lambda_modifiers(this);309};310AST_PrivateMethod.prototype._size = function () {311 return AST_ConciseMethod.prototype._size.call(this) + 1;312};313AST_PrivateGetter.prototype._size = AST_PrivateSetter.prototype._size = function () {314 return AST_ConciseMethod.prototype._size.call(this) + 4;315};316AST_Class.prototype._size = function () {317 return (318 (this.name ? 8 : 7)319 + (this.extends ? 8 : 0)320 );321};322AST_ClassProperty.prototype._size = function () {323 return (324 static_size(this.static)325 + (typeof this.key === "string" ? this.key.length + 2 : 0)326 + (this.value ? 1 : 0)327 );328};329AST_ClassPrivateProperty.prototype._size = function () {330 return AST_ClassProperty.prototype._size.call(this) + 1;331};332AST_Symbol.prototype._size = function () {333 return !mangle_options || this.definition().unmangleable(mangle_options)334 ? this.name.length335 : 1;336};337// TODO take propmangle into account338AST_SymbolClassProperty.prototype._size = function () {339 return this.name.length;340};341AST_SymbolRef.prototype._size = AST_SymbolDeclaration.prototype._size = function () {342 const { name, thedef } = this;343 if (thedef && thedef.global) return name.length;344 if (name === "arguments") return 9;345 return AST_Symbol.prototype._size.call(this);346};347AST_NewTarget.prototype._size = () => 10;348AST_SymbolImportForeign.prototype._size = function () {349 return this.name.length;350};351AST_SymbolExportForeign.prototype._size = function () {352 return this.name.length;353};354AST_This.prototype._size = () => 4;355AST_Super.prototype._size = () => 5;356AST_String.prototype._size = function () {357 return this.value.length + 2;358};359AST_Number.prototype._size = function () {360 const { value } = this;361 if (value === 0) return 1;362 if (value > 0 && Math.floor(value) === value) {363 return Math.floor(Math.log10(value) + 1);364 }365 return value.toString().length;366};367AST_BigInt.prototype._size = function () {368 return this.value.length;369};370AST_RegExp.prototype._size = function () {371 return this.value.toString().length;372};373AST_Null.prototype._size = () => 4;374AST_NaN.prototype._size = () => 3;375AST_Undefined.prototype._size = () => 6; // "void 0"376AST_Hole.prototype._size = () => 0; // comma is taken into account by list_overhead()377AST_Infinity.prototype._size = () => 8;378AST_True.prototype._size = () => 4;379AST_False.prototype._size = () => 5;380AST_Await.prototype._size = () => 6;...

Full Screen

Full Screen

Evaluator.ts

Source:Evaluator.ts Github

copy

Full Screen

1import AST, {2 AssignableAST,3 IdentifierAssignableAST,4 NewVariableAST,5 AssignmentAST,6 UnaryAST,7 BinaryAST,8 IdentifierAST,9 LiteralAST,10 GenericsParameterAST,11 FunctionAST,12 FunctionCallAST,13 GenericsCallAST,14 ClassAST,15 MemberAccessAST,16 IfAST,17 InterfaceAST,18 TypeAliasAST,19} from "../parser/AST";20import Expression, {21 DeclarationExpression22} from "./Expression";23import {ClassExpression, InterfaceExpression} from "./ClassExpression";24import AssignableExpression, {25 IdentifierAssignableExpression26} from "./AssignableExpression";27import TypeExpression, {28 TypeUnionExpression,29 TypeIntersectionExpression,30 TypeIdentifierExpression,31 TypeAliasExpression,32} from "./TypeExpression"33import Type from "./Type";34import FunctionType from "./type/FunctionType";35import {Constness} from "./Member";36import {voidType} from "./defaultEnvironment";37import Environment from "./Environment";38import ExpressionBuilder, {ClassExpressionBuilder, InterfaceExpressionBuilder} from "./ExpressionBuilder";39import CompilationError from "../common/CompilationError";40import ErrorInfo from "../common/ErrorInfo";41export default42class Evaluator {43 builder = new ExpressionBuilder(this.environment);44 constructor(public environment: Environment) {45 }46 evaluateExpressions(asts: AST[]) {47 const expressions: Expression[] = [];48 const errors: ErrorInfo[] = [];49 for (const ast of asts) {50 try {51 expressions.push(this.evaluate(ast));52 }53 catch (error) {54 if (error instanceof CompilationError) {55 errors.push(...error.infos);56 }57 else {58 throw error;59 }60 }61 }62 if (errors.length > 0) {63 throw new CompilationError(errors);64 }65 return expressions;66 }67 evaluate(ast: AST): Expression {68 if (ast instanceof NewVariableAST) {69 return this.evaluateNewVariable(ast);70 } else if (ast instanceof AssignmentAST) {71 return this.evaluateAssignment(ast);72 }73 else if (ast instanceof UnaryAST) {74 return this.evaluateUnary(ast);75 }76 else if (ast instanceof BinaryAST) {77 return this.evaluateBinary(ast);78 }79 else if (ast instanceof IdentifierAST) {80 return this.evaluateIdentifier(ast);81 }82 else if (ast instanceof LiteralAST) {83 return this.evalauteLiteral(ast);84 }85 else if (ast instanceof FunctionAST) {86 return this.evaluateFunction(ast);87 }88 else if (ast instanceof FunctionCallAST) {89 return this.evaluateFunctionCall(ast);90 }91 else if (ast instanceof GenericsCallAST) {92 return this.evaluateGenericsCall(ast);93 }94 else if (ast instanceof ClassAST) {95 return this.evaluateClass(ast);96 }97 else if (ast instanceof MemberAccessAST) {98 return this.evaluateMemberAccess(ast);99 }100 else if (ast instanceof IfAST) {101 return this.evaluateIf(ast);102 }103 else if (ast instanceof InterfaceAST) {104 return this.builder.buildTypeOnly(ast.range, this.evaluateInterface(ast));105 }106 else if (ast instanceof TypeAliasAST) {107 return this.builder.buildTypeOnly(ast.range, this.evaluateTypeAlias(ast));108 }109 else {110 throw new Error(`Not supported AST: ${ast.constructor.name}`);111 }112 }113 evaluateAssignable(ast: AssignableAST): AssignableExpression {114 if (ast instanceof IdentifierAssignableAST) {115 return this.evaluateIdentifierAssignable(ast);116 }117 else {118 throw new Error(`Not supported AST: ${ast.constructor.name}`);119 }120 }121 evaluateIdentifierAssignable(ast: IdentifierAssignableAST) {122 return new IdentifierAssignableExpression(123 ast.range,124 ast.name,125 ast.type && this.evaluateType(ast.type).metaType126 );127 }128 evaluateNewVariable(ast: NewVariableAST) {129 const left = this.evaluateAssignable(ast.left);130 const right = this.evaluate(ast.right);131 const constness = (() => {132 switch (ast.declaration) {133 case "let":134 return Constness.Constant;135 case "var":136 return Constness.Variable;137 default:138 throw new Error(`not supported declaration: ${ast.declaration}`);139 }140 })();141 return this.builder.buildNewVariable(ast.range, constness, left, right);142 }143 evaluateAssignment(ast: AssignmentAST) {144 const left = this.evaluateAssignable(ast.left);145 const right = this.evaluate(ast.right);146 return this.builder.buildAssignment(ast.range, left, right);147 }148 evaluateUnary(ast: UnaryAST) {149 const operand = this.evaluate(ast.expression);150 return this.builder.buildUnary(ast.range, ast.operator, operand);151 }152 evaluateBinary(ast: BinaryAST) {153 const left = this.evaluate(ast.left);154 const right = this.evaluate(ast.right);155 return this.builder.buildBinary(ast.range, ast.operator, left, right);156 }157 evaluateIdentifier(ast: IdentifierAST) {158 return this.builder.buildIdentifier(ast.range, ast);159 }160 evalauteLiteral(ast: LiteralAST) {161 return this.builder.buildLiteral(ast.range, ast.value);162 }163 evaluateMemberAccess(ast: MemberAccessAST) {164 const obj = this.evaluate(ast.object);165 return this.builder.buildMemberAccess(ast.range, obj, ast.member);166 }167 evaluateFunction(ast: FunctionAST, thisType: Type = voidType): Expression {168 const func = this.evaluateFunctionGenerics(ast, thisType);169 if (ast.addAsVariable) {170 return this.builder.buildNewVariable(171 ast.range, Constness.Constant,172 new IdentifierAssignableExpression(ast.range, ast.name, null), func173 );174 } else {175 return func;176 }177 }178 evaluateGenericsParameter(ast: GenericsParameterAST) {179 const constraint = this.evaluateType(ast.type);180 return this.builder.buildGenericsParameter(ast.range, ast.name, constraint);181 }182 evaluateFunctionGenerics(ast: FunctionAST, thisType: Type) {183 if (ast.genericsParameters && ast.genericsParameters.length > 0) {184 return this.builder.buildGenerics(185 ast.range,186 env => {187 const evaluator = new Evaluator(env);188 return ast.genericsParameters.map(p => evaluator.evaluateGenericsParameter(p));189 },190 env => new Evaluator(env).evaluateFunctionMain(ast, thisType)191 )192 } else {193 return this.evaluateFunctionMain(ast, thisType);194 }195 }196 evaluateFunctionMain(ast: FunctionAST, thisType: Type) {197 return this.builder.buildFunction(198 ast.range,199 ast.name,200 ast.parameters.map(p => this.evaluateAssignable(p)),201 env => {202 const evaluator = new Evaluator(env);203 const body = evaluator.evaluateExpressions(ast.expressions);204 return this.builder.buildFunctionBody(ast.range, body);205 },206 thisType,207 ast.returnType && this.evaluateType(ast.returnType).metaType208 );209 }210 evaluateFunctionCall(ast: FunctionCallAST) {211 const func = this.evaluate(ast.function);212 const args = this.evaluateExpressions(ast.arguments);213 return this.builder.buildFunctionCall(ast.range, func, args, ast.isNewCall);214 }215 evaluateGenericsCall(ast: GenericsCallAST) {216 const value = this.evaluate(ast.value);217 const args = ast.arguments.map(a => this.evaluateType(a));218 return this.builder.buildGenericsCall(ast.range, value, args);219 }220 evaluateClass(ast: ClassAST) {221 let builder: ClassExpressionBuilder;222 if (ast.superclass) {223 const superExpr = this.evaluate(ast.superclass);224 const superType = this.evaluateType(ast.superclass);225 builder = new ClassExpressionBuilder(ast.range, this.environment, ast.name, superType, superExpr);226 } else {227 builder = new ClassExpressionBuilder(ast.range, this.environment, ast.name, null, null);228 }229 for (const memberAST of ast.members) {230 const member = this.builder.buildLazy(231 memberAST.range, memberAST.name,232 () => this.evaluateFunction(memberAST, builder.selfType)233 );234 builder.addMember(Constness.Constant, member);235 }236 return builder.buildClass();237 }238 evaluateDeclarationType(selfType: Type, ast: AST) {239 if (ast instanceof FunctionAST) {240 return this.evaluateMethodDeclarationType(selfType, ast);241 } else {242 throw new Error(`Not supported AST: ${ast.constructor.name}`);243 }244 }245 evaluateMethodDeclarationType(selfType: Type, ast: FunctionAST) {246 return this.builder.buildLazy(ast.range, ast.name, () =>247 this.builder.buildFunctionDeclaration(248 ast.range,249 ast.name,250 ast.parameters.map(p => this.evaluateAssignable(p)),251 selfType,252 this.evaluateType(ast.returnType)253 )254 );255 }256 evaluateInterface(ast: InterfaceAST) {257 const supers = ast.superTypes.map(ast => this.evaluateType(ast));258 const builder = new InterfaceExpressionBuilder(ast.range, this.environment, ast.name, supers);259 for (const memberAST of ast.members) {260 builder.addMember(Constness.Constant, this.evaluateDeclarationType(builder.selfType, memberAST));261 }262 return builder.buildInterface();263 }264 evaluateIf(ast: IfAST) {265 return this.builder.buildIf(ast.range,266 (env) => new Evaluator(env).evaluate(ast.condition),267 (env) => new Evaluator(env).evaluateExpressions(ast.ifTrue),268 (env) => new Evaluator(env).evaluateExpressions(ast.ifFalse)269 );270 }271 evaluateTypeAlias(ast: TypeAliasAST) {272 const typeExpr = this.evaluateType(ast.right);273 this.environment.checkAddType(ast.left, typeExpr.metaType);274 return new TypeAliasExpression(ast.range, ast.left, typeExpr);275 }276 evaluateType(ast: AST): TypeExpression {277 if (ast instanceof IdentifierAST) {278 return this.evaluateTypeIdentifier(ast);279 } else if (ast instanceof BinaryAST) {280 return this.evaluateTypeBinary(ast);281 } else if (ast instanceof InterfaceAST) {282 return this.evaluateInterface(ast);283 } else if (ast instanceof TypeAliasAST) {284 return this.evaluateTypeAlias(ast);285 } else {286 throw new Error(`Not supported AST: ${ast.constructor.name}`);287 }288 }289 evaluateTypeIdentifier(ast: IdentifierAST) {290 const type = this.environment.checkGetType(ast).get();291 return new TypeIdentifierExpression(ast.range, ast, type);292 }293 evaluateTypeBinary(ast: BinaryAST): TypeExpression {294 const left = this.evaluateType(ast.left);295 const right = this.evaluateType(ast.right);296 switch (ast.operator.name) {297 case "&": {298 return new TypeIntersectionExpression(ast.range, this.environment, left, right);299 }300 case "|": {301 return new TypeUnionExpression(ast.range, this.environment, left, right);302 }303 default: {304 throw new Error(`Unsupported type operator: ${ast.operator.name}`);305 }306 }307 }...

Full Screen

Full Screen

customizer-preview.js

Source:customizer-preview.js Github

copy

Full Screen

1/**2 * This file adds some LIVE to the Customizer live preview. To leverage3 * this, set your custom settings to 'postMessage' and then add your handling4 * here. Your javascript should grab settings from customizer controls, and5 * then make any necessary changes to the page using jQuery.6 *7 * @package Astra8 * @since 1.7.09 */10( function( $ ) {11 /* Breadcrumb Typography */12 astra_responsive_font_size(13 'astra-settings[breadcrumb-font-size]',14 '.ast-breadcrumbs-wrapper .trail-items span, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .breadcrumb_last, .ast-breadcrumbs-wrapper span, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .current-item, .ast-breadcrumbs-wrapper .last, .ast-breadcrumbs-wrapper .separator, .ast-breadcrumbs-wrapper .breadcrumb-item, .ast-breadcrumbs-wrapper .breadcrumb-item.active, .ast-breadcrumbs-wrapper .breadcrumb-item:after, .ast-breadcrumbs-inner nav, .ast-breadcrumbs-inner nav .breadcrumb-item, .ast-breadcrumbs-inner nav .breadcrumb-item:after'15 );16 astra_generate_outside_font_family_css(17 'astra-settings[breadcrumb-font-family]',18 '.ast-breadcrumbs-wrapper .trail-items span, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .breadcrumb_last, .ast-breadcrumbs-wrapper span, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .current-item, .ast-breadcrumbs-wrapper .last, .ast-breadcrumbs-wrapper .separator, .ast-breadcrumbs-wrapper .breadcrumb-item, .ast-breadcrumbs-wrapper .breadcrumb-item.active, .ast-breadcrumbs-wrapper .breadcrumb-item:after, .ast-breadcrumbs-inner nav, .ast-breadcrumbs-inner nav .breadcrumb-item, .ast-breadcrumbs-inner nav .breadcrumb-item:after'19 );20 astra_generate_font_weight_css( 'astra-settings[breadcrumb-font-family]', 'astra-settings[breadcrumb-font-weight]', 'font-weight', '.ast-breadcrumbs-wrapper .trail-items span, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .breadcrumb_last, .ast-breadcrumbs-wrapper span, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .current-item, .ast-breadcrumbs-wrapper .last, .ast-breadcrumbs-wrapper .separator, .ast-breadcrumbs-wrapper .breadcrumb-item, .ast-breadcrumbs-wrapper .breadcrumb-item.active, .ast-breadcrumbs-wrapper .breadcrumb-item:after, .ast-breadcrumbs-inner nav, .ast-breadcrumbs-inner nav .breadcrumb-item, .ast-breadcrumbs-inner nav .breadcrumb-item:after' );21 astra_css(22 'astra-settings[breadcrumb-text-transform]',23 'text-transform',24 '.ast-breadcrumbs-wrapper .trail-items span, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .breadcrumb_last, .ast-breadcrumbs-wrapper span, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .current-item, .ast-breadcrumbs-wrapper .last, .ast-breadcrumbs-wrapper .separator, .ast-breadcrumbs-wrapper .breadcrumb-item, .ast-breadcrumbs-wrapper .breadcrumb-item.active, .ast-breadcrumbs-wrapper .breadcrumb-item:after, .ast-breadcrumbs-inner nav, .ast-breadcrumbs-inner nav .breadcrumb-item, .ast-breadcrumbs-inner nav .breadcrumb-item:after'25 );26 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Line Height */27 astra_css(28 'astra-settings[breadcrumb-line-height]',29 'line-height',30 '.ast-breadcrumbs-wrapper .ast-breadcrumbs-name, .ast-breadcrumbs-wrapper .ast-breadcrumbs-item, .ast-breadcrumbs-wrapper .ast-breadcrumbs .separator, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .breadcrumb_last, .ast-breadcrumbs-wrapper span, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .current-item, .ast-breadcrumbs-wrapper a, .ast-breadcrumbs-wrapper .last, .ast-breadcrumbs-wrapper .separator, .ast-breadcrumbs-wrapper .breadcrumb-item, .ast-breadcrumbs-wrapper .breadcrumb-item.active, .ast-breadcrumbs-wrapper .breadcrumb-item:after, .ast-breadcrumbs-inner nav, .ast-breadcrumbs-inner nav .breadcrumb-item, .ast-breadcrumbs-inner nav .breadcrumb-item:after'31 );32 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Text Color */33 astra_color_responsive_css(34 'breadcrumb',35 'astra-settings[breadcrumb-active-color-responsive]',36 'color',37 '.ast-breadcrumbs-wrapper .trail-items .trail-end, .ast-breadcrumbs-wrapper #ast-breadcrumbs-yoast .breadcrumb_last, .ast-breadcrumbs-wrapper .current-item, .ast-breadcrumbs-wrapper .last, .ast-breadcrumbs-inner, .ast-breadcrumbs-wrapper .breadcrumb-item.active'38 );39 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Link Color */40 astra_color_responsive_css(41 'breadcrumb',42 'astra-settings[breadcrumb-text-color-responsive]',43 'color',44 '.ast-breadcrumbs-wrapper .trail-items a, .ast-breadcrumbs-wrapper #ast-breadcrumbs-yoast a, .ast-breadcrumbs-wrapper .breadcrumbs a, .ast-breadcrumbs-wrapper .rank-math-breadcrumb a, .ast-breadcrumbs-wrapper .breadcrumb-item a'45 );46 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Hover Color */47 astra_color_responsive_css(48 'breadcrumb',49 'astra-settings[breadcrumb-hover-color-responsive]',50 'color',51 '.ast-breadcrumbs-wrapper .trail-items a:hover, .ast-breadcrumbs-wrapper #ast-breadcrumbs-yoast a:hover, .ast-breadcrumbs-wrapper .breadcrumbs a:hover, .ast-breadcrumbs-wrapper .rank-math-breadcrumb a:hover, .ast-breadcrumbs-wrapper .breadcrumb-item a:hover'52 );53 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Separator Color */54 astra_color_responsive_css(55 'breadcrumb',56 'astra-settings[breadcrumb-separator-color]',57 'color',58 '.ast-breadcrumbs-wrapper .trail-items li::after, .ast-breadcrumbs-wrapper #ast-breadcrumbs-yoast, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .rank-math-breadcrumb .separator, .ast-breadcrumbs-wrapper .breadcrumb-item:after'59 );60 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Background Color */61 astra_color_responsive_css(62 'breadcrumb',63 'astra-settings[breadcrumb-bg-color]',64 'background-color',65 '.ast-breadcrumbs-wrapper, .main-header-bar.ast-header-breadcrumb, .ast-primary-sticky-header-active .main-header-bar.ast-header-breadcrumb'66 );67 /* Breadcrumb default, Yoast SEO Breadcrumb, Breadcrumb NavXT, Ran Math Breadcrumb, SEOPress Breadcrumb - Alignment */68 astra_css(69 'astra-settings[breadcrumb-alignment]',70 'text-align',71 '.ast-breadcrumbs-wrapper'72 );73 /**74 * Breadcrumb Spacing75 */76 wp.customize( 'astra-settings[breadcrumb-spacing]', function( value ) {77 value.bind( function( padding ) {78 var spacing_value = wp.customize( 'astra-settings[breadcrumb-position]' ).get();79 if( 'astra_header_markup_after' == spacing_value || 'astra_header_after' == spacing_value ) {80 astra_responsive_spacing( 'astra-settings[breadcrumb-spacing]','.main-header-bar.ast-header-breadcrumb', 'padding', ['top', 'right', 'bottom', 'left' ] );81 } else if( 'astra_masthead_content' == spacing_value ) {82 astra_responsive_spacing( 'astra-settings[breadcrumb-spacing]','.ast-breadcrumbs-wrapper .ast-breadcrumbs-inner #ast-breadcrumbs-yoast, .ast-breadcrumbs-wrapper .ast-breadcrumbs-inner .breadcrumbs, .ast-breadcrumbs-wrapper .ast-breadcrumbs-inner .rank-math-breadcrumb, .ast-breadcrumbs-wrapper .ast-breadcrumbs-inner .ast-breadcrumbs, .ast-breadcrumbs-wrapper .ast-breadcrumbs-inner', 'padding', ['top', 'right', 'bottom', 'left' ] );83 } else {84 astra_responsive_spacing( 'astra-settings[breadcrumb-spacing]','.ast-breadcrumbs-wrapper #ast-breadcrumbs-yoast, .ast-breadcrumbs-wrapper .breadcrumbs, .ast-breadcrumbs-wrapper .rank-math-breadcrumb, .ast-breadcrumbs-wrapper .ast-breadcrumbs, .ast-breadcrumbs-wrapper .ast-breadcrumbs-inner', 'padding', ['top', 'right', 'bottom', 'left' ] );85 }86 } );87 } );88 /**89 * Breadcrumb Separator.90 */91 wp.customize( 'astra-settings[breadcrumb-separator]', function( value ) {92 value.bind( function( value ) {93 var dynamicStyle = '';94 dynamicStyle += '.trail-items li::after {';95 dynamicStyle += 'content: "' + value + '";';96 dynamicStyle += '} ';97 astra_add_dynamic_css( 'breadcrumb-separator', dynamicStyle );98 } );99 } );...

Full Screen

Full Screen

AST.ts

Source:AST.ts Github

copy

Full Screen

1import SourceRange from "../common/SourceRange";2export default3class AST {4 constructor(5 public range: SourceRange6 ) {}7}8export9class ExpressionAST extends AST {10}11export12class AssignableAST extends AST {13}14export15class IdentifierAssignableAST extends AssignableAST {16 constructor(17 range: SourceRange,18 public name: IdentifierAST,19 public type: ExpressionAST20 ) {21 super(range);22 }23}24export25class AssignmentAST extends ExpressionAST {26 constructor(27 range: SourceRange,28 public left: AssignableAST,29 public operator: OperatorAST,30 public right: ExpressionAST31 ) {32 super(range);33 }34}35export36class NewVariableAST extends ExpressionAST {37 constructor(38 range: SourceRange,39 public declaration: String,40 public type: ExpressionAST,41 public left: AssignableAST,42 public right: ExpressionAST43 ) {44 super(range);45 }46}47export48class TypeAliasAST extends ExpressionAST {49 constructor(50 range: SourceRange,51 public left: IdentifierAST,52 public right: ExpressionAST53 ) {54 super(range);55 }56}57export58class BinaryAST extends ExpressionAST {59 constructor(60 range: SourceRange,61 public left: ExpressionAST,62 public operator: OperatorAST,63 public right: ExpressionAST64 ) {65 super(range);66 }67}68export69class FunctionAST extends ExpressionAST {70 constructor(71 range: SourceRange,72 public name: IdentifierAST,73 public genericsParameters: GenericsParameterAST[],74 public parameters: AssignableAST[],75 public returnType: ExpressionAST,76 public expressions: ExpressionAST[],77 public addAsVariable = false78 ) {79 super(range);80 }81}82export83class FunctionCallAST extends ExpressionAST {84 function: AST;85 arguments: ExpressionAST[];86 constructor(87 range: SourceRange,88 func: ExpressionAST,89 args: ExpressionAST[],90 public isNewCall = false91 ) {92 super(range);93 this.function = func;94 this.arguments = args;95 }96}97export98class GenericsCallAST extends ExpressionAST {99 arguments: ExpressionAST[];100 constructor(101 range: SourceRange,102 public value: ExpressionAST,103 args: ExpressionAST[]104 ) {105 super(range);106 this.arguments = args;107 }108}109export110class IfAST extends ExpressionAST {111 constructor(112 range: SourceRange,113 public condition: ExpressionAST,114 public ifTrue: ExpressionAST[],115 public ifFalse: ExpressionAST[]116 ) {117 super(range);118 }119}120export121class IdentifierAST extends ExpressionAST {122 constructor(123 range: SourceRange,124 public name: string125 ) {126 super(range);127 }128 toString() {129 return this.name;130 }131}132export133class LiteralAST extends ExpressionAST {134 constructor(135 public range: SourceRange,136 public value: any137 ) {138 super(range);139 }140}141export142class MemberAccessAST extends ExpressionAST {143 constructor(144 range: SourceRange,145 public object: ExpressionAST,146 public member: IdentifierAST147 ) {148 super(range);149 }150}151export152class OperatorAST extends ExpressionAST {153 constructor(154 range: SourceRange,155 public name: string156 ) {157 super(range);158 }159}160export161class GenericsParameterAST extends AST {162 constructor(163 range: SourceRange,164 public name: IdentifierAST,165 public type: ExpressionAST166 ) {167 super(range);168 }169}170export171class UnaryAST extends ExpressionAST {172 constructor(173 range: SourceRange,174 public operator: OperatorAST,175 public expression: ExpressionAST176 ) {177 super(range);178 }179}180export181class ClassAST extends ExpressionAST {182 constructor(183 range: SourceRange,184 public name: IdentifierAST,185 public superclass: ExpressionAST,186 public members: FunctionAST[]187 ) {188 super(range);189 }190}191export192class InterfaceAST extends ExpressionAST {193 constructor(194 range: SourceRange,195 public name: IdentifierAST,196 public superTypes: ExpressionAST[],197 public members: FunctionAST[]198 ) {199 super(range);200 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const ast = require('stryker-parent').ast;2ast.findNode('foo');3const ast = require('stryker-child').ast;4ast.findNode('foo');5const ast = require('stryker-child/src/ast');6ast.findNode('foo');7const ast = require('stryker-child/src/ast');8ast.findNode('foo');9const ast = require('stryker-child').ast;10ast.findNode('foo');

Full Screen

Using AI Code Generation

copy

Full Screen

1var ast = require('stryker-parent').ast;2var ast = require('stryker-parent').ast;3var ast = require('stryker-parent').ast;4var ast = require('stryker-parent').ast;5var ast = require('stryker-parent').ast;6var ast = require('stryker-parent').ast;7var ast = require('stryker-parent').ast;8var ast = require('stryker-parent').ast;9var ast = require('stryker-parent').ast;10var ast = require('stryker-parent').ast;11var ast = require('stryker-parent').ast;12var ast = require('stryker-parent').ast;13var ast = require('stryker-parent').ast;14var ast = require('stryker-parent').ast;15var ast = require('stryker-parent').ast;16var ast = require('stryker-parent').ast;17var ast = require('stryker-parent').ast;18var ast = require('stryker-parent').ast;19var ast = require('stryker-parent').ast;

Full Screen

Using AI Code Generation

copy

Full Screen

1var StrykerParent = require('stryker-parent');2var ast = StrykerParent.ast;3var esprima = ast.esprima;4var code = "var foo = 1;";5var ast = esprima.parse(code);6console.log(ast);7var StrykerChild = require('stryker-child');8var ast = StrykerChild.ast;9var esprima = ast.esprima;10var code = "var foo = 1;";11var ast = esprima.parse(code);12console.log(ast);13var StrykerChild = require('stryker-child');14var ast = StrykerChild.ast;15var esprima = ast.esprima;16var code = "var foo = 1;";17var ast = esprima.parse(code);18console.log(ast);19var StrykerChild = require('stryker-child');20var ast = StrykerChild.ast;21var esprima = ast.esprima;22var code = "var foo = 1;";23var ast = esprima.parse(code);24console.log(ast);25var StrykerChild = require('stryker-child');26var ast = StrykerChild.ast;27var esprima = ast.esprima;28var code = "var foo = 1;";29var ast = esprima.parse(code);30console.log(ast);31var StrykerChild = require('stryker-child');32var ast = StrykerChild.ast;33var esprima = ast.esprima;34var code = "var foo = 1;";35var ast = esprima.parse(code);36console.log(ast);37var StrykerChild = require('stryker-child');38var ast = StrykerChild.ast;39var esprima = ast.esprima;40var code = "var foo = 1;";41var ast = esprima.parse(code);42console.log(ast);43var StrykerChild = require('stryker-child');44var ast = StrykerChild.ast;45var esprima = ast.esprima;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { ast } = require('stryker-parent');2const { parse } = ast;3const { Syntax } = ast;4const { ast } = require('stryker-parent');5const { parse } = ast;6const { Syntax } = ast;7const { ast } = require('stryker-parent');8const { parse } = ast;9const { Syntax } = ast;10const { ast } = require('stryker-parent');11const { parse } = ast;12const { Syntax } = ast;13const { ast } = require('stryker-parent');14const { parse } = ast;15const { Syntax } = ast;16const { ast } = require('stryker-parent');17const { parse } = ast;18const { Syntax } = ast;19const { ast } = require('stryker-parent');20const { parse } = ast;21const { Syntax } = ast;22const { ast } = require('stryker-parent');23const { parse } = ast;24const { Syntax } = ast;25const { ast } = require('stryker-parent');26const { parse } = ast;27const { Syntax } = ast;28const { ast } = require('stryker-parent');29const { parse } = ast;30const { Syntax } = ast;31const { ast } = require('stryker-parent');32const { parse } = ast;33const { Syntax } = ast;34const { ast } = require('stryker-parent');35const { parse } = ast;36const { Syntax } = ast;

Full Screen

Using AI Code Generation

copy

Full Screen

1const { ast } = require('stryker-parent');2const { parse } = require('acorn');3const { generate } = require('astring');4const { ast: ast2 } = require('stryker');5const { parse: parse2 } = require('acorn');6const { generate: generate2 } = require('astring');7const code = 'var x = 1 + 2';8const ast1 = ast.parse(code);9const ast2 = ast2.parse(code);10console.log(ast1);11console.log(ast2);12const code1 = ast.generate(ast1);13const code2 = ast2.generate(ast2);14console.log(code1);15console.log(code2);16module.exports = function(config) {17 config.set({18 mochaOptions: {19 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const { ast } = require("stryker-parent");2const { parse } = require("@babel/parser");3const traverse = require("@babel/traverse").default;4const code = "const a = 1;";5const ast = parse(code, { sourceType: "module" });6traverse(ast, {7 enter(path) {8 console.log(path.node.type);9 },10});11const { ast } = require("stryker-parent");12const { parse } = require("@babel/parser");13const traverse = require("@babel/traverse").default;14const code = "const a = 1;";15const ast = parse(code, { sourceType: "module" });16traverse(ast, {17 enter(path) {18 console.log(path.node.type);19 },20});21const { ast } = require("stryker-parent");22const { parse } = require("@babel/parser");23const traverse = require("@babel/traverse").default;24const code = "const a = 1;";25const ast = parse(code, { sourceType: "module" });26traverse(ast, {27 enter(path) {28 console.log(path.node.type);29 },30});31const { ast } = require("stryker-parent");32const { parse } = require("@babel/parser");33const traverse = require("@babel/traverse").default;34const code = "const a = 1;";35const ast = parse(code, { sourceType: "module" });36traverse(ast, {37 enter(path) {38 console.log(path.node.type);39 },40});41const { ast } = require("stryker-parent");42const { parse } = require("@babel/parser");43const traverse = require("@babel

Full Screen

Using AI Code Generation

copy

Full Screen

1const { parse } = require('acorn');2const { findParent } = require('stryker-parent');3 function foo() {4 function bar() {5 return 1;6 }7 }8`;9const ast = parse(code);10const bar = ast.body[0].body.body[0];11const foo = findParent(bar, ast);12console.log(foo === ast.body[0]);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run stryker-parent automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful