private void importAllMembers( TypeDeclaration importedType, Set<String> ignoredMembers, ImportList til) { for (Declaration dec : importedType.getMembers()) { if (dec.isShared() && (dec.isStaticallyImportable() || isConstructor(dec)) && isResolvable(dec) && !ignoredMembers.contains(dec.getName())) { addWildcardImport(til, dec, importedType); } } }
private String importMember(Tree.ImportMemberOrType member, TypeDeclaration td, ImportList il) { Tree.Identifier id = member.getIdentifier(); if (id == null) { return null; } Import i = new Import(); member.setImportModel(i); Tree.Alias alias = member.getAlias(); String name = name(id); if (alias == null) { i.setAlias(name); } else { i.setAlias(name(alias.getIdentifier())); } Declaration m = td.getMember(name, null, false); if (m == null) { String correction = correct(td, null, unit, name); String message = correction == null ? "" : " (did you mean '" + correction + "'?)"; id.addError( "imported declaration not found: '" + name + "' of '" + td.getName() + "'" + message, 100); unit.getUnresolvedReferences().add(id); } else { List<Declaration> members = m.getContainer().getMembers(); for (Declaration d : members) { String dn = d.getName(); if (dn != null && dn.equals(name) && !d.sameKind(m) && !d.isAnonymous()) { // crazy interop cases like isOpen() + open() id.addError("ambiguous member declaration: '" + name + "' of '" + td.getName() + "'"); return null; } } if (!m.isShared()) { id.addError( "imported declaration is not shared: '" + name + "' of '" + td.getName() + "'", 400); } else if (!declaredInPackage(m, unit)) { if (m.isPackageVisibility()) { id.addError( "imported package private declaration is not visible: '" + name + "' of '" + td.getName() + "'"); } else if (m.isProtectedVisibility()) { id.addError( "imported protected declaration is not visible: '" + name + "' of '" + td.getName() + "'"); } } i.setTypeDeclaration(td); if (!m.isStaticallyImportable() && !isToplevelClassConstructor(td, m) && !isToplevelAnonymousClass(m.getContainer())) { if (alias == null) { member.addError("does not specify an alias"); } } i.setDeclaration(m); member.setDeclarationModel(m); if (il.hasImport(m)) { id.addError("already imported: '" + name + "' of '" + td.getName() + "'"); } else { if (m.isStaticallyImportable() || isToplevelClassConstructor(td, m) || isToplevelAnonymousClass(m.getContainer())) { if (!checkForHiddenToplevel(id, i, alias)) { addImport(member, il, i); } } else { addMemberImport(member, il, i); } } checkAliasCase(alias, m); } if (m != null) { importMembers(member, m); } // imtl.addError("member aliases may not have member aliases"); return name; }