Skip to content

Commit

Permalink
eclipse-lsp4jGH-296: Extended the protocol with `textDocument/callHie…
Browse files Browse the repository at this point in the history
…rarchy`.

Closes eclipse-lsp4j#296.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
  • Loading branch information
Akos Kitta committed Jan 25, 2019
1 parent db9f9bd commit e9056e1
Show file tree
Hide file tree
Showing 12 changed files with 1,033 additions and 6 deletions.
184 changes: 182 additions & 2 deletions org.eclipse.lsp4j/src/main/java/org/eclipse/lsp4j/Protocol.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,16 @@ class FoldingRangeCapabilities extends DynamicRegistrationCapabilities {

/**
* Capabilities specific to {@code textDocument/semanticHighlighting}.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/367">{@code textDocument/semanticHighlighting}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRpcData
class SemanticHighlightingCapabilities {

/**
* The client supports semantic highlighting.
*/
Expand All @@ -771,6 +777,11 @@ class SemanticHighlightingCapabilities {
/**
* Capabilities specific to the {@code textDocument/typeHierarchy} and the {@code typeHierarchy/resolve}
* language server methods.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/426">{@code textDocument/typeHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRpcData
Expand All @@ -781,11 +792,29 @@ class TypeHierarchyCapabilities {
*/
Boolean typeHierarchy

new(Boolean typeHierarchy) {
this.typeHierarchy = typeHierarchy
}

}

/**
* Capabilities specific to the {@code textDocument/callHierarchy}.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/420">{@code textDocument/callHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRpcData
class CallHierarchyCapabilities extends DynamicRegistrationCapabilities {

new() {
}

new(Boolean typeHierarchy) {
this.typeHierarchy = typeHierarchy
new(Boolean dynamicRegistration) {
super(dynamicRegistration)
}

}
Expand Down Expand Up @@ -912,6 +941,13 @@ class TextDocumentClientCapabilities {
*/
@Beta
TypeHierarchyCapabilities typeHierarchyCapabilities

/**
* Capabilities specific to {@code textDocument/callHierarchy}.
*/
@Beta
CallHierarchyCapabilities callHierarchy

}

/**
Expand Down Expand Up @@ -2837,14 +2873,32 @@ class ServerCapabilities {
/**
* Semantic highlighting server capabilities.
*/
@Beta
SemanticHighlightingServerCapabilities semanticHighlighting

