mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
ExtensionsRegistry only tracks extension points
This commit is contained in:
@@ -36,7 +36,6 @@ import Severity from 'vs/base/common/severity';
|
||||
import EditorCommon = require('vs/editor/common/editorCommon');
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtHostExtensionService } from 'vs/workbench/api/node/extHostExtensionService';
|
||||
import { ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
@@ -143,13 +142,13 @@ export function createApiFactory(threadService: IThreadService, extensionService
|
||||
// namespace: extensions
|
||||
const extensions: typeof vscode.extensions = {
|
||||
getExtension(extensionId: string): Extension<any> {
|
||||
let desc = ExtensionsRegistry.getExtensionDescription(extensionId);
|
||||
let desc = extensionService.getExtensionDescription(extensionId);
|
||||
if (desc) {
|
||||
return new Extension(extensionService, desc);
|
||||
}
|
||||
},
|
||||
get all(): Extension<any>[] {
|
||||
return ExtensionsRegistry.getAllExtensionDescriptions().map((desc) => new Extension(extensionService, desc));
|
||||
return extensionService.getAllExtensionDescriptions().map((desc) => new Extension(extensionService, desc));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -417,7 +416,7 @@ class Extension<T> implements vscode.Extension<T> {
|
||||
}
|
||||
}
|
||||
|
||||
export function defineAPI(factory: IExtensionApiFactory, extensions: IExtensionDescription[]): void {
|
||||
export function defineAPI(factory: IExtensionApiFactory, extensionService: ExtHostExtensionService): void {
|
||||
|
||||
// each extension is meant to get its own api implementation
|
||||
const extApiImpl: { [id: string]: typeof vscode } = Object.create(null);
|
||||
@@ -425,6 +424,7 @@ export function defineAPI(factory: IExtensionApiFactory, extensions: IExtensionD
|
||||
|
||||
// create trie to enable fast 'filename -> extension id' look up
|
||||
const trie = new TrieMap<IExtensionDescription>(TrieMap.PathSplitter);
|
||||
const extensions = extensionService.getAllExtensionDescriptions();
|
||||
for (const ext of extensions) {
|
||||
if (ext.name) {
|
||||
const path = realpathSync(ext.extensionFolderPath);
|
||||
|
||||
@@ -22,6 +22,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
|
||||
import { StatusbarAlignment as MainThreadStatusBarAlignment } from 'vs/platform/statusbar/common/statusbar';
|
||||
import { ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ICommandHandlerDescription } from 'vs/platform/commands/common/commands';
|
||||
import { IWorkspace } from 'vs/platform/workspace/common/workspace';
|
||||
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
@@ -34,6 +35,23 @@ import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IWorkspaceSymbol } from 'vs/workbench/parts/search/common/search';
|
||||
import { IApplyEditsOptions, TextEditorRevealType, ITextEditorConfigurationUpdate, IResolvedTextEditorConfiguration, ISelectionChangeEvent } from './mainThreadEditorsTracker';
|
||||
|
||||
export interface IEnvironment {
|
||||
appSettingsHome: string;
|
||||
disableExtensions: boolean;
|
||||
userExtensionsHome: string;
|
||||
extensionDevelopmentPath: string;
|
||||
extensionTestsPath: string;
|
||||
}
|
||||
|
||||
export interface IInitData {
|
||||
parentPid: number;
|
||||
environment: IEnvironment;
|
||||
contextService: {
|
||||
workspace: IWorkspace;
|
||||
};
|
||||
extensions: IExtensionDescription[];
|
||||
}
|
||||
|
||||
export interface InstanceSetter<T> {
|
||||
set<R extends T>(instance: T): R;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import Severity from 'vs/base/common/severity';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { AbstractExtensionService, ActivatedExtension } from 'vs/platform/extensions/common/abstractExtensionService';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtensionsRegistry } from 'vs/platform/extensions/common/extensionsRegistry';
|
||||
import { ExtHostStorage } from 'vs/workbench/api/node/extHostStorage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThreadService } from 'vs/workbench/services/thread/common/threadService';
|
||||
@@ -119,8 +118,9 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
|
||||
/**
|
||||
* This class is constructed manually because it is a service, so it doesn't use any ctor injection
|
||||
*/
|
||||
constructor(threadService: IThreadService, telemetryService: ITelemetryService, args: { _serviceBrand: any; workspaceStoragePath: string; }) {
|
||||
constructor(availableExtensions: IExtensionDescription[], threadService: IThreadService, telemetryService: ITelemetryService, args: { _serviceBrand: any; workspaceStoragePath: string; }) {
|
||||
super(false);
|
||||
this._registry.registerExtensions(availableExtensions);
|
||||
this._threadService = threadService;
|
||||
this._storage = new ExtHostStorage(threadService);
|
||||
this._proxy = this._threadService.get(MainContext.MainProcessExtensionService);
|
||||
@@ -128,6 +128,14 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
|
||||
this._workspaceStoragePath = args.workspaceStoragePath;
|
||||
}
|
||||
|
||||
public getAllExtensionDescriptions(): IExtensionDescription[] {
|
||||
return this._registry.getAllExtensionDescriptions();
|
||||
}
|
||||
|
||||
public getExtensionDescription(extensionId: string): IExtensionDescription {
|
||||
return this._registry.getExtensionDescription(extensionId);
|
||||
}
|
||||
|
||||
public $localShowMessage(severity: Severity, msg: string): void {
|
||||
switch (severity) {
|
||||
case Severity.Error:
|
||||
@@ -179,7 +187,7 @@ export class ExtHostExtensionService extends AbstractExtensionService<ExtHostExt
|
||||
}
|
||||
|
||||
public registrationDone(): void {
|
||||
this._proxy.$onExtensionHostReady(ExtensionsRegistry.getAllExtensionDescriptions()).then(() => {
|
||||
this._proxy.$onExtensionHostReady(this._registry.getAllExtensionDescriptions()).then(() => {
|
||||
// Wait for the main process to acknowledge its receival of the extensions descriptions
|
||||
// before allowing extensions to be activated
|
||||
this._triggerOnReady();
|
||||
|
||||
@@ -125,9 +125,9 @@ export class MainProcessExtensionService extends AbstractExtensionService<Activa
|
||||
// -- called by extension host
|
||||
|
||||
public $onExtensionHostReady(extensionDescriptions: IExtensionDescription[]): TPromise<void> {
|
||||
ExtensionsRegistry.registerExtensions(extensionDescriptions);
|
||||
this._registry.registerExtensions(extensionDescriptions);
|
||||
|
||||
let availableExtensions = ExtensionsRegistry.getAllExtensionDescriptions();
|
||||
let availableExtensions = this._registry.getAllExtensionDescriptions();
|
||||
let extensionPoints = ExtensionsRegistry.getExtensionPoints();
|
||||
|
||||
for (let i = 0, len = extensionPoints.length; i < len; i++) {
|
||||
|
||||
Reference in New Issue
Block a user