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 {
syn lazy ScopeTree Program.scopeTree() {
ScopeTree tree = new ScopeTree();
tree.setProgram(this);
coll ScopeTree Program.scopeTree() [asScopeTree()] with addElement root Program;
for (CompilationUnit compilationUnit : getCompilationUnitList())
for (TypeDecl typeDecl : compilationUnit.getTypeDeclList()) {
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;
}
TypeDecl contributes scope() when !isClassDecl() to Program.scopeTree();
ClassDecl contributes publicScope() when !isInnerType() && !superclass().compilationUnit().fromSource() to Program.scopeTree();
/** a relational nta collection attribute to compute the scope tree */
coll Scope ASTNode.scope() [asScope()] with addElement root Program;
......@@ -50,7 +35,6 @@ aspect ProgramToScopeTree {
syn lazy ScopeTree Program.asScopeTree() {
ScopeTree tree = new ScopeTree();
tree.setProgram(this);
return tree;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment