Trail:

Changeset 3

Show
Ignore:
Timestamp:
07/15/08 13:20:14 (4 years ago)
Author:
harald
Message:
  • Also search for annotations on fields
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/org/fluffnstuff/asdoclet/handler/ClassHandler.java

    r2 r3  
    5151                String propertyName = getBeanPropertyName(methodDoc); 
    5252                if (propertyName != null) { 
    53                     String fieldType = getFieldType(methodDoc, imports, methodCommands); 
     53                    String fieldType = getFieldType(methodDoc, findField(classDoc, propertyName), imports, methodCommands); 
    5454                    ASField field = type.newField(propertyName, Visibility.PUBLIC, fieldType); 
    5555 
     
    7272    } 
    7373 
    74     private String getFieldType(MethodDoc methodDoc, Collection<String> imports, Map<String, String> methodCommands) { 
     74    private String getFieldType(MethodDoc methodDoc, FieldDoc fieldDoc, Collection<String> imports, Map<String, String> methodCommands) { 
    7575        String overriddenType = TagParser.getStringCommand(Constants.COMMAND_TYPE, methodCommands); 
    7676        Type returnType = methodDoc.returnType(); 
     
    7878 
    7979        if (overriddenType == null) { 
    80             AnnotationDesc[] annotationDescs = methodDoc.annotations(); 
    81             for (AnnotationDesc annotationDesc : annotationDescs) { 
    82                 AnnotationTypeDoc annotationTypeDoc = annotationDesc.annotationType(); 
    83                 fieldType = getAnnotationMap().getType(annotationTypeDoc.qualifiedTypeName(), false, imports); 
    84                 if (fieldType != null) break; 
     80            fieldType = checkAnnotations(imports, fieldType, methodDoc.annotations()); 
     81 
     82            if (fieldType == null && fieldDoc != null) { 
     83                fieldType = checkAnnotations(imports, fieldType, fieldDoc.annotations()); 
    8584            } 
    8685 
     
    9493 
    9594        return fieldType; 
     95    } 
     96 
     97    private String checkAnnotations(Collection<String> imports, String fieldType, AnnotationDesc[] annotationDescs) { 
     98        for (AnnotationDesc annotationDesc : annotationDescs) { 
     99            AnnotationTypeDoc annotationTypeDoc = annotationDesc.annotationType(); 
     100            fieldType = getAnnotationMap().getType(annotationTypeDoc.qualifiedTypeName(), false, imports); 
     101            if (fieldType != null) break; 
     102        } 
     103        return fieldType; 
     104    } 
     105 
     106    private FieldDoc findField(ClassDoc classDoc, String propertyName) { 
     107        FieldDoc fieldDoc = null; 
     108        for (FieldDoc doc : classDoc.fields(false)) { 
     109            if (doc.name().equals(propertyName)) { 
     110                fieldDoc = doc; 
     111                break; 
     112            } 
     113        } 
     114 
     115        return fieldDoc; 
    96116    } 
    97117