Skip to content

Commit 83e910d

Browse files
authored
Adopt welcome view for lightweight mode (#300)
1 parent 1ec06e9 commit 83e910d

File tree

5 files changed

+26
-53
lines changed

5 files changed

+26
-53
lines changed

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,14 @@
328328
"when": "extensionActivated"
329329
}
330330
]
331-
}
331+
},
332+
"viewsWelcome": [
333+
{
334+
"view": "javaProjectExplorer",
335+
"contents": "No projects are listed because the Java Language Server is currently running in [LightWeight Mode](https://aka.ms/vscode-java-lightweight). To show projects, click on the button to switch to Standard Mode.\n[Switch to Standard Mode](command:java.server.mode.switch?%5B%22Standard%22,true%5D)",
336+
"when": "java:serverMode == LightWeight"
337+
}
338+
]
332339
},
333340
"scripts": {
334341
"compile": "tsc -p . && webpack --config webpack.config.js",

src/commands.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,9 @@ export namespace Commands {
5454

5555
export const JAVA_GETPACKAGEDATA = "java.getPackageData";
5656

57-
export const JAVA_PROJECT_SWITCH_SERVER_MODE = "java.project.switch.server.mode";
58-
5957
/**
6058
* command from VS Code Java to switch the language server mode
6159
*/
62-
export const JAVA_SWITCH_SERVER_MODE = "java.server.mode.switch";
63-
6460
export const JAVA_RESOLVEPATH = "java.resolvePath";
6561

6662
export const JAVA_PROJECT_GETMAINMETHOD = "java.project.getMainMethod";

src/extension.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import { commands, Event, Extension, ExtensionContext, extensions, Uri } from "vscode";
5-
import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentOperation, instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
5+
import { dispose as disposeTelemetryWrapper, initializeFromJsonFile, instrumentOperation } from "vscode-extension-telemetry-wrapper";
66
import { Commands } from "./commands";
77
import { Context } from "./constants";
88
import { contextManager } from "./contextManager";
@@ -63,13 +63,6 @@ async function activateExtension(_operationId: string, context: ExtensionContext
6363
contextManager.setContextValue(Context.EXTENSION_ACTIVATED, true);
6464

6565
initExpService(context);
66-
67-
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_SWITCH_SERVER_MODE, async () => {
68-
if (isSwitchingServer()) {
69-
return;
70-
}
71-
await commands.executeCommand(Commands.JAVA_SWITCH_SERVER_MODE, "Standard" /*mode*/);
72-
}));
7366
}
7467

7568
// determine if the add dependency shortcut will show or not
@@ -96,15 +89,25 @@ export function isStandardServerReady(): boolean {
9689
return true;
9790
}
9891

99-
if (serverMode !== "Standard") {
92+
if (serverMode !== LanguageServerMode.Standard) {
10093
return false;
10194
}
10295

10396
return true;
10497
}
10598

99+
export function isLightWeightMode(): boolean {
100+
return serverMode === LanguageServerMode.LightWeight;
101+
}
102+
106103
export function isSwitchingServer(): boolean {
107-
return serverMode === "Hybrid";
104+
return serverMode === LanguageServerMode.Hybrid;
108105
}
109106

110107
let serverMode: string | undefined;
108+
109+
const enum LanguageServerMode {
110+
LightWeight = "LightWeight",
111+
Standard = "Standard",
112+
Hybrid = "Hybrid",
113+
}

src/views/dependencyDataProvider.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import { instrumentOperation, instrumentOperationAsVsCodeCommand } from "vscode-
1010
import { Commands } from "../commands";
1111
import { newJavaClass, newPackage } from "../explorerCommands/new";
1212
import { createJarFile } from "../exportJarFileCommand";
13-
import { isStandardServerReady, isSwitchingServer } from "../extension";
13+
import { isLightWeightMode, isSwitchingServer } from "../extension";
1414
import { Jdtls } from "../java/jdtls";
1515
import { INodeData, NodeKind } from "../java/nodeData";
1616
import { Settings } from "../settings";
1717
import { DataNode } from "./dataNode";
1818
import { ExplorerNode } from "./explorerNode";
19-
import { LightWeightNode } from "./lightWeightNode";
2019
import { explorerNodeCache } from "./nodeCache/explorerNodeCache";
2120
import { ProjectNode } from "./projectNode";
2221
import { WorkspaceNode } from "./workspaceNode";
@@ -97,18 +96,16 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
9796
}
9897

9998
public async getChildren(element?: ExplorerNode): Promise<ExplorerNode[]> {
99+
if (isLightWeightMode()) {
100+
return [];
101+
}
102+
100103
if (isSwitchingServer()) {
101104
await new Promise<void>((resolve: () => void): void => {
102105
extensions.getExtension("redhat.java")!.exports.onDidServerModeChange(resolve);
103106
});
104107
}
105108

106-
if (!isStandardServerReady()) {
107-
return [
108-
new LightWeightNode(),
109-
];
110-
}
111-
112109
if (!this._rootItems || !element) {
113110
return this.getRootNodes();
114111
} else {

src/views/lightWeightNode.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)