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

treat all TypeDecls equally

parent 0bb3a16e
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ aspect ProgramToScopeTree {
// add all classes
for (CompilationUnit cu : getCompilationUnitList()) {
for (TypeDecl typeDecl : cu.getTypeDeclList()) {
tree.addElement(typeDecl.isClassDecl() ? ((ClassDecl)typeDecl).protectedScope() : typeDecl.scope());
tree.addElement(typeDecl.protectedScope());
}
}
......@@ -43,22 +43,21 @@ aspect ProgramToScopeTree {
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;
coll TypeDeclScope ClassDecl.packageScope() [asPackageScope()] with addElement root Program;
coll TypeDeclScope TypeDecl.protectedScope() [asProtectedScope()] with addElement root Program;
coll TypeDeclScope TypeDecl.packageScope() [asPackageScope()] with addElement root Program;
// collect all scopes
TypeDecl contributes scope() when !isNestedType() && !isClassDecl() to ASTNode.scope() for containingScope();
ClassDecl contributes protectedScope() when isNestedType() to ASTNode.scope() for containingScope();
TypeDecl contributes protectedScope() when isNestedType() to ASTNode.scope() for containingScope();
Block contributes scope() to ASTNode.scope() for containingScope();
ForStmt contributes scope() when !(getStmt() instanceof Block) to ASTNode.scope() for containingScope();
EnhancedForStmt contributes scope() when !(getStmt() instanceof Block) to ASTNode.scope() for containingScope();
// collect all elements
Declarator contributes asDeclaration() when !isField() || isPrivate() to ASTNode.scope() for containingScope();
Declarator contributes asDeclaration() when /* is NOT in interface || */ !isField() || isPrivate() to ASTNode.scope() for containingScope();
// field which is neither private, protected, nor public -> package-private scope
Declarator contributes asDeclaration() when isField() && !isPrivate() && !(isProtected() || isPublic()) to ClassDecl.packageScope() for containingScope();
Declarator contributes asDeclaration() when isField() && !isPrivate() && !(isProtected() || isPublic()) to TypeDecl.packageScope() for containingScope();
// field which is either protected or public -> protected scope
Declarator contributes asDeclaration() when isField() && !isPrivate() && (isProtected() || isPublic()) to ClassDecl.protectedScope() for containingScope();
Declarator contributes asDeclaration() when /* is in interface && */ isField() && !isPrivate() && (isProtected() || isPublic()) to TypeDecl.protectedScope() for containingScope();
ParameterDeclaration contributes asDeclaration() to ASTNode.scope() for containingScope();
}
......@@ -80,25 +79,19 @@ aspect ScopeTreeConstructors {
}
syn lazy TypeDeclScope TypeDecl.asScope() {
TypeDeclScope scope = new TypeDeclScope();
scope.setTypeDecl(this);
return scope;
}
syn lazy TypeDeclScope ClassDecl.asScope() {
TypeDeclScope scope = new PrivateClassDeclScope();
scope.setTypeDecl(this);
return scope;
}
syn lazy TypeDeclScope ClassDecl.asProtectedScope() {
syn lazy TypeDeclScope TypeDecl.asProtectedScope() {
TypeDeclScope scope = new ProtectedClassDeclScope();
scope.setTypeDecl(this);
scope.addElement(packageScope());
return scope;
}
syn lazy TypeDeclScope ClassDecl.asPackageScope() {
syn lazy TypeDeclScope TypeDecl.asPackageScope() {
TypeDeclScope scope = new PackageClassDeclScope();
scope.setTypeDecl(this);
scope.addElement(scope());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment