@@ -72,6 +72,9 @@ import { JdkDownloaderView } from './jdkDownloader/view';
72
72
73
73
const API_VERSION : string = "1.0" ;
74
74
const SERVER_NAME : string = "Oracle Java SE Language Server" ;
75
+ const NB_LANGUAGE_CLIENT_ID : string = "java" ;
76
+ const LANGUAGE_ID : string = "java" ;
77
+
75
78
export const COMMAND_PREFIX : string = "jdk" ;
76
79
const listeners = new Map < string , string [ ] > ( ) ;
77
80
let client : Promise < NbLanguageClient > ;
@@ -171,15 +174,10 @@ function findJDK(onChange: (path : string | null) => void): void {
171
174
let nowDark : boolean = isDarkColorTheme ( ) ;
172
175
let nowNbJavacDisabled : boolean = isNbJavacDisabled ( ) ;
173
176
function find ( ) : string | null {
174
- let nbJdk = workspace . getConfiguration ( 'jdk' ) . get ( 'jdkhome' ) ;
177
+ let nbJdk = workspace . getConfiguration ( COMMAND_PREFIX ) . get ( 'jdkhome' ) ;
175
178
if ( nbJdk ) {
176
179
return nbJdk as string ;
177
180
}
178
- let javahome = workspace . getConfiguration ( 'java' ) . get ( 'home' ) ;
179
- if ( javahome ) {
180
- return javahome as string ;
181
- }
182
-
183
181
let jdkHome : any = process . env . JDK_HOME ;
184
182
if ( jdkHome ) {
185
183
return jdkHome as string ;
@@ -199,7 +197,7 @@ function findJDK(onChange: (path : string | null) => void): void {
199
197
return ;
200
198
}
201
199
let interested : boolean = false ;
202
- if ( params . affectsConfiguration ( 'jdk' ) || params . affectsConfiguration ( 'java' ) ) {
200
+ if ( params . affectsConfiguration ( COMMAND_PREFIX ) ) {
203
201
interested = true ;
204
202
} else if ( params . affectsConfiguration ( 'workbench.colorTheme' ) ) {
205
203
let d = isDarkColorTheme ( ) ;
@@ -215,7 +213,7 @@ function findJDK(onChange: (path : string | null) => void): void {
215
213
let newJdk = find ( ) ;
216
214
let newD = isDarkColorTheme ( ) ;
217
215
let newNbJavacDisabled = isNbJavacDisabled ( ) ;
218
- let newProjectJdk : string | undefined = workspace . getConfiguration ( 'jdk' ) ?. get ( 'project.jdkhome' ) as string ;
216
+ let newProjectJdk : string | undefined = workspace . getConfiguration ( COMMAND_PREFIX ) ?. get ( 'project.jdkhome' ) as string ;
219
217
if ( newJdk !== currentJdk || newD != nowDark || newNbJavacDisabled != nowNbJavacDisabled || newProjectJdk != projectJdk ) {
220
218
nowDark = newD ;
221
219
currentJdk = newJdk ;
@@ -367,23 +365,22 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
367
365
368
366
//register debugger:
369
367
let debugTrackerFactory = new NetBeansDebugAdapterTrackerFactory ( ) ;
370
- context . subscriptions . push ( vscode . debug . registerDebugAdapterTrackerFactory ( 'jdk' , debugTrackerFactory ) ) ;
368
+ context . subscriptions . push ( vscode . debug . registerDebugAdapterTrackerFactory ( COMMAND_PREFIX , debugTrackerFactory ) ) ;
371
369
let configInitialProvider = new NetBeansConfigurationInitialProvider ( ) ;
372
- context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( 'jdk' , configInitialProvider , vscode . DebugConfigurationProviderTriggerKind . Initial ) ) ;
370
+ context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( COMMAND_PREFIX , configInitialProvider , vscode . DebugConfigurationProviderTriggerKind . Initial ) ) ;
373
371
let configDynamicProvider = new NetBeansConfigurationDynamicProvider ( context ) ;
374
- context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( 'jdk' , configDynamicProvider , vscode . DebugConfigurationProviderTriggerKind . Dynamic ) ) ;
372
+ context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( COMMAND_PREFIX , configDynamicProvider , vscode . DebugConfigurationProviderTriggerKind . Dynamic ) ) ;
375
373
let configResolver = new NetBeansConfigurationResolver ( ) ;
376
- context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( 'jdk' , configResolver ) ) ;
374
+ context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( COMMAND_PREFIX , configResolver ) ) ;
377
375
context . subscriptions . push ( vscode . debug . onDidTerminateDebugSession ( ( ( session ) => onDidTerminateSession ( session ) ) ) ) ;
378
376
379
377
let debugDescriptionFactory = new NetBeansDebugAdapterDescriptionFactory ( ) ;
380
- context . subscriptions . push ( vscode . debug . registerDebugAdapterDescriptorFactory ( 'jdk' , debugDescriptionFactory ) ) ;
378
+ context . subscriptions . push ( vscode . debug . registerDebugAdapterDescriptorFactory ( COMMAND_PREFIX , debugDescriptionFactory ) ) ;
381
379
382
380
// initialize Run Configuration
383
381
initializeRunConfiguration ( ) . then ( initialized => {
384
382
if ( initialized ) {
385
- context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( 'jdk' , runConfigurationProvider ) ) ;
386
- context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( 'java' , runConfigurationProvider ) ) ;
383
+ context . subscriptions . push ( vscode . debug . registerDebugConfigurationProvider ( COMMAND_PREFIX , runConfigurationProvider ) ) ;
387
384
context . subscriptions . push ( vscode . window . registerTreeDataProvider ( 'run-config' , runConfigurationNodeProvider ) ) ;
388
385
context . subscriptions . push ( vscode . commands . registerCommand ( COMMAND_PREFIX + '.workspace.configureRunSettings' , ( ...params : any [ ] ) => {
389
386
configureRunSettings ( context , params ) ;
@@ -572,7 +569,7 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
572
569
} ) ;
573
570
} ) ) ;
574
571
context . subscriptions . push ( commands . registerCommand ( COMMAND_PREFIX + '.java.goto.super.implementation' , async ( ) => {
575
- if ( window . activeTextEditor ?. document . languageId !== "java" ) {
572
+ if ( window . activeTextEditor ?. document . languageId !== LANGUAGE_ID ) {
576
573
return ;
577
574
}
578
575
const uri = window . activeTextEditor . document . uri ;
@@ -618,7 +615,7 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
618
615
if ( ! Array . isArray ( c ) ) {
619
616
return undefined ;
620
617
}
621
- let f = c . filter ( ( v ) => v [ 'type' ] === 'jdk' ) ;
618
+ let f = c . filter ( ( v ) => v [ 'type' ] === COMMAND_PREFIX ) ;
622
619
if ( ! f . length ) {
623
620
return undefined ;
624
621
}
@@ -631,10 +628,10 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
631
628
}
632
629
}
633
630
let provider = new P ( ) ;
634
- let d = vscode . debug . registerDebugConfigurationProvider ( 'jdk' , provider ) ;
631
+ let d = vscode . debug . registerDebugConfigurationProvider ( COMMAND_PREFIX , provider ) ;
635
632
// let vscode to select a debug config
636
633
return await vscode . commands . executeCommand ( 'workbench.action.debug.start' , { config : {
637
- type : 'jdk' ,
634
+ type : COMMAND_PREFIX ,
638
635
mainClass : uri . toString ( )
639
636
} , noDebug : true } ) . then ( ( v ) => {
640
637
d . dispose ( ) ;
@@ -650,7 +647,7 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
650
647
if ( docUri ) {
651
648
// attempt to find the active configuration in the vsode launch settings; undefined if no config is there.
652
649
let debugConfig : vscode . DebugConfiguration = await findRunConfiguration ( docUri ) || {
653
- type : "jdk" ,
650
+ type : COMMAND_PREFIX ,
654
651
name : "Java Single Debug" ,
655
652
request : "launch"
656
653
} ;
@@ -879,11 +876,11 @@ function isDarkColorTheme() : boolean {
879
876
}
880
877
881
878
function isNbJavacDisabled ( ) : boolean {
882
- return workspace . getConfiguration ( 'jdk' ) ?. get ( 'advanced.disable.nbjavac' ) as boolean ;
879
+ return workspace . getConfiguration ( COMMAND_PREFIX ) ?. get ( 'advanced.disable.nbjavac' ) as boolean ;
883
880
}
884
881
885
882
function getProjectJDKHome ( ) : string {
886
- return workspace . getConfiguration ( 'jdk' ) ?. get ( 'project.jdkhome' ) as string ;
883
+ return workspace . getConfiguration ( COMMAND_PREFIX ) ?. get ( 'project.jdkhome' ) as string ;
887
884
}
888
885
889
886
function doActivateWithJDK ( specifiedJDK : string | null , context : ExtensionContext , log : vscode . OutputChannel , notifyKill : boolean ,
@@ -897,7 +894,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
897
894
} , time ) ;
898
895
} ;
899
896
900
- const netbeansConfig = workspace . getConfiguration ( 'jdk' ) ;
897
+ const netbeansConfig = workspace . getConfiguration ( COMMAND_PREFIX ) ;
901
898
const beVerbose : boolean = netbeansConfig . get ( 'verbose' , false ) ;
902
899
let userdir = process . env [ 'nbcode_userdir' ] || netbeansConfig . get ( 'userdir' , 'local' ) ;
903
900
switch ( userdir ) {
@@ -993,7 +990,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
993
990
if ( isDarkColorTheme ( ) ) {
994
991
extras . push ( '--laf' , 'com.formdev.flatlaf.FlatDarkLaf' ) ;
995
992
}
996
- let serverVmOptions : string [ ] = workspace . getConfiguration ( 'jdk' ) . get ( "serverVmOptions" , [ ] ) ;
993
+ let serverVmOptions : string [ ] = workspace . getConfiguration ( COMMAND_PREFIX ) . get ( "serverVmOptions" , [ ] ) ;
997
994
extras . push ( ...serverVmOptions . map ( el => `-J${ el } ` ) ) ;
998
995
let p = launcher . launch ( info , ...extras ) ;
999
996
handleLog ( log , "LSP server launching: " + p . pid ) ;
@@ -1087,7 +1084,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
1087
1084
} ) ;
1088
1085
const conf = workspace . getConfiguration ( ) ;
1089
1086
let documentSelectors : DocumentSelector = [
1090
- { language : 'java' } ,
1087
+ { language : LANGUAGE_ID } ,
1091
1088
{ language : 'yaml' , pattern : '**/{application,bootstrap}*.yml' } ,
1092
1089
{ language : 'properties' , pattern : '**/{application,bootstrap}*.properties' } ,
1093
1090
{ language : 'jackpot-hint' } ,
@@ -1101,12 +1098,12 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
1101
1098
documentSelector : documentSelectors ,
1102
1099
synchronize : {
1103
1100
configurationSection : [
1104
- 'jdk .hints',
1105
- 'jdk .format',
1106
- 'jdk .java.imports',
1107
- 'jdk .project.jdkhome',
1108
- 'jdk .runConfig.vmOptions',
1109
- 'jdk .runConfig.cwd'
1101
+ COMMAND_PREFIX + ' .hints',
1102
+ COMMAND_PREFIX + ' .format',
1103
+ COMMAND_PREFIX + ' .java.imports',
1104
+ COMMAND_PREFIX + ' .project.jdkhome',
1105
+ COMMAND_PREFIX + ' .runConfig.vmOptions',
1106
+ COMMAND_PREFIX + ' .runConfig.cwd'
1110
1107
] ,
1111
1108
fileEvents : [
1112
1109
workspace . createFileSystemWatcher ( '**/*.java' )
@@ -1143,7 +1140,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
1143
1140
1144
1141
1145
1142
let c = new NbLanguageClient (
1146
- 'java' ,
1143
+ NB_LANGUAGE_CLIENT_ID ,
1147
1144
'Oracle Java SE' ,
1148
1145
connection ,
1149
1146
log ,
@@ -1324,7 +1321,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
1324
1321
}
1325
1322
1326
1323
ctx . subscriptions . push ( window . onDidChangeActiveTextEditor ( ed => {
1327
- const netbeansConfig = workspace . getConfiguration ( 'jdk' ) ;
1324
+ const netbeansConfig = workspace . getConfiguration ( COMMAND_PREFIX ) ;
1328
1325
if ( netbeansConfig . get ( "revealActiveInProjects" ) ) {
1329
1326
revealActiveEditor ( ed ) ;
1330
1327
}
@@ -1431,9 +1428,9 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
1431
1428
const settings = l10n . value ( "jdk.extension.nbjavac.label.openSettings" ) ;
1432
1429
window . showErrorMessage ( message , enable , settings ) . then ( reply => {
1433
1430
if ( enable === reply ) {
1434
- workspace . getConfiguration ( ) . update ( 'jdk .advanced.disable.nbjavac', false ) ;
1431
+ workspace . getConfiguration ( ) . update ( COMMAND_PREFIX + ' .advanced.disable.nbjavac', false ) ;
1435
1432
} else if ( settings === reply ) {
1436
- vscode . commands . executeCommand ( 'workbench.action.openSettings' , 'jdk .jdkhome') ;
1433
+ vscode . commands . executeCommand ( 'workbench.action.openSettings' , COMMAND_PREFIX + ' .jdkhome') ;
1437
1434
}
1438
1435
} ) ;
1439
1436
} else {
@@ -1578,7 +1575,7 @@ class NetBeansConfigurationInitialProvider implements vscode.DebugConfigurationP
1578
1575
}
1579
1576
const debugConfig : vscode . DebugConfiguration = {
1580
1577
name : cname ,
1581
- type : "jdk" ,
1578
+ type : COMMAND_PREFIX ,
1582
1579
request : "launch" ,
1583
1580
launchConfiguration : cn ,
1584
1581
} ;
@@ -1652,7 +1649,7 @@ class NetBeansConfigurationResolver implements vscode.DebugConfigurationProvider
1652
1649
1653
1650
resolveDebugConfiguration ( _folder : vscode . WorkspaceFolder | undefined , config : vscode . DebugConfiguration , _token ?: vscode . CancellationToken ) : vscode . ProviderResult < vscode . DebugConfiguration > {
1654
1651
if ( ! config . type ) {
1655
- config . type = 'jdk' ;
1652
+ config . type = COMMAND_PREFIX ;
1656
1653
}
1657
1654
if ( ! config . request ) {
1658
1655
config . request = 'launch' ;
0 commit comments