File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,30 @@ import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-w
77
88import { JAVA_LANGID } from "./constants" ;
99import { IMainMethod , resolveMainMethod } from "./languageServerPlugin" ;
10+ import { getJavaExtensionAPI , isJavaExtEnabled } from "./utility" ;
1011
1112const JAVA_RUN_CODELENS_COMMAND = "java.debug.runCodeLens" ;
1213const JAVA_DEBUG_CODELENS_COMMAND = "java.debug.debugCodeLens" ;
1314const JAVA_DEBUG_CONFIGURATION = "java.debug.settings" ;
1415const ENABLE_CODE_LENS_VARIABLE = "enableRunDebugCodeLens" ;
1516
1617export function initializeCodeLensProvider ( context : vscode . ExtensionContext ) : void {
17- context . subscriptions . push ( new DebugCodeLensContainer ( ) ) ;
18+ // delay registering codelens provider until the Java extension is activated.
19+ if ( isActivatedByJavaFile ( ) && isJavaExtEnabled ( ) ) {
20+ getJavaExtensionAPI ( ) . then ( ( ) => {
21+ context . subscriptions . push ( new DebugCodeLensContainer ( ) ) ;
22+ } ) ;
23+ } else {
24+ context . subscriptions . push ( new DebugCodeLensContainer ( ) ) ;
25+ }
26+ }
27+
28+ function isActivatedByJavaFile ( ) : boolean {
29+ if ( vscode . window . activeTextEditor ) {
30+ return vscode . window . activeTextEditor . document && vscode . window . activeTextEditor . document . languageId === "java" ;
31+ }
32+
33+ return false ;
1834}
1935
2036class DebugCodeLensContainer implements vscode . Disposable {
You can’t perform that action at this time.
0 commit comments