Index: impl/ASTASClassType.java
===================================================================
--- impl/ASTASClassType.java (revision 632)
+++ impl/ASTASClassType.java (working copy)
@@ -35,12 +35,28 @@
ASTUtils.addChildWithIndentation(findTypeBlock(), method.getAST());
}
+ private LinkedListTree findModifiers() {
+ return ASTUtils.findChildByType(ast, AS3Parser.MODIFIERS);
+ }
+
public String getSuperclass() {
LinkedListTree ext = ASTUtils.findChildByType(ast, AS3Parser.EXTENDS);
if (ext == null) return null;
return ASTUtils.identText(ext.getFirstChild());
}
+ public boolean isDynamic() {
+ return ModifierUtils.isDynamic(findModifiers());
+ }
+
+ public boolean isFinal() {
+ return ModifierUtils.isFinal(findModifiers());
+ }
+
+ public boolean isIntrinsic() {
+ return ModifierUtils.isIntrinsic(findModifiers());
+ }
+
public void setSuperclass(String superclassName) {
if (superclassName == null) {
removeExtendsClause();
@@ -172,4 +188,16 @@
}
}
}
+
+ public void setDynamic(boolean value) {
+ ModifierUtils.setDynamic(findModifiers(), value);
+ }
+
+ public void setFinal(boolean value) {
+ ModifierUtils.setFinal(findModifiers(), value);
+ }
+
+ public void setIntrinsic(boolean value) {
+ ModifierUtils.setIntrinsic(findModifiers(), value);
+ }
}
Index: impl/ModifierUtils.java
===================================================================
--- impl/ModifierUtils.java (revision 632)
+++ impl/ModifierUtils.java (working copy)
@@ -17,6 +17,9 @@
*/
class ModifierUtils {
+ private static final int FINAL = 179;
+ private static final int INTRINSIC = 183;
+
public static Visibility getVisibility(LinkedListTree modifiers) {
for (ASTIterator i=new ASTIterator(modifiers); i.hasNext(); ) {
LinkedListTree mod = i.next();
@@ -35,7 +38,62 @@
}
return Visibility.DEFAULT;
}
+
+ private static boolean hasModifierFlag(LinkedListTree modifiers, int type) {
+ for (ASTIterator i=new ASTIterator(modifiers); i.hasNext(); ) {
+ LinkedListTree mod = i.next();
+ if (mod.getType() == type) {
+ return true;
+ }
+ }
+ return false;
+ }
+ public static boolean isDynamic(LinkedListTree modifiers) {
+ return hasModifierFlag(modifiers, AS3Parser.DYNAMIC);
+ }
+
+ public static boolean isFinal(LinkedListTree modifiers) {
+ return hasModifierFlag(modifiers, FINAL);
+ }
+
+ public static boolean isIntrinsic(LinkedListTree modifiers) {
+ return hasModifierFlag(modifiers, INTRINSIC);
+ }
+
+ public static void setDynamic(LinkedListTree modifiers, boolean value) {
+ setModifierFlag(modifiers, value, AS3Parser.DYNAMIC, "dynamic");
+ }
+
+ public static void setFinal(LinkedListTree modifiers, boolean value) {
+ setModifierFlag(modifiers, value, FINAL, "final");
+ }
+
+ public static void setIntrinsic(LinkedListTree modifiers, boolean value) {
+ setModifierFlag(modifiers, value, INTRINSIC, "intrinsic");
+ }
+
+ private static void setModifierFlag(LinkedListTree modifiers, boolean flag, int type, String text) {
+ for (ASTIterator i=new ASTIterator(modifiers); i.hasNext(); ) {
+ LinkedListTree mod = i.next();
+ if (mod.getType() == type) {
+ if (flag) return;
+ else {
+ i.remove();
+ if (modifiers.getChildCount() == 0) {
+ deleteAllChildTokens(modifiers);
+ }
+ }
+ return;
+ }
+ }
+ if (flag) {
+ LinkedListTree node = ASTUtils.newAST(type, text);
+ node.appendToken(TokenBuilder.newSpace());
+ modifiers.addChildWithTokens(node);
+ }
+ }
+
public static void setVisibility(LinkedListTree modifiers, Visibility protection) {
for (ASTIterator i=new ASTIterator(modifiers); i.hasNext(); ) {
LinkedListTree mod = i.next();
Index: dom/ASClassType.java
===================================================================
--- dom/ASClassType.java (revision 631)
+++ dom/ASClassType.java (working copy)
@@ -63,8 +63,41 @@
public List getFields();
/**
+ * Returns true if the class is defined with the dynamic
+ * modifier, and false otherwise.
+ */
+ public boolean isDynamic();
+
+ /**
+ * Returns true if the class is defined with the final
+ * modifier, and false otherwise.
+ */
+ public boolean isFinal();
+
+ /**
+ * Returns true if the class is defined with the intrinsic
+ * modifier, and false otherwise.
+ */
+ public boolean isIntrinsic();
+
+ /**
* Removes the named field from the list of fields which this
* ActionScript class defines.
*/
public void removeField(String name);
+
+ /**
+ * Adds or removes the dynamic modifer.
+ */
+ public void setDynamic(boolean value);
+
+ /**
+ * Adds or removes the final modifer.
+ */
+ public void setFinal(boolean value);
+
+ /**
+ * Adds or removes the intrinsic modifer.
+ */
+ public void setIntrinsic(boolean value);
}
\ No newline at end of file