@Nullable public static Name getAliasName(@NotNull JetImportDirective importDirective) { String aliasName = importDirective.getAliasName(); JetExpression importedReference = importDirective.getImportedReference(); if (importedReference == null) { return null; } JetSimpleNameExpression referenceExpression = getLastReference(importedReference); if (aliasName == null) { aliasName = referenceExpression != null ? referenceExpression.getReferencedName() : null; } return aliasName != null && !aliasName.isEmpty() ? Name.identifier(aliasName) : null; }
@Nullable @IfNotParsed public static ImportPath getImportPath(@NotNull JetImportDirective importDirective) { if (PsiTreeUtil.hasErrorElements(importDirective)) { return null; } FqName importFqn = getFQName(importDirective.getImportedReference()); if (importFqn == null) { return null; } Name alias = null; String aliasName = importDirective.getAliasName(); if (aliasName != null) { alias = Name.identifier(aliasName); } return new ImportPath(importFqn, importDirective.isAllUnder(), alias); }