Reviewers: MikeSamuel,
Description:
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.
Please review this at http://codereview.appspot.com/115089
Affected files:
M src/com/google/caja/plugin/Job.java
M src/com/google/caja/plugin/stages/ConsolidateCodeStage.java
Index: src/com/google/caja/plugin/stages/ConsolidateCodeStage.java
===================================================================
--- src/com/google/caja/plugin/stages/ConsolidateCodeStage.java (revision
3721)
+++ src/com/google/caja/plugin/stages/ConsolidateCodeStage.java (working
copy)
@@ -47,23 +47,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();
Index: src/com/google/caja/plugin/Job.java
===================================================================
--- src/com/google/caja/plugin/Job.java (revision 3721)
+++ src/com/google/caja/plugin/Job.java (working copy)
@@ -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
@@ -65,12 +56,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; }
@Override