diff --git a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag index 3bdad9b7e2ea11387a30f27e88ec07398a82b380..20955beb656d2e069117ebe68a13a1522aa5c377 100644 --- a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag +++ b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag @@ -1,11 +1,13 @@ aspect ProgramToScopeTree { + /** a relational nta collection attribute to compute the scope tree */ coll ScopeTree Program.scopeTree() [asScopeTree()] with addElement root Program; - TypeDecl contributes scope() when !isClassDecl() to Program.scopeTree(); ClassDecl contributes protectedScope() when !isInnerType() && !superclass().compilationUnit().fromSource() to Program.scopeTree(); - /** a relational nta collection attribute to compute the scope tree */ + /** a relational nta collection attribute to compute scopes */ coll Scope ASTNode.scope() [asScope()] with addElement root Program; + + /** a relational nta collection attribute to compute a special scope containing visible fields and subtypes */ coll TypeDeclScope ClassDecl.protectedScope() [asProtectedScope()] with addElement root Program; // collect all scopes @@ -26,9 +28,14 @@ aspect ProgramToScopeTree { Declarator contributes asDeclaration() when !isField() || isPrivate() to ASTNode.scope() for containingScope(); Declarator contributes asDeclaration() when isField() && !isPrivate() to ClassDecl.protectedScope() for containingScope(); ParameterDeclaration contributes asDeclaration() to ASTNode.scope() for containingScope(); +} - // if it was not for the single line in asProtectedScope(), the rest of this aspect could have been generated - // automatically, which would have been much nicer! +/** + * ascpect containing helper methods to construct (mostly empty) AST nodes of the scope tree + * If it was not for the single line in asProtectedScope(), the rest of this aspect could have been generated + * automatically, which would have been much nicer! + */ +aspect ScopeTreeConstructors { syn lazy ScopeTree Program.asScopeTree() { ScopeTree tree = new ScopeTree();