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

use more collection attributes

parent aadf220e
No related branches found
No related tags found
No related merge requests found
aspect ProgramToScopeTree { aspect ProgramToScopeTree {
syn lazy ScopeTree Program.scopeTree() { coll ScopeTree Program.scopeTree() [asScopeTree()] with addElement root Program;
ScopeTree tree = new ScopeTree();
tree.setProgram(this);
for (CompilationUnit compilationUnit : getCompilationUnitList()) TypeDecl contributes scope() when !isClassDecl() to Program.scopeTree();
for (TypeDecl typeDecl : compilationUnit.getTypeDeclList()) { ClassDecl contributes publicScope() when !isInnerType() && !superclass().compilationUnit().fromSource() to Program.scopeTree();
if (typeDecl.isClassDecl()) {
// do not add the TypeDecl, if it has a superclass from source
ClassDecl classDecl = (ClassDecl)typeDecl;
if (!classDecl.superclass().compilationUnit().fromSource()) {
tree.addElement(((ClassDecl)typeDecl).publicScope());
}
} else {
tree.addElement(typeDecl.scope());
}
}
return tree;
}
/** a relational nta collection attribute to compute the scope tree */ /** a relational nta collection attribute to compute the scope tree */
coll Scope ASTNode.scope() [asScope()] with addElement root Program; coll Scope ASTNode.scope() [asScope()] with addElement root Program;
...@@ -50,7 +35,6 @@ aspect ProgramToScopeTree { ...@@ -50,7 +35,6 @@ aspect ProgramToScopeTree {
syn lazy ScopeTree Program.asScopeTree() { syn lazy ScopeTree Program.asScopeTree() {
ScopeTree tree = new ScopeTree(); ScopeTree tree = new ScopeTree();
tree.setProgram(this); tree.setProgram(this);
return tree; return tree;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment