~ubuntu-branches/ubuntu/wily/aspectj/wily-proposed

« back to all changes in this revision

Viewing changes to org.aspectj/modules/org.aspectj.matcher/src/org/aspectj/weaver/patterns/DeclareAnnotation.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-03-15 23:54:31 UTC
  • mfrom: (1.2.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110315235431-iq2gxbsx08kpwuiw
* New upstream release.
* Updated Standards-Version to 3.9.1 (no changes needed).
* Fix local Javadoc links:
  - d/patches/07_javadoc_links.diff: Use locally installed
   javadoc packages and hyperlink with them.
  - d/control: Add B-D on default-java-doc and libasm3-java-doc.
* d/control: Drop B-D on itself (our new bootstrap infrastructure doesn't need
  that anymore).
* Split packages into :
  - aspectj: only contains CLI tools.
  - libaspectj-java: JAR librairies for /usr/share/java.
  - libaspectj-java-doc: 4 API's Javadoc.
  - aspectj-doc: Programming Guides and SDK Documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import java.util.Map;
20
20
 
21
21
import org.aspectj.bridge.MessageUtil;
 
22
import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
22
23
import org.aspectj.weaver.AnnotationAJ;
23
24
import org.aspectj.weaver.CompressingDataOutputStream;
24
25
import org.aspectj.weaver.ISourceContext;
28
29
import org.aspectj.weaver.VersionedDataInputStream;
29
30
import org.aspectj.weaver.WeaverMessages;
30
31
import org.aspectj.weaver.World;
31
 
import org.aspectj.weaver.AjAttribute.WeaverVersionInfo;
32
32
 
33
33
/**
34
34
 * Represents a declare annotation statement, one of atField, atMethod, atConstructor or atType.
41
41
        public static final Kind AT_FIELD = new Kind(2, "field");
42
42
        public static final Kind AT_METHOD = new Kind(3, "method");
43
43
        public static final Kind AT_CONSTRUCTOR = new Kind(4, "constructor");
 
44
        public static final Kind AT_REMOVE_FROM_FIELD = new Kind(5, "removeFromField");
44
45
 
45
46
        private Kind kind;
46
47
        // for declare @type
53
54
        private AnnotationAJ annotation; // discovered when required
54
55
        private ResolvedType annotationType; // discovered when required
55
56
 
 
57
        // not serialized:
 
58
        private int annotationStart;
 
59
        private int annotationEnd;
 
60
 
56
61
        /**
57
62
         * Constructor for declare atType.
58
63
         */
160
165
                this.annotationStrings.set(0, annotationString);
161
166
        }
162
167
 
 
168
        public void setAnnotationLocation(int start, int end) {
 
169
                this.annotationStart = start;
 
170
                this.annotationEnd = end;
 
171
        }
 
172
 
 
173
        public int getAnnotationSourceStart() {
 
174
                return annotationStart;
 
175
        }
 
176
 
 
177
        public int getAnnotationSourceEnd() {
 
178
                return annotationEnd;
 
179
        }
 
180
 
163
181
        public void setAnnotationMethod(String methodName) {
164
182
                this.annotationMethods.set(0, methodName);
165
183
        }
210
228
        @Override
211
229
        public void write(CompressingDataOutputStream s) throws IOException {
212
230
                s.writeByte(Declare.ANNOTATION);
213
 
                s.writeInt(kind.id);
 
231
                if (kind.id == AT_FIELD.id && isRemover) {
 
232
                        s.writeInt(AT_REMOVE_FROM_FIELD.id);
 
233
                } else {
 
234
                        s.writeInt(kind.id);
 
235
                }
214
236
                int max = 0;
215
237
                s.writeByte(max = annotationStrings.size());
216
238
                for (int i = 0; i < max; i++) {
231
253
 
232
254
        public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException {
233
255
                DeclareAnnotation ret = null;
 
256
                boolean isRemover = false;
234
257
                int kind = s.readInt();
 
258
                if (kind == AT_REMOVE_FROM_FIELD.id) {
 
259
                        kind = AT_FIELD.id;
 
260
                        isRemover = true;
 
261
                }
235
262
                // old format was just a single string and method
236
263
                if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_AJ169) {
237
264
                        // int numAnnotationStrings =
257
284
                                sp = SignaturePattern.read(s, context);
258
285
                                ret = new DeclareAnnotation(AT_FIELD, sp);
259
286
                        }
 
287
                        if (isRemover) {
 
288
                                ret.setRemover(true);
 
289
                        }
260
290
                        break;
261
291
                case 3:
262
292
                        if (s.getMajorVersion() >= WeaverVersionInfo.WEAVER_VERSION_AJ169) {
494
524
                        return "at_" + s;
495
525
                }
496
526
        }
 
527
 
 
528
        boolean isRemover = false;
 
529
 
 
530
        public void setRemover(boolean b) {
 
531
                isRemover = b;
 
532
        }
 
533
 
 
534
        public boolean isRemover() {
 
535
                return isRemover;
 
536
        }
497
537
}