<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #copied {background-color:#ccccff;}
  tr.alt #copied {background-color:#bbbbf7;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;white-space:pre-wrap;word-wrap:break-word;padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="5">Commit in <b><tt>metaas/trunk/src</tt></b></td></tr>
<tr><td><tt>main/antlr/org/asdt/core/internal/antlr/<a href="#file1">AS3.g3</a></tt> </td><td></td><td align="right" id="added">+3</td><td align="right" id="removed">-3</td><td nowrap="nowrap" align="center">520 -&gt; 521</td></tr>
<tr class="alt"><td><tt>main/java/uk/co/badgersinfoil/metaas/dom/<a href="#file2">ASInvocationExpression.java</a></tt> </td><td></td><td align="right" id="added">+4</td><td></td><td nowrap="nowrap" align="center">520 -&gt; 521</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file3">ASNewExpression.java</a></tt> </td><td></td><td align="right" id="added">+8</td><td align="right" id="removed">-7</td><td nowrap="nowrap" align="center">520 -&gt; 521</td></tr>
<tr class="alt"><td><tt>main/java/uk/co/badgersinfoil/metaas/impl/<a href="#file4">ASTASNewExpression.java</a></tt> </td><td></td><td align="right" id="added">+20</td><td align="right" id="removed">-20</td><td nowrap="nowrap" align="center">520 -&gt; 521</td></tr>
<tr><td><tt>test/java/uk/co/badgersinfoil/metaas/<a href="#file5">InvocationExpressionTests.java</a></tt> </td><td></td><td align="right" id="added">+14</td><td align="right" id="removed">-10</td><td nowrap="nowrap" align="center">520 -&gt; 521</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file6">NewExpressionTests.java</a></tt> </td><td></td><td align="right" id="added">+24</td><td align="right" id="removed">-27</td><td nowrap="nowrap" align="center">520 -&gt; 521</td></tr>
<tr><td></td><td></td><td align="right" id="added">+73</td><td align="right" id="removed">-67</td><td></td></tr>
</table>
<small id="info">6 modified files</small><br />
<pre class="comment">
Improve 'new' expression support, including making the arg list optional
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">metaas/trunk/src/main/antlr/org/asdt/core/internal/antlr</span><br />
<div class="fileheader"><big><b>AS3.g3</b></big> <small id="info">520 -&gt; 521</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/antlr/org/asdt/core/internal/antlr/AS3.g3        2007-09-01 22:18:35 UTC (rev 520)
+++ trunk/src/main/antlr/org/asdt/core/internal/antlr/AS3.g3        2007-09-01 23:37:32 UTC (rev 521)
@@ -1091,14 +1091,14 @@
</small></pre><pre class="diff" id="context">         
 
 newExpression
</pre><pre class="diff" id="removed">-        :        NEW^ fullNewSubexpression arguments
</pre><pre class="diff" id="added">+        :        NEW^ fullNewSubexpression ((LPAREN)=&gt; arguments)?
</pre><pre class="diff" id="context">         
 
 fullNewSubexpression
         :        (        primaryExpression -&gt; primaryExpression
                 )
