mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
debt - asThenable -> asPromise because it returns a promise
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
|
||||
@@ -76,7 +76,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
}
|
||||
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.createNewCommentThread(data.document, ran, text, CancellationToken.None);
|
||||
}).then(commentThread => commentThread ? convertToCommentThread(provider, commentThread, this._commandsConverter) : null);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
}
|
||||
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.replyToCommentThread(data.document, ran, convertFromCommentThread(thread), text, CancellationToken.None);
|
||||
}).then(commentThread => commentThread ? convertToCommentThread(provider, commentThread, this._commandsConverter) : null);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
}
|
||||
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.editComment(data.document, convertFromComment(comment), text, CancellationToken.None);
|
||||
});
|
||||
}
|
||||
@@ -116,28 +116,28 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
}
|
||||
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.deleteComment(data.document, convertFromComment(comment), CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$startDraft(handle: number): Promise<void> {
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.startDraft(CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$deleteDraft(handle: number): Promise<void> {
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.deleteDraft(CancellationToken.None);
|
||||
});
|
||||
}
|
||||
|
||||
$finishDraft(handle: number): Promise<void> {
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.finishDraft(CancellationToken.None);
|
||||
});
|
||||
}
|
||||
@@ -149,7 +149,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
}
|
||||
|
||||
const provider = this._documentProviders.get(handle);
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.provideDocumentComments(data.document, CancellationToken.None);
|
||||
}).then(commentInfo => commentInfo ? convertCommentInfo(handle, provider, commentInfo, this._commandsConverter) : null);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ export class ExtHostComments implements ExtHostCommentsShape {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return asThenable(() => {
|
||||
return asPromise(() => {
|
||||
return provider.provideWorkspaceComments(CancellationToken.None);
|
||||
}).then(comments =>
|
||||
comments.map(comment => convertToCommentThread(provider, comment, this._commandsConverter)
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as paths from 'vs/base/common/paths';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import * as nls from 'vs/nls';
|
||||
import {
|
||||
MainContext, MainThreadDebugServiceShape, ExtHostDebugServiceShape, DebugSessionUUID,
|
||||
@@ -558,7 +558,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
if (!provider.provideDebugConfigurations) {
|
||||
return Promise.reject(new Error('handler has no method provideDebugConfigurations'));
|
||||
}
|
||||
return asThenable(() => provider.provideDebugConfigurations(this.getFolder(folderUri), CancellationToken.None));
|
||||
return asPromise(() => provider.provideDebugConfigurations(this.getFolder(folderUri), CancellationToken.None));
|
||||
}
|
||||
|
||||
public $resolveDebugConfiguration(configProviderHandle: number, folderUri: UriComponents | undefined, debugConfiguration: vscode.DebugConfiguration): Promise<vscode.DebugConfiguration> {
|
||||
@@ -569,7 +569,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
if (!provider.resolveDebugConfiguration) {
|
||||
return Promise.reject(new Error('handler has no method resolveDebugConfiguration'));
|
||||
}
|
||||
return asThenable(() => provider.resolveDebugConfiguration(this.getFolder(folderUri), debugConfiguration, CancellationToken.None));
|
||||
return asPromise(() => provider.resolveDebugConfiguration(this.getFolder(folderUri), debugConfiguration, CancellationToken.None));
|
||||
}
|
||||
|
||||
// TODO@AW legacy
|
||||
@@ -581,7 +581,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
if (!provider.debugAdapterExecutable) {
|
||||
return Promise.reject(new Error('handler has no method debugAdapterExecutable'));
|
||||
}
|
||||
return asThenable(() => provider.debugAdapterExecutable(this.getFolder(folderUri), CancellationToken.None)).then(x => this.convertToDto(x));
|
||||
return asPromise(() => provider.debugAdapterExecutable(this.getFolder(folderUri), CancellationToken.None)).then(x => this.convertToDto(x));
|
||||
}
|
||||
|
||||
public $provideDebugAdapter(adapterProviderHandle: number, sessionDto: IDebugSessionDto): Promise<IAdapterDescriptor> {
|
||||
@@ -696,11 +696,11 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
const promises1 = this._configProviders
|
||||
.filter(tuple => tuple.provider.provideDebugAdapterTracker && (tuple.type === type || tuple.type === '*'))
|
||||
.map(tuple => asThenable(() => tuple.provider.provideDebugAdapterTracker(session, session.workspaceFolder, session.configuration, CancellationToken.None)).then(p => p).catch(err => null));
|
||||
.map(tuple => asPromise(() => tuple.provider.provideDebugAdapterTracker(session, session.workspaceFolder, session.configuration, CancellationToken.None)).then(p => p).catch(err => null));
|
||||
|
||||
const promises2 = this._trackerFactories
|
||||
.filter(tuple => tuple.type === type || tuple.type === '*')
|
||||
.map(tuple => asThenable(() => tuple.factory.createDebugAdapterTracker(session)).then(p => p).catch(err => null));
|
||||
.map(tuple => asPromise(() => tuple.factory.createDebugAdapterTracker(session)).then(p => p).catch(err => null));
|
||||
|
||||
const promises = promises1.concat(promises2);
|
||||
|
||||
@@ -736,13 +736,13 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
const pairs = this._configProviders.filter(p => p.type === session.type);
|
||||
if (pairs.length > 0) {
|
||||
if (pairs[0].provider.debugAdapterExecutable) {
|
||||
return asThenable(() => pairs[0].provider.debugAdapterExecutable(session.workspaceFolder, CancellationToken.None));
|
||||
return asPromise(() => pairs[0].provider.debugAdapterExecutable(session.workspaceFolder, CancellationToken.None));
|
||||
}
|
||||
}
|
||||
|
||||
if (adapterProvider) {
|
||||
const extensionRegistry = await this._extensionService.getExtensionRegistry();
|
||||
return asThenable(() => adapterProvider.createDebugAdapterDescriptor(session, this.daExecutableFromPackage(session, extensionRegistry)));
|
||||
return asPromise(() => adapterProvider.createDebugAdapterDescriptor(session, this.daExecutableFromPackage(session, extensionRegistry)));
|
||||
}
|
||||
|
||||
// try deprecated command based extension API "adapterExecutableCommand" to determine the executable
|
||||
|
||||
@@ -14,7 +14,7 @@ import { ExtHostHeapService } from 'vs/workbench/api/node/extHostHeapService';
|
||||
import { ExtHostDocuments } from 'vs/workbench/api/node/extHostDocuments';
|
||||
import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { ExtHostDiagnostics } from 'vs/workbench/api/node/extHostDiagnostics';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { MainContext, MainThreadLanguageFeaturesShape, ExtHostLanguageFeaturesShape, ObjectIdentifier, IRawColorInfo, IMainContext, IdObject, ISerializedRegExp, ISerializedIndentationRule, ISerializedOnEnterRule, ISerializedLanguageConfiguration, WorkspaceSymbolDto, SuggestResultDto, WorkspaceSymbolsDto, SuggestionDto, CodeActionDto, ISerializedDocumentFilter, WorkspaceEditDto, ISerializedSignatureHelpProviderMetadata } from './extHost.protocol';
|
||||
import { regExpLeadsToEndlessLoop, regExpFlags } from 'vs/base/common/strings';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
@@ -40,7 +40,7 @@ class OutlineAdapter {
|
||||
|
||||
provideDocumentSymbols(resource: URI, token: CancellationToken): Promise<modes.DocumentSymbol[]> {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
return asThenable(() => this._provider.provideDocumentSymbols(doc, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideDocumentSymbols(doc, token)).then(value => {
|
||||
if (isFalsyOrEmpty(value)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class CodeLensAdapter {
|
||||
provideCodeLenses(resource: URI, token: CancellationToken): Promise<modes.ICodeLensSymbol[]> {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
|
||||
return asThenable(() => this._provider.provideCodeLenses(doc, token)).then(lenses => {
|
||||
return asPromise(() => this._provider.provideCodeLenses(doc, token)).then(lenses => {
|
||||
if (Array.isArray(lenses)) {
|
||||
return lenses.map(lens => {
|
||||
const id = this._heapService.keep(lens);
|
||||
@@ -132,7 +132,7 @@ class CodeLensAdapter {
|
||||
if (typeof this._provider.resolveCodeLens !== 'function' || lens.isResolved) {
|
||||
resolve = Promise.resolve(lens);
|
||||
} else {
|
||||
resolve = asThenable(() => this._provider.resolveCodeLens(lens, token));
|
||||
resolve = asPromise(() => this._provider.resolveCodeLens(lens, token));
|
||||
}
|
||||
|
||||
return resolve.then(newLens => {
|
||||
@@ -162,7 +162,7 @@ class DefinitionAdapter {
|
||||
provideDefinition(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DefinitionLink[]> {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
return asThenable(() => this._provider.provideDefinition(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
return asPromise(() => this._provider.provideDefinition(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class DeclarationAdapter {
|
||||
provideDeclaration(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DefinitionLink[]> {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
return asThenable(() => this._provider.provideDeclaration(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
return asPromise(() => this._provider.provideDeclaration(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ class ImplementationAdapter {
|
||||
provideImplementation(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DefinitionLink[]> {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
return asThenable(() => this._provider.provideImplementation(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
return asPromise(() => this._provider.provideImplementation(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ class TypeDefinitionAdapter {
|
||||
provideTypeDefinition(resource: URI, position: IPosition, token: CancellationToken): Promise<modes.DefinitionLink[]> {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asThenable(() => this._provider.provideTypeDefinition(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
return asPromise(() => this._provider.provideTypeDefinition(doc, pos, token)).then(convertToDefinitionLinks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ class HoverAdapter {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.provideHover(doc, pos, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideHover(doc, pos, token)).then(value => {
|
||||
if (!value || isFalsyOrEmpty(value.contents)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ class DocumentHighlightAdapter {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.provideDocumentHighlights(doc, pos, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideDocumentHighlights(doc, pos, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(typeConvert.DocumentHighlight.from);
|
||||
}
|
||||
@@ -268,7 +268,7 @@ class ReferenceAdapter {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.provideReferences(doc, pos, context, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideReferences(doc, pos, context, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(typeConvert.location.from);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ class CodeActionAdapter {
|
||||
only: context.only ? new CodeActionKind(context.only) : undefined
|
||||
};
|
||||
|
||||
return asThenable(() => this._provider.provideCodeActions(doc, ran, codeActionContext, token)).then(commandsOrActions => {
|
||||
return asPromise(() => this._provider.provideCodeActions(doc, ran, codeActionContext, token)).then(commandsOrActions => {
|
||||
if (isFalsyOrEmpty(commandsOrActions)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -367,7 +367,7 @@ class DocumentFormattingAdapter {
|
||||
|
||||
const { document } = this._documents.getDocumentData(resource);
|
||||
|
||||
return asThenable(() => this._provider.provideDocumentFormattingEdits(document, <any>options, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideDocumentFormattingEdits(document, <any>options, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(typeConvert.TextEdit.from);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ class RangeFormattingAdapter {
|
||||
const { document } = this._documents.getDocumentData(resource);
|
||||
const ran = typeConvert.Range.to(range);
|
||||
|
||||
return asThenable(() => this._provider.provideDocumentRangeFormattingEdits(document, ran, <any>options, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideDocumentRangeFormattingEdits(document, ran, <any>options, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(typeConvert.TextEdit.from);
|
||||
}
|
||||
@@ -411,7 +411,7 @@ class OnTypeFormattingAdapter {
|
||||
const { document } = this._documents.getDocumentData(resource);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.provideOnTypeFormattingEdits(document, pos, ch, <any>options, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideOnTypeFormattingEdits(document, pos, ch, <any>options, token)).then(value => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(typeConvert.TextEdit.from);
|
||||
}
|
||||
@@ -432,7 +432,7 @@ class NavigateTypeAdapter {
|
||||
|
||||
provideWorkspaceSymbols(search: string, token: CancellationToken): Promise<WorkspaceSymbolsDto> {
|
||||
const result: WorkspaceSymbolsDto = IdObject.mixin({ symbols: [] });
|
||||
return asThenable(() => this._provider.provideWorkspaceSymbols(search, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideWorkspaceSymbols(search, token)).then(value => {
|
||||
if (isNonEmptyArray(value)) {
|
||||
for (const item of value) {
|
||||
if (!item) {
|
||||
@@ -464,7 +464,7 @@ class NavigateTypeAdapter {
|
||||
|
||||
const item = this._symbolCache[symbol._id];
|
||||
if (item) {
|
||||
return asThenable(() => this._provider.resolveWorkspaceSymbol(item, token)).then(value => {
|
||||
return asPromise(() => this._provider.resolveWorkspaceSymbol(item, token)).then(value => {
|
||||
return value && mixin(symbol, typeConvert.WorkspaceSymbol.from(value), true);
|
||||
});
|
||||
}
|
||||
@@ -498,7 +498,7 @@ class RenameAdapter {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.provideRenameEdits(doc, pos, newName, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideRenameEdits(doc, pos, newName, token)).then(value => {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ class RenameAdapter {
|
||||
let doc = this._documents.getDocumentData(resource).document;
|
||||
let pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.prepareRename(doc, pos, token)).then(rangeOrLocation => {
|
||||
return asPromise(() => this._provider.prepareRename(doc, pos, token)).then(rangeOrLocation => {
|
||||
|
||||
let range: vscode.Range;
|
||||
let text: string;
|
||||
@@ -588,7 +588,7 @@ class SuggestAdapter {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable<vscode.CompletionItem[] | vscode.CompletionList>(
|
||||
return asPromise<vscode.CompletionItem[] | vscode.CompletionList>(
|
||||
() => this._provider.provideCompletionItems(doc, pos, token, typeConvert.CompletionContext.to(context))
|
||||
).then(value => {
|
||||
|
||||
@@ -642,7 +642,7 @@ class SuggestAdapter {
|
||||
return Promise.resolve(suggestion);
|
||||
}
|
||||
|
||||
return asThenable(() => this._provider.resolveCompletionItem(item, token)).then(resolvedItem => {
|
||||
return asPromise(() => this._provider.resolveCompletionItem(item, token)).then(resolvedItem => {
|
||||
|
||||
if (!resolvedItem) {
|
||||
return suggestion;
|
||||
@@ -738,7 +738,7 @@ class SignatureHelpAdapter {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
const pos = typeConvert.Position.to(position);
|
||||
|
||||
return asThenable(() => this._provider.provideSignatureHelp(doc, pos, token, context)).then(value => {
|
||||
return asPromise(() => this._provider.provideSignatureHelp(doc, pos, token, context)).then(value => {
|
||||
if (value) {
|
||||
return typeConvert.SignatureHelp.from(value);
|
||||
}
|
||||
@@ -758,7 +758,7 @@ class LinkProviderAdapter {
|
||||
provideLinks(resource: URI, token: CancellationToken): Promise<modes.ILink[]> {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
|
||||
return asThenable(() => this._provider.provideDocumentLinks(doc, token)).then(links => {
|
||||
return asPromise(() => this._provider.provideDocumentLinks(doc, token)).then(links => {
|
||||
if (!Array.isArray(links)) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -784,7 +784,7 @@ class LinkProviderAdapter {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return asThenable(() => this._provider.resolveDocumentLink(item, token)).then(value => {
|
||||
return asPromise(() => this._provider.resolveDocumentLink(item, token)).then(value => {
|
||||
if (value) {
|
||||
return typeConvert.DocumentLink.from(value);
|
||||
}
|
||||
@@ -802,7 +802,7 @@ class ColorProviderAdapter {
|
||||
|
||||
provideColors(resource: URI, token: CancellationToken): Promise<IRawColorInfo[]> {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
return asThenable(() => this._provider.provideDocumentColors(doc, token)).then(colors => {
|
||||
return asPromise(() => this._provider.provideDocumentColors(doc, token)).then(colors => {
|
||||
if (!Array.isArray(colors)) {
|
||||
return [];
|
||||
}
|
||||
@@ -822,7 +822,7 @@ class ColorProviderAdapter {
|
||||
const document = this._documents.getDocumentData(resource).document;
|
||||
const range = typeConvert.Range.to(raw.range);
|
||||
const color = typeConvert.Color.to(raw.color);
|
||||
return asThenable(() => this._provider.provideColorPresentations(color, { document, range }, token)).then(value => {
|
||||
return asPromise(() => this._provider.provideColorPresentations(color, { document, range }, token)).then(value => {
|
||||
return value.map(typeConvert.ColorPresentation.from);
|
||||
});
|
||||
}
|
||||
@@ -837,7 +837,7 @@ class FoldingProviderAdapter {
|
||||
|
||||
provideFoldingRanges(resource: URI, context: modes.FoldingContext, token: CancellationToken): Promise<modes.FoldingRange[]> {
|
||||
const doc = this._documents.getDocumentData(resource).document;
|
||||
return asThenable(() => this._provider.provideFoldingRanges(doc, context, token)).then(ranges => {
|
||||
return asPromise(() => this._provider.provideFoldingRanges(doc, context, token)).then(ranges => {
|
||||
if (!Array.isArray(ranges)) {
|
||||
return void 0;
|
||||
}
|
||||
@@ -856,7 +856,7 @@ class SelectionRangeAdapter {
|
||||
provideSelectionRanges(resource: URI, position: IPosition, token: CancellationToken): Promise<IRange[]> {
|
||||
const { document } = this._documents.getDocumentData(resource);
|
||||
const pos = typeConvert.Position.to(position);
|
||||
return asThenable(() => this._provider.provideSelectionRanges(document, pos, token)).then(ranges => {
|
||||
return asPromise(() => this._provider.provideSelectionRanges(document, pos, token)).then(ranges => {
|
||||
if (isFalsyOrEmpty(ranges)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -150,7 +150,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape {
|
||||
|
||||
$validateInput(input: string): Promise<string> {
|
||||
if (this._validateInput) {
|
||||
return asThenable(() => this._validateInput(input));
|
||||
return asPromise(() => this._validateInput(input));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { debounce } from 'vs/base/common/decorators';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
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';
|
||||
@@ -286,7 +286,7 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return asThenable(() => this._commands.executeCommand(command.command, ...command.arguments));
|
||||
return asPromise(() => this._commands.executeCommand(command.command, ...command.arguments));
|
||||
}
|
||||
|
||||
_takeResourceStateSnapshot(): SCMRawResourceSplice[] {
|
||||
@@ -618,7 +618,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return asThenable(() => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
|
||||
return asPromise(() => sourceControl.quickDiffProvider.provideOriginalResource(uri, token));
|
||||
}
|
||||
|
||||
$onInputBoxValueChange(sourceControlHandle: number, value: string): Promise<void> {
|
||||
@@ -665,7 +665,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
return asThenable(() => sourceControl.inputBox.validateInput(value, cursorPosition)).then(result => {
|
||||
return asPromise(() => sourceControl.inputBox.validateInput(value, cursorPosition)).then(result => {
|
||||
if (!result) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as path from 'path';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as Objects from 'vs/base/common/objects';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { win32 } from 'vs/base/node/processes';
|
||||
|
||||
@@ -870,7 +870,7 @@ export class ExtHostTask implements ExtHostTaskShape {
|
||||
if (!handler) {
|
||||
return Promise.reject(new Error('no handler found'));
|
||||
}
|
||||
return asThenable(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
|
||||
return asPromise(() => handler.provider.provideTasks(CancellationToken.None)).then(value => {
|
||||
let sanitized: vscode.Task[] = [];
|
||||
for (let task of value) {
|
||||
if (task.definition && validTypes[task.definition.type] === true) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ExtHostTreeViewsShape, MainThreadTreeViewsShape } from './extHost.protocol';
|
||||
import { ITreeItem, TreeViewItemHandleArg, ITreeItemLabel, IRevealOptions } from 'vs/workbench/common/views';
|
||||
import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHostCommands';
|
||||
import { asThenable } from 'vs/base/common/async';
|
||||
import { asPromise } from 'vs/base/common/async';
|
||||
import { TreeItemCollapsibleState, ThemeIcon, MarkdownString } from 'vs/workbench/api/node/extHostTypes';
|
||||
import { isUndefinedOrNull, isString } from 'vs/base/common/types';
|
||||
import { equals, coalesce } from 'vs/base/common/arrays';
|
||||
@@ -280,7 +280,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
if (node) {
|
||||
return Promise.resolve(node.parent ? this.elements.get(node.parent.item.handle) : null);
|
||||
}
|
||||
return asThenable(() => this.dataProvider.getParent(element));
|
||||
return asPromise(() => this.dataProvider.getParent(element));
|
||||
}
|
||||
|
||||
private resolveTreeNode(element: T, parent?: TreeNode): Promise<TreeNode> {
|
||||
@@ -288,7 +288,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
if (node) {
|
||||
return Promise.resolve(node);
|
||||
}
|
||||
return asThenable(() => this.dataProvider.getTreeItem(element))
|
||||
return asPromise(() => this.dataProvider.getTreeItem(element))
|
||||
.then(extTreeItem => this.createHandle(element, extTreeItem, parent, true))
|
||||
.then(handle => this.getChildren(parent ? parent.item.handle : null)
|
||||
.then(() => {
|
||||
@@ -322,10 +322,10 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
this.clearChildren(parentElement);
|
||||
|
||||
const parentNode = parentElement ? this.nodes.get(parentElement) : void 0;
|
||||
return asThenable(() => this.dataProvider.getChildren(parentElement))
|
||||
return asPromise(() => this.dataProvider.getChildren(parentElement))
|
||||
.then(elements => Promise.all(
|
||||
coalesce(elements || [])
|
||||
.map(element => asThenable(() => this.dataProvider.getTreeItem(element))
|
||||
.map(element => asPromise(() => this.dataProvider.getTreeItem(element))
|
||||
.then(extTreeItem => extTreeItem ? this.createAndRegisterTreeNode(element, extTreeItem, parentNode) : null))))
|
||||
.then(coalesce);
|
||||
}
|
||||
@@ -390,7 +390,7 @@ class ExtHostTreeView<T> extends Disposable {
|
||||
const extElement = this.getExtensionElement(treeItemHandle);
|
||||
const existing = this.nodes.get(extElement);
|
||||
this.clearChildren(extElement); // clear children cache
|
||||
return asThenable(() => this.dataProvider.getTreeItem(extElement))
|
||||
return asPromise(() => this.dataProvider.getTreeItem(extElement))
|
||||
.then(extTreeItem => {
|
||||
if (extTreeItem) {
|
||||
const newNode = this.createTreeNode(extElement, extTreeItem, existing.parent);
|
||||
|
||||
Reference in New Issue
Block a user