/**
* Server capability for calculating super- and subtype hierarchies.
* The LS supports the type hierarchy language feature, if this capability is set to {@code true}.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/426">{@code textDocument/typeHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
Boolean typeHierarchy

/**
* The server provides Call Hierarchy support.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/420">{@code textDocument/callHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
Either<Boolean, StaticRegistrationOptions> callHierarchyProvider

/**
* Experimental server capabilities.
*/
Expand Down Expand Up @@ -2875,6 +2929,11 @@ class WorkspaceServerCapabilities {

/**
* Semantic highlighting server capabilities.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/367">{@code textDocument/semanticHighlighting}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRpcData
Expand Down Expand Up @@ -4598,3 +4657,124 @@ class SemanticHighlightingInformation {
this.tokens = tokens
}
}

/**
* The parameters of a {@code textDocument/callHierarchy} request.
*/
@Beta
@JsonRpcData
class CallHierarchyParams extends TextDocumentPositionParams {

/**
* The number of levels to resolve.
*/
int resolve

/**
* Outgoing direction for callees. Valid values are: {@code incoming} and {@code outgoing}.
* The default is {@code incoming} for callers.
*/
String direction

}

/**
* The parameters of a {@code callHierarchy/resolve} request.
*/
@Beta
@JsonRpcData
class ResolveCallHierarchyItemParams {

/**
* Unresolved item.
*/
@NonNull
CallHierarchyItem item

/**
* The number of levels to resolve.
*/
int resolve

/**
* Outgoing direction for callees. Valid values are: {@code incoming} and {@code outgoing}.
* The default is {@code incoming} for callers.
*/
@NonNull
String direction

}

/**
* The result of a {@code textDocument/callHierarchy} request.
*/
@Beta
@JsonRpcData
class CallHierarchyItem {

/**
* The name of the symbol targeted by the call hierarchy request.
*/
@NonNull
String name

/**
* More detail for this symbol, e.g the signature of a function.
*/
String detail

/**
* The kind of this symbol.
*/
@NonNull
SymbolKind kind

/**
* URI of the document containing the symbol.
*/
@NonNull
String uri

/**
* The range enclosing this symbol not including leading/trailing whitespace but everything else
* like comments. This information is typically used to determine if the the clients cursor is
* inside the symbol to reveal in the symbol in the UI.
*/
@NonNull
Range range

/**
* The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
* Must be contained by the the {@code range}.
*/
@NonNull
Range selectionRange

/**
* The actual location of the call.
*
* <b>Must be defined</b> in resolved callers/callees.
*/
Location callLocation

/**
* List of incoming calls.
*
* <i>Note</i>: The items is <em>unresolved</em> if {@code callers} and {@code callees} is not defined.
*/
List<CallHierarchyItem> callers

/**
* List of outgoing calls.
*
* *Note*: The items is <em>unresolved</em> if {@code callers} and {@code callees} is not defined.
*/
List<CallHierarchyItem> callees

/**
* Optional data to identify an item in a resolve request.
*/
@JsonAdapter(JsonElementTypeAdapter.Factory)
Object data

}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ default CompletableFuture<List<Object>> configuration(ConfigurationParams config
* the server sends the semantic highlighting information for the entire document, but if the server
* receives a {@code DidChangeTextDocumentNotification}, it pushes the information only about
* the affected lines in the document.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/367">{@code textDocument/semanticHighlighting}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonNotification("textDocument/semanticHighlighting")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;

import org.eclipse.lsp4j.CallHierarchyItem;
import org.eclipse.lsp4j.CallHierarchyParams;
import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeActionParams;
import org.eclipse.lsp4j.CodeLens;
Expand Down Expand Up @@ -47,6 +49,7 @@
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.ReferenceParams;
import org.eclipse.lsp4j.RenameParams;
import org.eclipse.lsp4j.ResolveCallHierarchyItemParams;
import org.eclipse.lsp4j.ResolveTypeHierarchyItemParams;
import org.eclipse.lsp4j.SignatureHelp;
import org.eclipse.lsp4j.SymbolInformation;
Expand Down Expand Up @@ -415,6 +418,11 @@ default CompletableFuture<Either<Range, PrepareRenameResult>> prepareRename(Text
* request would also allow to specify if the item should be resolved and
* whether sub- or supertypes are to be resolved. If no type hierarchy item can
* be found under the given text document position, resolves to {@code null}.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/426">{@code textDocument/typeHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRequest
Expand All @@ -428,11 +436,51 @@ default CompletableFuture<TypeHierarchyItem> typeHierarchy(TypeHierarchyParams p
* item}. A type hierarchy item is unresolved if the if the
* {@link TypeHierarchyItem#getParents parents} or the
* {@link TypeHierarchyItem#getChildren children} is not defined.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/426">{@code textDocument/typeHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRequest(value="typeHierarchy/resolve", useSegment = false)
default CompletableFuture<TypeHierarchyItem> resolveTypeHierarchy(ResolveTypeHierarchyItemParams params) {
throw new UnsupportedOperationException();
}

/**
* Request to request the call hierarchy at a given text document position.
*
* The optional request's parameter defines the maximum number of levels to
* {@link CallHierarchyParams#getResolve() resolve} by this request. Unresolved
* items can be resolved in subsequent {@code callHierarchy/resolve} requests.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/420">{@code textDocument/callHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRequest
default CompletableFuture<CallHierarchyItem> callHierarchy(CallHierarchyParams params) {
throw new UnsupportedOperationException();
}

/**
* Request to resolve a call hierarchy item.
*
* The request's parameter is of type {@link ResolveCallHierarchyItemParams}.
* The response is of type {@link CallHierarchyItem}.
*
* <p>
* <b>Note:</b> the <a href=
* "https://github.com/Microsoft/vscode-languageserver-node/pull/420">{@code textDocument/callHierarchy}
* language feature</a> is not yet part of the official LSP specification.
*/
@Beta
@JsonRequest(value = "callHierarchy/resolve", useSegment = false)
default CompletableFuture<CallHierarchyItem> resolveCallHierarchy(ResolveCallHierarchyItemParams params) {
throw new UnsupportedOperationException();
}

}
Loading

0 comments on commit e9056e1

Please sign in to comment.