提交 0301fdb5 编写于 作者: B Benjamin Pasero

introduce and use IFileService#activateProvider()

上级 cef0992f
...@@ -162,7 +162,7 @@ class Renderer implements IListRenderer<ICompletionItem, ISuggestionTemplateData ...@@ -162,7 +162,7 @@ class Renderer implements IListRenderer<ICompletionItem, ISuggestionTemplateData
if ( if (
(suggestion.kind === CompletionItemKind.File) (suggestion.kind === CompletionItemKind.File)
&& document.querySelector('.file-icons-enabled') // todo@ben move file icon knowledge to editor or platform && document.querySelector('.file-icons-enabled') // todo@aeschli move file icon knowledge to editor or platform
) { ) {
addClass(data.root, 'show-file-icons'); addClass(data.root, 'show-file-icons');
data.icon.className = 'icon hide'; data.icon.className = 'icon hide';
......
...@@ -50,6 +50,11 @@ export interface IFileService { ...@@ -50,6 +50,11 @@ export interface IFileService {
*/ */
registerProvider(scheme: string, provider: IFileSystemProvider): IDisposable; registerProvider(scheme: string, provider: IFileSystemProvider): IDisposable;
/**
* Tries to activate a provider with the given scheme.
*/
activateProvider(scheme: string): TPromise<void>;
/** /**
* Checks if this file service can handle the given resource. * Checks if this file service can handle the given resource.
*/ */
......
...@@ -208,6 +208,10 @@ export class FileService extends Disposable implements IFileService { ...@@ -208,6 +208,10 @@ export class FileService extends Disposable implements IFileService {
throw new Error('not implemented'); throw new Error('not implemented');
} }
activateProvider(scheme: string): TPromise<void> {
return TPromise.wrapError(new Error('not implemented'));
}
canHandleResource(resource: uri): boolean { canHandleResource(resource: uri): boolean {
return resource.scheme === Schemas.file; return resource.scheme === Schemas.file;
} }
......
...@@ -206,6 +206,10 @@ export class RemoteFileService extends FileService { ...@@ -206,6 +206,10 @@ export class RemoteFileService extends FileService {
}; };
} }
activateProvider(scheme: string): TPromise<void> {
return this._extensionService.activateByEvent('onFileSystem:' + scheme);
}
canHandleResource(resource: URI): boolean { canHandleResource(resource: URI): boolean {
return resource.scheme === Schemas.file || this._provider.has(resource.scheme); return resource.scheme === Schemas.file || this._provider.has(resource.scheme);
} }
...@@ -253,7 +257,7 @@ export class RemoteFileService extends FileService { ...@@ -253,7 +257,7 @@ export class RemoteFileService extends FileService {
} }
return Promise.all([ return Promise.all([
this._extensionService.activateByEvent('onFileSystem:' + resource.scheme) this.activateProvider(resource.scheme)
]).then(() => { ]).then(() => {
const provider = this._provider.get(resource.scheme); const provider = this._provider.get(resource.scheme);
if (!provider) { if (!provider) {
......
...@@ -17,7 +17,6 @@ import { ITextModelService, ITextModelContentProvider, ITextEditorModel } from ' ...@@ -17,7 +17,6 @@ import { ITextModelService, ITextModelContentProvider, ITextEditorModel } from '
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService'; import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { IFileService } from 'vs/platform/files/common/files'; import { IFileService } from 'vs/platform/files/common/files';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
class ResourceModelCollection extends ReferenceCollection<TPromise<ITextEditorModel>> { class ResourceModelCollection extends ReferenceCollection<TPromise<ITextEditorModel>> {
...@@ -27,13 +26,12 @@ class ResourceModelCollection extends ReferenceCollection<TPromise<ITextEditorMo ...@@ -27,13 +26,12 @@ class ResourceModelCollection extends ReferenceCollection<TPromise<ITextEditorMo
constructor( constructor(
@IInstantiationService private instantiationService: IInstantiationService, @IInstantiationService private instantiationService: IInstantiationService,
@ITextFileService private textFileService: ITextFileService, @ITextFileService private textFileService: ITextFileService,
@IFileService private fileService: IFileService, @IFileService private fileService: IFileService
@IExtensionService private readonly _extensionService: IExtensionService,
) { ) {
super(); super();
} }
createReferencedObject(key: string, skipActivateExtensions?: boolean): TPromise<ITextEditorModel> { createReferencedObject(key: string, skipActivateProvider?: boolean): TPromise<ITextEditorModel> {
this.modelsToDispose.delete(key); this.modelsToDispose.delete(key);
const resource = URI.parse(key); const resource = URI.parse(key);
...@@ -48,9 +46,9 @@ class ResourceModelCollection extends ReferenceCollection<TPromise<ITextEditorMo ...@@ -48,9 +46,9 @@ class ResourceModelCollection extends ReferenceCollection<TPromise<ITextEditorMo
return this.resolveTextModelContent(key).then(() => this.instantiationService.createInstance(ResourceEditorModel, resource)); return this.resolveTextModelContent(key).then(() => this.instantiationService.createInstance(ResourceEditorModel, resource));
} }
// Either unknown schema, or not yet registered // Either unknown schema, or not yet registered, try to activate
if (!skipActivateExtensions) { if (!skipActivateProvider) {
return this._extensionService.activateByEvent('onFileSystem:' + resource.scheme).then(() => this.createReferencedObject(key, true)); return this.fileService.activateProvider(resource.scheme).then(() => this.createReferencedObject(key, true));
} }
return TPromise.wrapError<ITextEditorModel>(new Error('resource is not available')); return TPromise.wrapError<ITextEditorModel>(new Error('resource is not available'));
......
...@@ -882,6 +882,10 @@ export class TestFileService implements IFileService { ...@@ -882,6 +882,10 @@ export class TestFileService implements IFileService {
return { dispose() { } }; return { dispose() { } };
} }
activateProvider(_scheme: string) {
return TPromise.as(null);
}
canHandleResource(resource: URI): boolean { canHandleResource(resource: URI): boolean {
return resource.scheme === 'file'; return resource.scheme === 'file';
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册