Skip to content
Snippets Groups Projects
Commit be0656bd authored by René Schöne's avatar René Schöne
Browse files

Fixed inherited scopes.

- also added hashCodes to printed ASTs
parent c31c3c87
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ aspect Shadowing {
Declaration contributes new VariableShadowFinding(shadowed(), this) when isShadowing() to ScopeTree.variableShadowings();
Declaration contributes new MultipleDeclarationFinding(this) when isShadowingInSameScope() to ScopeTree.variableShadowings();
syn Declaration Declaration.shadowed()= shadowed(asDeclaration());
syn Declaration Declaration.shadowed() = shadowed(asDeclaration());
inh Declaration Element.shadowed(Declaration shadower);
eq Scope.getElement().shadowed(Declaration shadower) = shadowedLocally(shadower);
......@@ -16,7 +16,7 @@ aspect Shadowing {
return declaration;
}
}
// the look in the inherited scopes
// then look in the inherited scopes
for (Scope inherited : getInheritedScopeList()) {
Declaration shadowed = inherited.shadowedLocally(shadower);
if (shadowed != null) {
......
......@@ -133,10 +133,7 @@ jastadd {
}
run {
mainClassName = 'org.extendj.SccChecker'
if (project.hasProperty("appArgs")) {
args Eval.me(appArgs)
}
mainClassName = 'org.extendj.ScopeAnalysis'
}
task preprocess(type: JavaExec) {
......
......@@ -2,7 +2,7 @@ aspect Debugging {
public String ASTNode.getASTString() {
String result = this.getClass().getSimpleName() + "\n";
String result = this.getClass().getSimpleName() + " (@" + this.hashCode() + ")\n";
for (java.lang.reflect.Method method : this.getClass().getMethods()) {
ASTNodeAnnotation.Token annotation = method.getAnnotation(ASTNodeAnnotation.Token.class);
......@@ -14,7 +14,8 @@ aspect Debugging {
} else {
name += ":= ";
}
result += "|--" + name + method.invoke(this);
Object methodResult = method.invoke(this);
result += "|--" + name + methodResult + (methodResult == null ? "" : " (@" + methodResult.hashCode() + ")");
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (java.lang.reflect.InvocationTargetException e) {
......
......@@ -27,8 +27,13 @@ aspect ProgramToScopeTree {
public void ProtectedClassDeclScope.updateInheritance() {
if (getTypeDecl().isClassDecl()) {
ClassDecl classDecl = (ClassDecl)getTypeDecl();
if(classDecl.superclass().isClassDecl() && classDecl.superclass().compilationUnit().fromSource()) {
addInheritedScope(((ClassDecl)classDecl.superclass()).asPackageScope());
if (classDecl.superclass().isClassDecl() && classDecl.superclass().compilationUnit().fromSource()) {
ClassDecl superDecl = (ClassDecl)classDecl.superclass();
if (classDecl.hostPackage().equals(superDecl.hostPackage())) {
addInheritedScope(superDecl.asPackageScope());
} else {
addInheritedScope(superDecl.asProtectedScope());
}
}
}
super.updateInheritance();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment