use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class WebfluxElementsInformationTest method testContainsSingleLineRange.
@Test
public void testContainsSingleLineRange() {
Range range = new Range(new Position(3, 10), new Position(3, 20));
WebfluxElementsInformation information = new WebfluxElementsInformation(new Range[] { range });
assertFalse(information.contains(new Position(3, 5)));
assertTrue(information.contains(new Position(3, 11)));
assertFalse(information.contains(new Position(3, 25)));
assertFalse(information.contains(new Position(1, 12)));
assertFalse(information.contains(new Position(2, 1)));
assertFalse(information.contains(new Position(4, 21)));
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class LiveAppURLSymbolProvider method getSymbols.
public List<? extends SymbolInformation> getSymbols(String query) {
System.out.println(query);
List<SymbolInformation> result = new ArrayList<>();
try {
SpringBootApp[] runningApps = runningAppProvider.getAllRunningSpringApps().toArray(new SpringBootApp[0]);
for (SpringBootApp app : runningApps) {
try {
String host = app.getHost();
String port = app.getPort();
Stream<String> urls = app.getRequestMappings().stream().flatMap(rm -> Arrays.stream(rm.getSplitPath())).map(path -> UrlUtil.createUrl(host, port, path));
urls.forEach(url -> result.add(new SymbolInformation(url, SymbolKind.Method, new Location(url, new Range(new Position(0, 0), new Position(0, 1))))));
} catch (Exception e) {
Log.log(e);
}
}
} catch (Exception e) {
Log.log(e);
}
return result;
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class RequestMappingHoverProvider method provideHover.
private Hover provideHover(Annotation annotation, TextDocument doc, SpringBootApp[] runningApps) {
try {
List<Either<String, MarkedString>> hoverContent = new ArrayList<>();
List<Tuple2<RequestMapping, SpringBootApp>> val = getRequestMappingMethodFromRunningApp(annotation, runningApps);
if (!val.isEmpty()) {
addHoverContent(val, 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 WebfluxAcceptTypeFinder method visit.
@Override
public boolean visit(MethodInvocation node) {
IMethodBinding methodBinding = node.resolveMethodBinding();
try {
if (WebfluxUtils.REQUEST_PREDICATES_TYPE.equals(methodBinding.getDeclaringClass().getBinaryName())) {
String name = methodBinding.getName();
if (name != null && WebfluxUtils.REQUEST_PREDICATE_ACCEPT_TYPE_METHOD.equals(name)) {
SimpleName nameArgument = WebfluxUtils.extractSimpleNameArgument(node);
if (nameArgument != null && nameArgument.getFullyQualifiedName() != null) {
Range range = doc.toRange(nameArgument.getStartPosition(), nameArgument.getLength());
acceptTypes.add(new WebfluxRouteElement(nameArgument.getFullyQualifiedName().toString(), range));
}
}
}
} catch (BadLocationException e) {
// ignore
}
return !WebfluxUtils.isRouteMethodInvocation(methodBinding);
}
use of org.eclipse.lsp4j.Range in project sts4 by spring-projects.
the class WebfluxMethodFinder method visit.
@Override
public boolean visit(MethodInvocation node) {
boolean visitChildren = true;
if (node != this.root) {
IMethodBinding methodBinding = node.resolveMethodBinding();
try {
if (WebfluxUtils.REQUEST_PREDICATES_TYPE.equals(methodBinding.getDeclaringClass().getBinaryName())) {
String name = methodBinding.getName();
if (name != null && WebfluxUtils.REQUEST_PREDICATE_HTTPMETHOD_METHODS.contains(name)) {
Range range = doc.toRange(node.getStartPosition(), node.getLength());
methods.add(new WebfluxRouteElement(name, range));
} else if (name != null && WebfluxUtils.REQUEST_PREDICATE_METHOD_METHOD.equals(name)) {
QualifiedName qualifiedName = WebfluxUtils.extractQualifiedNameArgument(node);
if (qualifiedName.getName() != null) {
Range range = doc.toRange(qualifiedName.getStartPosition(), qualifiedName.getLength());
methods.add(new WebfluxRouteElement(qualifiedName.getName().toString(), range));
}
}
}
} catch (BadLocationException e) {
// ignore
}
if (WebfluxUtils.isRouteMethodInvocation(methodBinding)) {
visitChildren = false;
}
}
return visitChildren;
}
Aggregations