<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/main/java/uk/co/badgersinfoil/metaas/impl/antlr</tt></b></td></tr>
<tr><td><tt><a href="#file1">BasicListUpdateDelegate.java</a></tt> </td><td></td><td align="right" id="added">+35</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">392 -&gt; 393</td></tr>
</table>
<pre class="comment">
improve 'placeholder'-token handling
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">metaas/trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/antlr</span><br />
<div class="fileheader"><big><b>BasicListUpdateDelegate.java</b></big> <small id="info">392 -&gt; 393</small></div>
<pre class="diff"><small id="info">--- trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/antlr/BasicListUpdateDelegate.java        2007-02-09 23:34:59 UTC (rev 392)
+++ trunk/src/main/java/uk/co/badgersinfoil/metaas/impl/antlr/BasicListUpdateDelegate.java        2007-02-10 00:00:11 UTC (rev 393)
@@ -4,6 +4,8 @@
</small></pre><pre class="diff" id="context"> 
 package uk.co.badgersinfoil.metaas.impl.antlr;
 
</pre><pre class="diff" id="added">+import org.asdt.core.internal.antlr.AS3Parser;
+import uk.co.badgersinfoil.metaas.impl.ASTUtils;
</pre><pre class="diff" id="context"> import uk.co.badgersinfoil.metaas.impl.TokenBuilder;
 
 /**
</pre><pre class="diff"><small id="info">@@ -17,6 +19,21 @@
</small></pre><pre class="diff" id="context">         // TODO: delete PLACEHOLDER tokens when they are superseded by the addition of real tokens
 
         public void addedChild(LinkedListTree parent, LinkedListTree child) {
</pre><pre class="diff" id="added">+                if (isPlaceholder(parent)) {
+                        if (isPlaceholder(child)) {
+                                throw new IllegalArgumentException("The parent node ("+ASTUtils.tokenName(parent)+") has only a placeholder token, so a child which also has only a placeholder token ("+ASTUtils.tokenName(child)+") can't be added yet");
+                        }
+                        LinkedListToken placeholder = parent.getStartToken();
+                        if (placeholder.getPrev() != null) {
+                                placeholder.getPrev().setNext(child.getStartToken());
+                        }
+                        if (placeholder.getNext() != null) {
+                                placeholder.getNext().setPrev(child.getStopToken());
+                        }
+                        parent.setStartToken(child.getStartToken());
+                        parent.setStopToken(child.getStopToken());
+                        return;
+                }
</pre><pre class="diff" id="context">                 LinkedListToken stop = findTokenInsertionPointForChildWithinParent(parent, child);
                 if (parent.getStartToken() == null) {
                         parent.setStartToken(child.getStartToken());
</pre><pre class="diff"><small id="info">@@ -30,6 +47,12 @@
</small></pre><pre class="diff" id="context">                 }
         }
 
</pre><pre class="diff" id="added">+        private boolean isPlaceholder(LinkedListTree ast) {
+                return ast.getStartToken()==ast.getStopToken()
+                    &amp;&amp; ast.getStartToken()!=null
+                    &amp;&amp; ast.getStartToken().getType()==AS3Parser.VIRTUAL_PLACEHOLDER;
+        }
+
</pre><pre class="diff" id="context">         private LinkedListToken findTokenInsertionPointForChildWithinParent(LinkedListTree parent, LinkedListTree child) {
                 // FIXME: this fails to take into account am ancestor not
                 // having the same kind of TreeTokenListUpdateDelegate
</pre><pre class="diff"><small id="info">@@ -69,8 +92,12 @@
</small></pre><pre class="diff" id="context">                 LinkedListToken target;
                 LinkedListToken targetNext;
                 if (index == 0) {
</pre><pre class="diff" id="removed">-                        targetNext = parent.getFirstChild().getStartToken();
</pre><pre class="diff" id="added">+                        LinkedListTree prevFirstChild = (LinkedListTree)parent.getChild(1);
+                        targetNext = prevFirstChild.getStartToken();
</pre><pre class="diff" id="context">                         target = targetNext.getPrev();
</pre><pre class="diff" id="added">+                        if (targetNext == parent.getStartToken()) {
+                                parent.setStartToken(child.getStartToken());
+                        }
</pre><pre class="diff" id="context">                 } else {
                         target = ((LinkedListTree)parent.getChild(index - 1)).getStopToken();
                         targetNext = target.getNext();
</pre><pre class="diff"><small id="info">@@ -115,6 +142,13 @@
</small></pre><pre class="diff" id="context">         }
 
         public void addToken(LinkedListTree parent, int index, LinkedListToken append) {
</pre><pre class="diff" id="added">+                if (isPlaceholder(parent)) {
+                        LinkedListToken placeholder = parent.getStartToken();
+                        parent.setStartToken(append);
+                        parent.setStopToken(append);
+                        placeholder.setPrev(null);
+                        placeholder.setNext(null);
+                }
</pre><pre class="diff" id="context">                 if (parent.getStopToken() == null) {
                         parent.setStartToken(append);
                         parent.setStopToken(append);
</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>