give a scopeType for getClassString

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@765 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent fe82f8f2c7
commit 82af4162ab
  1. 24
      jode/jode/decompiler/TabbedPrintWriter.java

@ -178,7 +178,7 @@ public class TabbedPrintWriter {
return null; return null;
} }
public String getInnerClassString(ClassInfo info) { public String getInnerClassString(ClassInfo info, int scopeType) {
InnerClassInfo[] outers = info.getOuterClasses(); InnerClassInfo[] outers = info.getOuterClasses();
if (outers == null) if (outers == null)
return null; return null;
@ -188,7 +188,7 @@ public class TabbedPrintWriter {
Scope scope = getScope(ClassInfo.forName(outers[i].outer), Scope scope = getScope(ClassInfo.forName(outers[i].outer),
Scope.CLASSSCOPE); Scope.CLASSSCOPE);
if (scope != null && if (scope != null &&
!conflicts(outers[i].name, scope, Scope.AMBIGUOUSNAME)) { !conflicts(outers[i].name, scope, scopeType)) {
StringBuffer sb = new StringBuffer(outers[i].name); StringBuffer sb = new StringBuffer(outers[i].name);
for (int j = i; j-- > 0;) { for (int j = i; j-- > 0;) {
sb.append('.').append(outers[j].name); sb.append('.').append(outers[j].name);
@ -197,14 +197,14 @@ public class TabbedPrintWriter {
} }
} }
String name = getClassString String name = getClassString
(ClassInfo.forName(outers[outers.length-1].outer)); (ClassInfo.forName(outers[outers.length-1].outer), scopeType);
StringBuffer sb = new StringBuffer(name); StringBuffer sb = new StringBuffer(name);
for (int j = outers.length; j-- > 0;) for (int j = outers.length; j-- > 0;)
sb.append('.').append(outers[j].name); sb.append('.').append(outers[j].name);
return sb.toString(); return sb.toString();
} }
public String getAnonymousClassString(ClassInfo info) { public String getAnonymousClassString(ClassInfo info, int scopeType) {
InnerClassInfo[] outers = info.getOuterClasses(); InnerClassInfo[] outers = info.getOuterClasses();
if (outers == null) if (outers == null)
return null; return null;
@ -217,7 +217,7 @@ public class TabbedPrintWriter {
outers[i].outer == null outers[i].outer == null
? Scope.METHODSCOPE : Scope.CLASSSCOPE); ? Scope.METHODSCOPE : Scope.CLASSSCOPE);
if (scope != null && if (scope != null &&
!conflicts(outers[i].name, scope, Scope.AMBIGUOUSNAME)) { !conflicts(outers[i].name, scope, scopeType)) {
StringBuffer sb = new StringBuffer(outers[i].name); StringBuffer sb = new StringBuffer(outers[i].name);
for (int j = i; j-- > 0;) { for (int j = i; j-- > 0;) {
sb.append('.').append(outers[j].name); sb.append('.').append(outers[j].name);
@ -238,31 +238,33 @@ public class TabbedPrintWriter {
} }
} }
String name = getClassString String name = getClassString
(ClassInfo.forName(outers[outers.length-1].outer)); (ClassInfo.forName(outers[outers.length-1].outer), scopeType);
StringBuffer sb = new StringBuffer(name); StringBuffer sb = new StringBuffer(name);
for (int j = outers.length; j-- > 0;) for (int j = outers.length; j-- > 0;)
sb.append('.').append(outers[j].name); sb.append('.').append(outers[j].name);
return sb.toString(); return sb.toString();
} }
public String getClassString(ClassInfo clazz) { public String getClassString(ClassInfo clazz, int scopeType) {
String name = clazz.getName(); String name = clazz.getName();
if (name.indexOf('$') >= 0) { if (name.indexOf('$') >= 0) {
if ((Decompiler.options & Decompiler.OPTION_INNER) != 0) { if ((Decompiler.options & Decompiler.OPTION_INNER) != 0) {
String innerClassName = getInnerClassString(clazz); String innerClassName
= getInnerClassString(clazz, scopeType);
if (innerClassName != null) if (innerClassName != null)
return innerClassName; return innerClassName;
} }
if ((Decompiler.options if ((Decompiler.options
& Decompiler.OPTION_ANON) != 0) { & Decompiler.OPTION_ANON) != 0) {
String innerClassName = getAnonymousClassString(clazz); String innerClassName
= getAnonymousClassString(clazz, scopeType);
if (innerClassName != null) if (innerClassName != null)
return innerClassName; return innerClassName;
} }
} }
if (imports != null) { if (imports != null) {
String importedName = imports.getClassString(clazz); String importedName = imports.getClassString(clazz);
if (!conflicts(importedName, null, Scope.AMBIGUOUSNAME)) if (!conflicts(importedName, null, scopeType))
return importedName; return importedName;
} }
if (conflicts(name, null, Scope.AMBIGUOUSNAME)) if (conflicts(name, null, Scope.AMBIGUOUSNAME))
@ -275,7 +277,7 @@ public class TabbedPrintWriter {
return getTypeString(((ArrayType) type).getElementType()) + "[]"; return getTypeString(((ArrayType) type).getElementType()) + "[]";
else if (type instanceof ClassInterfacesType) { else if (type instanceof ClassInterfacesType) {
ClassInfo clazz = ((ClassInterfacesType) type).getClassInfo(); ClassInfo clazz = ((ClassInterfacesType) type).getClassInfo();
return getClassString(clazz); return getClassString(clazz, Scope.CLASSNAME);
} else if (type instanceof NullType) } else if (type instanceof NullType)
return "Object"; return "Object";
else else

Loading…
Cancel
Save