Skip to content

Commit 2888cd1

Browse files
Add restart IntelliSense command for active file
1 parent c4a1cd6 commit 2888cd1

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,11 @@
18131813
"title": "%java.server.restart%",
18141814
"category": "Java"
18151815
},
1816+
{
1817+
"command": "java.runtime.restartIntellisense",
1818+
"title": "Restart IntelliSense for Active File",
1819+
"category": "Java"
1820+
},
18161821
{
18171822
"command": "java.action.filesExplorerPasteAction",
18181823
"title": "%java.action.filesExplorerPasteAction%",
@@ -1941,6 +1946,11 @@
19411946
"command": "java.action.showTypeHierarchy",
19421947
"when": "javaLSReady && editorTextFocus && editorLangId == java",
19431948
"group": "0_navigation@3"
1949+
},
1950+
{
1951+
"command": "java.runtime.restartIntellisense",
1952+
"when": "editorTextFocus && editorLangId == java",
1953+
"group": "navigation@91"
19441954
}
19451955
],
19461956
"commandPalette": [

src/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export namespace Commands {
284284
* Command to restart the language server.
285285
*/
286286
export const RESTART_LANGUAGE_SERVER = 'java.server.restart';
287+
export const RESTART_INTELLISENSE_FOR_ACTIVE_FILE = 'java.runtime.restartIntellisense';
287288

288289
export const LEARN_MORE_ABOUT_REFACTORING = '_java.learnMoreAboutRefactorings';
289290

src/extension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,13 @@ function registerRestartJavaLanguageServerCommand(context: ExtensionContext) {
12701270
break;
12711271
}
12721272
}));
1273+
context.subscriptions.push(commands.registerCommand(Commands.RESTART_INTELLISENSE_FOR_ACTIVE_FILE, async () => {
1274+
const editor = window.activeTextEditor;
1275+
if (!editor || editor.document.languageId !== "java") {
1276+
return;
1277+
}
1278+
await commands.executeCommand(Commands.RESTART_LANGUAGE_SERVER);
1279+
}));
12731280
}
12741281

12751282
function escapeSnippetLiterals(value: string): string {

0 commit comments

Comments
 (0)