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(): AnalyserSystemReturns
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(): ProgramReturns
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(): TypeCheckerReturns
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(): AnalyserDiagnosticReturns
AnalyserDiagnostic:An instance of the
AnalyserDiagnosticwhere 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): booleanParameters
filePath stringThe 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): ModuleNodeParameters
filePath stringThe path of the new source file
content stringThe 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): ModuleNodeParameters
filePath stringThe path of the source file to update
content stringThe new content of the source file
Returns
ModuleNode:The updated reflected module
-
getName
codeThe name of the package defined in the
package.jsonin case one was foundgetName(): stringReturns
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