[noop-changes] [noop] 7 new revisions pushed by aeagle22206 on 2010-05-08 20:26 GMT

1 view
Skip to first unread message

no...@googlecode.com

unread,
May 8, 2010, 4:27:12 PM5/8/10
to noop-c...@googlegroups.com
7 new revisions:

Revision: d88ba1be01
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 01:04:21 2010
Log: Fix the stdlib dot graph.
http://code.google.com/p/noop/source/detail?r=d88ba1be01

Revision: 2cc02c4a0d
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 01:29:41 2010
Log: Code review suggestion.
http://code.google.com/p/noop/source/detail?r=2cc02c4a0d

Revision: 9a3b3c9698
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 06:44:04 2010
Log: Remaining examples now dump correctly. The vertices are assigned by
th...
http://code.google.com/p/noop/source/detail?r=9a3b3c9698

Revision: 1dca46d9c7
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 07:46:55 2010
Log: Pull up common code between the printing visitors, and remove last
rem...
http://code.google.com/p/noop/source/detail?r=1dca46d9c7

Revision: 65f63dc4b8
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 08:41:54 2010
Log: Serialize each library to a separate XML file.
http://code.google.com/p/noop/source/detail?r=65f63dc4b8

Revision: 926d565a9b
Author: Alex Eagle <alex...@google.com>
Date: Sat May 8 12:33:33 2010
Log: Update copyrights
http://code.google.com/p/noop/source/detail?r=926d565a9b

Revision: 1dbe8c8549
Author: Alex Eagle <alex...@google.com>
Date: Sat May 8 13:26:32 2010
Log: Get mvn test to run successfully
http://code.google.com/p/noop/source/detail?r=1dbe8c8549

==============================================================================
Revision: d88ba1be01
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 01:04:21 2010
Log: Fix the stdlib dot graph.
http://code.google.com/p/noop/source/detail?r=d88ba1be01

Added:
/core/src/test/java/noop/graph/PrintingVisitorTest.java
Deleted:
/core/src/main/java/noop/model/EmptyDocumentation.java
Modified:
/core/src/main/java/noop/graph/DotGraphPrintingVisitor.java
/core/src/main/java/noop/graph/ModelVisitor.java
/core/src/main/java/noop/graph/OutlinePrintingVisitor.java
/core/src/main/java/noop/graph/PrintingVisitor.java
/core/src/main/java/noop/graph/VertexCreatingVisitor.java
/core/src/main/java/noop/graph/Workspace.java
/core/src/main/java/noop/model/Documentation.java
/core/src/main/java/noop/model/LanguageElement.java
/core/src/main/java/noop/model/Library.java
/core/src/main/java/noop/model/Project.java
/core/src/test/java/noop/graph/VertexCreatingVisitorTest.java

=======================================
--- /dev/null
+++ /core/src/test/java/noop/graph/PrintingVisitorTest.java Sun Apr 25
01:04:21 2010
@@ -0,0 +1,46 @@
+package noop.graph;
+
+import noop.model.*;
+import org.junit.Test;
+
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author alex...@google.com (Alex Eagle)
+ */
+public class PrintingVisitorTest {
+ @Test public void testCorrectParent() {
+ final Project p = new Project("p", "ns", "c");
+ final Library l1 = new Library(UUID.randomUUID(), "l1");
+ p.addLibrary(l1);
+ final Library l2 = new Library(UUID.randomUUID(), "l2");
+ p.addLibrary(l2);
+ final Clazz c1 = new Clazz("c1");
+ l1.addClazz(c1);
+ c1.addBlock(new AnonymousBlock());
+ final Block block2 = new AnonymousBlock();
+ c1.addBlock(block2);
+ final Clazz c2 = new Clazz("c2");
+ l2.addClazz(c2);
+
+ final PrintingVisitor visitor = new PrintingVisitor() {
+ @Override
+ public void visit(Clazz clazz) {
+ if (clazz == c1) {
+ assertEquals(l1, getParent());
+ }
+ if (clazz == c2) {
+ assertEquals(l2, getParent());
+ }
+ }
+
+ @Override
+ public void visit(AnonymousBlock block) {
+ assertEquals(c1, getParent());
+ }
+ };
+ p.accept(visitor);
+ }
+}
=======================================
--- /core/src/main/java/noop/model/EmptyDocumentation.java Fri Apr 23
04:40:41 2010
+++ /dev/null
@@ -1,11 +0,0 @@
-package noop.model;
-
-/**
- * The Null Object for Documentation.
- * @author alex...@google.com (Alex Eagle)
- */
-public class EmptyDocumentation extends Documentation {
- public EmptyDocumentation() {
- super("", "");
- }
-}
=======================================
--- /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Fri Apr 23
06:41:28 2010
+++ /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
01:04:21 2010
@@ -22,9 +22,7 @@
import java.io.PrintStream;

import static com.google.common.base.Join.join;
-import static com.google.common.collect.Iterables.filter;
import static java.lang.System.identityHashCode;
-import static noop.graph.Edge.notContain;

