@@ -2,18 +2,17 @@ import * as requirements from './requirements';
2
2
3
3
import { DidChangeConfigurationNotification , LanguageClientOptions } from 'vscode-languageclient' ;
4
4
import { LanguageClient } from 'vscode-languageclient/node' ;
5
- import { ExtensionContext , commands , workspace , window , ConfigurationTarget , languages } from 'vscode' ;
5
+ import { ExtensionContext , commands , workspace , window , ConfigurationTarget } from 'vscode' ;
6
6
import { prepareExecutable } from './quteServerStarter' ;
7
7
import { registerQuteExecuteWorkspaceCommand , registerVSCodeQuteCommands , synchronizeQuteValidationButton } from '../commands/registerCommands' ;
8
8
import { QuteClientCommandConstants } from '../commands/commandConstants' ;
9
9
import { QuteSettings } from './settings' ;
10
10
import { JavaExtensionAPI } from '../../extension' ;
11
- import { QuteInlayHintsProvider } from './inlayHintsProvider' ;
12
11
13
- export function connectToQuteLS ( context : ExtensionContext , api : JavaExtensionAPI ) {
12
+ export async function connectToQuteLS ( context : ExtensionContext , api : JavaExtensionAPI ) {
14
13
registerVSCodeQuteCommands ( context ) ;
15
14
16
- return requirements . resolveRequirements ( api ) . then ( requirements => {
15
+ return requirements . resolveRequirements ( api ) . then ( async requirements => {
17
16
const clientOptions : LanguageClientOptions = {
18
17
documentSelector : [
19
18
{ scheme : 'file' , language : 'qute-html' } ,
@@ -36,8 +35,7 @@ export function connectToQuteLS(context: ExtensionContext, api: JavaExtensionAPI
36
35
QuteClientCommandConstants . COMMAND_CONFIGURATION_UPDATE
37
36
]
38
37
}
39
- } ,
40
- shouldLanguageServerExitOnShutdown : true
38
+ }
41
39
}
42
40
} ,
43
41
synchronize : {
@@ -49,9 +47,10 @@ export function connectToQuteLS(context: ExtensionContext, api: JavaExtensionAPI
49
47
didChangeConfiguration : async ( ) => {
50
48
// A settings.json is updated:
51
49
// 1. send the new Quet settings to the Qute language server
52
- quteLanguageClient . sendNotification ( DidChangeConfigurationNotification . type , { settings : getQuteSettings ( ) } ) ;
50
+ const result = quteLanguageClient . sendNotification ( DidChangeConfigurationNotification . type , { settings : getQuteSettings ( ) } ) ;
53
51
// 2. synchronize the Qute toggle button for validation
54
52
await synchronizeQuteValidationButton ( window . activeTextEditor ) ;
53
+ return result ;
55
54
}
56
55
}
57
56
}
@@ -71,59 +70,50 @@ export function connectToQuteLS(context: ExtensionContext, api: JavaExtensionAPI
71
70
72
71
const serverOptions = prepareExecutable ( requirements ) ;
73
72
const quteLanguageClient = new LanguageClient ( 'qute' , 'Qute Support' , serverOptions , clientOptions ) ;
74
- context . subscriptions . push ( quteLanguageClient . start ( ) ) ;
75
-
76
- return quteLanguageClient . onReady ( ) . then ( async ( ) => {
77
- bindQuteRequest ( 'qute/template/project' ) ;
78
- bindQuteRequest ( 'qute/template/projectDataModel' ) ;
79
- bindQuteRequest ( 'qute/template/userTags' ) ;
80
- bindQuteRequest ( 'qute/template/javaTypes' ) ;
81
- bindQuteRequest ( 'qute/template/resolvedJavaType' ) ;
82
- bindQuteRequest ( 'qute/template/javaDefinition' ) ;
83
- bindQuteRequest ( 'qute/template/javadoc' ) ;
84
- bindQuteRequest ( 'qute/template/generateMissingJavaMember' ) ;
85
- bindQuteRequest ( 'qute/java/codeLens' ) ;
86
- bindQuteRequest ( 'qute/java/diagnostics' ) ;
87
- bindQuteRequest ( 'qute/java/documentLink' ) ;
88
- bindQuteNotification ( 'qute/dataModelChanged' ) ;
89
-
90
- registerQuteExecuteWorkspaceCommand ( context , quteLanguageClient ) ;
91
- // Refresh the Qute context when editor tab has the focus
92
- context . subscriptions . push (
93
- window . onDidChangeActiveTextEditor ( async editor => {
94
- await synchronizeQuteValidationButton ( editor ) ;
95
- } )
96
- ) ;
97
- // Refresh the Qute context when the language id changed (HTML -> Qute HTML or Qute HTML -> HTML)
98
- context . subscriptions . push (
99
- workspace . onDidOpenTextDocument ( async ( document ) => {
100
- // when settings.json is updated, onDidOpenTextDocument is called,
101
- // the Qute context must be refreshed only for the activate text editor.
102
- if ( window . activeTextEditor ?. document === document ) {
103
- await synchronizeQuteValidationButton ( window . activeTextEditor ) ;
104
- }
105
- // Display the experimental Qute validation pop-up if it hasn't been displayed and a Qute file is open
106
- if ( ! hasShownQuteValidationPopUp ( context ) && document . languageId . includes ( 'qute' ) ) {
107
- showQuteValidationPopUp ( context ) ;
108
- }
109
- } )
110
- ) ;
111
- // Display the experimental Qute validation pop-up if it hasn't been displayed and a Qute file is open
112
- if ( ! hasShownQuteValidationPopUp ( context ) ) {
113
- for ( const textDocument of workspace . textDocuments ) {
114
- if ( textDocument . languageId . includes ( 'qute' ) ) {
115
- showQuteValidationPopUp ( context ) ;
116
- }
73
+ await quteLanguageClient . start ( ) ;
74
+
75
+ bindQuteRequest ( 'qute/template/project' ) ;
76
+ bindQuteRequest ( 'qute/template/projectDataModel' ) ;
77
+ bindQuteRequest ( 'qute/template/userTags' ) ;
78
+ bindQuteRequest ( 'qute/template/javaTypes' ) ;
79
+ bindQuteRequest ( 'qute/template/resolvedJavaType' ) ;
80
+ bindQuteRequest ( 'qute/template/javaDefinition' ) ;
81
+ bindQuteRequest ( 'qute/java/codeLens' ) ;
82
+ bindQuteRequest ( 'qute/java/diagnostics' ) ;
83
+ bindQuteRequest ( 'qute/java/documentLink' ) ;
84
+ bindQuteNotification ( 'qute/dataModelChanged' ) ;
85
+
86
+ registerQuteExecuteWorkspaceCommand ( context , quteLanguageClient ) ;
87
+ // Refresh the Qute context when editor tab has the focus
88
+ context . subscriptions . push (
89
+ window . onDidChangeActiveTextEditor ( async editor => {
90
+ await synchronizeQuteValidationButton ( editor ) ;
91
+ } )
92
+ ) ;
93
+ // Refresh the Qute context when the language id changed (HTML -> Qute HTML or Qute HTML -> HTML)
94
+ context . subscriptions . push (
95
+ workspace . onDidOpenTextDocument ( async ( document ) => {
96
+ // when settings.json is updated, onDidOpenTextDocument is called,
97
+ // the Qute context must be refreshed only for the activate text editor.
98
+ if ( window . activeTextEditor ?. document === document ) {
99
+ await synchronizeQuteValidationButton ( window . activeTextEditor ) ;
100
+ }
101
+ // Display the experimental Qute validation pop-up if it hasn't been displayed and a Qute file is open
102
+ if ( ! hasShownQuteValidationPopUp ( context ) && document . languageId . includes ( 'qute' ) ) {
103
+ showQuteValidationPopUp ( context ) ;
104
+ }
105
+ } )
106
+ ) ;
107
+ // Display the experimental Qute validation pop-up if it hasn't been displayed and a Qute file is open
108
+ if ( ! hasShownQuteValidationPopUp ( context ) ) {
109
+ for ( const textDocument of workspace . textDocuments ) {
110
+ if ( textDocument . languageId . includes ( 'qute' ) ) {
111
+ showQuteValidationPopUp ( context ) ;
117
112
}
118
113
}
119
- await setQuteValidationEnabledContext ( ) ;
120
- await synchronizeQuteValidationButton ( window . activeTextEditor ) ;
121
-
122
- const supportRegisterInlayHintsProvider = ( languages as any ) . registerInlayHintsProvider ;
123
- if ( supportRegisterInlayHintsProvider ) {
124
- context . subscriptions . push ( languages . registerInlayHintsProvider ( clientOptions . documentSelector , new QuteInlayHintsProvider ( quteLanguageClient ) ) ) ;
125
- }
126
- } ) ;
114
+ }
115
+ await setQuteValidationEnabledContext ( ) ;
116
+ await synchronizeQuteValidationButton ( window . activeTextEditor ) ;
127
117
} ) ;
128
118
}
129
119
0 commit comments