diff --git a/package.json b/package.json index fd4d6412..b12e4ac1 100644 --- a/package.json +++ b/package.json @@ -328,7 +328,14 @@ "when": "extensionActivated" } ] - } + }, + "viewsWelcome": [ + { + "view": "javaProjectExplorer", + "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)", + "when": "java:serverMode == LightWeight" + } + ] }, "scripts": { "compile": "tsc -p . && webpack --config webpack.config.js", diff --git a/src/commands.ts b/src/commands.ts index 3b1d5587..fb319990 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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"; diff --git a/src/extension.ts b/src/extension.ts index ff95cae9..d81fa5d9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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"; @@ -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 @@ -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 { + LightWeight = "LightWeight", + Standard = "Standard", + Hybrid = "Hybrid", +} diff --git a/src/views/dependencyDataProvider.ts b/src/views/dependencyDataProvider.ts index bdf8d1a4..b664e085 100644 --- a/src/views/dependencyDataProvider.ts +++ b/src/views/dependencyDataProvider.ts @@ -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"; @@ -97,18 +96,16 @@ export class DependencyDataProvider implements TreeDataProvider { } public async getChildren(element?: ExplorerNode): Promise { + if (isLightWeightMode()) { + return []; + } + if (isSwitchingServer()) { await new Promise((resolve: () => void): void => { extensions.getExtension("redhat.java")!.exports.onDidServerModeChange(resolve); }); } - if (!isStandardServerReady()) { - return [ - new LightWeightNode(), - ]; - } - if (!this._rootItems || !element) { return this.getRootNodes(); } else { diff --git a/src/views/lightWeightNode.ts b/src/views/lightWeightNode.ts deleted file mode 100644 index f6b37314..00000000 --- a/src/views/lightWeightNode.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -import * as _ from "lodash"; -import { ProviderResult, ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode"; -import { Commands } from "../commands"; -import { ExplorerNode } from "./explorerNode"; - -export class LightWeightNode extends ExplorerNode { - constructor() { - super(null); - } - - public getTreeItem(): TreeItem | Promise { - return { - label: "Click to load dependencies...", - collapsibleState: TreeItemCollapsibleState.None, - command: { - command: Commands.JAVA_PROJECT_SWITCH_SERVER_MODE, - title: "Switch to Standard mode", - }, - tooltip: "Switch the Java Language Server to Standard mode to show all the dependencies", - iconPath: new ThemeIcon("info"), - }; - } - - public getChildren(): ProviderResult { - return null; - } -}