/**
* @author alex...@google.com (Alex Eagle)
@@ -40,7 +38,10 @@
public void visit(Workspace workspace) {
this.workspace = workspace;
out.format("digraph workspace\n{\n");
- print(workspace, "Workspace", "shape=house");
+ out.format("workspace
[label=\"%s\" %s]\n", "Workspace", "shape=house");
+ for (Project project : workspace.getProjects()) {
+ out.format("workspace -> %s\n", project.vertex.hashCode());
+ }
}

private void print(LanguageElement element, String label, String...
additional) {
@@ -48,11 +49,14 @@
if (additional.length > 0) {
attrs = ", " + attrs;
}
- out.format("%s [label=\"%s\"%s]\n", element.vertex, label, attrs);
- for (Edge edge : filter(workspace.edgesFrom(element.vertex),
notContain())) {
- out.format("%s -> %s ", edge.src, edge.dest);
+ out.format("%s [label=\"%s\"%s]\n", element.vertex.hashCode(), label,
attrs);
+ for (Edge edge : workspace.edgesFrom(element.vertex)) {
+ out.format("%s -> %s ", edge.src.hashCode(), edge.dest.hashCode());
out.println("[label=\"" + edge.type.name().toLowerCase() + "\",
style=dashed]");
}
+ if (getParent().vertex != element.vertex) {
+ out.format("%s -> %s\n", getParent().vertex.hashCode(),
element.vertex.hashCode());
+ }
}

@Override
@@ -60,12 +64,13 @@
print(project, String.format("%s -> %s", project.getNamespace(),
project.getName()), "shape=box");
out.format("%s [label=\"%s\", shape=none]\n",
identityHashCode(project.getCopyright()),
escape(project.getCopyright()));
- out.format("%s -> %s\n", project.vertex,
identityHashCode(project.getCopyright()));
+ out.format("%s -> %s\n", project.vertex.hashCode(),
identityHashCode(project.getCopyright()));
}

@Override
public void visit(Library library) {
print(library, library.name, "shape=hexagon");
+
}

@Override
@@ -116,7 +121,9 @@

@Override
public void visit(Documentation documentation) {
- out.format("%s [label=\"%s\"%s]\n", identityHashCode(documentation),
escape(documentation.summary), "shape=none");
+ if (documentation != Documentation.NONE) {
+ out.format("%s [label=\"%s\"%s]\n", identityHashCode(documentation),
escape(documentation.summary), "shape=none");
+ }
}

protected String escape(String value) {
@@ -138,7 +145,7 @@
}

@Override
- public void leave(Visitable element) {
+ public void leave(LanguageElement element) {
super.leave(element);
if (currentDepth == 0) {
out.println("}");
=======================================
--- /core/src/main/java/noop/graph/ModelVisitor.java Fri Apr 23 04:53:28
2010
+++ /core/src/main/java/noop/graph/ModelVisitor.java Sun Apr 25 01:04:21
2010
@@ -22,9 +22,9 @@
* @author alex...@google.com (Alex Eagle)
*/
public abstract class ModelVisitor {
- public void enter(Visitable element) {}
-
- public void leave(Visitable element) {}
+ public void enter(LanguageElement element) {}
+
+ public void leave(LanguageElement element) {}

public void visit(Edge edge) {}

=======================================
--- /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Fri Apr 23
06:41:28 2010
+++ /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
01:04:21 2010
@@ -69,6 +69,7 @@

@Override
public void visit(Documentation documentation) {
+ if (documentation != Documentation.NONE)
out.format("%s%s\n", indent(), String.format("Documentation: %s",
documentation.summary));
}

=======================================
--- /core/src/main/java/noop/graph/PrintingVisitor.java Fri Apr 23 06:41:28
2010
+++ /core/src/main/java/noop/graph/PrintingVisitor.java Sun Apr 25 01:04:21
2010
@@ -1,6 +1,8 @@
package noop.graph;

-import noop.model.Visitable;
+import noop.model.LanguageElement;
+
+import java.util.Stack;

/**
* @author alex...@google.com (Alex Eagle)
@@ -8,14 +10,24 @@
public class PrintingVisitor extends ModelVisitor {
protected Workspace workspace;
protected int currentDepth;
+ protected Stack<LanguageElement> parents = new Stack<LanguageElement>();
+
+ protected LanguageElement getParent() {
+ if (parents.size() < 2) {
+ return null;
+ }
+ return parents.elementAt(parents.size() - 2);
+ }

@Override
- public void enter(Visitable element) {
+ public void enter(LanguageElement element) {
+ parents.push(element);
currentDepth++;
}

@Override
- public void leave(Visitable element) {
+ public void leave(LanguageElement element) {
+ parents.pop();
currentDepth--;
}

=======================================
--- /core/src/main/java/noop/graph/VertexCreatingVisitor.java Fri Apr 23
06:41:28 2010
+++ /core/src/main/java/noop/graph/VertexCreatingVisitor.java Sun Apr 25
01:04:21 2010
@@ -2,7 +2,6 @@

import noop.model.LanguageElement;
import noop.model.Library;
-import noop.model.Visitable;

/**
* Creates the vertex in the element graph for each element encountered
which doesn't have one already.
@@ -12,14 +11,11 @@
private Library currentLibrary;

@Override
- public void visit(Library library) {
- currentLibrary = library;
- }
-
- @Override
- public void enter(Visitable v) {
- if (currentLibrary != null && v instanceof LanguageElement) {
- LanguageElement element = (LanguageElement) v;
+ public void enter(LanguageElement element) {
+ if (element instanceof Library) {
+ currentLibrary = (Library) element;
+ }
+ if (currentLibrary != null) {
if (element.vertex == Vertex.NONE) {
int nextIndex = currentLibrary.add(element);
element.vertex = new Vertex(currentLibrary.uid, nextIndex);
=======================================
--- /core/src/main/java/noop/graph/Workspace.java Fri Apr 23 06:41:28 2010
+++ /core/src/main/java/noop/graph/Workspace.java Sun Apr 25 01:04:21 2010
@@ -18,6 +18,7 @@

import com.google.common.base.Nullable;
import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -34,15 +35,10 @@
public final Set<Edge> edges = Sets.newHashSet();
public final List<LanguageElement> elements =
Lists.<LanguageElement>newArrayList(this);
private List<Project> projects = Lists.newArrayList();
- private List<LanguageElement> orphans = Lists.newArrayList();

public void addProject(Project project) {
projects.add(project);
}
-
- public void addOrphan(LanguageElement orphan) {
- orphans.add(orphan);
- }

@Override
public void accept(ModelVisitor v) {
@@ -67,4 +63,8 @@
}
});
}
-}
+
+ public List<Project> getProjects() {
+ return ImmutableList.copyOf(projects);
+ }
+}
=======================================
--- /core/src/main/java/noop/model/Documentation.java Fri Apr 23 04:53:28
2010
+++ /core/src/main/java/noop/model/Documentation.java Sun Apr 25 01:04:21
2010
@@ -21,9 +21,10 @@
/**
* @author alex...@google.com (Alex Eagle)
*/
-public class Documentation implements Visitable {
+public class Documentation extends LanguageElement<Documentation> {
public final String summary;
public final String author;
+ public static final Documentation NONE = new Documentation("", "");

public Documentation(String summary, String author) {
this.summary = summary;
=======================================
--- /core/src/main/java/noop/model/LanguageElement.java Fri Apr 23 06:41:28
2010
+++ /core/src/main/java/noop/model/LanguageElement.java Sun Apr 25 01:04:21
2010
@@ -30,7 +30,7 @@
*/
public abstract class LanguageElement<T> implements Serializable,
Visitable {
public Vertex vertex = Vertex.NONE;
- protected Documentation documentation = new EmptyDocumentation();
+ protected Documentation documentation = Documentation.NONE;
protected List<Comment> comments = Lists.newArrayList();
protected Set<UnitTest> unitTests = Sets.newHashSet();
protected T previousVersion;
=======================================
--- /core/src/main/java/noop/model/Library.java Fri Apr 23 06:41:28 2010
+++ /core/src/main/java/noop/model/Library.java Sun Apr 25 01:04:21 2010
@@ -29,7 +29,7 @@
public class Library extends LanguageElement<Library> {
public final UUID uid;
public final String name;
- private final List<LanguageElement> elements =
Lists.<LanguageElement>newArrayList(this);
+ private final List<LanguageElement> elements = Lists.newArrayList();
private final List<Clazz> classes = Lists.newArrayList();
private final List<Block> functions = Lists.newArrayList();

=======================================
--- /core/src/main/java/noop/model/Project.java Fri Apr 23 03:26:30 2010
+++ /core/src/main/java/noop/model/Project.java Sun Apr 25 01:04:21 2010
@@ -16,6 +16,7 @@

package noop.model;

+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import noop.graph.ModelVisitor;
import org.apache.commons.lang.builder.EqualsBuilder;
@@ -86,4 +87,8 @@
}
super.accept(v);
}
-}
+
+ public List<Library> getLibraries() {
+ return ImmutableList.copyOf(libraries);
+ }
+}
=======================================
--- /core/src/test/java/noop/graph/VertexCreatingVisitorTest.java Fri Apr
23 06:41:28 2010
+++ /core/src/test/java/noop/graph/VertexCreatingVisitorTest.java Sun Apr
25 01:04:21 2010
@@ -9,6 +9,7 @@
import java.util.UUID;

import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;

/**
* @author alex...@google.com (Alex Eagle)
@@ -21,8 +22,10 @@
Library l = new Library(uid, "l");
Clazz c = new Clazz("c");
Method m = new Method("m");
+ Library l2 = new Library(UUID.randomUUID(), "l2");

p.addLibrary(l);
+ p.addLibrary(l2);
l.addClazz(c);
c.addBlock(m);

@@ -31,8 +34,9 @@
assertEquals(l, l.getElements().get(0));
assertEquals(c, l.getElements().get(1));
assertEquals(m, l.getElements().get(2));
-
+ assertEquals(new Vertex(uid, 0), l.vertex);
assertEquals(new Vertex(uid, 1), c.vertex);
assertEquals(new Vertex(uid, 2), m.vertex);
+ assertFalse(l2.vertex.libraryUid.equals(uid));
}
}

==============================================================================
Revision: 2cc02c4a0d
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 01:29:41 2010
Log: Code review suggestion.
http://code.google.com/p/noop/source/detail?r=2cc02c4a0d

Modified:
/core/src/main/java/noop/graph/Controller.java
/core/src/test/java/noop/graph/ArithmeticExample.java
/core/src/test/java/noop/graph/ControlFlowExample.java
/core/src/test/java/noop/graph/DumpExamplesMain.java
/core/src/test/java/noop/graph/HelloWorldExample.java

=======================================
--- /core/src/main/java/noop/graph/Controller.java Fri Apr 23 06:41:28 2010
+++ /core/src/main/java/noop/graph/Controller.java Sun Apr 25 01:29:41 2010
@@ -69,13 +69,9 @@
operation.project.accept(addVertices);
}

- public void apply(MutationOperation operation) {
- operation.execute(this);
- }
-
- public void applyAll(Iterable<? extends MutationOperation> operations) {
+ public void apply(MutationOperation... operations) {
for (MutationOperation operation : operations) {
- apply(operation);
+ operation.execute(this);
}
}
}
=======================================
--- /core/src/test/java/noop/graph/ArithmeticExample.java Fri Apr 23
06:41:28 2010
+++ /core/src/test/java/noop/graph/ArithmeticExample.java Sun Apr 25
01:29:41 2010
@@ -7,7 +7,6 @@

import java.util.UUID;

-import static java.util.Arrays.asList;
import static noop.graph.Edge.EdgeType.*;

/**
@@ -31,9 +30,9 @@
library.addFunction(entryPoint);
Parameter consoleDep = new Parameter("console");
entryPoint.addParameter(consoleDep);
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(entryPoint, TYPEOF, stdLib.intClazz),
- new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz)));
+ new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz));

IdentifierDeclaration i = new IdentifierDeclaration("i");
entryPoint.addStatement(i);
@@ -51,20 +50,18 @@
entryPoint.addStatement(k);

Expression sum = new MethodInvocation();
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(sum, INVOKE, stdLib.integerPlus),
new NewEdgeOperation(sum, TARGET, i),
- new NewEdgeOperation(sum, ARG, j)
- ));
+ new NewEdgeOperation(sum, ARG, j));
k.setInitialValue(sum);

Expression printResult = new MethodInvocation();
entryPoint.addStatement(printResult);
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(printResult, INVOKE, stdLib.printMethod),
new NewEdgeOperation(printResult, TARGET, consoleDep),
- new NewEdgeOperation(printResult, ARG, k)
- ));
+ new NewEdgeOperation(printResult, ARG, k));

IntegerLiteral zero = new IntegerLiteral(0);
entryPoint.addStatement(zero);
=======================================
--- /core/src/test/java/noop/graph/ControlFlowExample.java Fri Apr 23
06:41:28 2010
+++ /core/src/test/java/noop/graph/ControlFlowExample.java Sun Apr 25
01:29:41 2010
@@ -7,7 +7,6 @@

import java.util.UUID;

-import static java.util.Arrays.asList;
import static noop.graph.Edge.EdgeType.*;

/**
@@ -49,21 +48,19 @@

Expression terminateWhen = new MethodInvocation();
loop.setTerminationCondition(terminateWhen);
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(terminateWhen, TARGET, i),
new NewEdgeOperation(terminateWhen, INVOKE, stdLib.integerEquals),
- new NewEdgeOperation(terminateWhen, ARG, ten)
- ));
+ new NewEdgeOperation(terminateWhen, ARG, ten));

Block body = new AnonymousBlock();
loop.setBody(body);

Expression printValue = new MethodInvocation();
body.addStatement(printValue);
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(printValue, TARGET, consoleDep),
new NewEdgeOperation(printValue, INVOKE, stdLib.printMethod),
- new NewEdgeOperation(printValue, ARG, i)
- ));
+ new NewEdgeOperation(printValue, ARG, i));
}
}
=======================================
--- /core/src/test/java/noop/graph/DumpExamplesMain.java Fri Apr 23
06:41:28 2010
+++ /core/src/test/java/noop/graph/DumpExamplesMain.java Sun Apr 25
01:29:41 2010
@@ -50,11 +50,10 @@
new Example(stdLib) {
@Override
public void createProgram(Controller controller) {}
- }
-// new ArithmeticExample(stdLib),
-// new HelloWorldExample(stdLib),
-// new ControlFlowExample(stdLib)
- )) {
+ },
+ new ArithmeticExample(stdLib),
+ new HelloWorldExample(stdLib),
+ new ControlFlowExample(stdLib))) {
Workspace workspace = new Workspace();

Controller controller = new Controller(workspace, new
VertexCreatingVisitor());
=======================================
--- /core/src/test/java/noop/graph/HelloWorldExample.java Fri Apr 23
06:41:28 2010
+++ /core/src/test/java/noop/graph/HelloWorldExample.java Sun Apr 25
01:29:41 2010
@@ -7,7 +7,6 @@

import java.util.UUID;

-import static java.util.Arrays.asList;
import static noop.graph.Edge.EdgeType.*;

/**
@@ -32,9 +31,9 @@
Parameter consoleDep = new Parameter("console");
sayHello.addParameter(consoleDep);

- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(sayHello, TYPEOF, stdLib.intClazz),
- new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz)));
+ new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz));

sayHello.setDocumentation(new Documentation("This is the entry point
for the Hello World app",
"alex...@google.com (Alex Eagle)"));
@@ -45,19 +44,19 @@

Expression printHello = new MethodInvocation();
sayHello.addStatement(printHello);
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(printHello, TARGET, consoleDep),
new NewEdgeOperation(printHello, INVOKE, stdLib.printMethod),
- new NewEdgeOperation(printHello, ARG, helloWorld)));
+ new NewEdgeOperation(printHello, ARG, helloWorld));

IntegerLiteral zero = new IntegerLiteral(0);
sayHello.addStatement(zero);

Return aReturn = new Return();
sayHello.addStatement(aReturn);
- controller.applyAll(asList(
+ controller.apply(
new NewEdgeOperation(zero, TYPEOF, stdLib.intClazz),
- new NewEdgeOperation(aReturn, ARG, zero)));
+ new NewEdgeOperation(aReturn, ARG, zero));

UnitTest unitTest = new UnitTest("Should say hello");
sayHello.addUnitTest(unitTest);

==============================================================================
Revision: 9a3b3c9698
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 06:44:04 2010
Log: Remaining examples now dump correctly. The vertices are assigned by
the system, but the api user creates the object graph. Right now, the
VertexCreatingVisitor does this job, but only when the NewProjectOperation
is executed, so other edges must only be added after that operation has run
against the complete model. I think I'd like to use a Hibernate-like
attached-object pattern here, where the project is attached to the
controller and subsequent methods are dispatched through a proxy who can
record the dirty states and deltas. Too complicated for now...
http://code.google.com/p/noop/source/detail?r=9a3b3c9698

Modified:
/core/src/main/java/noop/graph/DotGraphPrintingVisitor.java
/core/src/main/java/noop/graph/Edge.java
/core/src/main/java/noop/graph/OutlinePrintingVisitor.java
/core/src/test/java/noop/graph/ArithmeticExample.java
/core/src/test/java/noop/graph/ControlFlowExample.java
/core/src/test/java/noop/graph/ControllerTest.java
/core/src/test/java/noop/graph/HelloWorldExample.java

=======================================
--- /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
01:04:21 2010
+++ /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
06:44:04 2010
@@ -16,7 +16,6 @@

package noop.graph;

-import noop.graph.Edge.EdgeType;
import noop.model.*;

import java.io.PrintStream;
@@ -40,7 +39,7 @@
out.format("digraph workspace\n{\n");
out.format("workspace
[label=\"%s\" %s]\n", "Workspace", "shape=house");
for (Project project : workspace.getProjects()) {
- out.format("workspace -> %s\n", project.vertex.hashCode());
+ out.format("workspace -> %s\n", identityHashCode(project));
}
}

@@ -54,17 +53,21 @@
out.format("%s -> %s ", edge.src.hashCode(), edge.dest.hashCode());
out.println("[label=\"" + edge.type.name().toLowerCase() + "\",
style=dashed]");
}
- if (getParent().vertex != element.vertex) {
+ if (getParent().vertex != Vertex.NONE) {
out.format("%s -> %s\n", getParent().vertex.hashCode(),
element.vertex.hashCode());
}
}

@Override
public void visit(Project project) {
- print(project, String.format("%s -> %s", project.getNamespace(),
project.getName()), "shape=box");
+ out.format("%s [label=\"%s\"%s]\n", identityHashCode(project),
+ String.format("%s -> %s", project.getNamespace(),
project.getName()), "shape=box");
+ for (Library library : project.getLibraries()) {
+ out.format("%s -> %s\n", identityHashCode(project),
library.vertex.hashCode());
+ }
out.format("%s [label=\"%s\", shape=none]\n",
identityHashCode(project.getCopyright()),
escape(project.getCopyright()));
- out.format("%s -> %s\n", project.vertex.hashCode(),
identityHashCode(project.getCopyright()));
+ out.format("%s -> %s\n", identityHashCode(project),
identityHashCode(project.getCopyright()));
}

@Override
@@ -96,7 +99,16 @@
@Override
public void visit(IdentifierDeclaration identifierDeclaration) {
print(identifierDeclaration, identifierDeclaration.name);
-
+ }
+
+ @Override
+ public void visit(Loop loop) {
+ print(loop, loop.toString());
+ }
+
+ @Override
+ public void visit(AnonymousBlock block) {
+ print(block, "{}");
}

@Override
@@ -151,11 +163,4 @@
out.println("}");
}
}
-
- @Override
- public void visit(Edge edge) {
- if (edge.type == EdgeType.CONTAIN) {
- out.format("%d -> %d\n", edge.src, edge.dest);
- }
- }
-}
+}
=======================================
--- /core/src/main/java/noop/graph/Edge.java Fri Apr 23 06:41:28 2010
+++ /core/src/main/java/noop/graph/Edge.java Sun Apr 25 06:44:04 2010
@@ -16,7 +16,6 @@

package noop.graph;

-import com.google.common.base.Predicate;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

@@ -33,19 +32,9 @@
public void accept(ModelVisitor v) {
v.visit(this);
}
-
- public static Predicate<? super Edge> notContain() {
- return new Predicate<Edge>() {
- @Override
- public boolean apply(Edge input) {
- return input.type != EdgeType.CONTAIN;
- }
- };
- }

public enum EdgeType {
INVOKE,
- CONTAIN,
IMPLEMENT,
TYPEOF,
TARGET,
=======================================
--- /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
01:04:21 2010
+++ /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
06:44:04 2010
@@ -6,9 +6,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;

-import static com.google.common.collect.Iterables.filter;
-import static noop.graph.Edge.notContain;
-
/**
* @author alex...@google.com (Alex Eagle)
*/
@@ -115,7 +112,7 @@

private void print(LanguageElement element, String message, String...
params) {
out.format("%s%s [#%s]", indent(), String.format(message, params),
element.vertex);
- for (Edge edge : filter(workspace.edgesFrom(element.vertex),
notContain())) {
+ for (Edge edge : workspace.edgesFrom(element.vertex)) {
out.format(" %s -> #%s", edge.type.name(), edge.dest);
}
out.println();
=======================================
--- /core/src/test/java/noop/graph/ArithmeticExample.java Sun Apr 25
01:29:41 2010
+++ /core/src/test/java/noop/graph/ArithmeticExample.java Sun Apr 25
06:44:04 2010
@@ -21,7 +21,6 @@
@Override
public void createProgram(Controller controller) {
Project project = new Project("Arithmetic", "com.example", "Copyright
2010\nExample Co.");
- controller.apply(new NewProjectOperation(project));

Library library = new Library(UUID.randomUUID(), "adding stuff");
project.addLibrary(library);
@@ -30,9 +29,6 @@
library.addFunction(entryPoint);
Parameter consoleDep = new Parameter("console");
entryPoint.addParameter(consoleDep);
- controller.apply(
- new NewEdgeOperation(entryPoint, TYPEOF, stdLib.intClazz),
- new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz));

IdentifierDeclaration i = new IdentifierDeclaration("i");
entryPoint.addStatement(i);
@@ -45,29 +41,35 @@

IntegerLiteral two = new IntegerLiteral(2);
entryPoint.addStatement(two);
+ j.setInitialValue(two);

IdentifierDeclaration k = new IdentifierDeclaration("k");
entryPoint.addStatement(k);

Expression sum = new MethodInvocation();
- controller.apply(
- new NewEdgeOperation(sum, INVOKE, stdLib.integerPlus),
- new NewEdgeOperation(sum, TARGET, i),
- new NewEdgeOperation(sum, ARG, j));
k.setInitialValue(sum);

Expression printResult = new MethodInvocation();
entryPoint.addStatement(printResult);
- controller.apply(
- new NewEdgeOperation(printResult, INVOKE, stdLib.printMethod),
- new NewEdgeOperation(printResult, TARGET, consoleDep),
- new NewEdgeOperation(printResult, ARG, k));

IntegerLiteral zero = new IntegerLiteral(0);
entryPoint.addStatement(zero);

Expression returnVal = new Return();
entryPoint.addStatement(returnVal);
+
+ controller.apply(new NewProjectOperation(project));
+ controller.apply(
+ new NewEdgeOperation(entryPoint, TYPEOF, stdLib.intClazz),
+ new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz));
+ controller.apply(
+ new NewEdgeOperation(sum, INVOKE, stdLib.integerPlus),
+ new NewEdgeOperation(sum, TARGET, i),
+ new NewEdgeOperation(sum, ARG, j));
+ controller.apply(
+ new NewEdgeOperation(printResult, INVOKE, stdLib.printMethod),
+ new NewEdgeOperation(printResult, TARGET, consoleDep),
+ new NewEdgeOperation(printResult, ARG, k));
controller.apply(new NewEdgeOperation(returnVal, ARG, zero));
}
}
=======================================
--- /core/src/test/java/noop/graph/ControlFlowExample.java Sun Apr 25
01:29:41 2010
+++ /core/src/test/java/noop/graph/ControlFlowExample.java Sun Apr 25
06:44:04 2010
@@ -20,7 +20,6 @@
@Override
public void createProgram(Controller controller) {
Project project = new Project("Control
Flow", "com.example", "Copyright 2010\nExample Co.");
- controller.apply(new NewProjectOperation(project));

Library library = new Library(UUID.randomUUID(), "Testing loops");
project.addLibrary(library);
@@ -36,7 +35,6 @@

IdentifierDeclaration i = new IdentifierDeclaration("count");
method.addStatement(i);
- controller.apply(new NewEdgeOperation(i, TYPEOF, stdLib.intClazz));

i.setInitialValue(new IntegerLiteral(0));

@@ -48,16 +46,19 @@

Expression terminateWhen = new MethodInvocation();
loop.setTerminationCondition(terminateWhen);
- controller.apply(
- new NewEdgeOperation(terminateWhen, TARGET, i),
- new NewEdgeOperation(terminateWhen, INVOKE, stdLib.integerEquals),
- new NewEdgeOperation(terminateWhen, ARG, ten));

Block body = new AnonymousBlock();
loop.setBody(body);

Expression printValue = new MethodInvocation();
body.addStatement(printValue);
+
+ controller.apply(new NewProjectOperation(project));
+ controller.apply(new NewEdgeOperation(i, TYPEOF, stdLib.intClazz));
+ controller.apply(
+ new NewEdgeOperation(terminateWhen, TARGET, i),
+ new NewEdgeOperation(terminateWhen, INVOKE, stdLib.integerEquals),
+ new NewEdgeOperation(terminateWhen, ARG, ten));
controller.apply(
new NewEdgeOperation(printValue, TARGET, consoleDep),
new NewEdgeOperation(printValue, INVOKE, stdLib.printMethod),
=======================================
--- /core/src/test/java/noop/graph/ControllerTest.java Fri Apr 23 06:41:28
2010
+++ /core/src/test/java/noop/graph/ControllerTest.java Sun Apr 25 06:44:04
2010
@@ -20,10 +20,10 @@
import noop.operations.EditNodeOperation;
import noop.operations.NewEdgeOperation;
import noop.operations.NewNodeOperation;
+import noop.operations.NewProjectOperation;
import org.junit.Before;
import org.junit.Test;

-import static noop.graph.Edge.EdgeType.CONTAIN;
import static noop.graph.Edge.EdgeType.TYPEOF;
import static org.junit.Assert.*;

@@ -41,11 +41,9 @@
}

@Test public void shouldMakeNewProject() {
- LanguageElement newNode = new Project("helloWorld", "com.google", "");
- controller.apply(new NewNodeOperation(newNode, workspace));
- assertTrue(workspace.elements.contains(newNode));
- assertEquals(1, workspace.edges.size());
- assertEquals(new Edge(new Vertex(null, 0), CONTAIN, new Vertex(null,
1)), workspace.edges.iterator().next());
+ Project project = new Project("helloWorld", "com.google", "");
+ controller.apply(new NewProjectOperation(project));
+ assertTrue(workspace.getProjects().contains(project));
}

@Test public void shouldCreateAdditionalEdges() {
@@ -56,8 +54,6 @@
controller.apply(new NewNodeOperation(newNode, workspace));
controller.apply(new NewEdgeOperation(newNode, TYPEOF, stringType));
assertEquals(3, workspace.edges.size());
- assertTrue(workspace.edges.contains(new Edge(new Vertex(null, 0),
CONTAIN, new Vertex(null, 1))));
- assertTrue(workspace.edges.contains(new Edge(new Vertex(null, 0),
CONTAIN, new Vertex(null, 2))));
assertTrue(workspace.edges.contains(new Edge(new Vertex(null, 2),
TYPEOF, new Vertex(null, 1))));
}

=======================================
--- /core/src/test/java/noop/graph/HelloWorldExample.java Sun Apr 25
01:29:41 2010
+++ /core/src/test/java/noop/graph/HelloWorldExample.java Sun Apr 25
06:44:04 2010
@@ -20,7 +20,6 @@
@Override
public void createProgram(Controller controller) {
Project project = new Project("Hello World", "com.example", "Copyright
2010\nExample Co.");
- controller.apply(new NewProjectOperation(project));

Library library = new Library(UUID.randomUUID(), "hello");
project.addLibrary(library);
@@ -31,46 +30,48 @@
Parameter consoleDep = new Parameter("console");
sayHello.addParameter(consoleDep);

- controller.apply(
- new NewEdgeOperation(sayHello, TYPEOF, stdLib.intClazz),
- new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz));

sayHello.setDocumentation(new Documentation("This is the entry point
for the Hello World app",
"alex...@google.com (Alex Eagle)"));

StringLiteral helloWorld = new StringLiteral("Hello, World!");
sayHello.addStatement(helloWorld);
- controller.apply(new NewEdgeOperation(helloWorld, TYPEOF,
stdLib.stringClazz));

Expression printHello = new MethodInvocation();
sayHello.addStatement(printHello);
- controller.apply(
- new NewEdgeOperation(printHello, TARGET, consoleDep),
- new NewEdgeOperation(printHello, INVOKE, stdLib.printMethod),
- new NewEdgeOperation(printHello, ARG, helloWorld));

IntegerLiteral zero = new IntegerLiteral(0);
sayHello.addStatement(zero);

Return aReturn = new Return();
sayHello.addStatement(aReturn);
- controller.apply(
- new NewEdgeOperation(zero, TYPEOF, stdLib.intClazz),
- new NewEdgeOperation(aReturn, ARG, zero));

UnitTest unitTest = new UnitTest("Should say hello");
sayHello.addUnitTest(unitTest);

IdentifierDeclaration resultDecl = new IdentifierDeclaration("result");
unitTest.addStatement(resultDecl);
- controller.apply(new NewEdgeOperation(resultDecl, TYPEOF,
stdLib.intClazz));

Expression callMain = new MethodInvocation();
unitTest.addStatement(callMain);
- controller.apply(new NewEdgeOperation(callMain, INVOKE, sayHello));

Expression assertion = new MethodInvocation();
unitTest.addStatement(assertion);
// TODO: fill in assertion
+
+ controller.apply(new NewProjectOperation(project));
+ controller.apply(
+ new NewEdgeOperation(sayHello, TYPEOF, stdLib.intClazz),
+ new NewEdgeOperation(consoleDep, TYPEOF, stdLib.consoleClazz));
+ controller.apply(new NewEdgeOperation(helloWorld, TYPEOF,
stdLib.stringClazz));
+ controller.apply(
+ new NewEdgeOperation(printHello, TARGET, consoleDep),
+ new NewEdgeOperation(printHello, INVOKE, stdLib.printMethod),
+ new NewEdgeOperation(printHello, ARG, helloWorld));
+ controller.apply(
+ new NewEdgeOperation(zero, TYPEOF, stdLib.intClazz),
+ new NewEdgeOperation(aReturn, ARG, zero));
+ controller.apply(new NewEdgeOperation(resultDecl, TYPEOF,
stdLib.intClazz));
+ controller.apply(new NewEdgeOperation(callMain, INVOKE, sayHello));
}
}

==============================================================================
Revision: 1dca46d9c7
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 07:46:55 2010
Log: Pull up common code between the printing visitors, and remove last
remnants of graph from workspace. The graph will be contained in the
Library so we can serialize each Library independently.
http://code.google.com/p/noop/source/detail?r=1dca46d9c7

Deleted:
/core/src/main/java/noop/operations/NewNodeOperation.java
Modified:
/core/src/main/java/noop/graph/Controller.java
/core/src/main/java/noop/graph/DotGraphPrintingVisitor.java
/core/src/main/java/noop/graph/OutlinePrintingVisitor.java
/core/src/main/java/noop/graph/PrintingVisitor.java
/core/src/main/java/noop/graph/Vertex.java
/core/src/main/java/noop/graph/Workspace.java
/core/src/main/java/noop/model/Library.java
/core/src/main/java/noop/operations/EditNodeOperation.java
/core/src/test/java/noop/graph/ControllerTest.java
/core/src/test/java/noop/graph/PrintingVisitorTest.java

=======================================
--- /core/src/main/java/noop/operations/NewNodeOperation.java Fri Apr 23
04:40:41 2010
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package noop.operations;
-
-import noop.graph.Controller;
-import noop.model.LanguageElement;
-
-/**
- * @author alex...@google.com (Alex Eagle)
- */
-public class NewNodeOperation implements MutationOperation {
- public final LanguageElement newElement;
- public final LanguageElement container;
-
- /**
- * Create a new node with the given parent
- * @param newElement any language element
- * @param container the containing element
- */
- public NewNodeOperation(LanguageElement newElement, LanguageElement
container) {
- this.newElement = newElement;
- this.container = container;
- }
-
- @Override
- public void execute(Controller controller) {
- controller.addNode(this);
- }
-}
=======================================
--- /core/src/main/java/noop/graph/Controller.java Sun Apr 25 01:29:41 2010
+++ /core/src/main/java/noop/graph/Controller.java Sun Apr 25 07:46:55 2010
@@ -17,7 +17,11 @@
package noop.graph;

import noop.model.LanguageElement;
-import noop.operations.*;
+import noop.model.Library;
+import noop.operations.EditNodeOperation;
+import noop.operations.MutationOperation;
+import noop.operations.NewEdgeOperation;
+import noop.operations.NewProjectOperation;

/**
* @author alex...@google.com (Alex Eagle)
@@ -30,28 +34,15 @@
this.workspace = workspace;
this.addVertices = addVertices;
}
-
- public void addNode(NewNodeOperation operation) {
- int nextNodeId = workspace.elements.size();
- LanguageElement container = operation.container == null ? workspace :
operation.container;
-
- int destId = workspace.elements.indexOf(container);
- if (destId < 0) {
- throw new IllegalStateException(String.format("Cannot add edge [%s
-> %s] due to non-existant dest %s",
- nextNodeId, destId, container));
- }
- workspace.elements.add(operation.newElement);
- }

public void editNode(EditNodeOperation operation) {
- LanguageElement currentValue = workspace.elements.get(operation.id);
+ Library library = workspace.lookupLibrary(operation.vertex.libraryUid);
+ LanguageElement currentValue =
library.getElements().get(operation.vertex.index);
if (currentValue.getClass() != operation.newValue.getClass()) {
- throw new IllegalArgumentException(String.format("Cannot edit
node %d with %s because the current type is %s",
- operation.id, operation.newValue, currentValue.getClass()));
- }
-
- operation.newValue.setPreviousVersion(currentValue);
- workspace.elements.set(operation.id, operation.newValue);
+ throw new IllegalArgumentException(String.format("Cannot edit
node %s with %s because the current type is %s",
+ operation.vertex, operation.newValue, currentValue.getClass()));
+ }
+ library.replace(operation.vertex.index, operation.newValue);
}

public void addEdge(NewEdgeOperation operation) {
@@ -61,7 +52,8 @@
if (operation.dest.vertex == Vertex.NONE) {
throw new IllegalArgumentException("dest element has no vertex");
}
- workspace.edges.add(new Edge(operation.src.vertex, operation.type,
operation.dest.vertex));
+ Library srcLibrary =
workspace.lookupLibrary(operation.src.vertex.libraryUid);
+ srcLibrary.addEdge(new Edge(operation.src.vertex, operation.type,
operation.dest.vertex));
}

public void addProject(NewProjectOperation operation) {
=======================================
--- /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
06:44:04 2010
+++ /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
07:46:55 2010
@@ -20,7 +20,6 @@

import java.io.PrintStream;

-import static com.google.common.base.Join.join;
import static java.lang.System.identityHashCode;

/**
@@ -43,13 +42,17 @@
}
}

- private void print(LanguageElement element, String label, String...
additional) {
- String attrs = join(",", additional);
- if (additional.length > 0) {
- attrs = ", " + attrs;
- }
- out.format("%s [label=\"%s\"%s]\n", element.vertex.hashCode(), label,
attrs);
- for (Edge edge : workspace.edgesFrom(element.vertex)) {
+ public void print(LanguageElement element, String label, String...
params) {
+ print(element, label, null, params);
+ }
+
+ public void print(LanguageElement element, String label, String
additional, String... params) {
+ if (additional != null) {
+ additional = ", " + additional;
+ }
+ out.format("%s [label=\"%s\"%s]\n", element.vertex.hashCode(),
String.format(label, params), additional);
+ Library library = workspace.lookupLibrary(element.vertex.libraryUid);
+ for (Edge edge : library.edgesFrom(element.vertex)) {
out.format("%s -> %s ", edge.src.hashCode(), edge.dest.hashCode());
out.println("[label=\"" + edge.type.name().toLowerCase() + "\",
style=dashed]");
}
@@ -69,67 +72,11 @@
escape(project.getCopyright()));
out.format("%s -> %s\n", identityHashCode(project),
identityHashCode(project.getCopyright()));
}
-
- @Override
- public void visit(Library library) {
- print(library, library.name, "shape=hexagon");
-
- }
-
- @Override
- public void visit(Method method) {
- print(method, method.name + "{}");
- }
-
- @Override
- public void visit(Function function) {
- print(function, function.name + "{}");
- }
-
- @Override
- public void visit(UnitTest unitTest) {
- print(unitTest, "test: " + unitTest.name);
- }
-
- @Override
- public void visit(Assignment assignment) {
- print(assignment, "assign");
- }

@Override
public void visit(IdentifierDeclaration identifierDeclaration) {
print(identifierDeclaration, identifierDeclaration.name);
}
-
- @Override
- public void visit(Loop loop) {
- print(loop, loop.toString());
- }
-
- @Override
- public void visit(AnonymousBlock block) {
- print(block, "{}");
- }
-
- @Override
- public void visit(Return aReturn) {
- print(aReturn, "[return]");
- }
-
- @Override
- public void visit(IntegerLiteral integerLiteral) {
- print(integerLiteral, String.valueOf(integerLiteral.value));
- }
-
- @Override
- public void visit(Parameter parameter) {
- print(parameter, parameter.name);
- }
-
- @Override
- public void visit(MethodInvocation methodInvocation) {
- print(methodInvocation, "[invoke]");
- }

@Override
public void visit(Documentation documentation) {
@@ -145,16 +92,6 @@
}
return escaped;
}
-
- @Override
- public void visit(StringLiteral stringLiteral) {
- print(stringLiteral, "\\\"" + stringLiteral.value + "\\\"");
- }
-
- @Override
- public void visit(Clazz clazz) {
- print(clazz, clazz.name);
- }

@Override
public void leave(LanguageElement element) {
=======================================
--- /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
06:44:04 2010
+++ /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
07:46:55 2010
@@ -28,41 +28,6 @@
print(project, "Project \"%s\"->\"%s\" (copyright: \"%s\")",
project.getNamespace(), project.getName(),
escape(project.getCopyright()));
}
-
- @Override
- public void visit(Library library) {
- print(library, "Library \"%s\"", library.name);
- }
-
- @Override
- public void visit(Clazz clazz) {
- print(clazz, "Class \"%s\"", clazz.name);
- }
-
- @Override
- public void visit(Method method) {
- print(method, "Method %s{}", method.name);
- }
-
- @Override
- public void visit(Function function) {
- print(function, "Function %s{}", function.name);
- }
-
- @Override
- public void visit(UnitTest unitTest) {
- print(unitTest, "Unit test %s", unitTest.name);
- }
-
- @Override
- public void visit(MethodInvocation methodInvocation) {
- print(methodInvocation, "invocation");
- }
-
- @Override
- public void visit(Parameter parameter) {
- print(parameter, "parameter %s", parameter.name);
- }

@Override
public void visit(Documentation documentation) {
@@ -74,46 +39,19 @@
public void visit(IdentifierDeclaration identifierDeclaration) {
print(identifierDeclaration, "Declare %s", identifierDeclaration.name);
}
-
- @Override
- public void visit(Loop loop) {
- print(loop, "Loop until");
- }
-
- @Override
- public void visit(AnonymousBlock block) {
- print(block, "{}");
- }
-
- @Override
- public void visit(Assignment assignment) {
- print(assignment, "Assign");
- }
-
- @Override
- public void visit(IntegerLiteral integerLiteral) {
- print(integerLiteral, "literal %s",
String.valueOf(integerLiteral.value));
- }
-
- @Override
- public void visit(StringLiteral stringLiteral) {
- print(stringLiteral, "literal \"%s\"", stringLiteral.value);
- }
-
- @Override
- public void visit(Return aReturn) {
- print(aReturn, "return");
- }

@Override
public void visit(Comment comment) {
print(comment, "// %s --%s %s", comment.text, comment.user,
comment.timestamp.toString());
}

- private void print(LanguageElement element, String message, String...
params) {
+ public void print(LanguageElement element, String message, String...
params) {
out.format("%s%s [#%s]", indent(), String.format(message, params),
element.vertex);
- for (Edge edge : workspace.edgesFrom(element.vertex)) {
- out.format(" %s -> #%s", edge.type.name(), edge.dest);
+ if (element.vertex != Vertex.NONE) {
+ Library library = workspace.lookupLibrary(element.vertex.libraryUid);
+ for (Edge edge : library.edgesFrom(element.vertex)) {
+ out.format(" %s -> #%s", edge.type.name(), edge.dest);
+ }
}
out.println();
}
=======================================
--- /core/src/main/java/noop/graph/PrintingVisitor.java Sun Apr 25 01:04:21
2010
+++ /core/src/main/java/noop/graph/PrintingVisitor.java Sun Apr 25 07:46:55
2010
@@ -1,13 +1,13 @@
package noop.graph;

-import noop.model.LanguageElement;
+import noop.model.*;

import java.util.Stack;

/**
* @author alex...@google.com (Alex Eagle)
*/
-public class PrintingVisitor extends ModelVisitor {
+public abstract class PrintingVisitor extends ModelVisitor {
protected Workspace workspace;
protected int currentDepth;
protected Stack<LanguageElement> parents = new Stack<LanguageElement>();
@@ -34,4 +34,73 @@
protected String escape(String value) {
return value.replaceAll("\n", "\\\\n");
}
-}
+
+ public abstract void print(LanguageElement element, String label,
String... params);
+
+ @Override
+ public void visit(Library library) {
+ print(library, "Library \"%s\"", library.name);
+ }
+
+ @Override
+ public void visit(Clazz clazz) {
+ print(clazz, "Class \"%s\"", clazz.name);
+ }
+
+ @Override
+ public void visit(Method method) {
+ print(method, "Method %s{}", method.name);
+ }
+
+ @Override
+ public void visit(Function function) {
+ print(function, "Function %s{}", function.name);
+ }
+
+ @Override
+ public void visit(UnitTest unitTest) {
+ print(unitTest, "Unit test %s", unitTest.name);
+ }
+
+ @Override
+ public void visit(MethodInvocation methodInvocation) {
+ print(methodInvocation, "invocation");
+ }
+
+ @Override
+ public void visit(Parameter parameter) {
+ print(parameter, "parameter %s", parameter.name);
+ }
+
+ @Override
+ public void visit(AnonymousBlock block) {
+ print(block, "{}");
+ }
+
+ @Override
+ public void visit(Return aReturn) {
+ print(aReturn, "[return]");
+ }
+
+ @Override
+ public void visit(IntegerLiteral integerLiteral) {
+ print(integerLiteral, "literal %s",
String.valueOf(integerLiteral.value));
+ }
+
+ @Override
+ public void visit(Loop loop) {
+ print(loop, "Loop until");
+ }
+
+ @Override
+ public void visit(Assignment assignment) {
+ print(assignment, "Assign");
+ }
+
+ @Override
+ public void visit(StringLiteral stringLiteral) {
+ print(stringLiteral, "literal \\\"%s\\\"", stringLiteral.value);
+ }
+
+
+}
=======================================
--- /core/src/main/java/noop/graph/Vertex.java Fri Apr 23 06:41:28 2010
+++ /core/src/main/java/noop/graph/Vertex.java Sun Apr 25 07:46:55 2010
@@ -46,6 +46,6 @@
if (this == NONE) {
return "NO_VERTEX";
}
- return index + "(" + libraryUid.toString() + ")";
+ return index + "(" + libraryUid.toString().substring(0,
libraryUid.toString().indexOf("-")) + ")";
}
}
=======================================
--- /core/src/main/java/noop/graph/Workspace.java Sun Apr 25 01:04:21 2010
+++ /core/src/main/java/noop/graph/Workspace.java Sun Apr 25 07:46:55 2010
@@ -16,24 +16,19 @@

package noop.graph;

-import com.google.common.base.Nullable;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import noop.model.LanguageElement;
+import noop.model.Library;
import noop.model.Project;

import java.util.List;
-import java.util.Set;
+import java.util.UUID;

/**
* @author alex...@google.com (Alex Eagle)
*/
public class Workspace extends LanguageElement<Workspace> {
- public final Set<Edge> edges = Sets.newHashSet();
- public final List<LanguageElement> elements =
Lists.<LanguageElement>newArrayList(this);
private List<Project> projects = Lists.newArrayList();

public void addProject(Project project) {
@@ -49,22 +44,21 @@
project.accept(v);
v.leave(project);
}
- for (Edge edge : edges) {
- edge.accept(v);
- }
v.leave(this);
}
-
- public Iterable<Edge> edgesFrom(final Vertex src) {
- return Iterables.filter(edges, new Predicate<Edge>() {
- @Override
- public boolean apply(@Nullable Edge input) {
- return input.src == src;
- }
- });
- }

public List<Project> getProjects() {
return ImmutableList.copyOf(projects);
}
-}
+
+ public Library lookupLibrary(UUID libraryUid) {
+ for (Project project : projects) {
+ for (Library library : project.getLibraries()) {
+ if (library.uid.equals(libraryUid)) {
+ return library;
+ }
+ }
+ }
+ return null;
+ }
+}
=======================================
--- /core/src/main/java/noop/model/Library.java Sun Apr 25 01:04:21 2010
+++ /core/src/main/java/noop/model/Library.java Sun Apr 25 07:46:55 2010
@@ -16,9 +16,14 @@

package noop.model;

+import com.google.common.base.Nullable;
+import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
+import noop.graph.Edge;
import noop.graph.ModelVisitor;
+import noop.graph.Vertex;

import java.util.List;
import java.util.UUID;
@@ -29,6 +34,7 @@
public class Library extends LanguageElement<Library> {
public final UUID uid;
public final String name;
+ private final List<Edge> edges = Lists.newArrayList();
private final List<LanguageElement> elements = Lists.newArrayList();
private final List<Clazz> classes = Lists.newArrayList();
private final List<Block> functions = Lists.newArrayList();
@@ -61,6 +67,16 @@
}
super.accept(v);
}
+
+
+ public Iterable<Edge> edgesFrom(final Vertex src) {
+ return Iterables.filter(edges, new Predicate<Edge>() {
+ @Override
+ public boolean apply(@Nullable Edge input) {
+ return input.src == src;
+ }
+ });
+ }

public List<LanguageElement> getElements() {
return ImmutableList.copyOf(elements);
@@ -70,4 +86,13 @@
elements.add(languageElement);
return elements.size() - 1;
}
-}
+
+ public <T extends LanguageElement> void replace(int index,
LanguageElement<T> newValue) {
+ elements.get(index).setPreviousVersion(newValue);
+ elements.set(index, newValue);
+ }
+
+ public void addEdge(Edge edge) {
+ edges.add(edge);
+ }
+}
=======================================
--- /core/src/main/java/noop/operations/EditNodeOperation.java Fri Apr 23
04:40:41 2010
+++ /core/src/main/java/noop/operations/EditNodeOperation.java Sun Apr 25
07:46:55 2010
@@ -17,6 +17,7 @@
package noop.operations;

