line separators normalized

This commit is contained in:
Roman Shevchenko
2012-12-08 20:01:21 +01:00
parent 175bc399f4
commit 91c10b815e
320 changed files with 60697 additions and 60697 deletions
@@ -1,5 +1,5 @@
public class Util {
int goo() {
ret<caret>cond ? 1: 0;
}
}
public class Util {
int goo() {
ret<caret>cond ? 1: 0;
}
}
@@ -1,7 +1,7 @@
class Util {
void foox() {
int fooy;
foo<caret>
}
class Util {
void foox() {
int fooy;
foo<caret>
}
}
@@ -1,17 +1,17 @@
class Foo {
int ELXEMENT_A = 1;
int ELXEMENT_B = 1;
int ELXEMENT_C = 1;
int ELXEMENT_D = 1;
int ELXEMENT_E = 1;
int ELXEMENT_F = 1;
int ELXEMENT_G = 1;
int ELXEMENT_H = 1;
int ELXEMENT_I = 1;
{
Elx<caret>
}
class Foo {
int ELXEMENT_A = 1;
int ELXEMENT_B = 1;
int ELXEMENT_C = 1;
int ELXEMENT_D = 1;
int ELXEMENT_E = 1;
int ELXEMENT_F = 1;
int ELXEMENT_G = 1;
int ELXEMENT_H = 1;
int ELXEMENT_I = 1;
{
Elx<caret>
}
}
@@ -1,5 +1,5 @@
class FooBar {
void foo(FooBar _fooBar) {
fb<caret>
}
class FooBar {
void foo(FooBar _fooBar) {
fb<caret>
}
}
@@ -1,33 +1,33 @@
class MyClass {
public void foo() {
MyDD<String> d = new MyDD<String>() {
@Override
public int hashCode() {
<selection>return super.hashCode(); //To change body of overridden methods use File | Settings | File Templates.</selection>
}
@Override
public boolean equals(Object obj) {
return super.equals(obj); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public String toString() {
return super.toString(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected void finalize() throws Throwable {
super.finalize(); //To change body of overridden methods use File | Settings | File Templates.
}
};
}
}
abstract class MyDD<T> {
class MyClass {
public void foo() {
MyDD<String> d = new MyDD<String>() {
@Override
public int hashCode() {
<selection>return super.hashCode(); //To change body of overridden methods use File | Settings | File Templates.</selection>
}
@Override
public boolean equals(Object obj) {
return super.equals(obj); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public String toString() {
return super.toString(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected void finalize() throws Throwable {
super.finalize(); //To change body of overridden methods use File | Settings | File Templates.
}
};
}
}
abstract class MyDD<T> {
}
@@ -1,31 +1,31 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class Test {
public interface Some<T> {
T test(T p1, T p2);
}
class Foo {
public Foo create() {return null;}
public Foo create1() {return null;}
}
{
Some<Foo> some = (i1, i2) -> {
return i1.create();
};
}
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class Test {
public interface Some<T> {
T test(T p1, T p2);
}
class Foo {
public Foo create() {return null;}
public Foo create1() {return null;}
}
{
Some<Foo> some = (i1, i2) -> {
return i1.create();
};
}
}
@@ -1,29 +1,29 @@
interface Function<X, Y> { }
class A {
private static final Function<String, String> a = new Function<String, String>() {
@Override
public int hashCode() {
<selection>return super.hashCode(); //To change body of overridden methods use File | Settings | File Templates.</selection>
}
@Override
public boolean equals(Object obj) {
return super.equals(obj); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public String toString() {
return super.toString(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected void finalize() throws Throwable {
super.finalize(); //To change body of overridden methods use File | Settings | File Templates.
}
};
interface Function<X, Y> { }
class A {
private static final Function<String, String> a = new Function<String, String>() {
@Override
public int hashCode() {
<selection>return super.hashCode(); //To change body of overridden methods use File | Settings | File Templates.</selection>
}
@Override
public boolean equals(Object obj) {
return super.equals(obj); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
public String toString() {
return super.toString(); //To change body of overridden methods use File | Settings | File Templates.
}
@Override
protected void finalize() throws Throwable {
super.finalize(); //To change body of overridden methods use File | Settings | File Templates.
}
};
}
@@ -1,7 +1,7 @@
// "Break string on '\n'" "true"
class A {
String s = "Hello,\n\r" +
"world\n" +
"!\n";
}
// "Break string on '\n'" "true"
class A {
String s = "Hello,\n\r" +
"world\n" +
"!\n";
}
@@ -1,5 +1,5 @@
// "Break string on '\n'" "true"
class A {
String s = "Hello,\n\rwor<caret>ld\n!\n";
}
// "Break string on '\n'" "true"
class A {
String s = "Hello,\n\rwor<caret>ld\n!\n";
}
@@ -1,5 +1,5 @@
// "Break string on '\n'" "false"
class A {
String s = "Hello!\n";
}
// "Break string on '\n'" "false"
class A {
String s = "Hello!\n";
}
@@ -1,5 +1,5 @@
// "Break string on '\n'" "false"
class A {
String s = "Hello!\n\r";
}
// "Break string on '\n'" "false"
class A {
String s = "Hello!\n\r";
}
@@ -1,21 +1,21 @@
// "Convert to 'new Color(0x10101)'" "true"
package java.awt;
class A {
private Color color = new Color(0x10101);
}
class Color {
Color(int r, int g, int b) {
}
Color(int r, int g, int b, int a) {
}
Color(int rgb) {
}
Color(int rgba, boolean hasAlpha) {
}
}
// "Convert to 'new Color(0x10101)'" "true"
package java.awt;
class A {
private Color color = new Color(0x10101);
}
class Color {
Color(int r, int g, int b) {
}
Color(int r, int g, int b, int a) {
}
Color(int rgb) {
}
Color(int rgba, boolean hasAlpha) {
}
}
@@ -1,21 +1,21 @@
// "Convert to 'new Color(0x10101)'" "true"
package java.awt;
class A {
private Color color = new Color(257, 257,<caret> 257);
}
class Color {
Color(int r, int g, int b) {
}
Color(int r, int g, int b, int a) {
}
Color(int rgb) {
}
Color(int rgba, boolean hasAlpha) {
}
}
// "Convert to 'new Color(0x10101)'" "true"
package java.awt;
class A {
private Color color = new Color(257, 257,<caret> 257);
}
class Color {
Color(int r, int g, int b) {
}
Color(int r, int g, int b, int a) {
}
Color(int rgb) {
}
Color(int rgba, boolean hasAlpha) {
}
}
@@ -1,269 +1,269 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.TestDataPath;
import java.io.IOException;
@TestDataPath("$CONTENT_ROOT/testData")
public class ClassNameCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/className/";
}
public void testImportAfterNew() throws Exception {
createClass("package pack; public class AAClass {}");
createClass("package pack; public class WithInnerAClass{\n" +
" public static class Inner{}\n" +
"}");
String path = "/importAfterNew";
configureByFile(path + "/before1.java");
checkResultByFile(path + "/after1.java");
configureByFile(path + "/before2.java");
selectItem(myItems[0]);
checkResultByFile(path + "/after2.java");
}
private void createClass(String text) {
myFixture.addClass(text);
}
public void testAfterNewThrowable1() throws Exception {
addClassesForAfterNewThrowable();
String path = "/afterNewThrowable";
configureByFile(path + "/before1.java");
myFixture.type('\n');
checkResultByFile(path + "/after1.java");
}
private void addClassesForAfterNewThrowable() throws IOException {
createClass("public class OurException extends Throwable{}");
createClass("public class OurNotException {\n" +
" public static class InnerException extends Throwable{}\n" +
" public static class InnerNonException{}\n" +
"}");
}
public void testAfterNewThrowable2() throws Exception {
addClassesForAfterNewThrowable();
String path = "/afterNewThrowable";
configureByFile(path + "/before2.java");
myFixture.type('\n');
checkResultByFile(path + "/after2.java");
}
public void testExcessParensAfterNew() throws Exception { doTest(); }
public void testReuseParensAfterNew() throws Exception { doTest(); }
public void testBracesAfterNew() throws Exception { doTest(); }
public void testInPlainTextFile() throws Exception {
configureByFile(getTestName(false) + ".txt");
checkResultByFile(getTestName(false) + "_after.txt");
}
public void testInPropertiesFile() throws Exception {
myFixture.configureByText("a.properties", "abc = StrinBui<caret>");
complete();
myFixture.checkResult("abc = java.lang.StringBuilder<caret>");
}
public void testDoubleStringBuffer() throws Exception {
createClass("package java.lang; public class StringBuffer {}");
doTest();
assertNull(myItems);
}
public void testReplaceReferenceExpressionWithTypeElement() throws Exception {
createClass("package foo.bar; public class ABCDEF {}");
doTest();
}
public void testCamelHumpPrefix() throws Exception {
String path = "/java/";
configureByFile(path + getTestName(false) + ".java");
complete();
assertEquals(2, myItems.length);
}
private void doTest() throws Exception {
String path = "/java/";
configureByFile(path + getTestName(false) + ".java");
checkResultByFile(path + getTestName(false) + "_after.java");
}
public void testNameCompletionJava() throws Exception {
String path = "/nameCompletion/java";
configureByFile(path + "/test1-source.java");
performAction();
checkResultByFile(path + "/test1-result.java");
configureByFile(path + "/test2-source.java");
performAction();
checkResultByFile(path + "/test2-result.java");
}
public void testImplementsFiltering1() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/test4-source.java");
performAction();
checkResultByFile(path + "/test4-result.java");
}
public void testImplementsFiltering2() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/test3-source.java");
performAction();
checkResultByFile(path + "/test3-result.java");
configureByFile(path + "/implements2-source.java");
performAction();
checkResultByFile(path + "/implements2-result.java");
configureByFile(path + "/implements3-source.java");
performAction();
checkResultByFile(path + "/implements3-result.java");
}
public void testAnnotationFiltering() throws Exception {
createClass("@interface MyObjectType {}");
final String path = "/nameCompletion/java";
configureByFile(path + "/test8-source.java");
performAction();
checkResultByFile(path + "/test8-result.java");
cleanupVfs();
configureByFile(path + "/test9-source.java");
performAction();
checkResultByFile(path + "/test9-result.java");
cleanupVfs();
configureByFile(path + "/test9_2-source.java");
performAction();
checkResultByFile(path + "/test9_2-result.java");
cleanupVfs();
configureByFile(path + "/test9_3-source.java");
performAction();
checkResultByFile(path + "/test9_3-result.java");
cleanupVfs();
configureByFile(path + "/test11-source.java");
performAction();
checkResultByFile(path + "/test11-result.java");
cleanupVfs();
configureByFile(path + "/test10-source.java");
performAction();
checkResultByFile(path + "/test10-result.java");
cleanupVfs();
configureByFile(path + "/test12-source.java");
performAction();
checkResultByFile(path + "/test12-result.java");
cleanupVfs();
configureByFile(path + "/test13-source.java");
performAction();
checkResultByFile(path + "/test13-result.java");
}
private void cleanupVfs() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
FileDocumentManager.getInstance().saveAllDocuments();
for (VirtualFile file : myFixture.getTempDirFixture().getFile("").getChildren()) {
try {
file.delete(this);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}
});
}
public void testInMethodCall() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/methodCall-source.java");
performAction();
checkResultByFile(path + "/methodCall-result.java");
}
public void testInMethodCallQualifier() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/methodCall1-source.java");
performAction();
checkResultByFile(path + "/methodCall1-result.java");
}
public void testInVariableDeclarationType() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/varType-source.java");
performAction();
checkResultByFile(path + "/varType-result.java");
}
public void testExtraSpace() throws Exception { doJavaTest(); }
public void testAnnotation() throws Exception { doJavaTest(); }
public void testInStaticImport() throws Exception { doJavaTest(); }
public void testInCommentWithPackagePrefix() throws Exception { doJavaTest(); }
private void doJavaTest() throws Exception {
final String path = "/nameCompletion/java";
myFixture.configureByFile(path + "/" + getTestName(false) + "-source.java");
performAction();
checkResultByFile(path + "/" + getTestName(false) + "-result.java");
}
@Override
protected void complete() {
myItems = myFixture.complete(CompletionType.BASIC, 2);
}
private void performAction() {
complete();
if (LookupManager.getActiveLookup(myFixture.getEditor()) != null) {
myFixture.type('\n');
}
}
}
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.TestDataPath;
import java.io.IOException;
@TestDataPath("$CONTENT_ROOT/testData")
public class ClassNameCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_7);
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/className/";
}
public void testImportAfterNew() throws Exception {
createClass("package pack; public class AAClass {}");
createClass("package pack; public class WithInnerAClass{\n" +
" public static class Inner{}\n" +
"}");
String path = "/importAfterNew";
configureByFile(path + "/before1.java");
checkResultByFile(path + "/after1.java");
configureByFile(path + "/before2.java");
selectItem(myItems[0]);
checkResultByFile(path + "/after2.java");
}
private void createClass(String text) {
myFixture.addClass(text);
}
public void testAfterNewThrowable1() throws Exception {
addClassesForAfterNewThrowable();
String path = "/afterNewThrowable";
configureByFile(path + "/before1.java");
myFixture.type('\n');
checkResultByFile(path + "/after1.java");
}
private void addClassesForAfterNewThrowable() throws IOException {
createClass("public class OurException extends Throwable{}");
createClass("public class OurNotException {\n" +
" public static class InnerException extends Throwable{}\n" +
" public static class InnerNonException{}\n" +
"}");
}
public void testAfterNewThrowable2() throws Exception {
addClassesForAfterNewThrowable();
String path = "/afterNewThrowable";
configureByFile(path + "/before2.java");
myFixture.type('\n');
checkResultByFile(path + "/after2.java");
}
public void testExcessParensAfterNew() throws Exception { doTest(); }
public void testReuseParensAfterNew() throws Exception { doTest(); }
public void testBracesAfterNew() throws Exception { doTest(); }
public void testInPlainTextFile() throws Exception {
configureByFile(getTestName(false) + ".txt");
checkResultByFile(getTestName(false) + "_after.txt");
}
public void testInPropertiesFile() throws Exception {
myFixture.configureByText("a.properties", "abc = StrinBui<caret>");
complete();
myFixture.checkResult("abc = java.lang.StringBuilder<caret>");
}
public void testDoubleStringBuffer() throws Exception {
createClass("package java.lang; public class StringBuffer {}");
doTest();
assertNull(myItems);
}
public void testReplaceReferenceExpressionWithTypeElement() throws Exception {
createClass("package foo.bar; public class ABCDEF {}");
doTest();
}
public void testCamelHumpPrefix() throws Exception {
String path = "/java/";
configureByFile(path + getTestName(false) + ".java");
complete();
assertEquals(2, myItems.length);
}
private void doTest() throws Exception {
String path = "/java/";
configureByFile(path + getTestName(false) + ".java");
checkResultByFile(path + getTestName(false) + "_after.java");
}
public void testNameCompletionJava() throws Exception {
String path = "/nameCompletion/java";
configureByFile(path + "/test1-source.java");
performAction();
checkResultByFile(path + "/test1-result.java");
configureByFile(path + "/test2-source.java");
performAction();
checkResultByFile(path + "/test2-result.java");
}
public void testImplementsFiltering1() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/test4-source.java");
performAction();
checkResultByFile(path + "/test4-result.java");
}
public void testImplementsFiltering2() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/test3-source.java");
performAction();
checkResultByFile(path + "/test3-result.java");
configureByFile(path + "/implements2-source.java");
performAction();
checkResultByFile(path + "/implements2-result.java");
configureByFile(path + "/implements3-source.java");
performAction();
checkResultByFile(path + "/implements3-result.java");
}
public void testAnnotationFiltering() throws Exception {
createClass("@interface MyObjectType {}");
final String path = "/nameCompletion/java";
configureByFile(path + "/test8-source.java");
performAction();
checkResultByFile(path + "/test8-result.java");
cleanupVfs();
configureByFile(path + "/test9-source.java");
performAction();
checkResultByFile(path + "/test9-result.java");
cleanupVfs();
configureByFile(path + "/test9_2-source.java");
performAction();
checkResultByFile(path + "/test9_2-result.java");
cleanupVfs();
configureByFile(path + "/test9_3-source.java");
performAction();
checkResultByFile(path + "/test9_3-result.java");
cleanupVfs();
configureByFile(path + "/test11-source.java");
performAction();
checkResultByFile(path + "/test11-result.java");
cleanupVfs();
configureByFile(path + "/test10-source.java");
performAction();
checkResultByFile(path + "/test10-result.java");
cleanupVfs();
configureByFile(path + "/test12-source.java");
performAction();
checkResultByFile(path + "/test12-result.java");
cleanupVfs();
configureByFile(path + "/test13-source.java");
performAction();
checkResultByFile(path + "/test13-result.java");
}
private void cleanupVfs() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
FileDocumentManager.getInstance().saveAllDocuments();
for (VirtualFile file : myFixture.getTempDirFixture().getFile("").getChildren()) {
try {
file.delete(this);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
}
});
}
public void testInMethodCall() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/methodCall-source.java");
performAction();
checkResultByFile(path + "/methodCall-result.java");
}
public void testInMethodCallQualifier() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/methodCall1-source.java");
performAction();
checkResultByFile(path + "/methodCall1-result.java");
}
public void testInVariableDeclarationType() throws Exception {
final String path = "/nameCompletion/java";
configureByFile(path + "/varType-source.java");
performAction();
checkResultByFile(path + "/varType-result.java");
}
public void testExtraSpace() throws Exception { doJavaTest(); }
public void testAnnotation() throws Exception { doJavaTest(); }
public void testInStaticImport() throws Exception { doJavaTest(); }
public void testInCommentWithPackagePrefix() throws Exception { doJavaTest(); }
private void doJavaTest() throws Exception {
final String path = "/nameCompletion/java";
myFixture.configureByFile(path + "/" + getTestName(false) + "-source.java");
performAction();
checkResultByFile(path + "/" + getTestName(false) + "-result.java");
}
@Override
protected void complete() {
myItems = myFixture.complete(CompletionType.BASIC, 2);
}
private void performAction() {
complete();
if (LookupManager.getActiveLookup(myFixture.getEditor()) != null) {
myFixture.type('\n');
}
}
}
@@ -1,82 +1,82 @@
/*
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
* Use is subject to license terms.
*/
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.ide.ui.UISettings;
import com.intellij.psi.statistics.StatisticsManager;
import com.intellij.psi.statistics.impl.StatisticsManagerImpl;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.annotations.NonNls;
/**
* @author peter
*/
@TestDataPath("$CONTENT_ROOT/testData")
public abstract class CompletionSortingTestCase extends LightFixtureCompletionTestCase {
private final CompletionType myType;
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
protected CompletionSortingTestCase(CompletionType type) {
myType = type;
}
@Override
protected void setUp() throws Exception {
super.setUp();
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(getTestRootDisposable());
}
@Override
protected void tearDown() throws Exception {
LookupManager.getInstance(getProject()).hideActiveLookup();
UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = false;
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER;
super.tearDown();
}
@Override
protected abstract String getBasePath();
protected void checkPreferredItems(final int selected, @NonNls final String... expected) {
invokeCompletion(getTestName(false) + ".java");
assertPreferredItems(selected, expected);
}
protected void assertPreferredItems(final int selected, @NonNls final String... expected) {
myFixture.assertPreferredCompletionItems(selected, expected);
}
protected LookupImpl invokeCompletion(final String path) {
configureNoCompletion(path);
myFixture.complete(myType);
return getLookup();
}
protected void configureNoCompletion(String path) {
myFixture.configureFromExistingVirtualFile(
myFixture.copyFileToProject(path, com.intellij.openapi.util.text.StringUtil.getShortName(path, '/')));
}
protected static void incUseCount(final LookupImpl lookup, final int index) {
imitateItemSelection(lookup, index);
refreshSorting(lookup);
}
protected static void refreshSorting(final LookupImpl lookup) {
lookup.setSelectionTouched(false);
lookup.resort(true);
}
protected static void imitateItemSelection(final LookupImpl lookup, final int index) {
final LookupElement item = lookup.getItems().get(index);
lookup.setCurrentItem(item);
CompletionLookupArranger.collectStatisticChanges(item, lookup);
CompletionLookupArranger.applyLastCompletionStatisticsUpdate();
}
}
/*
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
* Use is subject to license terms.
*/
package com.intellij.codeInsight.completion;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.ide.ui.UISettings;
import com.intellij.psi.statistics.StatisticsManager;
import com.intellij.psi.statistics.impl.StatisticsManagerImpl;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.annotations.NonNls;
/**
* @author peter
*/
@TestDataPath("$CONTENT_ROOT/testData")
public abstract class CompletionSortingTestCase extends LightFixtureCompletionTestCase {
private final CompletionType myType;
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
protected CompletionSortingTestCase(CompletionType type) {
myType = type;
}
@Override
protected void setUp() throws Exception {
super.setUp();
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(getTestRootDisposable());
}
@Override
protected void tearDown() throws Exception {
LookupManager.getInstance(getProject()).hideActiveLookup();
UISettings.getInstance().SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY = false;
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER;
super.tearDown();
}
@Override
protected abstract String getBasePath();
protected void checkPreferredItems(final int selected, @NonNls final String... expected) {
invokeCompletion(getTestName(false) + ".java");
assertPreferredItems(selected, expected);
}
protected void assertPreferredItems(final int selected, @NonNls final String... expected) {
myFixture.assertPreferredCompletionItems(selected, expected);
}
protected LookupImpl invokeCompletion(final String path) {
configureNoCompletion(path);
myFixture.complete(myType);
return getLookup();
}
protected void configureNoCompletion(String path) {
myFixture.configureFromExistingVirtualFile(
myFixture.copyFileToProject(path, com.intellij.openapi.util.text.StringUtil.getShortName(path, '/')));
}
protected static void incUseCount(final LookupImpl lookup, final int index) {
imitateItemSelection(lookup, index);
refreshSorting(lookup);
}
protected static void refreshSorting(final LookupImpl lookup) {
lookup.setSelectionTouched(false);
lookup.resort(true);
}
protected static void imitateItemSelection(final LookupImpl lookup, final int index) {
final LookupElement item = lookup.getItems().get(index);
lookup.setCurrentItem(item);
CompletionLookupArranger.collectStatisticChanges(item, lookup);
CompletionLookupArranger.applyLastCompletionStatisticsUpdate();
}
}
@@ -1,211 +1,211 @@
package com.intellij.codeInsight.completion;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.util.ArrayUtil
import com.intellij.codeInsight.lookup.LookupElementPresentation
import com.intellij.codeInsight.lookup.LookupElement;
/**
* @author peter
*/
public class GlobalMemberNameCompletionTest extends LightCodeInsightFixtureTestCase {
public void testMethodName() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcmethod() {}
static void methodThatsNotVisible() {}
}
""")
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod;
class Bar {{ abcmethod()<caret> }}"""
}
public void testFieldName() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcfield = 2
static final int fieldThatsNotVisible = 3
}
""")
doTest "class Bar {{ abcf<caret> }}", true, """import static foo.Foo.abcfield;
class Bar {{ abcfield<caret> }}"""
}
public void testFieldNameQualified() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcfield = 2
static final int fieldThatsNotVisible = 3
}
""")
doTest "class Bar {{ abcf<caret> }}", false, """import foo.Foo;
class Bar {{ Foo.abcfield<caret> }}"""
}
public void testFieldNamePresentation() {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcfield = 2
static final int fieldThatsNotVisible = 3
}
""")
myFixture.configureByText "a.java", "class Bar {{ abcf<caret> }}"
def element = complete()[0]
def presentation = LookupElementPresentation.renderElement(element)
assert 'Foo.abcfield' == presentation.itemText
assert ' (foo)' == presentation.tailText
assert 'int' == presentation.typeText
}
private LookupElement[] complete() {
myFixture.complete(CompletionType.BASIC, 2)
}
public void testQualifiedMethodName() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcmethod() {}
}
""")
doTest "class Bar {{ abcm<caret> }}", false, """import foo.Foo;
class Bar {{ Foo.abcmethod()<caret> }}"""
}
public void testIfThereAreAlreadyStaticImportsWithThatClass() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int anotherMethod(int a) {}
public static int abcmethod() {}
void methodThatsNotVisible() {}
}
""")
doTest """import static foo.Foo.abcmethod;
class Bar {{ abcmethod(); anoMe<caret> }}""", false,
"""import static foo.Foo.abcmethod;
import static foo.Foo.anotherMethod;
class Bar {{ abcmethod(); anotherMethod(<caret>) }}"""
}
@Override protected void tearDown() {
CodeInsightSettings.instance.EXCLUDED_PACKAGES = ArrayUtil.EMPTY_STRING_ARRAY
super.tearDown()
}
public void testExcludeClassFromCompletion() throws Exception {
myFixture.addClass("""package foo;
public class Foo {
public static int abcmethod() {}
}
""")
myFixture.addClass("""package foo;
public class Excl {
public static int abcmethod2() {}
}
""")
CodeInsightSettings.instance.EXCLUDED_PACKAGES = ["foo.Excl"] as String[]
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod;
class Bar {{ abcmethod()<caret> }}"""
}
public void testExcludeMethodFromCompletion() throws Exception {
myFixture.addClass("""package foo;
public class Foo {
public static int abcmethod1() {}
public static int abcmethodExcluded() {}
}
""")
CodeInsightSettings.instance.EXCLUDED_PACKAGES = ["foo.Foo.abcmethodExcluded"] as String[]
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod1;
class Bar {{ abcmethod1()<caret> }}"""
}
public void testMergeOverloads() throws Exception {
myFixture.addClass("""package foo;
public class Foo {
public static int abcmethod(int a) {}
public static int abcmethod(boolean a) {}
public static int abcmethod1(boolean a) {}
}
""")
myFixture.configureByText("a.java", "class Bar {{ abcm<caret> }}")
def element = complete()[0]
def tail = LookupElementPresentation.renderElement(element).tailFragments
assert tail[0].text == '(...)'
assert !tail[0].grayed
assert tail[1].text == ' (foo)'
assert tail[1].grayed
assertOrderedEquals myFixture.lookupElementStrings, "abcmethod", "abcmethod1"
}
public void testMethodFromTheSameClass() {
myFixture.configureByText("a.java", """
class A {
static void foo() {}
static void goo() {
f<caret>
}
}
""")
def element = complete()[0]
def presentation = LookupElementPresentation.renderElement(element)
assert 'foo' == presentation.itemText
myFixture.type '\n'
myFixture.checkResult '''
class A {
static void foo() {}
static void goo() {
foo();<caret>
}
}
'''
}
private void doTest(String input, boolean importStatic, String output) {
myFixture.configureByText("a.java", input)
def item = assertOneElement(complete())
if (importStatic) {
item.'as'(StaticallyImportable).shouldBeImported = true
}
myFixture.type('\n')
myFixture.checkResult output
}
}
package com.intellij.codeInsight.completion;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.util.ArrayUtil
import com.intellij.codeInsight.lookup.LookupElementPresentation
import com.intellij.codeInsight.lookup.LookupElement;
/**
* @author peter
*/
public class GlobalMemberNameCompletionTest extends LightCodeInsightFixtureTestCase {
public void testMethodName() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcmethod() {}
static void methodThatsNotVisible() {}
}
""")
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod;
class Bar {{ abcmethod()<caret> }}"""
}
public void testFieldName() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcfield = 2
static final int fieldThatsNotVisible = 3
}
""")
doTest "class Bar {{ abcf<caret> }}", true, """import static foo.Foo.abcfield;
class Bar {{ abcfield<caret> }}"""
}
public void testFieldNameQualified() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcfield = 2
static final int fieldThatsNotVisible = 3
}
""")
doTest "class Bar {{ abcf<caret> }}", false, """import foo.Foo;
class Bar {{ Foo.abcfield<caret> }}"""
}
public void testFieldNamePresentation() {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcfield = 2
static final int fieldThatsNotVisible = 3
}
""")
myFixture.configureByText "a.java", "class Bar {{ abcf<caret> }}"
def element = complete()[0]
def presentation = LookupElementPresentation.renderElement(element)
assert 'Foo.abcfield' == presentation.itemText
assert ' (foo)' == presentation.tailText
assert 'int' == presentation.typeText
}
private LookupElement[] complete() {
myFixture.complete(CompletionType.BASIC, 2)
}
public void testQualifiedMethodName() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int abcmethod() {}
}
""")
doTest "class Bar {{ abcm<caret> }}", false, """import foo.Foo;
class Bar {{ Foo.abcmethod()<caret> }}"""
}
public void testIfThereAreAlreadyStaticImportsWithThatClass() throws Exception {
myFixture.addClass("""
package foo;
public class Foo {
public static int anotherMethod(int a) {}
public static int abcmethod() {}
void methodThatsNotVisible() {}
}
""")
doTest """import static foo.Foo.abcmethod;
class Bar {{ abcmethod(); anoMe<caret> }}""", false,
"""import static foo.Foo.abcmethod;
import static foo.Foo.anotherMethod;
class Bar {{ abcmethod(); anotherMethod(<caret>) }}"""
}
@Override protected void tearDown() {
CodeInsightSettings.instance.EXCLUDED_PACKAGES = ArrayUtil.EMPTY_STRING_ARRAY
super.tearDown()
}
public void testExcludeClassFromCompletion() throws Exception {
myFixture.addClass("""package foo;
public class Foo {
public static int abcmethod() {}
}
""")
myFixture.addClass("""package foo;
public class Excl {
public static int abcmethod2() {}
}
""")
CodeInsightSettings.instance.EXCLUDED_PACKAGES = ["foo.Excl"] as String[]
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod;
class Bar {{ abcmethod()<caret> }}"""
}
public void testExcludeMethodFromCompletion() throws Exception {
myFixture.addClass("""package foo;
public class Foo {
public static int abcmethod1() {}
public static int abcmethodExcluded() {}
}
""")
CodeInsightSettings.instance.EXCLUDED_PACKAGES = ["foo.Foo.abcmethodExcluded"] as String[]
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod1;
class Bar {{ abcmethod1()<caret> }}"""
}
public void testMergeOverloads() throws Exception {
myFixture.addClass("""package foo;
public class Foo {
public static int abcmethod(int a) {}
public static int abcmethod(boolean a) {}
public static int abcmethod1(boolean a) {}
}
""")
myFixture.configureByText("a.java", "class Bar {{ abcm<caret> }}")
def element = complete()[0]
def tail = LookupElementPresentation.renderElement(element).tailFragments
assert tail[0].text == '(...)'
assert !tail[0].grayed
assert tail[1].text == ' (foo)'
assert tail[1].grayed
assertOrderedEquals myFixture.lookupElementStrings, "abcmethod", "abcmethod1"
}
public void testMethodFromTheSameClass() {
myFixture.configureByText("a.java", """
class A {
static void foo() {}
static void goo() {
f<caret>
}
}
""")
def element = complete()[0]
def presentation = LookupElementPresentation.renderElement(element)
assert 'foo' == presentation.itemText
myFixture.type '\n'
myFixture.checkResult '''
class A {
static void foo() {}
static void goo() {
foo();<caret>
}
}
'''
}
private void doTest(String input, boolean importStatic, String output) {
myFixture.configureByText("a.java", input)
def item = assertOneElement(complete())
if (importStatic) {
item.'as'(StaticallyImportable).shouldBeImported = true
}
myFixture.type('\n')
myFixture.checkResult output
}
}
@@ -1,113 +1,113 @@
/*
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
* Use is subject to license terms.
*/
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.SourceFolder;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
/**
* @author peter
*/
public class HeavyNormalCompletionTest extends JavaCodeInsightFixtureTestCase {
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testPackagePrefix() throws Throwable {
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
final ModifiableRootModel model = ModuleRootManager.getInstance(myFixture.getModule()).getModifiableModel();
model.getContentEntries()[0].getSourceFolders()[0].setPackagePrefix("foo.bar.goo");
model.commit();
}
}.execute().throwException();
myFixture.completeBasic();
myFixture.checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
assertTrue(JavaPsiFacade.getInstance(getProject()).findPackage("foo").isValid());
assertTrue(JavaPsiFacade.getInstance(getProject()).findPackage("foo.bar").isValid());
assertTrue(JavaPsiFacade.getInstance(getProject()).findPackage("foo.bar.goo").isValid());
}
public void testPreferTestCases() throws Throwable {
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
final ModifiableRootModel model = ModuleRootManager.getInstance(myFixture.getModule()).getModifiableModel();
ContentEntry contentEntry = model.getContentEntries()[0];
SourceFolder sourceFolder = contentEntry.getSourceFolders()[0];
VirtualFile file = sourceFolder.getFile();
contentEntry.removeSourceFolder(sourceFolder);
contentEntry.addSourceFolder(file, true);
model.commit();
}
}.execute().throwException();
myFixture.addClass("package foo; public class SomeTestCase {}");
myFixture.addClass("package bar; public class SomeTestec {}");
myFixture.addClass("package goo; public class SomeAnchor {}");
myFixture.completeBasic();
myFixture.assertPreferredCompletionItems(0, "SomeTestCase", "SomeAnchor", "SomeTestec");
}
public void testAllClassesWhenNothingIsFound() throws Throwable {
myFixture.addClass("package foo.bar; public class AxBxCxDxEx {}");
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
myFixture.completeBasic();
myFixture.type('\n');
myFixture.checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
}
public void testAllClassesOnSecondBasicCompletion() throws Throwable {
myFixture.addClass("package foo.bar; public class AxBxCxDxEx {}");
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myFixture.getEditor());
LookupElement[] myItems = lookup.getItems().toArray(LookupElement.EMPTY_ARRAY);
assertEquals(2, myItems.length);
assertEquals("AxBxCxDxEx", myItems[1].getLookupString());
assertEquals("AyByCyDyEy", myItems[0].getLookupString());
}
public void testMapsInvalidation() throws Exception {
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
assertInstanceOf(myFixture.getFile().getVirtualFile().getFileSystem(), LocalFileSystem.class); // otherwise the completion copy won't be preserved which is critical here
myFixture.completeBasic();
assertOrderedEquals(myFixture.getLookupElementStrings(), "getAaa", "getBbb");
myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getCaretModel().getOffset() + 2);
assertNull(myFixture.completeBasic());
}
public void testQualifyInaccessibleClassName() throws Exception {
PsiTestUtil.addModule(getProject(), StdModuleTypes.JAVA, "second", myFixture.getTempDirFixture().findOrCreateDir("second"));
myFixture.addFileToProject("second/foo/bar/AxBxCxDxEx.java", "package foo.bar; class AxBxCxDxEx {}");
myFixture.configureByText("a.java", "class Main { ABCDE<caret> }");
myFixture.complete(CompletionType.BASIC, 3);
myFixture.checkResult("class Main { foo.bar.AxBxCxDxEx<caret> }");
}
}
/*
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
* Use is subject to license terms.
*/
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.module.StdModuleTypes;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.roots.SourceFolder;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
/**
* @author peter
*/
public class HeavyNormalCompletionTest extends JavaCodeInsightFixtureTestCase {
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testPackagePrefix() throws Throwable {
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
final ModifiableRootModel model = ModuleRootManager.getInstance(myFixture.getModule()).getModifiableModel();
model.getContentEntries()[0].getSourceFolders()[0].setPackagePrefix("foo.bar.goo");
model.commit();
}
}.execute().throwException();
myFixture.completeBasic();
myFixture.checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
assertTrue(JavaPsiFacade.getInstance(getProject()).findPackage("foo").isValid());
assertTrue(JavaPsiFacade.getInstance(getProject()).findPackage("foo.bar").isValid());
assertTrue(JavaPsiFacade.getInstance(getProject()).findPackage("foo.bar.goo").isValid());
}
public void testPreferTestCases() throws Throwable {
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
final ModifiableRootModel model = ModuleRootManager.getInstance(myFixture.getModule()).getModifiableModel();
ContentEntry contentEntry = model.getContentEntries()[0];
SourceFolder sourceFolder = contentEntry.getSourceFolders()[0];
VirtualFile file = sourceFolder.getFile();
contentEntry.removeSourceFolder(sourceFolder);
contentEntry.addSourceFolder(file, true);
model.commit();
}
}.execute().throwException();
myFixture.addClass("package foo; public class SomeTestCase {}");
myFixture.addClass("package bar; public class SomeTestec {}");
myFixture.addClass("package goo; public class SomeAnchor {}");
myFixture.completeBasic();
myFixture.assertPreferredCompletionItems(0, "SomeTestCase", "SomeAnchor", "SomeTestec");
}
public void testAllClassesWhenNothingIsFound() throws Throwable {
myFixture.addClass("package foo.bar; public class AxBxCxDxEx {}");
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
myFixture.completeBasic();
myFixture.type('\n');
myFixture.checkResultByFile("/codeInsight/completion/normal/" + getTestName(false) + "_after.java");
}
public void testAllClassesOnSecondBasicCompletion() throws Throwable {
myFixture.addClass("package foo.bar; public class AxBxCxDxEx {}");
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myFixture.getEditor());
LookupElement[] myItems = lookup.getItems().toArray(LookupElement.EMPTY_ARRAY);
assertEquals(2, myItems.length);
assertEquals("AxBxCxDxEx", myItems[1].getLookupString());
assertEquals("AyByCyDyEy", myItems[0].getLookupString());
}
public void testMapsInvalidation() throws Exception {
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java");
assertInstanceOf(myFixture.getFile().getVirtualFile().getFileSystem(), LocalFileSystem.class); // otherwise the completion copy won't be preserved which is critical here
myFixture.completeBasic();
assertOrderedEquals(myFixture.getLookupElementStrings(), "getAaa", "getBbb");
myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getCaretModel().getOffset() + 2);
assertNull(myFixture.completeBasic());
}
public void testQualifyInaccessibleClassName() throws Exception {
PsiTestUtil.addModule(getProject(), StdModuleTypes.JAVA, "second", myFixture.getTempDirFixture().findOrCreateDir("second"));
myFixture.addFileToProject("second/foo/bar/AxBxCxDxEx.java", "package foo.bar; class AxBxCxDxEx {}");
myFixture.configureByText("a.java", "class Main { ABCDE<caret> }");
myFixture.complete(CompletionType.BASIC, 3);
myFixture.checkResult("class Main { foo.bar.AxBxCxDxEx<caret> }");
}
}
@@ -1,30 +1,30 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.quickFix;
/**
* @author Danila Ponomarenko
*/
public class BreakStringOnLineBreaksTest extends LightQuickFixTestCase {
public void test() throws Exception { doAllTests(); }
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/breakStringOnLineBreaks";
}
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon.quickFix;
/**
* @author Danila Ponomarenko
*/
public class BreakStringOnLineBreaksTest extends LightQuickFixTestCase {
public void test() throws Exception { doAllTests(); }
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/breakStringOnLineBreaks";
}
}