]> source.dussan.org Git - aspectj.git/commitdiff
Add traverse methods for declare and pattern types
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 29 Jan 2023 16:05:59 +0000 (17:05 +0100)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 29 Jan 2023 17:01:42 +0000 (18:01 +0100)
Relates to #215.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/DeclareAnnotation.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/DeclareParents.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/DeclarePrecedence.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/DeclareSoft.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/DeclareTypeErrorOrWarning.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/HasMemberTypePattern.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/SignaturePattern.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypePatternList.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/TypeVariablePatternList.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java

index 6adc25a3e74836f1c8c62bb9cef85bf95c6d0336..7bd8da03d3d921ab0272bfd5e853bb1e9f2ec013 100644 (file)
@@ -116,6 +116,15 @@ public class DeclareAnnotation extends Declare {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.signaturePattern != null && this.signaturePattern instanceof SignaturePattern)
+                       ((SignaturePattern) this.signaturePattern).traverse(visitor, ret);
+               if (this.typePattern != null)
+                       this.typePattern.traverse(visitor, ret);
+               return ret;
+       }
+
        @Override
        public void resolve(IScope scope) {
                if (!scope.getWorld().isInJava5Mode()) {
index de04e61f492657e8f6a77ab91f5698036361213d..61e4bfb1ee4c767f3f358e4ac257413bfe6d2e19 100644 (file)
@@ -70,6 +70,13 @@ public class DeclareErrorOrWarning extends Declare {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.pointcut != null)
+                       this.pointcut.traverse(visitor, ret);
+               return ret;
+       }
+
        public void write(CompressingDataOutputStream s) throws IOException {
                s.writeByte(Declare.ERROR_OR_WARNING);
                s.writeBoolean(isError);
index 32e4654e30005bda19f3ebda412254773769add0..87182eba945cda022e6edcdcc82afbd2b9087bb2 100644 (file)
@@ -66,6 +66,15 @@ public class DeclareParents extends Declare {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.child != null)
+                       this.child.traverse(visitor, ret);
+               if (this.parents != null)
+                       this.parents.traverse(visitor, ret);
+               return ret;
+       }
+
        @Override
        public Declare parameterizeWith(Map<String,UnresolvedType> typeVariableBindingMap, World w) {
                DeclareParents ret = new DeclareParents(child.parameterizeWith(typeVariableBindingMap, w), parents.parameterizeWith(
index 880fd8e4464a5bbe2939ce7570dc6bfad74f9b48..42a9de6f3c608e97d73fe612ef80f71c13c3b5b3 100644 (file)
@@ -40,6 +40,13 @@ public class DeclarePrecedence extends Declare {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.patterns != null)
+                       this.patterns.traverse(visitor, ret);
+               return ret;
+       }
+
        public Declare parameterizeWith(Map typeVariableBindingMap, World w) {
                DeclarePrecedence ret = new DeclarePrecedence(this.patterns.parameterizeWith(typeVariableBindingMap, w));
                ret.copyLocationFrom(this);
index 3384f3346ff68dc0185331c832149e9ecf0656a5..f57a5bc79a5f7dcd510bf6d3bac16ef290fcce87 100644 (file)
@@ -39,6 +39,15 @@ public class DeclareSoft extends Declare {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.exception != null)
+                       this.exception.traverse(visitor, ret);
+               if (this.pointcut != null)
+                       this.pointcut.traverse(visitor, ret);
+               return ret;
+       }
+
        @Override
        public Declare parameterizeWith(Map typeVariableBindingMap, World w) {
                DeclareSoft ret = new DeclareSoft(exception.parameterizeWith(typeVariableBindingMap, w), pointcut.parameterizeWith(
index 8f7954a1bc50fbffe8647f481e094252eda33272..b76c99f8781626d52d7109e6f7b734e4b06a74fa 100644 (file)
@@ -75,6 +75,13 @@ public class DeclareTypeErrorOrWarning extends Declare {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.typePattern != null)
+                       this.typePattern.traverse(visitor, ret);
+               return ret;
+       }
+
        public void write(CompressingDataOutputStream s) throws IOException {
                s.writeByte(Declare.TYPE_ERROR_OR_WARNING);
                s.writeBoolean(isError);
index be09f77baf857135bc817bbf938b4af35ef1f3c7..ea1e15d15d8de91f11080b3e45c2819c39dea9c6 100644 (file)
@@ -198,4 +198,10 @@ public class HasMemberTypePattern extends TypePattern {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.signaturePattern != null)
+                       this.signaturePattern.traverse(visitor, ret);
+               return ret;
+       }
 }
index 4285da575df1837f50b55e17ae0e710eee0085b5..895108adeeff799c7bae1218dd98ce08f06885a4 100644 (file)
@@ -980,6 +980,23 @@ public class SignaturePattern extends PatternNode implements ISignaturePattern {
                return visitor.visit(this, data);
        }
 
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.annotationPattern != null)
+                       this.annotationPattern.traverse(visitor, ret);
+               if (this.returnType != null)
+                       this.returnType.traverse(visitor, ret);
+               if (this.declaringType != null)
+                       this.declaringType.traverse(visitor, ret);
+               if (this.name != null)
+                       this.name.traverse(visitor, ret);
+               if (this.parameterTypes != null)
+                       this.parameterTypes.traverse(visitor, ret);
+               if (this.throwsPattern != null)
+                       this.throwsPattern.traverse(visitor, ret);
+               return ret;
+       }
+
        public boolean isExactDeclaringTypePattern() {
                return isExactDeclaringTypePattern;
        }
index 2ac2583c6721c29f3e5868e3c82802d9b88c7ac7..0f8e60424a0a9efa43097355a15f8201e7ebd552 100644 (file)
@@ -549,8 +549,10 @@ public class TypePatternList extends PatternNode {
        @Override
        public Object traverse(PatternNodeVisitor visitor, Object data) {
                Object ret = accept(visitor, data);
-               for (TypePattern typePattern : typePatterns) {
-                       typePattern.traverse(visitor, ret);
+               if (typePatterns != null) {
+                       for (TypePattern typePattern : typePatterns) {
+                               typePattern.traverse(visitor, ret);
+                       }
                }
                return ret;
        }
index d3402c4ede826e7326bb0f7c575a922f0b752f1a..babf57ee4cac2def98ab5a0ce9f73ed45c98b40f 100644 (file)
@@ -75,8 +75,10 @@ public class TypeVariablePatternList extends PatternNode {
 
        public Object traverse(PatternNodeVisitor visitor, Object data) {
                Object ret = accept(visitor, data);
-               for (TypeVariablePattern pattern : patterns) {
-                       pattern.traverse(visitor, ret);
+               if (patterns != null) {
+                       for (TypeVariablePattern pattern : patterns) {
+                               pattern.traverse(visitor, ret);
+                       }
                }
                return ret;
        }
index b7e56f6131dc4548e26dac3e806643a895ddf522..eaec45aa07c4461898b0eddc9e827ddeafc4b0ab 100644 (file)
@@ -428,4 +428,11 @@ public class WildAnnotationTypePattern extends AnnotationTypePattern {
        public Object accept(PatternNodeVisitor visitor, Object data) {
                return visitor.visit(this, data);
        }
+
+       public Object traverse(PatternNodeVisitor visitor, Object data) {
+               Object ret = accept(visitor, data);
+               if (this.typePattern != null)
+                       this.typePattern.traverse(visitor, ret);
+               return ret;
+       }
 }