VariablesCompletionTest -> community

This commit is contained in:
peter
2009-10-15 19:04:17 +01:00
parent 5b6d7557a1
commit 98e865fe67
37 changed files with 525 additions and 0 deletions
@@ -0,0 +1,3 @@
interface Abc {
String[] getStrings<caret>
}
@@ -0,0 +1,3 @@
interface Abc {
String[] get<caret>
}
@@ -0,0 +1,4 @@
class Zloboglas{}
class A{
Zloboglas zloboglas<caret>
}
@@ -0,0 +1,4 @@
class Zloboglas{}
class A{
Zloboglas z<caret>
}
@@ -0,0 +1,4 @@
class Zloboglas{}
class A{
Zloboglas myZloboglas<caret>
}
@@ -0,0 +1,4 @@
class Zloboglas{}
class A{
Zloboglas my<caret>
}
@@ -0,0 +1,7 @@
class Zloboglas{}
class B {
private Zloboglas myZloboglas;
}
class A extends B {
private Zloboglas myZloboglas<caret>
}
@@ -0,0 +1,7 @@
class Zloboglas{}
class B {
private Zloboglas myZloboglas;
}
class A extends B {
private Zloboglas my<caret>
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
java.awt.event.InputMethodEvent i<caret>
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
java.awt.event.InputMethodEvent inputMethodEvent<caret>
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
Object ob<caret>
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
Object object<caret>
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
String st<caret>
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
String string<caret>
}
}
@@ -0,0 +1,19 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource9 {
private int aField;
public void foo() {
Runnable r = new Runnable() {
public void run() {
int x = aF<caret>;
}
};
}
}
@@ -0,0 +1,19 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource9 {
private int aField;
public void foo() {
Runnable r = new Runnable() {
public void run() {
int x = aField<caret>;
}
};
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
int abc = 0, bac = abc<caret>
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:07:18 PM
* To change this template use Options | File Templates.
*/
public class TestSource2 {
int aaa = 0;
public void foo(){
int abc = 0, bac = a<caret>
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource3 {
int aaa = 0;
public static void foo(){
int abc = 0, bac = abc<caret>
}
}
@@ -0,0 +1,18 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource4 {
int aaa = 0;
public static void foo(){
int abc = 0;
class Inner1{
int sbe=abc<caret>
}
}
}
@@ -0,0 +1,22 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource5 {
public static class inner{
static int aaa = 0;
public void foo(){
int abc = 0;
}
static class Inner1{
static int sbe = aaa<caret>
}
}
}
@@ -0,0 +1,13 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource6 {
int aaa = bbb<caret>
int bbb = 0;
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource7 {
public void foo(){
int aaa = b<caret>
int bbb = 0;
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource8 {
static {
int aaa = b<caret>
int bbb = 0;
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource9 {
static {
int bbb = 0;
int aaa = bbb<caret>
}
}
@@ -0,0 +1,5 @@
class TestSource1{
public void foo(){
int abc = 0, bac = a<caret>
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:07:18 PM
* To change this template use Options | File Templates.
*/
public class TestSource2 {
int aaa = 0;
public void foo(){
int abc = 0, bac = a<caret>
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource3 {
int aaa = 0;
public static void foo(){
int abc = 0, bac = a<caret>
}
}
@@ -0,0 +1,18 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource4 {
int aaa = 0;
public static void foo(){
int abc = 0;
class Inner1{
int sbe=a<caret>
}
}
}
@@ -0,0 +1,22 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource5 {
public static class inner{
static int aaa = 0;
public void foo(){
int abc = 0;
}
static class Inner1{
static int sbe = a<caret>
}
}
}
@@ -0,0 +1,13 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource6 {
int aaa = b<caret>
int bbb = 0;
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource7 {
public void foo(){
int aaa = b<caret>
int bbb = 0;
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource8 {
static {
int aaa = b<caret>
int bbb = 0;
}
}
@@ -0,0 +1,15 @@
package codeInsight.completion.variables.locals;
/**
* Created by IntelliJ IDEA.
* User: igork
* Date: Nov 25, 2002
* Time: 3:10:08 PM
* To change this template use Options | File Templates.
*/
public class TestSource9 {
static {
int bbb = 0;
int aaa = b<caret>
}
}
@@ -0,0 +1,7 @@
public class Foo {
public void a() {
int i = createStylesheetCombobox();
}
private int cre<caret>
}
@@ -0,0 +1,146 @@
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.util.text.LineTokenizer;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import java.io.IOException;
public class VariablesCompletionTest extends CompletionTestCase {
public static final String FILE_PREFIX = "/codeInsight/completion/variables/";
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testObjectVariable() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + getTestName(false) + ".java");
checkResultByFile(FILE_PREFIX + "locals/" + getTestName(false) + "_after.java");
}
public void testStringVariable() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + getTestName(false) + ".java");
checkResultByFile(FILE_PREFIX + "locals/" + getTestName(false) + "_after.java");
}
public void testInputMethodEventVariable() throws Exception {
createClass("package java.awt.event; public interface InputMethodEvent {}");
configureByFile(FILE_PREFIX + "locals/" + getTestName(false) + ".java");
checkResultByFile(FILE_PREFIX + "locals/" + getTestName(false) + "_after.java");
}
public void testLocals1() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource1.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult1.java");
}
public void testLocals2() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource2.java");
compareLookup(FILE_PREFIX + "locals/test2-lst.txt");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult2.java");
}
public void testLocals3() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource3.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult3.java");
}
public void testLocals4() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource4.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult4.java");
}
public void testLocals5() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource5.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult5.java");
}
public void testLocals6() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource6.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult6.java");
}
public void testLocals7() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource7.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult7.java");
}
public void testLocals8() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource8.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult8.java");
}
public void testFieldNameCompletion1() throws Exception {
configureByFileNoCompletion(FILE_PREFIX + "locals/" + "FieldNameCompletion1.java");
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject);
String oldPrefix = settings.FIELD_NAME_PREFIX;
settings.FIELD_NAME_PREFIX = "my";
complete();
settings.FIELD_NAME_PREFIX = oldPrefix;
checkResultByFile(FILE_PREFIX + "locals/" + "FieldNameCompletion1-result.java");
}
public void testFieldNameCompletion2() throws Exception {
configureByFileNoCompletion(FILE_PREFIX + "locals/" + "FieldNameCompletion2.java");
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject);
String oldPrefix = settings.FIELD_NAME_PREFIX;
settings.FIELD_NAME_PREFIX = "my";
complete();
settings.FIELD_NAME_PREFIX = oldPrefix;
checkResultByFile(FILE_PREFIX + "locals/" + "FieldNameCompletion2-result.java");
}
public void testFieldNameCompletion3() throws Exception {
configureByFileNoCompletion(FILE_PREFIX + "locals/" + "FieldNameCompletion3.java");
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject);
String oldPrefix = settings.FIELD_NAME_PREFIX;
settings.FIELD_NAME_PREFIX = "my";
complete();
settings.FIELD_NAME_PREFIX = oldPrefix;
checkResultByFile(FILE_PREFIX + "locals/" + "FieldNameCompletion3-result.java");
}
public void testLocals9() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestSource9.java");
checkResultByFile(FILE_PREFIX + "locals/" + "TestResult9.java");
}
public void testFieldOutOfAnonymous() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "TestFieldOutOfAnonymous.java");
complete();
checkResultByFile(FILE_PREFIX + "locals/" + "TestFieldOutOfAnonymousResult.java");
}
public void testUnresolvedMethodName() throws Exception {
configureByFile(FILE_PREFIX + "locals/" + "UnresolvedMethodName.java");
complete();
checkResultByFile(FILE_PREFIX + "locals/" + "UnresolvedMethodName.java");
testByCount(2, "creAnInt", "createStylesheetCombobox");
}
public void testArrayMethodName() throws Throwable {
configureByFile(FILE_PREFIX + "locals/" + "ArrayMethodName.java");
checkResultByFile(FILE_PREFIX + "locals/" + "ArrayMethodName-result.java");
}
protected void compareLookup(String fileName) throws IOException{
String fullPath = getTestDataPath() + fileName;
VirtualFile result = LocalFileSystem.getInstance().findFileByPath(fullPath);
assertNotNull("file " + fullPath + " not found", result);
String[] strings = LineTokenizer.tokenize(FileDocumentManager.getInstance().getDocument(result).getCharsSequence(), false);
assertNotNull(myItems);
for (int i = 0; i < myItems.length; i++) {
assertEquals(strings[i], myItems[i].toString());
}
}
}