98 // <editor-fold defaultstate="collapsed" desc="annotations"> |
98 // <editor-fold defaultstate="collapsed" desc="annotations"> |
99 |
99 |
100 /** The attributes of this symbol are contained in this |
100 /** The attributes of this symbol are contained in this |
101 * SymbolMetadata. The SymbolMetadata instance is NOT immutable. |
101 * SymbolMetadata. The SymbolMetadata instance is NOT immutable. |
102 */ |
102 */ |
103 protected SymbolMetadata annotations; |
103 protected SymbolMetadata metadata; |
104 |
104 |
105 |
105 |
106 /** An accessor method for the attributes of this symbol. |
106 /** An accessor method for the attributes of this symbol. |
107 * Attributes of class symbols should be accessed through the accessor |
107 * Attributes of class symbols should be accessed through the accessor |
108 * method to make sure that the class symbol is loaded. |
108 * method to make sure that the class symbol is loaded. |
109 */ |
109 */ |
110 public List<Attribute.Compound> getRawAttributes() { |
110 public List<Attribute.Compound> getRawAttributes() { |
111 return (annotations == null) |
111 return (metadata == null) |
112 ? List.<Attribute.Compound>nil() |
112 ? List.<Attribute.Compound>nil() |
113 : annotations.getDeclarationAttributes(); |
113 : metadata.getDeclarationAttributes(); |
114 } |
114 } |
115 |
115 |
116 /** An accessor method for the type attributes of this symbol. |
116 /** An accessor method for the type attributes of this symbol. |
117 * Attributes of class symbols should be accessed through the accessor |
117 * Attributes of class symbols should be accessed through the accessor |
118 * method to make sure that the class symbol is loaded. |
118 * method to make sure that the class symbol is loaded. |
119 */ |
119 */ |
120 public List<Attribute.TypeCompound> getRawTypeAttributes() { |
120 public List<Attribute.TypeCompound> getRawTypeAttributes() { |
121 return (annotations == null) |
121 return (metadata == null) |
122 ? List.<Attribute.TypeCompound>nil() |
122 ? List.<Attribute.TypeCompound>nil() |
123 : annotations.getTypeAttributes(); |
123 : metadata.getTypeAttributes(); |
124 } |
124 } |
125 |
125 |
126 /** Fetch a particular annotation from a symbol. */ |
126 /** Fetch a particular annotation from a symbol. */ |
127 public Attribute.Compound attribute(Symbol anno) { |
127 public Attribute.Compound attribute(Symbol anno) { |
128 for (Attribute.Compound a : getRawAttributes()) { |
128 for (Attribute.Compound a : getRawAttributes()) { |
130 } |
130 } |
131 return null; |
131 return null; |
132 } |
132 } |
133 |
133 |
134 public boolean annotationsPendingCompletion() { |
134 public boolean annotationsPendingCompletion() { |
135 return annotations == null ? false : annotations.pendingCompletion(); |
135 return metadata == null ? false : metadata.pendingCompletion(); |
136 } |
136 } |
137 |
137 |
138 public void appendAttributes(List<Attribute.Compound> l) { |
138 public void appendAttributes(List<Attribute.Compound> l) { |
139 if (l.nonEmpty()) { |
139 if (l.nonEmpty()) { |
140 initedAnnos().append(l); |
140 initedMetadata().append(l); |
141 } |
141 } |
142 } |
142 } |
143 |
143 |
144 public void appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) { |
144 public void appendClassInitTypeAttributes(List<Attribute.TypeCompound> l) { |
145 if (l.nonEmpty()) { |
145 if (l.nonEmpty()) { |
146 initedAnnos().appendClassInitTypeAttributes(l); |
146 initedMetadata().appendClassInitTypeAttributes(l); |
147 } |
147 } |
148 } |
148 } |
149 |
149 |
150 public void appendInitTypeAttributes(List<Attribute.TypeCompound> l) { |
150 public void appendInitTypeAttributes(List<Attribute.TypeCompound> l) { |
151 if (l.nonEmpty()) { |
151 if (l.nonEmpty()) { |
152 initedAnnos().appendInitTypeAttributes(l); |
152 initedMetadata().appendInitTypeAttributes(l); |
153 } |
153 } |
154 } |
154 } |
155 |
155 |
156 public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) { |
156 public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) { |
157 initedAnnos().appendTypeAttributesWithCompletion(ctx); |
157 initedMetadata().appendTypeAttributesWithCompletion(ctx); |
158 } |
158 } |
159 |
159 |
160 public void appendUniqueTypeAttributes(List<Attribute.TypeCompound> l) { |
160 public void appendUniqueTypeAttributes(List<Attribute.TypeCompound> l) { |
161 if (l.nonEmpty()) { |
161 if (l.nonEmpty()) { |
162 initedAnnos().appendUniqueTypes(l); |
162 initedMetadata().appendUniqueTypes(l); |
163 } |
163 } |
164 } |
164 } |
165 |
165 |
166 public List<Attribute.TypeCompound> getClassInitTypeAttributes() { |
166 public List<Attribute.TypeCompound> getClassInitTypeAttributes() { |
167 return (annotations == null) |
167 return (metadata == null) |
168 ? List.<Attribute.TypeCompound>nil() |
168 ? List.<Attribute.TypeCompound>nil() |
169 : annotations.getClassInitTypeAttributes(); |
169 : metadata.getClassInitTypeAttributes(); |
170 } |
170 } |
171 |
171 |
172 public List<Attribute.TypeCompound> getInitTypeAttributes() { |
172 public List<Attribute.TypeCompound> getInitTypeAttributes() { |
173 return (annotations == null) |
173 return (metadata == null) |
174 ? List.<Attribute.TypeCompound>nil() |
174 ? List.<Attribute.TypeCompound>nil() |
175 : annotations.getInitTypeAttributes(); |
175 : metadata.getInitTypeAttributes(); |
176 } |
176 } |
177 |
177 |
178 public List<Attribute.Compound> getDeclarationAttributes() { |
178 public List<Attribute.Compound> getDeclarationAttributes() { |
179 return (annotations == null) |
179 return (metadata == null) |
180 ? List.<Attribute.Compound>nil() |
180 ? List.<Attribute.Compound>nil() |
181 : annotations.getDeclarationAttributes(); |
181 : metadata.getDeclarationAttributes(); |
182 } |
182 } |
183 |
183 |
184 public boolean hasAnnotations() { |
184 public boolean hasAnnotations() { |
185 return (annotations != null && !annotations.isEmpty()); |
185 return (metadata != null && !metadata.isEmpty()); |
186 } |
186 } |
187 |
187 |
188 public boolean hasTypeAnnotations() { |
188 public boolean hasTypeAnnotations() { |
189 return (annotations != null && !annotations.isTypesEmpty()); |
189 return (metadata != null && !metadata.isTypesEmpty()); |
190 } |
190 } |
191 |
191 |
192 public void prependAttributes(List<Attribute.Compound> l) { |
192 public void prependAttributes(List<Attribute.Compound> l) { |
193 if (l.nonEmpty()) { |
193 if (l.nonEmpty()) { |
194 initedAnnos().prepend(l); |
194 initedMetadata().prepend(l); |
195 } |
195 } |
196 } |
196 } |
197 |
197 |
198 public void resetAnnotations() { |
198 public void resetAnnotations() { |
199 initedAnnos().reset(); |
199 initedMetadata().reset(); |
200 } |
200 } |
201 |
201 |
202 public void setAttributes(Symbol other) { |
202 public void setAttributes(Symbol other) { |
203 if (annotations != null || other.annotations != null) { |
203 if (metadata != null || other.metadata != null) { |
204 initedAnnos().setAttributes(other.annotations); |
204 initedMetadata().setAttributes(other.metadata); |
205 } |
205 } |
206 } |
206 } |
207 |
207 |
208 public void setDeclarationAttributes(List<Attribute.Compound> a) { |
208 public void setDeclarationAttributes(List<Attribute.Compound> a) { |
209 if (annotations != null || a.nonEmpty()) { |
209 if (metadata != null || a.nonEmpty()) { |
210 initedAnnos().setDeclarationAttributes(a); |
210 initedMetadata().setDeclarationAttributes(a); |
211 } |
211 } |
212 } |
212 } |
213 |
213 |
214 public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { |
214 public void setDeclarationAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.Compound> ctx) { |
215 initedAnnos().setDeclarationAttributesWithCompletion(ctx); |
215 initedMetadata().setDeclarationAttributesWithCompletion(ctx); |
216 } |
216 } |
217 |
217 |
218 public void setTypeAttributes(List<Attribute.TypeCompound> a) { |
218 public void setTypeAttributes(List<Attribute.TypeCompound> a) { |
219 if (annotations != null || a.nonEmpty()) { |
219 if (metadata != null || a.nonEmpty()) { |
220 if (annotations == null) |
220 if (metadata == null) |
221 annotations = new SymbolMetadata(this); |
221 metadata = new SymbolMetadata(this); |
222 annotations.setTypeAttributes(a); |
222 metadata.setTypeAttributes(a); |
223 } |
223 } |
224 } |
224 } |
225 |
225 |
226 private SymbolMetadata initedAnnos() { |
226 private SymbolMetadata initedMetadata() { |
227 if (annotations == null) |
227 if (metadata == null) |
228 annotations = new SymbolMetadata(this); |
228 metadata = new SymbolMetadata(this); |
229 return annotations; |
229 return metadata; |
230 } |
230 } |
231 |
231 |
232 /** This method is intended for debugging only. */ |
232 /** This method is intended for debugging only. */ |
233 public SymbolMetadata getAnnotations() { |
233 public SymbolMetadata getMetadata() { |
234 return annotations; |
234 return metadata; |
235 } |
235 } |
236 |
236 |
237 // </editor-fold> |
237 // </editor-fold> |
238 |
238 |
239 /** Construct a symbol with given kind, flags, name, type and owner. |
239 /** Construct a symbol with given kind, flags, name, type and owner. |