WordCompletionTest->community

This commit is contained in:
peter
2009-10-26 17:13:32 +00:00
parent 8740f9fa35
commit 81e863bdfd
18 changed files with 150 additions and 0 deletions
@@ -0,0 +1 @@
Settings Sett<caret> other
@@ -0,0 +1 @@
Settings Sett<caret> other
@@ -0,0 +1 @@
<a>Settings Sett<caret> other</a>
@@ -0,0 +1 @@
Settings Settings other
@@ -0,0 +1 @@
Settings Settings other
@@ -0,0 +1 @@
<a>Settings Settings <caret>other</a>
@@ -0,0 +1,4 @@
<root>
<a value="Settings"/>
<a value="Sett<caret>"></a>
</root>
@@ -0,0 +1,4 @@
<root>
<a value="Settings"/>
<a value="Settings <caret>"></a>
</root>
@@ -0,0 +1,3 @@
public class MyClass {
String b = "My<caret>";
}
@@ -0,0 +1,3 @@
public class MyClass {
String b = "MyHardVariant<caret>";
}
@@ -0,0 +1,4 @@
public class MyClass {
String b = "My";
// pu<caret>
}
@@ -0,0 +1,4 @@
public class MyClass {
String b = "My";
// public <caret>
}
@@ -0,0 +1,2 @@
$test
$te<caret>
@@ -0,0 +1,2 @@
$test
$test <caret>
@@ -0,0 +1,4 @@
public class MyClass {
// comment <caret>
}
@@ -0,0 +1,4 @@
public class MyClass {
/** comment My<caret> */
}
@@ -0,0 +1,4 @@
public class MyClass {
/** comment MyClass <caret>*/
}
@@ -0,0 +1,106 @@
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLiteralExpression;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceBase;
import com.intellij.psi.impl.source.resolve.reference.PsiReferenceProviderBase;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
/**
* Created by IntelliJ IDEA.
* User: Maxim.Mossienko
* Date: Oct 14, 2004
* Time: 4:39:37 PM
* To change this template use File | Settings | File Templates.
*/
public class WordCompletionTest extends CompletionTestCase {
private static final String BASE_PATH = "/codeInsight/completion/word/";
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testKeyWordCompletion() throws Exception {
configureByFile(BASE_PATH + "1.txt");
checkResultByFile(BASE_PATH + "1_after.txt");
configureByFile(BASE_PATH + "1.properties");
checkResultByFile(BASE_PATH + "1_after.properties");
configureByFile(BASE_PATH + "1.xml");
checkResultByFile(BASE_PATH + "1_after.xml");
configureByFile(BASE_PATH + "2.xml");
configureByFile(BASE_PATH + "2_after.xml");
}
public void testNoWordCompletionForNonSoftReference() throws Throwable {
final PsiReferenceProviderBase softProvider = new PsiReferenceProviderBase() {
@NotNull
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {
public PsiElement resolve() {
return null;
}
public boolean isSoft() {
return true;
}
public Object[] getVariants() {
return new Object[]{"MySoftVariant"};
}
}};
}
};
final PsiReferenceProviderBase hardProvider = new PsiReferenceProviderBase() {
@NotNull
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {
public PsiElement resolve() {
return null;
}
public boolean isSoft() {
return false;
}
public Object[] getVariants() {
return new Object[]{"MyHardVariant"};
}
}};
}
};
ReferenceProvidersRegistry.getInstance(getProject()).registerReferenceProvider(PsiLiteralExpression.class, softProvider);
ReferenceProvidersRegistry.getInstance(getProject()).registerReferenceProvider(PsiLiteralExpression.class, hardProvider);
configureByFile(BASE_PATH + "3.java");
checkResultByFile(BASE_PATH + "3_after.java");
}
public void testComments() throws Throwable {
configureByFile(BASE_PATH + "4.java");
checkResultByFile(BASE_PATH + "4_after.java");
}
public void testSpaceInComment() throws Throwable {
configureByFile(BASE_PATH + "SpaceInComment.java");
checkResultByFile(BASE_PATH + "SpaceInComment.java");
}
public void testTextInComment() throws Throwable {
configureByFile(BASE_PATH + "TextInComment.java");
checkResultByFile(BASE_PATH + "TextInComment_after.java");
}
public void testDollarsInPrefix() throws Throwable {
configureByFile(BASE_PATH + getTestName(false) + ".txt");
checkResultByFile(BASE_PATH + getTestName(false) + "_after.txt");
}
}