mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Do not add import statement for java.lang classes when replacing fqn with import (IDEA-134529)
This commit is contained in:
+28
-4
@@ -289,7 +289,33 @@ class Test {
|
||||
assert !myFixture.filterAvailableIntentions("Import class")
|
||||
}
|
||||
|
||||
public void "test allow to add import from javadoc"() {
|
||||
public void "test allow to add import from javadoc"() {
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class Test {
|
||||
|
||||
/**
|
||||
* {@link java.util.Ma<caret>p}
|
||||
*/
|
||||
void run() {
|
||||
}
|
||||
}
|
||||
'''
|
||||
reimportClass()
|
||||
myFixture.checkResult '''\
|
||||
import java.util.Map;
|
||||
|
||||
class Test {
|
||||
|
||||
/**
|
||||
* {@link Map}
|
||||
*/
|
||||
void run() {
|
||||
}
|
||||
}
|
||||
'''
|
||||
}
|
||||
|
||||
public void "test do not add import for default package"() {
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class Test {
|
||||
|
||||
@@ -301,9 +327,7 @@ class Test {
|
||||
}
|
||||
'''
|
||||
reimportClass()
|
||||
myFixture.checkResult '''\
|
||||
import java.lang.Math;
|
||||
|
||||
myFixture.checkResult '''
|
||||
class Test {
|
||||
|
||||
/**
|
||||
|
||||
+3
@@ -60,6 +60,9 @@ public final class ImportUtils {
|
||||
}
|
||||
final String containingPackageName = javaFile.getPackageName();
|
||||
@NonNls final String packageName = ClassUtil.extractPackageName(qualifiedName);
|
||||
if (CommonClassNames.DEFAULT_PACKAGE.equals(packageName)) {
|
||||
return;
|
||||
}
|
||||
if (containingPackageName.equals(packageName) || importList.findSingleClassImportStatement(qualifiedName) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user