langtools/src/share/classes/com/sun/tools/javac/code/Annotations.java
changeset 14804 f93a8d60b9a4
parent 14258 8d2148961366
child 15356 cf312dc54c60
equal deleted inserted replaced
14803:88347e495d34 14804:f93a8d60b9a4
    72     /*
    72     /*
    73      * This field should never be null
    73      * This field should never be null
    74      */
    74      */
    75     private List<Attribute.Compound> attributes = NOT_STARTED;
    75     private List<Attribute.Compound> attributes = NOT_STARTED;
    76     /*
    76     /*
    77      * The Symbol this Annotatios belong to
    77      * The Symbol this Annotations belong to
    78      */
    78      */
    79     private final Symbol s;
    79     private final Symbol sym;
    80 
    80 
    81     public Annotations(Symbol s) {
    81     public Annotations(Symbol sym) {
    82         this.s = s;
    82         this.sym = sym;
    83     }
    83     }
    84 
    84 
    85     public List<Attribute.Compound> getAttributes() {
    85     public List<Attribute.Compound> getAttributes() {
    86         return filterSentinels(attributes);
    86         return filterSentinels(attributes);
    87     }
    87     }
   100         }
   100         }
   101         setAttributes(other.getAttributes());
   101         setAttributes(other.getAttributes());
   102     }
   102     }
   103 
   103 
   104     public void setAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) {
   104     public void setAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) {
   105         Assert.check(pendingCompletion() || (!isStarted() && s.kind == PCK));
   105         Assert.check(pendingCompletion() || (!isStarted() && sym.kind == PCK));
   106 
   106 
   107         Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated = ctx.annotated;
   107         Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated = ctx.annotated;
   108         boolean atLeastOneRepeated = false;
   108         boolean atLeastOneRepeated = false;
   109         List<Attribute.Compound> buf = List.<Attribute.Compound>nil();
   109         List<Attribute.Compound> buf = List.<Attribute.Compound>nil();
   110         for (ListBuffer<Attribute.Compound> lb : annotated.values()) {
   110         for (ListBuffer<Attribute.Compound> lb : annotated.values()) {
   111             if (lb.size() == 1) {
   111             if (lb.size() == 1) {
   112                 buf = buf.prepend(lb.first());
   112                 buf = buf.prepend(lb.first());
   113             } else { // repeated
   113             } else { // repeated
   114                 buf = buf.prepend(new Placeholder(lb.toList(), s));
   114                 buf = buf.prepend(new Placeholder(lb.toList(), sym));
   115                 atLeastOneRepeated = true;
   115                 atLeastOneRepeated = true;
   116             }
   116             }
   117         }
   117         }
   118 
   118 
   119         // Add non-repeating attributes
   119         // Add non-repeating attributes
   139             // with Attribute.Compound (made from synthesized containers).
   139             // with Attribute.Compound (made from synthesized containers).
   140             ctx.annotateRepeated(new Annotate.Annotator() {
   140             ctx.annotateRepeated(new Annotate.Annotator() {
   141 
   141 
   142                 @Override
   142                 @Override
   143                 public String toString() {
   143                 public String toString() {
   144                     return "repeated annotation pass of: " + s + " in: " + s.owner;
   144                     return "repeated annotation pass of: " + sym + " in: " + sym.owner;
   145                 }
   145                 }
   146 
   146 
   147                 @Override
   147                 @Override
   148                 public void enterAnnotation() {
   148                 public void enterAnnotation() {
   149                     complete(ctx);
   149                     complete(ctx);
   251     private Attribute.Compound replaceOne(Placeholder placeholder, Annotate.AnnotateRepeatedContext ctx) {
   251     private Attribute.Compound replaceOne(Placeholder placeholder, Annotate.AnnotateRepeatedContext ctx) {
   252         Log log = ctx.log;
   252         Log log = ctx.log;
   253 
   253 
   254         // Process repeated annotations
   254         // Process repeated annotations
   255         Attribute.Compound validRepeated =
   255         Attribute.Compound validRepeated =
   256                 ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor());
   256             ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);
   257 
   257 
   258         if (validRepeated != null) {
   258         if (validRepeated != null) {
   259             // Check that the container isn't manually
   259             // Check that the container isn't manually
   260             // present along with repeated instances of
   260             // present along with repeated instances of
   261             // its contained annotation.
   261             // its contained annotation.