Skip to content

Commit

Permalink
Merge pull request #1781 from rchande/codeLensOption
Browse files Browse the repository at this point in the history
Add an option to disable the references CodeLens
  • Loading branch information
DustinCampbell authored Oct 6, 2017
2 parents 2a0d82e + 1d63100 commit 38ffa15
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
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);
}
}

0 comments on commit 38ffa15

Please sign in to comment.