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

introduce and use IFileService#activateProvider()

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