Removed old way of matching annotations

This commit is contained in:
nsingh
2017-10-27 11:04:41 -07:00
parent 06e86a33a4
commit c0e55cb7e2

View File

@@ -104,7 +104,6 @@ public class RequestMappingHoverProvider implements HoverProvider {
Collection<RequestMapping> mappings = app.getRequestMappings();
if (mappings != null && !mappings.isEmpty()) {
mappings.stream()
// .filter(rm -> matchesAnnotation(annotation, rm))
.filter(rm -> methodMatchesAnnotation(annotation, rm))
.map(rm -> Tuples.of(rm, app))
.findFirst().ifPresent(t -> results.add(t));
@@ -171,118 +170,4 @@ public class RequestMappingHoverProvider implements HoverProvider {
}
}
// protected String getRequestMethod(SingleMemberAnnotation annotation) {
// ITypeBinding type = annotation.resolveTypeBinding();
// if (type != null) {
// switch (type.getQualifiedName()) {
// case Constants.SPRING_GET_MAPPING:
// return "GET";
// case Constants.SPRING_POST_MAPPING:
// return "POST";
// case Constants.SPRING_DELETE_MAPPING:
// return "DELETE";
// case Constants.SPRING_PUT_MAPPING:
// return "PUT";
// case Constants.SPRING_PATCH_MAPPING:
// return "PATCH";
// }
// }
// return null;
// }
//
// private boolean matchesAnnotation(Annotation annotation, RequestMapping rm) {
// String[] mappingPath = null;
// Set<String> methods = null;
// if (annotation instanceof SingleMemberAnnotation) {
// SingleMemberAnnotation singleAnnotation = (SingleMemberAnnotation) annotation;
// Expression valueContent = singleAnnotation.getValue();
// if (valueContent instanceof StringLiteral) {
// mappingPath = new String[] { ((StringLiteral)valueContent).getLiteralValue() };
// }
// String method = getRequestMethod(singleAnnotation);
// if (method != null) {
// methods = new HashSet<>();
// methods.add(method);
// }
// }
// else if (annotation instanceof NormalAnnotation) {
// List<?> values = ((NormalAnnotation) annotation).values();
// for (Object value : values) {
// if (value instanceof MemberValuePair) {
// MemberValuePair pair = (MemberValuePair)value;
// String name = pair.getName().toString();
// switch (name) {
// case "value":
// case "path":
// mappingPath = getPaths(pair.getValue());
// break;
// case "method":
// methods = getRequestMethod(pair.getValue());
// break;
// }
// }
// }
//
// }
//
// if (mappingPath != null) {
// if (Arrays.equals(mappingPath, rm.getSplitPath())) {
// if (methods == null || methods.isEmpty()) {
// return true;
// } else {
// return methods.equals(rm.getRequestMethods());
// }
// }
// }
// return false;
// }
//
// private static String getExpressionValueAsString(Expression exp) {
// if (exp instanceof StringLiteral) {
// return ((StringLiteral)exp).getLiteralValue();
// } else if (exp instanceof QualifiedName) {
// return getExpressionValueAsString(((QualifiedName)exp).getName());
// } else if (exp instanceof SimpleName) {
// return ((SimpleName)exp).getIdentifier();
// } else {
// return null;
// }
// }
//
// @SuppressWarnings("unchecked")
// private static String[] getPaths(Expression exp) {
// if (exp instanceof ArrayInitializer) {
// ArrayInitializer array = (ArrayInitializer) exp;
// return ((List<Expression>)array.expressions()).stream()
// .map(e -> getExpressionValueAsString(e))
// .filter(Objects::nonNull)
// .toArray(String[]::new);
// } else {
// String rm = getExpressionValueAsString(exp);
// if (rm != null) {
// return new String[] { rm };
// }
// }
// return null;
// }
//
// @SuppressWarnings("unchecked")
// private static Set<String> getRequestMethod(Expression exp) {
// if (exp instanceof ArrayInitializer) {
// ArrayInitializer array = (ArrayInitializer) exp;
// return ((List<Expression>)array.expressions()).stream()
// .map(e -> getExpressionValueAsString(e))
// .filter(Objects::nonNull)
// .collect(Collectors.toSet());
// } else {
// String rm = getExpressionValueAsString(exp);
// if (rm != null) {
// HashSet<String> methods = new HashSet<>();
// methods.add(rm);
// }
// }
// return null;
// }
}