Merge branch 'master' of github.com:spring-projects/sts4
This commit is contained in:
@@ -62,12 +62,19 @@ Example entry:
|
||||
|
||||
private JSONObject getHandlerMethod() {
|
||||
JSONObject details = getDetails();
|
||||
return details == null ? null : details.getJSONObject("handlerMethod");
|
||||
if (details != null) {
|
||||
if (details.has("handlerMethod")) {
|
||||
return details.getJSONObject("handlerMethod");
|
||||
} else if (details.has("handlerFunction")) {
|
||||
//TODO: handler function for the Router bean
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONObject getRequestMappingConditions() {
|
||||
JSONObject details = getDetails();
|
||||
return details == null ? null : details.getJSONObject("requestMappingConditions");
|
||||
return details == null ? null : details.optJSONObject("requestMappingConditions");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,9 @@ package org.springframework.ide.vscode.commons.boot.app.cli;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.json.JSONObject;
|
||||
@@ -20,6 +22,8 @@ import org.junit.Test;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMapping;
|
||||
import org.springframework.ide.vscode.commons.boot.app.cli.requestmappings.RequestMappingsParser20;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public class Boot2xRequestMappingsTest {
|
||||
|
||||
@Test
|
||||
@@ -27,13 +31,62 @@ public class Boot2xRequestMappingsTest {
|
||||
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-web.json"));
|
||||
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
|
||||
assertEquals(10, rms.size());
|
||||
|
||||
ImmutableSet<String> expected = ImmutableSet.of(
|
||||
"/error",
|
||||
"/actuator",
|
||||
"/actuator/health",
|
||||
"/actuator/info",
|
||||
"/hello",
|
||||
"/qq",
|
||||
"/pp"
|
||||
);
|
||||
assertEquals(expected,
|
||||
rms.stream()
|
||||
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
|
||||
.collect(Collectors.toSet())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWebFluxAnnotationRms() throws Exception {
|
||||
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux.json"));
|
||||
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
|
||||
|
||||
assertEquals(7, rms.size());
|
||||
|
||||
ImmutableSet<String> expected = ImmutableSet.of(
|
||||
"/actuator",
|
||||
"/actuator/health",
|
||||
"/actuator/info",
|
||||
"/hello",
|
||||
"/pp",
|
||||
"/qq"
|
||||
);
|
||||
assertEquals(expected,
|
||||
rms.stream()
|
||||
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
|
||||
.collect(Collectors.toSet())
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWebFluxAnnotationRmsFunctional() throws Exception {
|
||||
String json = IOUtils.toString(Boot2xRequestMappingsTest.class.getResourceAsStream("/live-rm-beans/rms-boot2-webflux-functional.json"));
|
||||
Collection<RequestMapping> rms = RequestMappingsParser20.parse(new JSONObject(json));
|
||||
|
||||
assertEquals(6, rms.size());
|
||||
|
||||
ImmutableSet<String> expected = ImmutableSet.of(
|
||||
"/actuator",
|
||||
"/actuator/health",
|
||||
"/actuator/info"
|
||||
);
|
||||
assertEquals(expected,
|
||||
rms.stream()
|
||||
.flatMap(rm -> Arrays.stream(rm.getSplitPath()))
|
||||
.collect(Collectors.toSet())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.stream.Stream;
|
||||
import org.eclipse.jdt.core.dom.Annotation;
|
||||
import org.eclipse.jdt.core.dom.IAnnotationBinding;
|
||||
import org.eclipse.jdt.core.dom.ITypeBinding;
|
||||
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
|
||||
import org.springframework.ide.vscode.commons.util.CollectorUtil;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -34,28 +35,31 @@ import com.google.common.collect.ImmutableList;
|
||||
*/
|
||||
public abstract class AnnotationHierarchies {
|
||||
|
||||
private AnnotationHierarchies() {
|
||||
}
|
||||
|
||||
protected static boolean ignoreAnnotation(String fqname) {
|
||||
return fqname.startsWith("java."); //mostly intended to capture java.lang.annotation.* types. But really it should be
|
||||
//safe to ignore any type defined by the JRE since it can't possibly be inheriting from a spring annotation.
|
||||
};
|
||||
|
||||
public static Collection<ITypeBinding> getDirectSuperAnnotations(ITypeBinding typeBinding) {
|
||||
IAnnotationBinding[] annotations = typeBinding.getAnnotations();
|
||||
if (annotations!=null && annotations.length!=0) {
|
||||
ImmutableList.Builder<ITypeBinding> superAnnotations = ImmutableList.builder();
|
||||
for (IAnnotationBinding ab : annotations) {
|
||||
ITypeBinding sa = ab.getAnnotationType();
|
||||
if (sa!=null) {
|
||||
if (!ignoreAnnotation(sa.getQualifiedName())) {
|
||||
superAnnotations.add(sa);
|
||||
try {
|
||||
IAnnotationBinding[] annotations = typeBinding.getAnnotations();
|
||||
if (annotations != null && annotations.length != 0) {
|
||||
ImmutableList.Builder<ITypeBinding> superAnnotations = ImmutableList.builder();
|
||||
for (IAnnotationBinding ab : annotations) {
|
||||
ITypeBinding sa = ab.getAnnotationType();
|
||||
if (sa != null) {
|
||||
if (!ignoreAnnotation(sa.getQualifiedName())) {
|
||||
superAnnotations.add(sa);
|
||||
}
|
||||
}
|
||||
}
|
||||
return superAnnotations.build();
|
||||
}
|
||||
return superAnnotations.build();
|
||||
}
|
||||
catch (AbortCompilation e) {
|
||||
// ignore this, it is most likely caused by broken source code, a broken classpath, or some optional dependencies not being on the classpath
|
||||
}
|
||||
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ import com.google.common.collect.ImmutableList;
|
||||
*/
|
||||
public class AnnotationHierarchyAwareLookup<T> {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
private static class Binding<T> {
|
||||
T value;
|
||||
boolean isOverriding;
|
||||
|
||||
Reference in New Issue
Block a user