Skip to content

Commit 755350a

Browse files
committed
Switch to getters/setters for easier option access
1 parent 74748aa commit 755350a

27 files changed

+491
-606
lines changed

omnisharptest/omnisharpJestTests/options.test.ts

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,71 +15,71 @@ describe('Options tests', () => {
1515
jest.spyOn(vscode.workspace, 'getConfiguration').mockReturnValue(getWorkspaceConfiguration());
1616
});
1717
test('Verify defaults', () => {
18-
expect(commonOptions.serverPath.getValue(vscode)).toEqual('');
19-
expect(omnisharpOptions.monoPath.getValue(vscode)).toEqual('');
20-
expect(commonOptions.defaultSolution.getValue(vscode)).toEqual('');
21-
expect(commonOptions.waitForDebugger.getValue(vscode)).toEqual(false);
22-
expect(omnisharpOptions.loggingLevel.getValue(vscode)).toEqual('information');
23-
expect(omnisharpOptions.autoStart.getValue(vscode)).toEqual(true);
24-
expect(omnisharpOptions.projectLoadTimeout.getValue(vscode)).toEqual(60);
25-
expect(omnisharpOptions.maxProjectResults.getValue(vscode)).toEqual(250);
26-
expect(omnisharpOptions.useEditorFormattingSettings.getValue(vscode)).toEqual(true);
27-
expect(omnisharpOptions.useFormatting.getValue(vscode)).toEqual(true);
28-
expect(omnisharpOptions.showReferencesCodeLens.getValue(vscode)).toEqual(true);
29-
expect(omnisharpOptions.showTestsCodeLens.getValue(vscode)).toEqual(true);
30-
expect(omnisharpOptions.disableCodeActions.getValue(vscode)).toEqual(false);
31-
expect(omnisharpOptions.showOmnisharpLogOnError.getValue(vscode)).toEqual(true);
32-
expect(omnisharpOptions.minFindSymbolsFilterLength.getValue(vscode)).toEqual(0);
33-
expect(omnisharpOptions.maxFindSymbolsItems.getValue(vscode)).toEqual(1000);
34-
expect(omnisharpOptions.enableMsBuildLoadProjectsOnDemand.getValue(vscode)).toEqual(false);
35-
expect(omnisharpOptions.enableRoslynAnalyzers.getValue(vscode)).toEqual(true);
36-
expect(omnisharpOptions.enableEditorConfigSupport.getValue(vscode)).toEqual(true);
37-
expect(omnisharpOptions.enableDecompilationSupport.getValue(vscode)).toEqual(false);
38-
expect(omnisharpOptions.enableImportCompletion.getValue(vscode)).toEqual(false);
39-
expect(omnisharpOptions.enableAsyncCompletion.getValue(vscode)).toEqual(false);
40-
expect(omnisharpOptions.analyzeOpenDocumentsOnly.getValue(vscode)).toEqual(true);
41-
expect(commonOptions.runSettingsPath.getValue(vscode)).toEqual('');
18+
expect(commonOptions.serverPath).toEqual('');
19+
expect(omnisharpOptions.monoPath).toEqual('');
20+
expect(commonOptions.defaultSolution).toEqual('');
21+
expect(commonOptions.waitForDebugger).toEqual(false);
22+
expect(omnisharpOptions.loggingLevel).toEqual('information');
23+
expect(omnisharpOptions.autoStart).toEqual(true);
24+
expect(omnisharpOptions.projectLoadTimeout).toEqual(60);
25+
expect(omnisharpOptions.maxProjectResults).toEqual(250);
26+
expect(omnisharpOptions.useEditorFormattingSettings).toEqual(true);
27+
expect(omnisharpOptions.useFormatting).toEqual(true);
28+
expect(omnisharpOptions.showReferencesCodeLens).toEqual(true);
29+
expect(omnisharpOptions.showTestsCodeLens).toEqual(true);
30+
expect(omnisharpOptions.disableCodeActions).toEqual(false);
31+
expect(omnisharpOptions.showOmnisharpLogOnError).toEqual(true);
32+
expect(omnisharpOptions.minFindSymbolsFilterLength).toEqual(0);
33+
expect(omnisharpOptions.maxFindSymbolsItems).toEqual(1000);
34+
expect(omnisharpOptions.enableMsBuildLoadProjectsOnDemand).toEqual(false);
35+
expect(omnisharpOptions.enableRoslynAnalyzers).toEqual(true);
36+
expect(omnisharpOptions.enableEditorConfigSupport).toEqual(true);
37+
expect(omnisharpOptions.enableDecompilationSupport).toEqual(false);
38+
expect(omnisharpOptions.enableImportCompletion).toEqual(false);
39+
expect(omnisharpOptions.enableAsyncCompletion).toEqual(false);
40+
expect(omnisharpOptions.analyzeOpenDocumentsOnly).toEqual(true);
41+
expect(commonOptions.runSettingsPath).toEqual('');
4242
});
4343

