1 2 25 26 package org.aspectj.asm; 27 28 import java.util.*; 29 import java.io.*; 30 import org.aspectj.compiler.base.ast.*; 31 32 33 36 public class ProgramElementNode extends StructureNode { 37 38 private List modifiers; 39 private List relations; 40 41 private Kind kind; 42 private Accessibility accessibility; 43 private String declaringType = ""; 44 private String formalComment = ""; 45 private String packageName = null; 46 private boolean member = false; 47 private boolean runnable = false; 48 private boolean implementor = false; 49 private boolean overrider = false; 50 51 private transient ASTObject astObject = null; 52 53 56 public ProgramElementNode() { } 57 58 61 public ProgramElementNode(String signature, Kind kind, List children) { 62 super(signature, kind.toString(), children); 63 this.kind = kind; 64 } 65 66 69 public ProgramElementNode(String signature, Kind kind, List modifiers, Accessibility accessibility, 70 String declaringType, String packageName, String formalComment, SourceLocation sourceLocation, 71 List relations, List children, boolean member, ASTObject astObject) { 72 73 super(signature, kind.toString(), children); 74 super.sourceLocation = sourceLocation; 75 this.kind = kind; 76 this.modifiers = modifiers; 77 this.accessibility = accessibility; 78 this.declaringType = declaringType; 79 this.packageName = packageName; 80 this.formalComment = formalComment; 81 this.relations = relations; 82 this.member = member; 83 this.astObject = astObject; 84 } 85 86 public Kind getProgramElementKind() { 87 return kind; 88 } 89 90 public List getModifiers() { 91 return modifiers; 92 } 93 94 public Accessibility getAccessibility() { 95 return accessibility; 96 } 97 98 public String getDeclaringType() { 99 return declaringType; 100 } 101 102 public String getPackageName() { 103 return packageName; 104 } 105 106 public ASTObject getAstObject() { 107 return astObject; 108 } 109 110 public void clearAstObject() { 111 this.astObject = null; 112 } 113 114 public String getKind() { 115 return super.kind; 116 } 117 118 public String getSignature() { 119 return super.name; 120 } 121 122 public boolean isCode() { 123 return kind.equals(Kind.CODE); 124 } 125 126 public boolean isMemberKind() { 127 return member; 128 } 129 130 public void setRunnable(boolean value) { 131 this.runnable = value; 132 } 133 134 public boolean isRunnable() { 135 return runnable; 136 } 137 138 public boolean isImplementor() { 139 return implementor; 140 } 141 142 public void setImplementor(boolean value) { 143 this.implementor = value; 144 } 145 146 public boolean isOverrider() { 147 return overrider; 148 } 149 150 public void setOverrider(boolean value) { 151 this.overrider = value; 152 } 153 154 public List getRelations() { 155 return relations; 156 } 157 158 public void setRelations(List relations) { 159 if (relations.size() > 0) { 160 this.relations = relations; 161 } 162 } 163 164 public String getFormalComment() { 165 return formalComment; 166 } 167 168 public String toString() { 169 return super.name; 170 } 171 172 192 195 public static class Modifiers implements Serializable { 196 197 public static final Modifiers STATIC = new Modifiers("static"); 198 public static final Modifiers FINAL = new Modifiers("final"); 199 public static final Modifiers ABSTRACT = new Modifiers("abstract"); 200 public static final Modifiers SYNCHRONIZED = new Modifiers("synchronized"); 201 public static final Modifiers VOLATILE = new Modifiers("volatile"); 202 public static final Modifiers STRICTFP = new Modifiers("strictfp"); 203 public static final Modifiers TRANSIENT = new Modifiers("transient"); 204 public static final Modifiers NATIVE = new Modifiers("native"); 205 public static final Modifiers[] ALL = { STATIC, FINAL, ABSTRACT, SYNCHRONIZED, TRANSIENT, VOLATILE, STRICTFP, NATIVE }; 206 private final String name; 207 208 private Modifiers(String name) { 209 this.name = name; 210 } 211 212 public String toString() { 213 return name; 214 } 215 216 private static int nextOrdinal = 0; 218 private final int ordinal = nextOrdinal++; 219 private Object readResolve() throws ObjectStreamException { 220 return ALL[ordinal]; 221 } 222 } 223 224 227 public static class Accessibility implements Serializable { 228 229 public static final Accessibility PUBLIC = new Accessibility("public"); 230 public static final Accessibility PACKAGE = new Accessibility("package"); 231 public static final Accessibility PROTECTED = new Accessibility("protected"); 232 public static final Accessibility PRIVATE = new Accessibility("private"); 233 public static final Accessibility PRIVILEGED = new Accessibility("privileged"); 234 public static final Accessibility[] ALL = { PUBLIC, PACKAGE, PROTECTED, PRIVATE, PRIVILEGED }; 235 private final String name; 236 237 private Accessibility(String name) { 238 this.name = name; 239 } 240 241 public String toString() { 242 return name; 243 } 244 245 private static int nextOrdinal = 0; 247 private final int ordinal = nextOrdinal++; 248 private Object readResolve() throws ObjectStreamException { 249 return ALL[ordinal]; 250 } 251 } 252 253 256 public static class Kind implements Serializable { 257 258 public static final Kind PROJECT = new Kind("project"); 259 public static final Kind PACKAGE = new Kind("package"); 260 public static final Kind FILE = new Kind("file"); 261 public static final Kind FILE_JAVA = new Kind("java source file"); 262 public static final Kind FILE_ASPECTJ = new Kind("aspect source file"); 263 public static final Kind FILE_LST = new Kind("build configuration file"); 264 public static final Kind CLASS = new Kind("class"); 265 public static final Kind INTERFACE = new Kind("interface"); 266 public static final Kind ASPECT = new Kind("aspect"); 267 public static final Kind INITIALIZER = new Kind("initializer"); 268 public static final Kind INTRODUCTION = new Kind("introduction"); 269 public static final Kind CONSTRUCTOR = new Kind("constructor"); 270 public static final Kind METHOD = new Kind("method"); 271 public static final Kind FIELD = new Kind("field"); 272 public static final Kind POINTCUT = new Kind("pointcut"); 273 public static final Kind ADVICE = new Kind("advice"); 274 public static final Kind DECLARE_PARENTS = new Kind("declare parents"); 275 public static final Kind DECLARE_WARNING = new Kind("declare warning"); 276 public static final Kind DECLARE_ERROR = new Kind("declare error"); 277 public static final Kind DECLARE_SOFT = new Kind("declare soft"); 278 public static final Kind CODE = new Kind("decBodyElement"); 279 public static final Kind ERROR = new Kind("error"); 280 281 public static final Kind[] ALL = { PROJECT, PACKAGE, FILE, FILE_JAVA, 282 FILE_ASPECTJ, FILE_LST, CLASS, INTERFACE, ASPECT, 283 INITIALIZER, INTRODUCTION, CONSTRUCTOR, METHOD, FIELD, POINTCUT, ADVICE, 284 DECLARE_PARENTS, DECLARE_WARNING, DECLARE_ERROR, DECLARE_SOFT, CODE, ERROR }; 285 286 public static Kind getKindForString(String kindString) { 287 for (int i = 0; i < ALL.length; i++) { 288 if (ALL[i].toString().equals(kindString)) return ALL[i]; 289 } 290 return ERROR; 291 } 292 293 private final String name; 294 295 private Kind(String name) { 296 this.name = name; 297 } 298 299 public String toString() { 300 return name; 301 } 302 303 307 public static List getNonAJMemberKinds() { 308 List list = new ArrayList(); 309 list.add(METHOD); 310 list.add(FIELD); 311 list.add(CONSTRUCTOR); 312 return list; 313 } 314 315 public boolean isMemberKind() { 316 return this == FIELD 317 || this == METHOD 318 || this == CONSTRUCTOR 319 || this == POINTCUT 320 || this == ADVICE; 321 } 322 323 public boolean isTypeKind() { 324 return this == CLASS 325 || this == INTERFACE 326 || this == ASPECT; 327 } 328 329 public boolean isSourceFileKind() { 330 return this == FILE_ASPECTJ 331 || this == FILE_JAVA; 332 } 333 334 public boolean isDeclareKind() { 335 return name.startsWith("declare"); 336 } 337 338 private static int nextOrdinal = 0; 340 private final int ordinal = nextOrdinal++; 341 private Object readResolve() throws ObjectStreamException { 342 return ALL[ordinal]; 343 } 344 } 345 } 346 347 | Popular Tags |