@@ -8,7 +8,7 @@ import { JSONSchema, JSONSchemaMap, JSONSchemaRef } from '../jsonSchema';
8
8
import { URI } from 'vscode-uri' ;
9
9
import * as Strings from '../utils/strings' ;
10
10
import * as Parser from '../parser/jsonParser' ;
11
- import { SchemaRequestService , WorkspaceContextService , PromiseConstructor , Thenable , MatchingSchema , TextDocument , SchemaConfiguration } from '../jsonLanguageTypes' ;
11
+ import { SchemaRequestService , WorkspaceContextService , PromiseConstructor , MatchingSchema , TextDocument , SchemaConfiguration } from '../jsonLanguageTypes' ;
12
12
13
13
import * as l10n from '@vscode/l10n' ;
14
14
import { createRegex } from '../utils/glob' ;
@@ -34,7 +34,7 @@ export interface IJSONSchemaService {
34
34
/**
35
35
* Looks up the appropriate schema for the given URI
36
36
*/
37
- getSchemaForResource ( resource : string , document ?: Parser . JSONDocument ) : Thenable < ResolvedSchema | undefined > ;
37
+ getSchemaForResource ( resource : string , document ?: Parser . JSONDocument ) : PromiseLike < ResolvedSchema | undefined > ;
38
38
39
39
/**
40
40
* Returns all registered schema ids
@@ -62,12 +62,12 @@ export interface ISchemaHandle {
62
62
/**
63
63
* The schema from the file, with potential $ref references
64
64
*/
65
- getUnresolvedSchema ( ) : Thenable < UnresolvedSchema > ;
65
+ getUnresolvedSchema ( ) : PromiseLike < UnresolvedSchema > ;
66
66
67
67
/**
68
68
* The schema from the file, with references resolved
69
69
*/
70
- getResolvedSchema ( ) : Thenable < ResolvedSchema > ;
70
+ getResolvedSchema ( ) : PromiseLike < ResolvedSchema > ;
71
71
}
72
72
73
73
const BANG = '!' ;
@@ -138,8 +138,8 @@ class SchemaHandle implements ISchemaHandle {
138
138
public readonly uri : string ;
139
139
public readonly dependencies : SchemaDependencies ;
140
140
public anchors : Map < string , JSONSchema > | undefined ;
141
- private resolvedSchema : Thenable < ResolvedSchema > | undefined ;
142
- private unresolvedSchema : Thenable < UnresolvedSchema > | undefined ;
141
+ private resolvedSchema : PromiseLike < ResolvedSchema > | undefined ;
142
+ private unresolvedSchema : PromiseLike < UnresolvedSchema > | undefined ;
143
143
private readonly service : JSONSchemaService ;
144
144
145
145
constructor ( service : JSONSchemaService , uri : string , unresolvedSchemaContent ?: JSONSchema ) {
@@ -152,14 +152,14 @@ class SchemaHandle implements ISchemaHandle {
152
152
}
153
153
}
154
154
155
- public getUnresolvedSchema ( ) : Thenable < UnresolvedSchema > {
155
+ public getUnresolvedSchema ( ) : PromiseLike < UnresolvedSchema > {
156
156
if ( ! this . unresolvedSchema ) {
157
157
this . unresolvedSchema = this . service . loadSchema ( this . uri ) ;
158
158
}
159
159
return this . unresolvedSchema ;
160
160
}
161
161
162
- public getResolvedSchema ( ) : Thenable < ResolvedSchema > {
162
+ public getResolvedSchema ( ) : PromiseLike < ResolvedSchema > {
163
163
if ( ! this . resolvedSchema ) {
164
164
this . resolvedSchema = this . getUnresolvedSchema ( ) . then ( unresolved => {
165
165
return this . service . resolveSchemaContent ( unresolved , this ) ;
@@ -256,7 +256,7 @@ export class JSONSchemaService implements IJSONSchemaService {
256
256
private requestService : SchemaRequestService | undefined ;
257
257
private promiseConstructor : PromiseConstructor ;
258
258
259
- private cachedSchemaForResource : { resource : string ; resolvedSchema : Thenable < ResolvedSchema | undefined > } | undefined ;
259
+ private cachedSchemaForResource : { resource : string ; resolvedSchema : PromiseLike < ResolvedSchema | undefined > } | undefined ;
260
260
261
261
constructor ( requestService ?: SchemaRequestService , contextService ?: WorkspaceContextService , promiseConstructor ?: PromiseConstructor ) {
262
262
this . contextService = contextService ;
@@ -376,7 +376,7 @@ export class JSONSchemaService implements IJSONSchemaService {
376
376
}
377
377
}
378
378
379
- public getResolvedSchema ( schemaId : string ) : Thenable < ResolvedSchema | undefined > {
379
+ public getResolvedSchema ( schemaId : string ) : PromiseLike < ResolvedSchema | undefined > {
380
380
const id = normalizeId ( schemaId ) ;
381
381
const schemaHandle = this . schemasById [ id ] ;
382
382
if ( schemaHandle ) {
@@ -385,7 +385,7 @@ export class JSONSchemaService implements IJSONSchemaService {
385
385
return this . promise . resolve ( undefined ) ;
386
386
}
387
387
388
- public loadSchema ( url : string ) : Thenable < UnresolvedSchema > {
388
+ public loadSchema ( url : string ) : PromiseLike < UnresolvedSchema > {
389
389
if ( ! this . requestService ) {
390
390
const errorMessage = l10n . t ( 'Unable to load schema from \'{0}\'. No schema request service available' , toDisplayString ( url ) ) ;
391
391
return this . promise . resolve ( new UnresolvedSchema ( < JSONSchema > { } , [ errorMessage ] ) ) ;
@@ -428,7 +428,7 @@ export class JSONSchemaService implements IJSONSchemaService {
428
428
) ;
429
429
}
430
430
431
- public resolveSchemaContent ( schemaToResolve : UnresolvedSchema , handle : SchemaHandle ) : Thenable < ResolvedSchema > {
431
+ public resolveSchemaContent ( schemaToResolve : UnresolvedSchema , handle : SchemaHandle ) : PromiseLike < ResolvedSchema > {
432
432
433
433
const resolveErrors : string [ ] = schemaToResolve . errors . slice ( 0 ) ;
434
434
const schema = schemaToResolve . schema ;
@@ -489,7 +489,7 @@ export class JSONSchemaService implements IJSONSchemaService {
489
489
}
490
490
} ;
491
491
492
- const resolveExternalLink = ( node : JSONSchema , uri : string , refSegment : string | undefined , parentHandle : SchemaHandle ) : Thenable < any > => {
492
+ const resolveExternalLink = ( node : JSONSchema , uri : string , refSegment : string | undefined , parentHandle : SchemaHandle ) : PromiseLike < any > => {
493
493
if ( contextService && ! / ^ [ A - Z a - z ] [ A - Z a - z 0 - 9 + \- . + ] * : \/ \/ .* / . test ( uri ) ) {
494
494
uri = contextService . resolveRelativePath ( uri , parentHandle . uri ) ;
495
495
}
@@ -506,8 +506,8 @@ export class JSONSchemaService implements IJSONSchemaService {
506
506
} ) ;
507
507
} ;
508
508
509
- const resolveRefs = ( node : JSONSchema , parentSchema : JSONSchema , parentHandle : SchemaHandle ) : Thenable < any > => {
510
- const openPromises : Thenable < any > [ ] = [ ] ;
509
+ const resolveRefs = ( node : JSONSchema , parentSchema : JSONSchema , parentHandle : SchemaHandle ) : PromiseLike < any > => {
510
+ const openPromises : PromiseLike < any > [ ] = [ ] ;
511
511
512
512
this . traverseNodes ( node , next => {
513
513
const seenRefs = new Set < string > ( ) ;
@@ -674,7 +674,7 @@ export class JSONSchemaService implements IJSONSchemaService {
674
674
return this . getAssociatedSchemas ( resource ) ;
675
675
}
676
676
677
- public getSchemaForResource ( resource : string , document ?: Parser . JSONDocument ) : Thenable < ResolvedSchema | undefined > {
677
+ public getSchemaForResource ( resource : string , document ?: Parser . JSONDocument ) : PromiseLike < ResolvedSchema | undefined > {
678
678
if ( document ) {
679
679
// first use $schema if present
680
680
let schemeId = this . getSchemaFromProperty ( resource , document ) ;
@@ -704,7 +704,7 @@ export class JSONSchemaService implements IJSONSchemaService {
704
704
}
705
705
}
706
706
707
- public getMatchingSchemas ( document : TextDocument , jsonDocument : Parser . JSONDocument , schema ?: JSONSchema ) : Thenable < MatchingSchema [ ] > {
707
+ public getMatchingSchemas ( document : TextDocument , jsonDocument : Parser . JSONDocument , schema ?: JSONSchema ) : PromiseLike < MatchingSchema [ ] > {
708
708
if ( schema ) {
709
709
const id = schema . id || ( 'schemaservice://untitled/matchingSchemas/' + idCounter ++ ) ;
710
710
const handle = this . addSchemaHandle ( id , schema ) ;
0 commit comments