提交 a5be21f7 编写于 作者: A Alex Dima

Render activation times

上级 f8ca8085
......@@ -34,13 +34,14 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
import jsonContributionRegistry = require('vs/platform/jsonschemas/common/jsonContributionRegistry');
import { ExtensionsConfigurationSchema, ExtensionsConfigurationSchemaId } from 'vs/workbench/parts/extensions/common/extensionsFileTemplate';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { KeymapExtensions, BetterMergeDisabled } from 'vs/workbench/parts/extensions/electron-browser/extensionsUtils';
import { adoptToGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { GalleryExtensionsHandler, ExtensionsHandler } from 'vs/workbench/parts/extensions/browser/extensionsQuickOpen';
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { RuntimeExtensionsEditor, RuntimeExtensionsInput, ShowRuntimeExtensionsAction } from 'vs/workbench/parts/extensions/electron-browser/runtimeExtensionsEditor';
import { EditorInput, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
// Singletons
registerSingleton(IExtensionGalleryService, ExtensionGalleryService);
......@@ -89,6 +90,8 @@ const editorDescriptor = new EditorDescriptor(
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(editorDescriptor, [new SyncDescriptor(ExtensionsInput)]);
// Running Extensions Editor
const runtimeExtensionsEditorDescriptor = new EditorDescriptor(
RuntimeExtensionsEditor,
RuntimeExtensionsEditor.ID,
......@@ -98,6 +101,18 @@ const runtimeExtensionsEditorDescriptor = new EditorDescriptor(
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
.registerEditor(runtimeExtensionsEditorDescriptor, [new SyncDescriptor(RuntimeExtensionsInput)]);
class RuntimeExtensionsInputFactory implements IEditorInputFactory {
serialize(editorInput: EditorInput): string {
return '';
}
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): EditorInput {
return new RuntimeExtensionsInput();
}
}
Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).registerEditorInputFactory(RuntimeExtensionsInput.ID, RuntimeExtensionsInputFactory);
// Viewlet
const viewletDescriptor = new ViewletDescriptor(
ExtensionsViewlet,
......
......@@ -3,9 +3,25 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.runtime-extensions-editor .extension {
display: flex;
padding-left: 20px;
}
.runtime-extensions-editor .extension .desc {
flex: 1;
}
.runtime-extensions-editor .extension .desc .name {
font-weight: bold;
}
.runtime-extensions-editor .extension .desc .time-label {
padding-left: 4px;
}
.runtime-extensions-editor .icon {
width: 42px;
height: 42px;
padding: 10px 14px 10px 0;
float: left;
}
......@@ -62,7 +62,10 @@ export class RuntimeExtensionsEditor extends BaseEditor {
this._updateExtensions();
this._extensionService.getExtensions().then((extensions) => {
this._extensionsDescriptions = extensions;
// We only deal with extensions with source code!
this._extensionsDescriptions = extensions.filter((extension) => {
return !!extension.main;
});
this._updateExtensions();
});
this._register(this._extensionService.onDidChangeExtensionsStatus(() => this._updateExtensions()));
......@@ -97,7 +100,7 @@ export class RuntimeExtensionsEditor extends BaseEditor {
};
}
return result;
return result.filter((element) => element.status.activationTimes);
}
protected createEditor(parent: Builder): void {
......@@ -121,6 +124,7 @@ export class RuntimeExtensionsEditor extends BaseEditor {
element: HTMLElement;
icon: HTMLImageElement;
name: HTMLElement;
time: HTMLElement;
disposables: IDisposable[];
elementDisposables: IDisposable[];
}
......@@ -130,7 +134,12 @@ export class RuntimeExtensionsEditor extends BaseEditor {
renderTemplate: (root: HTMLElement): IRuntimeExtensionTemplateData => {
const element = append(root, $('.extension'));
const icon = append(element, $<HTMLImageElement>('img.icon'));
const name = append(element, $('span.name'));
const desc = append(element, $('div.desc'));
const name = append(desc, $('div.name'));
const timeContainer = append(desc, $('div.time'));
append(timeContainer, $('span.octicon.octicon-clock'));
const time = append(timeContainer, $('span.time-label'));
const actionbar = new ActionBar(element, {
animated: false,
actionItemProvider: (action: Action) => {
......@@ -150,6 +159,7 @@ export class RuntimeExtensionsEditor extends BaseEditor {
element,
icon,
name,
time,
disposables,
elementDisposables: []
};
......@@ -167,6 +177,10 @@ export class RuntimeExtensionsEditor extends BaseEditor {
data.icon.src = element.marketplaceInfo.iconUrl;
data.name.textContent = element.marketplaceInfo.displayName;
const activationTimes = element.status.activationTimes;
let syncTime = activationTimes.codeLoadingTime + activationTimes.activateCallTime;
data.time.textContent = `${syncTime}ms`;
},
disposeTemplate: (data: IRuntimeExtensionTemplateData): void => {
......
......@@ -304,14 +304,16 @@ export class ExtensionService extends Disposable implements IExtensionService {
public getExtensionsStatus(): { [id: string]: IExtensionsStatus; } {
let result: { [id: string]: IExtensionsStatus; } = Object.create(null);
const extensions = this._registry.getAllExtensionDescriptions();
for (let i = 0, len = extensions.length; i < len; i++) {
const extension = extensions[i];
const id = extension.id;
result[id] = {
messages: this._extensionsMessages[id],
activationTimes: this._extensionHostProcessActivationTimes[id]
};
if (this._registry) {
const extensions = this._registry.getAllExtensionDescriptions();
for (let i = 0, len = extensions.length; i < len; i++) {
const extension = extensions[i];
const id = extension.id;
result[id] = {
messages: this._extensionsMessages[id],
activationTimes: this._extensionHostProcessActivationTimes[id]
};
}
}
return result;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册