Skip to content
Snippets Groups Projects

Clean-up, document and rename some attributes.

Merged René Schöne requested to merge cleanup into master
6 files
+ 56
54
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -30,12 +30,6 @@ aspect ComponentAnalysis {
//--- name ---
syn String Component.name() = getID();
//--- toTypeDecl ---
/** @return enclosing type */
syn TypeDecl Component.toTypeDecl() = enclosingTypeDecl();
/** @return type of nonterminal relation role is defined for */
eq RelationComponent.toTypeDecl() = getTypeUse().decl();
//--- enclosingTypeDecl ---
inh TypeDecl Component.enclosingTypeDecl();
eq TypeDecl.getChild().enclosingTypeDecl() = this;
@@ -48,7 +42,7 @@ aspect ComponentAnalysis {
eq Program.getChild().otherSide() = null;
//--- ofTypeDecl ---
syn TypeDecl RelationComponent.ofTypeDecl() = otherSide().toTypeDecl();
syn TypeDecl RelationComponent.ofTypeDecl() = otherSide().getTypeUse().decl();
//--- isAlreadyDeclared ---
/**
@@ -56,8 +50,8 @@ aspect ComponentAnalysis {
*/
syn boolean RelationComponent.isAlreadyDeclared()
= !isTargetOfDirectedRelation() /* if unnamed in relation, there is no role name, so no error */
&& toTypeDecl() != null /* nonterminal type of role is defined */
&& findComponent(toTypeDecl(), name()) != this; /* there is another role defined previously with the same name */
&& getTypeUse().decl() != null /* nonterminal type of role is defined */
&& findComponent(getTypeUse().decl(), name()) != this; /* there is another role defined previously with the same name */
//--- findComponent ---
/** Search for either a component on the RHS of the given type with the given name,
@@ -82,12 +76,16 @@ aspect ComponentAnalysis {
return null;
}
/* Should this better return the component, where it is defined previously defined? */
//--- isInvalidRedefinition ---
/**
* Check, if a component with the same name is already declared in some supertype
*/
syn boolean Component.isInvalidRedefinition() {
TypeDecl td = toTypeDecl();
syn boolean Component.isInvalidRedefinition() = false;
eq TokenComponent.isInvalidRedefinition() = hasInvalidRedefinitionOn(enclosingTypeDecl());
eq RelationComponent.isInvalidRedefinition() = hasInvalidRedefinitionOn(getTypeUse().decl());
syn boolean Component.hasInvalidRedefinitionOn(TypeDecl td) {
if (td == null) return false;
while (td.hasSuper() && td.getSuper().decl() != null) {
@@ -121,16 +119,16 @@ aspect ComponentAnalysis {
* @return true, if the component has both type and role, its type matches the given typeDecl and its name matches the given name
*/
syn boolean RelationComponent.matches(TypeDecl td, String name)
= !isTargetOfDirectedRelation() && toTypeDecl() == td && name().equals(name);
= !isTargetOfDirectedRelation() && getTypeUse().decl() == td && name().equals(name);
//--- relationComponents ---
coll Set<RelationComponent> TypeDecl.relationComponents()
[new HashSet<RelationComponent>()]
root Program;
RelationComponent contributes this
when !isTargetOfDirectedRelation() && toTypeDecl() != null
when !isTargetOfDirectedRelation() && getTypeUse().decl() != null
to TypeDecl.relationComponents()
for toTypeDecl();
for getTypeUse().decl();
//--- relationComponentsTransitive ---
syn Collection<RelationComponent> TypeDecl.relationComponentsTransitive() {
Loading