Permalink
Browse files

change apit to new Networkparser because the api has now less method

  • Loading branch information...
StefanLindel committed Oct 9, 2017
1 parent 5b05481 commit 0fbdf757e2c77b608a7f739eb8f6ecb0735ab0bb
Showing with 87 additions and 99 deletions.
  1. +1 −0 .classpath
  2. +1 −0 src/main/java/org/sdmlib/codegen/Parser.java
  3. +5 −6 src/main/java/org/sdmlib/doc/JavascriptAdapter/Javascript.java
  4. +0 −5 src/main/java/org/sdmlib/models/classes/ClassModel.java
  5. +4 −6 src/main/java/org/sdmlib/models/classes/logic/GenClassModel.java
  6. +8 −8 src/test/java/org/sdmlib/simple/TestAttributes.java
  7. +2 −1 src/test/java/org/sdmlib/simple/TestEnumeration.java
  8. +17 −17 src/test/java/org/sdmlib/simple/TestMethods.java
  9. +1 −3 src/test/java/org/sdmlib/simple/TestModelCreation.java
  10. +1 −2 src/test/java/org/sdmlib/simple/testGen.java
  11. +9 −11 src/test/java/org/sdmlib/test/examples/SDMLib/ClassModelTest.java
  12. +3 −4 src/test/java/org/sdmlib/test/examples/SDMLib/PatternModelCodeGen.java
  13. +2 −3 src/test/java/org/sdmlib/test/examples/SimpleModelWithSet/testSimpleSetModel.java
  14. +1 −1 src/test/java/org/sdmlib/test/examples/gofpattern/StrategyModel.java
  15. +4 −5 src/test/java/org/sdmlib/test/examples/ludo/LudoModel.java
  16. +8 −9 src/test/java/org/sdmlib/test/examples/ludoreverse/LudoReverseModel.java
  17. +8 −8 src/test/java/org/sdmlib/test/examples/mancala/MancalaModel.java
  18. +4 −4 src/test/java/org/sdmlib/test/examples/maumau/GenModel.java
  19. +2 −1 src/test/java/org/sdmlib/test/examples/simpleEnumModel/SimpleClassModelWithEnumeration.java
  20. +2 −1 src/test/java/org/sdmlib/test/examples/simpleModel/SimpleModel.java
  21. +1 −1 src/test/java/org/sdmlib/test/examples/studyrightWithAssignments/StudyRightWithAssignmentsModel.java
  22. +3 −3 src/test/java/org/sdmlib/test/modelcouch/ModelCouchModel.java
