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

GH-707: Introduced the @theia/typehierarchy extension. #3802

Merged
merged 1 commit into from
Mar 7, 2019
Merged

Conversation

kittaakos
Copy link
Contributor

@kittaakos kittaakos commented Dec 11, 2018

Originally from here: #3148.

  • Extended the LSP with the type hierarchy.
  • From now on, a tree node can carry decoration data.
  • Added editor access for the current/active editors.

Closes: #707.

Signed-off-by: Akos Kitta [email protected]

@simark
Copy link
Contributor

simark commented Dec 14, 2018

In #3148, you mentioned that this implementation differs from the proposal in microsoft/vscode-languageserver-node#346. Can you explain how it differs?

@kittaakos
Copy link
Contributor Author

#3148 (comment)

@simark
Copy link
Contributor

simark commented Dec 14, 2018

I saw this, but I don't really understand what to get from it.

@kittaakos
Copy link
Contributor Author

I don't really understand

Which part needs clarification?

@simark
Copy link
Contributor

simark commented Dec 14, 2018

Well, what in your implementation differs from the proposal. Different methods, fields?

@kittaakos
Copy link
Contributor Author

I see. The links are broken so you cannot compare the implementation with the proposed protocol changes; so I cannot do this either right now :(

By the way, we most likely throw away the LSP related changes from the PR and reimplement it based on this. Knowing these, are the differences still relevant to you?

@simark
Copy link
Contributor

simark commented Dec 14, 2018

By the way, we most likely throw away the LSP related changes from the PR and reimplement it based on this. Knowing these, are the differences still relevant to you?

In any case, I am just interested to know what this patch implements. I think it would be relevant to mention and explain it in the commit message. If you implemented the version in the comment you linked, you can mention that. If you made changes compared to it, it would be good to mention what they are as well.

@HighCommander4
Copy link
Contributor

I implemented server support for the superTypes part of this in clangd (C++ language server) in this patch, and wrote a patch to enable it in Theia's C++ language client.

One question, @kittaakos: why does this need to be enabled separately for each language client (e.g. separately in java-client-contribution.ts vs. cpp-client-contribution.ts? I understand that not every language has the concept of super- and subtypes, and we don't want to show menu items that aren't applicable to the language, but isn't the "capabilities" mechanism sufficient to take care of this? That is, a server for a language that doesn't have a concept of super- and subtypes would not include typeHierarchy in ServerCapabilities, and thus Theia wouldn't show the menus anyways.

@kittaakos
Copy link
Contributor Author

why does this need to be enabled separately for each language client (e.g. separately in java-client-contribution.ts vs. cpp-client-contribution.ts?

@HighCommander4, thank you for your remark. 👍 This PR is a POC. Once the type hierarchy LSP extension is accepted, we can register the feature in a generic way by relying on the server capabilities. Hence, the explicit type hierarchy feature registration per language will not be necessary.

Please note, the proposal and the reference implementation will change due to this: microsoft/vscode-languageserver-node#346 (comment)

@kittaakos kittaakos force-pushed the GH-707 branch 3 times, most recently from 380dd03 to 1863194 Compare January 25, 2019 15:21

/**
* The range that should be selected and revealed when this type hierarchy item is being picked, e.g the name
* of a function. Must be contained by the the `range`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: duplicate "the"

export interface TypeHierarchyParams extends TextDocumentPositionParams {

/**
* The hierarchy levels to resolve. `0` indicates no level. When no defined, it is treated as `0`.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: no defined -> not defined

/**
* The item to resolve.
*/
item: TypeHierarchyItem;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the client need to send a full TypeHierarchyItem - which includes things like the symbol kind, range, and selection range - to identify what it wants to resolve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To have a symmetric API with other existing language feature. For instance, completionItem/resolve.

item: TypeHierarchyItem;

/**
* The hierarchy levels to resolve. `0` indicates no level.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a way of saying "resolve all levels"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can use Number.MAX_SAFE_INTEGER.

@kittaakos
Copy link
Contributor Author

this implementation differs from the proposal

It is not the case anymore.

@AlexTugarev
Copy link
Contributor

@kittaakos, FYI [email protected] implements this protocol extension.

node.resolved = true;
const items = TypeHierarchyType.SUBTYPE === type ? resolvedItem.children : resolvedItem.parents;
if (items) {
node.children = items.map(child => TypeHierarchyTree.Node.create(child, type));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be passing resolved = false to create()? The protocol call above is using resolve: 1, so the node itself will be resolved but the children won't be.

tsconfig.json Outdated
@@ -121,4 +124,4 @@
"packages/*/src",
"examples/*/test"
]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add new line at the end.

@kittaakos
Copy link
Contributor Author

Ready for the review.

client.registerFeature(SemanticHighlightingService.createNewFeature(this.semanticHighlightingService, client));
client.registerFeatures([
SemanticHighlightingService.createNewFeature(this.semanticHighlightingService, client),
]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo

@@ -24,7 +24,7 @@ import {
ServerCapabilities,
Disposable,
DocumentSelector
} from '../';
} from '../index';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo

/**
* Enumeration of available type hierarchy types.
*/
export enum TypeHierarchyType {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove

"@theia/core": "^0.4.0",
"@theia/editor": "^0.4.0",
"@theia/languages": "^0.4.0",
"@theia/monaco": "^0.4.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

why?

/**
* Performs the `textDocument/typeHierarchy` LS method invocations.
*/
protected async types(arg: TypeHierarchyItem | TextDocumentPositionParams | Location, direction: TypeHierarchyDirection): Promise<TypeHierarchyItem | undefined> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

todo: public

/**
* Converts the argument into a text document position parameter. Returns with the argument if it was a text document position parameter.
*/
protected toTextDocumentPositionParams(arg: TypeHierarchyItem | TextDocumentPositionParams | Location): TypeHierarchyParams {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wrong. should call typeHierarchy/resolve instead.

@kittaakos
Copy link
Contributor Author

we can register the feature in a generic way

It's done.

@kittaakos kittaakos force-pushed the GH-707 branch 2 times, most recently from 79ffbdf to 890755a Compare March 6, 2019 07:47
@AlexTugarev AlexTugarev self-requested a review March 6, 2019 07:51
 - Extended the LSP with the type hierarchy.
 - From now on, a tree node can carry decoration data.
 - Added editor access for the current/active editors.

Closes: #707.

Signed-off-by: Akos Kitta <[email protected]>
@kittaakos
Copy link
Contributor Author

Ready for the review. A try-out branch is here: #4490

Copy link
Contributor

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

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

I ❤️ it! I tried it with the test PR.

Just two remarks, which can be discussed and tackled separately.

  1. The menu contribution: WDYT of adding an Code Analysis sub-menu to the context menu? I fear that it will "explode" with the call hierarchy contribution.
  2. A progress indicator would be nice, as some request might take a while, e.g. here the subtypes for Runnable, which comes back after +10 seconds and in the meantime the view is empty.

screen shot 2019-03-07 at 10 39 31

@kittaakos kittaakos merged commit 8ff594a into master Mar 7, 2019
llvm-git-migration pushed a commit to llvm/llvm-project that referenced this pull request Mar 19, 2019
Summary:
Patch by Nathan Ridge(@nridge)!

This is an LSP extension proposed here:
microsoft/vscode-languageserver-node#426

An example client implementation can be found here:
eclipse-theia/theia#3802

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56370

llvm-svn: 356445
dtzWill pushed a commit to llvm-mirror/clang-tools-extra that referenced this pull request Mar 19, 2019
Summary:
Patch by Nathan Ridge(@nridge)!

This is an LSP extension proposed here:
microsoft/vscode-languageserver-node#426

An example client implementation can be found here:
eclipse-theia/theia#3802

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56370

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@356445 91177308-0d34-0410-b5e6-96231b3b80d8
@marcdumais-work marcdumais-work deleted the GH-707 branch March 20, 2019 10:54
arichardson pushed a commit to arichardson/llvm-project that referenced this pull request Apr 8, 2019
Summary:
Patch by Nathan Ridge(@nridge)!

This is an LSP extension proposed here:
microsoft/vscode-languageserver-node#426

An example client implementation can be found here:
eclipse-theia/theia#3802

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56370

llvm-svn: 356445
shrouxm pushed a commit to sourcegraph/lsif-clang that referenced this pull request Jul 12, 2020
Summary:
Patch by Nathan Ridge(@nridge)!

This is an LSP extension proposed here:
microsoft/vscode-languageserver-node#426

An example client implementation can be found here:
eclipse-theia/theia#3802

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet

Tags: #clang

Differential Revision: https://reviews.llvm.org/D56370

llvm-svn: 356445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants