mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Get rid of platform/selection (fixes #5616)
This commit is contained in:
parent
b1b0dd5891
commit
6a8b606792
|
@ -8,7 +8,6 @@ import URI from 'vs/base/common/uri';
|
|||
import {TPromise} from 'vs/base/common/winjs.base';
|
||||
import {IEventEmitter} from 'vs/base/common/eventEmitter';
|
||||
|
||||
import {ISelection} from 'vs/platform/selection/common/selection';
|
||||
import {createDecorator, ServiceIdentifier} from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IEditorService = createDecorator<IEditorService>('editorService');
|
||||
|
@ -105,11 +104,6 @@ export interface IEditor {
|
|||
*/
|
||||
getControl(): IEventEmitter;
|
||||
|
||||
/**
|
||||
* Returns the selection of this editor.
|
||||
*/
|
||||
getSelection(): ISelection;
|
||||
|
||||
/**
|
||||
* Asks the underlying control to focus.
|
||||
*/
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
export interface ISelection {
|
||||
|
||||
/**
|
||||
* Returns if the selection is empty or not.
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
}
|
||||
|
||||
export interface IStructuredSelection extends ISelection {
|
||||
|
||||
/**
|
||||
* Returns an array of selected elements.
|
||||
*/
|
||||
toArray(): any[];
|
||||
}
|
||||
|
||||
export class Selection implements ISelection {
|
||||
static EMPTY = new Selection([]);
|
||||
|
||||
private _selection: any[];
|
||||
|
||||
constructor(selection: any[]) {
|
||||
this._selection = selection || [];
|
||||
}
|
||||
|
||||
public get selection() {
|
||||
return this._selection;
|
||||
}
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return this._selection.length === 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class StructuredSelection extends Selection implements IStructuredSelection {
|
||||
public toArray(): any[] {
|
||||
return this.selection;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,6 @@ import {CompositeEvent} from 'vs/workbench/common/events';
|
|||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {AsyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
|
||||
import {IComposite} from 'vs/workbench/common/composite';
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
/**
|
||||
* Internal composite events to communicate with composite container.
|
||||
|
@ -178,13 +177,6 @@ export abstract class Composite extends WorkbenchComponent implements IComposite
|
|||
this.emit(EventType.INTERNAL_COMPOSITE_TITLE_AREA_UPDATE, new CompositeEvent(this.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of elements that are selected in the composite.
|
||||
*/
|
||||
public getSelection(): ISelection {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this composite is currently visible and false otherwise.
|
||||
*/
|
||||
|
|
|
@ -23,9 +23,9 @@ import {IViewlet} from 'vs/workbench/common/viewlet';
|
|||
import {Composite, CompositeDescriptor, CompositeRegistry} from 'vs/workbench/browser/composite';
|
||||
import {IContextMenuService} from 'vs/platform/contextview/browser/contextView';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {StructuredSelection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
export abstract class Viewlet extends Composite implements IViewlet {
|
||||
|
||||
public getOptimalWidth(): number {
|
||||
return null;
|
||||
}
|
||||
|
@ -136,14 +136,6 @@ export abstract class ViewerViewlet extends Viewlet {
|
|||
return this.viewer;
|
||||
}
|
||||
|
||||
public getSelection(): StructuredSelection {
|
||||
if (!this.viewer) {
|
||||
return new StructuredSelection([]); // return early if viewlet has not yet been created
|
||||
}
|
||||
|
||||
return new StructuredSelection(this.viewer.getSelection());
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
// Dispose Viewer
|
||||
|
@ -367,10 +359,6 @@ export abstract class AdaptiveCollapsibleViewletView extends FixedCollapsibleVie
|
|||
focus(this.tree);
|
||||
}
|
||||
|
||||
public getSelection(): StructuredSelection {
|
||||
return new StructuredSelection(this.tree.getSelection());
|
||||
}
|
||||
|
||||
protected reveal(element: any, relativeTop?: number): TPromise<void> {
|
||||
return reveal(this.tree, element, relativeTop);
|
||||
}
|
||||
|
@ -490,10 +478,6 @@ export abstract class CollapsibleViewletView extends CollapsibleView implements
|
|||
focus(this.tree);
|
||||
}
|
||||
|
||||
public getSelection(): StructuredSelection {
|
||||
return new StructuredSelection(this.tree.getSelection());
|
||||
}
|
||||
|
||||
protected reveal(element: any, relativeTop?: number): TPromise<void> {
|
||||
return reveal(this.tree, element, relativeTop);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import {IEventEmitter} from 'vs/base/common/eventEmitter';
|
||||
import {IAction, IActionItem} from 'vs/base/common/actions';
|
||||
import {ISelection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
export interface IComposite {
|
||||
|
||||
|
@ -39,11 +38,6 @@ export interface IComposite {
|
|||
*/
|
||||
getControl(): IEventEmitter;
|
||||
|
||||
/**
|
||||
* Returns the selection of this composite.
|
||||
*/
|
||||
getSelection(): ISelection;
|
||||
|
||||
/**
|
||||
* Asks the underlying control to focus.
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,6 @@ import {WorkingFilesView} from 'vs/workbench/parts/files/browser/views/workingFi
|
|||
import {IStorageService} from 'vs/platform/storage/common/storage';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {StructuredSelection} from 'vs/platform/selection/common/selection';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
|
||||
export class ExplorerViewlet extends Viewlet {
|
||||
|
@ -163,10 +162,6 @@ export class ExplorerViewlet extends Viewlet {
|
|||
this.splitView.layout(dimension.height);
|
||||
}
|
||||
|
||||
public getSelection(): StructuredSelection {
|
||||
return this.explorerView ? this.explorerView.getSelection() : this.workingFilesView.getSelection();
|
||||
}
|
||||
|
||||
public getActionRunner(): IActionRunner {
|
||||
if (!this.actionRunner) {
|
||||
this.actionRunner = new ActionRunner(this.viewletState);
|
||||
|
|
|
@ -19,6 +19,7 @@ import {Event, EventType as CommonEventType} from 'vs/base/common/events';
|
|||
import {getPathLabel} from 'vs/base/common/labels';
|
||||
import severity from 'vs/base/common/severity';
|
||||
import diagnostics = require('vs/base/common/diagnostics');
|
||||
import {BaseTextEditor} from 'vs/workbench/browser/parts/editor/textEditor';
|
||||
import {Action, IAction} from 'vs/base/common/actions';
|
||||
import {MessageType, IInputValidator} from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import {ITree, IHighlightEvent} from 'vs/base/parts/tree/browser/tree';
|
||||
|
@ -1466,7 +1467,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
|
|||
let selectionOfSource: IEditorSelection;
|
||||
if (positionsOfSource.length) {
|
||||
const activeEditor = this.editorService.getActiveEditor();
|
||||
if (activeEditor && positionsOfSource.indexOf(activeEditor.position) >= 0) {
|
||||
if (activeEditor instanceof BaseTextEditor && positionsOfSource.indexOf(activeEditor.position) >= 0) {
|
||||
selectionOfSource = <IEditorSelection>activeEditor.getSelection();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import {CollapsibleView} from 'vs/base/browser/ui/splitview/splitview';
|
|||
import {Registry} from 'vs/platform/platform';
|
||||
import {IWorkbenchActionRegistry, Extensions} from 'vs/workbench/common/actionRegistry';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {StructuredSelection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
export class EmptyView extends CollapsibleView {
|
||||
|
||||
|
@ -72,10 +71,6 @@ export class EmptyView extends CollapsibleView {
|
|||
// Ignore
|
||||
}
|
||||
|
||||
public getSelection(): StructuredSelection {
|
||||
return new StructuredSelection([]);
|
||||
}
|
||||
|
||||
protected reveal(element: any, relativeTop?: number): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import noworkspace = require('vs/workbench/parts/git/browser/views/noworkspace/n
|
|||
import { DisabledView } from './views/disabled/disabledView';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IProgressService, IProgressRunner} from 'vs/platform/progress/common/progress';
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
|
||||
import IGitService = git.IGitService;
|
||||
|
@ -163,14 +162,6 @@ export class GitViewlet
|
|||
return this.currentView ? this.currentView.getSecondaryActions() : [];
|
||||
}
|
||||
|
||||
public getSelection(): ISelection {
|
||||
if (!this.currentView) {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
return this.currentView.getSelection();
|
||||
}
|
||||
|
||||
public getControl(): eventemitter.IEventEmitter {
|
||||
if (!this.currentView) {
|
||||
return null;
|
||||
|
|
|
@ -38,7 +38,6 @@ import {IEditorInput} from 'vs/platform/editor/common/editor';
|
|||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {ISelection, StructuredSelection} from 'vs/platform/selection/common/selection';
|
||||
import {IEventService} from 'vs/platform/event/common/event';
|
||||
import {CommonKeybindings} from 'vs/base/common/keyCodes';
|
||||
|
||||
|
@ -226,10 +225,6 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
|||
}
|
||||
}
|
||||
|
||||
public getSelection():ISelection {
|
||||
return new StructuredSelection(this.tree.getSelection());
|
||||
}
|
||||
|
||||
public getControl(): Tree.ITree {
|
||||
return this.tree;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import ee = require('vs/base/common/eventEmitter');
|
|||
import view = require('vs/workbench/parts/git/browser/views/view');
|
||||
import builder = require('vs/base/browser/builder');
|
||||
import actions = require('vs/base/common/actions');
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
var $ = builder.$;
|
||||
|
||||
|
@ -51,10 +50,6 @@ export class DisabledView
|
|||
return winjs.TPromise.as(null);
|
||||
}
|
||||
|
||||
public getSelection(): ISelection {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
public getControl(): ee.IEventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import GitActions = require('vs/workbench/parts/git/browser/gitActions');
|
|||
import {IFileService} from 'vs/platform/files/common/files';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {IMessageService} from 'vs/platform/message/common/message';
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
import IGitService = git.IGitService;
|
||||
|
||||
|
@ -151,10 +150,6 @@ export class EmptyView extends EventEmitter.EventEmitter implements GitView.IVie
|
|||
return WinJS.TPromise.as(null);
|
||||
}
|
||||
|
||||
public getSelection():ISelection {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
public getControl(): EventEmitter.IEventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import view = require('vs/workbench/parts/git/browser/views/view');
|
|||
import builder = require('vs/base/browser/builder');
|
||||
import actions = require('vs/base/common/actions');
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
var $ = builder.$;
|
||||
|
||||
|
@ -90,10 +89,6 @@ export class GitlessView
|
|||
return winjs.TPromise.as(null);
|
||||
}
|
||||
|
||||
public getSelection(): ISelection {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
public getControl(): ee.IEventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import ee = require('vs/base/common/eventEmitter');
|
|||
import view = require('vs/workbench/parts/git/browser/views/view');
|
||||
import builder = require('vs/base/browser/builder');
|
||||
import actions = require('vs/base/common/actions');
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
var $ = builder.$;
|
||||
const $ = builder.$;
|
||||
|
||||
export class NotRootView
|
||||
extends ee.EventEmitter
|
||||
|
@ -51,10 +50,6 @@ export class NotRootView
|
|||
return winjs.TPromise.as(null);
|
||||
}
|
||||
|
||||
public getSelection(): ISelection {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
public getControl(): ee.IEventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import ee = require('vs/base/common/eventEmitter');
|
|||
import view = require('vs/workbench/parts/git/browser/views/view');
|
||||
import builder = require('vs/base/browser/builder');
|
||||
import actions = require('vs/base/common/actions');
|
||||
import {ISelection, Selection} from 'vs/platform/selection/common/selection';
|
||||
var $ = builder.$;
|
||||
const $ = builder.$;
|
||||
|
||||
export class NoWorkspaceView
|
||||
extends ee.EventEmitter
|
||||
|
@ -51,10 +50,6 @@ export class NoWorkspaceView
|
|||
return winjs.TPromise.as(null);
|
||||
}
|
||||
|
||||
public getSelection(): ISelection {
|
||||
return Selection.EMPTY;
|
||||
}
|
||||
|
||||
public getControl(): ee.IEventEmitter {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import WinJS = require('vs/base/common/winjs.base');
|
|||
import EventEmitter = require('vs/base/common/eventEmitter');
|
||||
import Builder = require('vs/base/browser/builder');
|
||||
import Actions = require('vs/base/common/actions');
|
||||
import {ISelection} from 'vs/platform/selection/common/selection';
|
||||
|
||||
export interface IView extends Lifecycle.IDisposable {
|
||||
ID: string;
|
||||
|
@ -15,7 +14,6 @@ export interface IView extends Lifecycle.IDisposable {
|
|||
focus(): void;
|
||||
layout(dimension:Builder.Dimension): void;
|
||||
setVisible(visible:boolean): WinJS.Promise;
|
||||
getSelection(): ISelection;
|
||||
getControl(): EventEmitter.IEventEmitter;
|
||||
getActions(): Actions.IAction[];
|
||||
getSecondaryActions(): Actions.IAction[];
|
||||
|
|
|
@ -56,7 +56,6 @@ import {IMessageService} from 'vs/platform/message/common/message';
|
|||
import {ISearchService} from 'vs/platform/search/common/search';
|
||||
import {IProgressService} from 'vs/platform/progress/common/progress';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {ISelection, StructuredSelection} from 'vs/platform/selection/common/selection';
|
||||
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybindingService';
|
||||
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
|
||||
import {KeyCode, CommonKeybindings} from 'vs/base/common/keyCodes';
|
||||
|
@ -1472,10 +1471,6 @@ export class SearchViewlet extends Viewlet {
|
|||
}
|
||||
}
|
||||
|
||||
public getSelection(): ISelection {
|
||||
return new StructuredSelection(this.tree.getSelection());
|
||||
}
|
||||
|
||||
public getActions(): IAction[] {
|
||||
return [
|
||||
this.actionRegistry['refresh'],
|
||||
|
|
Loading…
Reference in a new issue