Revision: 3723
Author: felix8a
Date: Thu Sep 10 15:16:44 2009
Log: remove unused 'target' field from Job
http://codereview.appspot.com/115089
the Job class has a 'target' field that isn't used,
and probably doesn't work correctly if it is used.
I was trying to write another pipeline stage, and got
confused by Job.target, and couldn't convince myself that
Job.target was going to behave correctly, then found out that
it isn't used by any reachable code.
this change deletes all the references to Job.target.
[email protected]
http://code.google.com/p/google-caja/source/detail?r=3723
Modified:
/trunk/src/com/google/caja/plugin/Job.java
/trunk/src/com/google/caja/plugin/stages/ConsolidateCodeStage.java
/trunk/tests/com/google/caja/service/CajolingServiceTest.java
=======================================
--- /trunk/src/com/google/caja/plugin/Job.java Fri Apr 17 11:17:36 2009
+++ /trunk/src/com/google/caja/plugin/Job.java Thu Sep 10 15:16:44 2009
@@ -34,20 +34,11 @@
}
private final AncestorChain<?> root;
- private final AncestorChain<?> target;
private final Job.JobType type;
public Job(AncestorChain<?> root) {
- this(root, null);
- }
-
- /**
- * @param target the location to insert the compiled output or null.
- */
- public Job(AncestorChain<?> root, AncestorChain<?> target) {
- assert root != null && (target == null || target.parent != null);
+ assert root != null;
this.root = root;
- this.target = target;
ParseTreeNode rootNode = root.node;
if (rootNode instanceof Statement
|| rootNode instanceof Expression
@@ -64,12 +55,6 @@
}
public AncestorChain<?> getRoot() { return root; }
-
- /**
- * The node to replace with the compiled or rewritten root, or
- * null.
- */
- public AncestorChain<?> getTarget() { return target; }
public Job.JobType getType() { return type; }
=======================================
--- /trunk/src/com/google/caja/plugin/stages/ConsolidateCodeStage.java Wed
May 20 13:31:01 2009
+++ /trunk/src/com/google/caja/plugin/stages/ConsolidateCodeStage.java Thu
Sep 10 15:16:44 2009
@@ -17,7 +17,6 @@
import com.google.caja.lexer.FilePosition;
import com.google.caja.parser.AncestorChain;
import com.google.caja.parser.MutableParseTreeNode;
-import com.google.caja.parser.ParseTreeNode;
import com.google.caja.parser.js.Block;
import com.google.caja.parser.js.Statement;
import com.google.caja.parser.js.UncajoledModule;
@@ -47,23 +46,17 @@
Job job = it.next();
if (Job.JobType.JAVASCRIPT != job.getType()) { continue; }
- if (job.getTarget() != null) {
- AncestorChain<?> toReplace = job.getTarget();
- ((MutableParseTreeNode) toReplace.parent.node).replaceChild(
- job.getRoot().cast(ParseTreeNode.class).node, toReplace.node);
- } else {
- Statement stmt = (Statement) job.getRoot().node;
- if (stmt instanceof Block) {
- Block body = (Block) stmt;
- MutableParseTreeNode.Mutation old = body.createMutation();
- for (Statement s : body.children()) {
- old.removeChild(s);
- mut.appendChild(s);
- }
- old.execute();
- } else {
- mut.appendChild(stmt);
- }
+ Statement stmt = (Statement) job.getRoot().node;
+ if (stmt instanceof Block) {
+ Block body = (Block) stmt;
+ MutableParseTreeNode.Mutation old = body.createMutation();
+ for (Statement s : body.children()) {
+ old.removeChild(s);
+ mut.appendChild(s);
+ }
+ old.execute();
+ } else {
+ mut.appendChild(stmt);
}
it.remove();
=======================================
--- /trunk/tests/com/google/caja/service/CajolingServiceTest.java Wed Sep
9 13:59:29 2009
+++ /trunk/tests/com/google/caja/service/CajolingServiceTest.java Thu Sep
10 15:16:44 2009
@@ -216,7 +216,6 @@
moduleEnvelope,
"<script src=bar.js></script><p>Hello, World!</p>"),
"application/xml");
- String indent = " ";
assertEquals(
String.format(
moduleEnvelope,