Update of /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/asm In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32530/src/java/net/sf/clirr/core/internal/asm Modified Files: AsmField.java AsmMethod.java AsmJavaType.java ClassInfoCollector.java Log Message: actual implementation for getEffectiveScope() Index: AsmField.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/asm/AsmField.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AsmField.java 16 Mar 2006 22:30:19 -0000 1.1 +++ AsmField.java 22 Apr 2006 22:04:27 -0000 1.2 @@ -13,11 +13,13 @@ private final Object value; private final Type type; private final Repository repository; + private final AsmJavaType container; - AsmField(Repository repository, int access, String name, Object value, Type type) + AsmField(AsmJavaType container, int access, String name, Object value, Type type) { super(access); - this.repository = repository; + this.container = container; + this.repository = container.getRepository(); this.name = name; this.value = value; this.type = type; @@ -56,7 +58,9 @@ public Scope getEffectiveScope() { - return getDeclaredScope(); // TODO: FIXME + final Scope containerScope = container.getEffectiveScope(); + final Scope declaredScope = getDeclaredScope(); + return containerScope.isLessVisibleThan(declaredScope) ? containerScope : declaredScope; } } Index: AsmMethod.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/asm/AsmMethod.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- AsmMethod.java 29 Mar 2006 12:21:41 -0000 1.3 +++ AsmMethod.java 22 Apr 2006 22:04:27 -0000 1.4 @@ -18,12 +18,15 @@ private final Type[] argumentTypes; private final String[] exceptions; + + private AsmJavaType container; - AsmMethod(Repository repository, int access, Type returnType, + AsmMethod(AsmJavaType container, int access, Type returnType, String name, Type[] argumentTypes, String[] exceptions) { super(access); - this.repository = repository; + this.container = container; + this.repository = container.getRepository(); this.returnType = returnType; this.name = name; this.argumentTypes = argumentTypes; @@ -93,8 +96,9 @@ public Scope getEffectiveScope() { - // TODO Auto-generated method stub - return getDeclaredScope(); + final Scope containerScope = container.getEffectiveScope(); + final Scope declaredScope = getDeclaredScope(); + return containerScope.isLessVisibleThan(declaredScope) ? containerScope : declaredScope; } } Index: AsmJavaType.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/asm/AsmJavaType.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AsmJavaType.java 29 Mar 2006 12:21:41 -0000 1.2 +++ AsmJavaType.java 22 Apr 2006 22:04:27 -0000 1.3 @@ -27,7 +27,7 @@ private final String[] interfaceNames; - public AsmJavaType(Repository repository, int access, String basicName, String superClassName, String[] interfaceNames) + AsmJavaType(Repository repository, int access, String basicName, String superClassName, String[] interfaceNames) { super(access); this.repository = repository; @@ -36,7 +36,13 @@ this.interfaceNames = interfaceNames; } - + Repository getRepository() + { + return repository; + } + + + public String getBasicName() { return basicName; @@ -50,8 +56,13 @@ public JavaType getContainingClass() { - // TODO Auto-generated method stub - return null; + int idx = basicName.lastIndexOf('$'); + if (idx == -1) + { + return null; + } + // TODO: bug #1022446 + return repository.findTypeByName(basicName.substring(0, idx)); } public JavaType[] getSuperClasses() @@ -88,12 +99,6 @@ return ret; } - public JavaType[] getInnerClasses() - { - // TODO Auto-generated method stub - return null; - } - void addMethod(Method method) { methods.add(method); @@ -120,13 +125,13 @@ public boolean isPrimitive() { - // TODO Auto-generated method stub + // primitives are represented by PrimitiveType return false; } public int getArrayDimension() { - // TODO: handle correctly for method argument and return types + // array types are represented by ArrayType return 0; } @@ -147,8 +152,15 @@ public Scope getEffectiveScope() { - // TODO: replace with real impl - return getDeclaredScope(); + JavaType container = getContainingClass(); + final Scope declaredScope = getDeclaredScope(); + if (container == null) + { + return declaredScope; + } + + Scope containerScope = container.getEffectiveScope(); + return containerScope.isLessVisibleThan(declaredScope) ? containerScope : declaredScope; } Index: ClassInfoCollector.java =================================================================== RCS file: /cvsroot/clirr/clirr/core/src/java/net/sf/clirr/core/internal/asm/ClassInfoCollector.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ClassInfoCollector.java 16 Mar 2006 22:30:19 -0000 1.1 +++ ClassInfoCollector.java 22 Apr 2006 22:04:27 -0000 1.2 @@ -33,7 +33,7 @@ public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { Type type = Type.getType(desc); - final AsmField asmField = new AsmField(repository, access, name, value, type); + final AsmField asmField = new AsmField(javaType, access, name, value, type); javaType.addField(asmField); // currently no need for visiting annotations @@ -45,7 +45,7 @@ final Type[] argumentTypes = Type.getArgumentTypes(desc); final Type returnType = Type.getReturnType(desc); final AsmMethod asmMethod = - new AsmMethod(repository, access, returnType, name, argumentTypes, exceptions); + new AsmMethod(javaType, access, returnType, name, argumentTypes, exceptions); javaType.addMethod(asmMethod); // currently no need for visiting annotations |