@@ -54,6 +54,7 @@ import { getLogger, setLogLevel } from "./logger";
5454import { initI18n } from "./i18n" ;
5555import { isXMLView , getCDNBaseUrl } from "@ui5-language-assistant/logic-utils" ;
5656import { getDefinition } from "@ui5-language-assistant/xml-views-definition" ;
57+ import { handleContextError } from "./utils" ;
5758
5859const connection = createConnection ( ProposedFeatures . all ) ;
5960const documents = new TextDocuments ( TextDocument ) ;
@@ -147,10 +148,7 @@ connection.onCompletion(
147148 initializationOptions ?. modelCachePath
148149 ) ;
149150 if ( ! isContext ( context ) ) {
150- connection . sendNotification (
151- "UI5LanguageAssistant/context-error" ,
152- context
153- ) ;
151+ handleContextError ( context ) ;
154152 return [ ] ;
155153 }
156154 const version = context . ui5Model . version ;
@@ -207,10 +205,7 @@ connection.onHover(
207205 initializationOptions ?. modelCachePath
208206 ) ;
209207 if ( ! isContext ( context ) ) {
210- connection . sendNotification (
211- "UI5LanguageAssistant/context-error" ,
212- context
213- ) ;
208+ handleContextError ( context ) ;
214209 return ;
215210 }
216211 const version = context . ui5Model . version ;
@@ -257,10 +252,7 @@ const validateOpenDocuments = async (): Promise<void> => {
257252 initializationOptions ?. modelCachePath
258253 ) ;
259254 if ( ! isContext ( context ) ) {
260- connection . sendNotification (
261- "UI5LanguageAssistant/context-error" ,
262- context
263- ) ;
255+ handleContextError ( context ) ;
264256 return ;
265257 }
266258 const diagnostics = getXMLViewDiagnostics ( {
@@ -288,10 +280,7 @@ const validateIdsOfOpenDocuments = async (): Promise<void> => {
288280 initializationOptions ?. modelCachePath
289281 ) ;
290282 if ( ! isContext ( context ) ) {
291- connection . sendNotification (
292- "UI5LanguageAssistant/context-error" ,
293- context
294- ) ;
283+ handleContextError ( context ) ;
295284 return ;
296285 }
297286 const idDiagnostics = getXMLViewIdDiagnostics ( {
@@ -422,10 +411,7 @@ documents.onDidChangeContent(async (changeEvent): Promise<void> => {
422411 document . getText ( )
423412 ) ;
424413 if ( ! isContext ( context ) ) {
425- connection . sendNotification (
426- "UI5LanguageAssistant/context-error" ,
427- context
428- ) ;
414+ handleContextError ( context ) ;
429415 return ;
430416 }
431417
@@ -476,10 +462,7 @@ connection.onCodeAction(async (params) => {
476462 textDocument . getText ( )
477463 ) ;
478464 if ( ! isContext ( context ) ) {
479- connection . sendNotification (
480- "UI5LanguageAssistant/context-error" ,
481- context
482- ) ;
465+ handleContextError ( context ) ;
483466 return ;
484467 }
485468
0 commit comments