diff --git a/src/vs/editor/common/services/modeService.ts b/src/vs/editor/common/services/modeService.ts index 5b6540f643b..b7d0b440561 100644 --- a/src/vs/editor/common/services/modeService.ts +++ b/src/vs/editor/common/services/modeService.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { Event } from 'vs/base/common/event'; -import { TPromise } from 'vs/base/common/winjs.base'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IMode, LanguageId, LanguageIdentifier } from 'vs/editor/common/modes'; import { URI } from 'vs/base/common/uri'; @@ -43,7 +42,7 @@ export interface IModeService { // --- instantiation getMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): IMode; - getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): TPromise; - getOrCreateModeByLanguageName(languageName: string): TPromise; - getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): TPromise; + getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): Promise; + getOrCreateModeByLanguageName(languageName: string): Promise; + getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): Promise; } diff --git a/src/vs/editor/common/services/modeServiceImpl.ts b/src/vs/editor/common/services/modeServiceImpl.ts index 9f2f52ce0c5..0e99262b381 100644 --- a/src/vs/editor/common/services/modeServiceImpl.ts +++ b/src/vs/editor/common/services/modeServiceImpl.ts @@ -5,7 +5,6 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { Event, Emitter } from 'vs/base/common/event'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IMode, LanguageId, LanguageIdentifier } from 'vs/editor/common/modes'; import { FrankensteinMode } from 'vs/editor/common/modes/abstractMode'; import { LanguagesRegistry } from 'vs/editor/common/services/languagesRegistry'; @@ -27,8 +26,8 @@ export class ModeServiceImpl implements IModeService { this._registry = new LanguagesRegistry(true, warnOnOverwrite); } - protected _onReady(): TPromise { - return TPromise.as(true); + protected _onReady(): Promise { + return Promise.resolve(true); } public isRegisteredMode(mimetypeOrModeId: string): boolean { @@ -115,7 +114,7 @@ export class ModeServiceImpl implements IModeService { return null; } - public getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): TPromise { + public getOrCreateMode(commaSeparatedMimetypesOrCommaSeparatedIds: string): Promise { return this._onReady().then(() => { const modeId = this.getModeId(commaSeparatedMimetypesOrCommaSeparatedIds); // Fall back to plain text if no mode was found @@ -123,7 +122,7 @@ export class ModeServiceImpl implements IModeService { }); } - public getOrCreateModeByLanguageName(languageName: string): TPromise { + public getOrCreateModeByLanguageName(languageName: string): Promise { return this._onReady().then(() => { const modeId = this._getModeIdByLanguageName(languageName); // Fall back to plain text if no mode was found @@ -141,7 +140,7 @@ export class ModeServiceImpl implements IModeService { return null; } - public getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): TPromise { + public getOrCreateModeByFilepathOrFirstLine(filepath: string, firstLine?: string): Promise { return this._onReady().then(() => { const modeId = this.getModeIdByFilepathOrFirstLine(filepath, firstLine); // Fall back to plain text if no mode was found diff --git a/src/vs/editor/common/services/modelService.ts b/src/vs/editor/common/services/modelService.ts index 5052fa378e5..c9994204338 100644 --- a/src/vs/editor/common/services/modelService.ts +++ b/src/vs/editor/common/services/modelService.ts @@ -5,7 +5,6 @@ import { Event } from 'vs/base/common/event'; import { URI } from 'vs/base/common/uri'; -import { TPromise } from 'vs/base/common/winjs.base'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { ITextModel, ITextModelCreationOptions, ITextBufferFactory } from 'vs/editor/common/model'; import { IMode } from 'vs/editor/common/modes'; @@ -15,11 +14,11 @@ export const IModelService = createDecorator('modelService'); export interface IModelService { _serviceBrand: any; - createModel(value: string | ITextBufferFactory, modeOrPromise: TPromise | IMode, resource: URI, isForSimpleWidget?: boolean): ITextModel; + createModel(value: string | ITextBufferFactory, modeOrPromise: Promise | IMode, resource: URI, isForSimpleWidget?: boolean): ITextModel; updateModel(model: ITextModel, value: string | ITextBufferFactory): void; - setMode(model: ITextModel, modeOrPromise: TPromise | IMode): void; + setMode(model: ITextModel, modeOrPromise: Promise | IMode): void; destroyModel(resource: URI): void; diff --git a/src/vs/editor/common/services/modelServiceImpl.ts b/src/vs/editor/common/services/modelServiceImpl.ts index 2d3c7a0e35f..226dfea8816 100644 --- a/src/vs/editor/common/services/modelServiceImpl.ts +++ b/src/vs/editor/common/services/modelServiceImpl.ts @@ -9,7 +9,6 @@ import { Event, Emitter } from 'vs/base/common/event'; import { MarkdownString } from 'vs/base/common/htmlContent'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { URI } from 'vs/base/common/uri'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IMarker, IMarkerService, MarkerSeverity, MarkerTag } from 'vs/platform/markers/common/markers'; import { Range } from 'vs/editor/common/core/range'; import { TextModel, createTextBuffer } from 'vs/editor/common/model/textModel'; @@ -492,7 +491,7 @@ export class ModelServiceImpl implements IModelService { return [EditOperation.replaceMove(oldRange, textBuffer.getValueInRange(newRange, EndOfLinePreference.TextDefined))]; } - public createModel(value: string | ITextBufferFactory, modeOrPromise: TPromise | IMode, resource: URI, isForSimpleWidget: boolean = false): ITextModel { + public createModel(value: string | ITextBufferFactory, modeOrPromise: Promise | IMode, resource: URI, isForSimpleWidget: boolean = false): ITextModel { let modelData: ModelData; if (!modeOrPromise || isThenable(modeOrPromise)) { @@ -512,7 +511,7 @@ export class ModelServiceImpl implements IModelService { return modelData.model; } - public setMode(model: ITextModel, modeOrPromise: TPromise | IMode): void { + public setMode(model: ITextModel, modeOrPromise: Promise | IMode): void { if (!modeOrPromise) { return; } diff --git a/src/vs/editor/standalone/browser/standaloneEditor.ts b/src/vs/editor/standalone/browser/standaloneEditor.ts index a85dd145bea..de8707ac01b 100644 --- a/src/vs/editor/standalone/browser/standaloneEditor.ts +++ b/src/vs/editor/standalone/browser/standaloneEditor.ts @@ -11,7 +11,6 @@ import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { IEditorOverrideServices, DynamicStandaloneServices, StaticServices } from 'vs/editor/standalone/browser/standaloneServices'; import { IDisposable } from 'vs/base/common/lifecycle'; import { URI } from 'vs/base/common/uri'; -import { TPromise } from 'vs/base/common/winjs.base'; import { OpenerService } from 'vs/editor/browser/services/openerService'; import { IOpenerService } from 'vs/platform/opener/common/opener'; import { Colorizer, IColorizerElementOptions, IColorizerOptions } from 'vs/editor/standalone/browser/colorizer'; @@ -136,7 +135,7 @@ export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: ID return new DiffNavigator(diffEditor, opts); } -function doCreateModel(value: string, mode: TPromise, uri?: URI): ITextModel { +function doCreateModel(value: string, mode: Promise, uri?: URI): ITextModel { return StaticServices.modelService.get().createModel(value, mode, uri); } diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 6f9fb065fbc..30ad1f37623 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -976,7 +976,7 @@ export class ChangeModeAction extends Action { } // Find mode - let mode: TPromise; + let mode: Promise; if (pick === autoDetectMode) { mode = this.modeService.getOrCreateModeByFilepathOrFirstLine(toResource(activeEditor, { supportSideBySide: true }).fsPath, textModel.getLineContent(1)); } else { diff --git a/src/vs/workbench/common/editor/textEditorModel.ts b/src/vs/workbench/common/editor/textEditorModel.ts index 41929a278af..6ae29b06ebf 100644 --- a/src/vs/workbench/common/editor/textEditorModel.ts +++ b/src/vs/workbench/common/editor/textEditorModel.ts @@ -77,7 +77,7 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd return TPromise.as(this.doCreateTextEditorModel(value, mode, resource)); } - private doCreateTextEditorModel(value: ITextBufferFactory, mode: TPromise, resource: URI): EditorModel { + private doCreateTextEditorModel(value: ITextBufferFactory, mode: Promise, resource: URI): EditorModel { let model = resource && this.modelService.getModel(resource); if (!model) { model = this.modelService.createModel(value, mode, resource); @@ -113,7 +113,7 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd * * @param firstLineText optional first line of the text buffer to set the mode on. This can be used to guess a mode from content. */ - protected getOrCreateMode(modeService: IModeService, modeId: string, firstLineText?: string): TPromise { + protected getOrCreateMode(modeService: IModeService, modeId: string, firstLineText?: string): Promise { return modeService.getOrCreateMode(modeId); } diff --git a/src/vs/workbench/common/editor/untitledEditorModel.ts b/src/vs/workbench/common/editor/untitledEditorModel.ts index 2d169aeeb12..936c4732993 100644 --- a/src/vs/workbench/common/editor/untitledEditorModel.ts +++ b/src/vs/workbench/common/editor/untitledEditorModel.ts @@ -58,7 +58,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin this.registerListeners(); } - protected getOrCreateMode(modeService: IModeService, modeId: string, firstLineText?: string): TPromise { + protected getOrCreateMode(modeService: IModeService, modeId: string, firstLineText?: string): Promise { if (!modeId || modeId === PLAINTEXT_MODE_ID) { return modeService.getOrCreateModeByFilepathOrFirstLine(this.resource.fsPath, firstLineText); // lookup mode via resource path if the provided modeId is unspecific } diff --git a/src/vs/workbench/parts/files/common/files.ts b/src/vs/workbench/parts/files/common/files.ts index ec77e28a9f1..b98dd326616 100644 --- a/src/vs/workbench/parts/files/common/files.ts +++ b/src/vs/workbench/parts/files/common/files.ts @@ -189,7 +189,7 @@ export class FileOnDiskContentProvider implements ITextModelContentProvider { } else if (createAsNeeded) { const fileOnDiskModel = this.modelService.getModel(fileOnDiskResource); - let mode: TPromise; + let mode: Promise; if (fileOnDiskModel) { mode = this.modeService.getOrCreateMode(fileOnDiskModel.getModeId()); } else { diff --git a/src/vs/workbench/services/mode/common/workbenchModeService.ts b/src/vs/workbench/services/mode/common/workbenchModeService.ts index 0a5daec589d..f0f732ddef1 100644 --- a/src/vs/workbench/services/mode/common/workbenchModeService.ts +++ b/src/vs/workbench/services/mode/common/workbenchModeService.ts @@ -5,7 +5,6 @@ import * as nls from 'vs/nls'; import * as resources from 'vs/base/common/resources'; -import { TPromise } from 'vs/base/common/winjs.base'; import * as mime from 'vs/base/common/mime'; import { IFilesConfiguration, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/files'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; @@ -91,7 +90,7 @@ export const languagesExtPoint: IExtensionPoint = export class WorkbenchModeServiceImpl extends ModeServiceImpl { private _configurationService: IConfigurationService; private _extensionService: IExtensionService; - private _onReadyPromise: TPromise; + private _onReadyPromise: Promise; constructor( @IExtensionService extensionService: IExtensionService, @@ -149,12 +148,14 @@ export class WorkbenchModeServiceImpl extends ModeServiceImpl { }); } - protected _onReady(): TPromise { + protected _onReady(): Promise { if (!this._onReadyPromise) { - this._onReadyPromise = this._extensionService.whenInstalledExtensionsRegistered().then(() => { - this.updateMime(); - return true; - }); + this._onReadyPromise = Promise.resolve( + this._extensionService.whenInstalledExtensionsRegistered().then(() => { + this.updateMime(); + return true; + }) + ); } return this._onReadyPromise; diff --git a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts index 48a1893ec24..f6e908bede0 100644 --- a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts +++ b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts @@ -492,7 +492,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil return this.backupFileService.resolveBackupContent(backup).then(backupContent => backupContent, error => null /* ignore errors */); } - protected getOrCreateMode(modeService: IModeService, preferredModeIds: string, firstLineText?: string): TPromise { + protected getOrCreateMode(modeService: IModeService, preferredModeIds: string, firstLineText?: string): Promise { return modeService.getOrCreateModeByFilepathOrFirstLine(this.resource.fsPath, firstLineText); }