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 <[email protected]>
  • Loading branch information
Akos Kitta committed Jan 24, 2019
1 parent db9f9bd commit 4204000
Show file tree
Hide file tree
Showing 8 changed files with 884 additions and 5 deletions.
142 changes: 140 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 @@ -781,11 +781,24 @@ class TypeHierarchyCapabilities {
*/
Boolean typeHierarchy

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

}

/**
* Capabilities specific to the {@code textDocument/callHierarchy}.
*/
@Beta
@JsonRpcData
class CallHierarchyCapabilities extends DynamicRegistrationCapabilities {

new() {
}

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

}
Expand Down Expand Up @@ -2845,6 +2858,12 @@ class ServerCapabilities {
*/
Boolean typeHierarchy

/**
* The server provides Call Hierarchy support.
*/
@Beta
Either<Boolean, StaticRegistrationOptions> callHierarchyProvider

/**
* Experimental server capabilities.
*/
Expand Down Expand Up @@ -4598,3 +4617,122 @@ 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 `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 `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 @@ -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 @@ -48,6 +50,7 @@
import org.eclipse.lsp4j.ReferenceParams;
import org.eclipse.lsp4j.RenameParams;
import org.eclipse.lsp4j.ResolveTypeHierarchyItemParams;
import org.eclipse.lsp4j.ResolveCallHierarchyItemParams;
import org.eclipse.lsp4j.SignatureHelp;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentPositionParams;
Expand Down Expand Up @@ -435,4 +438,29 @@ default CompletableFuture<TypeHierarchyItem> resolveTypeHierarchy(ResolveTypeHie
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.
*/
@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}.
*/
@Beta
@JsonRequest(value = "callHierarchy/resolve", useSegment = false)
default CompletableFuture<CallHierarchyItem> resolveCallHierarchy(ResolveCallHierarchyItemParams params) {
throw new UnsupportedOperationException();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) 2016-2018 TypeFox and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
package org.eclipse.lsp4j;

import com.google.common.annotations.Beta;
import org.eclipse.lsp4j.DynamicRegistrationCapabilities;
import org.eclipse.xtext.xbase.lib.Pure;
import org.eclipse.xtext.xbase.lib.util.ToStringBuilder;

/**
* Capabilities specific to the {@code textDocument/callHierarchy}.
*/
@Beta
@SuppressWarnings("all")
public class CallHierarchyCapabilities extends DynamicRegistrationCapabilities {
public CallHierarchyCapabilities() {
}

public CallHierarchyCapabilities(final Boolean dynamicRegistration) {
super(dynamicRegistration);
}

@Override
@Pure
public String toString() {
ToStringBuilder b = new ToStringBuilder(this);
b.add("dynamicRegistration", getDynamicRegistration());
return b.toString();
}

@Override
@Pure
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (!super.equals(obj))
return false;
return true;
}

@Override
@Pure
public int hashCode() {
return super.hashCode();
}
}
Loading

0 comments on commit 4204000

Please sign in to comment.