107 types = Types.instance(context); |
107 types = Types.instance(context); |
108 diags = JCDiagnostic.Factory.instance(context); |
108 diags = JCDiagnostic.Factory.instance(context); |
109 source = Source.instance(context); |
109 source = Source.instance(context); |
110 target = Target.instance(context); |
110 target = Target.instance(context); |
111 deferredLintHandler = DeferredLintHandler.instance(context); |
111 deferredLintHandler = DeferredLintHandler.instance(context); |
112 } |
112 allowTypeAnnos = source.allowTypeAnnotations(); |
|
113 } |
|
114 |
|
115 /** Switch: support type annotations. |
|
116 */ |
|
117 boolean allowTypeAnnos; |
113 |
118 |
114 /** A queue for classes whose members still need to be entered into the |
119 /** A queue for classes whose members still need to be entered into the |
115 * symbol table. |
120 * symbol table. |
116 */ |
121 */ |
117 ListBuffer<Env<AttrContext>> halfcompleted = new ListBuffer<Env<AttrContext>>(); |
122 ListBuffer<Env<AttrContext>> halfcompleted = new ListBuffer<Env<AttrContext>>(); |
118 |
123 |
119 /** Set to true only when the first of a set of classes is |
124 /** Set to true only when the first of a set of classes is |
120 * processed from the halfcompleted queue. |
125 * processed from the half completed queue. |
121 */ |
126 */ |
122 boolean isFirst = true; |
127 boolean isFirst = true; |
123 |
128 |
124 /** A flag to disable completion from time to time during member |
129 /** A flag to disable completion from time to time during member |
125 * enter, as we only need to look up types. This avoids |
130 * enter, as we only need to look up types. This avoids |
1115 annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true)); |
1122 annotate.new AnnotateRepeatedContext<Attribute.TypeCompound>(env, annotated, pos, log, true)); |
1116 } |
1123 } |
1117 } |
1124 } |
1118 |
1125 |
1119 public void typeAnnotate(final JCTree tree, final Env<AttrContext> env, final Symbol sym) { |
1126 public void typeAnnotate(final JCTree tree, final Env<AttrContext> env, final Symbol sym) { |
1120 tree.accept(new TypeAnnotate(env, sym)); |
1127 if (allowTypeAnnos) { |
|
1128 tree.accept(new TypeAnnotate(env, sym)); |
|
1129 } |
1121 } |
1130 } |
1122 |
1131 |
1123 /** |
1132 /** |
1124 * We need to use a TreeScanner, because it is not enough to visit the top-level |
1133 * We need to use a TreeScanner, because it is not enough to visit the top-level |
1125 * annotations. We also need to visit type arguments, etc. |
1134 * annotations. We also need to visit type arguments, etc. |