Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable the references CodeLens #1781

Merged
merged 2 commits into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@
"default": true,
"description": "Suppress 'hidden' diagnostics (such as 'unnecessary using directives') from appearing in the editor or the Problems pane."
},
"csharp.showReferencesCodeLens": {
"type": "boolean",
"default": true,
"description": "Specifies whether the references CodeLens show be shown."
},
"omnisharp.path": {
"type": [
"string",
Expand Down
7 changes: 7 additions & 0 deletions src/features/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { toRange, toLocation } from '../omnisharp/typeConvertion';
import AbstractProvider from './abstractProvider';
import * as protocol from '../omnisharp/protocol';
import * as serverUtils from '../omnisharp/utils';
import { Options } from '../omnisharp/options';

class OmniSharpCodeLens extends vscode.CodeLens {

Expand Down Expand Up @@ -43,6 +44,12 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
};

provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.CodeLens[] | Thenable<vscode.CodeLens[]> {
const options = Options.Read();
if (!options.showReferencesCodeLens)
{
return [];
}

return serverUtils.currentFileMembersAsTree(this._server, { FileName: document.fileName }, token).then(tree => {
let ret: vscode.CodeLens[] = [];
tree.TopLevelTypeDefinitions.forEach(node => this._convertQuickFix(ret, document.fileName, node));
Expand Down
16 changes: 14 additions & 2 deletions src/omnisharp/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export class Options {
public projectLoadTimeout?: number,
public maxProjectResults?: number,
public useEditorFormattingSettings?: boolean,
public useFormatting?: boolean) { }
public useFormatting?: boolean,
public showReferencesCodeLens?: boolean) { }

public static Read(): Options {
// Extra effort is taken below to ensure that legacy versions of options
Expand Down Expand Up @@ -51,6 +52,17 @@ export class Options {

const useFormatting = csharpConfig.get<boolean>('format.enable', true);

return new Options(path, useMono, waitForDebugger, loggingLevel, autoStart, projectLoadTimeout, maxProjectResults, useEditorFormattingSettings, useFormatting);
const showReferencesCodeLens = csharpConfig.get<boolean>('showReferencesCodeLens', true);

return new Options(path,
useMono,
waitForDebugger,
loggingLevel,
autoStart,
projectLoadTimeout,
maxProjectResults,
useEditorFormattingSettings,
useFormatting,
showReferencesCodeLens);
}
}