You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2011/04/30 00:55:02 UTC

svn commit: r1097987 - in /tapestry/tapestry5/trunk/plastic/src: main/java/org/apache/tapestry5/internal/plastic/ main/java/org/apache/tapestry5/plastic/ test/groovy/org/apache/tapestry5/plastic/

Author: hlship
Date: Fri Apr 29 22:55:02 2011
New Revision: 1097987

URL: http://svn.apache.org/viewvc?rev=1097987&view=rev
Log:
TAP5-853: Add ability to determine if a PlasticMethod represents an override of a transformed super-class method

Modified:
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
    tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java
    tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java?rev=1097987&r1=1097986&r2=1097987&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java (original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/internal/plastic/PlasticClassImpl.java Fri Apr 29 22:55:02 2011
@@ -211,6 +211,11 @@ public class PlasticClassImpl extends Lo
             return description.compareTo(o.description);
         }
 
+        public boolean isOverride()
+        {
+            return parentMethodBundle.isImplemented(node.name, node.desc);
+        }
+
         public MethodHandle getHandle()
         {
             check();
@@ -1363,7 +1368,7 @@ public class PlasticClassImpl extends Lo
 
     private final StaticContext staticContext;
 
-    private final MethodBundle methodBundle;
+    private final MethodBundle parentMethodBundle, methodBundle;
 
     // MethodNodes in which field transformations should occur; this is most existing and
     // introduced methods, outside of special access methods.
@@ -1428,6 +1433,7 @@ public class PlasticClassImpl extends Lo
         className = PlasticInternalUtils.toClassName(classNode.name);
         superClassName = PlasticInternalUtils.toClassName(classNode.superName);
 
+        this.parentMethodBundle = parentMethodBundle;
         methodBundle = parentMethodBundle.createChild(className);
 
         methods = new ArrayList(classNode.methods.size());

Modified: tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java?rev=1097987&r1=1097986&r2=1097987&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java (original)
+++ tapestry/tapestry5/trunk/plastic/src/main/java/org/apache/tapestry5/plastic/PlasticMethod.java Fri Apr 29 22:55:02 2011
@@ -100,4 +100,11 @@ public interface PlasticMethod extends A
      * the visible annotations on those parameters.
      */
     List<MethodParameter> getParameters();
+
+    /**
+     * Returns true if the method is an override of a method from the parent class.
+     * 
+     * @return true if the parent class contains a method with the name signature
+     */
+    boolean isOverride();
 }

Modified: tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy?rev=1097987&r1=1097986&r2=1097987&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy (original)
+++ tapestry/tapestry5/trunk/plastic/src/test/groovy/org/apache/tapestry5/plastic/MethodIntroduction.groovy Fri Apr 29 22:55:02 2011
@@ -8,10 +8,12 @@ class MethodIntroduction extends Abstrac
 
     static final String CLASS_NAME = "testsubjects.ChildClass"
 
-    def instanceWithIntroducedMethod(MethodDescription md) {
+    def instanceWithIntroducedMethod(MethodDescription md, isOverride) {
         def mgr = createMgr ({ PlasticClass pc ->
             if (pc.className == CLASS_NAME) {
-                pc.introduceMethod(md)
+                def method = pc.introduceMethod(md)
+                
+                assert method.override == isOverride
             }
         } as PlasticClassTransformer)
 
@@ -20,7 +22,7 @@ class MethodIntroduction extends Abstrac
 
     def "introduce method not present in base class"() {
 
-        def o = instanceWithIntroducedMethod(new MethodDescription(returnType, methodName))
+        def o = instanceWithIntroducedMethod(new MethodDescription(returnType, methodName), false)
 
         when:
 
@@ -55,7 +57,7 @@ class MethodIntroduction extends Abstrac
 
         setup:
 
-        def o = instanceWithIntroducedMethod(new MethodDescription("void", "voidMethod"))
+        def o = instanceWithIntroducedMethod(new MethodDescription("void", "voidMethod"), true)
 
         when:
 
@@ -69,7 +71,7 @@ class MethodIntroduction extends Abstrac
     def "introduce primitive method override"() {
         setup:
 
-        def o = instanceWithIntroducedMethod (new MethodDescription("int", "primitiveMethod", "int"))
+        def o = instanceWithIntroducedMethod (new MethodDescription("int", "primitiveMethod", "int"), true)
 
         expect:
 
@@ -80,7 +82,7 @@ class MethodIntroduction extends Abstrac
 
         setup:
 
-        def o = instanceWithIntroducedMethod (new MethodDescription("java.lang.String", "objectMethod", "java.lang.String"))
+        def o = instanceWithIntroducedMethod (new MethodDescription("java.lang.String", "objectMethod", "java.lang.String"), true)
 
         expect: