Commit 8a5cec44 authored by Johannes Mey's avatar Johannes Mey
Browse files

move name resolution methods, externalize additional names, fix naming problem...

move name resolution methods, externalize additional names, fix naming problem of the unresolved interface
parent c40c9d86
Pipeline #6111 passed with stage
in 2 minutes and 58 seconds
......@@ -23,47 +23,6 @@ aspect BackendAbstractGrammar {
}
}
public void TypeDecl.generateUnresolvedClass(StringBuilder sb) {
if (getAbstract()) {
sb.append(ind(1) + "abstract ");
} else {
sb.append(ind(1));
}
sb.append("class " + unresolvedPrefix + getID() + " extends " + getID() + " implements " + unresolvedPrefix + "Node {\n");
sb.append(ind(2) + "private String unresolved$Token;\n");
sb.append(ind(2) + "public String get" + unresolvedPrefix + "Token() {\n");
sb.append(ind(3) + "return unresolved$Token;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "void set" + unresolvedPrefix + "Token(String token) {\n");
sb.append(ind(3) + "this.unresolved$Token = token;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "private boolean unresolved$ResolveOpposite;\n");
sb.append(ind(2) + "public boolean get" + unresolvedPrefix + "ResolveOpposite() {\n");
sb.append(ind(3) + "return unresolved$ResolveOpposite;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "void set" + unresolvedPrefix + "ResolveOpposite(boolean resolveOpposite) {\n");
sb.append(ind(3) + "this.unresolved$ResolveOpposite = resolveOpposite;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + unresolvedPrefix + "Node " + getID() + "." + asUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return null;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + unresolvedPrefix + "Node " + unresolvedPrefix + getID() + "." + asUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return this;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + "boolean " + getID() + "." + isUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return false;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + "boolean " + unresolvedPrefix + getID() + "." + isUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return true;\n");
sb.append(ind(1) + "}\n");
}
public void TypeDecl.generateAbstractGrammar(StringBuilder sb) {
if (getAbstract()) {
sb.append("abstract ");
......
......@@ -55,8 +55,8 @@ aspect BackendBidirectionalAPI {
sb.append(ind(4) + ofTypeDecl() + " element = l.get(i);\n");
sb.append(ind(4) + "if (element." + isUnresolvedMethod + "()) {\n");
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(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + "" + resolvePostfix + "(element." + asUnresolvedMethod + "().get" + unresolvedTokenMethod + "(), i);\n");
sb.append(ind(5) + "if (resolvedElement != null && element." + asUnresolvedMethod + "().get" + unresolvedResolveOppositeMethod + "()) {\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");
......@@ -152,8 +152,8 @@ aspect BackendBidirectionalAPI {
sb.append(ind(4) + ofTypeDecl() + " element = l.get(i);\n");
sb.append(ind(4) + "if (element." + isUnresolvedMethod + "()) {\n");
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(5) + ofTypeDecl() + " resolvedElement = resolve" + nameCapitalized() + resolvePostfix + "(element." + asUnresolvedMethod + "().get" + unresolvedTokenMethod + "(), i);\n");
sb.append(ind(5) + "if (element." + asUnresolvedMethod + "().get" + unresolvedResolveOppositeMethod + "()) {\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");
......
......@@ -39,7 +39,7 @@ aspect BackendDirectedAPI {
sb.append(ind(4) + ofTypeDecl() + " element = l.get(i);\n");
sb.append(ind(4) + "if (element." + isUnresolvedMethod + "()) {\n");
sb.append(ind(5) + "changed = true;\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = " + resolvePrefix + "" + nameCapitalized() + "" + resolvePostfix + "(element." + asUnresolvedMethod + "()." + getUnresolvedTokenMethod + "(), i);\n");
sb.append(ind(5) + ofTypeDecl() + " resolvedElement = " + resolvePrefix + "" + nameCapitalized() + "" + resolvePostfix + "(element." + asUnresolvedMethod + "().get" + unresolvedTokenMethod + "(), i);\n");
sb.append(ind(5) + "l.set(i, resolvedElement);\n");
sb.append(ind(4) + "}\n");
sb.append(ind(3) + "}\n");
......
......@@ -3,8 +3,8 @@ aspect NameResolutionHelper {
protected static final String ASTNode.unresolvedPrefix = "Unresolved$";
protected static final String ASTNode.isUnresolvedMethod = "is$Unresolved";
protected static final String ASTNode.asUnresolvedMethod = "as$Unresolved";
protected static final String ASTNode.getUnresolvedTokenMethod = "get" + unresolvedPrefix + "Token";
protected static final String ASTNode.getUnresolvedResolveOppositeMethod = "get" + unresolvedPrefix + "ResolveOpposite";
protected static final String ASTNode.unresolvedTokenMethod = unresolvedPrefix + "Token";
protected static final String ASTNode.unresolvedResolveOppositeMethod = unresolvedPrefix + "ResolveOpposite";
protected static final String ASTNode.createReferenceMethod = "createReference";
protected static final String ASTNode.createRefMethod = "createRef";
protected static final String ASTNode.createRefDirectionMethod = "createRefDirection";
......@@ -13,6 +13,48 @@ aspect NameResolutionHelper {
protected static final String ASTNode.resolvePostfix = "ByToken";
protected static final String ASTNode.resolveAllMethod = "resolveAll";
protected static final String ASTNode.treeResolveAllMethod = "treeResolveAll";
protected static final String ASTNode.unresolvedNodeInterface = unresolvedPrefix + "Node$Interface";
public void TypeDecl.generateUnresolvedClass(StringBuilder sb) {
if (getAbstract()) {
sb.append(ind(1) + "abstract ");
} else {
sb.append(ind(1));
}
sb.append("class " + unresolvedPrefix + getID() + " extends " + getID() + " implements " + unresolvedNodeInterface + " {\n");
sb.append(ind(2) + "private String unresolved$Token;\n");
sb.append(ind(2) + "public String get" + unresolvedTokenMethod + "() {\n");
sb.append(ind(3) + "return unresolved$Token;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "void set" + unresolvedTokenMethod + "(String token) {\n");
sb.append(ind(3) + "this.unresolved$Token = token;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "private boolean unresolved$ResolveOpposite;\n");
sb.append(ind(2) + "public boolean get" + unresolvedResolveOppositeMethod + "() {\n");
sb.append(ind(3) + "return unresolved$ResolveOpposite;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(2) + "void set" + unresolvedResolveOppositeMethod + "(boolean resolveOpposite) {\n");
sb.append(ind(3) + "this.unresolved$ResolveOpposite = resolveOpposite;\n");
sb.append(ind(2) + "}\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + unresolvedNodeInterface + " " + getID() + "." + asUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return null;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + unresolvedNodeInterface + " " + unresolvedPrefix + getID() + "." + asUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return this;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + "boolean " + getID() + "." + isUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return false;\n");
sb.append(ind(1) + "}\n");
sb.append(ind(1) + "boolean " + unresolvedPrefix + getID() + "." + isUnresolvedMethod + "() {\n");
sb.append(ind(2) + "return true;\n");
sb.append(ind(1) + "}\n");
}
public String Program.generateRewriteToSuperTypeStub() {
StringBuilder sb = new StringBuilder();
......@@ -124,9 +166,9 @@ aspect NameResolutionHelper {
sb.append("aspect RefResolverHelpers {\n\n");
sb.append(ind(1) + "interface " + unresolvedPrefix + "Node {\n");
sb.append(ind(2) + "String " + getUnresolvedTokenMethod + "();\n");
sb.append(ind(2) + "boolean " + getUnresolvedResolveOppositeMethod + "();\n");
sb.append(ind(1) + "interface " + unresolvedNodeInterface + " {\n");
sb.append(ind(2) + "String get" + unresolvedTokenMethod + "();\n");
sb.append(ind(2) + "boolean get" + unresolvedResolveOppositeMethod + "();\n");
sb.append(ind(1) + "}\n\n");
for (TypeDecl td: getTypeDecls()) {
......
Markdown is supported
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