import { AnonymousClass , AnonymousFunctionNode , AnythingNode , ArrayNode , BooleanNode , BottomNode , ByteNode , CharacterNode , ClassDeclaration , ClassLikeNode , ComplexNumberNode , DateLikeNode , DateNode , DateTimeLiteral , DateTimeNode , DecimalLiteral , DecimalNode , Definition , EnumDeclaration , EnumMemberDeclaration , FalseLiteral , FunctionDeclaration , FunctionNode , GenericIterable , ImaginaryNumberLiteral , InfinityNode , IntegerLiteral , IntegerNode , InterfaceDeclaration , IntersectionNode , IterableNode , LinkedListNode , ListNode , MapNode , MethodDeclaration , ModuleDeclaration , ModuleLikeNode , MultiSetNode , NamedNode , Node , NotANumberNode , NothingNode , NullNode , NumericNode , ObjectLikeMember , ObjectLikeNode , ObjectNode , ParameterNode , PropertyDeclaration , RealNumberLiteral , RealNumberNode , ReferenceNode , RegExpLiteral , RegExpNode , SetNode , SignatureNode , SourceFile , StringLiteral , StringNode , SymbolLiteral , SymbolNode , TopNode , TrueLiteral , TupleNode , TypeArgumentNode , TypeDeclaration , TypeParameterDeclaration , UnionNode , VariableDeclaration } from '#ast/node-types' ; import { NodeFlags , NodeKind , TypeFlags } from '#ast/enums' ; import { NodeObject } from '#ast/node-object' ; import { Declaration , RootDeclaration } from '#ast/node-aliases' ; export const isNode = ( v ) : v is Node => v instanceof NodeObject ; export const isNamedNode = ( n ) : n is NamedNode => ! ! ( n . flags & NodeFlags . Named ) ; export const isDeclaration = ( n ) : n is Declaration => ! ! ( n . flags & NodeFlags . Declaration ) ; export const isRootDeclaration = ( n ) : n is RootDeclaration => isDeclaration ( n ) && ! ( n . flags & NodeFlags . Nested ) ; export const isDefinition = ( n ) : n is Definition => ! ! ( n . flags & NodeFlags . Definition ) ; export const isModuleNode = ( n ) : n is ModuleLikeNode => ! ! ( n . typeFlags & TypeFlags . Module ) ; export const isNamespaceNode = ( n ) : n is ModuleDeclaration => ( n . kind === NodeKind . ModuleDeclaration ) ; export const isSourceFile = ( n ) : n is SourceFile => ( n . kind === NodeKind . SourceFile ) ; export const isStringNode = ( n ) : n is StringNode => ( n . kind === NodeKind . String ) ; export const isCharacterNode = ( n ) : n is CharacterNode => ( n . kind === NodeKind . Character ) ; export const isByteNode = ( n ) : n is ByteNode => ( n . kind === NodeKind . Byte ) ; export const isRegExpNode = ( n ) : n is RegExpNode => ( n . kind === NodeKind . RegExp ) ; export const isSymbolNode = ( n ) : n is SymbolNode => ( n . kind === NodeKind . Symbol ) ; export const isBooleanNode = ( n ) : n is BooleanNode => ( n . kind === NodeKind . Boolean ) ; export const isRealNumberNode = ( n ) : n is RealNumberNode => [ NodeKind . Integer , NodeKind . Decimal ] . includes ( n . kind ) ; export const isNumericNode = ( n ) : n is NumericNode => ! ! ( n . typeFlags & TypeFlags . Numeric ) ; export const isIntegerNode = ( n ) : n is IntegerNode => ( n . kind === NodeKind . Integer ) ; export const isDecimalNumberNode = ( n ) : n is DecimalNode => ( n . kind === NodeKind . Decimal ) ; export const isComplexNumberNode = ( n ) : n is ComplexNumberNode => ( n . kind === NodeKind . ComplexNumber ) ; export const isNotANumberNode = ( n ) : n is NotANumberNode => ( n . kind === NodeKind . NotANumber ) ; export const isInfinityNode = ( n ) : n is InfinityNode => ( n . kind === NodeKind . Infinity ) ; export const isStringLiteral = ( n ) : n is StringLiteral => ( n . kind === NodeKind . StringLiteral ) ; export const isTrueLiteral = ( n ) : n is TrueLiteral => ( n . kind === NodeKind . TrueLiteral ) ; export const isFalseLiteral = ( n ) : n is FalseLiteral => ( n . kind === NodeKind . FalseLiteral ) ; export const isRegExpLiteral = ( n ) : n is RegExpLiteral => ( n . kind === NodeKind . RegExpLiteral ) ; export const isDateTimeLiteral = ( n ) : n is DateTimeLiteral => ( n . kind === NodeKind . DateTimeLiteral ) ; export const isSymbolLiteral = ( n ) : n is SymbolLiteral => ( n . kind === NodeKind . SymbolLiteral ) ; export const isRealNumberLiteral = ( n ) : n is RealNumberLiteral => [ NodeKind . IntegerLiteral , NodeKind . DecimalLiteral ] . includes ( n . kind ) ; export const isIntegerLiteral = ( n ) : n is IntegerLiteral => ( n . kind === NodeKind . IntegerLiteral ) ; export const isDecimalLiteral = ( n ) : n is DecimalLiteral => ( n . kind === NodeKind . DecimalLiteral ) ; export const isImaginaryNumberLiteral = ( n ) : n is ImaginaryNumberLiteral => ( n . kind === NodeKind . ImaginaryNumberLiteral ) ; export const isIterableNode = ( n ) : n is IterableNode => ! ! ( n . typeFlags & TypeFlags . Iterable ) ; export const isGenericIterable = ( n ) : n is GenericIterable => ( n . kind === NodeKind . GenericIterable ) ; export const isArrayNode = ( n ) : n is ArrayNode => ( n . kind === NodeKind . Array ) ; export const isMapNode = ( n ) : n is MapNode => ( n . kind === NodeKind . Map ) ; export const isMultiSetNode = ( n ) : n is MultiSetNode => ( n . kind === NodeKind . MultiSet ) ; export const isSetNode = ( n ) : n is SetNode => ( n . kind === NodeKind . Set ) ; export const isListNode = ( n ) : n is ListNode => ( n . kind === NodeKind . List ) ; export const isLinkedListNode = ( n ) : n is LinkedListNode => ( n . kind === NodeKind . LinkedList ) ; export const isEnumDeclaration = ( n ) : n is EnumDeclaration => ( n . kind === NodeKind . EnumDeclaration ) ; export const isEnumMemberDeclaration = ( n ) : n is EnumMemberDeclaration => ( n . kind === NodeKind . EnumMemberDeclaration ) ; export const isTupleNode = ( n ) : n is TupleNode => ( n . kind === NodeKind . Tuple ) ; export const isObjectLikeNode = ( n ) : n is ObjectLikeNode => ! ! ( n . typeFlags & TypeFlags . ObjectLike ) ; export const isClassLikeNode = ( n ) : n is ClassLikeNode => ! ! ( n . typeFlags & TypeFlags . ClassLike ) ; export const isObjectNode = ( n ) : n is ObjectNode => ( n . kind === NodeKind . Object ) ; export const isClassDeclaration = ( n ) : n is ClassDeclaration => ( n . kind === NodeKind . ClassDeclaration ) ; export const isAnonymousClass = ( n ) : n is AnonymousClass => ( n . kind === NodeKind . AnonymousClass ) ; export const isInterfaceDeclaration = ( n ) : n is InterfaceDeclaration => ( n . kind === NodeKind . InterfaceDeclaration ) ; export const isObjectLikeMember = ( n ) : n is ObjectLikeMember => ! ! ( n . typeFlags & TypeFlags . ObjectLikeMember ) ; export const isPropertyDeclaration = ( n ) : n is PropertyDeclaration => ( n . kind === NodeKind . PropertyDeclaration ) ; export const isMethodDeclaration = ( n ) : n is MethodDeclaration => ( n . kind === NodeKind . MethodDeclaration ) ; export const isDateLikeNode = ( n ) : n is DateLikeNode => [ NodeKind . Date , NodeKind . DateTime ] . includes ( n . kind ) ; export const isDateNode = ( n ) : n is DateNode => ( n . kind === NodeKind . Date ) ; export const isDateTimeNode = ( n ) : n is DateTimeNode => ( n . kind === NodeKind . DateTime ) ; export const isFunctionNode = ( n ) : n is FunctionNode => ! ! ( n . typeFlags & TypeFlags . Function ) ; export const isFunctionDeclaration = ( n ) : n is FunctionDeclaration => ( n . kind === NodeKind . FunctionDeclaration ) ; export const isAnonymousFunctionNode = ( n ) : n is AnonymousFunctionNode => ( n . kind === NodeKind . AnonymousFunction ) ; export const isSignatureNode = ( n ) : n is SignatureNode => ( n . kind === NodeKind . Signature ) ; export const isParameterNode = ( n ) : n is ParameterNode => ( n . kind === NodeKind . Parameter ) ; export const isTypeParameterDeclaration = ( n ) : n is TypeParameterDeclaration => ( n . kind === NodeKind . TypeParameterDeclaration ) ; export const isTypeArgumentNode = ( n ) : n is TypeArgumentNode => ( n . kind === NodeKind . TypeArgument ) ; export const isTypeDeclaration = ( n ) : n is TypeDeclaration => ( n . kind === NodeKind . TypeDeclaration ) ; export const isVariableDeclaration = ( n ) : n is VariableDeclaration => ( n . kind === NodeKind . VariableDeclaration ) ; export const isUnionNode = ( n ) : n is UnionNode => ( n . kind === NodeKind . Union ) ; export const isIntersectionNode = ( n ) : n is IntersectionNode => ( n . kind === NodeKind . Intersection ) ; export const isTopNode = ( n ) : n is TopNode => ( n . kind === NodeKind . Anything ) ; export const isBottomNode = ( n ) : n is BottomNode => ( n . kind === NodeKind . Nothing ) ; export const isAnythingNode = ( n ) : n is AnythingNode => ( n . kind === NodeKind . Anything ) ; export const isNothingNode = ( n ) : n is NothingNode => ( n . kind === NodeKind . Nothing ) ; export const isNullNode = ( n ) : n is NullNode => ( n . kind === NodeKind . Null ) ; export const isReferenceNode = ( n ) : n is ReferenceNode => ( n . kind === NodeKind . Reference ) ;