protected boolean addFieldImport(CtFieldReference ref) { // static import is not supported below java 1.5 if (ref.getFactory().getEnvironment().getComplianceLevel() < 5) { return false; } if (this.fieldImports.containsKey(ref.getSimpleName())) { return isImportedInFieldImports(ref); } if (declaringTypeIsLocalOrImported(ref.getDeclaringType())) { return false; } fieldImports.put(ref.getSimpleName(), ref); return true; }
protected boolean addMethodImport(CtExecutableReference ref) { // static import is not supported below java 1.5 if (ref.getFactory().getEnvironment().getComplianceLevel() < 5) { return false; } if (this.isImportedInMethodImports(ref)) { return true; } // if the whole class is imported: no need to import the method. if (declaringTypeIsLocalOrImported(ref.getDeclaringType())) { return false; } if (this.isInCollisionWithLocalMethod(ref)) { return false; } methodImports.put(ref.getSimpleName(), ref); // if we are in the same package than target type, we also import class to avoid FQN in FQN mode. if (ref.getDeclaringType() != null) { if (ref.getDeclaringType().getPackage() != null) { if (ref.getDeclaringType().getPackage().equals(this.targetType.getPackage())) { addClassImport(ref.getDeclaringType()); } } } return true; }