mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-83774 Completion for anonymous class is incorrectly aligned when class is not accessible in the scope
This commit is contained in:
@@ -747,6 +747,7 @@ public class JavaCompletionUtil {
|
||||
final String qName = psiClass.getQualifiedName();
|
||||
if (qName != null) {
|
||||
document.replaceString(newElement.getTextRange().getStartOffset(), newEndOffset, qName);
|
||||
newEndOffset = newElement.getTextRange().getStartOffset() + qName.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
{
|
||||
bar.Bar.accept(new foo.Foo() {
|
||||
});
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
{
|
||||
bar.Bar.accept(new <caret>)
|
||||
}
|
||||
}
|
||||
+19
-5
@@ -1,9 +1,12 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.StdModuleTypes;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
@SuppressWarnings(["ALL"])
|
||||
public class HeavySmartTypeCompletion15Test extends JavaCodeInsightFixtureTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartType";
|
||||
|
||||
@@ -15,7 +18,7 @@ public class HeavySmartTypeCompletion15Test extends JavaCodeInsightFixtureTestCa
|
||||
public void testGetInstance() throws Throwable {
|
||||
myFixture.configureFromExistingVirtualFile(
|
||||
myFixture.copyFileToProject(BASE_PATH + "/foo/" + getTestName(false) + ".java", "foo/" + getTestName(false) + ".java"));
|
||||
performAction();
|
||||
myFixture.complete(CompletionType.SMART);
|
||||
myFixture.type('\n');
|
||||
myFixture.checkResultByFile(BASE_PATH + "/foo/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
@@ -64,7 +67,7 @@ public class HeavySmartTypeCompletion15Test extends JavaCodeInsightFixtureTestCa
|
||||
|
||||
private void configure() {
|
||||
myFixture.configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
performAction();
|
||||
myFixture.complete(CompletionType.SMART);
|
||||
}
|
||||
|
||||
public void testClassLiteralShouldInsertImport() throws Throwable {
|
||||
@@ -76,8 +79,19 @@ public class HeavySmartTypeCompletion15Test extends JavaCodeInsightFixtureTestCa
|
||||
checkResult();
|
||||
}
|
||||
|
||||
private void performAction() {
|
||||
myFixture.complete(CompletionType.SMART);
|
||||
public void testInaccessibleClassAfterNew() {
|
||||
Module moduleA = PsiTestUtil.addModule(project, StdModuleTypes.JAVA, 'A', myFixture.tempDirFixture.findOrCreateDir("a"))
|
||||
Module moduleB = PsiTestUtil.addModule(project, StdModuleTypes.JAVA, 'B', myFixture.tempDirFixture.findOrCreateDir("b"))
|
||||
|
||||
PsiTestUtil.addDependency(myModule, moduleB)
|
||||
PsiTestUtil.addDependency(moduleB, moduleA)
|
||||
|
||||
myFixture.addFileToProject('a/foo/Foo.java', 'package foo; public interface Foo {}')
|
||||
myFixture.addFileToProject('b/bar/Bar.java', 'package bar; public class Bar { public static void accept(foo.Foo i) {} }')
|
||||
|
||||
configure()
|
||||
myFixture.type('\n')
|
||||
checkResult()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user