mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 17:23:40 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
@@ -37,7 +37,7 @@ export namespace ExtHostCustomersRegistry {
|
||||
|
||||
class ExtHostCustomersRegistryImpl {
|
||||
|
||||
public static INSTANCE = new ExtHostCustomersRegistryImpl();
|
||||
public static readonly INSTANCE = new ExtHostCustomersRegistryImpl();
|
||||
|
||||
private _namedCustomers: IExtHostNamedCustomer<any>[];
|
||||
private _customers: IExtHostCustomerCtor<any>[];
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
|
||||
// --- other interested parties
|
||||
import { JSONValidationExtensionPoint } from 'vs/platform/jsonschemas/common/jsonValidationExtensionPoint';
|
||||
@@ -17,8 +18,6 @@ import { LanguageConfigurationFileHandler } from 'vs/workbench/parts/codeEditor/
|
||||
// --- mainThread participants
|
||||
import './mainThreadCommands';
|
||||
import './mainThreadConfiguration';
|
||||
import './mainThreadCredentials';
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
// disable the debug service
|
||||
// import './mainThreadDebugService';
|
||||
@@ -63,12 +62,6 @@ export class ExtensionPoints implements IWorkbenchContribution {
|
||||
this.instantiationService.createInstance(ColorExtensionPoint);
|
||||
this.instantiationService.createInstance(LanguageConfigurationFileHandler);
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
return 'vs.api.extensionPoints';
|
||||
}
|
||||
}
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(
|
||||
ExtensionPoints
|
||||
);
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ExtensionPoints, LifecyclePhase.Starting);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { ExtHostContext, MainThreadCredentialsShape, ExtHostCredentialsShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadCredentials)
|
||||
export class MainThreadCredentials implements MainThreadCredentialsShape {
|
||||
|
||||
private _proxy: ExtHostCredentialsShape;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@ICredentialsService private _credentialsService: ICredentialsService
|
||||
) {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostCredentials);
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
}
|
||||
|
||||
$readSecret(service: string, account: string): Thenable<string | undefined> {
|
||||
return this._credentialsService.readSecret(service, account);
|
||||
}
|
||||
|
||||
$writeSecret(service: string, account: string, secret: string): Thenable<void> {
|
||||
return this._credentialsService.writeSecret(service, account, secret);
|
||||
}
|
||||
$deleteSecret(service: string, account: string): Thenable<boolean> {
|
||||
return this._credentialsService.deleteSecret(service, account);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDebugService, IConfig, IDebugConfigurationProvider } from 'vs/workbench/parts/debug/common/debug';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { ExtHostContext, ExtHostDebugServiceShape, MainThreadDebugServiceShape, DebugSessionUUID, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { ExtHostContext, ExtHostDebugServiceShape, MainThreadDebugServiceShape, DebugSessionUUID, MainContext, IExtHostContext, IBreakpointsDelta, ISourceBreakpointData, IFunctionBreakpointData } from '../node/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import severity from 'vs/base/common/severity';
|
||||
|
||||
@@ -20,6 +20,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
|
||||
private _proxy: ExtHostDebugServiceShape;
|
||||
private _toDispose: IDisposable[];
|
||||
private _breakpointEventsActive: boolean;
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@@ -37,6 +38,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
this._proxy.$acceptDebugSessionActiveChanged(undefined);
|
||||
}
|
||||
}));
|
||||
|
||||
this._toDispose.push(debugService.onDidCustomEvent(event => {
|
||||
if (event && event.sessionId) {
|
||||
const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === event.sessionId).pop();
|
||||
@@ -51,6 +53,74 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
public $startBreakpointEvents(): TPromise<any> {
|
||||
|
||||
if (!this._breakpointEventsActive) {
|
||||
this._breakpointEventsActive = true;
|
||||
|
||||
// set up a handler to send more
|
||||
this._toDispose.push(this.debugService.getModel().onDidChangeBreakpoints(e => {
|
||||
if (e) {
|
||||
const delta: IBreakpointsDelta = {};
|
||||
if (e.added) {
|
||||
delta.added = this.toWire(e.added);
|
||||
}
|
||||
if (e.removed) {
|
||||
delta.removed = e.removed.map(x => x.getId());
|
||||
}
|
||||
if (e.changed) {
|
||||
delta.changed = this.toWire(e.changed);
|
||||
}
|
||||
|
||||
if (delta.added || delta.removed || delta.changed) {
|
||||
this._proxy.$acceptBreakpointsDelta(delta);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
// send all breakpoints
|
||||
const bps = this.debugService.getModel().getBreakpoints();
|
||||
const fbps = this.debugService.getModel().getFunctionBreakpoints();
|
||||
if (bps.length > 0 || fbps.length > 0) {
|
||||
this._proxy.$acceptBreakpointsDelta({
|
||||
added: this.toWire(bps).concat(this.toWire(fbps))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
|
||||
private toWire(bps: (IBreakpoint | IFunctionBreakpoint)[]): (ISourceBreakpointData | IFunctionBreakpointData)[] {
|
||||
|
||||
return bps.map(bp => {
|
||||
if ('name' in bp) {
|
||||
const fbp = <IFunctionBreakpoint>bp;
|
||||
return <IFunctionBreakpointData>{
|
||||
type: 'function',
|
||||
id: bp.getId(),
|
||||
enabled: bp.enabled,
|
||||
functionName: fbp.name,
|
||||
hitCondition: bp.hitCondition,
|
||||
// {{SQL CARBON EDIT}}
|
||||
// condition: bp.condition
|
||||
};
|
||||
} else {
|
||||
const sbp = <IBreakpoint>bp;
|
||||
return <ISourceBreakpointData>{
|
||||
type: 'source',
|
||||
id: bp.getId(),
|
||||
enabled: bp.enabled,
|
||||
condition: sbp.condition,
|
||||
hitCondition: bp.hitCondition,
|
||||
uri: sbp.uri,
|
||||
line: sbp.lineNumber > 0 ? sbp.lineNumber - 1 : 0,
|
||||
character: (typeof sbp.column === 'number' && sbp.column > 0) ? sbp.column - 1 : 0
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public $registerDebugConfigurationProvider(debugType: string, hasProvide: boolean, hasResolve: boolean, handle: number): TPromise<void> {
|
||||
|
||||
const provider = <IDebugConfigurationProvider>{
|
||||
@@ -68,12 +138,12 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
}
|
||||
this.debugService.getConfigurationManager().registerDebugConfigurationProvider(handle, provider);
|
||||
|
||||
return TPromise.as<void>(undefined);
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
|
||||
public $unregisterDebugConfigurationProvider(handle: number): TPromise<any> {
|
||||
this.debugService.getConfigurationManager().unregisterDebugConfigurationProvider(handle);
|
||||
return TPromise.as<void>(undefined);
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
|
||||
public $startDebugging(folderUri: uri | undefined, nameOrConfiguration: string | IConfig): TPromise<boolean> {
|
||||
@@ -102,7 +172,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
|
||||
public $appendDebugConsole(value: string): TPromise<any> {
|
||||
// Use warning as severity to get the orange color for messages coming from the debug extension
|
||||
this.debugService.logToRepl(value, severity.Warning);
|
||||
return TPromise.as<void>(undefined);
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
}
|
||||
// {{SQL CARBON EDIT}}
|
||||
|
||||
@@ -31,10 +31,11 @@ export class MainThreadDialogs implements MainThreadDiaglogsShape {
|
||||
return TPromise.wrapError(new Error('Not supported - Open-dialogs can only be opened on `file`-uris.'));
|
||||
}
|
||||
return new TPromise<string[]>(resolve => {
|
||||
this._windowService.showOpenDialog(
|
||||
MainThreadDialogs._convertOpenOptions(options),
|
||||
filenames => resolve(isFalsyOrEmpty(filenames) ? undefined : filenames)
|
||||
const filenames = this._windowService.showOpenDialog(
|
||||
MainThreadDialogs._convertOpenOptions(options)
|
||||
);
|
||||
|
||||
resolve(isFalsyOrEmpty(filenames) ? undefined : filenames);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,10 +45,10 @@ export class MainThreadDialogs implements MainThreadDiaglogsShape {
|
||||
return TPromise.wrapError(new Error('Not supported - Save-dialogs can only be opened on `file`-uris.'));
|
||||
}
|
||||
return new TPromise<string>(resolve => {
|
||||
this._windowService.showSaveDialog(
|
||||
MainThreadDialogs._convertSaveOptions(options),
|
||||
filename => resolve(!filename ? undefined : filename)
|
||||
const filename = this._windowService.showSaveDialog(
|
||||
MainThreadDialogs._convertSaveOptions(options)
|
||||
);
|
||||
resolve(!filename ? undefined : filename);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import URI from 'vs/base/common/uri';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IModel } from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { MainThreadDocumentContentProvidersShape, ExtHostContext, ExtHostDocumentContentProvidersShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { ITextSource } from 'vs/editor/common/model/textSource';
|
||||
|
||||
@@ -66,7 +66,6 @@ export class BoundModelReferenceCollection {
|
||||
export class MainThreadDocuments implements MainThreadDocumentsShape {
|
||||
|
||||
private _modelService: IModelService;
|
||||
private _modeService: IModeService;
|
||||
private _textModelResolverService: ITextModelService;
|
||||
private _textFileService: ITextFileService;
|
||||
private _fileService: IFileService;
|
||||
@@ -89,7 +88,6 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
|
||||
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
||||
) {
|
||||
this._modelService = modelService;
|
||||
this._modeService = modeService;
|
||||
this._textModelResolverService = textModelResolverService;
|
||||
this._textFileService = textFileService;
|
||||
this._fileService = fileService;
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
'use strict';
|
||||
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModel, ICommonCodeEditor, isCommonCodeEditor, isCommonDiffEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IModel } from 'vs/editor/common/editorCommon';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { ExtHostContext, ExtHostDocumentsAndEditorsShape, IModelAddedData, ITextEditorAddData, IDocumentsAndEditorsDelta, IExtHostContext, MainContext } from '../node/extHost.protocol';
|
||||
import { MainThreadTextEditor } from './mainThreadEditor';
|
||||
@@ -22,17 +22,10 @@ import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/untitledEditorService';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { isCodeEditor, isDiffEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
namespace mapset {
|
||||
|
||||
export function newSet<E>(from: Set<E>): Set<E> {
|
||||
return new (<any>Set)(from);
|
||||
// let ret = new Set<E>();
|
||||
// from.forEach(ret.add, ret);
|
||||
// return ret;
|
||||
}
|
||||
|
||||
export function setValues<T>(set: Set<T>): T[] {
|
||||
// return Array.from(set);
|
||||
let ret: T[] = [];
|
||||
@@ -64,7 +57,7 @@ namespace delta {
|
||||
}
|
||||
});
|
||||
return { removed, added };
|
||||
};
|
||||
}
|
||||
|
||||
export function ofMaps<K, V>(before: Map<K, V>, after: Map<K, V>): { removed: V[], added: V[] } {
|
||||
const removed: V[] = [];
|
||||
@@ -80,7 +73,7 @@ namespace delta {
|
||||
}
|
||||
});
|
||||
return { removed, added };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class EditorSnapshot {
|
||||
@@ -88,7 +81,7 @@ class EditorSnapshot {
|
||||
readonly id: string;
|
||||
|
||||
constructor(
|
||||
readonly editor: ICommonCodeEditor,
|
||||
readonly editor: ICodeEditor,
|
||||
) {
|
||||
this.id = `${editor.getId()},${editor.getModel().id}`;
|
||||
}
|
||||
@@ -181,14 +174,14 @@ class MainThreadDocumentAndEditorStateComputer {
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
}
|
||||
|
||||
private _onDidAddEditor(e: ICommonCodeEditor): void {
|
||||
private _onDidAddEditor(e: ICodeEditor): void {
|
||||
this._toDisposeOnEditorRemove.set(e.getId(), e.onDidChangeModel(() => this._updateState()));
|
||||
this._toDisposeOnEditorRemove.set(e.getId(), e.onDidFocusEditor(() => this._updateState()));
|
||||
this._toDisposeOnEditorRemove.set(e.getId(), e.onDidBlurEditor(() => this._updateState()));
|
||||
this._updateState();
|
||||
}
|
||||
|
||||
private _onDidRemoveEditor(e: ICommonCodeEditor): void {
|
||||
private _onDidRemoveEditor(e: ICodeEditor): void {
|
||||
const sub = this._toDisposeOnEditorRemove.get(e.getId());
|
||||
if (sub) {
|
||||
this._toDisposeOnEditorRemove.delete(e.getId());
|
||||
@@ -219,7 +212,7 @@ class MainThreadDocumentAndEditorStateComputer {
|
||||
this._onDidChangeState(new DocumentAndEditorStateDelta(
|
||||
[], [model],
|
||||
[], [],
|
||||
this._currentState.activeEditor, this._currentState.activeEditor
|
||||
undefined, undefined
|
||||
));
|
||||
}
|
||||
|
||||
@@ -259,10 +252,10 @@ class MainThreadDocumentAndEditorStateComputer {
|
||||
const workbenchEditor = this._workbenchEditorService.getActiveEditor();
|
||||
if (workbenchEditor) {
|
||||
const workbenchEditorControl = workbenchEditor.getControl();
|
||||
let candidate: ICommonCodeEditor;
|
||||
if (isCommonCodeEditor(workbenchEditorControl)) {
|
||||
let candidate: ICodeEditor;
|
||||
if (isCodeEditor(workbenchEditorControl)) {
|
||||
candidate = workbenchEditorControl;
|
||||
} else if (isCommonDiffEditor(workbenchEditorControl)) {
|
||||
} else if (isDiffEditor(workbenchEditorControl)) {
|
||||
candidate = workbenchEditorControl.getModifiedEditor();
|
||||
}
|
||||
if (candidate) {
|
||||
@@ -313,15 +306,14 @@ export class MainThreadDocumentsAndEditors {
|
||||
@IFileService fileService: IFileService,
|
||||
@ITextModelService textModelResolverService: ITextModelService,
|
||||
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
|
||||
@IEditorGroupService editorGroupService: IEditorGroupService,
|
||||
@ITelemetryService telemetryService: ITelemetryService
|
||||
@IEditorGroupService editorGroupService: IEditorGroupService
|
||||
) {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostDocumentsAndEditors);
|
||||
|
||||
const mainThreadDocuments = new MainThreadDocuments(this, extHostContext, this._modelService, modeService, this._textFileService, fileService, textModelResolverService, untitledEditorService);
|
||||
extHostContext.set(MainContext.MainThreadDocuments, mainThreadDocuments);
|
||||
|
||||
const mainThreadEditors = new MainThreadEditors(this, extHostContext, codeEditorService, this._workbenchEditorService, editorGroupService, telemetryService, textModelResolverService, fileService, this._modelService);
|
||||
const mainThreadEditors = new MainThreadEditors(this, extHostContext, codeEditorService, this._workbenchEditorService, editorGroupService, textModelResolverService, fileService, this._modelService);
|
||||
extHostContext.set(MainContext.MainThreadEditors, mainThreadEditors);
|
||||
|
||||
// It is expected that the ctor of the state computer calls our `_onDelta`.
|
||||
|
||||
@@ -11,11 +11,12 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { Selection, ISelection } from 'vs/editor/common/core/selection';
|
||||
import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
|
||||
import { SnippetController2 } from 'vs/editor/contrib/snippet/snippetController2';
|
||||
import { EndOfLine, TextEditorLineNumbersStyle } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { TextEditorCursorStyle, cursorStyleToString } from 'vs/editor/common/config/editorOptions';
|
||||
import { TextEditorCursorStyle, cursorStyleToString, RenderLineNumbersType } from 'vs/editor/common/config/editorOptions';
|
||||
import { ICursorSelectionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IResolvedTextEditorConfiguration, ISelectionChangeEvent, ITextEditorConfigurationUpdate, TextEditorRevealType, IApplyEditsOptions, IUndoStopOptions } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
function configurationsEqual(a: IResolvedTextEditorConfiguration, b: IResolvedTextEditorConfiguration) {
|
||||
if (a && !b || !a && b) {
|
||||
@@ -45,7 +46,7 @@ export class MainThreadTextEditor {
|
||||
private _model: EditorCommon.IModel;
|
||||
private _modelService: IModelService;
|
||||
private _modelListeners: IDisposable[];
|
||||
private _codeEditor: EditorCommon.ICommonCodeEditor;
|
||||
private _codeEditor: ICodeEditor;
|
||||
private _focusTracker: IFocusTracker;
|
||||
private _codeEditorListeners: IDisposable[];
|
||||
|
||||
@@ -58,7 +59,7 @@ export class MainThreadTextEditor {
|
||||
constructor(
|
||||
id: string,
|
||||
model: EditorCommon.IModel,
|
||||
codeEditor: EditorCommon.ICommonCodeEditor,
|
||||
codeEditor: ICodeEditor,
|
||||
focusTracker: IFocusTracker,
|
||||
modelService: IModelService
|
||||
) {
|
||||
@@ -97,15 +98,15 @@ export class MainThreadTextEditor {
|
||||
return this._model;
|
||||
}
|
||||
|
||||
public getCodeEditor(): EditorCommon.ICommonCodeEditor {
|
||||
public getCodeEditor(): ICodeEditor {
|
||||
return this._codeEditor;
|
||||
}
|
||||
|
||||
public hasCodeEditor(codeEditor: EditorCommon.ICommonCodeEditor): boolean {
|
||||
public hasCodeEditor(codeEditor: ICodeEditor): boolean {
|
||||
return (this._codeEditor === codeEditor);
|
||||
}
|
||||
|
||||
public setCodeEditor(codeEditor: EditorCommon.ICommonCodeEditor): void {
|
||||
public setCodeEditor(codeEditor: ICodeEditor): void {
|
||||
if (this.hasCodeEditor(codeEditor)) {
|
||||
// Nothing to do...
|
||||
return;
|
||||
@@ -278,7 +279,7 @@ export class MainThreadTextEditor {
|
||||
}
|
||||
}
|
||||
|
||||
private _readConfiguration(model: EditorCommon.IModel, codeEditor: EditorCommon.ICommonCodeEditor): IResolvedTextEditorConfiguration {
|
||||
private _readConfiguration(model: EditorCommon.IModel, codeEditor: ICodeEditor): IResolvedTextEditorConfiguration {
|
||||
if (model.isDisposed()) {
|
||||
// shutdown time
|
||||
return this._configuration;
|
||||
@@ -289,12 +290,16 @@ export class MainThreadTextEditor {
|
||||
let codeEditorOpts = codeEditor.getConfiguration();
|
||||
cursorStyle = codeEditorOpts.viewInfo.cursorStyle;
|
||||
|
||||
if (codeEditorOpts.viewInfo.renderRelativeLineNumbers) {
|
||||
lineNumbers = TextEditorLineNumbersStyle.Relative;
|
||||
} else if (codeEditorOpts.viewInfo.renderLineNumbers) {
|
||||
lineNumbers = TextEditorLineNumbersStyle.On;
|
||||
} else {
|
||||
lineNumbers = TextEditorLineNumbersStyle.Off;
|
||||
switch (codeEditorOpts.viewInfo.renderLineNumbers) {
|
||||
case RenderLineNumbersType.Off:
|
||||
lineNumbers = TextEditorLineNumbersStyle.Off;
|
||||
break;
|
||||
case RenderLineNumbersType.Relative:
|
||||
lineNumbers = TextEditorLineNumbersStyle.Relative;
|
||||
break;
|
||||
default:
|
||||
lineNumbers = TextEditorLineNumbersStyle.On;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,30 +8,29 @@ import URI from 'vs/base/common/uri';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { disposed } from 'vs/base/common/errors';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ISingleEditOperation, IDecorationRenderOptions, IDecorationOptions, ILineChange, ICommonCodeEditor, isCommonCodeEditor } from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { ISingleEditOperation, IDecorationRenderOptions, IDecorationOptions, ILineChange } from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { Position as EditorPosition, ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { MainThreadTextEditor } from './mainThreadEditor';
|
||||
import { ITextEditorConfigurationUpdate, TextEditorRevealType, IApplyEditsOptions, IUndoStopOptions } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { MainThreadDocumentsAndEditors } from './mainThreadDocumentsAndEditors';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { equals as objectEquals } from 'vs/base/common/objects';
|
||||
import { ExtHostContext, MainThreadEditorsShape, ExtHostEditorsShape, ITextDocumentShowOptions, ITextEditorPositionData, IExtHostContext, IWorkspaceResourceEdit } from '../node/extHost.protocol';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { ISelection } from 'vs/editor/common/core/selection';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { bulkEdit, IResourceEdit } from 'vs/editor/common/services/bulkEdit';
|
||||
import { bulkEdit, IResourceEdit } from 'vs/editor/browser/services/bulkEdit';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { isCodeEditor, ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
|
||||
private _proxy: ExtHostEditorsShape;
|
||||
private _documentsAndEditors: MainThreadDocumentsAndEditors;
|
||||
private _workbenchEditorService: IWorkbenchEditorService;
|
||||
private _telemetryService: ITelemetryService;
|
||||
private _toDispose: IDisposable[];
|
||||
private _textEditorsListenersMap: { [editorId: string]: IDisposable[]; };
|
||||
private _editorPositionData: ITextEditorPositionData;
|
||||
@@ -43,7 +42,6 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
@ICodeEditorService private _codeEditorService: ICodeEditorService,
|
||||
@IWorkbenchEditorService workbenchEditorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService editorGroupService: IEditorGroupService,
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@ITextModelService private readonly _textModelResolverService: ITextModelService,
|
||||
@IFileService private readonly _fileService: IFileService,
|
||||
@IModelService private readonly _modelService: IModelService,
|
||||
@@ -51,7 +49,6 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostEditors);
|
||||
this._documentsAndEditors = documentsAndEditors;
|
||||
this._workbenchEditorService = workbenchEditorService;
|
||||
this._telemetryService = telemetryService;
|
||||
this._toDispose = [];
|
||||
this._textEditorsListenersMap = Object.create(null);
|
||||
this._editorPositionData = null;
|
||||
@@ -139,14 +136,6 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
}
|
||||
|
||||
$tryShowEditor(id: string, position: EditorPosition): TPromise<void> {
|
||||
// check how often this is used
|
||||
/* __GDPR__
|
||||
"api.deprecated" : {
|
||||
"function" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this._telemetryService.publicLog('api.deprecated', { function: 'TextEditor.show' });
|
||||
|
||||
let mainThreadEditor = this._documentsAndEditors.getEditor(id);
|
||||
if (mainThreadEditor) {
|
||||
let model = mainThreadEditor.getModel();
|
||||
@@ -159,14 +148,6 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
}
|
||||
|
||||
$tryHideEditor(id: string): TPromise<void> {
|
||||
// check how often this is used
|
||||
/* __GDPR__
|
||||
"api.deprecated" : {
|
||||
"function" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this._telemetryService.publicLog('api.deprecated', { function: 'TextEditor.hide' });
|
||||
|
||||
let mainThreadEditor = this._documentsAndEditors.getEditor(id);
|
||||
if (mainThreadEditor) {
|
||||
let editors = this._workbenchEditorService.getVisibleEditors();
|
||||
@@ -259,11 +240,11 @@ export class MainThreadEditors implements MainThreadEditorsShape {
|
||||
}
|
||||
}
|
||||
|
||||
let codeEditor: ICommonCodeEditor;
|
||||
let codeEditor: ICodeEditor;
|
||||
let editor = this._workbenchEditorService.getActiveEditor();
|
||||
if (editor) {
|
||||
let candidate = editor.getControl();
|
||||
if (isCommonCodeEditor(candidate)) {
|
||||
if (isCodeEditor(candidate)) {
|
||||
codeEditor = candidate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ export class MainThreadErrors implements MainThreadErrorsShape {
|
||||
//
|
||||
}
|
||||
|
||||
$onUnexpectedError(err: any | SerializedError, extensionId: string | undefined): void {
|
||||
$onUnexpectedError(err: any | SerializedError): void {
|
||||
if (err.$isError) {
|
||||
const { name, message, stack } = err;
|
||||
err = new Error();
|
||||
err.message = extensionId ? `[${extensionId}] ${message}` : message;
|
||||
err.message = message;
|
||||
err.name = name;
|
||||
err.stack = stack;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
|
||||
import { MainThreadExtensionServiceShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { ExtensionService } from 'vs/workbench/services/extensions/electron-browser/extensionService';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { SerializedError } from 'vs/base/common/errors';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadExtensionService)
|
||||
export class MainThreadExtensionService implements MainThreadExtensionServiceShape {
|
||||
@@ -30,9 +31,21 @@ export class MainThreadExtensionService implements MainThreadExtensionServiceSha
|
||||
$localShowMessage(severity: Severity, msg: string): void {
|
||||
this._extensionService._logOrShowMessage(severity, msg);
|
||||
}
|
||||
$onExtensionActivated(extensionId: string, startup: boolean, codeLoadingTime: number, activateCallTime: number, activateResolvedTime: number): void {
|
||||
this._extensionService._onExtensionActivated(extensionId, startup, codeLoadingTime, activateCallTime, activateResolvedTime);
|
||||
$onExtensionActivated(extensionId: string, startup: boolean, codeLoadingTime: number, activateCallTime: number, activateResolvedTime: number, activationEvent: string): void {
|
||||
this._extensionService._onExtensionActivated(extensionId, startup, codeLoadingTime, activateCallTime, activateResolvedTime, activationEvent);
|
||||
}
|
||||
$onExtensionRuntimeError(extensionId: string, data: SerializedError): void {
|
||||
const error = new Error();
|
||||
error.name = data.name;
|
||||
error.message = data.message;
|
||||
error.stack = data.stack;
|
||||
this._extensionService._onExtensionRuntimeError(extensionId, error);
|
||||
console.error(`[${extensionId}]${error.message}`);
|
||||
console.error(error.stack);
|
||||
}
|
||||
$onExtensionActivationFailed(extensionId: string): void {
|
||||
}
|
||||
$addMessage(extensionId: string, severity: Severity, message: string): void {
|
||||
this._extensionService._addMessage(extensionId, severity, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ export class HeapService implements IHeapService {
|
||||
|
||||
trackRecursive<T>(p: TPromise<T>): TPromise<T>;
|
||||
trackRecursive<T>(obj: T): T;
|
||||
trackRecursive<T>(obj: any): any {
|
||||
trackRecursive(obj: any): any {
|
||||
if (TPromise.is(obj)) {
|
||||
return obj.then(result => this.trackRecursive(result));
|
||||
} else {
|
||||
|
||||
@@ -21,6 +21,7 @@ import { LanguageConfiguration } from 'vs/editor/common/modes/languageConfigurat
|
||||
import { IHeapService } from './mainThreadHeapService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { toLanguageSelector } from 'vs/workbench/api/node/extHostTypeConverters';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadLanguageFeatures)
|
||||
export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesShape {
|
||||
@@ -58,7 +59,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- outline
|
||||
|
||||
$registerOutlineSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.DocumentSymbolProviderRegistry.register(selector, <modes.DocumentSymbolProvider>{
|
||||
this._registrations[handle] = modes.DocumentSymbolProviderRegistry.register(toLanguageSelector(selector), <modes.DocumentSymbolProvider>{
|
||||
provideDocumentSymbols: (model: IReadOnlyModel, token: CancellationToken): Thenable<modes.SymbolInformation[]> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideDocumentSymbols(handle, model.uri));
|
||||
}
|
||||
@@ -85,7 +86,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
provider.onDidChange = emitter.event;
|
||||
}
|
||||
|
||||
this._registrations[handle] = modes.CodeLensProviderRegistry.register(selector, provider);
|
||||
this._registrations[handle] = modes.CodeLensProviderRegistry.register(toLanguageSelector(selector), provider);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- declaration
|
||||
|
||||
$registerDeclaractionSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.DefinitionProviderRegistry.register(selector, <modes.DefinitionProvider>{
|
||||
this._registrations[handle] = modes.DefinitionProviderRegistry.register(toLanguageSelector(selector), <modes.DefinitionProvider>{
|
||||
provideDefinition: (model, position, token): Thenable<modes.Definition> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideDefinition(handle, model.uri, position));
|
||||
}
|
||||
@@ -109,7 +110,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
}
|
||||
|
||||
$registerImplementationSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.ImplementationProviderRegistry.register(selector, <modes.ImplementationProvider>{
|
||||
this._registrations[handle] = modes.ImplementationProviderRegistry.register(toLanguageSelector(selector), <modes.ImplementationProvider>{
|
||||
provideImplementation: (model, position, token): Thenable<modes.Definition> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideImplementation(handle, model.uri, position));
|
||||
}
|
||||
@@ -118,7 +119,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
}
|
||||
|
||||
$registerTypeDefinitionSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.TypeDefinitionProviderRegistry.register(selector, <modes.TypeDefinitionProvider>{
|
||||
this._registrations[handle] = modes.TypeDefinitionProviderRegistry.register(toLanguageSelector(selector), <modes.TypeDefinitionProvider>{
|
||||
provideTypeDefinition: (model, position, token): Thenable<modes.Definition> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideTypeDefinition(handle, model.uri, position));
|
||||
}
|
||||
@@ -129,7 +130,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- extra info
|
||||
|
||||
$registerHoverProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.HoverProviderRegistry.register(selector, <modes.HoverProvider>{
|
||||
this._registrations[handle] = modes.HoverProviderRegistry.register(toLanguageSelector(selector), <modes.HoverProvider>{
|
||||
provideHover: (model: IReadOnlyModel, position: EditorPosition, token: CancellationToken): Thenable<modes.Hover> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideHover(handle, model.uri, position));
|
||||
}
|
||||
@@ -140,7 +141,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- occurrences
|
||||
|
||||
$registerDocumentHighlightProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.DocumentHighlightProviderRegistry.register(selector, <modes.DocumentHighlightProvider>{
|
||||
this._registrations[handle] = modes.DocumentHighlightProviderRegistry.register(toLanguageSelector(selector), <modes.DocumentHighlightProvider>{
|
||||
provideDocumentHighlights: (model: IReadOnlyModel, position: EditorPosition, token: CancellationToken): Thenable<modes.DocumentHighlight[]> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideDocumentHighlights(handle, model.uri, position));
|
||||
}
|
||||
@@ -151,7 +152,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- references
|
||||
|
||||
$registerReferenceSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.ReferenceProviderRegistry.register(selector, <modes.ReferenceProvider>{
|
||||
this._registrations[handle] = modes.ReferenceProviderRegistry.register(toLanguageSelector(selector), <modes.ReferenceProvider>{
|
||||
provideReferences: (model: IReadOnlyModel, position: EditorPosition, context: modes.ReferenceContext, token: CancellationToken): Thenable<modes.Location[]> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideReferences(handle, model.uri, position, context));
|
||||
}
|
||||
@@ -162,8 +163,8 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- quick fix
|
||||
|
||||
$registerQuickFixSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.CodeActionProviderRegistry.register(selector, <modes.CodeActionProvider>{
|
||||
provideCodeActions: (model: IReadOnlyModel, range: EditorRange, token: CancellationToken): Thenable<modes.Command[]> => {
|
||||
this._registrations[handle] = modes.CodeActionProviderRegistry.register(toLanguageSelector(selector), <modes.CodeActionProvider>{
|
||||
provideCodeActions: (model: IReadOnlyModel, range: EditorRange, token: CancellationToken): Thenable<modes.CodeAction[]> => {
|
||||
return this._heapService.trackRecursive(wireCancellationToken(token, this._proxy.$provideCodeActions(handle, model.uri, range)));
|
||||
}
|
||||
});
|
||||
@@ -173,7 +174,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- formatting
|
||||
|
||||
$registerDocumentFormattingSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.DocumentFormattingEditProviderRegistry.register(selector, <modes.DocumentFormattingEditProvider>{
|
||||
this._registrations[handle] = modes.DocumentFormattingEditProviderRegistry.register(toLanguageSelector(selector), <modes.DocumentFormattingEditProvider>{
|
||||
provideDocumentFormattingEdits: (model: IReadOnlyModel, options: modes.FormattingOptions, token: CancellationToken): Thenable<ISingleEditOperation[]> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideDocumentFormattingEdits(handle, model.uri, options));
|
||||
}
|
||||
@@ -182,7 +183,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
}
|
||||
|
||||
$registerRangeFormattingSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.DocumentRangeFormattingEditProviderRegistry.register(selector, <modes.DocumentRangeFormattingEditProvider>{
|
||||
this._registrations[handle] = modes.DocumentRangeFormattingEditProviderRegistry.register(toLanguageSelector(selector), <modes.DocumentRangeFormattingEditProvider>{
|
||||
provideDocumentRangeFormattingEdits: (model: IReadOnlyModel, range: EditorRange, options: modes.FormattingOptions, token: CancellationToken): Thenable<ISingleEditOperation[]> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideDocumentRangeFormattingEdits(handle, model.uri, range, options));
|
||||
}
|
||||
@@ -191,7 +192,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
}
|
||||
|
||||
$registerOnTypeFormattingSupport(handle: number, selector: vscode.DocumentSelector, autoFormatTriggerCharacters: string[]): TPromise<any> {
|
||||
this._registrations[handle] = modes.OnTypeFormattingEditProviderRegistry.register(selector, <modes.OnTypeFormattingEditProvider>{
|
||||
this._registrations[handle] = modes.OnTypeFormattingEditProviderRegistry.register(toLanguageSelector(selector), <modes.OnTypeFormattingEditProvider>{
|
||||
|
||||
autoFormatTriggerCharacters,
|
||||
|
||||
@@ -227,7 +228,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- rename
|
||||
|
||||
$registerRenameSupport(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.RenameProviderRegistry.register(selector, <modes.RenameProvider>{
|
||||
this._registrations[handle] = modes.RenameProviderRegistry.register(toLanguageSelector(selector), <modes.RenameProvider>{
|
||||
provideRenameEdits: (model: IReadOnlyModel, position: EditorPosition, newName: string, token: CancellationToken): Thenable<modes.WorkspaceEdit> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideRenameEdits(handle, model.uri, position, newName));
|
||||
}
|
||||
@@ -239,7 +240,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
|
||||
$registerSuggestSupport(handle: number, selector: vscode.DocumentSelector, triggerCharacters: string[], supportsResolveDetails: boolean): TPromise<any> {
|
||||
|
||||
this._registrations[handle] = modes.SuggestRegistry.register(selector, <modes.ISuggestSupport>{
|
||||
this._registrations[handle] = modes.SuggestRegistry.register(toLanguageSelector(selector), <modes.ISuggestSupport>{
|
||||
triggerCharacters,
|
||||
provideCompletionItems: (model: IReadOnlyModel, position: EditorPosition, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> => {
|
||||
return wireCancellationToken(token, this._proxy.$provideCompletionItems(handle, model.uri, position, context)).then(result => {
|
||||
@@ -263,7 +264,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- parameter hints
|
||||
|
||||
$registerSignatureHelpProvider(handle: number, selector: vscode.DocumentSelector, triggerCharacter: string[]): TPromise<any> {
|
||||
this._registrations[handle] = modes.SignatureHelpProviderRegistry.register(selector, <modes.SignatureHelpProvider>{
|
||||
this._registrations[handle] = modes.SignatureHelpProviderRegistry.register(toLanguageSelector(selector), <modes.SignatureHelpProvider>{
|
||||
|
||||
signatureHelpTriggerCharacters: triggerCharacter,
|
||||
|
||||
@@ -278,7 +279,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
// --- links
|
||||
|
||||
$registerDocumentLinkProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
this._registrations[handle] = modes.LinkProviderRegistry.register(selector, <modes.LinkProvider>{
|
||||
this._registrations[handle] = modes.LinkProviderRegistry.register(toLanguageSelector(selector), <modes.LinkProvider>{
|
||||
provideLinks: (model, token) => {
|
||||
return this._heapService.trackRecursive(wireCancellationToken(token, this._proxy.$provideDocumentLinks(handle, model.uri)));
|
||||
},
|
||||
@@ -293,7 +294,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
|
||||
|
||||
$registerDocumentColorProvider(handle: number, selector: vscode.DocumentSelector): TPromise<any> {
|
||||
const proxy = this._proxy;
|
||||
this._registrations[handle] = modes.ColorProviderRegistry.register(selector, <modes.DocumentColorProvider>{
|
||||
this._registrations[handle] = modes.ColorProviderRegistry.register(toLanguageSelector(selector), <modes.DocumentColorProvider>{
|
||||
provideDocumentColors: (model, token) => {
|
||||
return wireCancellationToken(token, proxy.$provideDocumentColors(handle, model.uri))
|
||||
.then(documentColors => {
|
||||
|
||||
@@ -11,14 +11,13 @@ import { Action } from 'vs/base/common/actions';
|
||||
import { TPromise as Promise } from 'vs/base/common/winjs.base';
|
||||
import { MainThreadMessageServiceShape, MainContext, IExtHostContext, MainThreadMessageOptions } from '../node/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { IExtensionService, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadMessageService)
|
||||
export class MainThreadMessageService implements MainThreadMessageServiceShape {
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IExtensionService private readonly _extensionService: IExtensionService,
|
||||
@IMessageService private readonly _messageService: IMessageService,
|
||||
@IChoiceService private readonly _choiceService: IChoiceService
|
||||
) {
|
||||
|
||||
@@ -33,12 +33,16 @@ export class MainThreadProgress implements MainThreadProgressShape {
|
||||
}
|
||||
|
||||
$progressReport(handle: number, message: IProgressStep): void {
|
||||
this._progress.get(handle).progress.report(message);
|
||||
if (this._progress.has(handle)) {
|
||||
this._progress.get(handle).progress.report(message);
|
||||
}
|
||||
}
|
||||
|
||||
$progressEnd(handle: number): void {
|
||||
this._progress.get(handle).resolve();
|
||||
this._progress.delete(handle);
|
||||
if (this._progress.has(handle)) {
|
||||
this._progress.get(handle).resolve();
|
||||
this._progress.delete(handle);
|
||||
}
|
||||
}
|
||||
|
||||
private _createTask(handle: number) {
|
||||
|
||||
@@ -10,31 +10,24 @@ import URI from 'vs/base/common/uri';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations, ISCMResourceCollection, ISCMResourceSplice } from 'vs/workbench/services/scm/common/scm';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { ISCMService, ISCMRepository, ISCMProvider, ISCMResource, ISCMResourceGroup, ISCMResourceDecorations } from 'vs/workbench/services/scm/common/scm';
|
||||
import { ExtHostContext, MainThreadSCMShape, ExtHostSCMShape, SCMProviderFeatures, SCMRawResourceSplices, SCMGroupFeatures, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { Command } from 'vs/editor/common/modes';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
|
||||
class MainThreadSCMResourceCollection implements ISCMResourceCollection {
|
||||
|
||||
readonly resources: ISCMResource[] = [];
|
||||
|
||||
private _onDidSplice = new Emitter<ISCMResourceSplice>();
|
||||
readonly onDidSplice = this._onDidSplice.event;
|
||||
|
||||
splice(start: number, deleteCount: number, resources: ISCMResource[]) {
|
||||
this.resources.splice(start, deleteCount, ...resources);
|
||||
this._onDidSplice.fire({ start, deleteCount, resources });
|
||||
}
|
||||
}
|
||||
import { ISplice, Sequence } from 'vs/base/common/sequence';
|
||||
|
||||
class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
|
||||
readonly resourceCollection = new MainThreadSCMResourceCollection();
|
||||
readonly elements: ISCMResource[] = [];
|
||||
|
||||
private _onDidSplice = new Emitter<ISplice<ISCMResource>>();
|
||||
readonly onDidSplice = this._onDidSplice.event;
|
||||
|
||||
get hideWhenEmpty(): boolean { return this.features.hideWhenEmpty; }
|
||||
|
||||
private _onDidChange = new Emitter<void>();
|
||||
get onDidChange(): Event<void> { return this._onDidChange.event; }
|
||||
|
||||
constructor(
|
||||
private sourceControlHandle: number,
|
||||
private handle: number,
|
||||
@@ -51,6 +44,21 @@ class MainThreadSCMResourceGroup implements ISCMResourceGroup {
|
||||
groupHandle: this.handle
|
||||
};
|
||||
}
|
||||
|
||||
splice(start: number, deleteCount: number, toInsert: ISCMResource[]) {
|
||||
this.elements.splice(start, deleteCount, ...toInsert);
|
||||
this._onDidSplice.fire({ start, deleteCount, toInsert });
|
||||
}
|
||||
|
||||
$updateGroup(features: SCMGroupFeatures): void {
|
||||
this.features = assign(this.features, features);
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
|
||||
$updateGroupLabel(label: string): void {
|
||||
this.label = label;
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
}
|
||||
|
||||
class MainThreadSCMResource implements ISCMResource {
|
||||
@@ -85,13 +93,18 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
private _id = `scm${MainThreadSCMProvider.ID_HANDLE++}`;
|
||||
get id(): string { return this._id; }
|
||||
|
||||
private _groups: MainThreadSCMResourceGroup[] = [];
|
||||
readonly groups = new Sequence<MainThreadSCMResourceGroup>();
|
||||
private _groupsByHandle: { [handle: number]: MainThreadSCMResourceGroup; } = Object.create(null);
|
||||
|
||||
get resources(): ISCMResourceGroup[] {
|
||||
return this._groups
|
||||
.filter(g => g.resourceCollection.resources.length > 0 || !g.features.hideWhenEmpty);
|
||||
}
|
||||
// get groups(): ISequence<ISCMResourceGroup> {
|
||||
// return {
|
||||
// elements: this._groups,
|
||||
// onDidSplice: this._onDidSplice.event
|
||||
// };
|
||||
|
||||
// // return this._groups
|
||||
// // .filter(g => g.resources.elements.length > 0 || !g.features.hideWhenEmpty);
|
||||
// }
|
||||
|
||||
private _onDidChangeResources = new Emitter<void>();
|
||||
get onDidChangeResources(): Event<void> { return this._onDidChangeResources.event; }
|
||||
@@ -120,8 +133,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
private _contextValue: string,
|
||||
private _label: string,
|
||||
private _rootUri: URI | undefined,
|
||||
@ISCMService scmService: ISCMService,
|
||||
@ICommandService private commandService: ICommandService
|
||||
@ISCMService scmService: ISCMService
|
||||
) { }
|
||||
|
||||
$updateSourceControl(features: SCMProviderFeatures): void {
|
||||
@@ -143,8 +155,8 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
id
|
||||
);
|
||||
|
||||
this._groups.push(group);
|
||||
this._groupsByHandle[handle] = group;
|
||||
this.groups.splice(this.groups.elements.length, 0, [group]);
|
||||
}
|
||||
|
||||
$updateGroup(handle: number, features: SCMGroupFeatures): void {
|
||||
@@ -154,8 +166,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
group.features = assign(group.features, features);
|
||||
this._onDidChange.fire();
|
||||
group.$updateGroup(features);
|
||||
}
|
||||
|
||||
$updateGroupLabel(handle: number, label: string): void {
|
||||
@@ -165,8 +176,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
group.label = label;
|
||||
this._onDidChange.fire();
|
||||
group.$updateGroupLabel(label);
|
||||
}
|
||||
|
||||
$spliceGroupResourceStates(splices: SCMRawResourceSplices[]): void {
|
||||
@@ -208,7 +218,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
);
|
||||
});
|
||||
|
||||
group.resourceCollection.splice(start, deleteCount, resources);
|
||||
group.splice(start, deleteCount, resources);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +233,7 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
}
|
||||
|
||||
delete this._groupsByHandle[handle];
|
||||
this._groups.splice(this._groups.indexOf(group), 1);
|
||||
this.groups.splice(this.groups.elements.indexOf(group), 1);
|
||||
}
|
||||
|
||||
getOriginalResource(uri: URI): TPromise<URI> {
|
||||
@@ -256,9 +266,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@ISCMService private scmService: ISCMService,
|
||||
@ICommandService private commandService: ICommandService
|
||||
@ISCMService private scmService: ISCMService
|
||||
) {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostSCM);
|
||||
}
|
||||
@@ -276,7 +284,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
||||
}
|
||||
|
||||
$registerSourceControl(handle: number, id: string, label: string, rootUri: string | undefined): void {
|
||||
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri && URI.parse(rootUri), this.scmService, this.commandService);
|
||||
const provider = new MainThreadSCMProvider(this._proxy, handle, id, label, rootUri && URI.parse(rootUri), this.scmService);
|
||||
const repository = this.scmService.registerSCMProvider(provider);
|
||||
this._repositories[handle] = repository;
|
||||
|
||||
@@ -373,4 +381,14 @@ export class MainThreadSCM implements MainThreadSCMShape {
|
||||
|
||||
repository.input.value = value;
|
||||
}
|
||||
|
||||
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void {
|
||||
const repository = this._repositories[sourceControlHandle];
|
||||
|
||||
if (!repository) {
|
||||
return;
|
||||
}
|
||||
|
||||
repository.input.placeholder = placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,31 +8,25 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { sequence } from 'vs/base/common/async';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ISaveParticipant, ITextFileEditorModel, SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IModel, ICommonCodeEditor, ISingleEditOperation, IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { IModel, ISingleEditOperation, IIdentifiedSingleEditOperation } from 'vs/editor/common/editorCommon';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { trimTrailingWhitespace } from 'vs/editor/common/commands/trimTrailingWhitespaceCommand';
|
||||
import { getDocumentFormattingEdits } from 'vs/editor/contrib/format/common/format';
|
||||
import { EditOperationsCommand } from 'vs/editor/contrib/format/common/formatCommand';
|
||||
import { getDocumentFormattingEdits } from 'vs/editor/contrib/format/format';
|
||||
import { EditOperationsCommand } from 'vs/editor/contrib/format/formatCommand';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
export interface INamedSaveParticpant extends ISaveParticipant {
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
class TrimWhitespaceParticipant implements INamedSaveParticpant {
|
||||
|
||||
readonly name = 'TrimWhitespaceParticipant';
|
||||
class TrimWhitespaceParticipant implements ISaveParticipant {
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@@ -70,8 +64,8 @@ class TrimWhitespaceParticipant implements INamedSaveParticpant {
|
||||
}
|
||||
}
|
||||
|
||||
function findEditor(model: IModel, codeEditorService: ICodeEditorService): ICommonCodeEditor {
|
||||
let candidate: ICommonCodeEditor = null;
|
||||
function findEditor(model: IModel, codeEditorService: ICodeEditorService): ICodeEditor {
|
||||
let candidate: ICodeEditor = null;
|
||||
|
||||
if (model.isAttachedToEditor()) {
|
||||
for (const editor of codeEditorService.listCodeEditors()) {
|
||||
@@ -88,9 +82,7 @@ function findEditor(model: IModel, codeEditorService: ICodeEditorService): IComm
|
||||
return candidate;
|
||||
}
|
||||
|
||||
export class FinalNewLineParticipant implements INamedSaveParticpant {
|
||||
|
||||
readonly name = 'FinalNewLineParticipant';
|
||||
export class FinalNewLineParticipant implements ISaveParticipant {
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@@ -128,9 +120,7 @@ export class FinalNewLineParticipant implements INamedSaveParticpant {
|
||||
}
|
||||
}
|
||||
|
||||
export class TrimFinalNewLinesParticipant implements INamedSaveParticpant {
|
||||
|
||||
readonly name = 'TrimFinalNewLinesParticipant';
|
||||
export class TrimFinalNewLinesParticipant implements ISaveParticipant {
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@@ -175,9 +165,7 @@ export class TrimFinalNewLinesParticipant implements INamedSaveParticpant {
|
||||
}
|
||||
}
|
||||
|
||||
class FormatOnSaveParticipant implements INamedSaveParticpant {
|
||||
|
||||
readonly name = 'FormatOnSaveParticipant';
|
||||
class FormatOnSaveParticipant implements ISaveParticipant {
|
||||
|
||||
constructor(
|
||||
@ICodeEditorService private _editorService: ICodeEditorService,
|
||||
@@ -216,7 +204,7 @@ class FormatOnSaveParticipant implements INamedSaveParticpant {
|
||||
});
|
||||
}
|
||||
|
||||
private _editsWithEditor(editor: ICommonCodeEditor, edits: ISingleEditOperation[]): void {
|
||||
private _editsWithEditor(editor: ICodeEditor, edits: ISingleEditOperation[]): void {
|
||||
EditOperationsCommand.execute(editor, edits);
|
||||
}
|
||||
|
||||
@@ -245,12 +233,10 @@ class FormatOnSaveParticipant implements INamedSaveParticpant {
|
||||
}
|
||||
}
|
||||
|
||||
class ExtHostSaveParticipant implements INamedSaveParticpant {
|
||||
class ExtHostSaveParticipant implements ISaveParticipant {
|
||||
|
||||
private _proxy: ExtHostDocumentSaveParticipantShape;
|
||||
|
||||
readonly name = 'ExtHostSaveParticipant';
|
||||
|
||||
constructor(extHostContext: IExtHostContext) {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostDocumentSaveParticipant);
|
||||
}
|
||||
@@ -274,11 +260,10 @@ class ExtHostSaveParticipant implements INamedSaveParticpant {
|
||||
@extHostCustomer
|
||||
export class SaveParticipant implements ISaveParticipant {
|
||||
|
||||
private _saveParticipants: INamedSaveParticpant[];
|
||||
private _saveParticipants: ISaveParticipant[];
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@ITelemetryService private _telemetryService: ITelemetryService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@@ -302,38 +287,10 @@ export class SaveParticipant implements ISaveParticipant {
|
||||
}
|
||||
|
||||
participate(model: ITextFileEditorModel, env: { reason: SaveReason }): TPromise<void> {
|
||||
|
||||
const stats: { [name: string]: number } = Object.create(null);
|
||||
|
||||
const promiseFactory = this._saveParticipants.map(p => () => {
|
||||
|
||||
const { name } = p;
|
||||
const t1 = Date.now();
|
||||
|
||||
return TPromise.as(p.participate(model, env)).then(() => {
|
||||
stats[`Success-${name}`] = Date.now() - t1;
|
||||
}, err => {
|
||||
stats[`Failure-${name}`] = Date.now() - t1;
|
||||
// console.error(err);
|
||||
});
|
||||
return TPromise.as(p.participate(model, env));
|
||||
});
|
||||
|
||||
return sequence(promiseFactory).then(() => {
|
||||
/* __GDPR__
|
||||
"saveParticipantStats" : {
|
||||
"${wildcard}": [
|
||||
{
|
||||
"${prefix}": "Success-",
|
||||
"${classification}": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
},
|
||||
{
|
||||
"${prefix}": "Failure-",
|
||||
"${classification}": { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
}
|
||||
]
|
||||
}
|
||||
*/
|
||||
this._telemetryService.publicLog('saveParticipantStats', stats);
|
||||
});
|
||||
return sequence(promiseFactory).then(() => { });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ export class MainThreadTask implements MainThreadTaskShape {
|
||||
}
|
||||
});
|
||||
this._activeHandles[handle] = true;
|
||||
return TPromise.as<void>(undefined);
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
|
||||
public $unregisterTaskProvider(handle: number): TPromise<any> {
|
||||
this._taskService.unregisterTaskProvider(handle);
|
||||
delete this._activeHandles[handle];
|
||||
return TPromise.as<void>(undefined);
|
||||
return TPromise.wrap<void>(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostC
|
||||
@extHostNamedCustomer(MainContext.MainThreadTelemetry)
|
||||
export class MainThreadTelemetry implements MainThreadTelemetryShape {
|
||||
|
||||
private static _name = 'pluginHostTelemetry';
|
||||
private static readonly _name = 'pluginHostTelemetry';
|
||||
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
|
||||
@@ -10,8 +10,9 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ExtHostContext, MainThreadTreeViewsShape, ExtHostTreeViewsShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { IMessageService, Severity } from 'vs/platform/message/common/message';
|
||||
import { ViewsRegistry } from 'vs/workbench/browser/parts/views/viewsRegistry';
|
||||
import { ITreeViewDataProvider, ITreeItem, TreeItemCollapsibleState } from 'vs/workbench/common/views';
|
||||
import { ITreeViewDataProvider, ITreeItem } from 'vs/workbench/common/views';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadTreeViews)
|
||||
export class MainThreadTreeViews extends Disposable implements MainThreadTreeViewsShape {
|
||||
@@ -30,10 +31,10 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
|
||||
ViewsRegistry.registerTreeViewDataProvider(treeViewId, this._register(new TreeViewDataProvider(treeViewId, this._proxy, this.messageService)));
|
||||
}
|
||||
|
||||
$refresh(treeViewId: string, treeItemHandles: number[]): void {
|
||||
$refresh(treeViewId: string, itemsToRefresh: { [treeItemHandle: string]: ITreeItem }): void {
|
||||
const treeViewDataProvider: TreeViewDataProvider = <TreeViewDataProvider>ViewsRegistry.getTreeViewDataProvider(treeViewId);
|
||||
if (treeViewDataProvider) {
|
||||
treeViewDataProvider.refresh(treeItemHandles);
|
||||
treeViewDataProvider.refresh(itemsToRefresh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
|
||||
}
|
||||
}
|
||||
|
||||
type TreeItemHandle = number;
|
||||
type TreeItemHandle = string;
|
||||
|
||||
class TreeViewDataProvider implements ITreeViewDataProvider {
|
||||
|
||||
@@ -53,7 +54,6 @@ class TreeViewDataProvider implements ITreeViewDataProvider {
|
||||
private _onDispose: Emitter<void> = new Emitter<void>();
|
||||
readonly onDispose: Event<void> = this._onDispose.event;
|
||||
|
||||
private childrenMap: Map<TreeItemHandle, TreeItemHandle[]> = new Map<TreeItemHandle, TreeItemHandle[]>();
|
||||
private itemsMap: Map<TreeItemHandle, ITreeItem> = new Map<TreeItemHandle, ITreeItem>();
|
||||
|
||||
constructor(private treeViewId: string,
|
||||
@@ -65,8 +65,7 @@ class TreeViewDataProvider implements ITreeViewDataProvider {
|
||||
getElements(): TPromise<ITreeItem[]> {
|
||||
return this._proxy.$getElements(this.treeViewId)
|
||||
.then(elements => {
|
||||
this.postGetElements(null, elements);
|
||||
return elements;
|
||||
return this.postGetElements(elements);
|
||||
}, err => {
|
||||
this.messageService.show(Severity.Error, err);
|
||||
return null;
|
||||
@@ -79,20 +78,34 @@ class TreeViewDataProvider implements ITreeViewDataProvider {
|
||||
}
|
||||
return this._proxy.$getChildren(this.treeViewId, treeItem.handle)
|
||||
.then(children => {
|
||||
this.postGetElements(treeItem.handle, children);
|
||||
return children;
|
||||
return this.postGetElements(children);
|
||||
}, err => {
|
||||
this.messageService.show(Severity.Error, err);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
refresh(treeItemHandles: number[]) {
|
||||
if (treeItemHandles && treeItemHandles.length) {
|
||||
let treeItems = treeItemHandles.map(treeItemHandle => this.itemsMap.get(treeItemHandle))
|
||||
.filter(treeItem => !!treeItem);
|
||||
if (treeItems.length) {
|
||||
this._onDidChange.fire(treeItems);
|
||||
refresh(itemsToRefreshByHandle: { [treeItemHandle: string]: ITreeItem }) {
|
||||
if (itemsToRefreshByHandle) {
|
||||
const itemsToRefresh: ITreeItem[] = [];
|
||||
for (const treeItemHandle of Object.keys(itemsToRefreshByHandle)) {
|
||||
const currentTreeItem = this.itemsMap.get(treeItemHandle);
|
||||
if (currentTreeItem) { // Refresh only if the item exists
|
||||
const treeItem = itemsToRefreshByHandle[treeItemHandle];
|
||||
// Update the current item with refreshed item
|
||||
this.updateTreeItem(currentTreeItem, treeItem);
|
||||
if (treeItemHandle === treeItem.handle) {
|
||||
itemsToRefresh.push(currentTreeItem);
|
||||
} else {
|
||||
// Update maps when handle is changed and refresh parent
|
||||
this.itemsMap.delete(treeItemHandle);
|
||||
this.itemsMap.set(currentTreeItem.handle, currentTreeItem);
|
||||
itemsToRefresh.push(this.itemsMap.get(treeItem.parentHandle));
|
||||
}
|
||||
}
|
||||
if (itemsToRefresh.length) {
|
||||
this._onDidChange.fire(itemsToRefresh);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this._onDidChange.fire();
|
||||
@@ -103,43 +116,28 @@ class TreeViewDataProvider implements ITreeViewDataProvider {
|
||||
this._onDispose.fire();
|
||||
}
|
||||
|
||||
private clearChildren(treeItemHandle: TreeItemHandle): void {
|
||||
const children = this.childrenMap.get(treeItemHandle);
|
||||
if (children) {
|
||||
for (const child of children) {
|
||||
this.clearChildren(child);
|
||||
this.itemsMap.delete(child);
|
||||
}
|
||||
this.childrenMap.delete(treeItemHandle);
|
||||
}
|
||||
}
|
||||
|
||||
private postGetElements(parent: TreeItemHandle, children: ITreeItem[]) {
|
||||
this.setElements(parent, children);
|
||||
}
|
||||
|
||||
private setElements(parent: TreeItemHandle, children: ITreeItem[]) {
|
||||
if (children && children.length) {
|
||||
for (const child of children) {
|
||||
this.itemsMap.set(child.handle, child);
|
||||
if (child.children && child.children.length) {
|
||||
this.setElements(child.handle, child.children);
|
||||
private postGetElements(elements: ITreeItem[]): ITreeItem[] {
|
||||
const result = [];
|
||||
if (elements) {
|
||||
for (const element of elements) {
|
||||
const currentTreeItem = this.itemsMap.get(element.handle);
|
||||
if (currentTreeItem) {
|
||||
// Update the current item with new item
|
||||
this.updateTreeItem(currentTreeItem, element);
|
||||
} else {
|
||||
this.itemsMap.set(element.handle, element);
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
this.childrenMap.set(parent, children.map(child => child.handle));
|
||||
// Always use the existing items
|
||||
result.push(this.itemsMap.get(element.handle));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private populateElementsToExpand(elements: ITreeItem[], toExpand: ITreeItem[]) {
|
||||
for (const element of elements) {
|
||||
if (element.collapsibleState === TreeItemCollapsibleState.Expanded) {
|
||||
toExpand.push(element);
|
||||
if (element.children && element.children.length) {
|
||||
this.populateElementsToExpand(element.children, toExpand);
|
||||
}
|
||||
}
|
||||
private updateTreeItem(current: ITreeItem, treeItem: ITreeItem): void {
|
||||
treeItem.children = treeItem.children ? treeItem.children : null;
|
||||
if (current) {
|
||||
assign(current, treeItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,9 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { MainThreadWorkspaceShape, ExtHostWorkspaceShape, ExtHostContext, MainContext, IExtHostContext } from '../node/extHost.protocol';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IRelativePattern } from 'vs/base/common/glob';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadWorkspace)
|
||||
export class MainThreadWorkspace implements MainThreadWorkspaceShape {
|
||||
@@ -30,9 +27,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
|
||||
@ISearchService private readonly _searchService: ISearchService,
|
||||
@IWorkspaceContextService private readonly _contextService: IWorkspaceContextService,
|
||||
@ITextFileService private readonly _textFileService: ITextFileService,
|
||||
@IConfigurationService private _configurationService: IConfigurationService,
|
||||
@IFileService private readonly _fileService: IFileService,
|
||||
@IWorkspaceEditingService private _workspaceEditingService: IWorkspaceEditingService
|
||||
@IConfigurationService private _configurationService: IConfigurationService
|
||||
) {
|
||||
this._proxy = extHostContext.get(ExtHostContext.ExtHostWorkspace);
|
||||
this._contextService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspace, this, this._toDispose);
|
||||
@@ -56,26 +51,30 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
|
||||
|
||||
// --- search ---
|
||||
|
||||
$startSearch(include: string | IRelativePattern, exclude: string | IRelativePattern, maxResults: number, requestId: number): Thenable<URI[]> {
|
||||
$startSearch(includePattern: string, includeFolder: string, excludePattern: string, maxResults: number, requestId: number): Thenable<URI[]> {
|
||||
const workspace = this._contextService.getWorkspace();
|
||||
if (!workspace.folders.length) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let folderQueries: IFolderQuery[];
|
||||
if (typeof include === 'string' || !include) {
|
||||
folderQueries = workspace.folders.map(folder => ({ folder: folder.uri })); // absolute pattern: search across all folders
|
||||
if (typeof includeFolder === 'string') {
|
||||
folderQueries = [{ folder: URI.file(includeFolder) }]; // if base provided, only search in that folder
|
||||
} else {
|
||||
folderQueries = [{ folder: URI.file(include.base) }]; // relative pattern: search only in base folder
|
||||
folderQueries = workspace.folders.map(folder => ({ folder: folder.uri })); // absolute pattern: search across all folders
|
||||
}
|
||||
|
||||
if (!folderQueries) {
|
||||
return undefined; // invalid query parameters
|
||||
}
|
||||
|
||||
const useRipgrep = folderQueries.every(folderQuery => {
|
||||
const folderConfig = this._configurationService.getConfiguration<ISearchConfiguration>({ resource: folderQuery.folder });
|
||||
const folderConfig = this._configurationService.getValue<ISearchConfiguration>({ resource: folderQuery.folder });
|
||||
return folderConfig.search.useRipgrep;
|
||||
});
|
||||
|
||||
const ignoreSymlinks = folderQueries.every(folderQuery => {
|
||||
const folderConfig = this._configurationService.getConfiguration<ISearchConfiguration>({ resource: folderQuery.folder });
|
||||
const folderConfig = this._configurationService.getValue<ISearchConfiguration>({ resource: folderQuery.folder });
|
||||
return !folderConfig.search.followSymlinks;
|
||||
});
|
||||
|
||||
@@ -83,8 +82,8 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
|
||||
folderQueries,
|
||||
type: QueryType.File,
|
||||
maxResults,
|
||||
includePattern: { [typeof include === 'string' ? include : !!include ? include.pattern : undefined]: true },
|
||||
excludePattern: { [typeof exclude === 'string' ? exclude : !!exclude ? exclude.pattern : undefined]: true },
|
||||
includePattern: { [typeof includePattern === 'string' ? includePattern : undefined]: true },
|
||||
excludePattern: { [typeof excludePattern === 'string' ? excludePattern : undefined]: true },
|
||||
useRipgrep,
|
||||
ignoreSymlinks
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user