import { Connection , Diagnostic , TextDocuments } from 'vscode-languageserver/node' ; import { TextDocument } from 'vscode-languageserver-textdocument' ; import { DocumentCompiler } from './DocumentCompiler' ; import { VerilatorCompiler } from './VerilatorCompiler' ; import { VCSCompiler } from './VCSCompiler' ; import { VeribleCompiler } from './VeribleCompiler' ; export enum compilerType { Verilator = 1 , VCS = 2 , Verible = 3 } export class SystemVerilogCompiler { compiler : DocumentCompiler ; connection : Connection ; documents : TextDocuments < TextDocument > ; workspaceRootPath : string ; configurations : Map < string , any > ; compilerConfigurationsKeys : string [ ] ; constructor ( connection , documents , workspaceRootPath , configurations , compilerConfigurationsKeys ) { this . connection = connection ; this . documents = documents ; this . workspaceRootPath = workspaceRootPath ; this . configurations = configurations ; this . compilerConfigurationsKeys = compilerConfigurationsKeys ; } returns public async validateTextDocument ( document , type ) { if ( type === compilerType . Verilator ) { this . compiler = new VerilatorCompiler ( this . connection , this . documents , this . workspaceRootPath , this . configurations , this . compilerConfigurationsKeys ) ; } else if ( type === compilerType . VCS ) { this . compiler = new VCSCompiler ( this . connection , this . documents , this . workspaceRootPath , this . configurations , this . compilerConfigurationsKeys ) ; } else if ( type === compilerType . Verible ) { this . compiler = new VeribleCompiler ( this . connection , this . documents , this . workspaceRootPath , this . configurations , this . compilerConfigurationsKeys ) ; } else { this . connection . console . log ( `SystemVerilog: '${ type }' is an invalid compiler type.` ) ; return ; } return this . compiler . getTextDocumentDiagnostics ( document ) ; } }