4444
test('Verify return no excluded paths when files.exclude empty', () => {
4545
vscode.workspace.getConfiguration().update('files.exclude', {});
4646

47-
const excludedPaths = commonOptions.excludePaths.getValue(vscode);
47+
const excludedPaths = commonOptions.excludePaths;
4848
expect(excludedPaths).toHaveLength(0);
4949
});
5050

5151
test('Verify return excluded paths when files.exclude populated', () => {
5252
vscode.workspace.getConfiguration().update('files.exclude', { '**/node_modules': true, '**/assets': false });
5353

54-
const excludedPaths = commonOptions.excludePaths.getValue(vscode);
54+
const excludedPaths = commonOptions.excludePaths;
5555
expect(excludedPaths).toStrictEqual(['**/node_modules']);
5656
});
5757

5858
test('Verify return no excluded paths when files.exclude and search.exclude empty', () => {
5959
vscode.workspace.getConfiguration().update('files.exclude', {});
6060
vscode.workspace.getConfiguration().update('search.exclude', {});
6161

62-
const excludedPaths = commonOptions.excludePaths.getValue(vscode);
62+
const excludedPaths = commonOptions.excludePaths;
6363
expect(excludedPaths).toHaveLength(0);
6464
});
6565

6666
test('BACK-COMPAT: "omnisharp.loggingLevel": "verbose" == "omnisharp.loggingLevel": "debug"', () => {
6767
vscode.workspace.getConfiguration().update('omnisharp.loggingLevel', 'verbose');
6868

69-
expect(omnisharpOptions.loggingLevel.getValue(vscode)).toEqual('debug');
69+
expect(omnisharpOptions.loggingLevel).toEqual('debug');
7070
});
7171

7272
test('BACK-COMPAT: "csharp.omnisharp" is used if it is set and "omnisharp.path" is not', () => {
7373
vscode.workspace.getConfiguration().update('csharp.omnisharp', 'OldPath');
7474

75-
expect(commonOptions.serverPath.getValue(vscode)).toEqual('OldPath');
75+
expect(commonOptions.serverPath).toEqual('OldPath');
7676
});
7777

7878
test('BACK-COMPAT: "csharp.omnisharp" is not used if "omnisharp.path" is set', () => {
7979
vscode.workspace.getConfiguration().update('omnisharp.path', 'NewPath');
8080
vscode.workspace.getConfiguration().update('csharp.omnisharp', 'OldPath');
8181

82-
expect(commonOptions.serverPath.getValue(vscode)).toEqual('NewPath');
82+
expect(commonOptions.serverPath).toEqual('NewPath');
8383
});
8484

8585
test('"omnisharp.defaultLaunchSolution" is used if set', () => {
@@ -90,18 +90,14 @@ describe('Options tests', () => {
9090

9191
vscode.workspace.getConfiguration().update('omnisharp.defaultLaunchSolution', 'some_valid_solution.sln');
9292

93-
expect(commonOptions.defaultSolution.getValue(vscode)).toEqual(
94-
path.join(workspaceFolderUri.fsPath, 'some_valid_solution.sln')
95-
);
93+
expect(commonOptions.defaultSolution).toEqual(path.join(workspaceFolderUri.fsPath, 'some_valid_solution.sln'));
9694
});
9795

9896
test('"omnisharp.testRunSettings" is used if set', () => {
9997
vscode.workspace
10098
.getConfiguration()
10199
.update('omnisharp.testRunSettings', 'some_valid_path\\some_valid_runsettings_files.runsettings');
102100

103-
expect(commonOptions.runSettingsPath.getValue(vscode)).toEqual(
104-
'some_valid_path\\some_valid_runsettings_files.runsettings'
105-
);
101+
expect(commonOptions.runSettingsPath).toEqual('some_valid_path\\some_valid_runsettings_files.runsettings');
106102
});
107103
});

