Skip to content

Commit 285a279

Browse files
committed
Rename configuration option
1 parent dff893f commit 285a279

File tree

6 files changed

+31
-25
lines changed

6 files changed

+31
-25
lines changed

server/src/__tests__/analyzer.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ describe('commandNameAtPoint', () => {
296296
})
297297

298298
describe('findSymbolsMatchingWord', () => {
299-
it('return a list of symbols across the workspace when isSourcingAware is false', async () => {
299+
it('return a list of symbols across the workspace when includeAllWorkspaceSymbols is true', async () => {
300300
const parser = await initializeParser()
301301
const connection = getMockConnection()
302302

303303
const analyzer = new Analyzer({
304304
console: connection.console,
305305
parser,
306-
isSourcingAware: false,
306+
includeAllWorkspaceSymbols: true,
307307
workspaceFolder: FIXTURE_FOLDER,
308308
})
309309
await analyzer.initiateBackgroundAnalysis({
@@ -421,14 +421,14 @@ describe('findSymbolsMatchingWord', () => {
421421
`)
422422
})
423423

424-
it('return a list of symbols accessible to the uri when isSourcingAware is true', async () => {
424+
it('return a list of symbols accessible to the uri when includeAllWorkspaceSymbols is false', async () => {
425425
const parser = await initializeParser()
426426
const connection = getMockConnection()
427427

428428
const analyzer = new Analyzer({
429429
console: connection.console,
430430
parser,
431-
isSourcingAware: true,
431+
includeAllWorkspaceSymbols: false,
432432
workspaceFolder: FIXTURE_FOLDER,
433433
})
434434
await analyzer.initiateBackgroundAnalysis({

server/src/__tests__/config.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
import { ConfigSchema, getConfigFromEnvironmentVariables } from '../config'
22

33
describe('ConfigSchema', () => {
4-
it('parses an object', () => {
4+
it('returns a default', () => {
55
expect(ConfigSchema.parse({})).toMatchInlineSnapshot(`
66
Object {
77
"backgroundAnalysisMaxFiles": 500,
8-
"completionBasedOnImports": true,
98
"explainshellEndpoint": "",
109
"globPattern": "**/*@(.sh|.inc|.bash|.command)",
1110
"highlightParsingErrors": false,
11+
"includeAllWorkspaceSymbols": false,
1212
"shellcheckArguments": Array [],
1313
"shellcheckPath": "shellcheck",
1414
}
1515
`)
16+
})
17+
it('parses an object', () => {
1618
expect(
1719
ConfigSchema.parse({
1820
backgroundAnalysisMaxFiles: 1,
1921
explainshellEndpoint: 'localhost:8080',
2022
globPattern: '**/*@(.sh)',
2123
highlightParsingErrors: true,
24+
includeAllWorkspaceSymbols: true,
2225
shellcheckArguments: ' -e SC2001 -e SC2002 ',
2326
shellcheckPath: '',
2427
}),
2528
).toMatchInlineSnapshot(`
2629
Object {
2730
"backgroundAnalysisMaxFiles": 1,
28-
"completionBasedOnImports": true,
2931
"explainshellEndpoint": "localhost:8080",
3032
"globPattern": "**/*@(.sh)",
3133
"highlightParsingErrors": true,
34+
"includeAllWorkspaceSymbols": true,
3235
"shellcheckArguments": Array [
3336
"-e",
3437
"SC2001",

server/src/analyser.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ export default class Analyzer {
4545
variable_assignment: LSP.SymbolKind.Variable,
4646
}
4747

48-
private isSourcingAware: boolean
48+
private includeAllWorkspaceSymbols: boolean
4949
private workspaceFolder: string | null
5050

5151
public constructor({
5252
console,
53-
isSourcingAware = true,
53+
includeAllWorkspaceSymbols = false,
5454
parser,
5555
workspaceFolder,
5656
}: {
5757
console: LSP.RemoteConsole
58-
isSourcingAware?: boolean
58+
includeAllWorkspaceSymbols?: boolean
5959
parser: Parser
6060
workspaceFolder: string | null
6161
}) {
6262
this.console = console
63-
this.isSourcingAware = isSourcingAware
63+
this.includeAllWorkspaceSymbols = includeAllWorkspaceSymbols
6464
this.parser = parser
6565
this.workspaceFolder = workspaceFolder
6666
}
@@ -564,14 +564,14 @@ export default class Analyzer {
564564
)
565565
}
566566

567-
public setIsSourcingAware(isSourcingAware: boolean): void {
568-
this.isSourcingAware = isSourcingAware
567+
public setIncludeAllWorkspaceSymbols(includeAllWorkspaceSymbols: boolean): void {
568+
this.includeAllWorkspaceSymbols = includeAllWorkspaceSymbols
569569
}
570570

571571
private getReachableUriToDeclarations({
572572
uri: fromUri,
573573
}: { uri?: string } = {}): FileDeclarations {
574-
if (!fromUri || !this.isSourcingAware) {
574+
if (!fromUri || this.includeAllWorkspaceSymbols) {
575575
return this.uriToDeclarations
576576
}
577577

server/src/config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import { z } from 'zod'
22

33
export const ConfigSchema = z
44
.object({
5-
// Controls if completions are based only on analyzing the import/sourcing of files.
6-
// If false, completion will be based on all files in the workspace.
7-
completionBasedOnImports: z.boolean().default(true),
8-
95
// Maximum number of files to analyze in the background. Set to 0 to disable background analysis.
106
backgroundAnalysisMaxFiles: z.number().int().min(0).default(500),
117

@@ -19,6 +15,11 @@ export const ConfigSchema = z
1915
// Controls if Treesitter parsing errors will be highlighted as problems.
2016
highlightParsingErrors: z.boolean().default(false),
2117

18+
// Controls how symbols (e.g. variables and functions) are included and used for completion and documentation.
19+
// If false, then we only include symbols from sourced files (i.e. using non dynamic statements like 'source file.sh' or '. file.sh').
20+
// If true, then all symbols from the workspace are included.
21+
includeAllWorkspaceSymbols: z.boolean().default(false),
22+
2223
// Additional ShellCheck arguments. Note that we already add the following arguments: --shell, --format, --external-sources."
2324
shellcheckArguments: z
2425
.preprocess((arg) => {
@@ -48,10 +49,10 @@ export function getConfigFromEnvironmentVariables(): {
4849
} {
4950
const rawConfig = {
5051
backgroundAnalysisMaxFiles: process.env.BACKGROUND_ANALYSIS_MAX_FILES,
51-
completionBasedOnImports: toBoolean(process.env.COMPLETION_BASED_ON_IMPORTS),
5252
explainshellEndpoint: process.env.EXPLAINSHELL_ENDPOINT,
5353
globPattern: process.env.GLOB_PATTERN,
5454
highlightParsingErrors: toBoolean(process.env.HIGHLIGHT_PARSING_ERRORS),
55+
includeAllWorkspaceSymbols: toBoolean(process.env.INCLUDE_ALL_WORKSPACE_SYMBOLS),
5556
shellcheckArguments: process.env.SHELLCHECK_ARGUMENTS,
5657
shellcheckPath: process.env.SHELLCHECK_PATH,
5758
}

server/src/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ export default class BashServer {
227227
})
228228
}
229229

230-
this.analyzer.setIsSourcingAware(this.config.completionBasedOnImports)
230+
this.analyzer.setIncludeAllWorkspaceSymbols(
231+
this.config.includeAllWorkspaceSymbols,
232+
)
231233

232234
return true
233235
}

vscode-client/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
"description": "Maximum number of files to analyze in the background. Set to 0 to disable background analysis.",
3838
"minimum": 0
3939
},
40-
"bashIde.completionBasedOnImports": {
41-
"type": "boolean",
42-
"default": true,
43-
"description": "Controls if symbols completion across files is based on parsing sourcing statements (i.e. 'source file.sh' or '. file.sh'). If false then all symbols found in the workspace will be used."
44-
},
4540
"bashIde.explainshellEndpoint": {
4641
"type": "string",
4742
"default": "",
@@ -57,6 +52,11 @@
5752
"default": false,
5853
"description": "Controls if Treesitter parsing errors will be highlighted as problems."
5954
},
55+
"bashIde.includeAllWorkspaceSymbols": {
56+
"type": "boolean",
57+
"default": false,
58+
"description": "Controls how symbols (e.g. variables and functions) are included and used for completion and documentation. If false (default and recommended), then we only include symbols from sourced files (i.e. using non dynamic statements like 'source file.sh' or '. file.sh'). If true, then all symbols from the workspace are included."
59+
},
6060
"bashIde.shellcheckPath": {
6161
"type": "string",
6262
"default": "shellcheck",

0 commit comments

Comments
 (0)