Skip to content

Commit bec491f

Browse files
authored
feat: make the capability of newJSONDocument and JSONDocument constructor consistent (#259)
1 parent a6ff075 commit bec491f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/jsonLanguageService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface LanguageService {
3838
configure(settings: LanguageSettings): void;
3939
doValidation(document: TextDocument, jsonDocument: JSONDocument, documentSettings?: DocumentLanguageSettings, schema?: JSONSchema): PromiseLike<Diagnostic[]>;
4040
parseJSONDocument(document: TextDocument): JSONDocument;
41-
newJSONDocument(rootNode: ASTNode, syntaxDiagnostics?: Diagnostic[]): JSONDocument;
41+
newJSONDocument(rootNode: ASTNode | undefined, syntaxDiagnostics?: Diagnostic[], comments?: Range[]): JSONDocument;
4242
resetSchema(uri: string): boolean;
4343
getMatchingSchemas(document: TextDocument, jsonDocument: JSONDocument, schema?: JSONSchema): PromiseLike<MatchingSchema[]>;
4444
getLanguageStatus(document: TextDocument, jsonDocument: JSONDocument): JSONLanguageStatus;
@@ -79,7 +79,7 @@ export function getLanguageService(params: LanguageServiceParams): LanguageServi
7979
doValidation: jsonValidation.doValidation.bind(jsonValidation),
8080
getLanguageStatus: jsonValidation.getLanguageStatus.bind(jsonValidation),
8181
parseJSONDocument: (document: TextDocument) => parseJSON(document, { collectComments: true }),
82-
newJSONDocument: (root: ASTNode, diagnostics: Diagnostic[]) => newJSONDocument(root, diagnostics),
82+
newJSONDocument: (root: ASTNode | undefined, diagnostics?: Diagnostic[], comments?: Range[]) => newJSONDocument(root, diagnostics, comments),
8383
getMatchingSchemas: jsonSchemaService.getMatchingSchemas.bind(jsonSchemaService),
8484
doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
8585
doComplete: jsonCompletion.doComplete.bind(jsonCompletion),

src/parser/jsonParser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ export class ValidationResult {
308308

309309
}
310310

311-
export function newJSONDocument(root: ASTNode, diagnostics: Diagnostic[] = []) {
312-
return new JSONDocument(root, diagnostics, []);
311+
export function newJSONDocument(root: ASTNode | undefined, diagnostics: Diagnostic[] = [], comments: Range[] = []) {
312+
return new JSONDocument(root, diagnostics, comments);
313313
}
314314

315315
export function getNodeValue(node: ASTNode): any {

0 commit comments

Comments
 (0)