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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
dumpAst
Merge requests
!13
3.0.1
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
3.0.1
dev
into
main
Overview
0
Commits
22
Pipelines
2
Changes
35
Merged
René Schöne
requested to merge
dev
into
main
2 years ago
Overview
0
Commits
22
Pipelines
2
Changes
35
0
0
Merge request reports
Compare
main
version 1
87d6f894
2 years ago
main (base)
and
latest version
latest version
2b5428a6
22 commits,
2 years ago
version 1
87d6f894
21 commits,
2 years ago
35 files
+
1103
−
1487
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
35
dumpAst.base/src/main/jastadd/ClassAnalysis.jrag
+
22
−
9
View file @ 2b5428a6
Edit in single-file editor
Open in Web IDE
Show full file
@@ -48,29 +48,28 @@ aspect ClassAnalysis {
String tokenName = invokeName(annotation);
if (tokenName.startsWith("_impl_")) {
String relationName = titleCase(tokenName.substring(6));
try {
java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName);
if (present(getMethod(clazz, "get" + relationName), relationMethod -> {
// normal get + token-name -> singleRelation
SingleRelationMethod singleRelationMethod = new SingleRelationMethod();
SingleRelationMethod singleRelationMethod = getMethod(clazz, "has" + relationName).isPresent() ?
new OptRelationMethod() : new SingleRelationMethod();
singleRelationMethod.setMethod(relationMethod);
singleRelationMethod.setName(relationName);
result.addOtherMethod(singleRelationMethod);
})) {
continue;
} catch (NoSuchMethodException e) {
// ignore, but we know this is probably not a single relation
}
// we know here this is probably not a single or opt relation
// try list-relation next
try {
java.lang.reflect.Method relationMethod = clazz.getMethod("get" + relationName + "List");
if (present(getMethod(clazz, "get" + relationName + "List"), relationMethod -> {
// normal get + token-name + "List" -> listRelation
ListRelationMethod listRelationMethod = new ListRelationMethod();
listRelationMethod.setMethod(relationMethod);
listRelationMethod.setName(relationName);
result.addOtherMethod(listRelationMethod);
})) {
continue;
} catch (NoSuchMethodException e) {
// ignore, but we know this is probably not a relation at all
}
// we know here this is probably not a relation at all
}
IntrinsicTokenMethod tokenMethod = new IntrinsicTokenMethod();
tokenMethod.setMethod(method);
@@ -201,6 +200,20 @@ aspect ClassAnalysis {
}
}
private static java.util.Optional<java.lang.reflect.Method> DumpAst.getMethod(Class<?> clazz, String methodName) {
try {
java.lang.reflect.Method method = clazz.getMethod(methodName);
return java.util.Optional.of(method);
} catch (NoSuchMethodException e) {
return java.util.Optional.empty();
}
}
private static <T> boolean DumpAst.present(java.util.Optional<T> optional, java.util.function.Consumer<T> callback) {
optional.ifPresent(callback);
return optional.isPresent();
}
// --- astNodeAnnotationPrefix ---
syn String DumpAst.astNodeAnnotationPrefix() = getPackageName() + ".ASTNodeAnnotation";
inh String DumpNode.astNodeAnnotationPrefix();
Loading