use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class ConditionalsLiveHoverProvider method provideHover.
private Hover provideHover(Annotation annotation, TextDocument doc, SpringBootApp[] runningApps) {
try {
List<Either<String, MarkedString>> hoverContent = new ArrayList<>();
Optional<List<LiveConditional>> val = getMatchedLiveConditionals(annotation, runningApps);
if (val.isPresent()) {
addHoverContent(val.get(), hoverContent);
}
Range hoverRange = doc.toRange(annotation.getStartPosition(), annotation.getLength());
Hover hover = new Hover();
hover.setContents(hoverContent);
hover.setRange(hoverRange);
return hover;
} catch (Exception e) {
Log.log(e);
}
return null;
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class WebFluxCodeLensProviderTest method containsCodeLens.
private boolean containsCodeLens(List<? extends CodeLens> codeLenses, String commandTitle, int startLine, int startPosition, int endLine, int endPosition) {
for (CodeLens codeLens : codeLenses) {
Command command = codeLens.getCommand();
Range range = codeLens.getRange();
if (command.getTitle().equals(commandTitle) && range.getStart().getLine() == startLine && range.getStart().getCharacter() == startPosition && range.getEnd().getLine() == endLine && range.getEnd().getCharacter() == endPosition) {
return true;
}
}
return false;
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class WebfluxElementsInformationTest method testContainsMultipleLineRange.
@Test
public void testContainsMultipleLineRange() {
Range range = new Range(new Position(2, 10), new Position(4, 5));
WebfluxElementsInformation information = new WebfluxElementsInformation(new Range[] { range });
assertFalse(information.contains(new Position(1, 1)));
assertFalse(information.contains(new Position(1, 11)));
assertFalse(information.contains(new Position(2, 1)));
assertFalse(information.contains(new Position(2, 9)));
assertTrue(information.contains(new Position(2, 10)));
assertTrue(information.contains(new Position(2, 11)));
assertTrue(information.contains(new Position(2, 40)));
assertTrue(information.contains(new Position(3, 1)));
assertTrue(information.contains(new Position(3, 12)));
assertTrue(information.contains(new Position(3, 50)));
assertTrue(information.contains(new Position(4, 1)));
assertTrue(information.contains(new Position(4, 5)));
assertFalse(information.contains(new Position(4, 6)));
assertFalse(information.contains(new Position(4, 10)));
assertFalse(information.contains(new Position(5, 1)));
assertFalse(information.contains(new Position(5, 20)));
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class WebfluxElementsInformationTest method testContainsMultipleRanges.
@Test
public void testContainsMultipleRanges() {
Range range1 = new Range(new Position(2, 10), new Position(3, 20));
Range range2 = new Range(new Position(5, 2), new Position(5, 3));
Range range3 = new Range(new Position(10, 10), new Position(20, 20));
Range range4 = new Range(new Position(4, 40), new Position(6, 3));
WebfluxElementsInformation information = new WebfluxElementsInformation(new Range[] { range1, range2, range3, range4 });
assertFalse(information.contains(new Position(2, 9)));
assertTrue(information.contains(new Position(2, 10)));
assertTrue(information.contains(new Position(3, 19)));
assertTrue(information.contains(new Position(3, 20)));
assertFalse(information.contains(new Position(3, 21)));
assertTrue(information.contains(new Position(5, 1)));
assertTrue(information.contains(new Position(5, 2)));
assertTrue(information.contains(new Position(5, 3)));
assertTrue(information.contains(new Position(5, 4)));
assertFalse(information.contains(new Position(4, 39)));
assertTrue(information.contains(new Position(4, 40)));
assertTrue(information.contains(new Position(4, 41)));
assertTrue(information.contains(new Position(6, 2)));
assertTrue(information.contains(new Position(6, 3)));
assertFalse(information.contains(new Position(6, 4)));
assertFalse(information.contains(new Position(9, 10)));
assertFalse(information.contains(new Position(10, 9)));
assertTrue(information.contains(new Position(10, 10)));
assertTrue(information.contains(new Position(10, 21)));
assertTrue(information.contains(new Position(15, 3)));
assertTrue(information.contains(new Position(20, 20)));
assertFalse(information.contains(new Position(20, 21)));
assertFalse(information.contains(new Position(23, 1)));
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class WebfluxElementsInformationTest method testContainsSingleCharacterRange.
@Test
public void testContainsSingleCharacterRange() {
Range range = new Range(new Position(3, 10), new Position(3, 10));
WebfluxElementsInformation information = new WebfluxElementsInformation(new Range[] { range });
assertFalse(information.contains(new Position(3, 9)));
assertTrue(information.contains(new Position(3, 10)));
assertFalse(information.contains(new Position(3, 11)));
}
Aggregations