Skip to content

Commit

Permalink
remove call hierarchy API commands since the API/flow changes, #83274
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Oct 25, 2019
1 parent 051164a commit 5cf9024
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 92 deletions.
48 changes: 1 addition & 47 deletions src/vs/workbench/api/common/extHostApiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import * as vscode from 'vscode';
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
import * as types from 'vs/workbench/api/common/extHostTypes';
import { IRawColorInfo, IWorkspaceEditDto, ICallHierarchyItemDto } from 'vs/workbench/api/common/extHost.protocol';
import { IRawColorInfo, IWorkspaceEditDto } from 'vs/workbench/api/common/extHost.protocol';
import { ISingleEditOperation } from 'vs/editor/common/model';
import * as modes from 'vs/editor/common/modes';
import * as search from 'vs/workbench/contrib/search/common/search';
Expand Down Expand Up @@ -182,22 +182,6 @@ export class ExtHostApiCommands {
],
returns: 'A promise that resolves to an array of DocumentLink-instances.'
});
this._register('vscode.executeCallHierarchyProviderIncomingCalls', this._executeCallHierarchyIncomingCallsProvider, {
description: 'Execute call hierarchy provider for incoming calls',
args: [
{ name: 'uri', description: 'Uri of a text document', constraint: URI },
{ name: 'position', description: 'Position in a text document', constraint: types.Position },
],
returns: 'A promise that resolves to an array of CallHierarchyIncomingCall-instances.'
});
this._register('vscode.executeCallHierarchyProviderOutgoingCalls', this._executeCallHierarchyOutgoingCallsProvider, {
description: 'Execute call hierarchy provider for outgoing calls',
args: [
{ name: 'uri', description: 'Uri of a text document', constraint: URI },
{ name: 'position', description: 'Position in a text document', constraint: types.Position },
],
returns: 'A promise that resolves to an array of CallHierarchyOutgoingCall-instances.'
});
this._register('vscode.executeDocumentColorProvider', this._executeDocumentColorProvider, {
description: 'Execute document color provider.',
args: [
Expand Down Expand Up @@ -573,36 +557,6 @@ export class ExtHostApiCommands {
return this._commands.executeCommand<modes.ILink[]>('_executeLinkProvider', resource)
.then(tryMapWith(typeConverters.DocumentLink.to));
}

private async _executeCallHierarchyIncomingCallsProvider(resource: URI, position: types.Position): Promise<vscode.CallHierarchyIncomingCall[]> {
type IncomingCallDto = {
from: ICallHierarchyItemDto;
fromRanges: IRange[];
};
const args = { resource, position: typeConverters.Position.from(position) };
const calls = await this._commands.executeCommand<IncomingCallDto[]>('_executeCallHierarchyIncomingCalls', args);

const result: vscode.CallHierarchyIncomingCall[] = [];
for (const call of calls) {
result.push(new types.CallHierarchyIncomingCall(typeConverters.CallHierarchyItem.to(call.from), <vscode.Range[]>call.fromRanges.map(typeConverters.Range.to)));
}
return result;
}

private async _executeCallHierarchyOutgoingCallsProvider(resource: URI, position: types.Position): Promise<vscode.CallHierarchyOutgoingCall[]> {
type OutgoingCallDto = {
fromRanges: IRange[];
to: ICallHierarchyItemDto;
};
const args = { resource, position: typeConverters.Position.from(position) };
const calls = await this._commands.executeCommand<OutgoingCallDto[]>('_executeCallHierarchyOutgoingCalls', args);

const result: vscode.CallHierarchyOutgoingCall[] = [];
for (const call of calls) {
result.push(new types.CallHierarchyOutgoingCall(typeConverters.CallHierarchyItem.to(call.to), <vscode.Range[]>call.fromRanges.map(typeConverters.Range.to)));
}
return result;
}
}

function tryMapWith<T, R>(f: (x: T) => R) {
Expand Down
12 changes: 0 additions & 12 deletions src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { LanguageFeatureRegistry } from 'vs/editor/common/modes/languageFeatureRegistry';
import { URI } from 'vs/base/common/uri';
import { IPosition } from 'vs/editor/common/core/position';
import { registerDefaultLanguageCommand } from 'vs/editor/browser/editorExtensions';
import { isNonEmptyArray } from 'vs/base/common/arrays';
import { onUnexpectedExternalError } from 'vs/base/common/errors';

Expand Down Expand Up @@ -105,14 +104,3 @@ export class CallHierarchyModel {
}
}


export async function provideIncomingCalls(model: ITextModel, position: IPosition, token: CancellationToken): Promise<IncomingCall[]> {
throw new Error();
}

export async function provideOutgoingCalls(model: ITextModel, position: IPosition, token: CancellationToken): Promise<OutgoingCall[]> {
throw new Error();
}

registerDefaultLanguageCommand('_executeCallHierarchyIncomingCalls', async (model, position) => provideIncomingCalls(model, position, CancellationToken.None));
registerDefaultLanguageCommand('_executeCallHierarchyOutgoingCalls', async (model, position) => provideOutgoingCalls(model, position, CancellationToken.None));
Original file line number Diff line number Diff line change
Expand Up @@ -856,37 +856,4 @@ suite('ExtHostLanguageFeatureCommands', function () {
assert.equal(value.length, 1);
assert.ok(value[0].parent);
});

// --- call hierarcht

test('Call Hierarchy, back and forth', async function () {

disposables.push(extHost.registerCallHierarchyProvider(nullExtensionDescription, defaultSelector, new class implements vscode.CallHierarchyItemProvider {
prepareCallHierarchy(document: vscode.TextDocument) {
return new types.CallHierarchyItem(types.SymbolKind.Array, 'ROOT', '', document.uri, new types.Range(0, 0, 2, 0), new types.Range(0, 0, 2, 0));
}
provideCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CallHierarchyIncomingCall[]> {
return [
new types.CallHierarchyIncomingCall(new types.CallHierarchyItem(types.SymbolKind.Array, 'IN', '', item.uri, new types.Range(0, 0, 2, 0), new types.Range(0, 0, 2, 0)), [new types.Range(0, 0, 0, 0)]),
];
}
provideCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CallHierarchyOutgoingCall[]> {
return [
new types.CallHierarchyOutgoingCall(new types.CallHierarchyItem(types.SymbolKind.Array, 'OUT', '', item.uri, new types.Range(0, 0, 2, 0), new types.Range(0, 0, 2, 0)), [new types.Range(0, 0, 0, 0)]),
];
}
}));

await rpcProtocol.sync();

// let incoming = await commands.executeCommand<vscode.CallHierarchyIncomingCall[]>('vscode.executeCallHierarchyProviderIncomingCalls', model.uri, new types.Position(0, 10));
// assert.equal(incoming.length, 1);
// assert.ok(incoming[0].from instanceof types.CallHierarchyItem);
// assert.equal(incoming[0].from.name, 'IN');

// let outgoing = await commands.executeCommand<vscode.CallHierarchyOutgoingCall[]>('vscode.executeCallHierarchyProviderOutgoingCalls', model.uri, new types.Position(0, 10));
// assert.equal(outgoing.length, 1);
// assert.ok(outgoing[0].to instanceof types.CallHierarchyItem);
// assert.equal(outgoing[0].to.name, 'OUT');
});
});

0 comments on commit 5cf9024

Please sign in to comment.