Skip to content

Commit 6c4e9d0

Browse files
committed
Add setting 'java.references.includeDeclarations'.
- Control inclusion of declarations when searching for references. Signed-off-by: Roland Grunberg <[email protected]>
1 parent 2cd1c83 commit 6c4e9d0

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

package.json

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,26 +1422,33 @@
14221422
"scope": "window",
14231423
"order": 30
14241424
},
1425+
"java.references.includeDeclarations": {
1426+
"type": "boolean",
1427+
"default": true,
1428+
"description": "Include declarations when finding references.",
1429+
"scope": "window",
1430+
"order": 40
1431+
},
14251432
"java.references.includeDecompiledSources": {
14261433
"type": "boolean",
14271434
"default": true,
14281435
"description": "Include the decompiled sources when finding references.",
14291436
"scope": "window",
1430-
"order": 40
1437+
"order": 50
14311438
},
14321439
"java.symbols.includeSourceMethodDeclarations": {
14331440
"type": "boolean",
14341441
"markdownDescription": "Include method declarations from source files in symbol search.",
14351442
"default": false,
14361443
"scope": "window",
1437-
"order": 50
1444+
"order": 60
14381445
},
14391446
"java.typeHierarchy.lazyLoad": {
14401447
"type": "boolean",
14411448
"default": false,
14421449
"description": "Enable/disable lazy loading the content in type hierarchy. Lazy loading could save a lot of loading time but every type should be expanded manually to load its content.",
14431450
"scope": "window",
1444-
"order": 60
1451+
"order": 70
14451452
},
14461453
"java.inlayHints.parameterNames.enabled": {
14471454
"type": "string",
@@ -1458,7 +1465,7 @@
14581465
"default": "literals",
14591466
"markdownDescription": "Enable/disable inlay hints for parameter names:\n```java\n\nInteger.valueOf(/* s: */ '123', /* radix: */ 10)\n \n```\n `#java.inlayHints.parameterNames.exclusions#` can be used to disable the inlay hints for methods.",
14601467
"scope": "window",
1461-
"order": 70
1468+
"order": 80
14621469
},
14631470
"java.inlayHints.parameterNames.exclusions": {
14641471
"type": "array",
@@ -1468,7 +1475,7 @@
14681475
"default": [],
14691476
"markdownDescription": "The patterns for the methods that will be disabled to show the inlay hints. Supported pattern examples:\n - `java.lang.Math.*` - All the methods from java.lang.Math.\n - `*.Arrays.asList` - Methods named as 'asList' in the types named as 'Arrays'.\n - `*.println(*)` - Methods named as 'println'.\n - `(from, to)` - Methods with two parameters named as 'from' and 'to'.\n - `(arg*)` - Methods with one parameter whose name starts with 'arg'.",
14701477
"scope": "window",
1471-
"order": 80
1478+
"order": 90
14721479
},
14731480
"java.search.scope": {
14741481
"type": "string",
@@ -1483,7 +1490,7 @@
14831490
"default": "all",
14841491
"markdownDescription": "Specifies the scope which must be used for search operation like \n - Find Reference\n - Call Hierarchy\n - Workspace Symbols",
14851492
"scope": "window",
1486-
"order": 90
1493+
"order": 100
14871494
}
14881495
}
14891496
},

src/extension.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as fse from 'fs-extra';
66
import * as os from 'os';
77
import * as path from 'path';
88
import * as semver from 'semver';
9-
import { CodeActionContext, commands, CompletionItem, ConfigurationTarget, Diagnostic, env, EventEmitter, ExtensionContext, extensions, IndentAction, InputBoxOptions, languages, MarkdownString, QuickPickItemKind, Range, RelativePattern, SnippetString, SnippetTextEdit, TextDocument, TextEditorRevealType, UIKind, Uri, ViewColumn, window, workspace, WorkspaceConfiguration, WorkspaceEdit } from 'vscode';
9+
import { CodeActionContext, commands, CompletionItem, ConfigurationTarget, Diagnostic, env, EventEmitter, ExtensionContext, extensions, IndentAction, InputBoxOptions, languages, Location, MarkdownString, QuickPickItemKind, Range, RelativePattern, SnippetString, SnippetTextEdit, TextDocument, TextEditorRevealType, UIKind, Uri, ViewColumn, window, workspace, WorkspaceConfiguration, WorkspaceEdit } from 'vscode';
1010
import { CancellationToken, CodeActionParams, CodeActionRequest, CodeActionResolveRequest, Command, CompletionRequest, DidChangeConfigurationNotification, ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient';
1111
import { LanguageClient } from 'vscode-languageclient/node';
1212
import { apiManager } from './apiManager';
@@ -355,6 +355,12 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>
355355
};
356356
return resolveCodeAction(item, token);
357357
},
358+
359+
provideReferences: async(document, position, options, token, next): Promise<Location[]> => {
360+
// Override includeDeclaration from VS Code by allowing it to be configured
361+
options.includeDeclaration = getJavaConfiguration().get('references.includeDeclarations');
362+
return await next(document, position, options, token);
363+
}
358364
},
359365
revealOutputChannelOn: RevealOutputChannelOn.Never,
360366
errorHandler: new ClientErrorHandler(extensionName),

0 commit comments

Comments
 (0)