Description
A class that shares common utilities between all reflected nodes
Methods
-
getProgram
codeA Program is an immutable collection of source files and the compiler options. Together represent a compilation unit.
getProgram(): Program
Returns
Program
:The TypeScript program created with the TypeScript compiler API
-
getCommandLine
codeThe TypeScript compiler options parsed (if you have a TSConfig file, the parsed options will be the ones defined there)
getCommandLine(): ParsedCommandLine
Returns
ParsedCommandLine
:The parsed compiler options
-
getTypeChecker
codeThe TypeScript type checker. Useful to resolve the types and location of the reflected nodes.
getTypeChecker(): TypeChecker
Returns
TypeChecker
:The TypeScript type checker
-
getSystem
codeAn abstraction layer around how we interact with the environment (browser or Node.js)
getSystem(): AnalyserSystem
Returns
AnalyserSystem
:The system environment used
-
getDiagnostics
codeHere we save all the errors we find while analysing the source files
getDiagnostics(): AnalyserDiagnostic
Returns
AnalyserDiagnostic
:An instance of the
AnalyserDiagnostic
where all errors are enqueue -
getOptions
codeThe user provided analyzer options.
getOptions(): Partial<AnalyserOptions>
Returns
Partial<AnalyserOptions>
:The options that were provided when calling the parser function
-
registerReflectedNode
codeCreates a new reflected node only if it doesn’t exist already in the internal cache.
registerReflectedNode<T extends ReflectedNode<object, Node>>(node: Node, reflectedNodeFactory: () => T): T
Parameters
node Node
The
ts.Node
associated with the reflected nodereflectedNodeFactory () => T
The function to use to build the new reflection if it doesn’t exist
Returns
T
:The reflected node instance
-
getSymbol
codeReturns the associated
ts.Symbol
for the given nodegetSymbol(node: Node): Symbol | null
Parameters
node Node
The
ts.Node
to search its symbolReturns
Symbol | null
:The symbol if it has one
-
getLocation
codeGiven a node or a type it returns it’s associated symbol, line position and the file path where it was defined.
getLocation(nodeOrType: Node | Type): SymbolWithLocation
Parameters
nodeOrType Node | Type
The node or type to search for
Returns
SymbolWithLocation
:The symbol, line position and path where the node/type is located
-
getLinePosition
codeReturns the start line number where the node is located
getLinePosition(node: Node): number
Parameters
node Node
The node to locate
Returns
number
:The line number where the node is located