From c0e55cb7e288956d0e1261f70ff700b2e8592989 Mon Sep 17 00:00:00 2001 From: nsingh Date: Fri, 27 Oct 2017 11:04:41 -0700 Subject: [PATCH] Removed old way of matching annotations --- .../RequestMappingHoverProvider.java | 115 ------------------ 1 file changed, 115 deletions(-) diff --git a/headless-services/boot-java-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java b/headless-services/boot-java-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java index c1cbb7ad1..81b778110 100644 --- a/headless-services/boot-java-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java +++ b/headless-services/boot-java-language-server/src/main/java/org/springframework/ide/vscode/boot/java/requestmapping/RequestMappingHoverProvider.java @@ -104,7 +104,6 @@ public class RequestMappingHoverProvider implements HoverProvider { Collection 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 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)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 getRequestMethod(Expression exp) { -// if (exp instanceof ArrayInitializer) { -// ArrayInitializer array = (ArrayInitializer) exp; -// return ((List)array.expressions()).stream() -// .map(e -> getExpressionValueAsString(e)) -// .filter(Objects::nonNull) -// .collect(Collectors.toSet()); -// } else { -// String rm = getExpressionValueAsString(exp); -// if (rm != null) { -// HashSet methods = new HashSet<>(); -// methods.add(rm); -// } -// } -// return null; -// } - }