-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
In #3148, you mentioned that this implementation differs from the proposal in microsoft/vscode-languageserver-node#346. Can you explain how it differs? |
I saw this, but I don't really understand what to get from it. |
Which part needs clarification? |
Well, what in your implementation differs from the proposal. Different methods, fields? |
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? |
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. |
I implemented server support for the One question, @kittaakos: why does this need to be enabled separately for each language client (e.g. separately in |
@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) |
380dd03
to
1863194
Compare
|
||
/** | ||
* 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`. |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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
.
It is not the case anymore. |
@kittaakos, FYI |
node.resolved = true; | ||
const items = TypeHierarchyType.SUBTYPE === type ? resolvedItem.children : resolvedItem.parents; | ||
if (items) { | ||
node.children = items.map(child => TypeHierarchyTree.Node.create(child, type)); |
There was a problem hiding this comment.
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" | |||
] | |||
} | |||
} |
There was a problem hiding this comment.
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.
Ready for the review.
|
client.registerFeature(SemanticHighlightingService.createNewFeature(this.semanticHighlightingService, client)); | ||
client.registerFeatures([ | ||
SemanticHighlightingService.createNewFeature(this.semanticHighlightingService, client), | ||
]); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
packages/typehierarchy/package.json
Outdated
"@theia/core": "^0.4.0", | ||
"@theia/editor": "^0.4.0", | ||
"@theia/languages": "^0.4.0", | ||
"@theia/monaco": "^0.4.0", |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
It's done. |
79ffbdf
to
890755a
Compare
- 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]>
Ready for the review. A try-out branch is here: #4490 |
There was a problem hiding this 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.
- 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. - 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.
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
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
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
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
Originally from here: #3148.
Closes: #707.
Signed-off-by: Akos Kitta [email protected]