From 4fcbb2d09ed83ae1dce049f9c7f5719fee311ae2 Mon Sep 17 00:00:00 2001 From: Johannes Mey <johannes.mey@tu-dresden.de> Date: Wed, 1 Jan 2020 15:28:23 +0100 Subject: [PATCH] use more collection attributes --- .../src/main/jastadd/ProgramToScopeTree.jrag | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag index 8a8ef7f..b7af23b 100644 --- a/scope4j/src/main/jastadd/ProgramToScopeTree.jrag +++ b/scope4j/src/main/jastadd/ProgramToScopeTree.jrag @@ -1,23 +1,8 @@ aspect ProgramToScopeTree { - syn lazy ScopeTree Program.scopeTree() { - ScopeTree tree = new ScopeTree(); - tree.setProgram(this); - - 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()); - } - } + coll ScopeTree Program.scopeTree() [asScopeTree()] with addElement root Program; - 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; } -- GitLab