Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,14 @@
"when": "extensionActivated"
}
]
}
},
"viewsWelcome": [
{
"view": "javaProjectExplorer",
"contents": "No projects 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)",
Comment thread
jdneo marked this conversation as resolved.
Outdated
"when": "java:serverMode == LightWeight"
}
]
},
"scripts": {
"compile": "tsc -p . && webpack --config webpack.config.js",
Expand Down
4 changes: 0 additions & 4 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ export namespace Commands {

export const JAVA_GETPACKAGEDATA = "java.getPackageData";

export const JAVA_PROJECT_SWITCH_SERVER_MODE = "java.project.switch.server.mode";

/**
* command from VS Code Java to switch the language server mode
*/
export const JAVA_SWITCH_SERVER_MODE = "java.server.mode.switch";

export const JAVA_RESOLVEPATH = "java.resolvePath";

export const JAVA_PROJECT_GETMAINMETHOD = "java.project.getMainMethod";
Expand Down
23 changes: 13 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

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

initExpService(context);

context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_PROJECT_SWITCH_SERVER_MODE, async () => {
if (isSwitchingServer()) {
return;
}
await commands.executeCommand(Commands.JAVA_SWITCH_SERVER_MODE, "Standard" /*mode*/);
}));
}

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

if (serverMode !== "Standard") {
if (serverMode !== LanguageServerMode.Standard) {
return false;
}

return true;
}

export function isLightWeightMode(): boolean {
return serverMode === LanguageServerMode.LightWeight;
}

export function isSwitchingServer(): boolean {
return serverMode === "Hybrid";
return serverMode === LanguageServerMode.Hybrid;
}

let serverMode: string | undefined;

const enum LanguageServerMode {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A potential debt here that other extension may need this as well.

LightWeight = "LightWeight",
Standard = "Standard",
Hybrid = "Hybrid",
}
13 changes: 5 additions & 8 deletions src/views/dependencyDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import { instrumentOperation, instrumentOperationAsVsCodeCommand } from "vscode-
import { Commands } from "../commands";
import { newJavaClass, newPackage } from "../explorerCommands/new";
import { createJarFile } from "../exportJarFileCommand";
import { isStandardServerReady, isSwitchingServer } from "../extension";
import { isLightWeightMode, isSwitchingServer } from "../extension";
import { Jdtls } from "../java/jdtls";
import { INodeData, NodeKind } from "../java/nodeData";
import { Settings } from "../settings";
import { DataNode } from "./dataNode";
import { ExplorerNode } from "./explorerNode";
import { LightWeightNode } from "./lightWeightNode";
import { explorerNodeCache } from "./nodeCache/explorerNodeCache";
import { ProjectNode } from "./projectNode";
import { WorkspaceNode } from "./workspaceNode";
Expand Down Expand Up @@ -97,18 +96,16 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
}

public async getChildren(element?: ExplorerNode): Promise<ExplorerNode[]> {
if (isLightWeightMode()) {
return [];
}

if (isSwitchingServer()) {
await new Promise<void>((resolve: () => void): void => {
extensions.getExtension("redhat.java")!.exports.onDidServerModeChange(resolve);
});
}

if (!isStandardServerReady()) {
return [
new LightWeightNode(),
];
}

if (!this._rootItems || !element) {
return this.getRootNodes();
} else {
Expand Down
30 changes: 0 additions & 30 deletions src/views/lightWeightNode.ts

This file was deleted.