use of org.eclipse.lsp4j.Hover in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method mxmlHover.
private CompletableFuture<Hover> mxmlHover(TextDocumentPositionParams position, IMXMLTagData offsetTag) {
IDefinition definition = getDefinitionForMXMLNameAtOffset(offsetTag, currentOffset);
if (definition == null) {
return CompletableFuture.completedFuture(new Hover(Collections.emptyList(), null));
}
if (isInsideTagPrefix(offsetTag, currentOffset)) {
//inside the prefix
String prefix = offsetTag.getPrefix();
Hover result = new Hover();
List<String> contents = new ArrayList<>();
StringBuilder detailBuilder = new StringBuilder();
detailBuilder.append(MARKDOWN_CODE_BLOCK_MXML_START);
if (prefix.length() > 0) {
detailBuilder.append("xmlns:" + prefix + "=\"" + offsetTag.getURI() + "\"");
} else {
detailBuilder.append("xmlns=\"" + offsetTag.getURI() + "\"");
}
detailBuilder.append(MARKDOWN_CODE_BLOCK_END);
contents.add(detailBuilder.toString());
result.setContents(contents);
return CompletableFuture.completedFuture(result);
}
Hover result = new Hover();
String detail = getDefinitionDetail(definition);
List<String> contents = new ArrayList<>();
contents.add(MARKDOWN_CODE_BLOCK_NEXTGENAS_START + detail + MARKDOWN_CODE_BLOCK_END);
result.setContents(contents);
return CompletableFuture.completedFuture(result);
}
use of org.eclipse.lsp4j.Hover in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method hover.
/**
* Returns information to display in a tooltip when the mouse hovers over
* something in a text document.
*/
@Override
public CompletableFuture<Hover> hover(TextDocumentPositionParams position) {
String textDocumentUri = position.getTextDocument().getUri();
if (!textDocumentUri.endsWith(AS_EXTENSION) && !textDocumentUri.endsWith(MXML_EXTENSION)) {
return CompletableFuture.completedFuture(new Hover(Collections.emptyList(), null));
}
IMXMLTagData offsetTag = getOffsetMXMLTag(position);
if (offsetTag != null) {
IASNode embeddedNode = getEmbeddedActionScriptNodeInMXMLTag(offsetTag, currentOffset, position);
if (embeddedNode != null) {
return actionScriptHoverWithNode(position, embeddedNode);
}
//so that's why we call isMXMLTagValidForCompletion()
if (isMXMLTagValidForCompletion(offsetTag)) {
return mxmlHover(position, offsetTag);
}
}
return actionScriptHover(position);
}
use of org.eclipse.lsp4j.Hover in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method actionScriptHoverWithNode.
private CompletableFuture<Hover> actionScriptHoverWithNode(TextDocumentPositionParams position, IASNode offsetNode) {
IDefinition definition = null;
if (offsetNode == null) {
//we couldn't find a node at the specified location
return CompletableFuture.completedFuture(new Hover(Collections.emptyList(), null));
}
//any hover information for it.
if (definition == null && offsetNode instanceof IIdentifierNode && !(offsetNode instanceof INamespaceDecorationNode)) {
IIdentifierNode identifierNode = (IIdentifierNode) offsetNode;
definition = identifierNode.resolve(currentUnit.getProject());
}
if (definition == null) {
return CompletableFuture.completedFuture(new Hover(Collections.emptyList(), null));
}
Hover result = new Hover();
String detail = getDefinitionDetail(definition);
List<String> contents = new ArrayList<>();
contents.add(MARKDOWN_CODE_BLOCK_NEXTGENAS_START + detail + MARKDOWN_CODE_BLOCK_END);
result.setContents(contents);
return CompletableFuture.completedFuture(result);
}
use of org.eclipse.lsp4j.Hover in project eclipse.jdt.ls by eclipse.
the class HoverHandler method hover.
public Hover hover(TextDocumentPositionParams position, IProgressMonitor monitor) {
ITypeRoot unit = JDTUtils.resolveTypeRoot(position.getTextDocument().getUri());
List<Either<String, MarkedString>> content = null;
if (unit != null && !monitor.isCanceled()) {
content = computeHover(unit, position.getPosition().getLine(), position.getPosition().getCharacter(), monitor);
}
Hover $ = new Hover();
$.setContents(content);
return $;
}
use of org.eclipse.lsp4j.Hover in project eclipse.jdt.ls by eclipse.
the class HoverHandlerTest method testHoverUnresolvedType.
@Test
public void testHoverUnresolvedType() throws Exception {
importProjects("eclipse/unresolvedtype");
project = WorkspaceHelper.getProject("unresolvedtype");
handler = new HoverHandler(preferenceManager);
// given
// Hovers on the IFoo
String payload = createHoverRequest("src/pckg/Foo.java", 2, 31);
TextDocumentPositionParams position = getParams(payload);
// when
Hover hover = handler.hover(position, monitor);
assertNotNull(hover);
assertTrue("Unexpected hover ", hover.getContents().isEmpty());
}
Aggregations