Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dumpAst
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
dumpAst
Commits
137d0ce5
Commit
137d0ce5
authored
2 years ago
by
René Schöne
Browse files
Options
Downloads
Patches
Plain Diff
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
!13
3.0.1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumpAst.base/src/main/jastadd/Transform.jadd
+213
-165
213 additions, 165 deletions
dumpAst.base/src/main/jastadd/Transform.jadd
with
213 additions
and
165 deletions
dumpAst.base/src/main/jastadd/Transform.jadd
+
213
−
165
View file @
137d0ce5
...
...
@@ -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)) {
continu
e;
return fals
e;
}
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) {
continu
e;
return fals
e;
}
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))) {
continu
e;
return fals
e;
}
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())) {
continu
e;
return fals
e;
}
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) {
continu
e;
return fals
e;
}
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) {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment