Commit bf521752 authored by Johannes Mey's avatar Johannes Mey
Browse files

create alternative reference resolving NOT setting the opposite directions

parent a2afc0cc
Pipeline #3003 passed with stage
in 47 seconds
......@@ -257,7 +257,11 @@ aspect BackendDirectedAPI {
sb.append(".get" + nameCapitalized() + "() {\n");
if (resolverHelper) {
sb.append(ind(2) + "if (get" + getImplAttributeName() + "() != null && get" + getImplAttributeName() + "().unresolved()) {\n");
sb.append(ind(3) + "set" + nameCapitalized() + "(resolve" + nameCapitalized() + "ByToken(get" + getImplAttributeName() + "().asUnresolved().get__token()));\n");
sb.append(ind(3) + "if (get" + getImplAttributeName() + "().asUnresolved().get__resolve_opposite()) {\n");
sb.append(ind(4) + "set" + nameCapitalized() + "(resolve" + nameCapitalized() + "ByToken(get" + getImplAttributeName() + "().asUnresolved().get__token()));\n");
sb.append(ind(3) + "} else {\n");
sb.append(ind(4) + "set" + getImplAttributeName() + "(resolve" + nameCapitalized() + "ByToken(get" + getImplAttributeName() + "().asUnresolved().get__token()));\n");
sb.append(ind(3) + "}\n");
sb.append(ind(2) + "}\n");
}
sb.append(ind(2) + "return get" + getImplAttributeName() + "();\n");
......@@ -391,7 +395,7 @@ aspect BackendBidirectionalAPI {
sb.append(ind(4) + "if (element.unresolved()) {\n");
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + "ByToken(element.asUnresolved().get__token(), i);\n");
sb.append(ind(5) + "if (resolvedElement != null) {\n");
sb.append(ind(5) + "if (resolvedElement != null && element.asUnresolved().get__resolve_opposite()) {\n");
sb.append(ind(6) + ASTNode.listClass + "<" + toTypeDecl() + "> otherList = resolvedElement.get" + opposite.getImplAttributeName() + "();\n");
sb.append(ind(6) + "if (otherList == null) {\n");
sb.append(ind(7) + "otherList = new ArrayList<>();\n");
......@@ -484,15 +488,19 @@ aspect BackendBidirectionalAPI {
sb.append(ind(4) + "if (element.unresolved()) {\n");
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + "ByToken(element.asUnresolved().get__token(), i);\n");
sb.append(ind(5) + toTypeDecl() + " oldTarget = resolvedElement.get" + opposite.getImplAttributeName() + "();\n");
sb.append(ind(5) + "if (oldTarget != null && oldTarget != this) {\n");
sb.append(ind(6) + "oldTarget.get" + getImplAttributeName() + "().remove(resolvedElement);\n");
sb.append(ind(5) + "}\n");
sb.append(ind(5) + "if (oldTarget == this) {\n");
sb.append(ind(6) + "l.remove(i);\n");
sb.append(ind(6) + "i--;\n");
sb.append(ind(5) + "if (element.asUnresolved().get__resolve_opposite()) {\n");
sb.append(ind(6) + toTypeDecl() + " oldTarget = resolvedElement.get" + opposite.getImplAttributeName() + "();\n");
sb.append(ind(6) + "if (oldTarget != null && oldTarget != this) {\n");
sb.append(ind(7) + "oldTarget.get" + getImplAttributeName() + "().remove(resolvedElement);\n");
sb.append(ind(6) + "}\n");
sb.append(ind(6) + "if (oldTarget == this) {\n");
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" + opposite.getImplAttributeName() + "(this);\n");
sb.append(ind(7) + "l.set(i, resolvedElement);\n");
sb.append(ind(6) + "}\n");
sb.append(ind(5) + "} else {\n");
sb.append(ind(6) + "resolvedElement.set" + opposite.getImplAttributeName() + "(this);\n");
sb.append(ind(6) + "l.set(i, resolvedElement);\n");
sb.append(ind(5) + "}\n");
sb.append(ind(4) + "}\n");
......@@ -727,6 +735,7 @@ aspect NameResolutionHelper {
sb.append(ind(1) + "public interface __Unresolved {\n");
sb.append(ind(2) + "abstract String get__token();\n");
sb.append(ind(2) + "abstract boolean get__resolve_opposite();\n");
sb.append(ind(1) + "}\n\n");
for (TypeDecl decl : getTypeDeclList()) {
......@@ -764,6 +773,14 @@ aspect NameResolutionHelper {
sb.append(ind(1) + "public static " + superType + " " + superType + ".createRef(String ref) {\n");
sb.append(ind(2) + instantiableUnresolved.getID() + " unresolvedNode = new " + instantiableUnresolved.getID() + "();\n");
sb.append(ind(2) + "unresolvedNode.set__token(ref);\n");
sb.append(ind(2) + "unresolvedNode.set__resolve_opposite(true);\n");
sb.append(ind(2) + "return unresolvedNode;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + "public static " + superType + " " + superType + ".createRefDirection(String ref) {\n");
sb.append(ind(2) + instantiableUnresolved.getID() + " unresolvedNode = new " + instantiableUnresolved.getID() + "();\n");
sb.append(ind(2) + "unresolvedNode.set__token(ref);\n");
sb.append(ind(2) + "unresolvedNode.set__resolve_opposite(false);\n");
sb.append(ind(2) + "return unresolvedNode;\n");
sb.append(ind(1) + "}\n");
}
......
......@@ -59,6 +59,7 @@ public class Compiler {
unresolvedDecl.setAbstract(typeDecl.getAbstract());
unresolvedDecl.setSuper(new SimpleTypeUse(typeDecl.getID()));
unresolvedDecl.addComponent(new TokenComponent("__token", new SimpleTypeUse("String")));
unresolvedDecl.addComponent(new TokenComponent("__resolve_opposite", new SimpleTypeUse("boolean")));
p.addTypeDecl(unresolvedDecl);
unresolvedDecls.add(unresolvedDecl);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment