Skip to content
Snippets Groups Projects
Commit 613339be authored by Johannes Mey's avatar Johannes Mey
Browse files

add rewrite to structure and fix semantic grammar bug

parent 703f8a95
No related branches found
No related tags found
1 merge request!5Resolve "Structure View Support"
Pipeline #12042 passed
......@@ -128,7 +128,7 @@ aspect_inh_attribute_declaration ::= annotation* INH NTA? LAZY? FINAL? aspect_ty
}
// FIXME parentheses are not required around the WHEN expression?
aspect_rewrite ::= REWRITE aspect_name (ast_type_name DOT method_name LPAREN RPAREN)? LBRACE ((WHEN LPAREN expression RPAREN)? TO aspect_type ( expression SEMICOLON | block ))+ RBRACE
aspect_rewrite ::= REWRITE ast_type_name (ast_type_name DOT method_name LPAREN RPAREN)? LBRACE ((WHEN LPAREN expression RPAREN)? TO aspect_type ( expression SEMICOLON | block ))+ RBRACE
aspect_syn_equation ::= annotation* EQUATION ast_type_name DOT attribute_name LPAREN (type parameter_name (COMMA type parameter_name)*)? RPAREN ( ASSIGN expression SEMICOLON | block )
......
......@@ -133,6 +133,18 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
return AllIcons.Nodes.Method;
}
};
} else if (myElement instanceof JastAddAspectAspectRewrite) {
presentation = new ItemPresentation() {
@Override
public String getPresentableText() {
return AspectStructureViewElement.getPresentableText((JastAddAspectAspectRewrite) myElement);
}
@Override
public Icon getIcon(boolean unused) {
return JastAddIcons.REWRITE;
}
};
}
}
......@@ -161,6 +173,11 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
+ " : " + decl.getAspectType().getText();
}
private static String getPresentableText(JastAddAspectAspectRewrite rewrite) {
return "rewrite " + rewrite.getAstTypeNameList().get(0).getText()
+ " to " + rewrite.getAspectTypeList().stream().map(JastAddAspectAspectType::getText).collect(Collectors.joining("/"));
}
private static String getPresentableText(JastAddAspectAspectConstructorDeclaration decl) {
return decl.getModifiers().getText()
+ " " + decl.getAstTypeNameList().get(0).getText()
......@@ -217,6 +234,8 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
return new AspectStructureViewElement((JastAddAspectAspectFieldDeclarationImpl) decl.getAspectFieldDeclaration());
} else if (decl.getAspectConstructorDeclaration()!= null) {
return new AspectStructureViewElement((JastAddAspectAspectConstructorDeclarationImpl) decl.getAspectConstructorDeclaration());
}else if (decl.getAspectRewrite()!= null) {
return new AspectStructureViewElement((JastAddAspectAspectRewriteImpl) decl.getAspectRewrite());
}
return null;
})
......@@ -227,7 +246,6 @@ public class AspectStructureViewElement implements StructureViewTreeElement, Sor
// aspect_refine_method_declaration
// aspect_refine_constructor_declaration
// aspect_rewrite
// aspect_add_interface
// aspect_extend_interface
......
......@@ -14,6 +14,7 @@ public class JastAddIcons {
public static final Icon INH_ATTRIBUTE = ATTRIBUTE;
public static final Icon SYN_ATTRIBUTE = ATTRIBUTE;
public static final Icon INTERTYPE_DECL = IconLoader.getIcon("/META-INF/intertypeIcon.svg", JastAddIcons.class);
public static final Icon REWRITE = IconLoader.getIcon("/META-INF/rewriteIcon.svg", JastAddIcons.class);
private JastAddIcons() {
throw new IllegalStateException("Utility class");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment