@@ -2,18 +2,17 @@ import * as requirements from './requirements';
22
33import { DidChangeConfigurationNotification , LanguageClientOptions } from 'vscode-languageclient' ;
44import { LanguageClient } from 'vscode-languageclient/node' ;
5- import { ExtensionContext , commands , workspace , window , ConfigurationTarget , languages } from 'vscode' ;
5+ import { ExtensionContext , commands , workspace , window , ConfigurationTarget } from 'vscode' ;
66import { prepareExecutable } from './quteServerStarter' ;
77import { registerQuteExecuteWorkspaceCommand , registerVSCodeQuteCommands , synchronizeQuteValidationButton } from '../commands/registerCommands' ;
88import { QuteClientCommandConstants } from '../commands/commandConstants' ;
99import { QuteSettings } from './settings' ;
1010import { JavaExtensionAPI } from '../../extension' ;
11- import { QuteInlayHintsProvider } from './inlayHintsProvider' ;
1211
13- export function connectToQuteLS ( context : ExtensionContext , api : JavaExtensionAPI ) {
12+ export async function connectToQuteLS ( context : ExtensionContext , api : JavaExtensionAPI ) {
1413 registerVSCodeQuteCommands ( context ) ;
1514
16- return requirements . resolveRequirements ( api ) . then ( requirements => {
15+ return requirements . resolveRequirements ( api ) . then ( async requirements => {
1716 const clientOptions : LanguageClientOptions = {
1817 documentSelector : [
1918 { scheme : 'file' , language : 'qute-html' } ,
@@ -36,8 +35,7 @@ export function connectToQuteLS(context: ExtensionContext, api: JavaExtensionAPI
3635 QuteClientCommandConstants . COMMAND_CONFIGURATION_UPDATE
3736 ]
3837 }
39- } ,
40- shouldLanguageServerExitOnShutdown : true
38+ }
4139 }
4240 } ,
4341 synchronize : {
@@ -49,9 +47,10 @@ export function connectToQuteLS(context: ExtensionContext, api: JavaExtensionAPI
4947 didChangeConfiguration : async ( ) => {
5048 // A settings.json is updated:
5149 // 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 ( ) } ) ;
5351 // 2. synchronize the Qute toggle button for validation
5452 await synchronizeQuteValidationButton ( window . activeTextEditor ) ;
53+ return result ;
5554 }
5655 }
5756 }
@@ -71,59 +70,50 @@ export function connectToQuteLS(context: ExtensionContext, api: JavaExtensionAPI
7170
7271 const serverOptions = prepareExecutable ( requirements ) ;
7372 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 ) ;
117112 }
118113 }
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 ) ;
127117 } ) ;
128118}
129119
0 commit comments