3
3
* Copyright (c) Microsoft Corporation. All rights reserved.
4
4
* Licensed under the MIT License. See License.txt in the project root for license information.
5
5
*--------------------------------------------------------------------------------------------*/
6
- import { JSONSchemaService } from './services/jsonSchemaService'
7
- import { TextDocument , Position , CompletionList , Diagnostic } from 'vscode-languageserver-types' ;
6
+
7
+ import { JSONSchemaService , CustomSchemaProvider } from './services/jsonSchemaService'
8
+ import { TextDocument , Position , CompletionList , FormattingOptions , Diagnostic } from 'vscode-languageserver-types' ;
8
9
import { JSONSchema } from './jsonSchema' ;
9
10
import { YAMLDocumentSymbols } from './services/documentSymbols' ;
10
11
import { YAMLCompletion } from "./services/yamlCompletion" ;
@@ -100,7 +101,8 @@ export interface CustomFormatterOptions {
100
101
101
102
export interface LanguageService {
102
103
configure ( settings ) : void ;
103
- doComplete ( document : TextDocument , position : Position , doc ) : Thenable < CompletionList > ;
104
+ registerCustomSchemaProvider ( schemaProvider : CustomSchemaProvider ) : void ; // Register a custom schema provider
105
+ doComplete ( document : TextDocument , position : Position , doc ) : Thenable < CompletionList > ;
104
106
doValidation ( document : TextDocument , yamlDocument ) : Thenable < Diagnostic [ ] > ;
105
107
doHover ( document : TextDocument , position : Position , doc ) ;
106
108
findDocumentSymbols ( document : TextDocument , doc ) ;
@@ -109,10 +111,10 @@ export interface LanguageService {
109
111
doFormat ( document : TextDocument , options : CustomFormatterOptions ) ;
110
112
}
111
113
112
- export function getLanguageService ( schemaRequestService , workspaceContext , contributions , customSchemaProvider , promiseConstructor ?) : LanguageService {
114
+ export function getLanguageService ( schemaRequestService , workspaceContext , contributions , promiseConstructor ?) : LanguageService {
113
115
let promise = promiseConstructor || Promise ;
114
116
115
- let schemaService = new JSONSchemaService ( schemaRequestService , workspaceContext , customSchemaProvider ) ;
117
+ let schemaService = new JSONSchemaService ( schemaRequestService , workspaceContext ) ;
116
118
117
119
let completer = new YAMLCompletion ( schemaService , contributions , promise ) ;
118
120
let hover = new YAMLHover ( schemaService , contributions , promise ) ;
@@ -132,6 +134,9 @@ export function getLanguageService(schemaRequestService, workspaceContext, contr
132
134
let customTagsSetting = settings && settings [ "customTags" ] ? settings [ "customTags" ] : [ ] ;
133
135
completer . configure ( settings , customTagsSetting ) ;
134
136
} ,
137
+ registerCustomSchemaProvider : ( schemaProvider : CustomSchemaProvider ) => {
138
+ schemaService . registerCustomSchemaProvider ( schemaProvider ) ;
139
+ } ,
135
140
doComplete : completer . doComplete . bind ( completer ) ,
136
141
doResolve : completer . doResolve . bind ( completer ) ,
137
142
doValidation : yamlValidation . doValidation . bind ( yamlValidation ) ,
0 commit comments