Skip to content
Snippets Groups Projects

Clean-up, document and rename some attributes.

Merged René Schöne requested to merge cleanup into master
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,
@@ -86,18 +80,26 @@ aspect ComponentAnalysis {
/**
* Check, if a component with the same name is already declared in some supertype
*/
syn boolean Component.isInvalidRedefinition() {
TypeDecl td = toTypeDecl();
if (td == null) return false;
syn boolean Component.isInvalidRedefinition() = invalidRedefinition() != null;
/**
* Check, if a component with the same name is already declared in some supertype, and return it, if any
*/
syn Component Component.invalidRedefinition() = null;
eq TokenComponent.invalidRedefinition() = invalidRedefinitionOn(enclosingTypeDecl());
eq RelationComponent.invalidRedefinition() = invalidRedefinitionOn(getTypeUse().decl());
syn Component Component.invalidRedefinitionOn(TypeDecl td) {
if (td == null) return null;
while (td.hasSuper() && td.getSuper().decl() != null) {
td = td.getSuper().decl();
// find a matching component on the RHS of the (current) super type
Component c = findComponent(td, getID());
if (c != null && !this.isEqual(c)) return true;
if (c != null && !this.isEqual(c)) return c;
}
return false;
return null;
}
//--- isEqual ---
@@ -121,16 +123,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