Report location where non-primitive type is used model
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Fri, 22 Mar 2013 16:39:30 +0100
branchmodel
changeset 875ac3b09b93f36
parent 770 26513bd377b9
child 876 4f02c384b13d
Report location where non-primitive type is used
javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java
     1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java	Fri Feb 22 08:59:40 2013 +0100
     1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java	Fri Mar 22 16:39:30 2013 +0100
     1.3 @@ -22,7 +22,6 @@
     1.4  import java.io.OutputStreamWriter;
     1.5  import java.io.StringWriter;
     1.6  import java.io.Writer;
     1.7 -import java.lang.annotation.Annotation;
     1.8  import java.util.ArrayList;
     1.9  import java.util.Collection;
    1.10  import java.util.Collections;
    1.11 @@ -39,7 +38,6 @@
    1.12  import javax.annotation.processing.RoundEnvironment;
    1.13  import javax.annotation.processing.SupportedAnnotationTypes;
    1.14  import javax.lang.model.element.AnnotationMirror;
    1.15 -import javax.lang.model.element.AnnotationValue;
    1.16  import javax.lang.model.element.Element;
    1.17  import javax.lang.model.element.ElementKind;
    1.18  import javax.lang.model.element.ExecutableElement;
    1.19 @@ -114,7 +112,7 @@
    1.20              if (!generateComputedProperties(body, m.properties(), e.getEnclosedElements(), propsGetSet, propsDeps)) {
    1.21                  ok = false;
    1.22              }
    1.23 -            if (!generateProperties(body, m.properties(), propsGetSet, propsDeps)) {
    1.24 +            if (!generateProperties(e, body, m.properties(), propsGetSet, propsDeps)) {
    1.25                  ok = false;
    1.26              }
    1.27              FileObject java = processingEnv.getFiler().createSourceFile(pkg + '.' + className, e);
    1.28 @@ -169,7 +167,7 @@
    1.29              if (!generateComputedProperties(body, p.properties(), e.getEnclosedElements(), propsGetSet, propsDeps)) {
    1.30                  ok = false;
    1.31              }
    1.32 -            if (!generateProperties(body, p.properties(), propsGetSet, propsDeps)) {
    1.33 +            if (!generateProperties(e, body, p.properties(), propsGetSet, propsDeps)) {
    1.34                  ok = false;
    1.35              }
    1.36              
    1.37 @@ -389,13 +387,14 @@
    1.38      }
    1.39  
    1.40      private boolean generateProperties(
    1.41 +        Element where,
    1.42          Writer w, Property[] properties,
    1.43          Collection<String> props, Map<String,Collection<String>> deps
    1.44      ) throws IOException {
    1.45          boolean ok = true;
    1.46          for (Property p : properties) {
    1.47              final String tn;
    1.48 -            tn = typeName(p);
    1.49 +            tn = typeName(where, p);
    1.50              String[] gs = toGetSet(p.name(), tn, p.array());
    1.51  
    1.52              if (p.array()) {
    1.53 @@ -556,7 +555,7 @@
    1.54          };
    1.55      }
    1.56  
    1.57 -    private String typeName(Property p) {
    1.58 +    private String typeName(Element where, Property p) {
    1.59          String ret;
    1.60          boolean isModel = false;
    1.61          try {
    1.62 @@ -581,7 +580,11 @@
    1.63          if (!isModel && !"java.lang.String".equals(ret)) {
    1.64              String bt = findBoxedType(ret);
    1.65              if (bt == null) {
    1.66 -                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Only primitive types supported in the mapping. Not " + ret);
    1.67 +                processingEnv.getMessager().printMessage(
    1.68 +                    Diagnostic.Kind.ERROR, 
    1.69 +                    "Only primitive types supported in the mapping. Not " + ret,
    1.70 +                    where
    1.71 +                );
    1.72              }
    1.73          }
    1.74          return ret;