String (@NotNull PsiPackage aPackage) { final StringBuilder name = new StringBuilder(aPackage.getName()); for (PsiPackage parentPackage = aPackage.getParentPackage(); parentPackage != null; parentPackage = parentPackage.getParentPackage()) { final String packageName = parentPackage.getName(); if (packageName == null || packageName.isEmpty()) { break; // reached default package } name.insert(0, "."); if (packageName.length() > 2 && shouldAbbreviateName(parentPackage)) { name.insert(0, packageName.charAt(0)); } else { name.insert(0, packageName); } } return name.toString(); }