Skip to content
Snippets Groups Projects
Commit 137d0ce5 authored by René Schöne's avatar René Schöne
Browse files

2.0.3

- internal restructure (methods for each kind of analysed method)
parent db9b919c
No related branches found
No related tags found
1 merge request!133.0.1
......@@ -126,12 +126,39 @@ aspect Transform {
}
for (AnalysedMethod containmentMethod : car.getContainmentMethodList()) {
if (containmentMethod.isSingleChildMethod() || containmentMethod.isOptChildMethod()) {
handleContainmentSingleOrOptChild(node, containmentMethod, obj, tti, options);
} else if (containmentMethod.isListChildMethod()) {
handleContainmentListChild(node, containmentMethod, obj, tti, options);
} else {
throw new RuntimeException("Unknown containment method type " + containmentMethod);
}
}
for (AnalysedMethod otherMethod : car.getOtherMethodList()) {
if (otherMethod.isSingleChildMethod()) {
handleOtherSingleChild(node, otherMethod, obj, tti, options);
} else if (otherMethod.isListChildMethod()) {
handleOtherListChild(node, otherMethod, obj, tti, options);
} else if (otherMethod.isSingleRelationMethod()) {
handleOtherSingleRelation(node, otherMethod, obj, tti, options);
} else if (otherMethod.isListRelationMethod()) {
handleOtherListRelation(node, otherMethod, obj, tti, options);
} else if (otherMethod.isTokenMethod()) {
handleOtherToken(node, otherMethod, obj, tti, options);
} else {
throw new RuntimeException("Unknown other method type " + otherMethod);
}
}
return node;
}
private boolean DumpAst.handleContainmentSingleOrOptChild(DumpNode node, AnalysedMethod containmentMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- singleChild or optChild --
Object target;
if (containmentMethod.isOptChildMethod() && !((boolean) containmentMethod.asOptChildMethod().getCheckMethod().invoke(obj))) {
if (getBuildConfig().getExcludeNullNodes()) {
continue;
//target = containmentMethod.getMethod().invoke(obj);
return false;
} else {
target = null;
}
......@@ -140,7 +167,7 @@ aspect Transform {
}
String childName = containmentMethod.getName();
if (!getBuildConfig().getIncludeChildMethod().shouldInclude(obj, target, childName)) {
continue;
return false;
}
DumpNode targetNode = transform(tti, target, options.asNormal(false).allowNullObjectsOnce());
if (targetNode != null) {
......@@ -150,7 +177,12 @@ aspect Transform {
normalChild.setComputed(false);
node.addDumpChildNode(normalChild);
}
} else if (containmentMethod.isListChildMethod()) {
return true;
}
private boolean DumpAst.handleContainmentListChild(DumpNode node, AnalysedMethod containmentMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- listChild --
Iterable<?> targetList = (Iterable<?>) containmentMethod.getMethod().invoke(obj);
DumpListChildNode listChild = new DumpListChildNode();
......@@ -173,12 +205,12 @@ aspect Transform {
options.asNormal(false).allowNullObjectsOnce())));
}
node.addDumpChildNode(listChild);
} else {
throw new RuntimeException("Unknown containment method type " + containmentMethod);
}
return true;
}
for (AnalysedMethod otherMethod : car.getOtherMethodList()) {
if (otherMethod.isSingleChildMethod()) {
private boolean DumpAst.handleOtherSingleChild(DumpNode node, AnalysedMethod otherMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- singleChild --
String childName = otherMethod.getName();
boolean computed = otherMethod.asSingleChildMethod().isNTASingleChildMethod();
......@@ -186,7 +218,7 @@ aspect Transform {
getBuildConfig().getIncludeAttributeMethod().shouldInclude(obj, childName, true, () -> catchedInvoke(otherMethod.getMethod(), obj)) :
getBuildConfig().getIncludeChildMethod().shouldInclude(obj, otherMethod.getMethod().invoke(obj), childName);
if (!shouldInclude) {
continue;
return false;
}
DumpNode targetNode = transform(tti, otherMethod.getMethod().invoke(obj), options.asNormal(false).computed(computed).allowNullObjectsOnce());
if (targetNode != null) {
......@@ -196,12 +228,17 @@ aspect Transform {
normalChild.setComputed(computed);
node.addDumpChildNode(normalChild);
}
} else if (otherMethod.isListChildMethod()) {
return true;
}
private boolean DumpAst.handleOtherListChild(DumpNode node, AnalysedMethod otherMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- listChild --
// it is always a NTAListChildMethod
String childName = otherMethod.getName();
if (!getBuildConfig().getIncludeAttributeMethod().shouldInclude(obj, childName, true, () -> catchedInvoke(otherMethod.getMethod(), obj))) {
continue;
return false;
}
Iterable<?> targetList = (Iterable<?>) otherMethod.getMethod().invoke(obj);
DumpListChildNode listChild = new DumpListChildNode();
......@@ -217,11 +254,16 @@ aspect Transform {
if (listChild.getNumInnerDumpNode() > 0) {
node.addDumpChildNode(listChild);
}
} else if (otherMethod.isSingleRelationMethod()) {
return true;
}
private boolean DumpAst.handleOtherSingleRelation(DumpNode node, AnalysedMethod otherMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- singleRelation --
Object target = otherMethod.getMethod().invoke(obj);
if (!getBuildConfig().getIncludeRelationMethod().shouldInclude(obj, target, otherMethod.getName())) {
continue;
return false;
}
DumpNode targetNode = transform(tti, target, options.asRelation());
if (targetNode != null) {
......@@ -231,7 +273,12 @@ aspect Transform {
normalRelation.setDumpNode(targetNode);
node.addDumpRelation(normalRelation);
}
} else if (otherMethod.isListRelationMethod()) {
return true;
}
private boolean DumpAst.handleOtherListRelation(DumpNode node, AnalysedMethod otherMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- listRelation --
Iterable<?> targetList = (Iterable<?>) otherMethod.getMethod().invoke(obj);
DumpListRelation listRelation = new DumpListRelation();
......@@ -253,14 +300,19 @@ aspect Transform {
options.asNormal(false).allowNullObjectsOnce())));
}
node.addDumpRelation(listRelation);
} else if (otherMethod.isTokenMethod()) {
return true;
}
private boolean DumpAst.handleOtherToken(DumpNode node, AnalysedMethod otherMethod,
Object obj, TransformationTransferInformation tti, TransformationOptions options)
throws java.lang.reflect.InvocationTargetException, IllegalAccessException, NoSuchMethodException {
// -- token --
TokenMethod tokenMethod = otherMethod.asTokenMethod();
boolean shouldInclude = tokenMethod.isAttributeMethod() ?
getBuildConfig().getIncludeAttributeMethod().shouldInclude(obj, otherMethod.getName(), false, () -> catchedInvoke(otherMethod.getMethod(), obj)) :
getBuildConfig().getIncludeTokenMethod().shouldInclude(obj, otherMethod.getName(), otherMethod.getMethod().invoke(obj));
if (!shouldInclude) {
continue;
return false;
}
Object target = otherMethod.getMethod().invoke(obj);
if (target != null) {
......@@ -303,11 +355,7 @@ aspect Transform {
node.addDumpToken(token);
}
}
} else {
throw new RuntimeException("Unknown other method type " + otherMethod);
}
}
return node;
return true;
}
private Object DumpAst.catchedInvoke(java.lang.reflect.Method method, Object obj) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment