Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix call hierarchy item serialization #40348

Merged
merged 1 commit into from Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/harness/client.ts
Expand Up @@ -757,6 +757,7 @@ namespace ts.server {
name: item.name,
kind: item.kind,
kindModifiers: item.kindModifiers,
containerName: item.containerName,
span: this.decodeSpan(item.span, item.file),
selectionSpan: this.decodeSpan(item.selectionSpan, item.file)
};
Expand All @@ -778,7 +779,7 @@ namespace ts.server {

provideCallHierarchyIncomingCalls(fileName: string, position: number) {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ProvideCallHierarchyIncomingCallsRequest>(CommandNames.PrepareCallHierarchy, args);
const request = this.processRequest<protocol.ProvideCallHierarchyIncomingCallsRequest>(CommandNames.ProvideCallHierarchyIncomingCalls, args);
const response = this.processResponse<protocol.ProvideCallHierarchyIncomingCallsResponse>(request);
return response.body.map(item => this.convertCallHierarchyIncomingCall(item));
}
Expand All @@ -792,7 +793,7 @@ namespace ts.server {

provideCallHierarchyOutgoingCalls(fileName: string, position: number) {
const args = this.createFileLocationRequestArgs(fileName, position);
const request = this.processRequest<protocol.ProvideCallHierarchyOutgoingCallsRequest>(CommandNames.PrepareCallHierarchy, args);
const request = this.processRequest<protocol.ProvideCallHierarchyOutgoingCallsRequest>(CommandNames.ProvideCallHierarchyOutgoingCalls, args);
const response = this.processResponse<protocol.ProvideCallHierarchyOutgoingCallsResponse>(request);
return response.body.map(item => this.convertCallHierarchyOutgoingCall(fileName, item));
}
Expand Down
1 change: 1 addition & 0 deletions src/server/session.ts
Expand Up @@ -2408,6 +2408,7 @@ namespace ts.server {
kind: item.kind,
kindModifiers: item.kindModifiers,
file: item.file,
containerName: item.containerName,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the implementation fix. Other changes are fixes to test infrastructure that was never used before now.

span: toProtocolTextSpan(item.span, scriptInfo),
selectionSpan: toProtocolTextSpan(item.selectionSpan, scriptInfo)
};
Expand Down
@@ -0,0 +1,165 @@
╭ name: f
├ kind: function
├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
├ span:
│ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:1:1-1:16
│ │ 1: function f() {}
│ │ ^^^^^^^^^^^^^^^
│ ╰
├ selectionSpan:
│ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:1:10-1:11
│ │ 1: function f() {}
│ │ ^
│ ╰
├ incoming:
│ ╭ from:
│ │ ╭ name: sameName
│ │ ├ kind: method
│ │ ├ containerName: A
│ │ ├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
│ │ ├ span:
│ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:4:3-6:4
│ │ │ │ 4: static sameName() {
│ │ │ │ ^^^^^^^^^^^^^^^^^^^
│ │ │ │ 5: f();
│ │ │ │ ^^^^^^^^
│ │ │ │ 6: }
│ │ │ │ ^^^
│ │ │ ╰
│ │ ├ selectionSpan:
│ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:4:10-4:18
│ │ │ │ 4: static sameName() {
│ │ │ │ ^^^^^^^^
│ │ │ ╰
│ │ ├ incoming:
│ │ │ ╭ from:
│ │ │ │ ╭ name: sameName
│ │ │ │ ├ kind: method
│ │ │ │ ├ containerName: B
│ │ │ │ ├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
│ │ │ │ ├ span:
│ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:10:3-12:4
│ │ │ │ │ │ 10: sameName() {
│ │ │ │ │ │ ^^^^^^^^^^^^
│ │ │ │ │ │ 11: A.sameName();
│ │ │ │ │ │ ^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ 12: }
│ │ │ │ │ │ ^^^
│ │ │ │ │ ╰
│ │ │ │ ├ selectionSpan:
│ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:10:3-10:11
│ │ │ │ │ │ 10: sameName() {
│ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ ╰
│ │ │ │ ├ incoming:
│ │ │ │ │ ╭ from:
│ │ │ │ │ │ ╭ name: sameName
│ │ │ │ │ │ ├ kind: getter
│ │ │ │ │ │ ├ containerName: Obj
│ │ │ │ │ │ ├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
│ │ │ │ │ │ ├ span:
│ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:16:3-18:4
│ │ │ │ │ │ │ │ 16: get sameName() {
│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ 17: return new B().sameName;
│ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ 18: }
│ │ │ │ │ │ │ │ ^^^
│ │ │ │ │ │ │ ╰
│ │ │ │ │ │ ├ selectionSpan:
│ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:16:7-16:15
│ │ │ │ │ │ │ │ 16: get sameName() {
│ │ │ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ │ │ ╰
│ │ │ │ │ │ ├ incoming:
│ │ │ │ │ │ │ ╭ from:
│ │ │ │ │ │ │ │ ╭ name: sameName
│ │ │ │ │ │ │ │ ├ kind: function
│ │ │ │ │ │ │ │ ├ containerName: Foo
│ │ │ │ │ │ │ │ ├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
│ │ │ │ │ │ │ │ ├ span:
│ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:22:3-24:4
│ │ │ │ │ │ │ │ │ │ 22: function sameName() {
│ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ │ │ 23: return Obj.sameName;
│ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ │ │ 24: }
│ │ │ │ │ │ │ │ │ │ ^^^
│ │ │ │ │ │ │ │ │ ╰
│ │ │ │ │ │ │ │ ├ selectionSpan:
│ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:22:12-22:20
│ │ │ │ │ │ │ │ │ │ 22: function sameName() {
│ │ │ │ │ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ │ │ │ │ ╰
│ │ │ │ │ │ │ │ ├ incoming:
│ │ │ │ │ │ │ │ │ ╭ from:
│ │ │ │ │ │ │ │ │ │ ╭ name: C
│ │ │ │ │ │ │ │ │ │ ├ kind: class
│ │ │ │ │ │ │ │ │ │ ├ containerName: Foo
│ │ │ │ │ │ │ │ │ │ ├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
│ │ │ │ │ │ │ │ │ │ ├ span:
│ │ │ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:26:3-30:4
│ │ │ │ │ │ │ │ │ │ │ │ 26: export class C {
│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ │ │ │ │ 27: constructor() {
│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ │ │ │ │ 28: sameName();
│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ │ │ │ │ 29: }
│ │ │ │ │ │ │ │ │ │ │ │ ^^^^^
│ │ │ │ │ │ │ │ │ │ │ │ 30: }
│ │ │ │ │ │ │ │ │ │ │ │ ^^^
│ │ │ │ │ │ │ │ │ │ │ ╰
│ │ │ │ │ │ │ │ │ │ ├ selectionSpan:
│ │ │ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:26:16-26:17
│ │ │ │ │ │ │ │ │ │ │ │ 26: export class C {
│ │ │ │ │ │ │ │ │ │ │ │ ^
│ │ │ │ │ │ │ │ │ │ │ ╰
│ │ │ │ │ │ │ │ │ │ ├ incoming:
│ │ │ │ │ │ │ │ │ │ │ ╭ from:
│ │ │ │ │ │ │ │ │ │ │ │ ╭ name: sameName
│ │ │ │ │ │ │ │ │ │ │ │ ├ kind: function
│ │ │ │ │ │ │ │ │ │ │ │ ├ containerName: Bar
│ │ │ │ │ │ │ │ │ │ │ │ ├ file: /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
│ │ │ │ │ │ │ │ │ │ │ │ ├ span:
│ │ │ │ │ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:34:20-34:37
│ │ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C();
│ │ │ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^^^^^^^^^^
│ │ │ │ │ │ │ │ │ │ │ │ │ ╰
│ │ │ │ │ │ │ │ │ │ │ │ ├ selectionSpan:
│ │ │ │ │ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:34:9-34:17
│ │ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C();
│ │ │ │ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ │ │ │ │ │ │ │ │ ╰
│ │ │ │ │ │ │ │ │ │ │ │ ╰ incoming: none
│ │ │ │ │ │ │ │ │ │ │ ├ fromSpans:
│ │ │ │ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:34:34-34:35
│ │ │ │ │ │ │ │ │ │ │ │ │ 34: const sameName = () => new Foo.C();
│ │ │ │ │ │ │ │ │ │ │ │ │ ^
│ │ │ │ │ │ │ │ │ │ ╰ ╰ ╰
│ │ │ │ │ │ │ │ │ ├ fromSpans:
│ │ │ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:28:7-28:15
│ │ │ │ │ │ │ │ │ │ │ 28: sameName();
│ │ │ │ │ │ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ │ │ │ ╰ ╰ ╰
│ │ │ │ │ │ │ ├ fromSpans:
│ │ │ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:23:16-23:24
│ │ │ │ │ │ │ │ │ 23: return Obj.sameName;
│ │ │ │ │ │ │ │ │ ^^^^^^^^
│ │ │ │ │ │ ╰ ╰ ╰
│ │ │ │ │ ├ fromSpans:
│ │ │ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:17:20-17:28
│ │ │ │ │ │ │ 17: return new B().sameName;
│ │ │ │ │ │ │ ^^^^^^^^
│ │ │ │ ╰ ╰ ╰
│ │ │ ├ fromSpans:
│ │ │ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:11:7-11:15
│ │ │ │ │ 11: A.sameName();
│ │ │ │ │ ^^^^^^^^
│ │ ╰ ╰ ╰
│ ├ fromSpans:
│ │ ╭ /tests/cases/fourslash/server/callHierarchyContainerNameServer.ts:5:5-5:6
│ │ │ 5: f();
│ │ │ ^
│ ╰ ╰
╰ outgoing: none
40 changes: 40 additions & 0 deletions tests/cases/fourslash/server/callHierarchyContainerNameServer.ts
@@ -0,0 +1,40 @@
/// <reference path="../fourslash.ts" />

////function /**/f() {}
////
////class A {
//// static sameName() {
//// f();
//// }
////}
////
////class B {
//// sameName() {
//// A.sameName();
//// }
////}
////
////const Obj = {
//// get sameName() {
//// return new B().sameName;
//// }
////};
////
////namespace Foo {
//// function sameName() {
//// return Obj.sameName;
//// }
////
//// export class C {
//// constructor() {
//// sameName();
//// }
//// }
////}
////
////module Foo.Bar {
//// const sameName = () => new Foo.C();
////}

goTo.marker();
verify.baselineCallHierarchy();