import noop.graph.Controller;
+import noop.graph.Vertex;
import noop.model.LanguageElement;

import java.io.Serializable;
@@ -25,11 +26,11 @@
* @author alex...@google.com (Alex Eagle)
*/
public class EditNodeOperation implements MutationOperation, Serializable {
- public final int id;
+ public final Vertex vertex;
public final LanguageElement newValue;

- public EditNodeOperation(int id, LanguageElement newValue) {
- this.id = id;
+ public EditNodeOperation(Vertex vertex, LanguageElement newValue) {
+ this.vertex = vertex;
this.newValue = newValue;
}

=======================================
--- /core/src/test/java/noop/graph/ControllerTest.java Sun Apr 25 06:44:04
2010
+++ /core/src/test/java/noop/graph/ControllerTest.java Sun Apr 25 07:46:55
2010
@@ -18,14 +18,14 @@

import noop.model.*;
import noop.operations.EditNodeOperation;
-import noop.operations.NewEdgeOperation;
-import noop.operations.NewNodeOperation;
import noop.operations.NewProjectOperation;
import org.junit.Before;
import org.junit.Test;

-import static noop.graph.Edge.EdgeType.TYPEOF;
-import static org.junit.Assert.*;
+import java.util.UUID;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;

/**
* @author alex...@google.com (Alex Eagle)
@@ -33,9 +33,11 @@
public class ControllerTest {
private Controller controller;
private Workspace workspace;
+ private Project p;

@Before
public void setUp() {
+ p = new Project("p", "ns", "copyright");
workspace = new Workspace();
controller = new Controller(workspace, new VertexCreatingVisitor());
}
@@ -46,36 +48,34 @@
assertTrue(workspace.getProjects().contains(project));
}

- @Test public void shouldCreateAdditionalEdges() {
- LanguageElement stringType = new Clazz("String");
- controller.apply(new NewNodeOperation(stringType, workspace));
-
- LanguageElement newNode = new StringLiteral("yes");
- controller.apply(new NewNodeOperation(newNode, workspace));
- controller.apply(new NewEdgeOperation(newNode, TYPEOF, stringType));
- assertEquals(3, workspace.edges.size());
- assertTrue(workspace.edges.contains(new Edge(new Vertex(null, 2),
TYPEOF, new Vertex(null, 1))));
- }
-
- @Test public void shouldAllowEditingAStringLiteral() {
- StringLiteral aString = new StringLiteral("hello");
- controller.apply(new NewNodeOperation(aString, workspace));
-
- controller.apply(new EditNodeOperation(1, new
StringLiteral("goodbye")));
- assertEquals(2, workspace.elements.size());
- assertEquals("goodbye", ((StringLiteral)
workspace.elements.get(1)).value);
- assertEquals("hello", ((StringLiteral)
workspace.elements.get(1).getPreviousVersion()).value);
+ @Test public void shouldAllowAddingAMethodToAClazz() {
+ Library l = new Library(UUID.randomUUID(), "l");
+ p.addLibrary(l);
+ Clazz c = new Clazz("c");
+ l.addClazz(c);
+ Method m = new Method("m");
+ c.addBlock(m);
+ controller.apply(new NewProjectOperation(p));
+
+ Clazz c2 = new Clazz("c2");
+ Method m2 = new Method("m2");
+ c2.addBlock(m);
+ c2.addBlock(m2);
+
+ controller.apply(new EditNodeOperation(c.vertex, c2));
}

@Test public void shouldErrorWhenEditingWithWrongType() {
- IntegerLiteral anInt = new IntegerLiteral(12);
- controller.apply(new NewNodeOperation(anInt, workspace));
+ Library l = new Library(UUID.randomUUID(), "l");
+ p.addLibrary(l);
+ Clazz c = new Clazz("c");
+ l.addClazz(c);

try {
- controller.apply(new EditNodeOperation(1, new StringLiteral("String
is not Int")));
+ controller.apply(new EditNodeOperation(c.vertex, new
StringLiteral("String is not Clazz")));
fail("should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
- assertTrue(e.getMessage(),
e.getMessage().contains("IntegerLiteral"));
+ assertTrue(e.getMessage(), e.getMessage().contains("Clazz"));
}
}
}
=======================================
--- /core/src/test/java/noop/graph/PrintingVisitorTest.java Sun Apr 25
01:04:21 2010
+++ /core/src/test/java/noop/graph/PrintingVisitorTest.java Sun Apr 25
07:46:55 2010
@@ -26,6 +26,9 @@
l2.addClazz(c2);

final PrintingVisitor visitor = new PrintingVisitor() {
+ @Override
+ public void print(LanguageElement element, String label, String...
params) {}
+
@Override
public void visit(Clazz clazz) {
if (clazz == c1) {

==============================================================================
Revision: 65f63dc4b8
Author: Alex Eagle <alex...@google.com>
Date: Sun Apr 25 08:41:54 2010
Log: Serialize each library to a separate XML file.
http://code.google.com/p/noop/source/detail?r=65f63dc4b8

Added:
/core/src/test/java/noop/graph/ArithmeticExampleTest.java
/core/src/test/java/noop/graph/ControlFlowExampleTest.java
/core/src/test/java/noop/graph/HelloWorldExampleTest.java
/core/src/test/java/noop/graph/ModelSerializer.java
Deleted:
/core/src/test/java/noop/graph/DumpExamplesTest.java
/core/src/test/java/noop/graph/WorkspaceDumper.java
Modified:
/core/src/main/java/noop/graph/DotGraphPrintingVisitor.java
/core/src/main/java/noop/graph/OutlinePrintingVisitor.java
/core/src/main/java/noop/graph/PrintingVisitor.java
/core/src/test/java/noop/graph/ArithmeticExample.java
/core/src/test/java/noop/graph/ControlFlowExample.java
/core/src/test/java/noop/graph/DumpExamplesMain.java
/core/src/test/java/noop/graph/HelloWorldExample.java

=======================================
--- /dev/null
+++ /core/src/test/java/noop/graph/ArithmeticExampleTest.java Sun Apr 25
08:41:54 2010
@@ -0,0 +1,39 @@
+package noop.graph;
+
+import noop.graph.ModelSerializer.Output;
+import noop.model.Library;
+import noop.stdlib.StandardLibraryBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author alex...@google.com (Alex Eagle)
+ */
+public class ArithmeticExampleTest {
+ Workspace workspace;
+ StandardLibraryBuilder stdLib;
+ Controller controller;
+ private ArithmeticExample arithmeticExample;
+ private Library library;
+
+ @Before
+ public void setUp() {
+ workspace = new Workspace();
+ stdLib = new StandardLibraryBuilder();
+ controller = new Controller(workspace, new VertexCreatingVisitor());
+ stdLib.build(controller);
+ arithmeticExample = new ArithmeticExample(stdLib);
+ arithmeticExample.createProgram(controller);
+ library = workspace.lookupLibrary(arithmeticExample.uid);
+ }
+
+ @Test
+ public void shouldCreateArithmeticDot() {
+ new ModelSerializer(Output.DOT, System.out).dump(library);
+ }
+
+ @Test
+ public void shouldCreateArithmeticOutline() {
+ new ModelSerializer(Output.TXT, System.out).dump(library);
+ }
+}
=======================================
--- /dev/null
+++ /core/src/test/java/noop/graph/ControlFlowExampleTest.java Sun Apr 25
08:41:54 2010
@@ -0,0 +1,39 @@
+package noop.graph;
+
+import noop.graph.ModelSerializer.Output;
+import noop.model.Library;
+import noop.stdlib.StandardLibraryBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author alex...@google.com (Alex Eagle)
+ */
+public class ControlFlowExampleTest {
+ Workspace workspace;
+ StandardLibraryBuilder stdLib;
+ Controller controller;
+ private ControlFlowExample controlFlowExample;
+ private Library library;
+
+ @Before
+ public void setUp() {
+ workspace = new Workspace();
+ stdLib = new StandardLibraryBuilder();
+ controller = new Controller(workspace, new VertexCreatingVisitor());
+ stdLib.build(controller);
+ controlFlowExample = new ControlFlowExample(stdLib);
+ controlFlowExample.createProgram(controller);
+ library = workspace.lookupLibrary(controlFlowExample.uid);
+ }
+
+ @Test
+ public void shouldCreateArithmeticDot() {
+ new ModelSerializer(Output.DOT, System.out).dump(library);
+ }
+
+ @Test
+ public void shouldCreateArithmeticOutline() {
+ new ModelSerializer(Output.TXT, System.out).dump(library);
+ }
+}
=======================================
--- /dev/null
+++ /core/src/test/java/noop/graph/HelloWorldExampleTest.java Sun Apr 25
08:41:54 2010
@@ -0,0 +1,39 @@
+package noop.graph;
+
+import noop.graph.ModelSerializer.Output;
+import noop.model.Library;
+import noop.stdlib.StandardLibraryBuilder;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author alex...@google.com (Alex Eagle)
+ */
+public class HelloWorldExampleTest {
+ Workspace workspace;
+ StandardLibraryBuilder stdLib;
+ Controller controller;
+ private HelloWorldExample helloWorldExample;
+ private Library library;
+
+ @Before
+ public void setUp() {
+ workspace = new Workspace();
+ stdLib = new StandardLibraryBuilder();
+ controller = new Controller(workspace, new VertexCreatingVisitor());
+ stdLib.build(controller);
+ helloWorldExample = new HelloWorldExample(stdLib);
+ helloWorldExample.createProgram(controller);
+ library = workspace.lookupLibrary(helloWorldExample.uid);
+ }
+
+ @Test
+ public void shouldCreateArithmeticDot() {
+ new ModelSerializer(Output.DOT, System.out).dump(library);
+ }
+
+ @Test
+ public void shouldCreateArithmeticOutline() {
+ new ModelSerializer(Output.TXT, System.out).dump(library);
+ }
+}
=======================================
--- /dev/null
+++ /core/src/test/java/noop/graph/ModelSerializer.java Sun Apr 25 08:41:54
2010
@@ -0,0 +1,41 @@
+package noop.graph;
+
+import com.thoughtworks.xstream.XStream;
+import noop.model.LanguageElement;
+
+import java.io.PrintStream;
+
+/**
+ * Dumps the content of a workspace in one of a few possible formats.
+ * @author alex...@google.com (Alex Eagle)
+ */
+public class ModelSerializer {
+ private final Output output;
+ private final PrintStream out;
+
+ public ModelSerializer(Output output, PrintStream out) {
+ this.output = output;
+ this.out = out;
+ }
+
+ public enum Output {
+ TXT, XML, DOT
+ }
+
+ public void dump(LanguageElement element) {
+ switch (output) {
+ case DOT:
+ element.accept(new DotGraphPrintingVisitor(out));
+ break;
+ case TXT:
+ element.accept(new OutlinePrintingVisitor(out));
+ break;
+ case XML:
+ XStream xStream = new XStream();
+ out.append(xStream.toXML(element));
+ break;
+ default:
+ throw new RuntimeException("unknown output type " + output);
+ }
+ }
+}
=======================================
--- /core/src/test/java/noop/graph/DumpExamplesTest.java Fri Apr 23
06:41:28 2010
+++ /dev/null
@@ -1,60 +0,0 @@
-package noop.graph;
-
-import noop.graph.WorkspaceDumper.Output;
-import noop.stdlib.StandardLibraryBuilder;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author alex...@google.com (Alex Eagle)
- */
-public class DumpExamplesTest {
-
- Workspace workspace;
- StandardLibraryBuilder stdLib;
- Controller controller;
-
- @Before
- public void setUp() {
- workspace = new Workspace();
- stdLib = new StandardLibraryBuilder();
- controller = new Controller(workspace, new VertexCreatingVisitor());
- stdLib.build(controller);
- }
-
- @Test
- public void shouldCreateArithmeticDot() {
- new ArithmeticExample(stdLib).createProgram(controller);
- new WorkspaceDumper(Output.DOT, System.out).dump(workspace);
- }
-
- @Test
- public void shouldCreateArithmeticOutline() {
- new ArithmeticExample(stdLib).createProgram(controller);
- new WorkspaceDumper(Output.TXT, System.out).dump(workspace);
- }
-
- @Test
- public void shouldCreateHelloWorldDot() {
- new HelloWorldExample(stdLib).createProgram(controller);
- new WorkspaceDumper(Output.DOT, System.out).dump(workspace);
- }
-
- @Test
- public void shouldCreateHelloWorldOutline() {
- new HelloWorldExample(stdLib).createProgram(controller);
- new WorkspaceDumper(Output.TXT, System.out).dump(workspace);
- }
-
- @Test
- public void shouldCreateControlFlowDot() {
- new ControlFlowExample(stdLib).createProgram(controller);
- new WorkspaceDumper(Output.DOT, System.out).dump(workspace);
- }
-
- @Test
- public void shouldCreateControlFlowOutline() {
- new ControlFlowExample(stdLib).createProgram(controller);
- new WorkspaceDumper(Output.TXT, System.out).dump(workspace);
- }
-}
=======================================
--- /core/src/test/java/noop/graph/WorkspaceDumper.java Fri Apr 23 03:26:30
2010
+++ /dev/null
@@ -1,40 +0,0 @@
-package noop.graph;
-
-import com.thoughtworks.xstream.XStream;
-
-import java.io.PrintStream;
-
-/**
- * Dumps the content of a workspace in one of a few possible formats.
- * @author alex...@google.com (Alex Eagle)
- */
-public class WorkspaceDumper {
- private final Output output;
- private final PrintStream out;
-
- public WorkspaceDumper(Output output, PrintStream out) {
- this.output = output;
- this.out = out;
- }
-
- public enum Output {
- TXT, XML, DOT
- }
-
- public void dump(Workspace workspace) {
- switch (output) {
- case DOT:
- workspace.accept(new DotGraphPrintingVisitor(out));
- break;
- case TXT:
- workspace.accept(new OutlinePrintingVisitor(out));
- break;
- case XML:
- XStream xStream = new XStream();
- out.append(xStream.toXML(workspace));
- break;
- default:
- throw new RuntimeException("unknown output type " + output);
- }
- }
-}
=======================================
--- /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
07:46:55 2010
+++ /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
08:41:54 2010
@@ -43,15 +43,7 @@
}

public void print(LanguageElement element, String label, String...
params) {
- print(element, label, null, params);
- }
-
- public void print(LanguageElement element, String label, String
additional, String... params) {
- if (additional != null) {
- additional = ", " + additional;
- }
- out.format("%s [label=\"%s\"%s]\n", element.vertex.hashCode(),
String.format(label, params), additional);
- Library library = workspace.lookupLibrary(element.vertex.libraryUid);
+ out.format("%s [label=\"%s\"]\n", element.vertex.hashCode(),
escape(String.format(label, params)));
for (Edge edge : library.edgesFrom(element.vertex)) {
out.format("%s -> %s ", edge.src.hashCode(), edge.dest.hashCode());
out.println("[label=\"" + edge.type.name().toLowerCase() + "\",
style=dashed]");
@@ -87,9 +79,10 @@

protected String escape(String value) {
String escaped = super.escape(value);
- if (escaped.length() > 15) {
- escaped = escaped.substring(0, 12) + "...";
- }
+ if (escaped.length() > 30) {
+ escaped = escaped.substring(0, 27) + "...";
+ }
+ escaped = escaped.replaceAll("\\\"", "\\\\\"");
return escaped;
}

=======================================
--- /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
07:46:55 2010
+++ /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
08:41:54 2010
@@ -48,7 +48,6 @@
public void print(LanguageElement element, String message, String...
params) {
out.format("%s%s [#%s]", indent(), String.format(message, params),
element.vertex);
if (element.vertex != Vertex.NONE) {
- Library library = workspace.lookupLibrary(element.vertex.libraryUid);
for (Edge edge : library.edgesFrom(element.vertex)) {
out.format(" %s -> #%s", edge.type.name(), edge.dest);
}
=======================================
--- /core/src/main/java/noop/graph/PrintingVisitor.java Sun Apr 25 07:46:55
2010
+++ /core/src/main/java/noop/graph/PrintingVisitor.java Sun Apr 25 08:41:54
2010
@@ -9,6 +9,7 @@
*/
public abstract class PrintingVisitor extends ModelVisitor {
protected Workspace workspace;
+ protected Library library;
protected int currentDepth;
protected Stack<LanguageElement> parents = new Stack<LanguageElement>();

@@ -39,6 +40,7 @@

@Override
public void visit(Library library) {
+ this.library = library;
print(library, "Library \"%s\"", library.name);
}

@@ -99,7 +101,7 @@

@Override
public void visit(StringLiteral stringLiteral) {
- print(stringLiteral, "literal \\\"%s\\\"", stringLiteral.value);
+ print(stringLiteral, "literal \"%s\"", stringLiteral.value);
}


=======================================
--- /core/src/test/java/noop/graph/ArithmeticExample.java Sun Apr 25
06:44:04 2010
+++ /core/src/test/java/noop/graph/ArithmeticExample.java Sun Apr 25
08:41:54 2010
@@ -13,6 +13,7 @@
* @author alex...@google.com (Alex Eagle)
*/
public class ArithmeticExample extends Example {
+ public UUID uid;

public ArithmeticExample(StandardLibraryBuilder stdLib) {
super(stdLib);
@@ -22,7 +23,8 @@
public void createProgram(Controller controller) {
Project project = new Project("Arithmetic", "com.example", "Copyright
2010\nExample Co.");

- Library library = new Library(UUID.randomUUID(), "adding stuff");
+ uid = UUID.randomUUID();
+ Library library = new Library(uid, "adding stuff");
project.addLibrary(library);

Function entryPoint = new Function("start here");
=======================================
--- /core/src/test/java/noop/graph/ControlFlowExample.java Sun Apr 25
06:44:04 2010
+++ /core/src/test/java/noop/graph/ControlFlowExample.java Sun Apr 25
08:41:54 2010
@@ -13,6 +13,8 @@
* @author alex...@google.com (Alex Eagle)
*/
public class ControlFlowExample extends Example {
+ public UUID uid;
+
public ControlFlowExample(StandardLibraryBuilder stdLib) {
super(stdLib);
}
@@ -20,8 +22,8 @@
@Override
public void createProgram(Controller controller) {
Project project = new Project("Control
Flow", "com.example", "Copyright 2010\nExample Co.");
-
- Library library = new Library(UUID.randomUUID(), "Testing loops");
+ uid = UUID.randomUUID();
+ Library library = new Library(uid, "Testing loops");
project.addLibrary(library);

Clazz clazz = new Clazz("Iterating Printer");
=======================================
--- /core/src/test/java/noop/graph/DumpExamplesMain.java Sun Apr 25
01:29:41 2010
+++ /core/src/test/java/noop/graph/DumpExamplesMain.java Sun Apr 25
08:41:54 2010
@@ -16,7 +16,9 @@

package noop.graph;

-import noop.graph.WorkspaceDumper.Output;
+import noop.graph.ModelSerializer.Output;
+import noop.model.Library;
+import noop.model.Project;
import noop.stdlib.StandardLibraryBuilder;

import java.io.File;
@@ -29,18 +31,14 @@
* @author alex...@google.com (Alex Eagle)
*/
public class DumpExamplesMain {
- private final Output output;
private final File outDir;

- public DumpExamplesMain(Output output, File outDir) {
- this.output = output;
+ public DumpExamplesMain(File outDir) {
this.outDir = outDir;
}

public static void main(String[] args) throws FileNotFoundException {
- new DumpExamplesMain(Output.DOT, new File(args[0])).run();
- new DumpExamplesMain(Output.TXT, new File(args[0])).run();
- new DumpExamplesMain(Output.XML, new File(args[0])).run();
+ new DumpExamplesMain(new File(args[0])).run();
}

public void run() throws FileNotFoundException {
@@ -60,8 +58,20 @@
stdLib.build(controller);

example.createProgram(controller);
- File outFile = new File(outDir, example.getClass().getName() + "." +
output.name().toLowerCase());
- new WorkspaceDumper(output, new PrintStream(new
FileOutputStream(outFile))).dump(workspace);
+ for (Output output : Arrays.asList(Output.DOT, Output.TXT)) {
+ File outFile = new File(outDir, example.getClass().getName() + "."
+ output.name().toLowerCase());
+ new ModelSerializer(output, new PrintStream(new
FileOutputStream(outFile))).dump(workspace);
+ }
+
+ for (Project project : workspace.getProjects()) {
+ File projectDir = new File(new File(outDir,
project.getNamespace()), project.getName());
+ projectDir.mkdirs();
+ for (Library library : project.getLibraries()) {
+ File outFile = new File(projectDir, library.name + ".xml");
+ PrintStream stream = new PrintStream(new
FileOutputStream(outFile));
+ new ModelSerializer(Output.XML, stream).dump(library);
+ }
+ }
}
}
}
=======================================
--- /core/src/test/java/noop/graph/HelloWorldExample.java Sun Apr 25
06:44:04 2010
+++ /core/src/test/java/noop/graph/HelloWorldExample.java Sun Apr 25
08:41:54 2010
@@ -13,6 +13,8 @@
* @author alex...@google.com (Alex Eagle)
*/
public class HelloWorldExample extends Example {
+ public UUID uid;
+
public HelloWorldExample(StandardLibraryBuilder stdLib) {
super(stdLib);
}
@@ -21,7 +23,8 @@
public void createProgram(Controller controller) {
Project project = new Project("Hello World", "com.example", "Copyright
2010\nExample Co.");

- Library library = new Library(UUID.randomUUID(), "hello");
+ uid = UUID.randomUUID();
+ Library library = new Library(uid, "hello");
project.addLibrary(library);

Function sayHello = new Function("Say hello");

==============================================================================
Revision: 926d565a9b
Author: Alex Eagle <alex...@google.com>
Date: Sat May 8 12:33:33 2010
Log: Update copyrights
http://code.google.com/p/noop/source/detail?r=926d565a9b

Modified:
/core/src/main/java/noop/graph/OutlinePrintingVisitor.java
/core/src/main/java/noop/graph/PrintingVisitor.java
/core/src/main/java/noop/graph/Vertex.java
/core/src/main/java/noop/graph/VertexCreatingVisitor.java
/core/src/main/java/noop/model/AnonymousBlock.java
/core/src/main/java/noop/model/Binding.java
/core/src/main/java/noop/model/Comment.java
/core/src/main/java/noop/model/Function.java
/core/src/main/java/noop/model/Loop.java
/core/src/main/java/noop/model/Method.java
/core/src/main/java/noop/model/UnitTest.java
/core/src/main/java/noop/model/Visitable.java
/core/src/main/java/noop/operations/NewEdgeOperation.java
/core/src/main/java/noop/stdlib/StandardLibraryBuilder.java
/core/src/test/java/noop/graph/ArithmeticExample.java
/core/src/test/java/noop/graph/ArithmeticExampleTest.java
/core/src/test/java/noop/graph/ControlFlowExample.java
/core/src/test/java/noop/graph/ControlFlowExampleTest.java
/core/src/test/java/noop/graph/Example.java
/core/src/test/java/noop/graph/HelloWorldExample.java
/core/src/test/java/noop/graph/HelloWorldExampleTest.java
/core/src/test/java/noop/graph/ModelSerializer.java
/core/src/test/java/noop/graph/PrintingVisitorTest.java
/core/src/test/java/noop/graph/VertexCreatingVisitorTest.java
/init.settings.xml
/pom.xml

=======================================
--- /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sun Apr 25
08:41:54 2010
+++ /core/src/main/java/noop/graph/OutlinePrintingVisitor.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.*;
@@ -62,6 +78,4 @@
}
return builder.toString();
}
-
-
-}
+}
=======================================
--- /core/src/main/java/noop/graph/PrintingVisitor.java Sun Apr 25 08:41:54
2010
+++ /core/src/main/java/noop/graph/PrintingVisitor.java Sat May 8 12:33:33
2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.*;
=======================================
--- /core/src/main/java/noop/graph/Vertex.java Sun Apr 25 07:46:55 2010
+++ /core/src/main/java/noop/graph/Vertex.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import org.apache.commons.lang.builder.EqualsBuilder;
=======================================
--- /core/src/main/java/noop/graph/VertexCreatingVisitor.java Sun Apr 25
01:04:21 2010
+++ /core/src/main/java/noop/graph/VertexCreatingVisitor.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.LanguageElement;
=======================================
--- /core/src/main/java/noop/model/AnonymousBlock.java Thu Apr 22 02:43:30
2010
+++ /core/src/main/java/noop/model/AnonymousBlock.java Sat May 8 12:33:33
2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import noop.graph.ModelVisitor;
=======================================
--- /core/src/main/java/noop/model/Binding.java Fri Apr 23 03:26:30 2010
+++ /core/src/main/java/noop/model/Binding.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import noop.graph.ModelVisitor;
=======================================
--- /core/src/main/java/noop/model/Comment.java Fri Apr 23 04:40:41 2010
+++ /core/src/main/java/noop/model/Comment.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import noop.graph.ModelVisitor;
=======================================
--- /core/src/main/java/noop/model/Function.java Fri Apr 23 03:26:30 2010
+++ /core/src/main/java/noop/model/Function.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import com.google.common.collect.Lists;
=======================================
--- /core/src/main/java/noop/model/Loop.java Fri Apr 23 03:26:30 2010
+++ /core/src/main/java/noop/model/Loop.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import noop.graph.ModelVisitor;
=======================================
--- /core/src/main/java/noop/model/Method.java Fri Apr 23 03:26:30 2010
+++ /core/src/main/java/noop/model/Method.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import com.google.common.collect.Lists;
=======================================
--- /core/src/main/java/noop/model/UnitTest.java Fri Apr 23 03:26:30 2010
+++ /core/src/main/java/noop/model/UnitTest.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import noop.graph.ModelVisitor;
=======================================
--- /core/src/main/java/noop/model/Visitable.java Fri Apr 23 04:53:28 2010
+++ /core/src/main/java/noop/model/Visitable.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.model;

import noop.graph.ModelVisitor;
=======================================
--- /core/src/main/java/noop/operations/NewEdgeOperation.java Fri Apr 23
04:40:41 2010
+++ /core/src/main/java/noop/operations/NewEdgeOperation.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.operations;

import noop.graph.Controller;
=======================================
--- /core/src/main/java/noop/stdlib/StandardLibraryBuilder.java Fri Apr 23
06:41:28 2010
+++ /core/src/main/java/noop/stdlib/StandardLibraryBuilder.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.stdlib;

import noop.graph.Controller;
=======================================
--- /core/src/test/java/noop/graph/ArithmeticExample.java Sun Apr 25
08:41:54 2010
+++ /core/src/test/java/noop/graph/ArithmeticExample.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.*;
=======================================
--- /core/src/test/java/noop/graph/ArithmeticExampleTest.java Sun Apr 25
08:41:54 2010
+++ /core/src/test/java/noop/graph/ArithmeticExampleTest.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.graph.ModelSerializer.Output;
=======================================
--- /core/src/test/java/noop/graph/ControlFlowExample.java Sun Apr 25
08:41:54 2010
+++ /core/src/test/java/noop/graph/ControlFlowExample.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.*;
=======================================
--- /core/src/test/java/noop/graph/ControlFlowExampleTest.java Sun Apr 25
08:41:54 2010
+++ /core/src/test/java/noop/graph/ControlFlowExampleTest.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.graph.ModelSerializer.Output;
=======================================
--- /core/src/test/java/noop/graph/Example.java Wed Apr 21 09:10:37 2010
+++ /core/src/test/java/noop/graph/Example.java Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.stdlib.StandardLibraryBuilder;
=======================================
--- /core/src/test/java/noop/graph/HelloWorldExample.java Sun Apr 25
08:41:54 2010
+++ /core/src/test/java/noop/graph/HelloWorldExample.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.*;
=======================================
--- /core/src/test/java/noop/graph/HelloWorldExampleTest.java Sun Apr 25
08:41:54 2010
+++ /core/src/test/java/noop/graph/HelloWorldExampleTest.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.graph.ModelSerializer.Output;
=======================================
--- /core/src/test/java/noop/graph/ModelSerializer.java Sun Apr 25 08:41:54
2010
+++ /core/src/test/java/noop/graph/ModelSerializer.java Sat May 8 12:33:33
2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import com.thoughtworks.xstream.XStream;
=======================================
--- /core/src/test/java/noop/graph/PrintingVisitorTest.java Sun Apr 25
07:46:55 2010
+++ /core/src/test/java/noop/graph/PrintingVisitorTest.java Sat May 8
12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.*;
=======================================
--- /core/src/test/java/noop/graph/VertexCreatingVisitorTest.java Sun Apr
25 01:04:21 2010
+++ /core/src/test/java/noop/graph/VertexCreatingVisitorTest.java Sat May
8 12:33:33 2010
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package noop.graph;

import noop.model.Clazz;
=======================================
--- /init.settings.xml Thu Aug 27 06:24:36 2009
+++ /init.settings.xml Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+<!--
+ ~ Copyright 2010 Google Inc.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
<settings>
<activeProfiles>
<activeProfile>init</activeProfile>
=======================================
--- /pom.xml Sun Apr 18 00:49:40 2010
+++ /pom.xml Sat May 8 12:33:33 2010
@@ -1,3 +1,19 @@
+<!--
+ ~ Copyright $year Google Inc.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0

==============================================================================
Revision: 1dbe8c8549
Author: Alex Eagle <alex...@google.com>
Date: Sat May 8 13:26:32 2010
Log: Get mvn test to run successfully
http://code.google.com/p/noop/source/detail?r=1dbe8c8549

Modified:
/core/src/main/java/noop/graph/DotGraphPrintingVisitor.java
/core/src/test/java/noop/graph/ControlFlowExampleTest.java
/core/src/test/java/noop/graph/ControllerTest.java
/core/src/test/java/noop/graph/HelloWorldExampleTest.java
/core/src/test/java/noop/graph/ModelSerializer.java
/pom.xml

=======================================
--- /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sun Apr 25
08:41:54 2010
+++ /core/src/main/java/noop/graph/DotGraphPrintingVisitor.java Sat May 8
13:26:32 2010
@@ -48,7 +48,7 @@
out.format("%s -> %s ", edge.src.hashCode(), edge.dest.hashCode());
out.println("[label=\"" + edge.type.name().toLowerCase() + "\",
style=dashed]");
}
- if (getParent().vertex != Vertex.NONE) {
+ if (getParent() != null && getParent().vertex != Vertex.NONE) {
out.format("%s -> %s\n", getParent().vertex.hashCode(),
element.vertex.hashCode());
}
}
=======================================
--- /core/src/test/java/noop/graph/ControlFlowExampleTest.java Sat May 8
12:33:33 2010
+++ /core/src/test/java/noop/graph/ControlFlowExampleTest.java Sat May 8
13:26:32 2010
@@ -44,12 +44,12 @@
}

@Test
- public void shouldCreateArithmeticDot() {
+ public void shouldCreateControlFlowDot() {
new ModelSerializer(Output.DOT, System.out).dump(library);
}

@Test
- public void shouldCreateArithmeticOutline() {
+ public void shouldCreateControlFlowOutline() {
new ModelSerializer(Output.TXT, System.out).dump(library);
}
}
=======================================
--- /core/src/test/java/noop/graph/ControllerTest.java Sun Apr 25 07:46:55
2010
+++ /core/src/test/java/noop/graph/ControllerTest.java Sat May 8 13:26:32
2010
@@ -70,7 +70,8 @@
p.addLibrary(l);
Clazz c = new Clazz("c");
l.addClazz(c);
-
+ controller.apply(new NewProjectOperation(p));
+
try {
controller.apply(new EditNodeOperation(c.vertex, new
StringLiteral("String is not Clazz")));
fail("should throw IllegalArgumentException");
=======================================
--- /core/src/test/java/noop/graph/HelloWorldExampleTest.java Sat May 8
12:33:33 2010
+++ /core/src/test/java/noop/graph/HelloWorldExampleTest.java Sat May 8
13:26:32 2010
@@ -44,12 +44,12 @@
}

@Test
- public void shouldCreateArithmeticDot() {
+ public void shouldCreateHelloWorldDot() {
new ModelSerializer(Output.DOT, System.out).dump(library);
}

@Test
- public void shouldCreateArithmeticOutline() {
+ public void shouldCreateHelloWorldOutline() {
new ModelSerializer(Output.TXT, System.out).dump(library);
}
}
=======================================
--- /core/src/test/java/noop/graph/ModelSerializer.java Sat May 8 12:33:33
2010
+++ /core/src/test/java/noop/graph/ModelSerializer.java Sat May 8 13:26:32
2010
@@ -41,10 +41,16 @@
public void dump(LanguageElement element) {
switch (output) {
case DOT:
- element.accept(new DotGraphPrintingVisitor(out));
+ DotGraphPrintingVisitor visitor = new DotGraphPrintingVisitor(out);
+ visitor.enter(element);
+ element.accept(visitor);
+ visitor.leave(element);
break;
case TXT:
- element.accept(new OutlinePrintingVisitor(out));
+ OutlinePrintingVisitor v = new OutlinePrintingVisitor(out);
+ v.enter(element);
+ element.accept(v);
+ v.leave(element);
break;
case XML:
XStream xStream = new XStream();
=======================================
--- /pom.xml Sat May 8 12:33:33 2010
+++ /pom.xml Sat May 8 13:26:32 2010
@@ -41,7 +41,9 @@
</scm>
<modules>
<module>core</module>
+ <!-- tests failing
<module>translator</module>
+ -->
</modules>

<properties>

--
You received this message because you are subscribed to the Google Groups "Noop project changes from the version control system" group.
To post to this group, send email to noop-c...@googlegroups.com.
To unsubscribe from this group, send email to noop-changes...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/noop-changes?hl=en.

Reply all
Reply to author
Forward
0 new messages