Merge remote-tracking branch 'upstream/master' into rebornix/commentenhancement

This commit is contained in:
Peng Lyu
2019-03-06 14:54:42 -08:00
551 changed files with 7614 additions and 5953 deletions

View File

@@ -377,7 +377,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution {
const viewDescriptor = <ICustomViewDescriptor>{
id: item.id,
name: item.name,
ctor: CustomTreeViewPanel,
ctorDescriptor: { ctor: CustomTreeViewPanel },
when: ContextKeyExpr.deserialize(item.when),
canToggleVisibility: true,
collapsed: this.showCollapsed(container),

View File

@@ -89,7 +89,7 @@ function _generateMarkdown(description: string | ICommandHandlerDescription): st
if (typeof description === 'string') {
return description;
} else {
let parts = [description.description];
const parts = [description.description];
parts.push('\n\n');
if (description.args) {
for (let arg of description.args) {

View File

@@ -26,9 +26,9 @@ import { IRange } from 'vs/editor/common/core/range';
import { Emitter, Event } from 'vs/base/common/event';
export class MainThreadDocumentCommentProvider implements modes.DocumentCommentProvider {
private _proxy: ExtHostCommentsShape;
private _handle: number;
private _features: CommentProviderFeatures;
private readonly _proxy: ExtHostCommentsShape;
private readonly _handle: number;
private readonly _features: CommentProviderFeatures;
get startDraftLabel(): string | undefined { return this._features.startDraftLabel; }
get deleteDraftLabel(): string | undefined { return this._features.deleteDraftLabel; }
get finishDraftLabel(): string | undefined { return this._features.finishDraftLabel; }
@@ -198,14 +198,14 @@ export class MainThreadCommentController {
return this._label;
}
private _threads: Map<number, MainThreadCommentThread> = new Map<number, MainThreadCommentThread>();
private readonly _threads: Map<number, MainThreadCommentThread> = new Map<number, MainThreadCommentThread>();
public activeCommentThread?: MainThreadCommentThread;
constructor(
private _proxy: ExtHostCommentsShape,
private _commentService: ICommentService,
private _handle: number,
private _id: string,
private _label: string
private readonly _proxy: ExtHostCommentsShape,
private readonly _commentService: ICommentService,
private readonly _handle: number,
private readonly _id: string,
private readonly _label: string
) { }
createCommentThread(commentThreadHandle: number, threadId: string, resource: UriComponents, range: IRange, comments: modes.Comment[], commands: modes.Command[], collapseState: modes.CommentThreadCollapsibleState): modes.CommentThread2 {
@@ -332,7 +332,7 @@ export class MainThreadCommentController {
export class MainThreadComments extends Disposable implements MainThreadCommentsShape {
private _disposables: IDisposable[];
private _activeCommentThreadDisposables: IDisposable[];
private _proxy: ExtHostCommentsShape;
private readonly _proxy: ExtHostCommentsShape;
private _documentProviders = new Map<number, IDisposable>();
private _workspaceProviders = new Map<number, IDisposable>();
private _handlers = new Map<number, string>();

View File

@@ -8,10 +8,9 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions, ConfigurationScope, getScopes } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { MainThreadConfigurationShape, MainContext, ExtHostContext, IExtHostContext, IWorkspaceConfigurationChangeEventData, IConfigurationInitData } from '../node/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { ConfigurationTarget, IConfigurationChangeEvent, IConfigurationModel } from 'vs/platform/configuration/common/configuration';
import { ConfigurationTarget, IConfigurationChangeEvent, IConfigurationModel, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
@extHostNamedCustomer(MainContext.MainThreadConfiguration)
@@ -22,7 +21,7 @@ export class MainThreadConfiguration implements MainThreadConfigurationShape {
constructor(
extHostContext: IExtHostContext,
@IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService,
@IWorkspaceConfigurationService private readonly configurationService: IWorkspaceConfigurationService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IEnvironmentService private readonly _environmentService: IEnvironmentService,
) {
const proxy = extHostContext.getProxy(ExtHostContext.ExtHostConfiguration);

View File

@@ -19,15 +19,15 @@ import { convertToVSCPaths, convertToDAPaths } from 'vs/workbench/contrib/debug/
@extHostNamedCustomer(MainContext.MainThreadDebugService)
export class MainThreadDebugService implements MainThreadDebugServiceShape, IDebugAdapterFactory {
private _proxy: ExtHostDebugServiceShape;
private readonly _proxy: ExtHostDebugServiceShape;
private _toDispose: IDisposable[];
private _breakpointEventsActive: boolean;
private _debugAdapters: Map<number, ExtensionHostDebugAdapter>;
private readonly _debugAdapters: Map<number, ExtensionHostDebugAdapter>;
private _debugAdaptersHandleCounter = 1;
private _debugConfigurationProviders: Map<number, IDebugConfigurationProvider>;
private _debugAdapterDescriptorFactories: Map<number, IDebugAdapterDescriptorFactory>;
private _debugAdapterTrackerFactories: Map<number, IDebugAdapterTrackerFactory>;
private _sessions: Set<DebugSessionUUID>;
private readonly _debugConfigurationProviders: Map<number, IDebugConfigurationProvider>;
private readonly _debugAdapterDescriptorFactories: Map<number, IDebugAdapterDescriptorFactory>;
private readonly _debugAdapterTrackerFactories: Map<number, IDebugAdapterTrackerFactory>;
private readonly _sessions: Set<DebugSessionUUID>;
constructor(
extHostContext: IExtHostContext,
@@ -343,7 +343,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
*/
class ExtensionHostDebugAdapter extends AbstractDebugAdapter {
constructor(private _ds: MainThreadDebugService, private _handle: number, private _proxy: ExtHostDebugServiceShape, private _session: IDebugSession) {
constructor(private readonly _ds: MainThreadDebugService, private _handle: number, private _proxy: ExtHostDebugServiceShape, private _session: IDebugSession) {
super();
}

View File

@@ -21,7 +21,7 @@ class DecorationRequestsQueue {
private _timer: any;
constructor(
private _proxy: ExtHostDecorationsShape
private readonly _proxy: ExtHostDecorationsShape
) {
//
}

View File

@@ -24,8 +24,8 @@ export class BoundModelReferenceCollection {
private _length = 0;
constructor(
private _maxAge: number = 1000 * 60 * 3,
private _maxLength: number = 1024 * 1024 * 80
private readonly _maxAge: number = 1000 * 60 * 3,
private readonly _maxLength: number = 1024 * 1024 * 80
) {
//
}
@@ -35,11 +35,11 @@ export class BoundModelReferenceCollection {
}
add(ref: IReference<ITextEditorModel>): void {
let length = ref.object.textEditorModel.getValueLength();
const length = ref.object.textEditorModel.getValueLength();
let handle: any;
let entry: { length: number, dispose(): void };
const dispose = () => {
let idx = this._data.indexOf(entry);
const idx = this._data.indexOf(entry);
if (idx >= 0) {
this._length -= length;
ref.dispose();
@@ -64,16 +64,16 @@ export class BoundModelReferenceCollection {
export class MainThreadDocuments implements MainThreadDocumentsShape {
private _modelService: IModelService;
private _textModelResolverService: ITextModelService;
private _textFileService: ITextFileService;
private _fileService: IFileService;
private _untitledEditorService: IUntitledEditorService;
private readonly _modelService: IModelService;
private readonly _textModelResolverService: ITextModelService;
private readonly _textFileService: ITextFileService;
private readonly _fileService: IFileService;
private readonly _untitledEditorService: IUntitledEditorService;
private _toDispose: IDisposable[];
private _modelToDisposeMap: { [modelUrl: string]: IDisposable; };
private _proxy: ExtHostDocumentsShape;
private _modelIsSynced: { [modelId: string]: boolean; };
private readonly _proxy: ExtHostDocumentsShape;
private readonly _modelIsSynced: { [modelId: string]: boolean; };
private _modelReferenceCollection = new BoundModelReferenceCollection();
constructor(
@@ -139,7 +139,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
// don't synchronize too large models
return;
}
let modelUrl = model.uri;
const modelUrl = model.uri;
this._modelIsSynced[modelUrl.toString()] = true;
this._modelToDisposeMap[modelUrl.toString()] = model.onDidChangeContent((e) => {
this._proxy.$acceptModelChanged(modelUrl, e, this._textFileService.isDirty(modelUrl));
@@ -148,7 +148,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
private _onModelModeChanged(event: { model: ITextModel; oldModeId: string; }): void {
let { model, oldModeId } = event;
let modelUrl = model.uri;
const modelUrl = model.uri;
if (!this._modelIsSynced[modelUrl.toString()]) {
return;
}
@@ -156,7 +156,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
}
private _onModelRemoved(modelUrl: URI): void {
let strModelUrl = modelUrl.toString();
const strModelUrl = modelUrl.toString();
if (!this._modelIsSynced[strModelUrl]) {
return;
}
@@ -214,7 +214,7 @@ export class MainThreadDocuments implements MainThreadDocumentsShape {
}
private _handleUntitledScheme(uri: URI): Promise<boolean> {
let asFileUri = uri.with({ scheme: Schemas.file });
const asFileUri = uri.with({ scheme: Schemas.file });
return this._fileService.resolveFile(asFileUri).then(stats => {
// don't create a new file ontop of an existing file
return Promise.reject(new Error('file already exists on disk'));

View File

@@ -283,7 +283,7 @@ class MainThreadDocumentAndEditorStateComputer {
}
private _getActiveEditorFromPanel(): IEditor | undefined {
let panel = this._panelService.getActivePanel();
const panel = this._panelService.getActivePanel();
if (panel instanceof BaseTextEditor && isCodeEditor(panel.getControl())) {
return panel.getControl();
} else {
@@ -304,8 +304,8 @@ class MainThreadDocumentAndEditorStateComputer {
export class MainThreadDocumentsAndEditors {
private _toDispose: IDisposable[];
private _proxy: ExtHostDocumentsAndEditorsShape;
private _stateComputer: MainThreadDocumentAndEditorStateComputer;
private readonly _proxy: ExtHostDocumentsAndEditorsShape;
private readonly _stateComputer: MainThreadDocumentAndEditorStateComputer;
private _textEditors = <{ [id: string]: MainThreadTextEditor }>Object.create(null);
private _onTextEditorAdd = new Emitter<MainThreadTextEditor[]>();
@@ -362,8 +362,8 @@ export class MainThreadDocumentsAndEditors {
private _onDelta(delta: DocumentAndEditorStateDelta): void {
let removedDocuments: URI[];
let removedEditors: string[] = [];
let addedEditors: MainThreadTextEditor[] = [];
const removedEditors: string[] = [];
const addedEditors: MainThreadTextEditor[] = [];
// removed models
removedDocuments = delta.removedDocuments.map(m => m.uri);
@@ -387,7 +387,7 @@ export class MainThreadDocumentsAndEditors {
}
}
let extHostDelta: IDocumentsAndEditorsDelta = Object.create(null);
const extHostDelta: IDocumentsAndEditorsDelta = Object.create(null);
let empty = true;
if (delta.newActiveEditor !== undefined) {
empty = false;

View File

@@ -105,7 +105,7 @@ export class MainThreadTextEditorProperties {
}
public generateDelta(oldProps: MainThreadTextEditorProperties | null, selectionChangeSource: string | null): IEditorPropertiesChangeData | null {
let delta: IEditorPropertiesChangeData = {
const delta: IEditorPropertiesChangeData = {
options: null,
selections: null,
visibleRanges: null
@@ -181,12 +181,12 @@ export class MainThreadTextEditorProperties {
*/
export class MainThreadTextEditor {
private _id: string;
private readonly _id: string;
private _model: ITextModel;
private _modelService: IModelService;
private readonly _modelService: IModelService;
private _modelListeners: IDisposable[];
private _codeEditor: ICodeEditor | null;
private _focusTracker: IFocusTracker;
private readonly _focusTracker: IFocusTracker;
private _codeEditorListeners: IDisposable[];
private _properties: MainThreadTextEditorProperties;
@@ -323,7 +323,7 @@ export class MainThreadTextEditor {
}
private _setIndentConfiguration(newConfiguration: ITextEditorConfigurationUpdate): void {
let creationOpts = this._modelService.getCreationOptions(this._model.getLanguageIdentifier().language, this._model.uri, this._model.isForSimpleWidget);
const creationOpts = this._modelService.getCreationOptions(this._model.getLanguageIdentifier().language, this._model.uri, this._model.isForSimpleWidget);
if (newConfiguration.tabSize === 'auto' || newConfiguration.insertSpaces === 'auto') {
// one of the options was set to 'auto' => detect indentation
@@ -342,7 +342,7 @@ export class MainThreadTextEditor {
return;
}
let newOpts: ITextModelUpdateOptions = {};
const newOpts: ITextModelUpdateOptions = {};
if (typeof newConfiguration.insertSpaces !== 'undefined') {
newOpts.insertSpaces = newConfiguration.insertSpaces;
}
@@ -367,7 +367,7 @@ export class MainThreadTextEditor {
}
if (newConfiguration.cursorStyle) {
let newCursorStyle = cursorStyleToString(newConfiguration.cursorStyle);
const newCursorStyle = cursorStyleToString(newConfiguration.cursorStyle);
this._codeEditor.updateOptions({
cursorStyle: newCursorStyle
});
@@ -402,7 +402,7 @@ export class MainThreadTextEditor {
if (!this._codeEditor) {
return;
}
let ranges: Range[] = [];
const ranges: Range[] = [];
for (let i = 0, len = Math.floor(_ranges.length / 4); i < len; i++) {
ranges[i] = new Range(_ranges[4 * i], _ranges[4 * i + 1], _ranges[4 * i + 2], _ranges[4 * i + 3]);
}
@@ -464,7 +464,7 @@ export class MainThreadTextEditor {
this._model.pushEOL(EndOfLineSequence.LF);
}
let transformedEdits = edits.map((edit): IIdentifiedSingleEditOperation => {
const transformedEdits = edits.map((edit): IIdentifiedSingleEditOperation => {
return {
range: Range.lift(edit.range),
text: edit.text,

View File

@@ -31,9 +31,9 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
private static INSTANCE_COUNT: number = 0;
private _instanceId: string;
private _proxy: ExtHostEditorsShape;
private _documentsAndEditors: MainThreadDocumentsAndEditors;
private readonly _instanceId: string;
private readonly _proxy: ExtHostEditorsShape;
private readonly _documentsAndEditors: MainThreadDocumentsAndEditors;
private _toDispose: IDisposable[];
private _textEditorsListenersMap: { [editorId: string]: IDisposable[]; };
private _editorPositionData: ITextEditorPositionData | null;
@@ -77,8 +77,8 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
}
private _onTextEditorAdd(textEditor: MainThreadTextEditor): void {
let id = textEditor.getId();
let toDispose: IDisposable[] = [];
const id = textEditor.getId();
const toDispose: IDisposable[] = [];
toDispose.push(textEditor.onPropertiesChanged((data) => {
this._proxy.$acceptEditorPropertiesChanged(id, data);
}));
@@ -94,7 +94,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
private _updateActiveAndVisibleTextEditors(): void {
// editor columns
let editorPositionData = this._getTextEditorPositionData();
const editorPositionData = this._getTextEditorPositionData();
if (!objectEquals(this._editorPositionData, editorPositionData)) {
this._editorPositionData = editorPositionData;
this._proxy.$acceptEditorPositionData(this._editorPositionData);
@@ -102,7 +102,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
}
private _getTextEditorPositionData(): ITextEditorPositionData {
let result: ITextEditorPositionData = Object.create(null);
const result: ITextEditorPositionData = Object.create(null);
for (let workbenchEditor of this._editorService.visibleControls) {
const id = this._documentsAndEditors.findTextEditorIdFor(workbenchEditor);
if (id) {
@@ -114,7 +114,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
// --- from extension host process
$tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): Promise<string> {
$tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): Promise<string | undefined> {
const uri = URI.revive(resource);
const editorOptions: ITextEditorOptions = {
@@ -137,9 +137,9 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
}
$tryShowEditor(id: string, position?: EditorViewColumn): Promise<void> {
let mainThreadEditor = this._documentsAndEditors.getEditor(id);
const mainThreadEditor = this._documentsAndEditors.getEditor(id);
if (mainThreadEditor) {
let model = mainThreadEditor.getModel();
const model = mainThreadEditor.getModel();
return this._editorService.openEditor({
resource: model.uri,
options: { preserveFocus: false }
@@ -149,9 +149,9 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
}
$tryHideEditor(id: string): Promise<void> {
let mainThreadEditor = this._documentsAndEditors.getEditor(id);
const mainThreadEditor = this._documentsAndEditors.getEditor(id);
if (mainThreadEditor) {
let editors = this._editorService.visibleControls;
const editors = this._editorService.visibleControls;
for (let editor of editors) {
if (mainThreadEditor.matches(editor)) {
return editor.group.closeEditor(editor.input).then(() => { return; });

View File

@@ -57,7 +57,7 @@ export class MainThreadFileSystemEventService {
}, undefined, this._listener);
textfileService.onWillMove(e => {
let promise = proxy.$onWillRename(e.oldResource, e.newResource);
const promise = proxy.$onWillRename(e.oldResource, e.newResource);
e.waitUntil(promise);
}, undefined, this._listener);
}

View File

@@ -96,7 +96,7 @@ export class HeapService implements IHeapService {
@extHostCustomer
export class MainThreadHeapService {
private _toDispose: IDisposable;
private readonly _toDispose: IDisposable;
constructor(
extHostContext: IExtHostContext,

View File

@@ -26,10 +26,10 @@ import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
@extHostNamedCustomer(MainContext.MainThreadLanguageFeatures)
export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesShape {
private _proxy: ExtHostLanguageFeaturesShape;
private _heapService: IHeapService;
private _modeService: IModeService;
private _registrations: { [handle: number]: IDisposable; } = Object.create(null);
private readonly _proxy: ExtHostLanguageFeaturesShape;
private readonly _heapService: IHeapService;
private readonly _modeService: IModeService;
private readonly _registrations: { [handle: number]: IDisposable; } = Object.create(null);
constructor(
extHostContext: IExtHostContext,
@@ -48,7 +48,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
}
$unregister(handle: number): void {
let registration = this._registrations[handle];
const registration = this._registrations[handle];
if (registration) {
registration.dispose();
delete this._registrations[handle];
@@ -506,7 +506,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
$setLanguageConfiguration(handle: number, languageId: string, _configuration: ISerializedLanguageConfiguration): void {
let configuration: LanguageConfiguration = {
const configuration: LanguageConfiguration = {
comments: _configuration.comments,
brackets: _configuration.brackets,
wordPattern: MainThreadLanguageFeatures._reviveRegExp(_configuration.wordPattern),
@@ -532,7 +532,7 @@ export class MainThreadLanguageFeatures implements MainThreadLanguageFeaturesSha
};
}
let languageIdentifier = this._modeService.getLanguageIdentifier(languageId);
const languageIdentifier = this._modeService.getLanguageIdentifier(languageId);
if (languageIdentifier) {
this._registrations[handle] = LanguageConfigurationRegistry.register(languageIdentifier, configuration);
}

View File

@@ -29,7 +29,7 @@ export class MainThreadLanguages implements MainThreadLanguagesShape {
$changeLanguage(resource: UriComponents, languageId: string): Promise<void> {
const uri = URI.revive(resource);
let model = this._modelService.getModel(uri);
const model = this._modelService.getModel(uri);
if (!model) {
return Promise.reject(new Error('Invalid uri'));
}

View File

@@ -44,7 +44,7 @@ export class MainThreadMessageService implements MainThreadMessageServiceShape {
return new Promise<number>(resolve => {
let primaryActions: MessageItemAction[] = [];
const primaryActions: MessageItemAction[] = [];
class MessageItemAction extends Action {
constructor(id: string, label: string, handle: number) {

View File

@@ -18,7 +18,7 @@ export class MainThreadOutputService extends Disposable implements MainThreadOut
private static _idPool = 1;
private _proxy: ExtHostOutputServiceShape;
private readonly _proxy: ExtHostOutputServiceShape;
private readonly _outputService: IOutputService;
private readonly _partService: IPartService;
private readonly _panelService: IPanelService;

View File

@@ -10,9 +10,9 @@ import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostC
@extHostNamedCustomer(MainContext.MainThreadProgress)
export class MainThreadProgress implements MainThreadProgressShape {
private _progressService: IProgressService2;
private readonly _progressService: IProgressService2;
private _progress = new Map<number, { resolve: () => void, progress: IProgress<IProgressStep> }>();
private _proxy: ExtHostProgressShape;
private readonly _proxy: ExtHostProgressShape;
constructor(
extHostContext: IExtHostContext,

View File

@@ -18,9 +18,9 @@ interface QuickInputSession {
@extHostNamedCustomer(MainContext.MainThreadQuickOpen)
export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
private _proxy: ExtHostQuickOpenShape;
private _quickInputService: IQuickInputService;
private _items: Record<number, {
private readonly _proxy: ExtHostQuickOpenShape;
private readonly _quickInputService: IQuickInputService;
private readonly _items: Record<number, {
resolve(items: TransferQuickPickItems[]): void;
reject(error: Error): void;
}> = {};
@@ -85,7 +85,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
// ---- input
$input(options: InputBoxOptions, validateInput: boolean, token: CancellationToken): Promise<string> {
$input(options: InputBoxOptions | undefined, validateInput: boolean, token: CancellationToken): Promise<string> {
const inputOptions: IInputOptions = Object.create(null);
if (options) {

View File

@@ -27,8 +27,8 @@ class MainThreadSCMResourceGroup implements ISCMResourceGroup {
get onDidChange(): Event<void> { return this._onDidChange.event; }
constructor(
private sourceControlHandle: number,
private handle: number,
private readonly sourceControlHandle: number,
private readonly handle: number,
public provider: ISCMProvider,
public features: SCMGroupFeatures,
public label: string,
@@ -62,10 +62,10 @@ class MainThreadSCMResourceGroup implements ISCMResourceGroup {
class MainThreadSCMResource implements ISCMResource {
constructor(
private proxy: ExtHostSCMShape,
private sourceControlHandle: number,
private groupHandle: number,
private handle: number,
private readonly proxy: ExtHostSCMShape,
private readonly sourceControlHandle: number,
private readonly groupHandle: number,
private readonly handle: number,
public sourceUri: URI,
public resourceGroup: ISCMResourceGroup,
public decorations: ISCMResourceDecorations
@@ -92,7 +92,7 @@ class MainThreadSCMProvider implements ISCMProvider {
get id(): string { return this._id; }
readonly groups = new Sequence<MainThreadSCMResourceGroup>();
private _groupsByHandle: { [handle: number]: MainThreadSCMResourceGroup; } = Object.create(null);
private readonly _groupsByHandle: { [handle: number]: MainThreadSCMResourceGroup; } = Object.create(null);
// get groups(): ISequence<ISCMResourceGroup> {
// return {
@@ -129,11 +129,11 @@ class MainThreadSCMProvider implements ISCMProvider {
get onDidChange(): Event<void> { return this._onDidChange.event; }
constructor(
private proxy: ExtHostSCMShape,
private _handle: number,
private _contextValue: string,
private _label: string,
private _rootUri: URI | undefined,
private readonly proxy: ExtHostSCMShape,
private readonly _handle: number,
private readonly _contextValue: string,
private readonly _label: string,
private readonly _rootUri: URI | undefined,
@ISCMService scmService: ISCMService
) { }
@@ -265,7 +265,7 @@ class MainThreadSCMProvider implements ISCMProvider {
@extHostNamedCustomer(MainContext.MainThreadSCM)
export class MainThreadSCM implements MainThreadSCMShape {
private _proxy: ExtHostSCMShape;
private readonly _proxy: ExtHostSCMShape;
private _repositories: { [handle: number]: ISCMRepository; } = Object.create(null);
private _inputDisposables: { [handle: number]: IDisposable; } = Object.create(null);
private _disposables: IDisposable[] = [];

View File

@@ -16,8 +16,8 @@ import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import { Selection } from 'vs/editor/common/core/selection';
import { IIdentifiedSingleEditOperation, ISingleEditOperation, ITextModel } from 'vs/editor/common/model';
import { CodeAction } from 'vs/editor/common/modes';
import { IIdentifiedSingleEditOperation, ITextModel } from 'vs/editor/common/model';
import { CodeAction, TextEdit } from 'vs/editor/common/modes';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { shouldSynchronizeModel } from 'vs/editor/common/services/modelService';
import { getCodeActions } from 'vs/editor/contrib/codeAction/codeAction';
@@ -34,7 +34,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IProgressService2, ProgressLocation } from 'vs/platform/progress/common/progress';
import { extHostCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
import { ISaveParticipant, ITextFileEditorModel, SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import { ISaveParticipant, SaveReason, IResolvedTextFileEditorModel } from 'vs/workbench/services/textfile/common/textfiles';
import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext } from '../node/extHost.protocol';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@@ -51,7 +51,7 @@ class TrimWhitespaceParticipant implements ISaveParticipantParticipant {
// Nothing
}
async participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
if (this.configurationService.getValue('files.trimTrailingWhitespace', { overrideIdentifier: model.textEditorModel.getLanguageIdentifier().language, resource: model.getResource() })) {
this.doTrimTrailingWhitespace(model.textEditorModel, env.reason === SaveReason.AUTO);
}
@@ -113,7 +113,7 @@ export class FinalNewLineParticipant implements ISaveParticipantParticipant {
// Nothing
}
async participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
if (this.configurationService.getValue('files.insertFinalNewline', { overrideIdentifier: model.textEditorModel.getLanguageIdentifier().language, resource: model.getResource() })) {
this.doInsertFinalNewLine(model.textEditorModel);
}
@@ -151,7 +151,7 @@ export class TrimFinalNewLinesParticipant implements ISaveParticipantParticipant
// Nothing
}
async participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
if (this.configurationService.getValue('files.trimFinalNewlines', { overrideIdentifier: model.textEditorModel.getLanguageIdentifier().language, resource: model.getResource() })) {
this.doTrimFinalNewLines(model.textEditorModel, env.reason === SaveReason.AUTO);
}
@@ -222,7 +222,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
// Nothing
}
async participate(editorModel: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
const model = editorModel.textEditorModel;
if (env.reason === SaveReason.AUTO
@@ -234,9 +234,9 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
const timeout = this._configurationService.getValue<number>('editor.formatOnSaveTimeout', { overrideIdentifier: model.getLanguageIdentifier().language, resource: editorModel.getResource() });
return new Promise<ISingleEditOperation[] | null | undefined>((resolve, reject) => {
let source = new CancellationTokenSource();
let request = getDocumentFormattingEdits(this._telemetryService, this._editorWorkerService, model, model.getFormattingOptions(), FormatMode.Auto, source.token);
return new Promise<TextEdit[] | null | undefined>((resolve, reject) => {
const source = new CancellationTokenSource();
const request = getDocumentFormattingEdits(this._telemetryService, this._editorWorkerService, model, model.getFormattingOptions(), FormatMode.Auto, source.token);
setTimeout(() => {
reject(localize('timeout.formatOnSave', "Aborted format on save after {0}ms", timeout));
@@ -257,11 +257,11 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
});
}
private _editsWithEditor(editor: ICodeEditor, edits: ISingleEditOperation[]): void {
private _editsWithEditor(editor: ICodeEditor, edits: TextEdit[]): void {
FormattingEdit.execute(editor, edits);
}
private _editWithModel(model: ITextModel, edits: ISingleEditOperation[]): void {
private _editWithModel(model: ITextModel, edits: TextEdit[]): void {
const [{ range }] = edits;
const initialSelection = new Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
@@ -276,7 +276,7 @@ class FormatOnSaveParticipant implements ISaveParticipantParticipant {
});
}
private static _asIdentEdit({ text, range }: ISingleEditOperation): IIdentifiedSingleEditOperation {
private static _asIdentEdit({ text, range }: TextEdit): IIdentifiedSingleEditOperation {
return {
text,
range: Range.lift(range),
@@ -293,7 +293,7 @@ class CodeActionOnSaveParticipant implements ISaveParticipant {
@IConfigurationService private readonly _configurationService: IConfigurationService
) { }
async participate(editorModel: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
if (env.reason === SaveReason.AUTO) {
return undefined;
}
@@ -367,13 +367,13 @@ class CodeActionOnSaveParticipant implements ISaveParticipant {
class ExtHostSaveParticipant implements ISaveParticipantParticipant {
private _proxy: ExtHostDocumentSaveParticipantShape;
private readonly _proxy: ExtHostDocumentSaveParticipantShape;
constructor(extHostContext: IExtHostContext) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDocumentSaveParticipant);
}
async participate(editorModel: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(editorModel: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
if (!shouldSynchronizeModel(editorModel.textEditorModel)) {
// the model never made it to the extension
@@ -424,7 +424,7 @@ export class SaveParticipant implements ISaveParticipant {
this._saveParticipants.dispose();
}
async participate(model: ITextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
async participate(model: IResolvedTextFileEditorModel, env: { reason: SaveReason }): Promise<void> {
return this._progressService.withProgress({ location: ProgressLocation.Window }, progress => {
progress.report({ message: localize('saveParticipants', "Running Save Participants...") });
const promiseFactory = this._saveParticipants.getValue().map(p => () => {

View File

@@ -34,12 +34,12 @@ export class MainThreadStatusBar implements MainThreadStatusBarShape {
this.$dispose(id);
// Add new
let entry = this._statusbarService.addEntry({ text, tooltip, command, color, extensionId }, alignment, priority);
const entry = this._statusbarService.addEntry({ text, tooltip, command, color, extensionId }, alignment, priority);
this._entries[id] = entry;
}
$dispose(id: number) {
let disposeable = this._entries[id];
const disposeable = this._entries[id];
if (disposeable) {
disposeable.dispose();
}

View File

@@ -11,10 +11,10 @@ import { IDisposable } from 'vs/base/common/lifecycle';
@extHostNamedCustomer(MainContext.MainThreadStorage)
export class MainThreadStorage implements MainThreadStorageShape {
private _storageService: IStorageService;
private _proxy: ExtHostStorageShape;
private _storageListener: IDisposable;
private _sharedStorageKeysToWatch: Map<string, boolean> = new Map<string, boolean>();
private readonly _storageService: IStorageService;
private readonly _proxy: ExtHostStorageShape;
private readonly _storageListener: IDisposable;
private readonly _sharedStorageKeysToWatch: Map<string, boolean> = new Map<string, boolean>();
constructor(
extHostContext: IExtHostContext,
@@ -24,7 +24,7 @@ export class MainThreadStorage implements MainThreadStorageShape {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostStorage);
this._storageListener = this._storageService.onDidChangeStorage(e => {
let shared = e.scope === StorageScope.GLOBAL;
const shared = e.scope === StorageScope.GLOBAL;
if (shared && this._sharedStorageKeysToWatch.has(e.key)) {
try {
this._proxy.$acceptValue(shared, e.key, this._getValue(shared, e.key));
@@ -51,7 +51,7 @@ export class MainThreadStorage implements MainThreadStorageShape {
}
private _getValue<T>(shared: boolean, key: string): T | undefined {
let jsonValue = this._storageService.get(key, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE);
const jsonValue = this._storageService.get(key, shared ? StorageScope.GLOBAL : StorageScope.WORKSPACE);
if (!jsonValue) {
return undefined;
}

View File

@@ -70,7 +70,7 @@ namespace TaskProcessEndedDTO {
namespace TaskDefinitionDTO {
export function from(value: KeyedTaskIdentifier): TaskDefinitionDTO {
let result = Objects.assign(Object.create(null), value);
const result = Objects.assign(Object.create(null), value);
delete result._key;
return result;
}
@@ -139,13 +139,13 @@ namespace ProcessExecutionOptionsDTO {
namespace ProcessExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO): value is ProcessExecutionDTO {
let candidate = value as ProcessExecutionDTO;
const candidate = value as ProcessExecutionDTO;
return candidate && !!candidate.process;
}
export function from(value: CommandConfiguration): ProcessExecutionDTO {
let process: string = Types.isString(value.name) ? value.name : value.name.value;
let args: string[] = value.args ? value.args.map(value => Types.isString(value) ? value : value.value) : [];
let result: ProcessExecutionDTO = {
const process: string = Types.isString(value.name) ? value.name : value.name.value;
const args: string[] = value.args ? value.args.map(value => Types.isString(value) ? value : value.value) : [];
const result: ProcessExecutionDTO = {
process: process,
args: args
};
@@ -155,7 +155,7 @@ namespace ProcessExecutionDTO {
return result;
}
export function to(value: ProcessExecutionDTO): CommandConfiguration {
let result: CommandConfiguration = {
const result: CommandConfiguration = {
runtime: RuntimeType.Process,
name: value.process,
args: value.args,
@@ -171,7 +171,7 @@ namespace ShellExecutionOptionsDTO {
if (value === undefined || value === null) {
return undefined;
}
let result: ShellExecutionOptionsDTO = {
const result: ShellExecutionOptionsDTO = {
cwd: value.cwd || CommandOptions.defaults.cwd,
env: value.env
};
@@ -186,7 +186,7 @@ namespace ShellExecutionOptionsDTO {
if (value === undefined || value === null) {
return undefined;
}
let result: CommandOptions = {
const result: CommandOptions = {
cwd: value.cwd,
env: value.env
};
@@ -207,11 +207,11 @@ namespace ShellExecutionOptionsDTO {
namespace ShellExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO): value is ShellExecutionDTO {
let candidate = value as ShellExecutionDTO;
const candidate = value as ShellExecutionDTO;
return candidate && (!!candidate.commandLine || !!candidate.command);
}
export function from(value: CommandConfiguration): ShellExecutionDTO {
let result: ShellExecutionDTO = {};
const result: ShellExecutionDTO = {};
if (value.name && Types.isString(value.name) && (value.args === undefined || value.args === null || value.args.length === 0)) {
result.commandLine = value.name;
} else {
@@ -224,7 +224,7 @@ namespace ShellExecutionDTO {
return result;
}
export function to(value: ShellExecutionDTO): CommandConfiguration {
let result: CommandConfiguration = {
const result: CommandConfiguration = {
runtime: RuntimeType.Shell,
name: value.commandLine ? value.commandLine : value.command,
args: value.args,
@@ -239,7 +239,7 @@ namespace ShellExecutionDTO {
namespace TaskSourceDTO {
export function from(value: TaskSource): TaskSourceDTO {
let result: TaskSourceDTO = {
const result: TaskSourceDTO = {
label: value.label
};
if (value.kind === TaskSourceKind.Extension) {
@@ -285,7 +285,7 @@ namespace TaskSourceDTO {
namespace TaskHandleDTO {
export function is(value: any): value is TaskHandleDTO {
let candidate: TaskHandleDTO = value;
const candidate: TaskHandleDTO = value;
return candidate && Types.isString(candidate.id) && !!candidate.workspaceFolder;
}
}
@@ -295,7 +295,7 @@ namespace TaskDTO {
if (task === undefined || task === null || (!CustomTask.is(task) && !ContributedTask.is(task))) {
return undefined;
}
let result: TaskDTO = {
const result: TaskDTO = {
_id: task._id,
name: task.configurationProperties.name,
definition: TaskDefinitionDTO.from(task.getDefinition()),
@@ -344,12 +344,12 @@ namespace TaskDTO {
return undefined;
}
command.presentation = TaskPresentationOptionsDTO.to(task.presentationOptions);
let source = TaskSourceDTO.to(task.source, workspace);
const source = TaskSourceDTO.to(task.source, workspace);
let label = nls.localize('task.label', '{0}: {1}', source.label, task.name);
let definition = TaskDefinitionDTO.to(task.definition, executeOnly);
let id = `${task.source.extensionId}.${definition._key}`;
let result: ContributedTask = new ContributedTask(
const label = nls.localize('task.label', '{0}: {1}', source.label, task.name);
const definition = TaskDefinitionDTO.to(task.definition, executeOnly);
const id = `${task.source.extensionId}.${definition._key}`;
const result: ContributedTask = new ContributedTask(
id, // uuidMap.getUUID(identifier)
source,
label,
@@ -382,9 +382,9 @@ namespace TaskFilterDTO {
@extHostNamedCustomer(MainContext.MainThreadTask)
export class MainThreadTask implements MainThreadTaskShape {
private _extHostContext: IExtHostContext;
private _proxy: ExtHostTaskShape;
private _providers: Map<number, { disposable: IDisposable, provider: ITaskProvider }>;
private readonly _extHostContext: IExtHostContext;
private readonly _proxy: ExtHostTaskShape;
private readonly _providers: Map<number, { disposable: IDisposable, provider: ITaskProvider }>;
constructor(
extHostContext: IExtHostContext,
@@ -416,12 +416,12 @@ export class MainThreadTask implements MainThreadTaskShape {
}
public $registerTaskProvider(handle: number): Promise<void> {
let provider: ITaskProvider = {
const provider: ITaskProvider = {
provideTasks: (validTypes: IStringDictionary<boolean>) => {
return Promise.resolve(this._proxy.$provideTasks(handle, validTypes)).then((value) => {
let tasks: Task[] = [];
const tasks: Task[] = [];
for (let dto of value.tasks) {
let task = TaskDTO.to(dto, this._workspaceContextServer, true);
const task = TaskDTO.to(dto, this._workspaceContextServer, true);
if (task) {
tasks.push(task);
} else {
@@ -435,7 +435,7 @@ export class MainThreadTask implements MainThreadTaskShape {
});
}
};
let disposable = this._taskService.registerTaskProvider(provider);
const disposable = this._taskService.registerTaskProvider(provider);
this._providers.set(handle, { disposable, provider });
return Promise.resolve(undefined);
}
@@ -448,9 +448,9 @@ export class MainThreadTask implements MainThreadTaskShape {
public $fetchTasks(filter?: TaskFilterDTO): Promise<TaskDTO[]> {
return this._taskService.tasks(TaskFilterDTO.to(filter)).then((tasks) => {
let result: TaskDTO[] = [];
const result: TaskDTO[] = [];
for (let task of tasks) {
let item = TaskDTO.from(task);
const item = TaskDTO.from(task);
if (item) {
result.push(item);
}
@@ -462,12 +462,12 @@ export class MainThreadTask implements MainThreadTaskShape {
public $executeTask(value: TaskHandleDTO | TaskDTO): Promise<TaskExecutionDTO> {
return new Promise<TaskExecutionDTO>((resolve, reject) => {
if (TaskHandleDTO.is(value)) {
let workspaceFolder = this._workspaceContextServer.getWorkspaceFolder(URI.revive(value.workspaceFolder));
const workspaceFolder = this._workspaceContextServer.getWorkspaceFolder(URI.revive(value.workspaceFolder));
this._taskService.getTask(workspaceFolder, value.id, true).then((task: Task) => {
this._taskService.run(task).then(undefined, reason => {
// eat the error, it has already been surfaced to the user and we don't care about it here
});
let result: TaskExecutionDTO = {
const result: TaskExecutionDTO = {
id: value.id,
task: TaskDTO.from(task)
};
@@ -476,11 +476,11 @@ export class MainThreadTask implements MainThreadTaskShape {
reject(new Error('Task not found'));
});
} else {
let task = TaskDTO.to(value, this._workspaceContextServer, true);
const task = TaskDTO.to(value, this._workspaceContextServer, true);
this._taskService.run(task).then(undefined, reason => {
// eat the error, it has already been surfaced to the user and we don't care about it here
});
let result: TaskExecutionDTO = {
const result: TaskExecutionDTO = {
id: task._id,
task: TaskDTO.from(task)
};
@@ -529,7 +529,7 @@ export class MainThreadTask implements MainThreadTaskShape {
},
context: this._extHostContext,
resolveVariables: (workspaceFolder: IWorkspaceFolder, toResolve: ResolveSet): Promise<ResolvedVariables> => {
let vars: string[] = [];
const vars: string[] = [];
toResolve.variables.forEach(item => vars.push(item));
return Promise.resolve(this._proxy.$resolveVariables(workspaceFolder.uri, { process: toResolve.process, variables: vars })).then(values => {
const partiallyResolvedVars = new Array<string>();
@@ -538,7 +538,7 @@ export class MainThreadTask implements MainThreadTaskShape {
});
return new Promise<ResolvedVariables>((resolve, reject) => {
this._configurationResolverService.resolveWithInteraction(workspaceFolder, partiallyResolvedVars, 'tasks').then(resolvedVars => {
let result: ResolvedVariables = {
const result: ResolvedVariables = {
process: undefined,
variables: new Map<string, string>()
};

View File

@@ -7,6 +7,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ITerminalService, ITerminalInstance, IShellLaunchConfig, ITerminalProcessExtHostProxy, ITerminalProcessExtHostRequest, ITerminalDimensions, EXT_HOST_CREATION_DELAY } from 'vs/workbench/contrib/terminal/common/terminal';
import { ExtHostContext, ExtHostTerminalServiceShape, MainThreadTerminalServiceShape, MainContext, IExtHostContext, ShellLaunchConfigDto } from 'vs/workbench/api/node/extHost.protocol';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
import { UriComponents, URI } from 'vs/base/common/uri';
@extHostNamedCustomer(MainContext.MainThreadTerminalService)
export class MainThreadTerminalService implements MainThreadTerminalServiceShape {
@@ -58,12 +59,12 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
// when the extension host process goes down ?
}
public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string, env?: { [key: string]: string }, waitOnExit?: boolean, strictEnv?: boolean): Promise<{ id: number, name: string }> {
public $createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string | UriComponents, env?: { [key: string]: string }, waitOnExit?: boolean, strictEnv?: boolean): Promise<{ id: number, name: string }> {
const shellLaunchConfig: IShellLaunchConfig = {
name,
executable: shellPath,
args: shellArgs,
cwd,
cwd: typeof cwd === 'string' ? cwd : URI.revive(cwd),
waitOnExit,
ignoreConfigurationCwd: true,
env,

View File

@@ -15,8 +15,8 @@ import { IMarkdownString } from 'vs/base/common/htmlContent';
@extHostNamedCustomer(MainContext.MainThreadTreeViews)
export class MainThreadTreeViews extends Disposable implements MainThreadTreeViewsShape {
private _proxy: ExtHostTreeViewsShape;
private _dataProviders: Map<string, TreeViewDataProvider> = new Map<string, TreeViewDataProvider>();
private readonly _proxy: ExtHostTreeViewsShape;
private readonly _dataProviders: Map<string, TreeViewDataProvider> = new Map<string, TreeViewDataProvider>();
constructor(
extHostContext: IExtHostContext,
@@ -133,11 +133,11 @@ type TreeItemHandle = string;
class TreeViewDataProvider implements ITreeViewDataProvider {
private itemsMap: Map<TreeItemHandle, ITreeItem> = new Map<TreeItemHandle, ITreeItem>();
private readonly itemsMap: Map<TreeItemHandle, ITreeItem> = new Map<TreeItemHandle, ITreeItem>();
constructor(private treeViewId: string,
private _proxy: ExtHostTreeViewsShape,
private notificationService: INotificationService
constructor(private readonly treeViewId: string,
private readonly _proxy: ExtHostTreeViewsShape,
private readonly notificationService: INotificationService
) {
}

View File

@@ -119,7 +119,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
// --- search ---
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
$startFileSearch(includePattern: string, _includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false | undefined, maxResults: number, token: CancellationToken): Promise<URI[] | undefined> {
const includeFolder = URI.revive(_includeFolder);
const workspace = this._contextService.getWorkspace();
if (!workspace.folders.length) {
@@ -134,6 +134,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
disregardSearchExcludeSettings: true,
disregardIgnoreFiles: true,
includePattern,
excludePattern: typeof excludePatternOrDisregardExcludes === 'string' ? excludePatternOrDisregardExcludes : undefined,
_reason: 'startFileSearch'
});
@@ -181,6 +182,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
const query = queryBuilder.file(folders, {
_reason: 'checkExists',
includePattern: includes.join(', '),
expandPatterns: true,
exists: true
});

View File

@@ -92,7 +92,7 @@ export function createApiFactory(
extHostStorage: ExtHostStorage
): IExtensionApiFactory {
let schemeTransformer: ISchemeTransformer | null = null;
const schemeTransformer: ISchemeTransformer | null = null;
// Addressable instances
rpcProtocol.set(ExtHostContext.ExtHostLogService, extHostLogService);
@@ -188,7 +188,7 @@ export function createApiFactory(
},
registerTextEditorCommand(id: string, callback: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit, ...args: any[]) => void, thisArg?: any): vscode.Disposable {
return extHostCommands.registerCommand(true, id, (...args: any[]): any => {
let activeTextEditor = extHostEditors.getActiveTextEditor();
const activeTextEditor = extHostEditors.getActiveTextEditor();
if (!activeTextEditor) {
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
return undefined;
@@ -209,7 +209,7 @@ export function createApiFactory(
},
registerDiffInformationCommand: proposedApiFunction(extension, (id: string, callback: (diff: vscode.LineChange[], ...args: any[]) => any, thisArg?: any): vscode.Disposable => {
return extHostCommands.registerCommand(true, id, async (...args: any[]): Promise<any> => {
let activeTextEditor = extHostEditors.getActiveTextEditor();
const activeTextEditor = extHostEditors.getActiveTextEditor();
if (!activeTextEditor) {
console.warn('Cannot execute ' + id + ' because there is no active text editor.');
return undefined;
@@ -527,7 +527,7 @@ export function createApiFactory(
onDidChangeWorkspaceFolders: function (listener, thisArgs?, disposables?) {
return extHostWorkspace.onDidChangeWorkspace(listener, thisArgs, disposables);
},
asRelativePath: (pathOrUri, includeWorkspace) => {
asRelativePath: (pathOrUri, includeWorkspace?) => {
return extHostWorkspace.getRelativePath(pathOrUri, includeWorkspace);
},
findFiles: (include, exclude, maxResults?, token?) => {
@@ -566,7 +566,7 @@ export function createApiFactory(
openTextDocument(uriOrFileNameOrOptions?: vscode.Uri | string | { language?: string; content?: string; }) {
let uriPromise: Thenable<URI>;
let options = uriOrFileNameOrOptions as { language?: string; content?: string; };
const options = uriOrFileNameOrOptions as { language?: string; content?: string; };
if (typeof uriOrFileNameOrOptions === 'string') {
uriPromise = Promise.resolve(URI.file(uriOrFileNameOrOptions));
} else if (uriOrFileNameOrOptions instanceof URI) {

View File

@@ -141,7 +141,7 @@ export interface MainThreadConfigurationShape extends IDisposable {
}
export interface MainThreadDiagnosticsShape extends IDisposable {
$changeMany(owner: string, entries: [UriComponents, IMarkerData[]][]): void;
$changeMany(owner: string, entries: [UriComponents, IMarkerData[] | undefined][]): void;
$clear(owner: string): void;
}
@@ -223,7 +223,7 @@ export interface ITextDocumentShowOptions {
}
export interface MainThreadTextEditorsShape extends IDisposable {
$tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): Promise<string>;
$tryShowTextDocument(resource: UriComponents, options: ITextDocumentShowOptions): Promise<string | undefined>;
$registerTextEditorDecorationType(key: string, options: editorCommon.IDecorationRenderOptions): void;
$removeTextEditorDecorationType(key: string): void;
$tryShowEditor(id: string, position: EditorViewColumn): Promise<void>;
@@ -367,7 +367,7 @@ export interface MainThreadProgressShape extends IDisposable {
}
export interface MainThreadTerminalServiceShape extends IDisposable {
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string | URI, env?: { [key: string]: string }, waitOnExit?: boolean, strictEnv?: boolean): Promise<{ id: number, name: string }>;
$createTerminal(name?: string, shellPath?: string, shellArgs?: string[], cwd?: string | UriComponents, env?: { [key: string]: string }, waitOnExit?: boolean, strictEnv?: boolean): Promise<{ id: number, name: string }>;
$createTerminalRenderer(name: string): Promise<number>;
$dispose(terminalId: number): void;
$hide(terminalId: number): void;
@@ -459,7 +459,7 @@ export interface MainThreadQuickOpenShape extends IDisposable {
$show(instance: number, options: IPickOptions<TransferQuickPickItems>, token: CancellationToken): Promise<number | number[] | undefined>;
$setItems(instance: number, items: TransferQuickPickItems[]): Promise<void>;
$setError(instance: number, error: Error): Promise<void>;
$input(options: vscode.InputBoxOptions, validateInput: boolean, token: CancellationToken): Promise<string>;
$input(options: vscode.InputBoxOptions | undefined, validateInput: boolean, token: CancellationToken): Promise<string>;
$createOrUpdate(params: TransferQuickInput): Promise<void>;
$dispose(id: number): Promise<void>;
}
@@ -526,7 +526,7 @@ export interface ExtHostUrlsShape {
}
export interface MainThreadWorkspaceShape extends IDisposable {
$startFileSearch(includePattern: string | undefined, includeFolder: URI | undefined, excludePatternOrDisregardExcludes: string | false, maxResults: number, token: CancellationToken): Promise<UriComponents[] | undefined>;
$startFileSearch(includePattern: string | undefined, includeFolder: UriComponents | undefined, excludePatternOrDisregardExcludes: string | false | undefined, maxResults: number, token: CancellationToken): Promise<UriComponents[] | undefined>;
$startTextSearch(query: IPatternInfo, options: ITextQueryBuilderOptions, requestId: number, token: CancellationToken): Promise<vscode.TextSearchComplete>;
$checkExists(includes: string[], token: CancellationToken): Promise<boolean>;
$saveAll(includeUntitled?: boolean): Promise<boolean>;
@@ -581,7 +581,7 @@ export interface SCMProviderFeatures {
count?: number;
commitTemplate?: string;
acceptInputCommand?: modes.Command;
statusBarCommands?: modes.Command[];
statusBarCommands?: CommandDto[];
}
export interface SCMGroupFeatures {
@@ -859,9 +859,9 @@ export interface WorkspaceSymbolsDto extends IdObject {
}
export interface ResourceFileEditDto {
oldUri: UriComponents;
newUri: UriComponents;
options: IFileOperationOptions;
oldUri?: UriComponents;
newUri?: UriComponents;
options?: IFileOperationOptions;
}
export interface ResourceTextEditDto {
@@ -964,7 +964,7 @@ export interface ShellLaunchConfigDto {
name?: string;
executable?: string;
args?: string[] | string;
cwd?: string | URI;
cwd?: string | UriComponents;
env?: { [key: string]: string | null };
}
@@ -977,7 +977,7 @@ export interface ExtHostTerminalServiceShape {
$acceptTerminalRendererInput(id: number, data: string): void;
$acceptTerminalTitleChange(id: number, name: string): void;
$acceptTerminalDimensions(id: number, cols: number, rows: number): void;
$createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, activeWorkspaceRootUri: URI, cols: number, rows: number): void;
$createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, activeWorkspaceRootUri: UriComponents, cols: number, rows: number): void;
$acceptProcessInput(id: number, data: string): void;
$acceptProcessResize(id: number, cols: number, rows: number): void;
$acceptProcessShutdown(id: number, immediate: boolean): void;

View File

@@ -263,7 +263,7 @@ export class ExtHostApiCommands {
// --- command impl
private _register(id: string, handler: (...args: any[]) => any, description?: ICommandHandlerDescription): void {
let disposable = this._commands.registerCommand(false, id, handler, this, description);
const disposable = this._commands.registerCommand(false, id, handler, this, description);
this._disposables.push(disposable);
}
@@ -408,7 +408,7 @@ export class ExtHostApiCommands {
}
private _executeSelectionRangeProvider(resource: URI, positions: types.Position[]): Promise<vscode.SelectionRange[][]> {
let pos = positions.map(typeConverters.Position.from);
const pos = positions.map(typeConverters.Position.from);
const args = {
resource,
position: pos[0],
@@ -443,7 +443,7 @@ export class ExtHostApiCommands {
}
class MergedInfo extends types.SymbolInformation implements vscode.DocumentSymbol {
static to(symbol: modes.DocumentSymbol): MergedInfo {
let res = new MergedInfo(
const res = new MergedInfo(
symbol.name,
typeConverters.SymbolKind.to(symbol.kind),
symbol.containerName,

View File

@@ -39,7 +39,7 @@ export class CLIServer {
console.error('Could not start open from terminal server.');
}
return this.ipcHandlePath;
return this._ipcHandlePath;
}
private collectURIToOpen(strs: string[], typeHint: URIType, result: IURIToOpen[]): void {
if (Array.isArray(strs)) {

View File

@@ -22,7 +22,7 @@ import { URI } from 'vs/base/common/uri';
interface CommandHandler {
callback: Function;
thisArg: any;
description: ICommandHandlerDescription;
description?: ICommandHandlerDescription;
}
export interface ArgumentProcessor {
@@ -154,7 +154,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
}
try {
let result = callback.apply(thisArg, args);
const result = callback.apply(thisArg, args);
return Promise.resolve(result);
} catch (err) {
this._logService.error(err, id);

View File

@@ -374,7 +374,7 @@ export class ExtHostCommentThread implements vscode.CommentThread {
}
getComment(commentId: string): vscode.Comment | undefined {
let comments = this._comments.filter(comment => comment.commentId === commentId);
const comments = this._comments.filter(comment => comment.commentId === commentId);
if (comments && comments.length) {
return comments[0];

View File

@@ -255,7 +255,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
console.error('DebugConfigurationProvider.debugAdapterExecutable is deprecated and will be removed soon; please use DebugAdapterDescriptorFactory.createDebugAdapterDescriptor instead.');
}
let handle = this._configProviderHandleCounter++;
const handle = this._configProviderHandleCounter++;
this._configProviders.push({ type, handle, provider });
this._debugServiceProxy.$registerDebugConfigurationProvider(type,
@@ -286,7 +286,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
throw new Error(`a DebugAdapterDescriptorFactory can only be registered once per a type.`);
}
let handle = this._adapterFactoryHandleCounter++;
const handle = this._adapterFactoryHandleCounter++;
this._adapterFactories.push({ type, handle, factory });
this._debugServiceProxy.$registerDebugAdapterDescriptorFactory(type, handle);
@@ -303,7 +303,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
return new Disposable(() => { });
}
let handle = this._trackerFactoryHandleCounter++;
const handle = this._trackerFactoryHandleCounter++;
this._trackerFactories.push({ type, handle, factory });
this._debugServiceProxy.$registerDebugAdapterTrackerFactory(type, handle);
@@ -494,9 +494,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
public $acceptBreakpointsDelta(delta: IBreakpointsDeltaDto): void {
let a: vscode.Breakpoint[] = [];
let r: vscode.Breakpoint[] = [];
let c: vscode.Breakpoint[] = [];
const a: vscode.Breakpoint[] = [];
const r: vscode.Breakpoint[] = [];
const c: vscode.Breakpoint[] = [];
if (delta.added) {
for (const bpd of delta.added) {
@@ -528,7 +528,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
if (delta.changed) {
for (const bpd of delta.changed) {
let bp = this._breakpoints.get(bpd.id);
const bp = this._breakpoints.get(bpd.id);
if (bp) {
if (bp instanceof FunctionBreakpoint && bpd.type === 'function') {
const fbp = <any>bp;
@@ -554,7 +554,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
}
public async $provideDebugConfigurations(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<vscode.DebugConfiguration[]> {
let provider = this.getConfigProviderByHandle(configProviderHandle);
const provider = this.getConfigProviderByHandle(configProviderHandle);
if (!provider) {
return Promise.reject(new Error('no handler found'));
}
@@ -566,7 +566,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
}
public async $resolveDebugConfiguration(configProviderHandle: number, folderUri: UriComponents | undefined, debugConfiguration: vscode.DebugConfiguration): Promise<vscode.DebugConfiguration> {
let provider = this.getConfigProviderByHandle(configProviderHandle);
const provider = this.getConfigProviderByHandle(configProviderHandle);
if (!provider) {
return Promise.reject(new Error('no handler found'));
}
@@ -579,7 +579,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
// TODO@AW legacy
public async $legacyDebugAdapterExecutable(configProviderHandle: number, folderUri: UriComponents | undefined): Promise<IAdapterDescriptor> {
let provider = this.getConfigProviderByHandle(configProviderHandle);
const provider = this.getConfigProviderByHandle(configProviderHandle);
if (!provider) {
return Promise.reject(new Error('no handler found'));
}
@@ -591,7 +591,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
}
public async $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
let adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
const adapterProvider = this.getAdapterProviderByHandle(adapterProviderHandle);
if (!adapterProvider) {
return Promise.reject(new Error('no handler found'));
}

View File

@@ -37,7 +37,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
if (!this._isDisposed) {
this._onDidChangeDiagnostics.fire(keys(this._data));
this._proxy.$clear(this._owner);
this._data = undefined;
this._data = undefined!;
this._isDisposed = true;
}
}
@@ -85,7 +85,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
for (const tuple of first) {
const [uri, diagnostics] = tuple;
if (!lastUri || uri.toString() !== lastUri.toString()) {
if (lastUri && this._data.get(lastUri.toString()).length === 0) {
if (lastUri && this._data.get(lastUri.toString())!.length === 0) {
this._data.delete(lastUri.toString());
}
lastUri = uri;
@@ -95,9 +95,15 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
if (!diagnostics) {
// [Uri, undefined] means clear this
this._data.get(uri.toString()).length = 0;
const currentDiagnostics = this._data.get(uri.toString());
if (currentDiagnostics) {
currentDiagnostics.length = 0;
}
} else {
this._data.get(uri.toString()).push(...diagnostics);
const currentDiagnostics = this._data.get(uri.toString());
if (currentDiagnostics) {
currentDiagnostics.push(...diagnostics);
}
}
}
}
@@ -108,8 +114,8 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
// compute change and send to main side
const entries: [URI, IMarkerData[]][] = [];
for (let uri of toSync) {
let marker: IMarkerData[] | undefined;
let diagnostics = this._data.get(uri.toString());
let marker: IMarkerData[] = [];
const diagnostics = this._data.get(uri.toString());
if (diagnostics) {
// no more than N diagnostics per file
@@ -137,7 +143,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
endColumn: marker[marker.length - 1].endColumn
});
} else {
marker = diagnostics.map(converter.Diagnostic.from);
marker = diagnostics.map(diag => converter.Diagnostic.from(diag));
}
}
@@ -164,18 +170,18 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
forEach(callback: (uri: URI, diagnostics: vscode.Diagnostic[], collection: DiagnosticCollection) => any, thisArg?: any): void {
this._checkDisposed();
this._data.forEach((value, key) => {
let uri = URI.parse(key);
const uri = URI.parse(key);
callback.apply(thisArg, [uri, this.get(uri), this]);
});
}
get(uri: URI): vscode.Diagnostic[] {
this._checkDisposed();
let result = this._data.get(uri.toString());
const result = this._data.get(uri.toString());
if (Array.isArray(result)) {
return <vscode.Diagnostic[]>Object.freeze(result.slice(0));
}
return undefined;
return [];
}
has(uri: URI): boolean {
@@ -218,8 +224,8 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
}
static _mapper(last: (vscode.Uri | string)[]): { uris: vscode.Uri[] } {
let uris: vscode.Uri[] = [];
let map = new Set<string>();
const uris: vscode.Uri[] = [];
const map = new Set<string>();
for (const uri of last) {
if (typeof uri === 'string') {
if (!map.has(uri)) {
@@ -279,8 +285,8 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
if (resource) {
return this._getDiagnostics(resource);
} else {
let index = new Map<string, number>();
let res: [vscode.Uri, vscode.Diagnostic[]][] = [];
const index = new Map<string, number>();
const res: [vscode.Uri, vscode.Diagnostic[]][] = [];
this._collections.forEach(collection => {
collection.forEach((uri, diagnostics) => {
let idx = index.get(uri.toString());

View File

@@ -105,7 +105,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
}
private _getTextInRange(_range: vscode.Range): string {
let range = this._validateRange(_range);
const range = this._validateRange(_range);
if (range.isEmpty) {
return '';
@@ -115,7 +115,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
return this._lines[range.start.line].substring(range.start.character, range.end.character);
}
let lineEnding = this._eol,
const lineEnding = this._eol,
startLineIndex = range.start.line,
endLineIndex = range.end.line,
resultLines: string[] = [];
@@ -178,9 +178,9 @@ export class ExtHostDocumentData extends MirrorTextModel {
offset = Math.max(0, offset);
this._ensureLineStarts();
let out = this._lineStarts!.getIndexOf(offset);
const out = this._lineStarts!.getIndexOf(offset);
let lineLength = this._lines[out.index].length;
const lineLength = this._lines[out.index].length;
// Ensure we return a valid position
return new Position(out.index, Math.min(out.remainder, lineLength));
@@ -193,8 +193,8 @@ export class ExtHostDocumentData extends MirrorTextModel {
throw new Error('Invalid argument');
}
let start = this._validatePosition(range.start);
let end = this._validatePosition(range.end);
const start = this._validatePosition(range.start);
const end = this._validatePosition(range.end);
if (start === range.start && end === range.end) {
return range;
@@ -221,7 +221,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
hasChanged = true;
}
else {
let maxCharacter = this._lines[line].length;
const maxCharacter = this._lines[line].length;
if (character < 0) {
character = 0;
hasChanged = true;
@@ -239,7 +239,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
}
private _getWordRangeAtPosition(_position: vscode.Position, regexp?: RegExp): vscode.Range | undefined {
let position = this._validatePosition(_position);
const position = this._validatePosition(_position);
if (!regexp) {
// use default when custom-regexp isn't provided
@@ -251,7 +251,7 @@ export class ExtHostDocumentData extends MirrorTextModel {
regexp = getWordDefinitionFor(this._languageId);
}
let wordAtText = getWordAtText(
const wordAtText = getWordAtText(
position.character + 1,
ensureValidWordDefinition(regexp),
this._lines[position.line],

View File

@@ -53,14 +53,14 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic
const entries = this._callbacks.toArray();
let didTimeout = false;
let didTimeoutHandle = setTimeout(() => didTimeout = true, this._thresholds.timeout);
const didTimeoutHandle = setTimeout(() => didTimeout = true, this._thresholds.timeout);
const promise = sequence(entries.map(listener => {
return () => {
if (didTimeout) {
// timeout - no more listeners
return undefined;
return Promise.resolve();
}
const document = this._documents.getDocument(resource);
@@ -169,7 +169,6 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic
return this._mainThreadEditors.$tryApplyWorkspaceEdit({ edits: [resourceEdit] });
}
// TODO@joh bubble this to listener?
return Promise.reject(new Error('concurrent_edits'));
});
}

View File

@@ -77,7 +77,7 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
public ensureDocumentData(uri: URI): Promise<ExtHostDocumentData> {
let cached = this._documentsAndEditors.getDocument(uri);
const cached = this._documentsAndEditors.getDocument(uri);
if (cached) {
return Promise.resolve(cached);
}
@@ -103,8 +103,10 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
public $acceptModelModeChanged(uriComponents: UriComponents, oldModeId: string, newModeId: string): void {
const uri = URI.revive(uriComponents);
let data = this._documentsAndEditors.getDocument(uri);
const data = this._documentsAndEditors.getDocument(uri);
if (!data) {
throw new Error('unknown document');
}
// Treat a mode change as a remove + add
this._onDidRemoveDocument.fire(data.document);
@@ -114,14 +116,20 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
public $acceptModelSaved(uriComponents: UriComponents): void {
const uri = URI.revive(uriComponents);
let data = this._documentsAndEditors.getDocument(uri);
const data = this._documentsAndEditors.getDocument(uri);
if (!data) {
throw new Error('unknown document');
}
this.$acceptDirtyStateChanged(uriComponents, false);
this._onDidSaveDocument.fire(data.document);
}
public $acceptDirtyStateChanged(uriComponents: UriComponents, isDirty: boolean): void {
const uri = URI.revive(uriComponents);
let data = this._documentsAndEditors.getDocument(uri);
const data = this._documentsAndEditors.getDocument(uri);
if (!data) {
throw new Error('unknown document');
}
data._acceptIsDirty(isDirty);
this._onDidChangeDocument.fire({
document: data.document,
@@ -131,7 +139,10 @@ export class ExtHostDocuments implements ExtHostDocumentsShape {
public $acceptModelChanged(uriComponents: UriComponents, events: IModelChangedEvent, isDirty: boolean): void {
const uri = URI.revive(uriComponents);
let data = this._documentsAndEditors.getDocument(uri);
const data = this._documentsAndEditors.getDocument(uri);
if (!data) {
throw new Error('unknown document');
}
data._acceptIsDirty(isDirty);
data.onEvents(events);
this._onDidChangeDocument.fire({

View File

@@ -17,7 +17,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
private _disposables: Disposable[] = [];
private _activeEditorId: string;
private _activeEditorId: string | null;
private readonly _editors = new Map<string, ExtHostTextEditor>();
private readonly _documents = new Map<string, ExtHostDocumentData>();
@@ -25,12 +25,12 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
private readonly _onDidAddDocuments = new Emitter<ExtHostDocumentData[]>();
private readonly _onDidRemoveDocuments = new Emitter<ExtHostDocumentData[]>();
private readonly _onDidChangeVisibleTextEditors = new Emitter<ExtHostTextEditor[]>();
private readonly _onDidChangeActiveTextEditor = new Emitter<ExtHostTextEditor>();
private readonly _onDidChangeActiveTextEditor = new Emitter<ExtHostTextEditor | undefined>();
readonly onDidAddDocuments: Event<ExtHostDocumentData[]> = this._onDidAddDocuments.event;
readonly onDidRemoveDocuments: Event<ExtHostDocumentData[]> = this._onDidRemoveDocuments.event;
readonly onDidChangeVisibleTextEditors: Event<ExtHostTextEditor[]> = this._onDidChangeVisibleTextEditors.event;
readonly onDidChangeActiveTextEditor: Event<ExtHostTextEditor> = this._onDidChangeActiveTextEditor.event;
readonly onDidChangeActiveTextEditor: Event<ExtHostTextEditor | undefined> = this._onDidChangeActiveTextEditor.event;
constructor(
private readonly _mainContext: IMainContext,
@@ -93,14 +93,14 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
assert.ok(this._documents.has(resource.toString()), `document '${resource}' does not exist`);
assert.ok(!this._editors.has(data.id), `editor '${data.id}' already exists!`);
const documentData = this._documents.get(resource.toString());
const documentData = this._documents.get(resource.toString())!;
const editor = new ExtHostTextEditor(
this._mainContext.getProxy(MainContext.MainThreadTextEditors),
data.id,
documentData,
data.selections.map(typeConverters.Selection.to),
data.options,
data.visibleRanges.map(typeConverters.Range.to),
data.visibleRanges.map(range => typeConverters.Range.to(range)),
typeof data.editorPosition === 'number' ? typeConverters.ViewColumn.to(data.editorPosition) : undefined
);
this._editors.set(data.id, editor);
@@ -131,7 +131,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
}
}
getDocument(uri: URI): ExtHostDocumentData {
getDocument(uri: URI): ExtHostDocumentData | undefined {
return this._documents.get(uri.toString());
}
@@ -141,7 +141,7 @@ export class ExtHostDocumentsAndEditors implements ExtHostDocumentsAndEditorsSha
return result;
}
getEditor(id: string): ExtHostTextEditor {
getEditor(id: string): ExtHostTextEditor | undefined {
return this._editors.get(id);
}

View File

@@ -238,14 +238,14 @@ export class ExtensionsActivator {
if (this._alreadyActivatedEvents[activationEvent]) {
return NO_OP_VOID_PROMISE;
}
let activateExtensions = this._registry.getExtensionDescriptionsForActivationEvent(activationEvent);
const activateExtensions = this._registry.getExtensionDescriptionsForActivationEvent(activationEvent);
return this._activateExtensions(activateExtensions.map(e => e.identifier), reason).then(() => {
this._alreadyActivatedEvents[activationEvent] = true;
});
}
public activateById(extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<void> {
let desc = this._registry.getExtensionDescription(extensionId);
const desc = this._registry.getExtensionDescription(extensionId);
if (!desc) {
throw new Error('Extension `' + extensionId + '` is not known');
}
@@ -264,7 +264,7 @@ export class ExtensionsActivator {
}
const currentExtension = this._registry.getExtensionDescription(currentExtensionId)!;
let depIds = (typeof currentExtension.extensionDependencies === 'undefined' ? [] : currentExtension.extensionDependencies);
const depIds = (typeof currentExtension.extensionDependencies === 'undefined' ? [] : currentExtension.extensionDependencies);
let currentExtensionGetsGreenLight = true;
for (let j = 0, lenJ = depIds.length; j < lenJ; j++) {
@@ -330,7 +330,7 @@ export class ExtensionsActivator {
return Promise.resolve(undefined);
}
let greenMap: { [id: string]: ExtensionIdentifier; } = Object.create(null),
const greenMap: { [id: string]: ExtensionIdentifier; } = Object.create(null),
red: ExtensionIdentifier[] = [];
for (let i = 0, len = extensionIds.length; i < len; i++) {
@@ -345,7 +345,7 @@ export class ExtensionsActivator {
}
}
let green = Object.keys(greenMap).map(id => greenMap[id]);
const green = Object.keys(greenMap).map(id => greenMap[id]);
// console.log('greenExtensions: ', green.map(p => p.id));
// console.log('redExtensions: ', red.map(p => p.id));

View File

@@ -116,6 +116,9 @@ class ExtensionStoragePath {
return Promise.resolve(undefined);
}
if (!this._environment.appSettingsHome) {
return undefined;
}
const storageName = this._workspace.id;
const storagePath = path.join(this._environment.appSettingsHome.fsPath, 'workspaceStorage', storageName);
@@ -222,7 +225,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
actualActivateExtension: async (extensionId: ExtensionIdentifier, reason: ExtensionActivationReason): Promise<ActivatedExtension> => {
if (hostExtensions.has(ExtensionIdentifier.toKey(extensionId))) {
let activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
const activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
await this._mainThreadExtensionsProxy.$activateExtension(extensionId, activationEvent);
return new HostExtension();
}
@@ -342,7 +345,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
return result;
}
let extension = this._activator.getActivatedExtension(extensionId);
const extension = this._activator.getActivatedExtension(extensionId);
if (!extension) {
return result;
}
@@ -379,7 +382,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
this._mainThreadExtensionsProxy.$onWillActivateExtension(extensionDescription.identifier);
return this._doActivateExtension(extensionDescription, reason).then((activatedExtension) => {
const activationTimes = activatedExtension.activationTimes;
let activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
const activationEvent = (reason instanceof ExtensionActivatedByEvent ? reason.activationEvent : null);
this._mainThreadExtensionsProxy.$onDidActivateExtension(extensionDescription.identifier, activationTimes.startup, activationTimes.codeLoadingTime, activationTimes.activateCallTime, activationTimes.activateResolvedTime, activationEvent);
this._logExtensionActivationTimes(extensionDescription, reason, 'success', activationTimes);
return activatedExtension;
@@ -391,7 +394,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
}
private _logExtensionActivationTimes(extensionDescription: IExtensionDescription, reason: ExtensionActivationReason, outcome: string, activationTimes?: ExtensionActivationTimes) {
let event = getTelemetryActivationEvent(extensionDescription, reason);
const event = getTelemetryActivationEvent(extensionDescription, reason);
/* __GDPR__
"extensionActivationTimes" : {
"${include}": [
@@ -409,7 +412,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
}
private _doActivateExtension(extensionDescription: IExtensionDescription, reason: ExtensionActivationReason): Promise<ActivatedExtension> {
let event = getTelemetryActivationEvent(extensionDescription, reason);
const event = getTelemetryActivationEvent(extensionDescription, reason);
/* __GDPR__
"activatePlugin" : {
"${include}": [
@@ -436,8 +439,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
private _loadExtensionContext(extensionDescription: IExtensionDescription): Promise<IExtensionContext> {
let globalState = new ExtensionMemento(extensionDescription.identifier.value, true, this._storage);
let workspaceState = new ExtensionMemento(extensionDescription.identifier.value, false, this._storage);
const globalState = new ExtensionMemento(extensionDescription.identifier.value, true, this._storage);
const workspaceState = new ExtensionMemento(extensionDescription.identifier.value, false, this._storage);
this._extHostLogService.trace(`ExtensionService#loadExtensionContext ${extensionDescription.identifier.value}`);
return Promise.all([
@@ -760,7 +763,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape {
}
public async $test_down(size: number): Promise<Buffer> {
let b = Buffer.alloc(size, Math.random() % 256);
const b = Buffer.alloc(size, Math.random() % 256);
return b;
}
@@ -796,7 +799,7 @@ function getTelemetryActivationEvent(extensionDescription: IExtensionDescription
"reason": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
let event = {
const event = {
id: extensionDescription.identifier.value,
name: extensionDescription.name,
extensionVersion: extensionDescription.version,

View File

@@ -20,7 +20,7 @@ import { CharCode } from 'vs/base/common/charCode';
class FsLinkProvider {
private _schemes: string[] = [];
private _stateMachine: StateMachine;
private _stateMachine?: StateMachine;
add(scheme: string): void {
this._stateMachine = undefined;
@@ -28,7 +28,7 @@ class FsLinkProvider {
}
delete(scheme: string): void {
let idx = this._schemes.indexOf(scheme);
const idx = this._schemes.indexOf(scheme);
if (idx >= 0) {
this._schemes.splice(idx, 1);
this._stateMachine = undefined;
@@ -94,7 +94,7 @@ class FsLinkProvider {
}, this._stateMachine);
for (const link of links) {
let docLink = typeConverter.DocumentLink.to(link);
const docLink = typeConverter.DocumentLink.to(link);
if (docLink.target) {
result.push(docLink);
}
@@ -172,7 +172,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
this._proxy.$registerFileSystemProvider(handle, scheme, capabilites);
const subscription = provider.onDidChangeFile(event => {
let mapped: IFileChangeDto[] = [];
const mapped: IFileChangeDto[] = [];
for (const e of event) {
let { uri: resource, type } = e;
if (resource.scheme !== scheme) {
@@ -190,6 +190,8 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
case FileChangeType.Deleted:
newType = files.FileChangeType.DELETED;
break;
default:
throw new Error('Unknown FileChangeType');
}
mapped.push({ resource, type: newType });
}
@@ -219,65 +221,51 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
return { type, ctime, mtime, size };
}
private _checkProviderExists(handle: number): void {
if (!this._fsProvider.has(handle)) {
const err = new Error();
err.name = 'ENOPRO';
err.message = `no provider`;
throw err;
}
}
$stat(handle: number, resource: UriComponents): Promise<files.IStat> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).stat(URI.revive(resource))).then(ExtHostFileSystem._asIStat);
return Promise.resolve(this.getProvider(handle).stat(URI.revive(resource))).then(ExtHostFileSystem._asIStat);
}
$readdir(handle: number, resource: UriComponents): Promise<[string, files.FileType][]> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).readDirectory(URI.revive(resource)));
return Promise.resolve(this.getProvider(handle).readDirectory(URI.revive(resource)));
}
$readFile(handle: number, resource: UriComponents): Promise<Buffer> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).readFile(URI.revive(resource))).then(data => {
return Promise.resolve(this.getProvider(handle).readFile(URI.revive(resource))).then(data => {
return Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
});
}
$writeFile(handle: number, resource: UriComponents, content: Buffer, opts: files.FileWriteOptions): Promise<void> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).writeFile(URI.revive(resource), content, opts));
return Promise.resolve(this.getProvider(handle).writeFile(URI.revive(resource), content, opts));
}
$delete(handle: number, resource: UriComponents, opts: files.FileDeleteOptions): Promise<void> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).delete(URI.revive(resource), opts));
return Promise.resolve(this.getProvider(handle).delete(URI.revive(resource), opts));
}
$rename(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): Promise<void> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts));
return Promise.resolve(this.getProvider(handle).rename(URI.revive(oldUri), URI.revive(newUri), opts));
}
$copy(handle: number, oldUri: UriComponents, newUri: UriComponents, opts: files.FileOverwriteOptions): Promise<void> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).copy(URI.revive(oldUri), URI.revive(newUri), opts));
const provider = this.getProvider(handle);
if (!provider.copy) {
throw new Error('FileSystemProvider does not implement "copy"');
}
return Promise.resolve(provider.copy(URI.revive(oldUri), URI.revive(newUri), opts));
}
$mkdir(handle: number, resource: UriComponents): Promise<void> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).createDirectory(URI.revive(resource)));
return Promise.resolve(this.getProvider(handle).createDirectory(URI.revive(resource)));
}
$watch(handle: number, session: number, resource: UriComponents, opts: files.IWatchOptions): void {
this._checkProviderExists(handle);
let subscription = this._fsProvider.get(handle).watch(URI.revive(resource), opts);
const subscription = this.getProvider(handle).watch(URI.revive(resource), opts);
this._watches.set(session, subscription);
}
$unwatch(_handle: number, session: number): void {
let subscription = this._watches.get(session);
const subscription = this._watches.get(session);
if (subscription) {
subscription.dispose();
this._watches.delete(session);
@@ -285,26 +273,48 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
}
$open(handle: number, resource: UriComponents, opts: files.FileOpenOptions): Promise<number> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).open(URI.revive(resource), opts));
const provider = this.getProvider(handle);
if (!provider.open) {
throw new Error('FileSystemProvider does not implement "open"');
}
return Promise.resolve(provider.open(URI.revive(resource), opts));
}
$close(handle: number, fd: number): Promise<void> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).close(fd));
const provider = this.getProvider(handle);
if (!provider.close) {
throw new Error('FileSystemProvider does not implement "close"');
}
return Promise.resolve(provider.close(fd));
}
$read(handle: number, fd: number, pos: number, length: number): Promise<Buffer> {
this._checkProviderExists(handle);
const provider = this.getProvider(handle);
if (!provider.read) {
throw new Error('FileSystemProvider does not implement "read"');
}
const data = Buffer.allocUnsafe(length);
return Promise.resolve(this._fsProvider.get(handle).read(fd, pos, data, 0, length)).then(read => {
return Promise.resolve(provider.read(fd, pos, data, 0, length)).then(read => {
return data.slice(0, read); // don't send zeros
});
}
$write(handle: number, fd: number, pos: number, data: Buffer): Promise<number> {
this._checkProviderExists(handle);
return Promise.resolve(this._fsProvider.get(handle).write(fd, pos, data, 0, data.length));
const provider = this.getProvider(handle);
if (!provider.write) {
throw new Error('FileSystemProvider does not implement "write"');
}
return Promise.resolve(provider.write(fd, pos, data, 0, data.length));
}
private getProvider(handle: number): vscode.FileSystemProvider {
const provider = this._fsProvider.get(handle);
if (!provider) {
const err = new Error();
err.name = 'ENOPRO';
err.message = `no provider`;
throw err;
}
return provider;
}
}

View File

@@ -49,10 +49,10 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
const parsedPattern = parse(globPattern);
let subscription = dispatcher(events => {
const subscription = dispatcher(events => {
if (!ignoreCreateEvents) {
for (let created of events.created) {
let uri = URI.revive(created);
const uri = URI.revive(created);
if (parsedPattern(uri.fsPath)) {
this._onDidCreate.fire(uri);
}
@@ -60,7 +60,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
}
if (!ignoreChangeEvents) {
for (let changed of events.changed) {
let uri = URI.revive(changed);
const uri = URI.revive(changed);
if (parsedPattern(uri.fsPath)) {
this._onDidChange.fire(uri);
}
@@ -68,7 +68,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
}
if (!ignoreDeleteEvents) {
for (let deleted of events.deleted) {
let uri = URI.revive(deleted);
const uri = URI.revive(deleted);
if (parsedPattern(uri.fsPath)) {
this._onDidDelete.fire(uri);
}
@@ -169,7 +169,7 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
}
// flatten all WorkspaceEdits collected via waitUntil-call
// and apply them in one go.
let allEdits = new Array<Array<ResourceFileEditDto | ResourceTextEditDto>>();
const allEdits = new Array<Array<ResourceFileEditDto | ResourceTextEditDto>>();
for (let edit of edits) {
if (edit) { // sparse array
let { edits } = typeConverter.WorkspaceEdit.from(edit, this._extHostDocumentsAndEditors);

View File

@@ -65,10 +65,10 @@ class DocumentSymbolAdapter {
}
return res;
});
let res: modes.DocumentSymbol[] = [];
let parentStack: modes.DocumentSymbol[] = [];
const res: modes.DocumentSymbol[] = [];
const parentStack: modes.DocumentSymbol[] = [];
for (const info of infos) {
let element = <modes.DocumentSymbol>{
const element = <modes.DocumentSymbol>{
name: info.name || '!!MISSING: name!!',
kind: typeConvert.SymbolKind.from(info.kind),
containerName: info.containerName,
@@ -83,7 +83,7 @@ class DocumentSymbolAdapter {
res.push(element);
break;
}
let parent = parentStack[parentStack.length - 1];
const parent = parentStack[parentStack.length - 1];
if (EditorRange.containsRange(parent.range, element.range) && !EditorRange.equalsRange(parent.range, element.range)) {
parent.children.push(element);
parentStack.push(element);
@@ -111,7 +111,7 @@ class CodeLensAdapter {
const doc = this._documents.getDocument(resource);
return asPromise(() => this._provider.provideCodeLenses(doc, token)).then(lenses => {
let result: CodeLensDto[] = [];
const result: CodeLensDto[] = [];
if (isNonEmptyArray(lenses)) {
for (const lens of lenses) {
const id = this._heapService.keep(lens);
@@ -206,7 +206,7 @@ class DefinitionAdapter {
provideDefinition(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideDefinition(doc, pos, token)).then(convertToLocationLinks);
}
}
@@ -220,7 +220,7 @@ class DeclarationAdapter {
provideDeclaration(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideDeclaration(doc, pos, token)).then(convertToLocationLinks);
}
}
@@ -234,7 +234,7 @@ class ImplementationAdapter {
provideImplementation(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.LocationLink[]> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideImplementation(doc, pos, token)).then(convertToLocationLinks);
}
}
@@ -263,7 +263,7 @@ class HoverAdapter {
public provideHover(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.Hover | undefined> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideHover(doc, pos, token)).then(value => {
if (!value || isFalsyOrEmpty(value.contents)) {
@@ -291,7 +291,7 @@ class DocumentHighlightAdapter {
provideDocumentHighlights(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DocumentHighlight[] | undefined> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideDocumentHighlights(doc, pos, token)).then(value => {
if (Array.isArray(value)) {
@@ -311,7 +311,7 @@ class ReferenceAdapter {
provideReferences(resource: URI, position: IPosition, context: modes.ReferenceContext, token: CancellationToken): Promise<modes.Location[] | undefined> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideReferences(doc, pos, context, token)).then(value => {
if (Array.isArray(value)) {
@@ -546,7 +546,7 @@ class RenameAdapter {
provideRenameEdits(resource: URI, position: IPosition, newName: string, token: CancellationToken): Promise<WorkspaceEditDto | undefined> {
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.provideRenameEdits(doc, pos, newName, token)).then(value => {
if (!value) {
@@ -554,7 +554,7 @@ class RenameAdapter {
}
return typeConvert.WorkspaceEdit.from(value);
}, err => {
let rejectReason = RenameAdapter._asMessage(err);
const rejectReason = RenameAdapter._asMessage(err);
if (rejectReason) {
return <WorkspaceEditDto>{ rejectReason, edits: undefined! };
} else {
@@ -570,7 +570,7 @@ class RenameAdapter {
}
const doc = this._documents.getDocument(resource);
let pos = typeConvert.Position.to(position);
const pos = typeConvert.Position.to(position);
return asPromise(() => this._provider.prepareRename!(doc, pos, token)).then(rangeOrLocation => {
@@ -594,7 +594,7 @@ class RenameAdapter {
}
return { range: typeConvert.Range.from(range), text };
}, err => {
let rejectReason = RenameAdapter._asMessage(err);
const rejectReason = RenameAdapter._asMessage(err);
if (rejectReason) {
return <modes.RenameLocation & modes.Rejection>{ rejectReason, range: undefined!, text: undefined! };
} else {
@@ -832,8 +832,8 @@ class LinkProviderAdapter {
}
const result: LinkDto[] = [];
for (const link of links) {
let data = typeConvert.DocumentLink.from(link);
let id = this._heapService.keep(link);
const data = typeConvert.DocumentLink.from(link);
const id = this._heapService.keep(link);
result.push(ObjectIdentifier.mixin(data, id));
}
return result;
@@ -936,7 +936,7 @@ class SelectionRangeAdapter {
return [];
}
let allResults: modes.SelectionRange[][] = [];
const allResults: modes.SelectionRange[][] = [];
for (let i = 0; i < positions.length; i++) {
const oneResult: modes.SelectionRange[] = [];
allResults.push(oneResult);
@@ -1065,7 +1065,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
t1 = Date.now();
this._logService.trace(`[${data.extension.identifier.value}] INVOKE provider '${(ctor as any).name}'`);
}
let p = callback(data.adapter, data.extension);
const p = callback(data.adapter, data.extension);
const extension = data.extension;
if (extension) {
Promise.resolve(p).then(
@@ -1081,7 +1081,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
return Promise.reject(new Error('no adapter found'));
}
private _addNewAdapter(adapter: Adapter, extension: IExtensionDescription): number {
private _addNewAdapter(adapter: Adapter, extension: IExtensionDescription | undefined): number {
const handle = this._nextHandle();
this._adapter.set(handle, new AdapterData(adapter, extension));
return handle;
@@ -1358,7 +1358,7 @@ export class ExtHostLanguageFeatures implements ExtHostLanguageFeaturesShape {
// --- links
registerDocumentLinkProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
registerDocumentLinkProvider(extension: IExtensionDescription | undefined, selector: vscode.DocumentSelector, provider: vscode.DocumentLinkProvider): vscode.Disposable {
const handle = this._addNewAdapter(new LinkProviderAdapter(this._documents, this._heapService, provider), extension);
this._proxy.$registerDocumentLinkProvider(handle, this._transformDocumentSelector(selector));
return this._createDisposable(handle);

View File

@@ -24,7 +24,7 @@ export class ExtHostMessageService {
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | vscode.MessageItem, rest: vscode.MessageItem[]): Promise<vscode.MessageItem | undefined>;
showMessage(extension: IExtensionDescription, severity: Severity, message: string, optionsOrFirstItem: vscode.MessageOptions | string | vscode.MessageItem, rest: (string | vscode.MessageItem)[]): Promise<string | vscode.MessageItem | undefined> {
let options: MainThreadMessageOptions = { extension };
const options: MainThreadMessageOptions = { extension };
let items: (string | vscode.MessageItem)[];
if (typeof optionsOrFirstItem === 'string' || isMessageItem(optionsOrFirstItem)) {
@@ -37,7 +37,7 @@ export class ExtHostMessageService {
const commands: { title: string; isCloseAffordance: boolean; handle: number; }[] = [];
for (let handle = 0; handle < items.length; handle++) {
let command = items[handle];
const command = items[handle];
if (typeof command === 'string') {
commands.push({ title: command, handle, isCloseAffordance: false });
} else if (typeof command === 'object') {

View File

@@ -7,7 +7,7 @@ import { MainContext, MainThreadOutputServiceShape, IMainContext, ExtHostOutputS
import * as vscode from 'vscode';
import { URI } from 'vs/base/common/uri';
import { join } from 'vs/base/common/path';
import { OutputAppender } from 'vs/workbench/contrib/output/node/outputAppender';
import { OutputAppender } from 'vs/workbench/services/output/node/outputAppender';
import { toLocalISOString } from 'vs/base/common/date';
import { Event, Emitter } from 'vs/base/common/event';
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';

View File

@@ -15,6 +15,7 @@ import { URI } from 'vs/base/common/uri';
import { ThemeIcon, QuickInputButtons } from 'vs/workbench/api/node/extHostTypes';
import { isPromiseCanceledError } from 'vs/base/common/errors';
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { coalesce } from 'vs/base/common/arrays';
export type Item = string | QuickPickItem;
@@ -24,7 +25,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
private _workspace: IExtHostWorkspaceProvider;
private _commands: ExtHostCommands;
private _onDidSelectItem: (handle: number) => void;
private _onDidSelectItem?: (handle: number) => void;
private _validateInput?: (input: string) => string | undefined | null | Thenable<string | undefined | null>;
private _sessions = new Map<number, ExtHostQuickInput>();
@@ -67,10 +68,10 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
return itemsPromise.then(items => {
let pickItems: TransferQuickPickItems[] = [];
const pickItems: TransferQuickPickItems[] = [];
for (let handle = 0; handle < items.length; handle++) {
let item = items[handle];
const item = items[handle];
let label: string;
let description: string | undefined;
let detail: string | undefined;
@@ -158,12 +159,15 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
// ---- workspace folder picker
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder> {
showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions, token = CancellationToken.None): Promise<WorkspaceFolder | undefined> {
return this._commands.executeCommand('_workbench.pickWorkspaceFolder', [options]).then(async (selectedFolder: WorkspaceFolder) => {
if (!selectedFolder) {
return undefined;
}
const workspaceFolders = await this._workspace.getWorkspaceFolders2();
if (!workspaceFolders) {
return undefined;
}
return workspaceFolders.filter(folder => folder.uri.toString() === selectedFolder.uri.toString())[0];
});
}
@@ -382,7 +386,9 @@ class ExtHostQuickInput implements QuickInput {
_fireDidTriggerButton(handle: number) {
const button = this._handlesToButtons.get(handle);
this._onDidTriggerButtonEmitter.fire(button);
if (button) {
this._onDidTriggerButtonEmitter.fire(button);
}
}
_fireDidHide() {
@@ -437,9 +443,13 @@ class ExtHostQuickInput implements QuickInput {
}
}
function getIconUris(iconPath: QuickInputButton['iconPath']) {
function getIconUris(iconPath: QuickInputButton['iconPath']): { dark: URI, light?: URI } | undefined {
const dark = getDarkIconUri(iconPath);
const light = getLightIconUri(iconPath);
return { dark: getDarkIconUri(iconPath) || light, light };
if (!light && !dark) {
return undefined;
}
return { dark: (dark || light)!, light };
}
function getLightIconUri(iconPath: QuickInputButton['iconPath']) {
@@ -563,13 +573,13 @@ class ExtHostQuickPick<T extends QuickPickItem> extends ExtHostQuickInput implem
onDidChangeSelection = this._onDidChangeSelectionEmitter.event;
_fireDidChangeActive(handles: number[]) {
const items = handles.map(handle => this._handlesToItems.get(handle));
const items = coalesce(handles.map(handle => this._handlesToItems.get(handle)));
this._activeItems = items;
this._onDidChangeActiveEmitter.fire(items);
}
_fireDidChangeSelection(handles: number[]) {
const items = handles.map(handle => this._handlesToItems.get(handle));
const items = coalesce(handles.map(handle => this._handlesToItems.get(handle)));
this._selectedItems = items;
this._onDidChangeSelectionEmitter.fire(items);
}

View File

@@ -10,7 +10,7 @@ import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { asPromise } from 'vs/base/common/async';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands';
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape } from './extHost.protocol';
import { MainContext, MainThreadSCMShape, SCMRawResource, SCMRawResourceSplice, SCMRawResourceSplices, IMainContext, ExtHostSCMShape, CommandDto } from './extHost.protocol';
import { sortedDiff } from 'vs/base/common/arrays';
import { comparePaths } from 'vs/base/common/comparers';
import * as vscode from 'vscode';
@@ -23,7 +23,7 @@ type ProviderHandle = number;
type GroupHandle = number;
type ResourceStateHandle = number;
function getIconPath(decorations: vscode.SourceControlResourceThemableDecorations) {
function getIconPath(decorations?: vscode.SourceControlResourceThemableDecorations): string | undefined {
if (!decorations) {
return undefined;
} else if (typeof decorations.iconPath === 'string') {
@@ -60,7 +60,7 @@ function compareResourceStatesDecorations(a: vscode.SourceControlResourceDecorat
}
if (a.tooltip !== b.tooltip) {
return (a.tooltip || '').localeCompare(b.tooltip);
return (a.tooltip || '').localeCompare(b.tooltip || '');
}
result = compareResourceThemableDecorations(a, b);
@@ -205,7 +205,7 @@ export class ExtHostSCMInputBox implements vscode.SourceControlInputBox {
return this._visible;
}
set visible(visible: boolean | undefined) {
set visible(visible: boolean) {
visible = !!visible;
this._visible = visible;
this._proxy.$setInputBoxVisibility(this._sourceControlHandle, visible);
@@ -287,7 +287,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
return Promise.resolve(undefined);
}
return asPromise(() => this._commands.executeCommand(command.command, ...command.arguments));
return asPromise(() => this._commands.executeCommand(command.command, ...(command.arguments || [])));
}
_takeResourceStateSnapshot(): SCMRawResourceSplice[] {
@@ -309,11 +309,11 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
this._resourceStatesCommandsMap.set(handle, r.command);
}
if (lightIconPath || darkIconPath) {
if (lightIconPath) {
icons.push(lightIconPath);
}
if (darkIconPath !== lightIconPath) {
if (darkIconPath && (darkIconPath !== lightIconPath)) {
icons.push(darkIconPath);
}
@@ -442,7 +442,7 @@ class ExtHostSourceControl implements vscode.SourceControl {
this._statusBarCommands = statusBarCommands;
const internal = (statusBarCommands || []).map(c => this._commands.converter.toInternal(c));
const internal = (statusBarCommands || []).map(c => this._commands.converter.toInternal(c)) as CommandDto[];
this._proxy.$updateSourceControl(this.handle, { statusBarCommands: internal });
}
@@ -599,14 +599,12 @@ export class ExtHostSCM implements ExtHostSCMShape {
}
// Deprecated
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox {
getLastInputBox(extension: IExtensionDescription): ExtHostSCMInputBox | undefined {
this.logService.trace('ExtHostSCM#getLastInputBox', extension.identifier.value);
const sourceControls = this._sourceControlsByExtension.get(ExtensionIdentifier.toKey(extension.identifier));
const sourceControl = sourceControls && sourceControls[sourceControls.length - 1];
const inputBox = sourceControl && sourceControl.inputBox;
return inputBox;
return sourceControl && sourceControl.inputBox;
}
$provideOriginalResource(sourceControlHandle: number, uriComponents: UriComponents, token: CancellationToken): Promise<UriComponents | null> {
@@ -615,11 +613,12 @@ export class ExtHostSCM implements ExtHostSCMShape {
const sourceControl = this._sourceControls.get(sourceControlHandle);
if (!sourceControl || !sourceControl.quickDiffProvider) {
if (!sourceControl || !sourceControl.quickDiffProvider || !sourceControl.quickDiffProvider.provideOriginalResource) {
return Promise.resolve(null);
}
return asPromise(() => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
return asPromise(() => sourceControl.quickDiffProvider!.provideOriginalResource!(uri, token))
.then<UriComponents | null>(r => r || null);
}
$onInputBoxValueChange(sourceControlHandle: number, value: string): Promise<void> {

View File

@@ -116,7 +116,7 @@ export class FileIndexSearchEngine {
}
private searchInFolder(fq: IFolderQuery<URI>, onResult: (match: IInternalFileMatch) => void): Promise<IFileIndexProviderStats> {
let cancellation = new CancellationTokenSource();
const cancellation = new CancellationTokenSource();
return new Promise((resolve, reject) => {
const options = this.getSearchOptionsForFolder(fq);
const tree = this.initDirectoryTree();
@@ -511,10 +511,10 @@ export class FileIndexSearchManager {
}
// Pattern match on results
let results: IInternalFileMatch[] = [];
const results: IInternalFileMatch[] = [];
const normalizedSearchValueLowercase = strings.stripWildcards(searchValue).toLowerCase();
for (let i = 0; i < complete.results.length; i++) {
let entry = complete.results[i];
const entry = complete.results[i];
// Check if this entry is a match for the search value
if (!strings.fuzzyContains(entry.relativePath!, normalizedSearchValueLowercase)) {

View File

@@ -139,7 +139,7 @@ class StatusBarMessage {
this._update();
return new Disposable(() => {
let idx = this._messages.indexOf(data);
const idx = this._messages.indexOf(data);
if (idx >= 0) {
this._messages.splice(idx, 1);
this._update();
@@ -173,7 +173,7 @@ export class ExtHostStatusBar {
setStatusBarMessage(text: string, timeoutOrThenable?: number | Thenable<any>): Disposable {
let d = this._statusMessage.setMessage(text);
const d = this._statusMessage.setMessage(text);
let handle: any;
if (typeof timeoutOrThenable === 'number') {

View File

@@ -75,14 +75,14 @@ namespace ProcessExecutionOptionsDTO {
namespace ProcessExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO): value is ProcessExecutionDTO {
let candidate = value as ProcessExecutionDTO;
const candidate = value as ProcessExecutionDTO;
return candidate && !!candidate.process;
}
export function from(value: vscode.ProcessExecution): ProcessExecutionDTO {
if (value === undefined || value === null) {
return undefined;
}
let result: ProcessExecutionDTO = {
const result: ProcessExecutionDTO = {
process: value.process,
args: value.args
};
@@ -116,14 +116,14 @@ namespace ShellExecutionOptionsDTO {
namespace ShellExecutionDTO {
export function is(value: ShellExecutionDTO | ProcessExecutionDTO): value is ShellExecutionDTO {
let candidate = value as ShellExecutionDTO;
const candidate = value as ShellExecutionDTO;
return candidate && (!!candidate.commandLine || !!candidate.command);
}
export function from(value: vscode.ShellExecution): ShellExecutionDTO {
if (value === undefined || value === null) {
return undefined;
}
let result: ShellExecutionDTO = {
const result: ShellExecutionDTO = {
};
if (value.commandLine !== undefined) {
result.commandLine = value.commandLine;
@@ -167,9 +167,9 @@ namespace TaskDTO {
if (tasks === undefined || tasks === null) {
return [];
}
let result: TaskDTO[] = [];
const result: TaskDTO[] = [];
for (let task of tasks) {
let converted = from(task, extension);
const converted = from(task, extension);
if (converted) {
result.push(converted);
}
@@ -187,7 +187,7 @@ namespace TaskDTO {
} else if (value.execution instanceof types.ShellExecution) {
execution = ShellExecutionDTO.from(value.execution);
}
let definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
const definition: TaskDefinitionDTO = TaskDefinitionDTO.from(value.definition);
let scope: number | UriComponents;
if (value.scope) {
if (typeof value.scope === 'number') {
@@ -202,8 +202,8 @@ namespace TaskDTO {
if (!definition || !scope) {
return undefined;
}
let group = (value.group as types.TaskGroup) ? (value.group as types.TaskGroup).id : undefined;
let result: TaskDTO = {
const group = (value.group as types.TaskGroup) ? (value.group as types.TaskGroup).id : undefined;
const result: TaskDTO = {
_id: (value as types.Task)._id,
definition,
name: value.name,
@@ -232,7 +232,7 @@ namespace TaskDTO {
} else if (ShellExecutionDTO.is(value.execution)) {
execution = ShellExecutionDTO.to(value.execution);
}
let definition: vscode.TaskDefinition = TaskDefinitionDTO.to(value.definition);
const definition: vscode.TaskDefinition = TaskDefinitionDTO.to(value.definition);
let scope: vscode.TaskScope.Global | vscode.TaskScope.Workspace | vscode.WorkspaceFolder | undefined;
if (value.source) {
if (value.source.scope !== undefined) {
@@ -248,7 +248,7 @@ namespace TaskDTO {
if (!definition || !scope) {
return undefined;
}
let result = new types.Task(definition, scope, value.name, value.source.label, execution, value.problemMatchers);
const result = new types.Task(definition, scope, value.name, value.source.label, execution, value.problemMatchers);
if (value.isBackground !== undefined) {
result.isBackground = value.isBackground;
}
@@ -345,7 +345,7 @@ export class ExtHostTask implements ExtHostTaskShape {
if (!provider) {
return new types.Disposable(() => { });
}
let handle = this.nextHandle();
const handle = this.nextHandle();
this._handlers.set(handle, { provider, extension });
this._proxy.$registerTaskProvider(handle);
return new types.Disposable(() => {
@@ -360,9 +360,9 @@ export class ExtHostTask implements ExtHostTaskShape {
public fetchTasks(filter?: vscode.TaskFilter): Promise<vscode.Task[]> {
return this._proxy.$fetchTasks(TaskFilterDTO.from(filter)).then(async (values) => {
let result: vscode.Task[] = [];
const result: vscode.Task[] = [];
for (let value of values) {
let task = await TaskDTO.to(value, this._workspaceProvider);
const task = await TaskDTO.to(value, this._workspaceProvider);
if (task) {
result.push(task);
}
@@ -372,12 +372,12 @@ export class ExtHostTask implements ExtHostTaskShape {
}
public async executeTask(extension: IExtensionDescription, task: vscode.Task): Promise<vscode.TaskExecution> {
let tTask = (task as types.Task);
const tTask = (task as types.Task);
// We have a preserved ID. So the task didn't change.
if (tTask._id !== undefined) {
return this._proxy.$executeTask(TaskHandleDTO.from(tTask)).then(value => this.getTaskExecution(value, task));
} else {
let dto = TaskDTO.from(task, extension);
const dto = TaskDTO.from(task, extension);
if (dto === undefined) {
return Promise.reject(new Error('Task is not valid'));
}
@@ -386,7 +386,7 @@ export class ExtHostTask implements ExtHostTaskShape {
}
public get taskExecutions(): vscode.TaskExecution[] {
let result: vscode.TaskExecution[] = [];
const result: vscode.TaskExecution[] = [];
this._taskExecutions.forEach(value => result.push(value));
return result;
}
@@ -449,12 +449,12 @@ export class ExtHostTask implements ExtHostTaskShape {
}
public $provideTasks(handle: number, validTypes: { [key: string]: boolean; }): Thenable<TaskSetDTO> {
let handler = this._handlers.get(handle);
const handler = this._handlers.get(handle);
if (!handler) {
return Promise.reject(new Error('no handler found'));
}
return asPromise(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
let sanitized: vscode.Task[] = [];
const sanitized: vscode.Task[] = [];
for (let task of value) {
if (task.definition && validTypes[task.definition.type] === true) {
sanitized.push(task);
@@ -472,15 +472,15 @@ export class ExtHostTask implements ExtHostTaskShape {
public async $resolveVariables(uriComponents: UriComponents, toResolve: { process?: { name: string; cwd?: string; path?: string }, variables: string[] }): Promise<{ process?: string, variables: { [key: string]: string; } }> {
const configProvider = await this._configurationService.getConfigProvider();
let uri: URI = URI.revive(uriComponents);
let result = {
const uri: URI = URI.revive(uriComponents);
const result = {
process: undefined as string,
variables: Object.create(null)
};
let workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(uri);
const workspaceFolder = await this._workspaceProvider.resolveWorkspaceFolder(uri);
const workspaceFolders = await this._workspaceProvider.getWorkspaceFolders2();
let resolver = new ExtHostVariableResolverService(workspaceFolders, this._editorService, configProvider);
let ws: IWorkspaceFolder = {
const resolver = new ExtHostVariableResolverService(workspaceFolders, this._editorService, configProvider);
const ws: IWorkspaceFolder = {
uri: workspaceFolder.uri,
name: workspaceFolder.name,
index: workspaceFolder.index,

View File

@@ -4,17 +4,19 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import pkg from 'vs/platform/product/node/package';
import * as os from 'os';
import { URI, UriComponents } from 'vs/base/common/uri';
import * as platform from 'vs/base/common/platform';
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/node/terminalEnvironment';
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
import { Event, Emitter } from 'vs/base/common/event';
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, IMainContext, ShellLaunchConfigDto } from 'vs/workbench/api/node/extHost.protocol';
import { ExtHostConfiguration } from 'vs/workbench/api/node/extHostConfiguration';
import { ILogService } from 'vs/platform/log/common/log';
import { EXT_HOST_CREATION_DELAY } from 'vs/workbench/contrib/terminal/common/terminal';
import { EXT_HOST_CREATION_DELAY, IShellLaunchConfig } from 'vs/workbench/contrib/terminal/common/terminal';
import { TerminalProcess } from 'vs/workbench/contrib/terminal/node/terminalProcess';
import { timeout } from 'vs/base/common/async';
import { sanitizeProcessEnvironment } from 'vs/base/node/processes';
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';
const RENDERER_NO_PROCESS_ID = -1;
@@ -409,7 +411,15 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
}
}
public async $createProcess(id: number, shellLaunchConfig: ShellLaunchConfigDto, activeWorkspaceRootUriComponents: UriComponents, cols: number, rows: number): Promise<void> {
public async $createProcess(id: number, shellLaunchConfigDto: ShellLaunchConfigDto, activeWorkspaceRootUriComponents: UriComponents, cols: number, rows: number): Promise<void> {
const shellLaunchConfig: IShellLaunchConfig = {
name: shellLaunchConfigDto.name,
executable: shellLaunchConfigDto.executable,
args: shellLaunchConfigDto.args,
cwd: typeof shellLaunchConfigDto.cwd === 'string' ? shellLaunchConfigDto.cwd : URI.revive(shellLaunchConfigDto.cwd),
env: shellLaunchConfigDto.env
};
// TODO: This function duplicates a lot of TerminalProcessManager.createProcess, ideally
// they would be merged into a single implementation.
const configProvider = await this._extHostConfiguration.getConfigProvider();
@@ -429,7 +439,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
// TODO: @daniel
const activeWorkspaceRootUri = URI.revive(activeWorkspaceRootUriComponents);
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, activeWorkspaceRootUri, terminalConfig.cwd);
const initialCwd = terminalEnvironment.getCwd(shellLaunchConfig, os.homedir(), activeWorkspaceRootUri, terminalConfig.cwd);
// TODO: Pull in and resolve config settings
// // Resolve env vars from config and shell
@@ -450,7 +460,7 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
// Continue env initialization, merging in the env from the launch
// config and adding keys that are needed to create the process
terminalEnvironment.addTerminalEnvironmentKeys(env, platform.locale, terminalConfig.get('setLocaleVariables'));
terminalEnvironment.addTerminalEnvironmentKeys(env, pkg.version, platform.locale, terminalConfig.get('setLocaleVariables'));
// Fork the process and listen for messages
this._logService.debug(`Terminal process launching on ext host`, shellLaunchConfig, initialCwd, cols, rows, env);

View File

@@ -35,7 +35,7 @@ export class TextEditorDecorationType implements vscode.TextEditorDecorationType
export interface ITextEditOperation {
range: vscode.Range;
text: string;
text: string | null;
forceMoveMarkers: boolean;
}
@@ -105,8 +105,8 @@ export class TextEditorEdit {
this._pushEdit(range, null, true);
}
private _pushEdit(range: Range, text: string, forceMoveMarkers: boolean): void {
let validRange = this._document.validateRange(range);
private _pushEdit(range: Range, text: string | null, forceMoveMarkers: boolean): void {
const validRange = this._document.validateRange(range);
this._collectedEdits.push({
range: validRange,
text: text,
@@ -170,11 +170,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
return 'auto';
}
if (typeof value === 'number') {
let r = Math.floor(value);
const r = Math.floor(value);
return (r > 0 ? r : null);
}
if (typeof value === 'string') {
let r = parseInt(value, 10);
const r = parseInt(value, 10);
if (isNaN(r)) {
return null;
}
@@ -184,7 +184,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
}
public set tabSize(value: number | string) {
let tabSize = this._validateTabSize(value);
const tabSize = this._validateTabSize(value);
if (tabSize === null) {
// ignore invalid call
return;
@@ -211,11 +211,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
return 'tabSize';
}
if (typeof value === 'number') {
let r = Math.floor(value);
const r = Math.floor(value);
return (r > 0 ? r : null);
}
if (typeof value === 'string') {
let r = parseInt(value, 10);
const r = parseInt(value, 10);
if (isNaN(r)) {
return null;
}
@@ -225,7 +225,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
}
public set indentSize(value: number | string) {
let indentSize = this._validateIndentSize(value);
const indentSize = this._validateIndentSize(value);
if (indentSize === null) {
// ignore invalid call
return;
@@ -255,7 +255,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
}
public set insertSpaces(value: boolean | string) {
let insertSpaces = this._validateInsertSpaces(value);
const insertSpaces = this._validateInsertSpaces(value);
if (typeof insertSpaces === 'boolean') {
if (this._insertSpaces === insertSpaces) {
// nothing to do
@@ -300,11 +300,11 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
}
public assign(newOptions: vscode.TextEditorOptions) {
let bulkConfigurationUpdate: ITextEditorConfigurationUpdate = {};
const bulkConfigurationUpdate: ITextEditorConfigurationUpdate = {};
let hasUpdate = false;
if (typeof newOptions.tabSize !== 'undefined') {
let tabSize = this._validateTabSize(newOptions.tabSize);
const tabSize = this._validateTabSize(newOptions.tabSize);
if (tabSize === 'auto') {
hasUpdate = true;
bulkConfigurationUpdate.tabSize = tabSize;
@@ -317,7 +317,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
}
// if (typeof newOptions.indentSize !== 'undefined') {
// let indentSize = this._validateIndentSize(newOptions.indentSize);
// const indentSize = this._validateIndentSize(newOptions.indentSize);
// if (indentSize === 'tabSize') {
// hasUpdate = true;
// bulkConfigurationUpdate.indentSize = indentSize;
@@ -330,7 +330,7 @@ export class ExtHostTextEditorOptions implements vscode.TextEditorOptions {
// }
if (typeof newOptions.insertSpaces !== 'undefined') {
let insertSpaces = this._validateInsertSpaces(newOptions.insertSpaces);
const insertSpaces = this._validateInsertSpaces(newOptions.insertSpaces);
if (insertSpaces === 'auto') {
hasUpdate = true;
bulkConfigurationUpdate.insertSpaces = insertSpaces;
@@ -373,7 +373,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
private _selections: Selection[];
private _options: ExtHostTextEditorOptions;
private _visibleRanges: Range[];
private _viewColumn: vscode.ViewColumn;
private _viewColumn: vscode.ViewColumn | undefined;
private _disposed: boolean = false;
private _hasDecorationsForKey: { [key: string]: boolean; };
@@ -382,7 +382,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
constructor(
proxy: MainThreadTextEditorsShape, id: string, document: ExtHostDocumentData,
selections: Selection[], options: IResolvedTextEditorConfiguration,
visibleRanges: Range[], viewColumn: vscode.ViewColumn
visibleRanges: Range[], viewColumn: vscode.ViewColumn | undefined
) {
this._proxy = proxy;
this._id = id;
@@ -451,7 +451,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
// ---- view column
get viewColumn(): vscode.ViewColumn {
get viewColumn(): vscode.ViewColumn | undefined {
return this._viewColumn;
}
@@ -510,7 +510,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
TypeConverters.fromRangeOrRangeWithMessage(ranges)
);
} else {
let _ranges: number[] = new Array<number>(4 * ranges.length);
const _ranges: number[] = new Array<number>(4 * ranges.length);
for (let i = 0, len = ranges.length; i < len; i++) {
const range = ranges[i];
_ranges[4 * i] = range.start.line + 1;
@@ -538,8 +538,8 @@ export class ExtHostTextEditor implements vscode.TextEditor {
);
}
private _trySetSelection(): Promise<vscode.TextEditor> {
let selection = this._selections.map(TypeConverters.Selection.from);
private _trySetSelection(): Promise<vscode.TextEditor | null | undefined> {
const selection = this._selections.map(TypeConverters.Selection.from);
return this._runOnProxy(() => this._proxy.$trySetSelections(this._id, selection));
}
@@ -554,13 +554,13 @@ export class ExtHostTextEditor implements vscode.TextEditor {
if (this._disposed) {
return Promise.reject(new Error('TextEditor#edit not possible on closed editors'));
}
let edit = new TextEditorEdit(this._documentData.document, options);
const edit = new TextEditorEdit(this._documentData.document, options);
callback(edit);
return this._applyEdit(edit);
}
private _applyEdit(editBuilder: TextEditorEdit): Promise<boolean> {
let editData = editBuilder.finalize();
const editData = editBuilder.finalize();
// return when there is nothing to do
if (editData.edits.length === 0 && !editData.setEndOfLine) {
@@ -568,7 +568,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
}
// check that the edits are not overlapping (i.e. illegal)
let editRanges = editData.edits.map(edit => edit.range);
const editRanges = editData.edits.map(edit => edit.range);
// sort ascending (by end and then by start)
editRanges.sort((a, b) => {
@@ -598,7 +598,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
}
// prepare data for serialization
let edits: ISingleEditOperation[] = editData.edits.map((edit) => {
const edits = editData.edits.map((edit): ISingleEditOperation => {
return {
range: TypeConverters.Range.from(edit.range),
text: edit.text,
@@ -620,7 +620,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
let ranges: IRange[];
if (!where || (Array.isArray(where) && where.length === 0)) {
ranges = this._selections.map(TypeConverters.Range.from);
ranges = this._selections.map(range => TypeConverters.Range.from(range));
} else if (where instanceof Position) {
const { lineNumber, column } = TypeConverters.Position.from(where);
@@ -645,7 +645,7 @@ export class ExtHostTextEditor implements vscode.TextEditor {
// ---- util
private _runOnProxy(callback: () => Promise<any>): Promise<ExtHostTextEditor> {
private _runOnProxy(callback: () => Promise<any>): Promise<ExtHostTextEditor | undefined | null> {
if (this._disposed) {
console.warn('TextEditor is closed/disposed');
return Promise.resolve(undefined);

View File

@@ -75,7 +75,7 @@ export class ExtHostEditors implements ExtHostEditorsShape {
}
return this._proxy.$tryShowTextDocument(document.uri, options).then(id => {
let editor = this._extHostDocumentsAndEditors.getEditor(id);
const editor = id && this._extHostDocumentsAndEditors.getEditor(id);
if (editor) {
return editor;
} else {
@@ -97,6 +97,9 @@ export class ExtHostEditors implements ExtHostEditorsShape {
$acceptEditorPropertiesChanged(id: string, data: IEditorPropertiesChangeData): void {
const textEditor = this._extHostDocumentsAndEditors.getEditor(id);
if (!textEditor) {
throw new Error('unknown text editor');
}
// (1) set all properties
if (data.options) {
@@ -137,9 +140,12 @@ export class ExtHostEditors implements ExtHostEditorsShape {
}
$acceptEditorPositionData(data: ITextEditorPositionData): void {
for (let id in data) {
let textEditor = this._extHostDocumentsAndEditors.getEditor(id);
let viewColumn = TypeConverters.ViewColumn.to(data[id]);
for (const id in data) {
const textEditor = this._extHostDocumentsAndEditors.getEditor(id);
if (!textEditor) {
throw new Error('Unknown text editor');
}
const viewColumn = TypeConverters.ViewColumn.to(data[id]);
if (textEditor.viewColumn !== viewColumn) {
textEditor._acceptViewColumn(viewColumn);
this._onDidChangeTextEditorViewColumn.fire({ textEditor, viewColumn });

View File

@@ -366,7 +366,7 @@ class ExtHostTreeView<T> extends Disposable {
private getHandlesToRefresh(elements: T[]): TreeItemHandle[] {
const elementsToUpdate = new Set<TreeItemHandle>();
for (const element of elements) {
let elementNode = this.nodes.get(element);
const elementNode = this.nodes.get(element);
if (elementNode && !elementsToUpdate.has(elementNode.item.handle)) {
// check if an ancestor of extElement is already in the elements to update list
let currentNode = elementNode;
@@ -384,7 +384,7 @@ class ExtHostTreeView<T> extends Disposable {
// Take only top level elements
elementsToUpdate.forEach((handle) => {
const element = this.elements.get(handle);
let node = this.nodes.get(element);
const node = this.nodes.get(element);
if (node && (!node.parent || !elementsToUpdate.has(node.parent.item.handle))) {
handlesToUpdate.push(handle);
}
@@ -553,7 +553,7 @@ class ExtHostTreeView<T> extends Disposable {
private clearChildren(parentElement?: T): void {
if (parentElement) {
let node = this.nodes.get(parentElement);
const node = this.nodes.get(parentElement);
if (node.children) {
for (const child of node.children) {
const childEleement = this.elements.get(child.item.handle);
@@ -569,7 +569,7 @@ class ExtHostTreeView<T> extends Disposable {
}
private clear(element: T): void {
let node = this.nodes.get(element);
const node = this.nodes.get(element);
if (node.children) {
for (const child of node.children) {
const childEleement = this.elements.get(child.item.handle);

View File

@@ -236,7 +236,7 @@ export namespace MarkdownString {
const resUris: { [href: string]: UriComponents } = Object.create(null);
res.uris = resUris;
let renderer = new marked.Renderer();
const renderer = new marked.Renderer();
renderer.image = renderer.link = (href: string): string => {
try {
let uri = URI.parse(href, true);
@@ -267,7 +267,7 @@ export namespace MarkdownString {
}
data = cloneAndChange(data, value => {
if (value instanceof URI) {
let key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
const key = `__uri_${Math.random().toString(16).slice(2, 8)}`;
bucket[key] = value;
return key;
} else {

View File

@@ -66,7 +66,7 @@ export class Position {
}
let result = positions[0];
for (let i = 1; i < positions.length; i++) {
let p = positions[i];
const p = positions[i];
if (p.isBefore(result!)) {
result = p;
}
@@ -80,7 +80,7 @@ export class Position {
}
let result = positions[0];
for (let i = 1; i < positions.length; i++) {
let p = positions[i];
const p = positions[i];
if (p.isAfter(result!)) {
result = p;
}
@@ -303,8 +303,8 @@ export class Range {
}
intersection(other: Range): Range | undefined {
let start = Position.Max(other.start, this._start);
let end = Position.Min(other.end, this._end);
const start = Position.Max(other.start, this._start);
const end = Position.Min(other.end, this._end);
if (start.isAfter(end)) {
// this happens when there is no overlap:
// |-----|
@@ -320,8 +320,8 @@ export class Range {
} else if (other.contains(this)) {
return other;
}
let start = Position.Min(other.start, this._start);
let end = Position.Max(other.end, this.end);
const start = Position.Min(other.start, this._start);
const end = Position.Max(other.end, this.end);
return new Range(start, end);
}
@@ -480,7 +480,7 @@ export class TextEdit {
}
static setEndOfLine(eol: EndOfLine): TextEdit {
let ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
const ret = new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), '');
ret.newEol = eol;
return ret;
}
@@ -616,7 +616,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
}
get(uri: URI): TextEdit[] {
let res: TextEdit[] = [];
const res: TextEdit[] = [];
for (let candidate of this._edits) {
if (candidate._type === 2 && candidate.uri.toString() === uri.toString()) {
res.push(candidate.edit);
@@ -626,7 +626,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
}
entries(): [URI, TextEdit[]][] {
let textEdits = new Map<string, [URI, TextEdit[]]>();
const textEdits = new Map<string, [URI, TextEdit[]]>();
for (let candidate of this._edits) {
if (candidate._type === 2) {
let textEdit = textEdits.get(candidate.uri.toString());
@@ -641,7 +641,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
}
_allEntries(): ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] {
let res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
const res: ([URI, TextEdit[]] | [URI?, URI?, IFileOperationOptions?])[] = [];
for (let edit of this._edits) {
if (edit._type === 1) {
res.push([edit.from, edit.to, edit.options]);
@@ -1846,7 +1846,7 @@ export class Task implements vscode.Task {
}
this.clear();
this._execution = value;
let type = this._definition.type;
const type = this._definition.type;
if (Task.EmptyType === type || Task.ProcessType === type || Task.ShellType === type) {
this.computeDefinitionBasedOnExecution();
}

View File

@@ -321,10 +321,10 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
return folders[0].uri.fsPath;
}
getRelativePath(pathOrUri: string | vscode.Uri, includeWorkspace?: boolean): string | undefined {
getRelativePath(pathOrUri: string | vscode.Uri, includeWorkspace?: boolean): string {
let resource: URI | undefined;
let path: string | undefined;
let path: string = '';
if (typeof pathOrUri === 'string') {
resource = URI.file(pathOrUri);
path = pathOrUri;
@@ -354,7 +354,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
if (includeWorkspace && folder.name) {
result = `${folder.name}/${result}`;
}
return result;
return result!;
}
private trySetWorkspaceFolders(folders: vscode.WorkspaceFolder[]): void {
@@ -405,7 +405,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
}
}
let excludePatternOrDisregardExcludes: string | false = false;
let excludePatternOrDisregardExcludes: string | false | undefined = undefined;
if (exclude === null) {
excludePatternOrDisregardExcludes = false;
} else if (exclude) {
@@ -459,7 +459,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
excludePattern: options.exclude ? globPatternToString(options.exclude) : undefined
};
let isCanceled = false;
const isCanceled = false;
this._activeSearchCallbacks[requestId] = p => {
if (isCanceled) {