Skip to content

Commit

Permalink
IDE-1244: RequestMappings does not include mappings defined on
Browse files Browse the repository at this point in the history
  • Loading branch information
leods authored and Martin Lippert committed Apr 30, 2012
1 parent bc79e41 commit 47c1c41
Showing 1 changed file with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 Spring IDE Developers
* Copyright (c) 2009 - 2012 Spring IDE Developers
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -33,6 +33,7 @@
* {@link IAnnotationMetadata} implementation that uses Eclipse JDT core model information for
* extracting the metadata.
* @author Christian Dupuis
* @author Leo Dos Santos
* @since 2.2.2
*/
public class JdtBasedAnnotationMetadata implements IAnnotationMetadata {
Expand Down Expand Up @@ -72,6 +73,10 @@ private void init() {
for (IAnnotation annotation : method.getAnnotations()) {
modelAnnotations.add(processAnnotation(annotation));
}
if (modelAnnotations.size() <= 0) {
// If no annotations found on concrete method, look for them on the interface
modelAnnotations = processInterfaceMethods(method);
}
if (modelAnnotations.size() > 0) {
methodAnnotations.put(method, modelAnnotations);
}
Expand Down Expand Up @@ -100,13 +105,13 @@ private void init() {
}
}

private Annotation processAnnotation(IAnnotation annotation) {
private Annotation processAnnotation(IAnnotation annotation, IType itype) {
Annotation modelAnnotation;
if (type.isBinary()) {
if (itype.isBinary()) {
modelAnnotation = new Annotation(annotation.getElementName());
}
else {
modelAnnotation = new Annotation(JdtUtils.resolveClassName(annotation.getElementName(), type));
modelAnnotation = new Annotation(JdtUtils.resolveClassName(annotation.getElementName(), itype));
}
try {
for (IMemberValuePair member : annotation.getMemberValuePairs()) {
Expand Down Expand Up @@ -136,6 +141,25 @@ else if (member.getValue() != null) {
}
return modelAnnotation;
}

private Annotation processAnnotation(IAnnotation annotation) {
return processAnnotation(annotation, type);
}

private Set<Annotation> processInterfaceMethods(IMethod method) throws JavaModelException {
Set<Annotation> modelAnnotations = new LinkedHashSet<Annotation>();
Set<IType> interfaces = Introspector.getAllImplementedInterfaces(type);
for (IType iface : interfaces) {
IMethod[] interfaceMethod = iface.findMethods(method);
if (interfaceMethod != null && interfaceMethod.length > 0) {
for (IAnnotation annotation : interfaceMethod[0].getAnnotations()) {
modelAnnotations.add(processAnnotation(annotation, iface));
}
}
}
return modelAnnotations;
}


private void processStringValue(IMemberValuePair member, StringBuilder builder, String value) {
// class value
Expand Down

0 comments on commit 47c1c41

Please sign in to comment.