Skip to content

Commit

Permalink
Fix: Remove unnecessary extensionPath
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Apr 2, 2024
1 parent 26931cb commit d47d570
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
10 changes: 2 additions & 8 deletions server/src/BitBakeDocScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class BitBakeDocScanner {
private _variableFlagInfo: VariableFlagInfo[] = []
private _yoctoTaskInfo: DocInfo[] = []
private _pythonDatastoreFunction: string[] = []
private _docPath: string = path.join(__dirname, '../resources/docs') // This default path is for the test. The path after the compilation can be different
private readonly _docPath: string = path.join(__dirname, '../resources/docs')
private readonly _keywordInfo: DocInfo[] = KEYWORDS

get bitbakeVariableInfo (): VariableInfo[] {
Expand Down Expand Up @@ -110,13 +110,7 @@ export class BitBakeDocScanner {
this._pythonDatastoreFunction = []
}

public setDocPathAndParse (extensionPath: string): void {
// Expected path on VSCode
this._docPath = path.join(extensionPath, 'server/resources/docs')
if (!fs.existsSync(this._docPath)) {
// Expected path on standalone npm language-server-bitbake package
this._docPath = path.join(extensionPath, 'resources/docs')
}
public setDocPathAndParse (): void {
this.parseVariableFlagFile()
this.parseBitbakeVariablesFile()
this.parseYoctoVariablesFile()
Expand Down
5 changes: 1 addition & 4 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,10 @@ connection.onInitialize(async (params: InitializeParams): Promise<InitializeResu

workspaceFolder = params.workspaceFolders?.[0].uri.replace('file://', '')

// If the language server is not started by VSCode, extensionPath and pathToBitbakeFolder can be undefined
// We provide alternatives here to prevent crashes when these variables are used
const extensionPath = params.initializationOptions?.extensionPath ?? path.join(__dirname, '..')
pokyFolder = pokyFolder ?? workspaceFolder

logger.info('[onInitialize] Setting yocto doc path and parsing doc files')
bitBakeDocScanner.setDocPathAndParse(extensionPath)
bitBakeDocScanner.setDocPathAndParse()

const parser = await generateParser()
analyzer.initialize(parser)
Expand Down

0 comments on commit d47d570

Please sign in to comment.