@@ -25,6 +25,7 @@ import { JSONDocument } from '../parser/jsonParser07';
2525import { parse } from 'yaml' ;
2626import * as path from 'path' ;
2727import { getSchemaFromModeline } from './modelineUtil' ;
28+ import { JSONSchemaDescriptionExt } from '../../requestTypes' ;
2829
2930const localize = nls . loadMessageBundle ( ) ;
3031
@@ -95,6 +96,8 @@ export class YAMLSchemaService extends JSONSchemaService {
9596 private requestService : SchemaRequestService ;
9697 public schemaPriorityMapping : Map < string , Set < SchemaPriority > > ;
9798
99+ private schemaUriToNameAndDescription = new Map < string , [ string , string ] > ( ) ;
100+
98101 constructor (
99102 requestService : SchemaRequestService ,
100103 contextService ?: WorkspaceContextService ,
@@ -110,6 +113,33 @@ export class YAMLSchemaService extends JSONSchemaService {
110113 this . customSchemaProvider = customSchemaProvider ;
111114 }
112115
116+ getAllSchemas ( ) : JSONSchemaDescriptionExt [ ] {
117+ const result : JSONSchemaDescriptionExt [ ] = [ ] ;
118+ const schemaUris = new Set < string > ( ) ;
119+ for ( const filePattern of this . filePatternAssociations ) {
120+ const schemaUri = filePattern . uris [ 0 ] ;
121+ if ( schemaUris . has ( schemaUri ) ) {
122+ continue ;
123+ }
124+ schemaUris . add ( schemaUri ) ;
125+ const schemaHandle : JSONSchemaDescriptionExt = {
126+ uri : schemaUri ,
127+ fromStore : false ,
128+ usedForCurrentFile : false ,
129+ } ;
130+
131+ if ( this . schemaUriToNameAndDescription . has ( schemaUri ) ) {
132+ const [ name , description ] = this . schemaUriToNameAndDescription . get ( schemaUri ) ;
133+ schemaHandle . name = name ;
134+ schemaHandle . description = description ;
135+ schemaHandle . fromStore = true ;
136+ }
137+ result . push ( schemaHandle ) ;
138+ }
139+
140+ return result ;
141+ }
142+
113143 async resolveSchemaContent (
114144 schemaToResolve : UnresolvedSchema ,
115145 schemaURL : string ,
@@ -610,11 +640,25 @@ export class YAMLSchemaService extends JSONSchemaService {
610640 ) ;
611641 }
612642 unresolvedJsonSchema . uri = schemaUri ;
643+ if ( this . schemaUriToNameAndDescription . has ( schemaUri ) ) {
644+ const [ name , description ] = this . schemaUriToNameAndDescription . get ( schemaUri ) ;
645+ unresolvedJsonSchema . schema . title = name ?? unresolvedJsonSchema . schema . title ;
646+ unresolvedJsonSchema . schema . description = description ?? unresolvedJsonSchema . schema . description ;
647+ }
613648 return unresolvedJsonSchema ;
614649 } ) ;
615650 }
616651
617- registerExternalSchema ( uri : string , filePatterns ?: string [ ] , unresolvedSchema ?: JSONSchema ) : SchemaHandle {
652+ registerExternalSchema (
653+ uri : string ,
654+ filePatterns ?: string [ ] ,
655+ unresolvedSchema ?: JSONSchema ,
656+ name ?: string ,
657+ description ?: string
658+ ) : SchemaHandle {
659+ if ( name || description ) {
660+ this . schemaUriToNameAndDescription . set ( uri , [ name , description ] ) ;
661+ }
618662 return super . registerExternalSchema ( uri , filePatterns , unresolvedSchema ) ;
619663 }
620664
0 commit comments