Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions codemodel/src/main/java/com/sun/codemodel/JFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

package com.sun.codemodel;

import com.sun.org.apache.xml.internal.security.encryption.ReferenceList;

import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
Expand Down Expand Up @@ -473,17 +475,26 @@ private boolean supressImport(JClass clazz, JClass c) {
if(packageName.equals("java.lang"))
return true; // no need to explicitly import java.lang classes

if (clazz._package() == c._package()){
if (clazz._package() == c._package()) {
// inner classes require an import stmt.
// All other pkg local classes do not need an
// import stmt for ref.
if(clazz.outer()==null) {
return true; // no need to explicitly import a class into itself
}
// no need to explicitly import a class into itself
return clazz.outer() == null || isInnerClass(clazz, c);
}
return false;
}

private boolean isInnerClass(JClass clazz, JClass c){
if(clazz.outer() == null){
return false;
}
else if(clazz.outer().equals(c)){
return true;
}
return isInnerClass(clazz.outer(), c);
}

private JPackage javaLang;


Expand Down