From 5cf253a7dcf4f130ad367f2257535aa88ad9834d Mon Sep 17 00:00:00 2001 From: Johannes Mey <johannes.mey@tu-dresden.de> Date: Thu, 2 Jan 2020 16:09:03 +0100 Subject: [PATCH] reordering and some documentation to separate generatable and hand-written methods --- scope4j/src/main/jastadd/ProgramToScopeTree.jrag | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag index 3bdad9b..20955be 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(); -- GitLab