From 41f9314f6b9b29cf5a47ce32b37257834549b112 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 18 Jul 2008 21:56:28 +0000 Subject: 230234 comment 10 - ajdoc modifications and tests --- asm/src/org/aspectj/asm/IProgramElement.java | 26 +++++++++++++--------- .../org/aspectj/asm/internal/ProgramElement.java | 26 ++++++++++++---------- 2 files changed, 30 insertions(+), 22 deletions(-) (limited to 'asm') diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index bc60fdbce..495bef0ba 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -151,7 +151,7 @@ public interface IProgramElement extends Serializable { public void setSourceSignature(String string); public IProgramElement walk(HierarchyWalker walker); - + /** * Uses "typesafe enum" pattern. */ @@ -159,24 +159,30 @@ public interface IProgramElement extends Serializable { private static final long serialVersionUID = -8279300899976607927L; - public static final Modifiers STATIC = new Modifiers("static"); - public static final Modifiers FINAL = new Modifiers("final"); - public static final Modifiers ABSTRACT = new Modifiers("abstract"); - public static final Modifiers SYNCHRONIZED = new Modifiers("synchronized"); - public static final Modifiers VOLATILE = new Modifiers("volatile"); - public static final Modifiers STRICTFP = new Modifiers("strictfp"); - public static final Modifiers TRANSIENT = new Modifiers("transient"); - public static final Modifiers NATIVE = new Modifiers("native"); + public static final Modifiers STATIC = new Modifiers("static",0x0008); + public static final Modifiers FINAL = new Modifiers("final",0x0010); + public static final Modifiers ABSTRACT = new Modifiers("abstract",0x0400); + public static final Modifiers SYNCHRONIZED = new Modifiers("synchronized",0x0020); + public static final Modifiers VOLATILE = new Modifiers("volatile",0x0040); + public static final Modifiers STRICTFP = new Modifiers("strictfp",0x0800); + public static final Modifiers TRANSIENT = new Modifiers("transient",0x0080); + public static final Modifiers NATIVE = new Modifiers("native",0x0100); public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, VOLATILE, STRICTFP, TRANSIENT, NATIVE }; private final String name; + private int bit; - private Modifiers(String name) { + private Modifiers(String name, int bit) { this.name = name; + this.bit = bit; } public String toString() { return name; } + + public int getBit() { + return bit; + } // The 4 declarations below are necessary for serialization private static int nextOrdinal = 0; diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 189133935..b63f74108 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -49,8 +50,6 @@ public class ProgramElement implements IProgramElement { private static int AccInterface = 0x0200; private static int AccAbstract = 0x0400; private static int AccStrictfp = 0x0800; - - protected String name; private Kind kind; @@ -58,7 +57,7 @@ public class ProgramElement implements IProgramElement { protected List children = Collections.EMPTY_LIST; private Map kvpairs = Collections.EMPTY_MAP; protected ISourceLocation sourceLocation = null; - private int modifiers; + private int modifiers; private String handle = null; @@ -82,7 +81,6 @@ public class ProgramElement implements IProgramElement { setFormalComment(comment); // if (comment!=null && comment.length()>0) formalComment = comment; this.modifiers = modifiers; -// this.accessibility = genAccessibility(modifiers); } /** @@ -105,7 +103,6 @@ public class ProgramElement implements IProgramElement { this.sourceLocation = sourceLocation; this.kind = kind; this.modifiers = modifiers; -// this.accessibility = accessibility; setDeclaringType(declaringType);//this.declaringType = declaringType; //this.packageName = packageName; setFormalComment(comment); @@ -115,18 +112,13 @@ public class ProgramElement implements IProgramElement { } public List getModifiers() { - return genModifiers(modifiers); + return genModifiers(this.modifiers); } public Accessibility getAccessibility() { - return genAccessibility(modifiers); // accessibility + return genAccessibility(this.modifiers); } -// public void setAccessibility(Accessibility a) { -// -// //accessibility=a; -// } - public void setDeclaringType(String t) { if (t!=null && t.length()>0) { if (kvpairs==Collections.EMPTY_MAP) kvpairs = new HashMap(); @@ -400,6 +392,16 @@ public class ProgramElement implements IProgramElement { public void setModifiers(int i) { this.modifiers = i; } + + /** + * Convenience mechanism for setting new modifiers which do not require + * knowledge of the private internal representation + * + * @param newModifier + */ + public void addModifiers(IProgramElement.Modifiers newModifier) { + modifiers |= newModifier.getBit(); + } public String toSignatureString() { return toSignatureString(true); -- cgit v1.2.3