Description
Represents a collection of modules (TypeScript/JavaScript files) that have been successfully analysed.
Methods
-
getSystem
codeAn abstraction layer around how we interact with the environment (browser or Node.js)
getSystem(): AnalyserSystem
Returns
AnalyserSystem
:The system environment used
-
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
-
getTypeChecker
codeThe TypeScript type checker. Useful to resolve the types and location of the reflected nodes.
getTypeChecker(): TypeChecker
Returns
TypeChecker
:The TypeScript type checker
-
getOptions
codeThe user provided analyzer options.
getOptions(): Partial<AnalyserOptions>
Returns
Partial<AnalyserOptions>
:The options that were provided when calling the parser function
-
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 -
getModules
codeAll the reflected modules/files that have been successfully analysed.
getModules(): ModuleNode[]
Returns
ModuleNode[]
:The reflected modules
-
has
codeWhether the given source file path is present in the reflected modules
has(filePath: string): boolean
Parameters
filePath string
The source file path to check
Returns
boolean
:True if the source file has been already analysed, false otherwise
-
add
codeAdds a new source file to the collection of reflected modules. Will throw an error if the source file already exists in the program.
add(filePath: string, content: string): ModuleNode
Parameters
filePath string
The path of the new source file
content string
The content of the source file
Returns
ModuleNode
:The new reflected module
-
update
codeUpdates the content of an existing source file. Will throw an error if the source file doesn’t exist in the program.
update(filePath: string, content: string): ModuleNode
Parameters
filePath string
The path of the source file to update
content string
The new content of the source file
Returns
ModuleNode
:The updated reflected module
-
getName
codeThe name of the package defined in the
package.json
in case one was foundgetName(): string
Returns
string
:The package name if found, otherwise an empty string
-
serialize
codeSerializes the project
serialize(): Module[]
Returns
Module[]
:The reflected node as a serializable object