use of org.eclipse.lsp4j.Hover in project sts4 by spring-projects.
the class BootJavaHoverProvider method handle.
@Override
public Hover handle(TextDocumentPositionParams params) {
SimpleTextDocumentService documents = server.getTextDocumentService();
if (documents.get(params) != null) {
TextDocument doc = documents.get(params).copy();
try {
int offset = doc.toOffset(params.getPosition());
Hover hoverResult = provideHover(doc, offset);
if (hoverResult != null) {
return hoverResult;
}
} catch (Exception e) {
}
}
return SimpleTextDocumentService.NO_HOVER;
}
use of org.eclipse.lsp4j.Hover in project sts4 by spring-projects.
the class ActiveProfilesProvider method provideHover.
@Override
public Hover provideHover(ASTNode node, Annotation annotation, ITypeBinding type, int offset, TextDocument doc, IJavaProject project, SpringBootApp[] runningApps) {
if (runningApps.length > 0) {
StringBuilder markdown = new StringBuilder();
markdown.append("**Active Profiles**\n\n");
boolean hasInterestingApp = false;
for (SpringBootApp app : runningApps) {
List<String> profiles = app.getActiveProfiles();
if (profiles == null) {
markdown.append(niceAppName(app) + " : _Unknown_\n\n");
} else {
hasInterestingApp = true;
if (profiles.isEmpty()) {
markdown.append(niceAppName(app) + " : _None_\n\n");
} else {
markdown.append(niceAppName(app) + " :\n");
for (String profile : profiles) {
markdown.append("- " + profile + "\n");
}
markdown.append("\n");
}
}
}
if (hasInterestingApp) {
return new Hover(ImmutableList.of(Either.forLeft(markdown.toString())));
}
}
return null;
}
use of org.eclipse.lsp4j.Hover in project sts4 by spring-projects.
the class Editor method assertIsHoverRegion.
public void assertIsHoverRegion(String string) throws Exception {
int hoverPosition = getHoverPosition(string, 1);
Hover hover = harness.getHover(doc, doc.toPosition(hoverPosition));
assertEquals(string, getText(hover.getRange()));
}
use of org.eclipse.lsp4j.Hover in project sts4 by spring-projects.
the class Editor method assertTrimmedHover.
public void assertTrimmedHover(String hoverOver, String expectedHover) throws Exception {
int hoverPosition = getHoverPosition(hoverOver, 1);
Hover hover = harness.getHover(doc, doc.toPosition(hoverPosition));
assertEquals(expectedHover.trim(), hoverString(hover).trim());
}
use of org.eclipse.lsp4j.Hover in project sts4 by spring-projects.
the class Editor method assertNoHover.
public void assertNoHover(String hoverOver) throws Exception {
int hoverPosition = getRawText().indexOf(hoverOver) + hoverOver.length() / 2;
Hover hover = harness.getHover(doc, doc.toPosition(hoverPosition));
List<Either<String, MarkedString>> contents = hover.getContents();
assertTrue(contents.toString(), contents.isEmpty());
}
Aggregations