Don't add import if there's general import with .* exist
This commit is contained in:
@@ -138,6 +138,17 @@ public class JetPsiUtil {
|
||||
return jetClass.getName();
|
||||
}
|
||||
|
||||
@Nullable @JetElement.IfNotParsed
|
||||
public static String getImportPath(JetImportDirective importDirective) {
|
||||
final JetExpression importedReference = importDirective.getImportedReference();
|
||||
if (importedReference == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final String text = importedReference.getText();
|
||||
return text.replaceAll(" ", "") + (importDirective.isAllUnder() ? ".*" : "");
|
||||
}
|
||||
|
||||
private static String makeFQName(String prefix, JetClassOrObject jetClass) {
|
||||
return ((prefix == null || prefix.length() == 0) ? "" : prefix + ".") + jetClass.getName();
|
||||
}
|
||||
|
||||
@@ -100,4 +100,19 @@ public final class QualifiedNamesUtil {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that given fqn could be imported with import.
|
||||
*
|
||||
* @param importPath path from the import. Could contain .* part
|
||||
* @param fqn
|
||||
* @return
|
||||
*/
|
||||
public static boolean isImported(@NotNull String importPath, @NotNull String fqn) {
|
||||
if (importPath.endsWith("*")) {
|
||||
return withoutLastSegment(importPath).equals(withoutLastSegment(fqn));
|
||||
}
|
||||
|
||||
return importPath.equals(fqn);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user