</pre><pre class="diff" id="removed">-                (        d=DOT qualifiedIdent -&gt; ^(PROPERTY_OR_IDENTIFIER[$d] $fullNewSubexpression qualifiedIdent)
-                |        brackets -&gt; ^(ARRAY_ACC $fullNewSubexpression brackets)
</pre><pre class="diff" id="added">+                (        (DOT)=&gt; d=DOT qualifiedIdent -&gt; ^(PROPERTY_OR_IDENTIFIER[$d] $fullNewSubexpression qualifiedIdent)
+                |        (LBRACK)=&gt; brackets -&gt; ^(ARRAY_ACC $fullNewSubexpression brackets)
</pre><pre class="diff" id="context">                 )*
         
 
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader"><big><b>ASInvocationExpression.java</b></big> <small id="info">520 -&gt; 521</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASInvocationExpression.java        2007-09-01 22:18:35 UTC (rev 520)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASInvocationExpression.java        2007-09-01 23:37:32 UTC (rev 521)
@@ -2,6 +2,10 @@
</small></pre><pre class="diff" id="context"> 
 import java.util.List;
 
</pre><pre class="diff" id="added">+/**
+ * An expression that invokes a method or function.  For constructor
+ * invocations see {@link ASNewExpression}.
+ */
</pre><pre class="diff" id="context"> public interface ASInvocationExpression extends ASExpression {
         public ASExpression getTargetExpression();
         public void setTargetExpression(ASExpression expr);
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/dom</span><br />
<div class="fileheader"><big><b>ASNewExpression.java</b></big> <small id="info">520 -&gt; 521</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASNewExpression.java        2007-09-01 22:18:35 UTC (rev 520)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/dom/ASNewExpression.java        2007-09-01 23:37:32 UTC (rev 521)
@@ -1,10 +1,11 @@
</small></pre><pre class="diff" id="context"> package uk.co.badgersinfoil.metaas.dom;
 
</pre><pre class="diff" id="removed">-import java.util.List;
-
-public interface ASNewExpression extends ASExpression {
-        public ASExpression getExpression();
-        public void setExpression(ASExpression expr);
-        public List getArguments();
-        public void setArguments(List args);
</pre><pre class="diff" id="added">+/**
+ * Specialisation of an ASInvocationExpression representing a constructor
+ * invocation using the 'new' keyword.  It is legal for a constructor
+ * invocation to appear without arguments (the parenthesis can be dropped e.g
+ * 'new Ctor', rather than 'new Ctor()'), and in this case, getArguments()
+ * will return null.
+ */
+public interface ASNewExpression extends ASInvocationExpression {
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl</span><br />
<div class="fileheader"><big><b>ASTASNewExpression.java</b></big> <small id="info">520 -&gt; 521</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASNewExpression.java        2007-09-01 22:18:35 UTC (rev 520)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/ASTASNewExpression.java        2007-09-01 23:37:32 UTC (rev 521)
@@ -11,37 +11,37 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree;
 
 
</pre><pre class="diff" id="removed">-public class ASTASNewExpression extends ASTASExpression implements
</pre><pre class="diff" id="added">+public class ASTASNewExpression extends ASTAS<span id="addedchars">Invocation</span>Expression implements
</pre><pre class="diff" id="context">                 ASNewExpression {
 
         public ASTASNewExpression(LinkedListTree ast) {
                 super(ast);
         }
 
</pre><pre class="diff" id="added">+        private boolean hasArgs() {
+                return ASTUtils.findChildByType(ast, AS3Parser.ARGUMENTS) != null;
+        }
+
</pre><pre class="diff" id="context">         public List getArguments() {
</pre><pre class="diff" id="removed">-                LinkedListTree args = ASTUtils.findChildByType(ast, AS3Parser.ARGUMENTS);
-                ASTIterator i = new ASTIterator(args);
-                List result = new ArrayList(args.getChildCount());
-                while (i.hasNext()) {
-                        result.add(ExpressionBuilder.build(i.next()));
</pre><pre class="diff" id="added">+                if (hasArgs()) {
+                        return super.getArguments();
</pre><pre class="diff" id="context">                 }
</pre><pre class="diff" id="removed">-                return Collections.unmodifiableList(result);
</pre><pre class="diff" id="added">+                return null;
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        public ASExpression getExpression() {
-                return ExpressionBuilder.build(ast.getFirstChild());
-        }
-
</pre><pre class="diff" id="context">         public void setArguments(List args) {
</pre><pre class="diff" id="removed">-                LinkedListTree arguments = ASTUtils.findChildByType(ast, AS3Parser.ARGUMENTS);                
-                for (Iterator i=args.iterator(); i.hasNext(); ) {
-                        ASTASExpression arg = (ASTASExpression)i.next();
-                        arguments.addChildWithTokens(arg.getAST());
</pre><pre class="diff" id="added">+                if (hasArgs()) {
+                        if (args == null) {
+                                ast.deleteChild(1);
+                        } else {
+                                super.setArguments(args);
+                        }
+                } else {
+                        if (args != null) {
+                                LinkedListTree argTree = ASTUtils.newParentheticAST(AS3Parser.ARGUMENTS, AS3Parser.LPAREN, "(", AS3Parser.RPAREN, ")");
+                                ast.addChildWithTokens(argTree);
+                                super.setArguments(args);
+                        }
</pre><pre class="diff" id="context">                 }
         }
</pre><pre class="diff" id="removed">-
-        public void setExpression(ASExpression expr) {
-                LinkedListTree exprAST = ((ASTASExpression)expr).getAST();
-                ast.setChildWithTokens(0, exprAST);
-        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname">metaas/trunk/src/test/java/uk/co/badgersinfoil/metaas</span><br />
<div class="fileheader"><big><b>InvocationExpressionTests.java</b></big> <small id="info">520 -&gt; 521</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/metaas/InvocationExpressionTests.java        2007-09-01 22:18:35 UTC (rev 520)
+++ trunk/src/test/java/uk/co/badgersinfoil/metaas/InvocationExpressionTests.java        2007-09-01 23:37:32 UTC (rev 521)
@@ -8,16 +8,16 @@
</small></pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASInvocationExpression;
 import uk.co.badgersinfoil.metaas.dom.ASStringLiteral;
 import uk.co.badgersinfoil.metaas.impl.AS3FragmentParser;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.impl.ASTAS<span id="removedchars">Invocation</span>Expression;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.impl.ASTASExpression;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.impl.ASTPrinter;
 import uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree;
 import junit.framework.TestCase;
 
 public class InvocationExpressionTests extends TestCase {
</pre><pre class="diff" id="removed">-        private ActionScriptFactory fact = new ActionScriptFactory();
-        private ASExpression sub;
-        private ASInvocationExpression expr;
-        private List args;
</pre><pre class="diff" id="added">+        protected ActionScriptFactory fact = new ActionScriptFactory();
+        protected ASExpression sub;
+        protected ASInvocationExpression expr;
+        protected List args;
</pre><pre class="diff" id="context"> 
         public void setUp() {
                 args = new ArrayList();
</pre><pre class="diff"><small id="info">@@ -26,29 +26,33 @@
</small></pre><pre class="diff" id="context"> 
         public void tearDown() {
                 StringWriter buff = new StringWriter();
</pre><pre class="diff" id="removed">-                LinkedListTree ast = ((ASTAS<span id="removedchars">Invocation</span>Expression)expr).getAST();
</pre><pre class="diff" id="added">+                LinkedListTree ast = ((ASTASExpression)expr).getAST();
</pre><pre class="diff" id="context">                 new ASTPrinter(buff).print(ast);
                 LinkedListTree parsed = AS3FragmentParser.parseExpr(buff.toString());
                 CodeMirror.assertASTMatch(ast, parsed);
         }
</pre><pre class="diff" id="added">+        
+        protected ASInvocationExpression newTestExpr(ASExpression sub, List args) {
+                return fact.newInvocationExpression(sub, args);
+        }
</pre><pre class="diff" id="context"> 
         public void testBasic() {
                 args.add(fact.newIntegerLiteral(1));
</pre><pre class="diff" id="removed">-                expr = fact.newInvocationExpression(sub, args);
</pre><pre class="diff" id="added">+                expr = newTestExpr(sub, args);
</pre><pre class="diff" id="context">                 assertEquals(sub, expr.getTargetExpression());
                 List actualArgs = expr.getArguments();
                 assertEquals(1, actualArgs.size());
         }
 
         public void testSetExpression() {
</pre><pre class="diff" id="removed">-                expr = fact.newInvocationExpression(sub, args);
</pre><pre class="diff" id="added">+                expr = newTestExpr(sub, args);
</pre><pre class="diff" id="context">                 sub = fact.newExpression("Replacement");
                 expr.setTargetExpression(sub);
                 assertEquals(sub, expr.getTargetExpression());
         }
 
         public void testSetArguments() {
</pre><pre class="diff" id="removed">-                expr = fact.newInvocationExpression(sub, args);
</pre><pre class="diff" id="added">+                expr = newTestExpr(sub, args);
</pre><pre class="diff" id="context">                 List newArgs = new ArrayList();
                 ASIntegerLiteral arg1 = fact.newIntegerLiteral(1);
                 newArgs.add(arg1);
</pre><pre class="diff"><small id="info">@@ -61,7 +65,7 @@
</small></pre><pre class="diff" id="context">         }
 
         public void testReplaceArguments() {
</pre><pre class="diff" id="removed">-                expr = fact.newInvocationExpression(sub, args);
</pre><pre class="diff" id="added">+                expr = newTestExpr(sub, args);
</pre><pre class="diff" id="context">                 List args = new ArrayList();
                 ASIntegerLiteral arg = fact.newIntegerLiteral(1);
                 args.add(arg);
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname">metaas/trunk/src/test/java/uk/co/badgersinfoil/metaas</span><br />
<div class="fileheader"><big><b>NewExpressionTests.java</b></big> <small id="info">520 -&gt; 521</small></div>
<pre class="diff"><small id="info">--- trunk/src/test/java/uk/co/badgersinfoil/metaas/NewExpressionTests.java        2007-09-01 22:18:35 UTC (rev 520)
+++ trunk/src/test/java/uk/co/badgersinfoil/metaas/NewExpressionTests.java        2007-09-01 23:37:32 UTC (rev 521)
@@ -3,43 +3,40 @@
</small></pre><pre class="diff" id="context"> import java.util.ArrayList;
 import java.util.List;
 import uk.co.badgersinfoil.metaas.dom.ASExpression;
</pre><pre class="diff" id="removed">-import uk.co.badgersinfoil.metaas.dom.ASIn<span id="removedchars">tegerLiteral</span>;
</pre><pre class="diff" id="added">+import uk.co.badgersinfoil.metaas.dom.ASIn<span id="addedchars">vocationExpression</span>;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.dom.ASNewExpression;
</pre><pre class="diff" id="removed">-import junit.framework.TestCase;
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-public class NewExpressionTests extends TestCase {
-        private ActionScriptFactory fact = new ActionScriptFactory();
-        private ASExpression sub;
-        private ASNewExpression expr;
-        private List args;
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+public class NewExpressionTests extends InvocationExpressionTests {
+
</pre><pre class="diff" id="context">         public void setUp() {
                 args = new ArrayList();
                 sub = fact.newExpression("com.example.MyClass");
         }
</pre><pre class="diff" id="added">+        
+        protected ASInvocationExpression newTestExpr(ASExpression sub, List args) {
+                return fact.newNewExpression(sub, args);
+        }
+        
+        private ASNewExpression getExpr() {
+                return (ASNewExpression)expr;
+        }
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-        public void test<span id="removedchars">Basic</span>() {
</pre><pre class="diff" id="added">+        public void test<span id="addedchars">NoArgs</span>() {
+                expr = newTestExpr(sub, null);
+                assertNull(getExpr().getArguments());
+        }
+        
+        public void testRemoveArgs() {
</pre><pre class="diff" id="context">                 args.add(fact.newIntegerLiteral(1));
</pre><pre class="diff" id="removed">-                expr = fact.newNewExpression(sub, args);
-                assertEquals(sub, expr.getExpression());
-                List actualArgs = expr.getArguments();
-                assertEquals(1, actualArgs.size());
</pre><pre class="diff" id="added">+                expr = newTestExpr(sub, args);
+                getExpr().setArguments(null);
+                assertNull(getExpr().getArguments());
</pre><pre class="diff" id="context">         }
 
</pre><pre class="diff" id="removed">-        public void testSetExpression() {
-                expr = fact.newNewExpression(sub, args);
-                sub = fact.newExpression("Replacement");
-                expr.setExpression(sub);
-                assertEquals(sub, expr.getExpression());
</pre><pre class="diff" id="added">+        public void testAddArgs() {
+                expr = newTestExpr(sub, null);
+                getExpr().setArguments(args);
+                assertNotNull(getExpr().getArguments());
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="removed">-
-        public void testSetArguments() {
-                expr = fact.newNewExpression(sub, args);
-                List newArgs = new ArrayList();
-                ASIntegerLiteral arg = fact.newIntegerLiteral(1);
-                newArgs.add(arg);
-                expr.setArguments(newArgs);
-                assertEquals(1, expr.getArguments().size());
-                assertEquals(arg, expr.getArguments().get(0));
-        }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.12</small></center>
</body></html>