src/coreclrDebug/activate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async function completeDebuggerInstall(
154154
eventStream: EventStream
155155
): Promise<boolean> {
156156
try {
157-
await debugUtil.checkDotNetCli(omnisharpOptions.dotNetCliPaths.getValue(vscode));
157+
await debugUtil.checkDotNetCli(omnisharpOptions.dotNetCliPaths);
158158
const isValidArchitecture = await checkIsValidArchitecture(platformInformation, eventStream);
159159
if (!isValidArchitecture) {
160160
eventStream.post(new DebuggerNotInstalledFailure());
@@ -277,7 +277,7 @@ export class DebugAdapterExecutableFactory implements vscode.DebugAdapterDescrip
277277

278278
// use the executable specified in the package.json if it exists or determine it based on some other information (e.g. the session)
279279
if (!executable) {
280-
const dotNetInfo = await getDotnetInfo(omnisharpOptions.dotNetCliPaths.getValue(vscode));
280+
const dotNetInfo = await getDotnetInfo(omnisharpOptions.dotNetCliPaths);
281281
const targetArchitecture = getTargetArchitecture(
282282
this.platformInfo,
283283
_session.configuration.targetArchitecture,

src/features/codeActionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class OmniSharpCodeActionProvider
3232
context: vscode.CodeActionContext,
3333
token: vscode.CancellationToken
3434
): Promise<vscode.CodeAction[] | undefined> {
35-
if (omnisharpOptions.disableCodeActions.getValue(vscode)) {
35+
if (omnisharpOptions.disableCodeActions) {
3636
return;
3737
}
3838

src/features/codeLensProvider.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,7 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
8787
document: vscode.TextDocument,
8888
token: vscode.CancellationToken
8989
): Promise<vscode.CodeLens[]> {
90-
if (
91-
!omnisharpOptions.showReferencesCodeLens.getValue(vscode) &&
92-
!omnisharpOptions.showTestsCodeLens.getValue(vscode)
93-
) {
90+
if (!omnisharpOptions.showReferencesCodeLens && !omnisharpOptions.showTestsCodeLens) {
9491
return [];
9592
}
9693

@@ -222,14 +219,14 @@ function createCodeLenses(elements: Structure.CodeElement[], fileName: string):
222219
function createCodeLensesForElement(element: Structure.CodeElement, fileName: string): vscode.CodeLens[] {
223220
const results: vscode.CodeLens[] = [];
224221

225-
if (omnisharpOptions.showReferencesCodeLens.getValue(vscode) && isValidElementForReferencesCodeLens(element)) {
222+
if (omnisharpOptions.showReferencesCodeLens && isValidElementForReferencesCodeLens(element)) {
226223
const range = element.Ranges[SymbolRangeNames.Name];
227224
if (range) {
228225
results.push(new ReferencesCodeLens(range, fileName));
229226
}
230227
}
231228

232-
if (omnisharpOptions.showTestsCodeLens.getValue(vscode)) {
229+
if (omnisharpOptions.showTestsCodeLens) {
233230
if (element.Kind === SymbolKinds.Method) {
234231
const test = getTest(element);
235232
if (test !== undefined) {
@@ -317,7 +314,7 @@ function isValidElementForReferencesCodeLens(element: Structure.CodeElement): bo
317314
return false;
318315
}
319316

320-
if (omnisharpOptions.filteredSymbolsCodeLens.getValue(vscode).includes(element.Name)) {
317+
if (omnisharpOptions.filteredSymbolsCodeLens.includes(element.Name)) {
321318
return false;
322319
}
323320

src/features/diagnosticsProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class Advisor {
9393
}
9494

9595
private _isOverFileLimit(): boolean {
96-
const fileLimit = omnisharpOptions.maxProjectFileCountForDiagnosticAnalysis.getValue(vscode);
96+
const fileLimit = omnisharpOptions.maxProjectFileCountForDiagnosticAnalysis;
9797
if (fileLimit > 0) {
9898
let sourceFileCount = 0;
9999
for (const key in this._projectSourceFileCounts) {
@@ -150,7 +150,7 @@ class OmniSharpDiagnosticsProvider extends AbstractSupport {
150150
.getConfiguration('csharp')
151151
.get('suppressHiddenDiagnostics', true);
152152

153-
if (!omnisharpOptions.enableLspDriver.getValue(vscode)) {
153+
if (!omnisharpOptions.enableLspDriver) {
154154
this._subscriptions.push(
155155
this._validateCurrentDocumentPipe
156156
.pipe(debounceTime(750))

src/features/dotnetTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export default class TestManager extends AbstractProvider {
232232
}
233233

234234
private _getRunSettings(filename: string): string | undefined {
235-
const testSettingsPath = commonOptions.runSettingsPath.getValue(vscode);
235+
const testSettingsPath = commonOptions.runSettingsPath;
236236
if (testSettingsPath.length === 0) {
237237
return undefined;
238238
}
@@ -392,7 +392,7 @@ export default class TestManager extends AbstractProvider {
392392
environmentVariables: Map<string, string>,
393393
debuggerEventsPipeName: string
394394
) {
395-
const debugOptions = commonOptions.unitTestDebuggingOptions.getValue(vscode);
395+
const debugOptions = commonOptions.unitTestDebuggingOptions;
396396

397397
// Get the initial set of options from the workspace setting
398398
let result: any;

src/features/semanticTokensProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default class OmniSharpSemanticTokensProvider
205205
return null;
206206
}
207207

208-
if (!omnisharpOptions.useSemanticHighlighting.getValue(vscode)) {
208+
if (!omnisharpOptions.useSemanticHighlighting) {
209209
return null;
210210
}
211211

src/features/workspaceSymbolProvider.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as vscode from 'vscode';
76
import AbstractSupport from './abstractProvider';
87
import { OmniSharpServer } from '../omnisharp/server';
98
import * as protocol from '../omnisharp/protocol';
@@ -24,8 +23,8 @@ export default class OmniSharpWorkspaceSymbolProvider extends AbstractSupport im
2423
}
2524

2625
public async provideWorkspaceSymbols(search: string, token: CancellationToken): Promise<SymbolInformation[]> {
27-
const minFindSymbolsFilterLength = omnisharpOptions.minFindSymbolsFilterLength.getValue(vscode);
28-
const maxFindSymbolsItems = omnisharpOptions.maxFindSymbolsItems.getValue(vscode);
26+
const minFindSymbolsFilterLength = omnisharpOptions.minFindSymbolsFilterLength;
27+
const maxFindSymbolsItems = omnisharpOptions.maxFindSymbolsItems;
2928
const minFilterLength = minFindSymbolsFilterLength > 0 ? minFindSymbolsFilterLength : undefined;
3029
const maxItemsToReturn = maxFindSymbolsItems > 0 ? maxFindSymbolsItems : undefined;
3130

src/lsptoolshost/dotnetRuntimeExtensionResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class DotnetRuntimeExtensionResolver implements IHostExecutableResolver {
4141
private hostInfo: HostExecutableInformation | undefined;
4242

4343
async getHostExecutableInfo(): Promise<HostExecutableInformation> {
44-
let dotnetRuntimePath = commonOptions.dotnetPath.getValue(vscode);
44+
let dotnetRuntimePath = commonOptions.dotnetPath;
4545
const serverPath = this.getServerPath(this.platformInfo);
4646

4747
// Check if we can find a valid dotnet from dotnet --version on the PATH.

src/lsptoolshost/onAutoInsert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { languageServerOptions } from '../shared/options';
1414
export function registerOnAutoInsert(languageServer: RoslynLanguageServer) {
1515
let source = new vscode.CancellationTokenSource();
1616
vscode.workspace.onDidChangeTextDocument(async (e) => {
17-
if (!languageServerOptions.documentSelector.getValue(vscode).includes(e.document.languageId)) {
17+
if (!languageServerOptions.documentSelector.includes(e.document.languageId)) {
1818
return;
1919
}
2020

0 commit comments

Comments
 (0)