mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Remove AsyncDescriptor usages (#35496)
* debt - syncdescriptors for composite * debt - syncdescriptor for baseeditor * debt - syncdescriptor for quickopenhandler * debt - remove asyncdescriptor * debt - introduce editor.ts in browser namespace * fix todos
This commit is contained in:
@@ -175,98 +175,4 @@ export interface SyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): SyncDescriptor2<A7, A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): SyncDescriptor1<A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): SyncDescriptor0<T>;
|
||||
}
|
||||
|
||||
export class AsyncDescriptor<T> extends AbstractDescriptor<T> implements AsyncDescriptor0<T> {
|
||||
|
||||
public static create<T>(moduleName: string, ctorName: string): AsyncDescriptor<T> {
|
||||
return new AsyncDescriptor<T>(moduleName, ctorName);
|
||||
}
|
||||
|
||||
constructor(private _moduleName: string, private _ctorName?: string, ...staticArguments: any[]) {
|
||||
super(staticArguments);
|
||||
if (typeof _moduleName !== 'string') {
|
||||
throw new Error('Invalid AsyncDescriptor arguments, expected `moduleName` to be a string!');
|
||||
}
|
||||
}
|
||||
|
||||
public get moduleName(): string {
|
||||
return this._moduleName;
|
||||
}
|
||||
|
||||
public get ctorName(): string {
|
||||
return this._ctorName;
|
||||
}
|
||||
|
||||
bind(...moreStaticArguments: any[]): AsyncDescriptor<T> {
|
||||
let allArgs: any[] = [];
|
||||
allArgs = allArgs.concat(this.staticArguments());
|
||||
allArgs = allArgs.concat(moreStaticArguments);
|
||||
return new AsyncDescriptor<T>(this.moduleName, this.ctorName, ...allArgs);
|
||||
}
|
||||
}
|
||||
|
||||
export interface AsyncDescriptor0<T> {
|
||||
moduleName: string;
|
||||
bind(): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor1<A1, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor2<A1, A2, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor1<A2, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor3<A1, A2, A3, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor2<A2, A3, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor1<A3, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor4<A1, A2, A3, A4, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor3<A2, A3, A4, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor2<A3, A4, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor1<A4, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor5<A1, A2, A3, A4, A5, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor4<A2, A3, A4, A5, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor3<A3, A4, A5, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor2<A4, A5, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor1<A5, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor6<A1, A2, A3, A4, A5, A6, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor5<A2, A3, A4, A5, A6, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor4<A3, A4, A5, A6, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor3<A4, A5, A6, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor2<A5, A6, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor1<A6, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor7<A1, A2, A3, A4, A5, A6, A7, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor6<A2, A3, A4, A5, A6, A7, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor5<A3, A4, A5, A6, A7, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor4<A4, A5, A6, A7, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor3<A5, A6, A7, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor2<A6, A7, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): AsyncDescriptor1<A7, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): AsyncDescriptor0<T>;
|
||||
}
|
||||
export interface AsyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T> {
|
||||
moduleName: string;
|
||||
bind(a1: A1): AsyncDescriptor7<A2, A3, A4, A5, A6, A7, A8, T>;
|
||||
bind(a1: A1, a2: A2): AsyncDescriptor6<A3, A4, A5, A6, A7, A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3): AsyncDescriptor5<A4, A5, A6, A7, A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4): AsyncDescriptor4<A5, A6, A7, A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): AsyncDescriptor3<A6, A7, A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): AsyncDescriptor2<A7, A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): AsyncDescriptor1<A8, T>;
|
||||
bind(a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): AsyncDescriptor0<T>;
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ServiceCollection } from './serviceCollection';
|
||||
import * as descriptors from './descriptors';
|
||||
|
||||
@@ -130,20 +129,6 @@ export interface IInstantiationService {
|
||||
createInstance<A1, A2, A3, A4, A5, A6, A7, T>(ctor: IConstructorSignature7<A1, A2, A3, A4, A5, A6, A7, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7): T;
|
||||
createInstance<A1, A2, A3, A4, A5, A6, A7, A8, T>(ctor: IConstructorSignature8<A1, A2, A3, A4, A5, A6, A7, A8, T>, first: A1, second: A2, third: A3, fourth: A4, fifth: A5, sixth: A6, seventh: A7, eigth: A8): T;
|
||||
|
||||
/**
|
||||
* Asynchronously creates an instance that is denoted by
|
||||
* the descriptor
|
||||
*/
|
||||
createInstance<T>(descriptor: descriptors.AsyncDescriptor0<T>): TPromise<T>;
|
||||
createInstance<A1, T>(descriptor: descriptors.AsyncDescriptor1<A1, T>, a1: A1): TPromise<T>;
|
||||
createInstance<A1, A2, T>(descriptor: descriptors.AsyncDescriptor2<A1, A2, T>, a1: A1, a2: A2): TPromise<T>;
|
||||
createInstance<A1, A2, A3, T>(descriptor: descriptors.AsyncDescriptor3<A1, A2, A3, T>, a1: A1, a2: A2, a3: A3): TPromise<T>;
|
||||
createInstance<A1, A2, A3, A4, T>(descriptor: descriptors.AsyncDescriptor4<A1, A2, A3, A4, T>, a1: A1, a2: A2, a3: A3, a4: A4): TPromise<T>;
|
||||
createInstance<A1, A2, A3, A4, A5, T>(descriptor: descriptors.AsyncDescriptor5<A1, A2, A3, A4, A5, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5): TPromise<T>;
|
||||
createInstance<A1, A2, A3, A4, A5, A6, T>(descriptor: descriptors.AsyncDescriptor6<A1, A2, A3, A4, A5, A6, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6): TPromise<T>;
|
||||
createInstance<A1, A2, A3, A4, A5, A6, A7, T>(descriptor: descriptors.AsyncDescriptor7<A1, A2, A3, A4, A5, A6, A7, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7): TPromise<T>;
|
||||
createInstance<A1, A2, A3, A4, A5, A6, A7, A8, T>(descriptor: descriptors.AsyncDescriptor8<A1, A2, A3, A4, A5, A6, A7, A8, T>, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8): TPromise<T>;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { illegalArgument, illegalState, canceled } from 'vs/base/common/errors';
|
||||
import { illegalState } from 'vs/base/common/errors';
|
||||
import { create } from 'vs/base/common/types';
|
||||
import * as assert from 'vs/base/common/assert';
|
||||
import { Graph } from 'vs/base/common/graph';
|
||||
import { SyncDescriptor, AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ServiceIdentifier, IInstantiationService, ServicesAccessor, _util, optional } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
|
||||
@@ -65,11 +64,7 @@ export class InstantiationService implements IInstantiationService {
|
||||
|
||||
createInstance<T>(param: any, ...rest: any[]): any {
|
||||
|
||||
if (param instanceof AsyncDescriptor) {
|
||||
// async
|
||||
return this._createInstanceAsync(param, rest);
|
||||
|
||||
} else if (param instanceof SyncDescriptor) {
|
||||
if (param instanceof SyncDescriptor) {
|
||||
// sync
|
||||
return this._createInstance(param, rest);
|
||||
|
||||
@@ -79,43 +74,6 @@ export class InstantiationService implements IInstantiationService {
|
||||
}
|
||||
}
|
||||
|
||||
private _createInstanceAsync<T>(descriptor: AsyncDescriptor<T>, args: any[]): TPromise<T> {
|
||||
|
||||
let canceledError: Error;
|
||||
|
||||
return new TPromise((c, e, p) => {
|
||||
require([descriptor.moduleName], (_module?: any) => {
|
||||
if (canceledError) {
|
||||
e(canceledError);
|
||||
}
|
||||
|
||||
if (!_module) {
|
||||
return e(illegalArgument('module not found: ' + descriptor.moduleName));
|
||||
}
|
||||
|
||||
let ctor: Function;
|
||||
if (!descriptor.ctorName) {
|
||||
ctor = _module;
|
||||
} else {
|
||||
ctor = _module[descriptor.ctorName];
|
||||
}
|
||||
|
||||
if (typeof ctor !== 'function') {
|
||||
return e(illegalArgument('not a function: ' + descriptor.ctorName || descriptor.moduleName));
|
||||
}
|
||||
|
||||
try {
|
||||
args.unshift.apply(args, descriptor.staticArguments()); // instead of spread in ctor call
|
||||
c(this._createInstance(new SyncDescriptor<T>(ctor), args));
|
||||
} catch (error) {
|
||||
return e(error);
|
||||
}
|
||||
}, e);
|
||||
}, () => {
|
||||
canceledError = canceled();
|
||||
});
|
||||
}
|
||||
|
||||
private _createInstance<T>(desc: SyncDescriptor<T>, args: any[]): T {
|
||||
|
||||
// arguments given by createInstance-call and/or the descriptor
|
||||
|
||||
@@ -9,11 +9,11 @@ import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
|
||||
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { Component } from 'vs/workbench/common/component';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IComposite } from 'vs/workbench/common/composite';
|
||||
import { IEditorControl } from 'vs/platform/editor/common/editor';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
/**
|
||||
* Composites are layed out in the sidebar and panel part of the workbench. At a time only one composite
|
||||
@@ -229,20 +229,25 @@ export abstract class Composite extends Component implements IComposite {
|
||||
/**
|
||||
* A composite descriptor is a leightweight descriptor of a composite in the workbench.
|
||||
*/
|
||||
export abstract class CompositeDescriptor<T extends Composite> extends AsyncDescriptor<T> {
|
||||
export abstract class CompositeDescriptor<T extends Composite> {
|
||||
public id: string;
|
||||
public name: string;
|
||||
public cssClass: string;
|
||||
public order: number;
|
||||
|
||||
constructor(moduleId: string, ctorName: string, id: string, name: string, cssClass?: string, order?: number) {
|
||||
super(moduleId, ctorName);
|
||||
private ctor: IConstructorSignature0<T>;
|
||||
|
||||
constructor(ctor: IConstructorSignature0<T>, id: string, name: string, cssClass?: string, order?: number) {
|
||||
this.ctor = ctor;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.cssClass = cssClass;
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public instantiate(instantiationService: IInstantiationService): T {
|
||||
return instantiationService.createInstance(this.ctor);
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class CompositeRegistry<T extends Composite> {
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { EditorInput } from 'vs/workbench/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { isArray } from 'vs/base/common/types';
|
||||
|
||||
export interface IEditorDescriptor {
|
||||
instantiate(instantiationService: IInstantiationService): BaseEditor;
|
||||
|
||||
getId(): string;
|
||||
getName(): string;
|
||||
|
||||
describes(obj: any): boolean;
|
||||
}
|
||||
|
||||
export interface IEditorRegistry {
|
||||
|
||||
/**
|
||||
* Registers an editor to the platform for the given input type. The second parameter also supports an
|
||||
* array of input classes to be passed in. If the more than one editor is registered for the same editor
|
||||
* input, the input itself will be asked which editor it prefers if this method is provided. Otherwise
|
||||
* the first editor in the list will be returned.
|
||||
*
|
||||
* @param editorInputDescriptor a constructor function that returns an instance of EditorInput for which the
|
||||
* registered editor should be used for.
|
||||
*/
|
||||
registerEditor(descriptor: IEditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>): void;
|
||||
registerEditor(descriptor: IEditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>[]): void;
|
||||
|
||||
/**
|
||||
* Returns the editor descriptor for the given input or null if none.
|
||||
*/
|
||||
getEditor(input: EditorInput): IEditorDescriptor;
|
||||
|
||||
/**
|
||||
* Returns the editor descriptor for the given identifier or null if none.
|
||||
*/
|
||||
getEditorById(editorId: string): IEditorDescriptor;
|
||||
|
||||
/**
|
||||
* Returns an array of registered editors known to the platform.
|
||||
*/
|
||||
getEditors(): IEditorDescriptor[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A lightweight descriptor of an editor. The descriptor is deferred so that heavy editors
|
||||
* can load lazily in the workbench.
|
||||
*/
|
||||
export class EditorDescriptor implements IEditorDescriptor {
|
||||
private ctor: IConstructorSignature0<BaseEditor>;
|
||||
private id: string;
|
||||
private name: string;
|
||||
|
||||
constructor(ctor: IConstructorSignature0<BaseEditor>, id: string, name: string) {
|
||||
this.ctor = ctor;
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public instantiate(instantiationService: IInstantiationService): BaseEditor {
|
||||
return instantiationService.createInstance(this.ctor);
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public describes(obj: any): boolean {
|
||||
return obj instanceof BaseEditor && (<BaseEditor>obj).getId() === this.id;
|
||||
}
|
||||
}
|
||||
|
||||
const INPUT_DESCRIPTORS_PROPERTY = '__$inputDescriptors';
|
||||
|
||||
class EditorRegistry implements IEditorRegistry {
|
||||
private editors: EditorDescriptor[];
|
||||
|
||||
constructor() {
|
||||
this.editors = [];
|
||||
}
|
||||
|
||||
public registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>): void;
|
||||
public registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>[]): void;
|
||||
public registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: any): void {
|
||||
|
||||
// Support both non-array and array parameter
|
||||
let inputDescriptors: SyncDescriptor<EditorInput>[] = [];
|
||||
if (!isArray(editorInputDescriptor)) {
|
||||
inputDescriptors.push(editorInputDescriptor);
|
||||
} else {
|
||||
inputDescriptors = editorInputDescriptor;
|
||||
}
|
||||
|
||||
// Register (Support multiple Editors per Input)
|
||||
descriptor[INPUT_DESCRIPTORS_PROPERTY] = inputDescriptors;
|
||||
this.editors.push(descriptor);
|
||||
}
|
||||
|
||||
public getEditor(input: EditorInput): EditorDescriptor {
|
||||
const findEditorDescriptors = (input: EditorInput, byInstanceOf?: boolean): EditorDescriptor[] => {
|
||||
const matchingDescriptors: EditorDescriptor[] = [];
|
||||
|
||||
for (let i = 0; i < this.editors.length; i++) {
|
||||
const editor = this.editors[i];
|
||||
const inputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
|
||||
for (let j = 0; j < inputDescriptors.length; j++) {
|
||||
const inputClass = inputDescriptors[j].ctor;
|
||||
|
||||
// Direct check on constructor type (ignores prototype chain)
|
||||
if (!byInstanceOf && input.constructor === inputClass) {
|
||||
matchingDescriptors.push(editor);
|
||||
break;
|
||||
}
|
||||
|
||||
// Normal instanceof check
|
||||
else if (byInstanceOf && input instanceof inputClass) {
|
||||
matchingDescriptors.push(editor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If no descriptors found, continue search using instanceof and prototype chain
|
||||
if (!byInstanceOf && matchingDescriptors.length === 0) {
|
||||
return findEditorDescriptors(input, true);
|
||||
}
|
||||
|
||||
if (byInstanceOf) {
|
||||
return matchingDescriptors;
|
||||
}
|
||||
|
||||
return matchingDescriptors;
|
||||
};
|
||||
|
||||
const descriptors = findEditorDescriptors(input);
|
||||
if (descriptors && descriptors.length > 0) {
|
||||
|
||||
// Ask the input for its preferred Editor
|
||||
const preferredEditorId = input.getPreferredEditorId(descriptors.map(d => d.getId()));
|
||||
if (preferredEditorId) {
|
||||
return this.getEditorById(preferredEditorId);
|
||||
}
|
||||
|
||||
// Otherwise, first come first serve
|
||||
return descriptors[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public getEditorById(editorId: string): EditorDescriptor {
|
||||
for (let i = 0; i < this.editors.length; i++) {
|
||||
const editor = this.editors[i];
|
||||
if (editor.getId() === editorId) {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public getEditors(): EditorDescriptor[] {
|
||||
return this.editors.slice(0);
|
||||
}
|
||||
|
||||
public setEditors(editorsToSet: EditorDescriptor[]): void {
|
||||
this.editors = editorsToSet;
|
||||
}
|
||||
|
||||
public getEditorInputs(): any[] {
|
||||
const inputClasses: any[] = [];
|
||||
for (let i = 0; i < this.editors.length; i++) {
|
||||
const editor = this.editors[i];
|
||||
const editorInputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
|
||||
inputClasses.push(...editorInputDescriptors.map(descriptor => descriptor.ctor));
|
||||
}
|
||||
|
||||
return inputClasses;
|
||||
}
|
||||
}
|
||||
|
||||
export const Extensions = {
|
||||
Editors: 'workbench.contributions.editors'
|
||||
};
|
||||
|
||||
Registry.add(Extensions.Editors, new EditorRegistry());
|
||||
@@ -11,6 +11,7 @@ import { Composite, CompositeDescriptor, CompositeRegistry } from 'vs/workbench/
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export abstract class Panel extends Composite implements IPanel { }
|
||||
|
||||
@@ -19,8 +20,8 @@ export abstract class Panel extends Composite implements IPanel { }
|
||||
*/
|
||||
export class PanelDescriptor extends CompositeDescriptor<Panel> {
|
||||
|
||||
constructor(moduleId: string, ctorName: string, id: string, name: string, cssClass?: string, order?: number, private _commandId?: string) {
|
||||
super(moduleId, ctorName, id, name, cssClass, order);
|
||||
constructor(ctor: IConstructorSignature0<Panel>, id: string, name: string, cssClass?: string, order?: number, private _commandId?: string) {
|
||||
super(ctor, id, name, cssClass, order);
|
||||
}
|
||||
|
||||
public get commandId(): string {
|
||||
|
||||
@@ -63,7 +63,6 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
private instantiatedComposites: Composite[];
|
||||
private titleLabel: ICompositeTitleLabel;
|
||||
private toolBar: ToolBar;
|
||||
private compositeLoaderPromises: { [compositeId: string]: TPromise<Composite>; };
|
||||
private progressBar: ProgressBar;
|
||||
private contentAreaSize: Dimension;
|
||||
private telemetryActionsListener: IDisposable;
|
||||
@@ -98,7 +97,6 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
this.mapProgressServiceToComposite = {};
|
||||
this.activeComposite = null;
|
||||
this.instantiatedComposites = [];
|
||||
this.compositeLoaderPromises = {};
|
||||
this.lastActiveCompositeId = storageService.get(activeCompositeSettingsKey, StorageScope.WORKSPACE, this.defaultCompositeId);
|
||||
}
|
||||
|
||||
@@ -120,7 +118,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
private doOpenComposite(id: string, focus?: boolean): TPromise<Composite> {
|
||||
|
||||
// Use a generated token to avoid race conditions from long running promises
|
||||
let currentCompositeOpenToken = defaultGenerator.nextId();
|
||||
const currentCompositeOpenToken = defaultGenerator.nextId();
|
||||
this.currentCompositeOpenToken = currentCompositeOpenToken;
|
||||
|
||||
// Hide current
|
||||
@@ -137,32 +135,31 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
this.updateTitle(id);
|
||||
|
||||
// Create composite
|
||||
return this.createComposite(id, true).then(composite => {
|
||||
const composite = this.createComposite(id, true);
|
||||
|
||||
// Check if another composite opened meanwhile and return in that case
|
||||
if ((this.currentCompositeOpenToken !== currentCompositeOpenToken) || (this.activeComposite && this.activeComposite.getId() !== composite.getId())) {
|
||||
return TPromise.as(null);
|
||||
// Check if another composite opened meanwhile and return in that case
|
||||
if ((this.currentCompositeOpenToken !== currentCompositeOpenToken) || (this.activeComposite && this.activeComposite.getId() !== composite.getId())) {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
// Check if composite already visible and just focus in that case
|
||||
if (this.activeComposite && this.activeComposite.getId() === composite.getId()) {
|
||||
if (focus) {
|
||||
composite.focus();
|
||||
}
|
||||
|
||||
// Check if composite already visible and just focus in that case
|
||||
if (this.activeComposite && this.activeComposite.getId() === composite.getId()) {
|
||||
if (focus) {
|
||||
composite.focus();
|
||||
}
|
||||
// Fullfill promise with composite that is being opened
|
||||
return TPromise.as(composite);
|
||||
}
|
||||
|
||||
// Fullfill promise with composite that is being opened
|
||||
return TPromise.as(composite);
|
||||
// Show Composite and Focus
|
||||
return this.showComposite(composite).then(() => {
|
||||
if (focus) {
|
||||
composite.focus();
|
||||
}
|
||||
|
||||
// Show Composite and Focus
|
||||
return this.showComposite(composite).then(() => {
|
||||
if (focus) {
|
||||
composite.focus();
|
||||
}
|
||||
|
||||
// Fullfill promise with composite that is being opened
|
||||
return composite;
|
||||
});
|
||||
// Fullfill promise with composite that is being opened
|
||||
return composite;
|
||||
});
|
||||
}).then(composite => {
|
||||
if (composite) {
|
||||
@@ -173,46 +170,31 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
});
|
||||
}
|
||||
|
||||
protected createComposite(id: string, isActive?: boolean): TPromise<Composite> {
|
||||
protected createComposite(id: string, isActive?: boolean): Composite {
|
||||
|
||||
// Check if composite is already created
|
||||
for (let i = 0; i < this.instantiatedComposites.length; i++) {
|
||||
if (this.instantiatedComposites[i].getId() === id) {
|
||||
return TPromise.as(this.instantiatedComposites[i]);
|
||||
return this.instantiatedComposites[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Instantiate composite from registry otherwise
|
||||
let compositeDescriptor = this.registry.getComposite(id);
|
||||
const compositeDescriptor = this.registry.getComposite(id);
|
||||
if (compositeDescriptor) {
|
||||
let loaderPromise = this.compositeLoaderPromises[id];
|
||||
if (!loaderPromise) {
|
||||
let progressService = this.instantiationService.createInstance(WorkbenchProgressService, this.progressBar, compositeDescriptor.id, isActive);
|
||||
let compositeInstantiationService = this.instantiationService.createChild(new ServiceCollection([IProgressService, progressService]));
|
||||
const progressService = this.instantiationService.createInstance(WorkbenchProgressService, this.progressBar, compositeDescriptor.id, isActive);
|
||||
const compositeInstantiationService = this.instantiationService.createChild(new ServiceCollection([IProgressService, progressService]));
|
||||
|
||||
loaderPromise = compositeInstantiationService.createInstance(compositeDescriptor).then((composite: Composite) => {
|
||||
this.mapProgressServiceToComposite[composite.getId()] = progressService;
|
||||
const composite = compositeDescriptor.instantiate(compositeInstantiationService);
|
||||
this.mapProgressServiceToComposite[composite.getId()] = progressService;
|
||||
|
||||
// Remember as Instantiated
|
||||
this.instantiatedComposites.push(composite);
|
||||
// Remember as Instantiated
|
||||
this.instantiatedComposites.push(composite);
|
||||
|
||||
// Register to title area update events from the composite
|
||||
this.instantiatedCompositeListeners.push(composite.onTitleAreaUpdate(() => this.onTitleAreaUpdate(composite.getId())));
|
||||
// Register to title area update events from the composite
|
||||
this.instantiatedCompositeListeners.push(composite.onTitleAreaUpdate(() => this.onTitleAreaUpdate(composite.getId())));
|
||||
|
||||
// Remove from Promises Cache since Loaded
|
||||
delete this.compositeLoaderPromises[id];
|
||||
|
||||
return composite;
|
||||
});
|
||||
|
||||
// Report progress for slow loading composites
|
||||
progressService.showWhile(loaderPromise, this.partService.isCreated() ? 800 : 3200 /* less ugly initial startup */);
|
||||
|
||||
// Add to Promise Cache until Loaded
|
||||
this.compositeLoaderPromises[id] = loaderPromise;
|
||||
}
|
||||
|
||||
return loaderPromise;
|
||||
return composite;
|
||||
}
|
||||
|
||||
throw new Error(strings.format('Unable to find composite with id {0}', id));
|
||||
@@ -260,7 +242,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
}
|
||||
|
||||
// Report progress for slow loading composites (but only if we did not create the composites before already)
|
||||
let progressService = this.mapProgressServiceToComposite[composite.getId()];
|
||||
const progressService = this.mapProgressServiceToComposite[composite.getId()];
|
||||
if (progressService && !compositeContainer) {
|
||||
this.mapProgressServiceToComposite[composite.getId()].showWhile(createCompositePromise, this.partService.isCreated() ? 800 : 3200 /* less ugly initial startup */);
|
||||
}
|
||||
@@ -281,7 +263,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
this.toolBar.actionRunner = composite.getActionRunner();
|
||||
|
||||
// Update title with composite title if it differs from descriptor
|
||||
let descriptor = this.registry.getComposite(composite.getId());
|
||||
const descriptor = this.registry.getComposite(composite.getId());
|
||||
if (descriptor && descriptor.name !== composite.getTitle()) {
|
||||
this.updateTitle(composite.getId(), composite.getTitle());
|
||||
}
|
||||
@@ -344,7 +326,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
this.updateTitle(this.activeComposite.getId(), this.activeComposite.getTitle());
|
||||
|
||||
// Actions
|
||||
let actionsBinding = this.collectCompositeActions(this.activeComposite);
|
||||
const actionsBinding = this.collectCompositeActions(this.activeComposite);
|
||||
this.mapActionsBindingToComposite[this.activeComposite.getId()] = actionsBinding;
|
||||
actionsBinding();
|
||||
}
|
||||
@@ -356,7 +338,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
}
|
||||
|
||||
private updateTitle(compositeId: string, compositeTitle?: string): void {
|
||||
let compositeDescriptor = this.registry.getComposite(compositeId);
|
||||
const compositeDescriptor = this.registry.getComposite(compositeId);
|
||||
if (!compositeDescriptor || !this.titleLabel) {
|
||||
return;
|
||||
}
|
||||
@@ -375,15 +357,15 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
private collectCompositeActions(composite: Composite): () => void {
|
||||
|
||||
// From Composite
|
||||
let primaryActions: IAction[] = composite.getActions().slice(0);
|
||||
let secondaryActions: IAction[] = composite.getSecondaryActions().slice(0);
|
||||
const primaryActions: IAction[] = composite.getActions().slice(0);
|
||||
const secondaryActions: IAction[] = composite.getSecondaryActions().slice(0);
|
||||
|
||||
// From Part
|
||||
primaryActions.push(...this.getActions());
|
||||
secondaryActions.push(...this.getSecondaryActions());
|
||||
|
||||
// From Contributions
|
||||
let actionBarRegistry = Registry.as<IActionBarRegistry>(Extensions.Actionbar);
|
||||
const actionBarRegistry = Registry.as<IActionBarRegistry>(Extensions.Actionbar);
|
||||
primaryActions.push(...actionBarRegistry.getActionBarActionsForContext(this.actionContributionScope, composite));
|
||||
secondaryActions.push(...actionBarRegistry.getSecondaryActionBarActionsForContext(this.actionContributionScope, composite));
|
||||
|
||||
@@ -404,10 +386,10 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
return TPromise.as(null); // Nothing to do
|
||||
}
|
||||
|
||||
let composite = this.activeComposite;
|
||||
const composite = this.activeComposite;
|
||||
this.activeComposite = null;
|
||||
|
||||
let compositeContainer = this.mapCompositeToCompositeContainer[composite.getId()];
|
||||
const compositeContainer = this.mapCompositeToCompositeContainer[composite.getId()];
|
||||
|
||||
// Indicate to Composite
|
||||
return composite.setVisible(false).then(() => {
|
||||
@@ -430,7 +412,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
public createTitleArea(parent: Builder): Builder {
|
||||
|
||||
// Title Area Container
|
||||
let titleArea = $(parent).div({
|
||||
const titleArea = $(parent).div({
|
||||
'class': ['composite', 'title']
|
||||
});
|
||||
|
||||
@@ -486,7 +468,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
if (this.activeComposite) {
|
||||
const contextMenuActions = this.getTitleAreaContextMenuActions();
|
||||
if (contextMenuActions.length) {
|
||||
let anchor: { x: number, y: number } = { x: event.posx, y: event.posy };
|
||||
const anchor: { x: number, y: number } = { x: event.posx, y: event.posy };
|
||||
this.contextMenuService.showContextMenu({
|
||||
getAnchor: () => anchor,
|
||||
getActions: () => TPromise.as(contextMenuActions),
|
||||
@@ -512,7 +494,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
|
||||
// Check Registry
|
||||
if (!actionItem) {
|
||||
let actionBarRegistry = Registry.as<IActionBarRegistry>(Extensions.Actionbar);
|
||||
const actionBarRegistry = Registry.as<IActionBarRegistry>(Extensions.Actionbar);
|
||||
actionItem = actionBarRegistry.getActionItemForContext(this.actionContributionScope, ToolBarContext, action);
|
||||
}
|
||||
|
||||
@@ -548,7 +530,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
public layout(dimension: Dimension): Dimension[] {
|
||||
|
||||
// Pass to super
|
||||
let sizes = super.layout(dimension);
|
||||
const sizes = super.layout(dimension);
|
||||
|
||||
// Pass Contentsize to composite
|
||||
this.contentAreaSize = sizes[1];
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import types = require('vs/base/common/types');
|
||||
import { Builder } from 'vs/base/browser/builder';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Panel } from 'vs/workbench/browser/panel';
|
||||
import { EditorInput, EditorOptions, IEditorDescriptor, IEditorRegistry } from 'vs/workbench/common/editor';
|
||||
import { EditorInput, EditorOptions } from 'vs/workbench/common/editor';
|
||||
import { IEditor, Position } from 'vs/platform/editor/common/editor';
|
||||
import { SyncDescriptor, AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
@@ -122,147 +119,4 @@ export abstract class BaseEditor extends Panel implements IEditor {
|
||||
// Super Dispose
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A lightweight descriptor of an editor. The descriptor is deferred so that heavy editors
|
||||
* can load lazily in the workbench.
|
||||
*/
|
||||
export class EditorDescriptor extends AsyncDescriptor<BaseEditor> implements IEditorDescriptor {
|
||||
private id: string;
|
||||
private name: string;
|
||||
|
||||
constructor(id: string, name: string, moduleId: string, ctorName: string) {
|
||||
super(moduleId, ctorName);
|
||||
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public describes(obj: any): boolean {
|
||||
return obj instanceof BaseEditor && (<BaseEditor>obj).getId() === this.id;
|
||||
}
|
||||
}
|
||||
|
||||
const INPUT_DESCRIPTORS_PROPERTY = '__$inputDescriptors';
|
||||
|
||||
class EditorRegistry implements IEditorRegistry {
|
||||
private editors: EditorDescriptor[];
|
||||
|
||||
constructor() {
|
||||
this.editors = [];
|
||||
}
|
||||
|
||||
public registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>): void;
|
||||
public registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>[]): void;
|
||||
public registerEditor(descriptor: EditorDescriptor, editorInputDescriptor: any): void {
|
||||
|
||||
// Support both non-array and array parameter
|
||||
let inputDescriptors: SyncDescriptor<EditorInput>[] = [];
|
||||
if (!types.isArray(editorInputDescriptor)) {
|
||||
inputDescriptors.push(editorInputDescriptor);
|
||||
} else {
|
||||
inputDescriptors = editorInputDescriptor;
|
||||
}
|
||||
|
||||
// Register (Support multiple Editors per Input)
|
||||
descriptor[INPUT_DESCRIPTORS_PROPERTY] = inputDescriptors;
|
||||
this.editors.push(descriptor);
|
||||
}
|
||||
|
||||
public getEditor(input: EditorInput): EditorDescriptor {
|
||||
const findEditorDescriptors = (input: EditorInput, byInstanceOf?: boolean): EditorDescriptor[] => {
|
||||
const matchingDescriptors: EditorDescriptor[] = [];
|
||||
|
||||
for (let i = 0; i < this.editors.length; i++) {
|
||||
const editor = this.editors[i];
|
||||
const inputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
|
||||
for (let j = 0; j < inputDescriptors.length; j++) {
|
||||
const inputClass = inputDescriptors[j].ctor;
|
||||
|
||||
// Direct check on constructor type (ignores prototype chain)
|
||||
if (!byInstanceOf && input.constructor === inputClass) {
|
||||
matchingDescriptors.push(editor);
|
||||
break;
|
||||
}
|
||||
|
||||
// Normal instanceof check
|
||||
else if (byInstanceOf && input instanceof inputClass) {
|
||||
matchingDescriptors.push(editor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If no descriptors found, continue search using instanceof and prototype chain
|
||||
if (!byInstanceOf && matchingDescriptors.length === 0) {
|
||||
return findEditorDescriptors(input, true);
|
||||
}
|
||||
|
||||
if (byInstanceOf) {
|
||||
return matchingDescriptors;
|
||||
}
|
||||
|
||||
return matchingDescriptors;
|
||||
};
|
||||
|
||||
const descriptors = findEditorDescriptors(input);
|
||||
if (descriptors && descriptors.length > 0) {
|
||||
|
||||
// Ask the input for its preferred Editor
|
||||
const preferredEditorId = input.getPreferredEditorId(descriptors.map(d => d.getId()));
|
||||
if (preferredEditorId) {
|
||||
return this.getEditorById(preferredEditorId);
|
||||
}
|
||||
|
||||
// Otherwise, first come first serve
|
||||
return descriptors[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public getEditorById(editorId: string): EditorDescriptor {
|
||||
for (let i = 0; i < this.editors.length; i++) {
|
||||
const editor = this.editors[i];
|
||||
if (editor.getId() === editorId) {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public getEditors(): EditorDescriptor[] {
|
||||
return this.editors.slice(0);
|
||||
}
|
||||
|
||||
public setEditors(editorsToSet: EditorDescriptor[]): void {
|
||||
this.editors = editorsToSet;
|
||||
}
|
||||
|
||||
public getEditorInputs(): any[] {
|
||||
const inputClasses: any[] = [];
|
||||
for (let i = 0; i < this.editors.length; i++) {
|
||||
const editor = this.editors[i];
|
||||
const editorInputDescriptors = <SyncDescriptor<EditorInput>[]>editor[INPUT_DESCRIPTORS_PROPERTY];
|
||||
inputClasses.push(...editorInputDescriptors.map(descriptor => descriptor.ctor));
|
||||
}
|
||||
|
||||
return inputClasses;
|
||||
}
|
||||
}
|
||||
|
||||
export const Extensions = {
|
||||
Editors: 'workbench.contributions.editors'
|
||||
};
|
||||
|
||||
Registry.add(Extensions.Editors, new EditorRegistry());
|
||||
}
|
||||
@@ -10,8 +10,8 @@ import URI from 'vs/base/common/uri';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import { IEditorQuickOpenEntry, IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
|
||||
import { StatusbarItemDescriptor, StatusbarAlignment, IStatusbarRegistry, Extensions as StatusExtensions } from 'vs/workbench/browser/parts/statusbar/statusbar';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, IEditorRegistry, IEditorInputFactory, SideBySideEditorInput, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
import { EditorInput, IEditorInputFactory, SideBySideEditorInput, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResourceEditor';
|
||||
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
@@ -40,14 +40,14 @@ import { getQuickNavigateHandler, inQuickOpenContext } from 'vs/workbench/browse
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { GroupOnePicker, GroupTwoPicker, GroupThreePicker, AllEditorsPicker } from 'vs/workbench/browser/parts/editor/editorPicker';
|
||||
|
||||
// Register String Editor
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
TextResourceEditor,
|
||||
TextResourceEditor.ID,
|
||||
nls.localize('textEditor', "Text Editor"),
|
||||
'vs/workbench/browser/parts/editor/textResourceEditor',
|
||||
'TextResourceEditor'
|
||||
),
|
||||
[
|
||||
new SyncDescriptor(UntitledEditorInput),
|
||||
@@ -58,10 +58,9 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
// Register Text Diff Editor
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
TextDiffEditor,
|
||||
TextDiffEditor.ID,
|
||||
nls.localize('textDiffEditor', "Text Diff Editor"),
|
||||
'vs/workbench/browser/parts/editor/textDiffEditor',
|
||||
'TextDiffEditor'
|
||||
nls.localize('textDiffEditor', "Text Diff Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor(DiffEditorInput)
|
||||
@@ -71,10 +70,9 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
// Register Binary Resource Diff Editor
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
BinaryResourceDiffEditor,
|
||||
BinaryResourceDiffEditor.ID,
|
||||
nls.localize('binaryDiffEditor', "Binary Diff Editor"),
|
||||
'vs/workbench/browser/parts/editor/binaryDiffEditor',
|
||||
'BinaryResourceDiffEditor'
|
||||
nls.localize('binaryDiffEditor', "Binary Diff Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor(DiffEditorInput)
|
||||
@@ -83,10 +81,9 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
SideBySideEditor,
|
||||
SideBySideEditor.ID,
|
||||
nls.localize('sideBySideEditor', "Side by Side Editor"),
|
||||
'vs/workbench/browser/parts/editor/sideBySideEditor',
|
||||
'SideBySideEditor'
|
||||
nls.localize('sideBySideEditor', "Side by Side Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor(SideBySideEditorInput)
|
||||
@@ -266,8 +263,8 @@ const editorPickerContext = ContextKeyExpr.and(inQuickOpenContext, ContextKeyExp
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/browser/parts/editor/editorPicker',
|
||||
'GroupOnePicker',
|
||||
GroupOnePicker,
|
||||
GroupOnePicker.ID,
|
||||
NAVIGATE_IN_GROUP_ONE_PREFIX,
|
||||
editorPickerContextKey,
|
||||
[
|
||||
@@ -292,8 +289,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/browser/parts/editor/editorPicker',
|
||||
'GroupTwoPicker',
|
||||
GroupTwoPicker,
|
||||
GroupTwoPicker.ID,
|
||||
NAVIGATE_IN_GROUP_TWO_PREFIX,
|
||||
editorPickerContextKey,
|
||||
[]
|
||||
@@ -302,8 +299,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/browser/parts/editor/editorPicker',
|
||||
'GroupThreePicker',
|
||||
GroupThreePicker,
|
||||
GroupThreePicker.ID,
|
||||
NAVIGATE_IN_GROUP_THREE_PREFIX,
|
||||
editorPickerContextKey,
|
||||
[]
|
||||
@@ -312,8 +309,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/browser/parts/editor/editorPicker',
|
||||
'AllEditorsPicker',
|
||||
AllEditorsPicker,
|
||||
AllEditorsPicker.ID,
|
||||
NAVIGATE_ALL_EDITORS_GROUP_PREFIX,
|
||||
editorPickerContextKey,
|
||||
[
|
||||
|
||||
@@ -20,8 +20,8 @@ import { getCodeEditor } from 'vs/editor/common/services/codeEditorService';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { Scope as MementoScope } from 'vs/workbench/common/memento';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { BaseEditor, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry, EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, IEditorDescriptor, TextEditorOptions, SideBySideEditorInput, TextCompareEditorVisible, TEXT_DIFF_EDITOR_ID } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, TextEditorOptions, SideBySideEditorInput, TextCompareEditorVisible, TEXT_DIFF_EDITOR_ID } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupsControl, Rochade, IEditorGroupsControl, ProgressState } from 'vs/workbench/browser/parts/editor/editorGroupsControl';
|
||||
import { WorkbenchProgressService } from 'vs/workbench/services/progress/browser/progressService';
|
||||
import { IEditorGroupService, GroupOrientation, GroupArrangement, IEditorTabOptions, IMoveOptions } from 'vs/workbench/services/group/common/groupService';
|
||||
@@ -45,6 +45,7 @@ import { createCSSRule } from 'vs/base/browser/dom';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { join } from 'vs/base/common/paths';
|
||||
import { isCommonCodeEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
class ProgressMonitor {
|
||||
|
||||
@@ -108,7 +109,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
// The following data structures are partitioned into array of Position as provided by Services.POSITION array
|
||||
private visibleEditors: BaseEditor[];
|
||||
private instantiatedEditors: BaseEditor[][];
|
||||
private mapEditorInstantiationPromiseToEditor: { [editorId: string]: TPromise<BaseEditor>; }[];
|
||||
private editorOpenToken: number[];
|
||||
private pendingEditorInputsToClose: EditorIdentifier[];
|
||||
private pendingEditorInputCloseTimeout: number;
|
||||
@@ -143,8 +143,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
|
||||
this.instantiatedEditors = arrays.fill(POSITIONS.length, () => []);
|
||||
|
||||
this.mapEditorInstantiationPromiseToEditor = arrays.fill(POSITIONS.length, () => Object.create(null));
|
||||
|
||||
this.pendingEditorInputsToClose = [];
|
||||
this.pendingEditorInputCloseTimeout = null;
|
||||
|
||||
@@ -325,7 +323,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
if (
|
||||
!input || // no input
|
||||
position === null || // invalid position
|
||||
Object.keys(this.mapEditorInstantiationPromiseToEditor[position]).length > 0 || // pending editor load
|
||||
!this.editorGroupsControl || // too early
|
||||
this.editorGroupsControl.isDragging() // pending editor DND
|
||||
) {
|
||||
@@ -384,23 +381,22 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
}));
|
||||
|
||||
// Show editor
|
||||
return this.doShowEditor(group, descriptor, input, options, ratio, monitor).then(editor => {
|
||||
if (!editor) {
|
||||
return TPromise.as<BaseEditor>(null); // canceled or other error
|
||||
}
|
||||
const editor = this.doShowEditor(group, descriptor, input, options, ratio, monitor);
|
||||
if (!editor) {
|
||||
return TPromise.as<BaseEditor>(null); // canceled or other error
|
||||
}
|
||||
|
||||
// Set input to editor
|
||||
return this.doSetInput(group, editor, input, options, monitor);
|
||||
});
|
||||
// Set input to editor
|
||||
return this.doSetInput(group, editor, input, options, monitor);
|
||||
}
|
||||
|
||||
private doShowEditor(group: EditorGroup, descriptor: IEditorDescriptor, input: EditorInput, options: EditorOptions, ratio: number[], monitor: ProgressMonitor): TPromise<BaseEditor> {
|
||||
const position = this.stacks.positionOfGroup(group);
|
||||
private doShowEditor(group: EditorGroup, descriptor: IEditorDescriptor, input: EditorInput, options: EditorOptions, ratio: number[], monitor: ProgressMonitor): BaseEditor {
|
||||
let position = this.stacks.positionOfGroup(group);
|
||||
const editorAtPosition = this.visibleEditors[position];
|
||||
|
||||
// Return early if the currently visible editor can handle the input
|
||||
if (editorAtPosition && descriptor.describes(editorAtPosition)) {
|
||||
return TPromise.as(editorAtPosition);
|
||||
return editorAtPosition;
|
||||
}
|
||||
|
||||
// Hide active one first
|
||||
@@ -409,107 +405,77 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
}
|
||||
|
||||
// Create Editor
|
||||
return this.doCreateEditor(group, descriptor, monitor).then(editor => {
|
||||
const position = this.stacks.positionOfGroup(group); // might have changed due to a rochade meanwhile
|
||||
const editor = this.doCreateEditor(group, descriptor, monitor);
|
||||
position = this.stacks.positionOfGroup(group); // might have changed due to a rochade meanwhile
|
||||
|
||||
// Make sure that the user meanwhile did not open another editor or something went wrong
|
||||
if (!editor || !this.visibleEditors[position] || editor.getId() !== this.visibleEditors[position].getId()) {
|
||||
monitor.cancel();
|
||||
// Make sure that the user meanwhile did not open another editor or something went wrong
|
||||
if (!editor || !this.visibleEditors[position] || editor.getId() !== this.visibleEditors[position].getId()) {
|
||||
monitor.cancel();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Show in side by side control
|
||||
this.editorGroupsControl.show(editor, position, options && options.preserveFocus, ratio);
|
||||
|
||||
// Indicate to editor that it is now visible
|
||||
editor.setVisible(true, position);
|
||||
|
||||
// Update text compare editor visible context
|
||||
this.updateTextCompareEditorVisible();
|
||||
|
||||
// Make sure the editor is layed out
|
||||
this.editorGroupsControl.layout(position);
|
||||
|
||||
return editor;
|
||||
|
||||
}, e => {
|
||||
this.messageService.show(Severity.Error, types.isString(e) ? new Error(e) : e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
// Show in side by side control
|
||||
this.editorGroupsControl.show(editor, position, options && options.preserveFocus, ratio);
|
||||
|
||||
// Indicate to editor that it is now visible
|
||||
editor.setVisible(true, position);
|
||||
|
||||
// Update text compare editor visible context
|
||||
this.updateTextCompareEditorVisible();
|
||||
|
||||
// Make sure the editor is layed out
|
||||
this.editorGroupsControl.layout(position);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private doCreateEditor(group: EditorGroup, descriptor: IEditorDescriptor, monitor: ProgressMonitor): TPromise<BaseEditor> {
|
||||
private doCreateEditor(group: EditorGroup, descriptor: IEditorDescriptor, monitor: ProgressMonitor): BaseEditor {
|
||||
|
||||
// Instantiate editor
|
||||
return this.doInstantiateEditor(group, descriptor).then(editor => {
|
||||
const position = this.stacks.positionOfGroup(group); // might have changed due to a rochade meanwhile
|
||||
const editor = this.doInstantiateEditor(group, descriptor);
|
||||
const position = this.stacks.positionOfGroup(group); // might have changed due to a rochade meanwhile
|
||||
|
||||
// Make sure that the user meanwhile did not open another editor
|
||||
if (monitor.token !== this.editorOpenToken[position]) {
|
||||
monitor.cancel();
|
||||
// Make sure that the user meanwhile did not open another editor
|
||||
if (monitor.token !== this.editorOpenToken[position]) {
|
||||
monitor.cancel();
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Remember Editor at position
|
||||
this.visibleEditors[position] = editor;
|
||||
// Remember Editor at position
|
||||
this.visibleEditors[position] = editor;
|
||||
|
||||
// Create editor as needed
|
||||
if (!editor.getContainer()) {
|
||||
editor.create($().div({
|
||||
'class': 'editor-container',
|
||||
'role': 'tabpanel',
|
||||
id: descriptor.getId()
|
||||
}));
|
||||
}
|
||||
// Create editor as needed
|
||||
if (!editor.getContainer()) {
|
||||
editor.create($().div({
|
||||
'class': 'editor-container',
|
||||
'role': 'tabpanel',
|
||||
id: descriptor.getId()
|
||||
}));
|
||||
}
|
||||
|
||||
return editor;
|
||||
});
|
||||
return editor;
|
||||
}
|
||||
|
||||
private doInstantiateEditor(group: EditorGroup, descriptor: IEditorDescriptor): TPromise<BaseEditor> {
|
||||
private doInstantiateEditor(group: EditorGroup, descriptor: IEditorDescriptor): BaseEditor {
|
||||
const position = this.stacks.positionOfGroup(group);
|
||||
|
||||
// Return early if already instantiated
|
||||
const instantiatedEditor = this.instantiatedEditors[position].filter(e => descriptor.describes(e))[0];
|
||||
if (instantiatedEditor) {
|
||||
return TPromise.as(instantiatedEditor);
|
||||
}
|
||||
|
||||
// Return early if editor is being instantiated at the same time from a previous call
|
||||
const pendingEditorInstantiate = this.mapEditorInstantiationPromiseToEditor[position][descriptor.getId()];
|
||||
if (pendingEditorInstantiate) {
|
||||
return pendingEditorInstantiate;
|
||||
return instantiatedEditor;
|
||||
}
|
||||
|
||||
// Otherwise instantiate
|
||||
const progressService = this.instantiationService.createInstance(WorkbenchProgressService, this.editorGroupsControl.getProgressBar(position), descriptor.getId(), true);
|
||||
const editorInstantiationService = this.editorGroupsControl.getInstantiationService(position).createChild(new ServiceCollection([IProgressService, progressService]));
|
||||
let loaded = false;
|
||||
|
||||
const onInstantiate = (arg: BaseEditor): TPromise<BaseEditor> => {
|
||||
const position = this.stacks.positionOfGroup(group); // might have changed due to a rochade meanwhile
|
||||
const editor = descriptor.instantiate(editorInstantiationService);
|
||||
|
||||
loaded = true;
|
||||
delete this.mapEditorInstantiationPromiseToEditor[position][descriptor.getId()];
|
||||
this.instantiatedEditors[position].push(editor);
|
||||
|
||||
this.instantiatedEditors[position].push(arg);
|
||||
|
||||
return TPromise.as(arg);
|
||||
};
|
||||
|
||||
const instantiateEditorPromise = editorInstantiationService.createInstance(<EditorDescriptor>descriptor).then(onInstantiate);
|
||||
|
||||
if (!loaded) {
|
||||
this.mapEditorInstantiationPromiseToEditor[position][descriptor.getId()] = instantiateEditorPromise;
|
||||
}
|
||||
|
||||
return instantiateEditorPromise.then(result => {
|
||||
progressService.dispose();
|
||||
|
||||
return result;
|
||||
});
|
||||
return editor;
|
||||
}
|
||||
|
||||
private doSetInput(group: EditorGroup, editor: BaseEditor, input: EditorInput, options: EditorOptions, monitor: ProgressMonitor): TPromise<BaseEditor> {
|
||||
@@ -897,7 +863,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
// Move data structures
|
||||
arrays.move(this.visibleEditors, fromPosition, toPosition);
|
||||
arrays.move(this.editorOpenToken, fromPosition, toPosition);
|
||||
arrays.move(this.mapEditorInstantiationPromiseToEditor, fromPosition, toPosition);
|
||||
arrays.move(this.instantiatedEditors, fromPosition, toPosition);
|
||||
|
||||
// Restore focus
|
||||
@@ -1534,7 +1499,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
|
||||
this.doRochade(this.visibleEditors, from, to, null);
|
||||
this.doRochade(this.editorOpenToken, from, to, null);
|
||||
this.doRochade(this.mapEditorInstantiationPromiseToEditor, from, to, Object.create(null));
|
||||
this.doRochade(this.instantiatedEditors, from, to, []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,8 @@ export abstract class EditorGroupPicker extends BaseEditorPicker {
|
||||
|
||||
export class GroupOnePicker extends EditorGroupPicker {
|
||||
|
||||
public static readonly ID = 'workbench.picker.editors.one';
|
||||
|
||||
protected getPosition(): Position {
|
||||
return Position.ONE;
|
||||
}
|
||||
@@ -223,6 +225,8 @@ export class GroupOnePicker extends EditorGroupPicker {
|
||||
|
||||
export class GroupTwoPicker extends EditorGroupPicker {
|
||||
|
||||
public static readonly ID = 'workbench.picker.editors.two';
|
||||
|
||||
protected getPosition(): Position {
|
||||
return Position.TWO;
|
||||
}
|
||||
@@ -230,6 +234,8 @@ export class GroupTwoPicker extends EditorGroupPicker {
|
||||
|
||||
export class GroupThreePicker extends EditorGroupPicker {
|
||||
|
||||
public static readonly ID = 'workbench.picker.editors.three';
|
||||
|
||||
protected getPosition(): Position {
|
||||
return Position.THREE;
|
||||
}
|
||||
@@ -237,6 +243,8 @@ export class GroupThreePicker extends EditorGroupPicker {
|
||||
|
||||
export class AllEditorsPicker extends BaseEditorPicker {
|
||||
|
||||
public static readonly ID = 'workbench.picker.editors';
|
||||
|
||||
protected getEditorEntries(): EditorPickerEntry[] {
|
||||
const entries: EditorPickerEntry[] = [];
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEditorRegistry, EditorInput, EditorOptions, SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, EditorOptions, SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorControl, Position, IEditor } from 'vs/platform/editor/common/editor';
|
||||
import { VSash } from 'vs/base/browser/ui/sash/sash';
|
||||
|
||||
@@ -18,6 +17,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
export class SideBySideEditor extends BaseEditor {
|
||||
|
||||
@@ -110,7 +110,7 @@ export class SideBySideEditor extends BaseEditor {
|
||||
return this.detailsEditor;
|
||||
}
|
||||
|
||||
private updateInput(oldInput: SideBySideEditorInput, newInput: SideBySideEditorInput, options?: EditorOptions): TPromise<void> {
|
||||
private updateInput(oldInput: SideBySideEditorInput, newInput: SideBySideEditorInput, options?: EditorOptions): void {
|
||||
if (!newInput.matches(oldInput)) {
|
||||
if (oldInput) {
|
||||
this.disposeEditors();
|
||||
@@ -126,24 +126,21 @@ export class SideBySideEditor extends BaseEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private setNewInput(newInput: SideBySideEditorInput, options?: EditorOptions): TPromise<void> {
|
||||
return TPromise.join([
|
||||
this._createEditor(<EditorInput>newInput.details, this.detailsEditorContainer),
|
||||
this._createEditor(<EditorInput>newInput.master, this.masterEditorContainer)
|
||||
]).then(result => this.onEditorsCreated(result[0], result[1], newInput.details, newInput.master, options));
|
||||
private setNewInput(newInput: SideBySideEditorInput, options?: EditorOptions): void {
|
||||
const detailsEditor = this._createEditor(<EditorInput>newInput.details, this.detailsEditorContainer);
|
||||
const masterEditor = this._createEditor(<EditorInput>newInput.master, this.masterEditorContainer);
|
||||
|
||||
this.onEditorsCreated(detailsEditor, masterEditor, newInput.details, newInput.master, options);
|
||||
}
|
||||
|
||||
private _createEditor(editorInput: EditorInput, container: HTMLElement): TPromise<BaseEditor> {
|
||||
private _createEditor(editorInput: EditorInput, container: HTMLElement): BaseEditor {
|
||||
const descriptor = Registry.as<IEditorRegistry>(EditorExtensions.Editors).getEditor(editorInput);
|
||||
if (!descriptor) {
|
||||
return TPromise.wrapError<BaseEditor>(new Error(strings.format('Can not find a registered editor for the input {0}', editorInput)));
|
||||
}
|
||||
return this.instantiationService.createInstance(<EditorDescriptor>descriptor)
|
||||
.then((editor: BaseEditor) => {
|
||||
editor.create(new Builder(container));
|
||||
editor.setVisible(this.isVisible(), this.position);
|
||||
return editor;
|
||||
});
|
||||
|
||||
const editor = descriptor.instantiate(this.instantiationService);
|
||||
editor.create(new Builder(container));
|
||||
editor.setVisible(this.isVisible(), this.position);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private onEditorsCreated(details: BaseEditor, master: BaseEditor, detailsInput: EditorInput, masterInput: EditorInput, options: EditorOptions): TPromise<void> {
|
||||
|
||||
@@ -979,7 +979,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
||||
return result.then<QuickOpenHandler>(null, (error) => {
|
||||
delete this.mapResolvedHandlersToPrefix[id];
|
||||
|
||||
return TPromise.wrapError(new Error('Unable to instantiate quick open handler ' + handler.moduleName + ' - ' + handler.ctorName + ': ' + JSON.stringify(error)));
|
||||
return TPromise.wrapError(new Error(`Unable to instantiate quick open handler ${handler.getId()}: ${JSON.stringify(error)}`));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -992,7 +992,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
||||
}
|
||||
|
||||
// Otherwise load and create
|
||||
return this.mapResolvedHandlersToPrefix[id] = this.instantiationService.createInstance<QuickOpenHandler>(handler);
|
||||
return this.mapResolvedHandlersToPrefix[id] = TPromise.as(handler.instantiate(this.instantiationService));
|
||||
}
|
||||
|
||||
public layout(dimension: Dimension): void {
|
||||
|
||||
@@ -20,7 +20,7 @@ import { EditorOptions, EditorInput } from 'vs/workbench/common/editor';
|
||||
import { IResourceInput, IEditorInput, IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { AsyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IConstructorSignature0, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export interface IWorkbenchQuickOpenConfiguration {
|
||||
workbench: {
|
||||
@@ -128,7 +128,7 @@ export interface QuickOpenHandlerHelpEntry {
|
||||
/**
|
||||
* A lightweight descriptor of a quick open handler.
|
||||
*/
|
||||
export class QuickOpenHandlerDescriptor extends AsyncDescriptor<QuickOpenHandler> {
|
||||
export class QuickOpenHandlerDescriptor {
|
||||
public prefix: string;
|
||||
public description: string;
|
||||
public contextKey: string;
|
||||
@@ -137,13 +137,13 @@ export class QuickOpenHandlerDescriptor extends AsyncDescriptor<QuickOpenHandler
|
||||
public instantProgress: boolean;
|
||||
|
||||
private id: string;
|
||||
private ctor: IConstructorSignature0<QuickOpenHandler>;
|
||||
|
||||
constructor(moduleId: string, ctorName: string, prefix: string, contextKey: string, description: string, instantProgress?: boolean);
|
||||
constructor(moduleId: string, ctorName: string, prefix: string, contextKey: string, helpEntries: QuickOpenHandlerHelpEntry[], instantProgress?: boolean);
|
||||
constructor(moduleId: string, ctorName: string, prefix: string, contextKey: string, param: any, instantProgress: boolean = false) {
|
||||
super(moduleId, ctorName);
|
||||
|
||||
this.id = moduleId + ctorName;
|
||||
constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string, description: string, instantProgress?: boolean);
|
||||
constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string, helpEntries: QuickOpenHandlerHelpEntry[], instantProgress?: boolean);
|
||||
constructor(ctor: IConstructorSignature0<QuickOpenHandler>, id: string, prefix: string, contextKey: string, param: any, instantProgress: boolean = false) {
|
||||
this.ctor = ctor;
|
||||
this.id = id;
|
||||
this.prefix = prefix;
|
||||
this.contextKey = contextKey;
|
||||
this.instantProgress = instantProgress;
|
||||
@@ -158,6 +158,10 @@ export class QuickOpenHandlerDescriptor extends AsyncDescriptor<QuickOpenHandler
|
||||
public getId(): string {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public instantiate(instantiationService: IInstantiationService): QuickOpenHandler {
|
||||
return instantiationService.createInstance(this.ctor);
|
||||
}
|
||||
}
|
||||
|
||||
export const Extensions = {
|
||||
|
||||
@@ -15,6 +15,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IViewlet } from 'vs/workbench/common/viewlet';
|
||||
import { Composite, CompositeDescriptor, CompositeRegistry } from 'vs/workbench/browser/composite';
|
||||
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export abstract class Viewlet extends Composite implements IViewlet {
|
||||
|
||||
@@ -145,19 +146,14 @@ export abstract class ViewerViewlet extends Viewlet {
|
||||
export class ViewletDescriptor extends CompositeDescriptor<Viewlet> {
|
||||
|
||||
constructor(
|
||||
moduleId: string,
|
||||
ctorName: string,
|
||||
ctor: IConstructorSignature0<Viewlet>,
|
||||
id: string,
|
||||
name: string,
|
||||
cssClass?: string,
|
||||
order?: number,
|
||||
private _extensionId?: string
|
||||
) {
|
||||
super(moduleId, ctorName, id, name, cssClass, order);
|
||||
|
||||
if (_extensionId) {
|
||||
this.appendStaticArguments([id]); // Pass viewletId to external viewlet, which doesn't know its id until runtime.
|
||||
}
|
||||
super(ctor, id, name, cssClass, order);
|
||||
}
|
||||
|
||||
public get extensionId(): string {
|
||||
|
||||
@@ -12,7 +12,6 @@ import URI from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IEditor, IEditorViewState, IModel, ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorInput, IEditorModel, IEditorOptions, ITextEditorOptions, IBaseResourceInput, Position, Verbosity } from 'vs/platform/editor/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IInstantiationService, IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
@@ -25,15 +24,6 @@ export enum ConfirmResult {
|
||||
CANCEL
|
||||
}
|
||||
|
||||
export interface IEditorDescriptor {
|
||||
|
||||
getId(): string;
|
||||
|
||||
getName(): string;
|
||||
|
||||
describes(obj: any): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text diff editor id.
|
||||
*/
|
||||
@@ -48,36 +38,6 @@ export interface IFileInputFactory {
|
||||
createFileInput(resource: URI, encoding: string, instantiationService: IInstantiationService): IFileEditorInput;
|
||||
}
|
||||
|
||||
export interface IEditorRegistry {
|
||||
|
||||
/**
|
||||
* Registers an editor to the platform for the given input type. The second parameter also supports an
|
||||
* array of input classes to be passed in. If the more than one editor is registered for the same editor
|
||||
* input, the input itself will be asked which editor it prefers if this method is provided. Otherwise
|
||||
* the first editor in the list will be returned.
|
||||
*
|
||||
* @param editorInputDescriptor a constructor function that returns an instance of EditorInput for which the
|
||||
* registered editor should be used for.
|
||||
*/
|
||||
registerEditor(descriptor: IEditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>): void;
|
||||
registerEditor(descriptor: IEditorDescriptor, editorInputDescriptor: SyncDescriptor<EditorInput>[]): void;
|
||||
|
||||
/**
|
||||
* Returns the editor descriptor for the given input or null if none.
|
||||
*/
|
||||
getEditor(input: EditorInput): IEditorDescriptor;
|
||||
|
||||
/**
|
||||
* Returns the editor descriptor for the given identifier or null if none.
|
||||
*/
|
||||
getEditorById(editorId: string): IEditorDescriptor;
|
||||
|
||||
/**
|
||||
* Returns an array of registered editors known to the platform.
|
||||
*/
|
||||
getEditors(): IEditorDescriptor[];
|
||||
}
|
||||
|
||||
export interface IEditorInputFactoryRegistry {
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,8 @@ class DebugEntry extends Model.QuickOpenEntry {
|
||||
|
||||
export class DebugQuickOpenHandler extends Quickopen.QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.launch';
|
||||
|
||||
constructor(
|
||||
@IQuickOpenService private quickOpenService: IQuickOpenService,
|
||||
@IDebugService private debugService: IDebugService,
|
||||
|
||||
@@ -38,6 +38,9 @@ import { ViewLocation, ViewsRegistry } from 'vs/workbench/browser/parts/views/vi
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { DebugViewlet } from 'vs/workbench/parts/debug/browser/debugViewlet';
|
||||
import { Repl } from 'vs/workbench/parts/debug/electron-browser/repl';
|
||||
import { DebugQuickOpenHandler } from 'vs/workbench/parts/debug/browser/debugQuickOpen';
|
||||
|
||||
class OpenDebugViewletAction extends ToggleViewletAction {
|
||||
public static ID = VIEWLET_ID;
|
||||
@@ -69,8 +72,7 @@ class OpenDebugPanelAction extends TogglePanelAction {
|
||||
|
||||
// register viewlet
|
||||
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
|
||||
'vs/workbench/parts/debug/browser/debugViewlet',
|
||||
'DebugViewlet',
|
||||
DebugViewlet,
|
||||
VIEWLET_ID,
|
||||
nls.localize('debug', "Debug"),
|
||||
'debug',
|
||||
@@ -86,8 +88,7 @@ const openPanelKb: IKeybindings = {
|
||||
|
||||
// register repl panel
|
||||
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
|
||||
'vs/workbench/parts/debug/electron-browser/repl',
|
||||
'Repl',
|
||||
Repl,
|
||||
REPL_ID,
|
||||
nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugPanel' }, 'Debug Console'),
|
||||
'repl',
|
||||
@@ -137,8 +138,8 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(SelectAndStartAction,
|
||||
// Register Quick Open
|
||||
(<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/debug/browser/debugQuickOpen',
|
||||
'DebugQuickOpenHandler',
|
||||
DebugQuickOpenHandler,
|
||||
DebugQuickOpenHandler.ID,
|
||||
'debug ',
|
||||
'inLaunchConfigurationsPicker',
|
||||
nls.localize('debugCommands', "Debug Configuration")
|
||||
|
||||
@@ -38,6 +38,8 @@ class SimpleEntry extends QuickOpenEntry {
|
||||
|
||||
export class ExtensionsHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.extensions';
|
||||
|
||||
constructor( @IViewletService private viewletService: IViewletService) {
|
||||
super();
|
||||
}
|
||||
@@ -67,6 +69,8 @@ export class ExtensionsHandler extends QuickOpenHandler {
|
||||
|
||||
export class GalleryExtensionsHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.gallery';
|
||||
|
||||
constructor( @IViewletService private viewletService: IViewletService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } fro
|
||||
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IOutputChannelRegistry, Extensions as OutputExtensions } from 'vs/workbench/parts/output/common/output';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { VIEWLET_ID, IExtensionsWorkbenchService } from '../common/extensions';
|
||||
import { ExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/node/extensionsWorkbenchService';
|
||||
@@ -29,7 +28,7 @@ import { OpenExtensionsFolderAction, InstallVSIXAction } from 'vs/workbench/part
|
||||
import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensionsInput';
|
||||
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
|
||||
import { ExtensionEditor } from 'vs/workbench/parts/extensions/browser/extensionEditor';
|
||||
import { StatusUpdater } from 'vs/workbench/parts/extensions/electron-browser/extensionsViewlet';
|
||||
import { StatusUpdater, ExtensionsViewlet } from 'vs/workbench/parts/extensions/electron-browser/extensionsViewlet';
|
||||
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import jsonContributionRegistry = require('vs/platform/jsonschemas/common/jsonContributionRegistry');
|
||||
@@ -38,7 +37,8 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } 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 { IEditorRegistry } from 'vs/workbench/common/editor';
|
||||
import { GalleryExtensionsHandler, ExtensionsHandler } from 'vs/workbench/parts/extensions/browser/extensionsQuickOpen';
|
||||
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
// Singletons
|
||||
registerSingleton(IExtensionGalleryService, ExtensionGalleryService);
|
||||
@@ -56,8 +56,8 @@ Registry.as<IOutputChannelRegistry>(OutputExtensions.OutputChannels)
|
||||
// Quickopen
|
||||
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/extensions/browser/extensionsQuickOpen',
|
||||
'ExtensionsHandler',
|
||||
ExtensionsHandler,
|
||||
ExtensionsHandler.ID,
|
||||
'ext ',
|
||||
null,
|
||||
localize('extensionsCommands', "Manage Extensions"),
|
||||
@@ -67,8 +67,8 @@ Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/extensions/browser/extensionsQuickOpen',
|
||||
'GalleryExtensionsHandler',
|
||||
GalleryExtensionsHandler,
|
||||
GalleryExtensionsHandler.ID,
|
||||
'ext install ',
|
||||
null,
|
||||
localize('galleryExtensionsCommands', "Install Gallery Extensions"),
|
||||
@@ -78,10 +78,9 @@ Registry.as<IQuickOpenRegistry>(Extensions.Quickopen).registerQuickOpenHandler(
|
||||
|
||||
// Editor
|
||||
const editorDescriptor = new EditorDescriptor(
|
||||
ExtensionEditor,
|
||||
ExtensionEditor.ID,
|
||||
localize('extension', "Extension"),
|
||||
'vs/workbench/parts/extensions/browser/extensionEditor',
|
||||
'ExtensionEditor'
|
||||
localize('extension', "Extension")
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
@@ -89,8 +88,7 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
|
||||
// Viewlet
|
||||
const viewletDescriptor = new ViewletDescriptor(
|
||||
'vs/workbench/parts/extensions/electron-browser/extensionsViewlet',
|
||||
'ExtensionsViewlet',
|
||||
ExtensionsViewlet,
|
||||
VIEWLET_ID,
|
||||
localize('extensions', "Extensions"),
|
||||
'extensions',
|
||||
|
||||
@@ -13,9 +13,8 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { IEditorRegistry, IEditorInputFactory, EditorInput, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { IEditorInputFactory, EditorInput, IFileEditorInput, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { AutoSaveConfiguration, HotExitConfiguration, SUPPORTED_ENCODINGS } from 'vs/platform/files/common/files';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { FILE_EDITOR_INPUT_ID, VIEWLET_ID, SortOrderConfiguration } from 'vs/workbench/parts/files/common/files';
|
||||
import { FileEditorTracker } from 'vs/workbench/parts/files/common/editors/fileEditorTracker';
|
||||
import { SaveErrorHandler } from 'vs/workbench/parts/files/browser/saveErrorHandler';
|
||||
@@ -31,6 +30,8 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { DirtyFilesTracker } from 'vs/workbench/parts/files/common/dirtyFilesTracker';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { ExplorerViewlet } from 'vs/workbench/parts/files/browser/explorerViewlet';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
// Viewlet Action
|
||||
export class OpenExplorerViewletAction extends ToggleViewletAction {
|
||||
@@ -49,8 +50,7 @@ export class OpenExplorerViewletAction extends ToggleViewletAction {
|
||||
|
||||
// Register Viewlet
|
||||
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
|
||||
'vs/workbench/parts/files/browser/explorerViewlet',
|
||||
'ExplorerViewlet',
|
||||
ExplorerViewlet,
|
||||
VIEWLET_ID,
|
||||
nls.localize('explore', "Explorer"),
|
||||
'explore',
|
||||
@@ -74,10 +74,9 @@ registry.registerWorkbenchAction(
|
||||
// Register file editors
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
TextFileEditor.ID, // explicit dependency because we don't want these editors lazy loaded
|
||||
nls.localize('textFileEditor', "Text File Editor"),
|
||||
'vs/workbench/parts/files/browser/editors/textFileEditor',
|
||||
'TextFileEditor'
|
||||
TextFileEditor,
|
||||
TextFileEditor.ID,
|
||||
nls.localize('textFileEditor', "Text File Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor<EditorInput>(FileEditorInput)
|
||||
@@ -86,10 +85,9 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
BinaryFileEditor.ID, // explicit dependency because we don't want these editors lazy loaded
|
||||
nls.localize('binaryFileEditor', "Binary File Editor"),
|
||||
'vs/workbench/parts/files/browser/editors/binaryFileEditor',
|
||||
'BinaryFileEditor'
|
||||
BinaryFileEditor,
|
||||
BinaryFileEditor.ID,
|
||||
nls.localize('binaryFileEditor', "Binary File Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor<EditorInput>(FileEditorInput)
|
||||
|
||||
@@ -14,13 +14,12 @@ import { Position as EditorPosition } from 'vs/platform/editor/common/editor';
|
||||
import { HtmlInput, HtmlInputOptions } from '../common/htmlInput';
|
||||
import { HtmlPreviewPart } from 'vs/workbench/parts/html/browser/htmlPreviewPart';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry } from 'vs/workbench/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { WebviewElement } from 'vs/workbench/parts/html/browser/webview';
|
||||
import { IExtensionsWorkbenchService } from 'vs/workbench/parts/extensions/common/extensions';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI | string) {
|
||||
const uri = resource instanceof URI ? resource : URI.parse(resource);
|
||||
@@ -31,10 +30,10 @@ function getActivePreviewsForResource(accessor: ServicesAccessor, resource: URI
|
||||
}
|
||||
|
||||
// --- Register Editor
|
||||
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(HtmlPreviewPart.ID,
|
||||
localize('html.editor.label', "Html Preview"),
|
||||
'vs/workbench/parts/html/browser/htmlPreviewPart',
|
||||
'HtmlPreviewPart'),
|
||||
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(
|
||||
HtmlPreviewPart,
|
||||
HtmlPreviewPart.ID,
|
||||
localize('html.editor.label', "Html Preview")),
|
||||
[new SyncDescriptor(HtmlInput)]);
|
||||
|
||||
// --- Register Commands
|
||||
|
||||
@@ -50,8 +50,7 @@ export function registerContributions(): void {
|
||||
|
||||
// markers panel
|
||||
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
|
||||
'vs/workbench/parts/markers/browser/markersPanel',
|
||||
'MarkersPanel',
|
||||
MarkersPanel,
|
||||
Constants.MARKERS_PANEL_ID,
|
||||
Messages.MARKERS_PANEL_TITLE_PROBLEMS,
|
||||
'markersPanel',
|
||||
|
||||
@@ -17,6 +17,7 @@ import { OUTPUT_MODE_ID, OUTPUT_MIME, OUTPUT_PANEL_ID, IOutputService, CONTEXT_I
|
||||
import { PanelRegistry, Extensions, PanelDescriptor } from 'vs/workbench/browser/panel';
|
||||
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { OutputPanel } from 'vs/workbench/parts/output/browser/outputPanel';
|
||||
|
||||
// Register Service
|
||||
registerSingleton(IOutputService, OutputService);
|
||||
@@ -31,8 +32,7 @@ ModesRegistry.registerLanguage({
|
||||
|
||||
// Register Output Panel
|
||||
Registry.as<PanelRegistry>(Extensions.Panels).registerPanel(new PanelDescriptor(
|
||||
'vs/workbench/parts/output/browser/outputPanel',
|
||||
'OutputPanel',
|
||||
OutputPanel,
|
||||
OUTPUT_PANEL_ID,
|
||||
nls.localize('output', "Output"),
|
||||
'output',
|
||||
|
||||
@@ -9,8 +9,7 @@ import URI from 'vs/base/common/uri';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { EditorInput, IEditorRegistry, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorInputExtensions } from 'vs/workbench/common/editor';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
@@ -30,15 +29,15 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
registerSingleton(IPreferencesService, PreferencesService);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
PreferencesEditor,
|
||||
PreferencesEditor.ID,
|
||||
nls.localize('defaultPreferencesEditor', "Default Preferences Editor"),
|
||||
'vs/workbench/parts/preferences/browser/preferencesEditor',
|
||||
'PreferencesEditor'
|
||||
nls.localize('defaultPreferencesEditor', "Default Preferences Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor(PreferencesEditorInput)
|
||||
@@ -47,10 +46,9 @@ Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
new EditorDescriptor(
|
||||
KeybindingsEditor,
|
||||
KeybindingsEditor.ID,
|
||||
nls.localize('keybindingsEditor', "Keybindings Editor"),
|
||||
'vs/workbench/parts/preferences/browser/keybindingsEditor',
|
||||
'KeybindingsEditor'
|
||||
nls.localize('keybindingsEditor', "Keybindings Editor")
|
||||
),
|
||||
[
|
||||
new SyncDescriptor(KeybindingsEditorInput)
|
||||
|
||||
@@ -12,8 +12,8 @@ import { Dimension, Builder } from 'vs/base/browser/builder';
|
||||
import { ArrayNavigator, INavigator } from 'vs/base/common/iterator';
|
||||
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { toResource, SideBySideEditorInput, EditorOptions, EditorInput, IEditorRegistry } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor, EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { toResource, SideBySideEditorInput, EditorOptions, EditorInput } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorModel';
|
||||
import { IEditorControl, Position, Verbosity } from 'vs/platform/editor/common/editor';
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
@@ -47,8 +47,7 @@ import { IPreferencesRenderer, DefaultSettingsRenderer, UserSettingsRenderer, Wo
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { getCodeEditor } from 'vs/editor/common/services/codeEditorService';
|
||||
|
||||
// Ignore following contributions
|
||||
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
import { FoldingController } from 'vs/editor/contrib/folding/browser/folding';
|
||||
import { FindController } from 'vs/editor/contrib/find/browser/find';
|
||||
import { SelectionHighlighter } from 'vs/editor/contrib/find/common/findController';
|
||||
@@ -527,13 +526,11 @@ class SideBySidePreferencesWidget extends Widget {
|
||||
}
|
||||
|
||||
public setInput(defaultPreferencesEditorInput: DefaultPreferencesEditorInput, editablePreferencesEditorInput: EditorInput, options?: EditorOptions): TPromise<{ defaultPreferencesRenderer: IPreferencesRenderer<ISetting>, editablePreferencesRenderer: IPreferencesRenderer<ISetting> }> {
|
||||
return this.getOrCreateEditablePreferencesEditor(editablePreferencesEditorInput)
|
||||
.then(() => {
|
||||
this.dolayout(this.sash.getVerticalSashLeft());
|
||||
return TPromise.join([this.updateInput(this.defaultPreferencesEditor, defaultPreferencesEditorInput, DefaultSettingsEditorContribution.ID, toResource(editablePreferencesEditorInput), options),
|
||||
this.updateInput(this.editablePreferencesEditor, editablePreferencesEditorInput, SettingsEditorContribution.ID, defaultPreferencesEditorInput.getResource(), options)])
|
||||
.then(([defaultPreferencesRenderer, editablePreferencesRenderer]) => ({ defaultPreferencesRenderer, editablePreferencesRenderer }));
|
||||
});
|
||||
this.getOrCreateEditablePreferencesEditor(editablePreferencesEditorInput);
|
||||
this.dolayout(this.sash.getVerticalSashLeft());
|
||||
return TPromise.join([this.updateInput(this.defaultPreferencesEditor, defaultPreferencesEditorInput, DefaultSettingsEditorContribution.ID, toResource(editablePreferencesEditorInput), options),
|
||||
this.updateInput(this.editablePreferencesEditor, editablePreferencesEditorInput, SettingsEditorContribution.ID, defaultPreferencesEditorInput.getResource(), options)])
|
||||
.then(([defaultPreferencesRenderer, editablePreferencesRenderer]) => ({ defaultPreferencesRenderer, editablePreferencesRenderer }));
|
||||
}
|
||||
|
||||
public layout(dimension: Dimension): void {
|
||||
@@ -569,20 +566,19 @@ class SideBySidePreferencesWidget extends Widget {
|
||||
}
|
||||
}
|
||||
|
||||
private getOrCreateEditablePreferencesEditor(editorInput: EditorInput): TPromise<BaseEditor> {
|
||||
private getOrCreateEditablePreferencesEditor(editorInput: EditorInput): BaseEditor {
|
||||
if (this.editablePreferencesEditor) {
|
||||
return TPromise.as(this.editablePreferencesEditor);
|
||||
return this.editablePreferencesEditor;
|
||||
}
|
||||
const descriptor = Registry.as<IEditorRegistry>(EditorExtensions.Editors).getEditor(editorInput);
|
||||
return this.instantiationService.createInstance(<EditorDescriptor>descriptor)
|
||||
.then((editor: BaseEditor) => {
|
||||
this.editablePreferencesEditor = editor;
|
||||
this.editablePreferencesEditor.create(new Builder(this.editablePreferencesEditorContainer));
|
||||
this.editablePreferencesEditor.setVisible(true);
|
||||
(<CodeEditor>this.editablePreferencesEditor.getControl()).onDidFocusEditor(() => this.lastFocusedEditor = this.editablePreferencesEditor);
|
||||
this.lastFocusedEditor = this.editablePreferencesEditor;
|
||||
return editor;
|
||||
});
|
||||
const editor = descriptor.instantiate(this.instantiationService);
|
||||
this.editablePreferencesEditor = editor;
|
||||
this.editablePreferencesEditor.create(new Builder(this.editablePreferencesEditorContainer));
|
||||
this.editablePreferencesEditor.setVisible(true);
|
||||
(<CodeEditor>this.editablePreferencesEditor.getControl()).onDidFocusEditor(() => this.lastFocusedEditor = this.editablePreferencesEditor);
|
||||
this.lastFocusedEditor = this.editablePreferencesEditor;
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private updateInput(editor: BaseEditor, input: EditorInput, editorContributionId: string, associatedPreferencesModelUri: URI, options: EditorOptions): TPromise<IPreferencesRenderer<ISetting>> {
|
||||
|
||||
@@ -386,6 +386,9 @@ class ActionCommandEntry extends BaseCommandEntry {
|
||||
const wordFilter = or(matchesPrefix, matchesWords, matchesContiguousSubString);
|
||||
|
||||
export class CommandsHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.commands';
|
||||
|
||||
private lastSearchValue: string;
|
||||
private commandHistoryEnabled: boolean;
|
||||
private commandsHistory: CommandsHistory;
|
||||
|
||||
@@ -204,6 +204,9 @@ interface IEditorLineDecoration {
|
||||
}
|
||||
|
||||
export class GotoLineHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.line';
|
||||
|
||||
private rangeHighlightDecorationId: IEditorLineDecoration;
|
||||
private lastKnownEditorViewState: IEditorViewState;
|
||||
|
||||
|
||||
@@ -369,6 +369,9 @@ interface IEditorLineDecoration {
|
||||
}
|
||||
|
||||
export class GotoSymbolHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.filesymbols';
|
||||
|
||||
private outlineToModelCache: { [modelId: string]: OutlineModel; };
|
||||
private rangeHighlightDecorationId: IEditorLineDecoration;
|
||||
private lastKnownEditorViewState: IEditorViewState;
|
||||
|
||||
@@ -60,6 +60,8 @@ class HelpEntry extends QuickOpenEntryGroup {
|
||||
|
||||
export class HelpHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.help';
|
||||
|
||||
constructor( @IQuickOpenService private quickOpenService: IQuickOpenService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { GotoSymbolAction, GOTO_SYMBOL_PREFIX, SCOPE_PREFIX } from 'vs/workbench/parts/quickopen/browser/gotoSymbolHandler';
|
||||
import { ShowAllCommandsAction, ALL_COMMANDS_PREFIX, ClearCommandHistoryAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler';
|
||||
import { GotoLineAction, GOTO_LINE_PREFIX } from 'vs/workbench/parts/quickopen/browser/gotoLineHandler';
|
||||
import { HELP_PREFIX } from 'vs/workbench/parts/quickopen/browser/helpHandler';
|
||||
import { VIEW_PICKER_PREFIX, OpenViewPickerAction, QuickOpenViewPickerAction } from 'vs/workbench/parts/quickopen/browser/viewPickerHandler';
|
||||
import { GotoSymbolAction, GOTO_SYMBOL_PREFIX, SCOPE_PREFIX, GotoSymbolHandler } from 'vs/workbench/parts/quickopen/browser/gotoSymbolHandler';
|
||||
import { ShowAllCommandsAction, ALL_COMMANDS_PREFIX, ClearCommandHistoryAction, CommandsHandler } from 'vs/workbench/parts/quickopen/browser/commandsHandler';
|
||||
import { GotoLineAction, GOTO_LINE_PREFIX, GotoLineHandler } from 'vs/workbench/parts/quickopen/browser/gotoLineHandler';
|
||||
import { HELP_PREFIX, HelpHandler } from 'vs/workbench/parts/quickopen/browser/helpHandler';
|
||||
import { VIEW_PICKER_PREFIX, OpenViewPickerAction, QuickOpenViewPickerAction, ViewPickerHandler } from 'vs/workbench/parts/quickopen/browser/viewPickerHandler';
|
||||
import { inQuickOpenContext, getQuickNavigateHandler } from 'vs/workbench/browser/parts/quickopen/quickopen';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
@@ -74,8 +74,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/quickopen/browser/commandsHandler',
|
||||
'CommandsHandler',
|
||||
CommandsHandler,
|
||||
CommandsHandler.ID,
|
||||
ALL_COMMANDS_PREFIX,
|
||||
'inCommandsPicker',
|
||||
nls.localize('commandsHandlerDescriptionDefault', "Show and Run Commands")
|
||||
@@ -84,8 +84,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/quickopen/browser/gotoLineHandler',
|
||||
'GotoLineHandler',
|
||||
GotoLineHandler,
|
||||
GotoLineHandler.ID,
|
||||
GOTO_LINE_PREFIX,
|
||||
null,
|
||||
[
|
||||
@@ -100,8 +100,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/quickopen/browser/gotoSymbolHandler',
|
||||
'GotoSymbolHandler',
|
||||
GotoSymbolHandler,
|
||||
GotoSymbolHandler.ID,
|
||||
GOTO_SYMBOL_PREFIX,
|
||||
'inFileSymbolsPicker',
|
||||
[
|
||||
@@ -121,8 +121,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/quickopen/browser/helpHandler',
|
||||
'HelpHandler',
|
||||
HelpHandler,
|
||||
HelpHandler.ID,
|
||||
HELP_PREFIX,
|
||||
null,
|
||||
nls.localize('helpDescription', "Show Help")
|
||||
@@ -131,8 +131,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpen
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/quickopen/browser/viewPickerHandler',
|
||||
'ViewPickerHandler',
|
||||
ViewPickerHandler,
|
||||
ViewPickerHandler.ID,
|
||||
VIEW_PICKER_PREFIX,
|
||||
inViewsPickerContextKey,
|
||||
[
|
||||
|
||||
@@ -63,6 +63,8 @@ export class ViewEntry extends QuickOpenEntryGroup {
|
||||
|
||||
export class ViewPickerHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.views';
|
||||
|
||||
constructor(
|
||||
@IViewletService private viewletService: IViewletService,
|
||||
@IOutputService private outputService: IOutputService,
|
||||
|
||||
@@ -17,6 +17,7 @@ import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { StatusUpdater, StatusBarController } from './scmActivity';
|
||||
import { SCMViewlet } from 'vs/workbench/parts/scm/electron-browser/scmViewlet';
|
||||
|
||||
class OpenSCMViewletAction extends ToggleViewletAction {
|
||||
|
||||
@@ -32,8 +33,7 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
.registerWorkbenchContribution(DirtyDiffDecorator);
|
||||
|
||||
const viewletDescriptor = new ViewletDescriptor(
|
||||
'vs/workbench/parts/scm/electron-browser/scmViewlet',
|
||||
'SCMViewlet',
|
||||
SCMViewlet,
|
||||
VIEWLET_ID,
|
||||
localize('source control', "Source Control"),
|
||||
'scm',
|
||||
|
||||
@@ -113,6 +113,8 @@ interface ITelemetryData {
|
||||
|
||||
export class OpenAnythingHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.anything';
|
||||
|
||||
private static LINE_COLON_PATTERN = /[#|:|\(](\d*)([#|:|,](\d*))?\)?$/;
|
||||
|
||||
private static FILE_SEARCH_DELAY = 300;
|
||||
|
||||
@@ -130,6 +130,8 @@ export interface IOpenSymbolOptions {
|
||||
|
||||
export class OpenSymbolHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.symbols';
|
||||
|
||||
private static SEARCH_DELAY = 500; // This delay accommodates for the user typing a word and then stops typing to start searching
|
||||
|
||||
private delayer: ThrottledDelayer<QuickOpenEntry[]>;
|
||||
|
||||
@@ -41,6 +41,8 @@ import { SearchViewlet } from 'vs/workbench/parts/search/browser/searchViewlet';
|
||||
import { ListFocusContext } from 'vs/platform/list/browser/listService';
|
||||
import { IOutputChannelRegistry, Extensions as OutputExt } from 'vs/workbench/parts/output/common/output';
|
||||
import { defaultQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen';
|
||||
import { OpenSymbolHandler } from 'vs/workbench/parts/search/browser/openSymbolHandler';
|
||||
import { OpenAnythingHandler } from 'vs/workbench/parts/search/browser/openAnythingHandler';
|
||||
|
||||
registerSingleton(ISearchWorkbenchService, SearchWorkbenchService);
|
||||
replaceContributions();
|
||||
@@ -248,8 +250,7 @@ class ShowAllSymbolsAction extends Action {
|
||||
|
||||
// Register Viewlet
|
||||
Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets).registerViewlet(new ViewletDescriptor(
|
||||
'vs/workbench/parts/search/browser/searchViewlet',
|
||||
'SearchViewlet',
|
||||
SearchViewlet,
|
||||
Constants.VIEWLET_ID,
|
||||
nls.localize('name', "Search"),
|
||||
'search',
|
||||
@@ -295,8 +296,8 @@ actionBarRegistry.registerActionBarContributor(Scope.VIEWER, ExplorerViewerActio
|
||||
// Register Quick Open Handler
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerDefaultQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/search/browser/openAnythingHandler',
|
||||
'OpenAnythingHandler',
|
||||
OpenAnythingHandler,
|
||||
OpenAnythingHandler.ID,
|
||||
'',
|
||||
defaultQuickOpenContextKey,
|
||||
nls.localize('openAnythingHandlerDescription', "Go to File")
|
||||
@@ -305,8 +306,8 @@ Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerDefaultQu
|
||||
|
||||
Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen).registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/search/browser/openAnythingHandler',
|
||||
'OpenSymbolHandler',
|
||||
OpenSymbolHandler,
|
||||
OpenSymbolHandler.ID,
|
||||
ALL_SYMBOLS_PREFIX,
|
||||
'inWorkspaceSymbolsPicker',
|
||||
[
|
||||
|
||||
@@ -31,6 +31,9 @@ class TaskEntry extends base.TaskEntry {
|
||||
}
|
||||
|
||||
export class QuickOpenHandler extends base.QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.tasks';
|
||||
|
||||
private activationPromise: TPromise<void>;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./media/task.contribution';
|
||||
import 'vs/workbench/parts/tasks/browser/taskQuickOpen';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
import { QuickOpenHandler } from 'vs/workbench/parts/tasks/browser/taskQuickOpen';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import * as Objects from 'vs/base/common/objects';
|
||||
@@ -2428,8 +2428,8 @@ const tasksPickerContextKey = 'inTasksPicker';
|
||||
|
||||
quickOpenRegistry.registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/tasks/browser/taskQuickOpen',
|
||||
'QuickOpenHandler',
|
||||
QuickOpenHandler,
|
||||
QuickOpenHandler.ID,
|
||||
'task ',
|
||||
tasksPickerContextKey,
|
||||
nls.localize('quickOpen.task', "Run Task")
|
||||
|
||||
@@ -78,6 +78,8 @@ export class CreateTerminal extends QuickOpenEntry {
|
||||
|
||||
export class TerminalPickerHandler extends QuickOpenHandler {
|
||||
|
||||
public static readonly ID = 'workbench.picker.terminals';
|
||||
|
||||
constructor(
|
||||
@ITerminalService private terminalService: ITerminalService,
|
||||
@IPanelService private panelService: IPanelService
|
||||
|
||||
@@ -34,6 +34,8 @@ import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandler
|
||||
import { Scope, IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { TogglePanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
|
||||
import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel';
|
||||
import { TerminalPickerHandler } from 'vs/workbench/parts/terminal/browser/terminalQuickOpen';
|
||||
|
||||
const quickOpenRegistry = (<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen));
|
||||
|
||||
@@ -41,8 +43,8 @@ const inTerminalsPicker = 'inTerminalPicker';
|
||||
|
||||
quickOpenRegistry.registerQuickOpenHandler(
|
||||
new QuickOpenHandlerDescriptor(
|
||||
'vs/workbench/parts/terminal/browser/terminalQuickOpen',
|
||||
'TerminalPickerHandler',
|
||||
TerminalPickerHandler,
|
||||
TerminalPickerHandler.ID,
|
||||
TERMINAL_PICKER_PREFIX,
|
||||
inTerminalsPicker,
|
||||
nls.localize('quickOpen.terminal', "Show All Opened Terminals")
|
||||
@@ -256,8 +258,7 @@ configurationRegistry.registerConfiguration({
|
||||
registerSingleton(ITerminalService, TerminalService);
|
||||
|
||||
(<panel.PanelRegistry>Registry.as(panel.Extensions.Panels)).registerPanel(new panel.PanelDescriptor(
|
||||
'vs/workbench/parts/terminal/electron-browser/terminalPanel',
|
||||
'TerminalPanel',
|
||||
TerminalPanel,
|
||||
TERMINAL_PANEL_ID,
|
||||
nls.localize('terminal', "Terminal"),
|
||||
'terminal',
|
||||
|
||||
@@ -11,14 +11,13 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { ReleaseNotesEditor } from 'vs/workbench/parts/update/electron-browser/releaseNotesEditor';
|
||||
import { ReleaseNotesInput } from 'vs/workbench/parts/update/electron-browser/releaseNotesInput';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IGlobalActivityRegistry, GlobalActivityExtensions } from 'vs/workbench/common/activity';
|
||||
import { IEditorRegistry } from 'vs/workbench/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
|
||||
import { ShowCurrentReleaseNotesAction, ProductContribution, UpdateContribution, Win3264BitContribution } from './update';
|
||||
import { EditorDescriptor, IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
|
||||
.registerWorkbenchContribution(ProductContribution);
|
||||
@@ -33,10 +32,9 @@ Registry.as<IGlobalActivityRegistry>(GlobalActivityExtensions)
|
||||
|
||||
// Editor
|
||||
const editorDescriptor = new EditorDescriptor(
|
||||
ReleaseNotesEditor,
|
||||
ReleaseNotesEditor.ID,
|
||||
nls.localize('release notes', "Release notes"),
|
||||
'vs/workbench/parts/update/electron-browser/releaseNotesEditor',
|
||||
'ReleaseNotesEditor'
|
||||
nls.localize('release notes', "Release notes")
|
||||
);
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
|
||||
+6
-5
@@ -11,8 +11,7 @@ import { WalkThroughArrowUpAction, WalkThroughArrowDownAction, WalkThroughPageUp
|
||||
import { WalkThroughContentProvider, WalkThroughSnippetContentProvider } from 'vs/workbench/parts/welcome/walkThrough/node/walkThroughContentProvider';
|
||||
import { EditorWalkThroughAction, EditorWalkThroughInputFactory } from 'vs/workbench/parts/welcome/walkThrough/electron-browser/editor/editorWalkThrough';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry, Extensions as EditorInputExtensions, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
|
||||
import { Extensions as EditorInputExtensions, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
@@ -20,12 +19,14 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors)
|
||||
.registerEditor(new EditorDescriptor(WalkThroughPart.ID,
|
||||
.registerEditor(new EditorDescriptor(
|
||||
WalkThroughPart,
|
||||
WalkThroughPart.ID,
|
||||
localize('walkThrough.editor.label', "Interactive Playground"),
|
||||
'vs/workbench/parts/welcome/walkThrough/electron-browser/walkThroughPart',
|
||||
'WalkThroughPart'),
|
||||
),
|
||||
[new SyncDescriptor(WalkThroughInput)]);
|
||||
|
||||
Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions)
|
||||
|
||||
@@ -10,7 +10,7 @@ import errors = require('vs/base/common/errors');
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInput, ITextEditorSelection, Position as GroupPosition } from 'vs/platform/editor/common/editor';
|
||||
import { Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorRegistry, toResource, IEditorGroup, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
|
||||
import { Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, toResource, IEditorGroup, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { FileChangesEvent, IFileService, FileChangeType } from 'vs/platform/files/common/files';
|
||||
@@ -30,7 +30,7 @@ import { parse, IExpression } from 'vs/base/common/glob';
|
||||
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ResourceGlobMatcher } from 'vs/workbench/common/resources';
|
||||
import { Extensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry, Extensions } from 'vs/workbench/browser/editor';
|
||||
|
||||
/**
|
||||
* Stores the selection & view state of an editor and allows to compare it to other selection states.
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { BaseEditor, EditorDescriptor, Extensions } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, EditorOptions, IEditorRegistry, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { EditorInput, EditorOptions, IEditorInputFactory, IEditorInputFactoryRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import * as Platform from 'vs/platform/registry/common/platform';
|
||||
@@ -18,6 +18,7 @@ import { workbenchInstantiationService } from 'vs/workbench/test/workbenchTestSe
|
||||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { TestThemeService } from 'vs/platform/theme/test/common/testThemeService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IEditorRegistry, Extensions, EditorDescriptor } from 'vs/workbench/browser/editor';
|
||||
|
||||
const NullThemeService = new TestThemeService();
|
||||
|
||||
@@ -26,8 +27,8 @@ let EditorInputRegistry: IEditorInputFactoryRegistry = Platform.Registry.as(Edit
|
||||
|
||||
export class MyEditor extends BaseEditor {
|
||||
|
||||
constructor(id: string, @ITelemetryService telemetryService: ITelemetryService) {
|
||||
super(id, NullTelemetryService, NullThemeService);
|
||||
constructor( @ITelemetryService telemetryService: ITelemetryService) {
|
||||
super('MyEditor', NullTelemetryService, NullThemeService);
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
@@ -45,8 +46,8 @@ export class MyEditor extends BaseEditor {
|
||||
|
||||
export class MyOtherEditor extends BaseEditor {
|
||||
|
||||
constructor(id: string, @ITelemetryService telemetryService: ITelemetryService) {
|
||||
super(id, NullTelemetryService, NullThemeService);
|
||||
constructor( @ITelemetryService telemetryService: ITelemetryService) {
|
||||
super('myOtherEditor', NullTelemetryService, NullThemeService);
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
@@ -101,7 +102,7 @@ class MyResourceInput extends ResourceEditorInput { }
|
||||
suite('Workbench BaseEditor', () => {
|
||||
|
||||
test('BaseEditor API', function (done) {
|
||||
let e = new MyEditor('id', NullTelemetryService);
|
||||
let e = new MyEditor(NullTelemetryService);
|
||||
let input = new MyOtherInput();
|
||||
let options = new EditorOptions();
|
||||
|
||||
@@ -128,14 +129,14 @@ suite('Workbench BaseEditor', () => {
|
||||
});
|
||||
|
||||
test('EditorDescriptor', function () {
|
||||
let d = new EditorDescriptor('id', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyClass');
|
||||
let d = new EditorDescriptor(MyEditor, 'id', 'name');
|
||||
assert.strictEqual(d.getId(), 'id');
|
||||
assert.strictEqual(d.getName(), 'name');
|
||||
});
|
||||
|
||||
test('Editor Registration', function () {
|
||||
let d1 = new EditorDescriptor('id1', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyClass');
|
||||
let d2 = new EditorDescriptor('id2', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyOtherClass');
|
||||
let d1 = new EditorDescriptor(MyEditor, 'id1', 'name');
|
||||
let d2 = new EditorDescriptor(MyOtherEditor, 'id2', 'name');
|
||||
|
||||
let oldEditorsCnt = EditorRegistry.getEditors().length;
|
||||
let oldInputCnt = (<any>EditorRegistry).getEditorInputs().length;
|
||||
@@ -154,9 +155,9 @@ suite('Workbench BaseEditor', () => {
|
||||
assert(!EditorRegistry.getEditorById('id3'));
|
||||
});
|
||||
|
||||
test('Editor Lookup favors specific class over superclass (match on specific class)', function (done) {
|
||||
let d1 = new EditorDescriptor('id1', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyEditor');
|
||||
let d2 = new EditorDescriptor('id2', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyOtherEditor');
|
||||
test('Editor Lookup favors specific class over superclass (match on specific class)', function () {
|
||||
let d1 = new EditorDescriptor(MyEditor, 'id1', 'name');
|
||||
let d2 = new EditorDescriptor(MyOtherEditor, 'id2', 'name');
|
||||
|
||||
let oldEditors = EditorRegistry.getEditors();
|
||||
(<any>EditorRegistry).setEditors([]);
|
||||
@@ -166,19 +167,17 @@ suite('Workbench BaseEditor', () => {
|
||||
|
||||
let inst = new TestInstantiationService();
|
||||
|
||||
inst.createInstance(EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'))), 'id').then(editor => {
|
||||
assert.strictEqual(editor.getId(), 'myEditor');
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'))).instantiate(inst);
|
||||
assert.strictEqual(editor.getId(), 'myEditor');
|
||||
|
||||
return inst.createInstance(EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', URI.file('/fake'))), 'id').then(editor => {
|
||||
assert.strictEqual(editor.getId(), 'myOtherEditor');
|
||||
const otherEditor = EditorRegistry.getEditor(inst.createInstance(ResourceEditorInput, 'fake', '', URI.file('/fake'))).instantiate(inst);
|
||||
assert.strictEqual(otherEditor.getId(), 'myOtherEditor');
|
||||
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
});
|
||||
}).done(() => done());
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
});
|
||||
|
||||
test('Editor Lookup favors specific class over superclass (match on super class)', function (done) {
|
||||
let d1 = new EditorDescriptor('id1', 'name', 'vs/workbench/test/browser/parts/editor/baseEditor.test', 'MyOtherEditor');
|
||||
test('Editor Lookup favors specific class over superclass (match on super class)', function () {
|
||||
let d1 = new EditorDescriptor(MyOtherEditor, 'id1', 'name');
|
||||
|
||||
let oldEditors = EditorRegistry.getEditors();
|
||||
(<any>EditorRegistry).setEditors([]);
|
||||
@@ -187,11 +186,10 @@ suite('Workbench BaseEditor', () => {
|
||||
|
||||
let inst = new TestInstantiationService();
|
||||
|
||||
inst.createInstance(EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'))), 'id').then(editor => {
|
||||
assert.strictEqual('myOtherEditor', editor.getId());
|
||||
const editor = EditorRegistry.getEditor(inst.createInstance(MyResourceInput, 'fake', '', URI.file('/fake'))).instantiate(inst);
|
||||
assert.strictEqual('myOtherEditor', editor.getId());
|
||||
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
}).done(() => done());
|
||||
(<any>EditorRegistry).setEditors(oldEditors);
|
||||
});
|
||||
|
||||
test('Editor Input Factory', function () {
|
||||
|
||||
@@ -11,7 +11,7 @@ import { Promise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event from 'vs/base/common/event';
|
||||
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenAction } from 'vs/workbench/browser/quickopen';
|
||||
import { QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenAction, QuickOpenHandler } from 'vs/workbench/browser/quickopen';
|
||||
|
||||
export class TestQuickOpenService implements IQuickOpenService {
|
||||
public _serviceBrand: any;
|
||||
@@ -61,11 +61,15 @@ export class TestQuickOpenService implements IQuickOpenService {
|
||||
|
||||
suite('Workbench QuickOpen', () => {
|
||||
|
||||
class TestHandler extends QuickOpenHandler {
|
||||
|
||||
}
|
||||
|
||||
test('QuickOpen Handler and Registry', () => {
|
||||
let registry = (<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen));
|
||||
let handler = new QuickOpenHandlerDescriptor(
|
||||
'test',
|
||||
'TestHandler',
|
||||
TestHandler,
|
||||
'testhandler',
|
||||
',',
|
||||
'Handler',
|
||||
null
|
||||
|
||||
@@ -7,13 +7,24 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as Platform from 'vs/platform/registry/common/platform';
|
||||
import { ViewletDescriptor, Extensions } from 'vs/workbench/browser/viewlet';
|
||||
import { ViewletDescriptor, Extensions, Viewlet } from 'vs/workbench/browser/viewlet';
|
||||
import * as Types from 'vs/base/common/types';
|
||||
|
||||
suite('Workbench Viewlet', () => {
|
||||
|
||||
class TestViewlet extends Viewlet {
|
||||
|
||||
constructor() {
|
||||
super('id', null, null);
|
||||
}
|
||||
|
||||
public layout(dimension: any): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
test('ViewletDescriptor API', function () {
|
||||
let d = new ViewletDescriptor('moduleId', 'ctorName', 'id', 'name', 'class', 5);
|
||||
let d = new ViewletDescriptor(TestViewlet, 'id', 'name', 'class', 5);
|
||||
assert.strictEqual(d.id, 'id');
|
||||
assert.strictEqual(d.name, 'name');
|
||||
assert.strictEqual(d.cssClass, 'class');
|
||||
@@ -21,11 +32,11 @@ suite('Workbench Viewlet', () => {
|
||||
});
|
||||
|
||||
test('Editor Aware ViewletDescriptor API', function () {
|
||||
let d = new ViewletDescriptor('moduleId', 'ctorName', 'id', 'name', 'class', 5);
|
||||
let d = new ViewletDescriptor(TestViewlet, 'id', 'name', 'class', 5);
|
||||
assert.strictEqual(d.id, 'id');
|
||||
assert.strictEqual(d.name, 'name');
|
||||
|
||||
d = new ViewletDescriptor('moduleId', 'ctorName', 'id', 'name', 'class', 5);
|
||||
d = new ViewletDescriptor(TestViewlet, 'id', 'name', 'class', 5);
|
||||
assert.strictEqual(d.id, 'id');
|
||||
assert.strictEqual(d.name, 'name');
|
||||
});
|
||||
@@ -36,7 +47,7 @@ suite('Workbench Viewlet', () => {
|
||||
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlets));
|
||||
|
||||
let oldCount = Platform.Registry.as(Extensions.Viewlets).getViewlets().length;
|
||||
let d = new ViewletDescriptor('moduleId', 'ctorName', 'reg-test-id', 'name');
|
||||
let d = new ViewletDescriptor(TestViewlet, 'reg-test-id', 'name');
|
||||
Platform.Registry.as(Extensions.Viewlets).registerViewlet(d);
|
||||
|
||||
assert(d === Platform.Registry.as(Extensions.Viewlets).getViewlet('reg-test-id'));
|
||||
|
||||
Reference in New Issue
Block a user