View
@@ -3,6 +3,7 @@
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/main/replication"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/NetworkParser"/>
@@ -696,6 +696,7 @@ else if (currentRealKindEquals('('))
.withMemberName(methodSignature)
.withKind(METHOD)
.withThrowsTags(throwsTags)
//FIXME STEFAN RETURN
.withType(methodSignature + ":" + type)
.withStartPos(startPos)
.withEndPos(previousRealToken.startPos)
@@ -19,6 +19,7 @@
import de.uniks.networkparser.graph.Clazz;
import de.uniks.networkparser.graph.GraphList;
import de.uniks.networkparser.graph.GraphTokener;
import de.uniks.networkparser.graph.GraphUtil;
import de.uniks.networkparser.graph.Method;
import de.uniks.networkparser.graph.Parameter;
import de.uniks.networkparser.graph.util.AssociationSet;
@@ -126,16 +127,15 @@ public GraphList convertModelToGraphList(ClassModel model) {
// Attributes
for (Attribute attr : clazz.getAttributes())
{
node.with(new Attribute(attr.getName(), attr.getType()));
node.withAttribute(attr.getName(), attr.getType());
}
// Methods
for (Method method : clazz.getMethods())
{
Method newMethod = new Method(method.getName());
Method newMethod = node.createMethod(method.getName());
for(Parameter param : method.getParameter()){
newMethod.withParameter(param.getName(), param.getType());
}
node.with(newMethod);
}
list.with(node);
nodes.put(node.getId(), node);
@@ -151,7 +151,7 @@ public GraphList convertModelToGraphList(ClassModel model) {
sourceEdge.with(assoc.getInfo());
targetEdge.with(assoc.getInfo());
list.with(sourceEdge);
GraphUtil.setAssociation(list, sourceEdge);
}
for (Clazz kidClazz : model.getClazzes())
@@ -163,8 +163,7 @@ public GraphList convertModelToGraphList(ClassModel model) {
Clazz kidClazzes = nodes.get(CGUtil.shortClassName(superClazz.getName()));
Association kidEdge = new Association(kidClazzes).with(AssociationTypes.EDGE);
generationEdge.with(kidEdge);
list.with(generationEdge);
GraphUtil.setAssociation(list, generationEdge);
}
}
return list;
@@ -160,11 +160,6 @@ public String toString() {
return result.substring(1);
}
public ClassModel with(Clazz... values) {
super.with(values);
return this;
}
@Override
public ClassModel with(String name) {
super.with(name);
@@ -187,9 +187,8 @@ private void fixClassModel(Clazz item, HashSet<Clazz> visited, String rootDir) {
attribute.with(DataType.OBJECT);
}
} else {
Attribute attribute = new Attribute("value"+no, DataType.create(type));
Attribute attribute = item.createAttribute("value"+no, DataType.create(type));
attributes.add(attribute);
item.with(attribute);
}
}
no++;
@@ -199,15 +198,14 @@ private void fixClassModel(Clazz item, HashSet<Clazz> visited, String rootDir) {
GenClazzEntity orCreate = getOrCreate(item);
Parser orCreateParser = orCreate.getOrCreateParser(rootDir);
orCreateParser.indexOf(Parser.CLASS_END);
Method constructor = new Method(item.getName()).with(DataType.create(""));
Method constructor = item.createMethod(item.getName(), DataType.create(""));
String constructorBody = "";
for(Attribute attribute : attributes) {
constructor.with(new Parameter(attribute.getType()).with(attribute.getName()));
constructorBody += " this." + attribute.getName() + " = " + attribute.getName() + ";\n" ;
}
constructor.withBody(constructorBody);
constructor.with(Modifier.PACKAGE);
item.with(constructor);
}
}
@@ -2128,7 +2126,7 @@ public ClassModel learnFromGenericObjects(String packageName, GenericObject root
.with(Cardinality.ONE)
.with(sourceLabel)
.with(other);
model.with(currentAssoc);
GraphUtil.setAssociation(model, currentAssoc);
}
if (alreadyUsedLabels.contains(currentLink.getSrc().hashCode() + ":" + targetLabel))
@@ -2622,7 +2620,7 @@ private void tryToCreateAssoc(Clazz clazz, String memberName, Cardinality card,
if (!assocWithRolesExists(sourceRole, targetRole))
{
sourceRole.with(targetRole);
clazz.with(sourceRole);
GraphUtil.setAssociation(clazz, sourceRole);
}
}
@@ -37,7 +37,7 @@ public void testClassWithMultipleAttributes() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_c");
Clazz person = model.createClazz("Person");
person.createAttribute("name", DataType.STRING);
person.with(new Attribute("age", DataType.INT));
person.withAttribute("age", DataType.INT);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -48,7 +48,7 @@ public void testClassWithSetAttribute() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_d");
Clazz person = model.createClazz("Person");
person.with(new Attribute("names", DataTypeSet.create(DataType.STRING)));
person.withAttribute("names", DataTypeSet.create(DataType.STRING));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -59,7 +59,7 @@ public void testClassWithSingleSetAttributes() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_e");
Clazz person = model.createClazz("Person");
person.with(new Attribute("ages", DataTypeSet.create(DataType.INT)));
person.withAttribute("ages", DataTypeSet.create(DataType.INT));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
}
@@ -70,7 +70,7 @@ public void testClassWithMultipleSetAttributes() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_f");
Clazz person = model.createClazz("Person");
person.createAttribute("names", DataTypeSet.create(DataType.STRING));
person.with(new Attribute("ages", DataTypeSet.create(DataType.INT)));
person.withAttribute("ages", DataTypeSet.create(DataType.INT));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
}
@@ -139,7 +139,7 @@ public void testClassWithPrivateModifiedAttribute() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_l");
Clazz person = model.createClazz("Person");
person.with(new Attribute("personalName", DataType.STRING).with(Modifier.PRIVATE));
person.createAttribute("personalName", DataType.STRING).with(Modifier.PRIVATE);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -152,7 +152,7 @@ public void testClassWithPublicModifiedAttribute() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_m");
Clazz person = model.createClazz("Person");
person.with(new Attribute("personalName", DataType.STRING).with(Modifier.PUBLIC));
person.createAttribute("personalName", DataType.STRING).with(Modifier.PUBLIC);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
}
@@ -162,15 +162,15 @@ public void testClassWithStaticModifiedAttribute() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_n");
Clazz person = model.createClazz("Person");
person.with(new Attribute("personalName", DataType.STRING).with(Modifier.STATIC));
person.createAttribute("personalName", DataType.STRING).with(Modifier.STATIC);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
}
@Test
public void testClassWithProtectedModifiedAttribute() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.attribute_o");
Clazz person = model.createClazz("Person");
person.with(new Attribute("personalName", DataType.STRING).with(Modifier.PROTECTED));
person.createAttribute("personalName", DataType.STRING).with(Modifier.PROTECTED);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
}
@@ -4,6 +4,7 @@
import org.sdmlib.models.classes.ClassModel;
import de.uniks.networkparser.graph.Clazz;
import de.uniks.networkparser.graph.GraphUtil;
import de.uniks.networkparser.graph.Literal;
public class TestEnumeration {
@@ -41,7 +42,7 @@ public void testEnumerationWithMultipleEntries() {
Clazz testEnum = model.createClazz("TestEnum");
testEnum.enableEnumeration("PERSON","ROOM");
testEnum.with(new Literal("TEACHER"));
GraphUtil.setLiteral(testEnum, new Literal("TEACHER"));
model.getGenerator().testGeneratedCode();
}
@@ -18,7 +18,7 @@ public void testClassWithMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_a");
Clazz person = model.createClazz("Person");
person.with(new Method("think"));
person.createMethod("think");
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -30,7 +30,7 @@ public void testClassWithVoidMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_b");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID));
person.withMethod("think", DataType.VOID);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -42,7 +42,7 @@ public void testClassWithVoidAndNamelessParameterMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_c");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID, new Parameter(DataType.STRING)));
person.withMethod("think", DataType.VOID, new Parameter(DataType.STRING));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -54,7 +54,7 @@ public void testClassWithVoidAndParameterMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_d");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID, new Parameter(DataType.STRING).with("value")));
person.withMethod("think", DataType.VOID, new Parameter(DataType.STRING).with("value"));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -69,7 +69,7 @@ public void testClassWithVoidAndClassParameterMethod() {
Clazz person = model.createClazz("Person");
Clazz room = model.createClazz("Room");
person.with(new Method("think", DataType.VOID, new Parameter(DataType.create(room)).with("room")));
person.withMethod("think", DataType.VOID, new Parameter(DataType.create(room)).with("room"));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
}
@@ -81,8 +81,8 @@ public void testClassWithVoidAndSimpleClassParameterMethod() {
Clazz person = model.createClazz("Person");
Clazz room = model.createClazz("Room");
person.with(new Method("think", DataType.VOID, new Parameter(DataType.create(room)).with("room")));
person.with(new Method("read", DataType.VOID, new Parameter(room).with("room")));
person.withMethod("think", DataType.VOID, new Parameter(DataType.create(room)).with("room"));
person.withMethod("read", DataType.VOID, new Parameter(room).with("room"));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -95,7 +95,7 @@ public void testClassWithVoidAndSetParameterMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_g");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID, new Parameter(DataTypeSet.create(DataType.STRING)).with("values")));
person.withMethod("think", DataType.VOID, new Parameter(DataTypeSet.create(DataType.STRING)).with("values"));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -107,7 +107,7 @@ public void testClassWithVoidAndMapParameterMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_h");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID, new Parameter(DataTypeMap.create(DataType.STRING, DataType.STRING)).with("values")));
person.withMethod("think", DataType.VOID, new Parameter(DataTypeMap.create(DataType.STRING, DataType.STRING)).with("values"));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -119,7 +119,7 @@ public void testClassWithVoidAndMultipleParametersMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_i");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID, new Parameter(DataType.STRING).with("value"), new Parameter(DataType.INT)));
person.withMethod("think", DataType.VOID, new Parameter(DataType.STRING).with("value"), new Parameter(DataType.INT));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -131,7 +131,7 @@ public void testClassWithNonVoidMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_j");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.STRING));
person.withMethod("think", DataType.STRING);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -143,7 +143,7 @@ public void testClassWithNonVoidAndParameterMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_k");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.STRING, new Parameter(DataType.STRING)));
person.withMethod("think", DataType.STRING, new Parameter(DataType.STRING));
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -155,8 +155,8 @@ public void testClassWithMultipleMethods() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_l");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.STRING, new Parameter(DataType.STRING))
, new Method("dontThink", DataType.VOID));
person.withMethod("think", DataType.STRING, new Parameter(DataType.STRING));
person.withMethod("dontThink", DataType.VOID);
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -168,8 +168,8 @@ public void testClassWithMethodAndBody() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_m");
Clazz person = model.createClazz("Person");
person.with(new Method("think", DataType.VOID)
.withBody(" String thought = \"\";\n"));
person.createMethod("think", DataType.VOID)
.withBody(" String thought = \"\";\n");
model.getGenerator().testGeneratedCode();
// model.generate("src/test/java");
@@ -181,7 +181,7 @@ public void testClassWithBooleanMethod() {
ClassModel model = new ClassModel("org.sdmlib.simple.model.methods_n");
Clazz person = model.createClazz("Person");
person.with(new Method("checkSomething", DataType.BOOLEAN));
person.withMethod("checkSomething", DataType.BOOLEAN);
model.getGenerator().testGeneratedCode();
}
@@ -8,7 +8,6 @@
import de.uniks.networkparser.graph.Clazz;
import de.uniks.networkparser.graph.DataType;
import de.uniks.networkparser.graph.Literal;
import de.uniks.networkparser.graph.Method;
import de.uniks.networkparser.graph.Parameter;
public class TestModelCreation {
@@ -40,14 +39,13 @@ public void testCreateEntireModel() {
roomInterface.withAttribute("number", DataType.INT);
// Methods
Method teach = new Method("teach", DataType.STRING)
teacher.createMethod("teach", DataType.STRING)
.withBody(" String teachResult = \"greatResult\";\n"
+ " return teachResult;\n");
person.withMethod("think", DataType.VOID);
person.withMethod("dontThink", DataType.VOID, new Parameter(DataType.BOOLEAN));
pupil.withMethod("read", DataType.STRING);
teacher.with(teach);
// Super Classes
pupil.withSuperClazz(person);
@@ -6,7 +6,6 @@
import de.uniks.networkparser.graph.Cardinality;
import de.uniks.networkparser.graph.Clazz;
import de.uniks.networkparser.graph.DataType;
import de.uniks.networkparser.graph.Method;
public class testGen {
@@ -18,7 +17,7 @@ public void testModel() {
person.createAttribute("name", DataType.STRING);
person.createAttribute("age", DataType.INT);
room.with(new Method("init", DataType.VOID));
room.withMethod("init", DataType.VOID);
person.withBidirectional(room, "room", Cardinality.ONE, "persons", Cardinality.MANY);
Oops, something went wrong.

0 comments on commit 0fbdf75

Please sign in to comment.