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
7
7
8
8
import { JAVA_LANGID } from "./constants" ;
9
9
import { IMainMethod , resolveMainMethod } from "./languageServerPlugin" ;
10
+ import { getJavaExtensionAPI , isJavaExtEnabled } from "./utility" ;
10
11
11
12
const JAVA_RUN_CODELENS_COMMAND = "java.debug.runCodeLens" ;
12
13
const JAVA_DEBUG_CODELENS_COMMAND = "java.debug.debugCodeLens" ;
13
14
const JAVA_DEBUG_CONFIGURATION = "java.debug.settings" ;
14
15
const ENABLE_CODE_LENS_VARIABLE = "enableRunDebugCodeLens" ;
15
16
16
17
export 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 ;
18
34
}
19
35
20
36
class DebugCodeLensContainer implements vscode . Disposable {
You can’t perform that action at this time.
0 commit comments