fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 49 lines 1.7 kB view raw
1import type { File } from '../files/file'; 2import type { Language } from '../languages/types'; 3import type { IAnalysisContext } from '../planner/types'; 4import type { Ref } from '../refs/types'; 5import type { Symbol } from '../symbols/symbol'; 6 7export type MaybeRef<T> = T | Ref<T>; 8 9export type NodeName = MaybeRef<Symbol | string | number>; 10 11export type NodeNameSanitizer = (name: string) => string; 12 13export type NodeRelationship = 'container' | 'reference'; 14 15export type NodeScope = 'type' | 'value'; 16 17export interface INode<T = unknown> { 18 /** Perform semantic analysis. */ 19 analyze(ctx: IAnalysisContext): void; 20 /** Create a shallow copy of this node. */ 21 clone(): this; 22 /** Whether this node is exported from its file. */ 23 exported?: boolean; 24 /** The file this node belongs to. */ 25 file?: File; 26 /** The programming language associated with this node */ 27 language: Language; 28 /** The display name of this node. */ 29 readonly name: Ref<NodeName> & { 30 set(value: NodeName): void; 31 toString(): string; 32 }; 33 /** Optional function to sanitize the node name. */ 34 readonly nameSanitizer?: NodeNameSanitizer; 35 /** Whether this node is a root node in the file. */ 36 root?: boolean; 37 /** The scope of this node. */ 38 scope?: NodeScope; 39 /** Semantic children in the structure hierarchy. */ 40 structuralChildren?: Map<INode, NodeRelationship>; 41 /** Semantic parents in the structure hierarchy. */ 42 structuralParents?: Map<INode, NodeRelationship>; 43 /** The symbol associated with this node. */ 44 symbol?: Symbol; 45 /** Convert this node into AST representation. */ 46 toAst(): T; 47 /** Brand used for renderer dispatch. */ 48 readonly '~brand': string; 49}