Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
JastAdd
relational-rags
Commits
3afecd7c
Commit
3afecd7c
authored
Jan 16, 2020
by
Johannes Mey
Browse files
rename otherSide() to opposite()
parent
0b65daf7
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/jastadd/Analysis.jrag
View file @
3afecd7c
...
...
@@ -36,13 +36,13 @@ aspect ComponentAnalysis {
eq Program.getChild().enclosingTypeDecl() = null;
//--- otherSide ---
inh RelationComponent RelationComponent.o
therSid
e();
eq Relation.getLeft().o
therSid
e() = getRight();
eq Relation.getRight().o
therSid
e() = getLeft();
eq Program.getChild().o
therSid
e() = null;
inh RelationComponent RelationComponent.o
pposit
e();
eq Relation.getLeft().o
pposit
e() = getRight();
eq Relation.getRight().o
pposit
e() = getLeft();
eq Program.getChild().o
pposit
e() = null;
//--- ofTypeDecl ---
syn TypeDecl RelationComponent.ofTypeDecl() = o
therSid
e().getTypeUse().decl();
syn TypeDecl RelationComponent.ofTypeDecl() = o
pposit
e().getTypeUse().decl();
//--- isAlreadyDeclared ---
/**
...
...
src/main/jastadd/backend/API.jadd
View file @
3afecd7c
...
...
@@ -13,21 +13,21 @@ aspect BackendAPI {
}
public void RelationComponent.generateAPI(StringBuilder sb) {
if (o
therSid
e().isNavigable()) {
if (o
pposit
e().isNavigable()) {
if (multiplicityOne() || multiplicityOpt()) {
generateGetOne(sb);
if (o
therSid
e().multiplicityOne() || o
therSid
e().multiplicityOpt()) {
if (o
pposit
e().multiplicityOne() || o
pposit
e().multiplicityOpt()) {
generateBiOneOne(sb);
} else if (o
therSid
e().multiplicityMany()) {
} else if (o
pposit
e().multiplicityMany()) {
generateBiOneMany(sb);
}
if (isOpt()) {
generateExtraOptAPI(sb);
}
} else if (multiplicityMany()) {
if (o
therSid
e().multiplicityOne() || o
therSid
e().multiplicityOpt()) {
if (o
pposit
e().multiplicityOne() || o
pposit
e().multiplicityOpt()) {
generateBiManyOne(sb);
} else if (o
therSid
e().multiplicityMany()) {
} else if (o
pposit
e().multiplicityMany()) {
generateBiManyMany(sb);
}
}
...
...
src/main/jastadd/backend/BidirectionalAPI.jadd
View file @
3afecd7c
...
...
@@ -11,10 +11,10 @@ aspect BackendBidirectionalAPI {
}
// unset the old opposite
sb.append(ind(2) + "if (" + getImplAttributeField() + " != null)\n");
sb.append(ind(3) + getImplAttributeField() + ".set" + o
therSid
e().getImplAttributeName() + "(null);\n");
sb.append(ind(3) + getImplAttributeField() + ".set" + o
pposit
e().getImplAttributeName() + "(null);\n");
sb.append(ind(2) + "if (o != null && " + (resolve ? "!o." + isUnresolvedMethod + "() && o." : "o.") + o
therSid
e().getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + "o." + o
therSid
e().getImplAttributeField() + ".set" + getImplAttributeName() + "(null);\n");
sb.append(ind(2) + "if (o != null && " + (resolve ? "!o." + isUnresolvedMethod + "() && o." : "o.") + o
pposit
e().getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + "o." + o
pposit
e().getImplAttributeField() + ".set" + getImplAttributeName() + "(null);\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "set" + getImplAttributeName() + "(o);\n");
if (resolve) {
...
...
@@ -23,7 +23,7 @@ aspect BackendBidirectionalAPI {
if (isOpt()) {
sb.append(ind(resolve ? 3 : 2) + "if (o != null)\n");
}
sb.append(ind((isOpt() ? 1 : 0) + (resolve ? 3 : 2)) + "o.set" + o
therSid
e().getImplAttributeName() + "(this);\n");
sb.append(ind((isOpt() ? 1 : 0) + (resolve ? 3 : 2)) + "o.set" + o
pposit
e().getImplAttributeName() + "(this);\n");
sb.append(ind(2) + "return this;\n");
sb.append(ind(1) + "}\n");
...
...
@@ -57,12 +57,12 @@ aspect BackendBidirectionalAPI {
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + "" + resolvePostfix + "(element." + asUnresolvedMethod + "()." + getUnresolvedTokenMethod + "(), i);\n");
sb.append(ind(5) + "if (resolvedElement != null && element." + asUnresolvedMethod + "()." + getUnresolvedResolveOppositeMethod + "()) {\n");
sb.append(ind(6) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> otherList = resolvedElement." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(6) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> otherList = resolvedElement." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(6) + "if (otherList == null) {\n");
sb.append(ind(7) + "otherList = new " + listClass + "<>();\n");
sb.append(ind(6) + "}\n");
sb.append(ind(6) + "otherList.add(this);\n");
sb.append(ind(6) + "resolvedElement.set" + o
therSid
e().getImplAttributeName() + "(otherList);\n");
sb.append(ind(6) + "resolvedElement.set" + o
pposit
e().getImplAttributeName() + "(otherList);\n");
sb.append(ind(5) + "}\n");
sb.append(ind(5) + "l.set(i, resolvedElement);\n");
sb.append(ind(4) + "}\n");
...
...
@@ -83,14 +83,14 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + "if (list == null) {\n");
sb.append(ind(3) + "list = new " + ASTNode.listClass + "<>();\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + o
therSid
e().ofTypeDecl() + "> list2 = o." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + o
pposit
e().ofTypeDecl() + "> list2 = o." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (list2 == null) {\n");
sb.append(ind(3) + "list2 = new "+ ASTNode.listClass + "<>();\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "list.add(o);\n");
sb.append(ind(2) + "list2.add(this);\n");
sb.append(ind(2) + "set" + getImplAttributeName() + "(list);\n");
sb.append(ind(2) + "o.set" + o
therSid
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(2) + "o.set" + o
pposit
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(1) + "}\n");
// Insert / add at specific position
...
...
@@ -101,14 +101,14 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + "if (list == null) {\n");
sb.append(ind(3) + "list = new " + ASTNode.listClass + "<>();\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + o
therSid
e().ofTypeDecl() + "> list2 = o." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + o
pposit
e().ofTypeDecl() + "> list2 = o." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (list2 == null) {\n");
sb.append(ind(3) + "list2 = new "+ ASTNode.listClass + "<>();\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "list.add(index, o);\n");
sb.append(ind(2) + "list2.add(this);\n");
sb.append(ind(2) + "set" + getImplAttributeName() + "(list);\n");
sb.append(ind(2) + "o.set" + o
therSid
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(2) + "o.set" + o
pposit
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(1) + "}\n");
// Remove
...
...
@@ -117,10 +117,10 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + "assertNotNull(o);\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list = " + getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (list != null && list.remove(o)) {\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + o
therSid
e().ofTypeDecl() + "> list2 = o." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + o
pposit
e().ofTypeDecl() + "> list2 = o." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(3) + "if (list2 != null) list2.remove(this);\n");
sb.append(ind(3) + "set" + getImplAttributeName() + "(list);\n");
sb.append(ind(3) + "o.set" + o
therSid
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(3) + "o.set" + o
pposit
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(2) + "}\n");
sb.append(ind(1) + "}\n");
}
...
...
@@ -154,7 +154,7 @@ aspect BackendBidirectionalAPI {
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + resolvePostfix + "(element." + asUnresolvedMethod + "()." + getUnresolvedTokenMethod + "(), i);\n");
sb.append(ind(5) + "if (element." + asUnresolvedMethod + "()." + getUnresolvedResolveOppositeMethod + "()) {\n");
sb.append(ind(6) + getTypeUse().decl() + " oldTarget = resolvedElement." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(6) + getTypeUse().decl() + " oldTarget = resolvedElement." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(6) + "if (oldTarget != null && oldTarget != this) {\n");
sb.append(ind(7) + "oldTarget." + getImplAttributeField() + ".remove(resolvedElement);\n");
sb.append(ind(6) + "}\n");
...
...
@@ -162,7 +162,7 @@ aspect BackendBidirectionalAPI {
sb.append(ind(7) + "l.remove(i);\n");
sb.append(ind(7) + "i--;\n");
sb.append(ind(6) + "} else {\n");
sb.append(ind(7) + "resolvedElement.set" + o
therSid
e().getImplAttributeName() + "(this);\n");
sb.append(ind(7) + "resolvedElement.set" + o
pposit
e().getImplAttributeName() + "(this);\n");
sb.append(ind(7) + "l.set(i, resolvedElement);\n");
sb.append(ind(6) + "}\n");
sb.append(ind(5) + "} else {\n");
...
...
@@ -182,10 +182,10 @@ aspect BackendBidirectionalAPI {
String addMethodDecl1 = "void " + getTypeUse().decl() + ".add" + (useJastAddNames ? "" : "To") + nameCapitalized() + "(" + ofTypeDecl() + " o)";
sb.append(ind(1) + "public " + addMethodDecl1 + " {\n");
sb.append(ind(2) + "assertNotNull(o);\n");
sb.append(ind(2) + "if (o != null && o." + o
therSid
e().getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + o
therSid
e().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (o != null && o." + o
pposit
e().getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + o
pposit
e().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
sb.append(ind(3) + "if (list2.remove(o))\n");
sb.append(ind(4) + "o." + o
therSid
e().getImplAttributeField() + ".set" + getImplAttributeName() + "(list2);\n");
sb.append(ind(4) + "o." + o
pposit
e().getImplAttributeField() + ".set" + getImplAttributeName() + "(list2);\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list = " + getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (list == null) {\n");
...
...
@@ -193,17 +193,17 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "list.add(o);\n");
sb.append(ind(2) + "set" + getImplAttributeName() + "(list);\n");
sb.append(ind(2) + "o.set" + o
therSid
e().getImplAttributeName() + "(this);\n");
sb.append(ind(2) + "o.set" + o
pposit
e().getImplAttributeName() + "(this);\n");
sb.append(ind(1) + "}\n");
// Insert / add at specific position
String addMethodDecl2 = "void " + getTypeUse().decl() + ".add" + (useJastAddNames ? "" : "To") + nameCapitalized() + "(int index, " + ofTypeDecl() + " o)";
sb.append(ind(1) + "public " + addMethodDecl2 + " {\n");
sb.append(ind(2) + "assertNotNull(o);\n");
sb.append(ind(2) + "if (o != null && o." + o
therSid
e().getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + o
therSid
e().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (o != null && o." + o
pposit
e().getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + o
pposit
e().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
sb.append(ind(3) + "if (list2.remove(o))\n");
sb.append(ind(4) + "o." + o
therSid
e().getImplAttributeField() + ".set" + getImplAttributeName() + "(list2);\n");
sb.append(ind(4) + "o." + o
pposit
e().getImplAttributeField() + ".set" + getImplAttributeName() + "(list2);\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list = " + getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (list == null) {\n");
...
...
@@ -211,7 +211,7 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "list.add(index, o);\n");
sb.append(ind(2) + "set" + getImplAttributeName() + "(list);\n");
sb.append(ind(2) + "o.set" + o
therSid
e().getImplAttributeName() + "(this);\n");
sb.append(ind(2) + "o.set" + o
pposit
e().getImplAttributeName() + "(this);\n");
sb.append(ind(1) + "}\n");
// Remove
...
...
@@ -221,8 +221,8 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list = " + getImplAttributeField() + ";\n");
sb.append(ind(2) + "if (list != null && list.remove(o)) {\n");
sb.append(ind(3) + "set" + getImplAttributeName() + "(list);\n");
sb.append(ind(3) + "if (o." + o
therSid
e().getImplAttributeField() + " == this) {\n");
sb.append(ind(4) + "o.set" + o
therSid
e().getImplAttributeName() + "(null);\n");
sb.append(ind(3) + "if (o." + o
pposit
e().getImplAttributeField() + " == this) {\n");
sb.append(ind(4) + "o.set" + o
pposit
e().getImplAttributeName() + "(null);\n");
sb.append(ind(3) + "}\n");
sb.append(ind(2) + "}\n");
sb.append(ind(1) + "}\n");
...
...
@@ -236,9 +236,9 @@ aspect BackendBidirectionalAPI {
sb.append(ind(2) + "assertNotNull(o);\n");
}
sb.append(ind(2) + "if (" + getImplAttributeField() + " != null) {\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> list2 = " + getImplAttributeField() + "." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(3) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> list2 = " + getImplAttributeField() + "." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(3) + "list2.remove(this);\n");
sb.append(ind(3) + getImplAttributeField() + "." + "set" + o
therSid
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(3) + getImplAttributeField() + "." + "set" + o
pposit
e().getImplAttributeName() + "(list2);\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "set" + getImplAttributeName() + "(o);\n");
...
...
@@ -246,12 +246,12 @@ aspect BackendBidirectionalAPI {
if (isOpt()) {
sb.append(ind(2) + "if (o != null) {\n");
}
sb.append(ind(ind) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> list = o." + o
therSid
e().getImplAttributeField() + ";\n");
sb.append(ind(ind) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> list = o." + o
pposit
e().getImplAttributeField() + ";\n");
sb.append(ind(ind) + "if (list == null) {\n");
sb.append(ind(ind+1) + "list = new " + ASTNode.listClass + "<>();\n");
sb.append(ind(ind) + "}\n");
sb.append(ind(ind) + "list.add(this);\n");
sb.append(ind(ind) + "o.set" + o
therSid
e().getImplAttributeName() + "(list);\n");
sb.append(ind(ind) + "o.set" + o
pposit
e().getImplAttributeName() + "(list);\n");
if (isOpt()) {
sb.append(ind(2) + "}\n");
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment