@@ -46,11 +46,13 @@ import {
4646 CustomSchemaRequest ,
4747 SchemaModificationNotification ,
4848 ISchemaAssociations ,
49+ VSCodeContentRequestRegistration ,
4950} from './requestTypes' ;
50- import { schemaRequestHandler } from './languageservice/services/schemaRequestHandler' ;
5151import { isRelativePath , relativeToAbsolutePath , workspaceFoldersChanged } from './languageservice/utils/paths' ;
5252import { URI } from 'vscode-uri' ;
5353import { KUBERNETES_SCHEMA_URL , JSON_SCHEMASTORE_URL } from './languageservice/utils/schemaUrls' ;
54+ import { schemaRequestHandler } from './languageservice/services/schemaRequestHandler' ;
55+
5456// eslint-disable-next-line @typescript-eslint/no-explicit-any
5557nls . config ( process . env [ 'VSCODE_NLS_CONFIG' ] as any ) ;
5658
@@ -136,6 +138,7 @@ let workspaceFolders: WorkspaceFolder[] = [];
136138let clientDynamicRegisterSupport = false ;
137139let hierarchicalDocumentSymbolSupport = false ;
138140let hasWorkspaceFolderCapability = false ;
141+ let useVSCodeContentRequest = false ;
139142
140143/****************************
141144 * Reusable helper functions
@@ -373,7 +376,15 @@ console.error = connection.console.error.bind(connection.console);
373376// for open, change and close text document events
374377documents . listen ( connection ) ;
375378
376- const schemaRequestService = schemaRequestHandler . bind ( this , connection ) ;
379+ /**
380+ * Handles schema content requests given the schema URI
381+ * @param uri can be a local file, vscode request, http(s) request or a custom request
382+ */
383+ const schemaRequestHandlerWrapper = ( connection : IConnection , uri : string ) : Promise < string > => {
384+ return schemaRequestHandler ( connection , uri , workspaceFolders , workspaceRoot , useVSCodeContentRequest ) ;
385+ } ;
386+
387+ const schemaRequestService = schemaRequestHandlerWrapper . bind ( this , connection ) ;
377388
378389export const customLanguageService = getCustomLanguageService ( schemaRequestService , workspaceContext ) ;
379390
@@ -456,6 +467,15 @@ connection.onNotification(DynamicCustomSchemaRequestRegistration.type, () => {
456467 customLanguageService . registerCustomSchemaProvider ( schemaProvider ) ;
457468} ) ;
458469
470+ /**
471+ * Received a notification from the client that it can accept content requests
472+ * This means that the server sends schemas back to the client side to get resolved rather
473+ * than resolving them on the extension side
474+ */
475+ connection . onNotification ( VSCodeContentRequestRegistration . type , ( ) => {
476+ useVSCodeContentRequest = true ;
477+ } ) ;
478+
459479/**
460480 * Run when the editor configuration is changed
461481 * The client syncs the 'yaml', 'http.proxy', 'http.proxyStrictSSL' settings sections
0 commit comments