mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Remove usage of TPromise from public editor API (#53526)
This commit is contained in:
@@ -315,7 +315,6 @@ function generateDeclarationFile(out, inputFiles, recipe) {
|
|||||||
var resultTxt = result.join(endl);
|
var resultTxt = result.join(endl);
|
||||||
resultTxt = resultTxt.replace(/\bURI\b/g, 'Uri');
|
resultTxt = resultTxt.replace(/\bURI\b/g, 'Uri');
|
||||||
resultTxt = resultTxt.replace(/\bEvent</g, 'IEvent<');
|
resultTxt = resultTxt.replace(/\bEvent</g, 'IEvent<');
|
||||||
resultTxt = resultTxt.replace(/\bTPromise</g, 'Promise<');
|
|
||||||
resultTxt = format(resultTxt);
|
resultTxt = format(resultTxt);
|
||||||
return [
|
return [
|
||||||
resultTxt,
|
resultTxt,
|
||||||
|
|||||||
@@ -366,7 +366,6 @@ function generateDeclarationFile(out: string, inputFiles: { [file: string]: stri
|
|||||||
let resultTxt = result.join(endl);
|
let resultTxt = result.join(endl);
|
||||||
resultTxt = resultTxt.replace(/\bURI\b/g, 'Uri');
|
resultTxt = resultTxt.replace(/\bURI\b/g, 'Uri');
|
||||||
resultTxt = resultTxt.replace(/\bEvent</g, 'IEvent<');
|
resultTxt = resultTxt.replace(/\bEvent</g, 'IEvent<');
|
||||||
resultTxt = resultTxt.replace(/\bTPromise</g, 'Promise<');
|
|
||||||
|
|
||||||
resultTxt = format(resultTxt);
|
resultTxt = format(resultTxt);
|
||||||
|
|
||||||
|
|||||||
@@ -287,9 +287,9 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||||||
action.label,
|
action.label,
|
||||||
action.alias,
|
action.alias,
|
||||||
action.precondition,
|
action.precondition,
|
||||||
(): void | TPromise<void> => {
|
(): Promise<void> => {
|
||||||
return this._instantiationService.invokeFunction((accessor) => {
|
return this._instantiationService.invokeFunction((accessor) => {
|
||||||
return action.runEditorCommand(accessor, this, null);
|
return Promise.resolve(action.runEditorCommand(accessor, this, null));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
this._contextKeyService
|
this._contextKeyService
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
|
||||||
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
import { IEditorAction } from 'vs/editor/common/editorCommon';
|
||||||
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
import { IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ export class InternalEditorAction implements IEditorAction {
|
|||||||
public readonly alias: string;
|
public readonly alias: string;
|
||||||
|
|
||||||
private readonly _precondition: ContextKeyExpr;
|
private readonly _precondition: ContextKeyExpr;
|
||||||
private readonly _run: () => void | TPromise<void>;
|
private readonly _run: () => Promise<void>;
|
||||||
private readonly _contextKeyService: IContextKeyService;
|
private readonly _contextKeyService: IContextKeyService;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -22,7 +21,7 @@ export class InternalEditorAction implements IEditorAction {
|
|||||||
label: string,
|
label: string,
|
||||||
alias: string,
|
alias: string,
|
||||||
precondition: ContextKeyExpr,
|
precondition: ContextKeyExpr,
|
||||||
run: () => void,
|
run: () => Promise<void>,
|
||||||
contextKeyService: IContextKeyService
|
contextKeyService: IContextKeyService
|
||||||
) {
|
) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@@ -37,12 +36,12 @@ export class InternalEditorAction implements IEditorAction {
|
|||||||
return this._contextKeyService.contextMatchesRules(this._precondition);
|
return this._contextKeyService.contextMatchesRules(this._precondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public run(): TPromise<void> {
|
public run(): Promise<void> {
|
||||||
if (!this.isSupported()) {
|
if (!this.isSupported()) {
|
||||||
return TPromise.as(void 0);
|
return Promise.resolve(void 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = this._run();
|
const r = this._run();
|
||||||
return r ? r : TPromise.as(void 0);
|
return r ? r : Promise.resolve(void 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
|
||||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { Position, IPosition } from 'vs/editor/common/core/position';
|
import { Position, IPosition } from 'vs/editor/common/core/position';
|
||||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||||
@@ -185,7 +184,7 @@ export interface IEditorAction {
|
|||||||
readonly label: string;
|
readonly label: string;
|
||||||
readonly alias: string;
|
readonly alias: string;
|
||||||
isSupported(): boolean;
|
isSupported(): boolean;
|
||||||
run(): TPromise<void>;
|
run(): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IEditorModel = ITextModel | IDiffEditorModel;
|
export type IEditorModel = ITextModel | IDiffEditorModel;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
|
||||||
import { ITextModel } from 'vs/editor/common/model';
|
import { ITextModel } from 'vs/editor/common/model';
|
||||||
import { ColorId, MetadataConsts, FontStyle, TokenizationRegistry, ITokenizationSupport } from 'vs/editor/common/modes';
|
import { ColorId, MetadataConsts, FontStyle, TokenizationRegistry, ITokenizationSupport } from 'vs/editor/common/modes';
|
||||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||||
@@ -26,7 +25,7 @@ export interface IColorizerElementOptions extends IColorizerOptions {
|
|||||||
|
|
||||||
export class Colorizer {
|
export class Colorizer {
|
||||||
|
|
||||||
public static colorizeElement(themeService: IStandaloneThemeService, modeService: IModeService, domNode: HTMLElement, options: IColorizerElementOptions): TPromise<void> {
|
public static colorizeElement(themeService: IStandaloneThemeService, modeService: IModeService, domNode: HTMLElement, options: IColorizerElementOptions): Promise<void> {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
let theme = options.theme || 'vs';
|
let theme = options.theme || 'vs';
|
||||||
let mimeType = options.mimeType || domNode.getAttribute('lang') || domNode.getAttribute('data-lang');
|
let mimeType = options.mimeType || domNode.getAttribute('lang') || domNode.getAttribute('data-lang');
|
||||||
@@ -45,7 +44,7 @@ export class Colorizer {
|
|||||||
return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err));
|
return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static colorize(modeService: IModeService, text: string, mimeType: string, options: IColorizerOptions): TPromise<string> {
|
public static colorize(modeService: IModeService, text: string, mimeType: string, options: IColorizerOptions): Promise<string> {
|
||||||
if (strings.startsWithUTF8BOM(text)) {
|
if (strings.startsWithUTF8BOM(text)) {
|
||||||
text = text.substr(1);
|
text = text.substr(1);
|
||||||
}
|
}
|
||||||
@@ -62,10 +61,10 @@ export class Colorizer {
|
|||||||
|
|
||||||
let tokenizationSupport = TokenizationRegistry.get(language);
|
let tokenizationSupport = TokenizationRegistry.get(language);
|
||||||
if (tokenizationSupport) {
|
if (tokenizationSupport) {
|
||||||
return TPromise.as(_colorize(lines, options.tabSize, tokenizationSupport));
|
return Promise.resolve(_colorize(lines, options.tabSize, tokenizationSupport));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TPromise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
let listener: IDisposable = null;
|
let listener: IDisposable = null;
|
||||||
let timeout: TimeoutTimer = null;
|
let timeout: TimeoutTimer = null;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
import * as nls from 'vs/nls';
|
import * as nls from 'vs/nls';
|
||||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||||
import { matchesFuzzy } from 'vs/base/common/filters';
|
import { matchesFuzzy } from 'vs/base/common/filters';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
|
||||||
import { IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
import { IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||||
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
|
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||||
@@ -55,7 +54,7 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
|
|||||||
this.editor.focus();
|
this.editor.focus();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let promise = this.action.run() || TPromise.as(null);
|
let promise = this.action.run() || Promise.resolve();
|
||||||
promise.then(null, onUnexpectedError);
|
promise.then(null, onUnexpectedError);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
onUnexpectedError(error);
|
onUnexpectedError(error);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||||
import { TPromise } from 'vs/base/common/winjs.base';
|
|
||||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
|
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||||
@@ -72,7 +71,7 @@ export interface IActionDescriptor {
|
|||||||
* Method that will be executed when the action is triggered.
|
* Method that will be executed when the action is triggered.
|
||||||
* @param editor The editor instance is passed in as a convinience
|
* @param editor The editor instance is passed in as a convinience
|
||||||
*/
|
*/
|
||||||
run(editor: ICodeEditor): void | TPromise<void>;
|
run(editor: ICodeEditor): void | Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -221,9 +220,8 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
|||||||
);
|
);
|
||||||
const contextMenuGroupId = _descriptor.contextMenuGroupId || null;
|
const contextMenuGroupId = _descriptor.contextMenuGroupId || null;
|
||||||
const contextMenuOrder = _descriptor.contextMenuOrder || 0;
|
const contextMenuOrder = _descriptor.contextMenuOrder || 0;
|
||||||
const run = (): TPromise<void> => {
|
const run = (): Promise<void> => {
|
||||||
const r = _descriptor.run(this);
|
return Promise.resolve(_descriptor.run(this));
|
||||||
return r ? r : TPromise.as(void 0);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -240,14 +240,14 @@ export function createWebWorker<T>(opts: IWebWorkerOptions): MonacoWebWorker<T>
|
|||||||
/**
|
/**
|
||||||
* Colorize the contents of `domNode` using attribute `data-lang`.
|
* Colorize the contents of `domNode` using attribute `data-lang`.
|
||||||
*/
|
*/
|
||||||
export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): TPromise<void> {
|
export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void> {
|
||||||
return Colorizer.colorizeElement(StaticServices.standaloneThemeService.get(), StaticServices.modeService.get(), domNode, options);
|
return Colorizer.colorizeElement(StaticServices.standaloneThemeService.get(), StaticServices.modeService.get(), domNode, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Colorize `text` using language `languageId`.
|
* Colorize `text` using language `languageId`.
|
||||||
*/
|
*/
|
||||||
export function colorize(text: string, languageId: string, options: IColorizerOptions): TPromise<string> {
|
export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string> {
|
||||||
return Colorizer.colorize(StaticServices.modeService.get(), text, languageId, options);
|
return Colorizer.colorize(StaticServices.modeService.get(), text, languageId, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
this.telemetryService.publicLog('workbenchActionExecuted', { id: action.id, from: 'quick open' });
|
this.telemetryService.publicLog('workbenchActionExecuted', { id: action.id, from: 'quick open' });
|
||||||
(action.run() || TPromise.as(null)).then(() => {
|
(action.run() || Promise.resolve()).then(() => {
|
||||||
if (action instanceof Action) {
|
if (action instanceof Action) {
|
||||||
action.dispose();
|
action.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user