allow to ask if a document content provider already exists, prep for #65400

pull/65498/head
Johannes Rieken 2018-12-20 12:49:09 +01:00
parent 1386fba3be
commit 11a679521c
3 changed files with 17 additions and 0 deletions

View File

@ -24,6 +24,11 @@ export interface ITextModelService {
* Registers a specific `scheme` content provider.
*/
registerTextModelContentProvider(scheme: string, provider: ITextModelContentProvider): IDisposable;
/**
* Check if a provider for the given `scheme` exists
*/
hasTextModelContentProvider(scheme: string): boolean;
}
export interface ITextModelContentProvider {

View File

@ -116,6 +116,10 @@ export class SimpleEditorModelResolverService implements ITextModelService {
};
}
public hasTextModelContentProvider(scheme: string): boolean {
return false;
}
private findModel(editor: ICodeEditor, resource: URI): ITextModel | null {
let model = editor.getModel();
if (model && model.uri.toString() !== resource.toString()) {

View File

@ -96,6 +96,10 @@ class ResourceModelCollection extends ReferenceCollection<Promise<ITextEditorMod
});
}
hasTextModelContentProvider(scheme: string): boolean {
return this.providers[scheme] !== undefined;
}
private resolveTextModelContent(key: string): Promise<ITextModel> {
const resource = URI.parse(key);
const providers = this.providers[resource.scheme] || [];
@ -162,4 +166,8 @@ export class TextModelResolverService implements ITextModelService {
registerTextModelContentProvider(scheme: string, provider: ITextModelContentProvider): IDisposable {
return this.resourceModelCollection.registerTextModelContentProvider(scheme, provider);
}
hasTextModelContentProvider(scheme: string): boolean {
return this.resourceModelCollection.hasTextModelContentProvider(scheme);
}
}