Skip to content
Merged
Changes from all commits
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
18 changes: 17 additions & 1 deletion src/debugCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@ import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-w

import { JAVA_LANGID } from "./constants";
import { IMainMethod, resolveMainMethod } from "./languageServerPlugin";
import { getJavaExtensionAPI, isJavaExtEnabled } from "./utility";

const JAVA_RUN_CODELENS_COMMAND = "java.debug.runCodeLens";
const JAVA_DEBUG_CODELENS_COMMAND = "java.debug.debugCodeLens";
const JAVA_DEBUG_CONFIGURATION = "java.debug.settings";
const ENABLE_CODE_LENS_VARIABLE = "enableRunDebugCodeLens";

export function initializeCodeLensProvider(context: vscode.ExtensionContext): void {
context.subscriptions.push(new DebugCodeLensContainer());
// delay registering codelens provider until the Java extension is activated.
if (isActivatedByJavaFile() && isJavaExtEnabled()) {
getJavaExtensionAPI().then(() => {
context.subscriptions.push(new DebugCodeLensContainer());
});
} else {
context.subscriptions.push(new DebugCodeLensContainer());
}
}

function isActivatedByJavaFile(): boolean {
if (vscode.window.activeTextEditor) {
return vscode.window.activeTextEditor.document && vscode.window.activeTextEditor.document.languageId === "java";
}

return false;
}

class DebugCodeLensContainer implements vscode.Disposable {
Expand Down