From 3afecd7c3e09451f1708ed3ca1f13228c26fccfb Mon Sep 17 00:00:00 2001
From: Johannes Mey <johannes.mey@tu-dresden.de>
Date: Thu, 16 Jan 2020 10:54:22 +0100
Subject: [PATCH] rename otherSide() to opposite()

---
 src/main/jastadd/Analysis.jrag                | 10 ++--
 src/main/jastadd/backend/API.jadd             | 10 ++--
 .../jastadd/backend/BidirectionalAPI.jadd     | 56 +++++++++----------
 3 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/main/jastadd/Analysis.jrag b/src/main/jastadd/Analysis.jrag
index c73a8ca..0844b61 100644
--- a/src/main/jastadd/Analysis.jrag
+++ b/src/main/jastadd/Analysis.jrag
@@ -36,13 +36,13 @@ aspect ComponentAnalysis {
   eq Program.getChild().enclosingTypeDecl() = null;
 
   //--- otherSide ---
-  inh RelationComponent RelationComponent.otherSide();
-  eq Relation.getLeft().otherSide() = getRight();
-  eq Relation.getRight().otherSide() = getLeft();
-  eq Program.getChild().otherSide() = null;
+  inh RelationComponent RelationComponent.opposite();
+  eq Relation.getLeft().opposite() = getRight();
+  eq Relation.getRight().opposite() = getLeft();
+  eq Program.getChild().opposite() = null;
 
   //--- ofTypeDecl ---
-  syn TypeDecl RelationComponent.ofTypeDecl() = otherSide().getTypeUse().decl();
+  syn TypeDecl RelationComponent.ofTypeDecl() = opposite().getTypeUse().decl();
 
   //--- isAlreadyDeclared ---
   /**
diff --git a/src/main/jastadd/backend/API.jadd b/src/main/jastadd/backend/API.jadd
index 321d38f..97be8bc 100644
--- a/src/main/jastadd/backend/API.jadd
+++ b/src/main/jastadd/backend/API.jadd
@@ -13,21 +13,21 @@ aspect BackendAPI {
   }
 
   public void RelationComponent.generateAPI(StringBuilder sb) {
-    if (otherSide().isNavigable()) {
+    if (opposite().isNavigable()) {
       if (multiplicityOne() || multiplicityOpt()) {
         generateGetOne(sb);
-        if (otherSide().multiplicityOne() || otherSide().multiplicityOpt()) {
+        if (opposite().multiplicityOne() || opposite().multiplicityOpt()) {
           generateBiOneOne(sb);
-        } else if (otherSide().multiplicityMany()) {
+        } else if (opposite().multiplicityMany()) {
           generateBiOneMany(sb);
         }
         if (isOpt()) {
           generateExtraOptAPI(sb);
         }
       } else if (multiplicityMany()) {
-        if (otherSide().multiplicityOne() || otherSide().multiplicityOpt()) {
+        if (opposite().multiplicityOne() || opposite().multiplicityOpt()) {
           generateBiManyOne(sb);
-        } else if (otherSide().multiplicityMany()) {
+        } else if (opposite().multiplicityMany()) {
           generateBiManyMany(sb);
         }
       }
diff --git a/src/main/jastadd/backend/BidirectionalAPI.jadd b/src/main/jastadd/backend/BidirectionalAPI.jadd
index 1db4171..19eb9de 100644
--- a/src/main/jastadd/backend/BidirectionalAPI.jadd
+++ b/src/main/jastadd/backend/BidirectionalAPI.jadd
@@ -11,10 +11,10 @@ aspect BackendBidirectionalAPI {
     }
     // unset the old opposite
     sb.append(ind(2) + "if (" + getImplAttributeField() + " != null)\n");
-    sb.append(ind(3) + getImplAttributeField() + ".set" + otherSide().getImplAttributeName() + "(null);\n");
+    sb.append(ind(3) + getImplAttributeField() + ".set" + opposite().getImplAttributeName() + "(null);\n");
 
-    sb.append(ind(2) + "if (o != null && " + (resolve ? "!o." + isUnresolvedMethod + "() && o." : "o.") + otherSide().getImplAttributeField() + " != null) {\n");
-    sb.append(ind(3) + "o." + otherSide().getImplAttributeField() + ".set" + getImplAttributeName() + "(null);\n");
+    sb.append(ind(2) + "if (o != null && " + (resolve ? "!o." + isUnresolvedMethod + "() && o." : "o.") + opposite().getImplAttributeField() + " != null) {\n");
+    sb.append(ind(3) + "o." + opposite().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" + otherSide().getImplAttributeName() + "(this);\n");
+    sb.append(ind((isOpt() ? 1 : 0) + (resolve ? 3 : 2)) + "o.set" + opposite().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." + otherSide().getImplAttributeField() + ";\n");
+      sb.append(ind(6) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> otherList = resolvedElement." + opposite().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" + otherSide().getImplAttributeName() + "(otherList);\n");
+      sb.append(ind(6) + "resolvedElement.set" + opposite().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 + "<" + otherSide().ofTypeDecl() + "> list2 = o." + otherSide().getImplAttributeField() + ";\n");
+    sb.append(ind(2) + ASTNode.listInterface + "<" + opposite().ofTypeDecl() + "> list2 = o." + opposite().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" + otherSide().getImplAttributeName() + "(list2);\n");
+    sb.append(ind(2) + "o.set" + opposite().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 + "<" + otherSide().ofTypeDecl() + "> list2 = o." + otherSide().getImplAttributeField() + ";\n");
+    sb.append(ind(2) + ASTNode.listInterface + "<" + opposite().ofTypeDecl() + "> list2 = o." + opposite().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" + otherSide().getImplAttributeName() + "(list2);\n");
+    sb.append(ind(2) + "o.set" + opposite().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 + "<" + otherSide().ofTypeDecl() + "> list2 = o." + otherSide().getImplAttributeField() + ";\n");
+    sb.append(ind(3) + ASTNode.listInterface + "<" + opposite().ofTypeDecl() + "> list2 = o." + opposite().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" + otherSide().getImplAttributeName() + "(list2);\n");
+    sb.append(ind(3) + "o.set" + opposite().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." + otherSide().getImplAttributeField() + ";\n");
+      sb.append(ind(6) + getTypeUse().decl() + " oldTarget = resolvedElement." + opposite().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" + otherSide().getImplAttributeName() + "(this);\n");
+      sb.append(ind(7) + "resolvedElement.set" + opposite().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." + otherSide().getImplAttributeField() + " != null) {\n");
-    sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + otherSide().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
+    sb.append(ind(2) + "if (o != null && o." + opposite().getImplAttributeField() + " != null) {\n");
+    sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + opposite().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
     sb.append(ind(3) + "if (list2.remove(o))\n");
-    sb.append(ind(4) + "o." + otherSide().getImplAttributeField()  + ".set" + getImplAttributeName() + "(list2);\n");
+    sb.append(ind(4) + "o." + opposite().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" + otherSide().getImplAttributeName() + "(this);\n");
+    sb.append(ind(2) + "o.set" + opposite().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." + otherSide().getImplAttributeField() + " != null) {\n");
-    sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + otherSide().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
+    sb.append(ind(2) + "if (o != null && o." + opposite().getImplAttributeField() + " != null) {\n");
+    sb.append(ind(3) + ASTNode.listInterface + "<" + ofTypeDecl() + "> list2 = o." + opposite().getImplAttributeField() + "." + getImplAttributeField() + ";\n");
     sb.append(ind(3) + "if (list2.remove(o))\n");
-    sb.append(ind(4) + "o." + otherSide().getImplAttributeField() + ".set" + getImplAttributeName() + "(list2);\n");
+    sb.append(ind(4) + "o." + opposite().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" + otherSide().getImplAttributeName() + "(this);\n");
+    sb.append(ind(2) + "o.set" + opposite().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." + otherSide().getImplAttributeField() + " == this) {\n");
-    sb.append(ind(4) + "o.set" + otherSide().getImplAttributeName() + "(null);\n");
+    sb.append(ind(3) + "if (o." + opposite().getImplAttributeField() + " == this) {\n");
+    sb.append(ind(4) + "o.set" + opposite().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() + "." + otherSide().getImplAttributeField() + ";\n");
+    sb.append(ind(3) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> list2 = " + getImplAttributeField() + "." + opposite().getImplAttributeField() + ";\n");
     sb.append(ind(3) + "list2.remove(this);\n");
-    sb.append(ind(3) + getImplAttributeField() + "." + "set" + otherSide().getImplAttributeName() + "(list2);\n");
+    sb.append(ind(3) + getImplAttributeField() + "." + "set" + opposite().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." + otherSide().getImplAttributeField() + ";\n");
+    sb.append(ind(ind) + ASTNode.listInterface + "<" + getTypeUse().decl() + "> list = o." + opposite().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" + otherSide().getImplAttributeName() + "(list);\n");
+    sb.append(ind(ind) + "o.set" + opposite().getImplAttributeName() + "(list);\n");
     if (isOpt()) {
       sb.append(ind(2) + "}\n");
     }
-- 
GitLab