turn on middle matching in completion tests

This commit is contained in:
peter
2012-07-12 19:18:00 +02:00
parent 49dc4cb544
commit 3818145a76
31 changed files with 4695 additions and 4571 deletions
@@ -1,7 +1,7 @@
class C{
/**
* @see #n<caret>
* @see #not<caret>
*/
private int foo(int a, char b, String c) {}
}
@@ -1,7 +1,7 @@
class C{
/**
* @see #n<caret>
* @see #not<caret>
*
* @since
*/
@@ -110,6 +110,7 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
configureByFile(path + "/before3.java");
performSmartCompletion();
select(Lookup.NORMAL_SELECT_CHAR, 0);
checkResultByFile(path + "/after3.java");
}
File diff suppressed because it is too large Load Diff
@@ -1,232 +1,232 @@
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.lang.StdLanguages;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceBase;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.impl.source.resolve.reference.PsiReferenceRegistrarImpl;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import com.intellij.psi.javadoc.PsiDocTag;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* @author mike
*/
public class JavadocCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/javadoc/";
}
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new JavaDocLocalInspection());
}
public void testNamesInClass() throws Exception {
configureByFile("ClassTagName.java");
assertStringItems("author", "deprecated", "param", "see", "serial", "since", "version");
}
public void testNamesInField() throws Exception {
configureByFile("FieldTagName.java");
assertStringItems("deprecated", "see", "serial", "serialField", "since");
}
public void testNamesInMethod0() throws Exception {
configureByFile("MethodTagName0.java");
assertStringItems("deprecated", "exception", "param", "return", "see", "serialData", "since", "throws");
}
public void testNamesInMethod1() throws Exception {
configureByFile("MethodTagName1.java");
assertStringItems("see", "serialData", "since");
}
public void testParamValueCompletion() throws Exception {
configureByFile("ParamValue0.java");
assertStringItems("a", "b", "c");
}
public void testParamValueWithPrefixCompletion() throws Exception {
configureByFile("ParamValue1.java");
assertStringItems("a1", "a2", "a3");
}
public void testDescribedParameters() throws Exception {
configureByFile("ParamValue2.java");
assertStringItems("a2", "a3");
}
public void testSee0() throws Exception {
configureByFile("See0.java");
assertStringItems("foo", "clone", "equals", "getClass", "hashCode", "notify", "notifyAll", "Object", "toString", "wait", "wait", "wait", "finalize", "registerNatives");
}
public void testSee1() throws Exception {
configureByFile("See1.java");
assertStringItems("notify", "notifyAll");
}
public void testSee2() throws Exception {
configureByFile("See2.java");
assertStringItems("notify", "notifyAll");
}
public void testSee3() throws Exception {
configureByFile("See3.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("foo", "myField")));
}
@NotNull
private List<String> getLookupElementStrings() {
return ObjectUtils.assertNotNull(myFixture.getLookupElementStrings());
}
public void testSee4() throws Exception {
configureByFile("See4.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("A", "B", "C")));
}
public void testSee5() throws Exception {
configureByFile("See5.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("foo", "myName")));
}
public void testIDEADEV10620() throws Exception {
configureByFile("IDEADEV10620.java");
checkResultByFile("IDEADEV10620-after.java");
}
public void testException0() throws Exception {
configureByFile("Exception0.java");
assertStringItems("deprecated", "exception", "param", "see", "serialData", "since", "throws");
}
public void testException1() throws Exception {
configureByFile("Exception1.java");
assertTrue(myItems.length > 18);
}
public void testException2() throws Exception {
myFixture.configureByFile("Exception2.java");
myFixture.complete(CompletionType.SMART);
assertStringItems("IllegalStateException", "IOException");
}
public void testInlineLookup() throws Exception {
configureByFile("InlineTagName.java");
assertStringItems("code", "docRoot", "inheritDoc", "link", "linkplain", "literal", "value");
}
public void testFinishWithSharp() throws Throwable {
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION;
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
try {
checkFinishWithSharp();
}
finally {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = old;
}
}
private void checkFinishWithSharp() throws Exception {
myFixture.configureByFile("FinishWithSharp.java");
myFixture.completeBasic();
type('#');
checkResultByFile("FinishWithSharp_after.java");
final List<LookupElement> items = getLookup().getItems();
assertEquals("bar", items.get(0).getLookupString());
assertEquals("foo", items.get(1).getLookupString());
}
public void testShortenClassName() throws Throwable {
CodeStyleSettingsManager.getSettings(getProject()).USE_FQ_CLASS_NAMES_IN_JAVADOC = false;
try {
doTest();
}
finally {
CodeStyleSettingsManager.getSettings(getProject()).USE_FQ_CLASS_NAMES_IN_JAVADOC = true;
}
}
public void testMethodBeforeSharp() throws Throwable {
doTest();
}
public void testFieldReferenceInInnerClassJavadoc() throws Throwable {
doTest();
}
public void testShortenClassReference() throws Throwable { doTest(); }
public void testQualifiedClassReference() throws Throwable {
configureByFile(getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
checkResultByFile(getTestName(false) + "_after.java");
}
public void testThrowsNonImported() throws Throwable {
configureByFile(getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
checkResultByFile(getTestName(false) + "_after.java");
}
private void doTest() throws Exception {
configureByFile(getTestName(false) + ".java");
checkResultByFile(getTestName(false) + "_after.java");
}
public void testInlinePackageReferenceCompletion() throws Exception {
configureByFile("InlineReference.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("io", "lang", "util")));
}
public void testCustomReferenceProvider() throws Exception {
PsiReferenceRegistrarImpl registrar =
(PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(StdLanguages.JAVA);
PsiReferenceProvider provider = new PsiReferenceProvider() {
@Override
@NotNull
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {
@Override
public PsiElement resolve() {
return element;
}
@Override
@NotNull
public Object[] getVariants() {
return new Object[]{"1", "2", "3"};
}
}};
}
};
try {
registrar.registerReferenceProvider(PsiDocTag.class, provider);
configureByFile("ReferenceProvider.java");
assertStringItems("1", "2", "3");
}
finally {
registrar.unregisterReferenceProvider(PsiDocTag.class, provider);
}
}
}
package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.lang.StdLanguages;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceBase;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.impl.source.resolve.reference.PsiReferenceRegistrarImpl;
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
import com.intellij.psi.javadoc.PsiDocTag;
import com.intellij.util.ObjectUtils;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* @author mike
*/
public class JavadocCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/completion/javadoc/";
}
@Override
protected void setUp() throws Exception {
super.setUp();
myFixture.enableInspections(new JavaDocLocalInspection());
}
public void testNamesInClass() throws Exception {
configureByFile("ClassTagName.java");
assertStringItems("author", "deprecated", "param", "see", "serial", "since", "version");
}
public void testNamesInField() throws Exception {
configureByFile("FieldTagName.java");
assertStringItems("deprecated", "see", "serial", "serialField", "since");
}
public void testNamesInMethod0() throws Exception {
configureByFile("MethodTagName0.java");
assertStringItems("deprecated", "exception", "param", "return", "see", "serialData", "since", "throws");
}
public void testNamesInMethod1() throws Exception {
configureByFile("MethodTagName1.java");
assertStringItems("see", "serialData", "since", "class", "throws");
}
public void testParamValueCompletion() throws Exception {
configureByFile("ParamValue0.java");
assertStringItems("a", "b", "c");
}
public void testParamValueWithPrefixCompletion() throws Exception {
configureByFile("ParamValue1.java");
assertStringItems("a1", "a2", "a3");
}
public void testDescribedParameters() throws Exception {
configureByFile("ParamValue2.java");
assertStringItems("a2", "a3");
}
public void testSee0() throws Exception {
configureByFile("See0.java");
assertStringItems("foo", "clone", "equals", "getClass", "hashCode", "notify", "notifyAll", "Object", "toString", "wait", "wait", "wait", "finalize", "registerNatives");
}
public void testSee1() throws Exception {
configureByFile("See1.java");
assertStringItems("notify", "notifyAll");
}
public void testSee2() throws Exception {
configureByFile("See2.java");
assertStringItems("notify", "notifyAll");
}
public void testSee3() throws Exception {
configureByFile("See3.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("foo", "myField")));
}
@NotNull
private List<String> getLookupElementStrings() {
return ObjectUtils.assertNotNull(myFixture.getLookupElementStrings());
}
public void testSee4() throws Exception {
configureByFile("See4.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("A", "B", "C")));
}
public void testSee5() throws Exception {
configureByFile("See5.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("foo", "myName")));
}
public void testIDEADEV10620() throws Exception {
configureByFile("IDEADEV10620.java");
checkResultByFile("IDEADEV10620-after.java");
}
public void testException0() throws Exception {
configureByFile("Exception0.java");
assertStringItems("deprecated", "exception", "param", "see", "serialData", "since", "throws");
}
public void testException1() throws Exception {
configureByFile("Exception1.java");
assertTrue(myItems.length > 18);
}
public void testException2() throws Exception {
myFixture.configureByFile("Exception2.java");
myFixture.complete(CompletionType.SMART);
assertStringItems("IllegalStateException", "IOException");
}
public void testInlineLookup() throws Exception {
configureByFile("InlineTagName.java");
assertStringItems("code", "docRoot", "inheritDoc", "link", "linkplain", "literal", "value");
}
public void testFinishWithSharp() throws Throwable {
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION;
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
try {
checkFinishWithSharp();
}
finally {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = old;
}
}
private void checkFinishWithSharp() throws Exception {
myFixture.configureByFile("FinishWithSharp.java");
myFixture.completeBasic();
type('#');
checkResultByFile("FinishWithSharp_after.java");
final List<LookupElement> items = getLookup().getItems();
assertEquals("bar", items.get(0).getLookupString());
assertEquals("foo", items.get(1).getLookupString());
}
public void testShortenClassName() throws Throwable {
CodeStyleSettingsManager.getSettings(getProject()).USE_FQ_CLASS_NAMES_IN_JAVADOC = false;
try {
doTest();
}
finally {
CodeStyleSettingsManager.getSettings(getProject()).USE_FQ_CLASS_NAMES_IN_JAVADOC = true;
}
}
public void testMethodBeforeSharp() throws Throwable {
doTest();
}
public void testFieldReferenceInInnerClassJavadoc() throws Throwable {
doTest();
}
public void testShortenClassReference() throws Throwable { doTest(); }
public void testQualifiedClassReference() throws Throwable {
configureByFile(getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
checkResultByFile(getTestName(false) + "_after.java");
}
public void testThrowsNonImported() throws Throwable {
configureByFile(getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
checkResultByFile(getTestName(false) + "_after.java");
}
private void doTest() throws Exception {
configureByFile(getTestName(false) + ".java");
checkResultByFile(getTestName(false) + "_after.java");
}
public void testInlinePackageReferenceCompletion() throws Exception {
configureByFile("InlineReference.java");
assertTrue(getLookupElementStrings().containsAll(Arrays.asList("io", "lang", "util")));
}
public void testCustomReferenceProvider() throws Exception {
PsiReferenceRegistrarImpl registrar =
(PsiReferenceRegistrarImpl) ReferenceProvidersRegistry.getInstance().getRegistrar(StdLanguages.JAVA);
PsiReferenceProvider provider = new PsiReferenceProvider() {
@Override
@NotNull
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
return new PsiReference[]{new PsiReferenceBase<PsiElement>(element) {
@Override
public PsiElement resolve() {
return element;
}
@Override
@NotNull
public Object[] getVariants() {
return new Object[]{"1", "2", "3"};
}
}};
}
};
try {
registrar.registerReferenceProvider(PsiDocTag.class, provider);
configureByFile("ReferenceProvider.java");
assertStringItems("1", "2", "3");
}
finally {
registrar.unregisterReferenceProvider(PsiDocTag.class, provider);
}
}
}
@@ -1,114 +1,123 @@
/*
* 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.psi.codeStyle.CodeStyleSettingsManager;
import org.jetbrains.annotations.NonNls;
/**
* @author ik
* @since 20.02.2003
*/
public class KeywordCompletionTest extends LightCompletionTestCase {
private static final String BASE_PATH = "/codeInsight/completion/keywords";
private static final String[] FILE_SCOPE_KEYWORDS = new String[]{
"package", "public", "private", "import", "final", "class", "interface", "abstract", "enum", null};
private static final String[] CLASS_SCOPE_KEYWORDS = new String[]{
"public", "private", "protected", "import", "final", "class", "interface", "abstract", "enum", null};
private static final String[] CLASS_SCOPE_KEYWORDS_2 = new String[]{
"package", "public", "private", "protected", "transient", "volatile", "static", "import", "final", "class", "interface", "abstract"};
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testFileScope1() throws Exception { doTest(8, FILE_SCOPE_KEYWORDS); }
public void testFileScope2() throws Exception { doTest(7, CLASS_SCOPE_KEYWORDS); }
public void testClassScope1() throws Exception { doTest(5, CLASS_SCOPE_KEYWORDS); }
public void testClassScope2() throws Exception { doTest(4, CLASS_SCOPE_KEYWORDS); }
public void testClassScope3() throws Exception { doTest(0, CLASS_SCOPE_KEYWORDS); }
public void testClassScope4() throws Exception { doTest(10, CLASS_SCOPE_KEYWORDS_2); }
public void testAfterAnnotations() throws Exception { doTest(6, "public", "final", "class", "interface", "abstract", "enum", null); }
public void testExtends1() throws Exception { doTest(2, "extends", "implements", null); }
public void testExtends2() throws Exception { doTest(1, "extends", "implements", "AAA", "BBB", "instanceof"); }
public void testExtends3() throws Exception { doTest(2, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends4() throws Exception { doTest(2, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends5() throws Exception { doTest(1, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends6() throws Exception { doTest(1, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends7() throws Exception { doTest(false); }
public void testExtends8() throws Exception { doTest(false); }
public void testExtends9() throws Exception { doTest(false); }
public void testExtends10() throws Exception { doTest(false); }
public void testExtends11() throws Exception { doTest(false); }
public void testExtends12() throws Exception { doTest(false); }
public void testSynchronized1() throws Exception { doTest(false); }
public void testSynchronized2() throws Exception {
CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false;
doTest(false);
}
public void testMethodScope1() throws Exception { doTest(1, "throws"); }
public void testMethodScope2() throws Exception { doTest(1, "final", "public", "static", "volatile", "abstract"); }
public void testMethodScope3() throws Exception { doTest(1, "final", "public", "static", "volatile", "abstract", "throws", "instanceof"); }
public void testMethodScope4() throws Exception { doTest(6, "final", "try", "for", "while", "return", "throw"); }
public void testMethodScope5() throws Exception { doTest(false); }
public void testExtraBracketAfterFinally1() throws Exception { doTest(true); }
public void testExtraBracketAfterFinally2() throws Exception { doTest(true); }
public void testExtendsInCastTypeParameters() throws Exception { doTest(false); }
public void testExtendsWithRightContextInClassTypeParameters() throws Exception { doTest(false); }
public void testTrueInVariableDeclaration() throws Exception { doTest(false); }
public void testNullInIf() throws Exception { doTest(false); }
public void testNullInReturn() throws Exception { doTest(false); }
public void testExtendsInMethodParameters() throws Exception { doTest(false); }
public void testInstanceOf1() throws Exception { doTest(false); }
public void testInstanceOf2() throws Exception { doTest(false); }
public void testInstanceOf3() throws Exception { doTest(false); }
public void testCatchFinally() throws Exception { doTest(2, "catch", "finally"); }
public void testSuper1() throws Exception { doTest(1, "super"); }
public void testSuper2() throws Exception { doTest(0, "super"); }
public void testContinue() throws Exception { doTest(false); }
public void testThrowsOnSeparateLine() throws Exception { doTest(false); }
public void testDefaultInAnno() throws Exception { doTest(false); }
public void testDefaultInExtMethod() throws Exception { doTest(false); }
public void testNullInMethodCall() throws Exception { doTest(false); }
public void testNullInMethodCall2() throws Exception { doTest(false); }
public void testNewInMethodRefs() throws Exception { doTest(false); }
public void testAbstractInInterface() throws Exception { doTest(1, "abstract"); }
public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); }
public void testReturnInTernary() throws Exception { doTest(1, "return"); }
public void testTryInExpression() throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
assertStringItems("toString", "this");
}
private void doTest(boolean select) throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
if (select) {
selectItem(myItems[1]);
}
checkResultByFile(BASE_PATH + "/" + getTestName(true) + "_after.java");
}
protected void doTest(int finalCount, @NonNls String... values) {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
testByCount(finalCount, values);
}
/*
* 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.psi.codeStyle.CodeStyleSettingsManager;
import org.jetbrains.annotations.NonNls;
/**
* @author ik
* @since 20.02.2003
*/
public class KeywordCompletionTest extends LightCompletionTestCase {
private static final String BASE_PATH = "/codeInsight/completion/keywords";
private static final String[] FILE_SCOPE_KEYWORDS = new String[]{
"package", "public", "private", "import", "final", "class", "interface", "abstract", "enum", null};
private static final String[] CLASS_SCOPE_KEYWORDS = new String[]{
"public", "private", "protected", "import", "final", "class", "interface", "abstract", "enum", null};
private static final String[] CLASS_SCOPE_KEYWORDS_2 = new String[]{
"package", "public", "private", "protected", "transient", "volatile", "static", "import", "final", "class", "interface", "abstract"};
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
}
public void testFileScope1() throws Exception { doTest(8, FILE_SCOPE_KEYWORDS); }
public void testFileScope2() throws Exception { doTest(7, CLASS_SCOPE_KEYWORDS); }
public void testClassScope1() throws Exception { doTest(5, CLASS_SCOPE_KEYWORDS); }
public void testClassScope2() throws Exception { doTest(4, CLASS_SCOPE_KEYWORDS); }
public void testClassScope3() throws Exception { doTest(0, CLASS_SCOPE_KEYWORDS); }
public void testClassScope4() throws Exception { doTest(10, CLASS_SCOPE_KEYWORDS_2); }
public void testAfterAnnotations() throws Exception { doTest(6, "public", "final", "class", "interface", "abstract", "enum", null); }
public void testExtends1() throws Exception { doTest(2, "extends", "implements", null); }
public void testExtends2() throws Exception { doTest(1, "extends", "implements", "AAA", "BBB", "instanceof"); }
public void testExtends3() throws Exception { doTest(2, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends4() throws Exception { doTest(2, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends5() throws Exception { doTest(1, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends6() throws Exception { doTest(1, "extends", "implements", "AAA", "BBB", "CCC", "instanceof"); }
public void testExtends7() throws Exception { doTest(false); }
public void testExtends8() throws Exception { doTest(false); }
public void testExtends9() throws Exception { doTest(false); }
public void testExtends10() throws Exception { doTest(false); }
public void testExtends11() throws Exception { doTest(false); }
public void testExtends12() throws Exception { doTest(false); }
public void testSynchronized1() throws Exception { doTest(false); }
public void testSynchronized2() throws Exception {
CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false;
doTest(false);
}
public void testMethodScope1() throws Exception { doTest(1, "throws"); }
public void testMethodScope2() throws Exception { doTest(1, "final", "public", "static", "volatile", "abstract"); }
public void testMethodScope3() throws Exception { doTest(1, "final", "public", "static", "volatile", "abstract", "throws", "instanceof"); }
public void testMethodScope4() throws Exception { doTest(6, "final", "try", "for", "while", "return", "throw"); }
public void testMethodScope5() throws Exception { doTest(true); }
public void testExtraBracketAfterFinally1() throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
selectItem(myItems[1]);
checkResultByFile(BASE_PATH + "/" + getTestName(true) + "_after.java");
}
public void testExtraBracketAfterFinally2() throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
selectItem(myItems[1]);
checkResultByFile(BASE_PATH + "/" + getTestName(true) + "_after.java");
}
public void testExtendsInCastTypeParameters() throws Exception { doTest(false); }
public void testExtendsWithRightContextInClassTypeParameters() throws Exception { doTest(false); }
public void testTrueInVariableDeclaration() throws Exception { doTest(true); }
public void testNullInIf() throws Exception { doTest(true); }
public void testNullInReturn() throws Exception { doTest(true); }
public void testExtendsInMethodParameters() throws Exception { doTest(false); }
public void testInstanceOf1() throws Exception { doTest(true); }
public void testInstanceOf2() throws Exception { doTest(false); }
public void testInstanceOf3() throws Exception { doTest(true); }
public void testCatchFinally() throws Exception { doTest(2, "catch", "finally"); }
public void testSuper1() throws Exception { doTest(1, "super"); }
public void testSuper2() throws Exception { doTest(0, "super"); }
public void testContinue() throws Exception { doTest(false); }
public void testThrowsOnSeparateLine() throws Exception { doTest(true); }
public void testDefaultInAnno() throws Exception { doTest(false); }
public void testDefaultInExtMethod() throws Exception { doTest(false); }
public void testNullInMethodCall() throws Exception { doTest(true); }
public void testNullInMethodCall2() throws Exception { doTest(false); }
public void testNewInMethodRefs() throws Exception { doTest(false); }
public void testAbstractInInterface() throws Exception { doTest(1, "abstract"); }
public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); }
public void testReturnInTernary() throws Exception { doTest(1, "return"); }
public void testTryInExpression() throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
assertEquals("toString", myItems[0].getLookupString());
assertEquals("this", myItems[1].getLookupString());
}
private void doTest(boolean select) throws Exception {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
if (select) {
selectItem(myItems[0]);
}
checkResultByFile(BASE_PATH + "/" + getTestName(true) + "_after.java");
}
protected void doTest(int finalCount, @NonNls String... values) {
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
testByCount(finalCount, values);
}
}
File diff suppressed because it is too large Load Diff
@@ -2,6 +2,7 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.lookup.*;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.testFramework.PlatformTestUtil;
@@ -16,6 +17,12 @@ public class SecondSmartTypeCompletionTest extends LightCompletionTestCase {
setType(CompletionType.SMART);
}
@Override
protected void setUp() throws Exception {
super.setUp();
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath();
@@ -2,6 +2,7 @@ package com.intellij.codeInsight.completion;
import com.intellij.JavaTestUtil;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.lookup.Lookup;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
@@ -21,6 +22,11 @@ import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.util.containers.ContainerUtil;
public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
@Override
protected String getBasePath() {
@@ -5,10 +5,17 @@ import com.intellij.JavaTestUtil
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
public class VariablesCompletionTest extends LightFixtureCompletionTestCase {
public static final String FILE_PREFIX = "/codeInsight/completion/variables/";
@Override
protected void setUp() {
super.setUp()
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath();
@@ -1,92 +1,108 @@
package com.intellij.codeInsight.completion.impl;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.PrefixMatcher;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author peter
*/
public class CamelHumpMatcher extends PrefixMatcher {
private final MinusculeMatcher myMatcher;
private final boolean myCaseSensitive;
public CamelHumpMatcher(@NotNull final String prefix) {
this(prefix, true);
}
public CamelHumpMatcher(String prefix, boolean caseSensitive) {
super(prefix);
myCaseSensitive = caseSensitive;
myMatcher = createMatcher(myCaseSensitive);
}
@Override
public boolean isStartMatch(String name) {
return myMatcher.isStartMatch(name);
}
public boolean prefixMatches(@NotNull final String name) {
return myMatcher.matches(name);
}
public boolean prefixMatches(@NotNull final LookupElement element) {
return prefixMatchersInternal(element, !element.isCaseSensitive());
}
private boolean prefixMatchersInternal(final LookupElement element, final boolean itemCaseInsensitive) {
for (final String name : element.getAllLookupStrings()) {
if (itemCaseInsensitive && StringUtil.startsWithIgnoreCase(name, myPrefix) || prefixMatches(name)) {
return true;
}
if (itemCaseInsensitive && CodeInsightSettings.ALL != CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
if (createMatcher(false).matches(name)) {
return true;
}
}
}
return false;
}
@NotNull
public PrefixMatcher cloneWithPrefix(@NotNull final String prefix) {
return new CamelHumpMatcher(prefix, myCaseSensitive);
}
private MinusculeMatcher createMatcher(final boolean caseSensitive) {
String prefix = applyMiddleMatching(myPrefix);
if (!caseSensitive) {
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.NONE);
}
switch (CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
case CodeInsightSettings.NONE:
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.NONE);
case CodeInsightSettings.FIRST_LETTER:
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.FIRST_LETTER);
default:
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.ALL);
}
}
public static String applyMiddleMatching(String prefix) {
if (Registry.is("ide.completion.middle.matching") && !prefix.isEmpty() && !ApplicationManager.getApplication().isUnitTestMode()) {
return "*" + StringUtil.replace(prefix, ".", ". ").trim();
}
return prefix;
}
@Override
public String toString() {
return myPrefix;
}
}
package com.intellij.codeInsight.completion.impl;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.PrefixMatcher;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.codeStyle.MinusculeMatcher;
import com.intellij.psi.codeStyle.NameUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
/**
* @author peter
*/
public class CamelHumpMatcher extends PrefixMatcher {
private final MinusculeMatcher myMatcher;
private final boolean myCaseSensitive;
private static boolean ourForceStartMatching;
public CamelHumpMatcher(@NotNull final String prefix) {
this(prefix, true);
}
public CamelHumpMatcher(String prefix, boolean caseSensitive) {
super(prefix);
myCaseSensitive = caseSensitive;
myMatcher = createMatcher(myCaseSensitive);
}
@Override
public boolean isStartMatch(String name) {
return myMatcher.isStartMatch(name);
}
public boolean prefixMatches(@NotNull final String name) {
return myMatcher.matches(name);
}
public boolean prefixMatches(@NotNull final LookupElement element) {
return prefixMatchersInternal(element, !element.isCaseSensitive());
}
private boolean prefixMatchersInternal(final LookupElement element, final boolean itemCaseInsensitive) {
for (final String name : element.getAllLookupStrings()) {
if (itemCaseInsensitive && StringUtil.startsWithIgnoreCase(name, myPrefix) || prefixMatches(name)) {
return true;
}
if (itemCaseInsensitive && CodeInsightSettings.ALL != CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
if (createMatcher(false).matches(name)) {
return true;
}
}
}
return false;
}
@NotNull
public PrefixMatcher cloneWithPrefix(@NotNull final String prefix) {
return new CamelHumpMatcher(prefix, myCaseSensitive);
}
private MinusculeMatcher createMatcher(final boolean caseSensitive) {
String prefix = applyMiddleMatching(myPrefix);
if (!caseSensitive) {
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.NONE);
}
switch (CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE) {
case CodeInsightSettings.NONE:
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.NONE);
case CodeInsightSettings.FIRST_LETTER:
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.FIRST_LETTER);
default:
return NameUtil.buildMatcher(prefix, NameUtil.MatchingCaseSensitivity.ALL);
}
}
public static String applyMiddleMatching(String prefix) {
if (Registry.is("ide.completion.middle.matching") && !prefix.isEmpty() && !ourForceStartMatching) {
return "*" + StringUtil.replace(prefix, ".", ". ").trim();
}
return prefix;
}
@Override
public String toString() {
return myPrefix;
}
@TestOnly
public static void forceStartMatching(Disposable parent) {
ourForceStartMatching = true;
Disposer.register(parent, new Disposable() {
@Override
public void dispose() {
//noinspection AssignmentToStaticFieldFromInstanceMethod
ourForceStartMatching = false;
}
});
}
}
@@ -17,6 +17,7 @@
package org.jetbrains.android.dom;
import com.android.sdklib.SdkConstants;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
/**
* @author Eugene.Kudelevsky
@@ -46,6 +47,7 @@ public class AndroidAnimatorDomTest extends AndroidDomTest {
}
public void testTagNames() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
toTestCompletion("tn.xml", "tn_after.xml");
}
@@ -2,6 +2,7 @@ package org.jetbrains.android.dom;
import com.android.sdklib.SdkConstants;
import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.command.WriteCommandAction;
@@ -27,6 +28,7 @@ public class AndroidLayoutDomTest extends AndroidDomTest {
@Override
public void setUp() throws Exception {
super.setUp();
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, SdkConstants.FN_ANDROID_MANIFEST_XML);
// copy mock fragment, because it is not included to old android.jar
@@ -1,6 +1,7 @@
package org.jetbrains.android.dom;
import com.android.sdklib.SdkConstants;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import org.jetbrains.android.inspections.AndroidElementNotAllowedInspection;
import org.jetbrains.android.inspections.AndroidUnknownAttributeInspection;
@@ -22,6 +23,7 @@ public class AndroidManifestDomTest extends AndroidDomTest {
}
public void testAttributeNameCompletion2() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
doTestCompletionVariants("an2.xml", "debuggable", "description");
}
@@ -115,6 +117,7 @@ public class AndroidManifestDomTest extends AndroidDomTest {
}
public void testActivityCompletion3() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
copyFileToProject("MyActivity.java", "src/p1/p2/MyActivity.java");
copyFileToProject("MyActivity1.java", "src/p1/p2/p3/MyActivity1.java");
doTestCompletion(false);
@@ -17,6 +17,7 @@
package org.jetbrains.android.dom;
import com.android.sdklib.SdkConstants;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.openapi.command.WriteCommandAction;
@@ -81,6 +82,7 @@ public class AndroidValueResourcesTest extends AndroidDomTest {
}
public void testAttrFormatCompletion() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
toTestCompletion("attrs1.xml", "attrs1_after.xml");
}
@@ -17,6 +17,7 @@
package org.jetbrains.android.dom;
import com.android.sdklib.SdkConstants;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
/**
* Created by IntelliJ IDEA.
@@ -46,6 +47,7 @@ public class AndroidXmlResourcesDomTest extends AndroidDomTest {
}
public void testPreferenceChildrenCompletion() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
toTestCompletion("pref2.xml", "pref2_after.xml");
}
@@ -1,5 +1,6 @@
package org.jetbrains.android.intentions;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.template.TemplateManager;
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
import com.intellij.openapi.actionSystem.IdeActions;
@@ -36,6 +37,7 @@ public class AndroidAddStringResourceActionTest extends AndroidTestCase {
}
public void test1() throws IOException {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
doTest();
}
@@ -1,87 +1,89 @@
package org.jetbrains.plugins.groovy.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.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiMember;
import com.intellij.psi.PsiPackage;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.util.TestUtils;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @deprecated use {@link com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase}
* author ven
*/
public abstract class CompletionTestBase extends JavaCodeInsightFixtureTestCase {
protected void doTest() {
doTest("");
}
protected void doTest(String directory) {
final List<String> stringList = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
if (directory.length()!=0) directory += "/";
final String fileName = directory + getTestName(true) + "." + getExtension();
myFixture.addFileToProject(fileName, stringList.get(0));
myFixture.configureByFile(fileName);
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = false;
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
String result = "";
try {
myFixture.completeBasic();
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myFixture.getEditor());
if (lookup != null) {
List<LookupElement> items = lookup.getItems();
if (!addReferenceVariants()) {
items = ContainerUtil.findAll(items, new Condition<LookupElement>() {
@Override
public boolean value(LookupElement lookupElement) {
final Object o = lookupElement.getObject();
return !(o instanceof PsiMember) && !(o instanceof GrVariable) && !(o instanceof GroovyResolveResult) && !(o instanceof PsiPackage);
}
});
}
Collections.sort(items, new Comparator<LookupElement>() {
@Override
public int compare(LookupElement o1, LookupElement o2) {
return o1.getLookupString().compareTo(o2.getLookupString());
}
});
result = "";
for (LookupElement item : items) {
result = result + "\n" + item.getLookupString();
}
result = result.trim();
LookupManager.getInstance(myFixture.getProject()).hideActiveLookup();
}
}
finally {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = old;
}
assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result);
}
protected String getExtension() {
return "groovy";
}
protected boolean addReferenceVariants() {
return true;
}
}
package org.jetbrains.plugins.groovy.completion;
import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupManager;
import com.intellij.codeInsight.lookup.impl.LookupImpl;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiMember;
import com.intellij.psi.PsiPackage;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.util.TestUtils;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @deprecated use {@link com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase}
* author ven
*/
public abstract class CompletionTestBase extends JavaCodeInsightFixtureTestCase {
protected void doTest() {
doTest("");
}
protected void doTest(String directory) {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
final List<String> stringList = TestUtils.readInput(getTestDataPath() + "/" + getTestName(true) + ".test");
if (directory.length()!=0) directory += "/";
final String fileName = directory + getTestName(true) + "." + getExtension();
myFixture.addFileToProject(fileName, stringList.get(0));
myFixture.configureByFile(fileName);
boolean old = CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = false;
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false;
String result = "";
try {
myFixture.completeBasic();
final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myFixture.getEditor());
if (lookup != null) {
List<LookupElement> items = lookup.getItems();
if (!addReferenceVariants()) {
items = ContainerUtil.findAll(items, new Condition<LookupElement>() {
@Override
public boolean value(LookupElement lookupElement) {
final Object o = lookupElement.getObject();
return !(o instanceof PsiMember) && !(o instanceof GrVariable) && !(o instanceof GroovyResolveResult) && !(o instanceof PsiPackage);
}
});
}
Collections.sort(items, new Comparator<LookupElement>() {
@Override
public int compare(LookupElement o1, LookupElement o2) {
return o1.getLookupString().compareTo(o2.getLookupString());
}
});
result = "";
for (LookupElement item : items) {
result = result + "\n" + item.getLookupString();
}
result = result.trim();
LookupManager.getInstance(myFixture.getProject()).hideActiveLookup();
}
}
finally {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true;
CodeInsightSettings.getInstance().AUTOCOMPLETE_COMMON_PREFIX = old;
}
assertEquals(StringUtil.trimEnd(stringList.get(1), "\n"), result);
}
protected String getExtension() {
return "groovy";
}
protected boolean addReferenceVariants() {
return true;
}
}
@@ -26,6 +26,7 @@ import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
* @author Maxim.Medvedev
@@ -41,6 +42,12 @@ class GrCompletionWithLibraryTest extends GroovyCompletionTestBase {
}
};
@Override
protected void setUp() {
super.setUp()
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
File diff suppressed because it is too large Load Diff
@@ -20,6 +20,7 @@ package org.jetbrains.plugins.groovy.completion;
import com.intellij.codeInsight.completion.CompletionType
import com.intellij.codeInsight.completion.StaticallyImportable
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
* @author peter
@@ -79,7 +80,7 @@ public class GroovySmartCompletionTest extends GroovyCompletionTestBase {
public void testSmartCastCompletionWithoutRParenth() {doSmartTest();}
public void testSmartCastCompletionWithRParenth() {doSmartTest();}
public void testDontCompletePrivateMembers() {doSmartCompletion "foo1", "foo2"}
public void testDontCompletePrivateMembers() {CamelHumpMatcher.forceStartMatching(getTestRootDisposable());doSmartCompletion "foo1", "foo2"}
public void testEnumMembersInAssignment() {doSmartCompletion "IN_STOCK", "NOWHERE", "ORDERED" }
public void testEnumMembersInAssignmentInsideEnum() {doSmartCompletion "IN_STOCK", "NOWHERE", "ORDERED", "next", "previous" }
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection
import org.jetbrains.plugins.groovy.lang.documentation.GroovyDocumentationProvider
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
* @author peter
@@ -60,10 +61,6 @@ public class GroovyDslTest extends LightCodeInsightFixtureTestCase {
myFixture.testCompletion(getTestName(false) + ".gdsl", getTestName(false) + "_after.gdsl")
}
public void doPlainTest() throws Throwable {
myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + "_after.groovy")
}
public void testCompleteTopLevel() throws Throwable {
myFixture.configureByText 'a.gdsl', '<caret>'
myFixture.completeBasic()
@@ -132,6 +129,7 @@ public class GroovyDslTest extends LightCodeInsightFixtureTestCase {
}
public void testClassContext() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
doCustomTest( """
def ctx = context(scope: classScope(name: /.*WsSecurityConfig/))
@@ -161,6 +159,7 @@ public class MyCategory {
}
public void testPathRegexp() {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
addGdsl "contributor(pathRegexp: '.*aaa.*') { property name:'fffooo', type:'int' }"
myFixture.configureFromExistingVirtualFile myFixture.addFileToProject("aaa/foo.groovy", "fff<caret>x").virtualFile
@@ -173,6 +172,7 @@ public class MyCategory {
}
public void testNamedParameters() {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
addGdsl '''contribute(currentType(String.name)) {
method name:'foo', type:void, params:[:], namedParams:[
parameter(name:'param1', type:String),
@@ -185,6 +185,7 @@ public class MyCategory {
}
public void testNamedParametersGroovyConvention() {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
addGdsl '''contribute(currentType(String.name)) {
method name:'foo', type:void, params:[args:[
parameter(name:'param1', type:String, doc:'My doc'),
@@ -9,6 +9,7 @@ import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import org.jetbrains.plugins.groovy.util.TestUtils
import org.jetbrains.annotations.NotNull
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
* @author ilyas
@@ -20,6 +21,12 @@ class GroovyTransformationsTest extends LightCodeInsightFixtureTestCase {
}
}
@Override
protected void setUp() {
super.setUp()
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
@Override
protected String getBasePath() {
TestUtils.getTestDataPath() + "groovy/dsl/transform"
@@ -29,8 +29,9 @@ import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GroovyUntypedAccessInspection
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
/**
* @author ilyas
*/
public class GantReferenceCompletionTest extends LightCodeInsightFixtureTestCase {
@@ -57,6 +58,7 @@ public class GantReferenceCompletionTest extends LightCodeInsightFixtureTestCase
}
public void testDep() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
checkVariants """
target(aaa: "") {
dep<caret>
@@ -79,6 +81,7 @@ target(aaa: "") {
}
public void testInclude() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
checkVariants "inc<caret>", "includeTool", "includeTargets"
}
@@ -130,6 +133,7 @@ ant.zip {
}
public void testTagsInsideTagsInGantTarget() throws Exception {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
checkVariants """
target(aaa: "") {
zip {
@@ -15,6 +15,7 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
import org.jetbrains.annotations.NotNull
import org.jetbrains.plugins.groovy.util.SdkHomeConfigurable.SdkHomeBean
import org.jetbrains.plugins.groovy.util.TestUtils
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
* @author peter
@@ -60,6 +61,7 @@ public class StandaloneGantTest extends LightCodeInsightFixtureTestCase {
}
public void testDep() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
checkVariants """
target(aaa: "") {
dep<caret>
@@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilit
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyUncheckedAssignmentOfMemberOfRawTypeInspection
import com.intellij.testFramework.LightProjectDescriptor
import org.jetbrains.plugins.groovy.completion.GrCompletionWithLibraryTest
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
/**
* @author Sergey Evdokimov
@@ -238,6 +239,7 @@ class Aaa {
}
public void testConstructorInJavaClass() {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
myFixture.addFileToProject("Ccc.java", """
public class Ccc {
private String sss1
@@ -64,6 +64,7 @@ public abstract class TestBase extends UsefulTestCase {
protected void tearDown() throws Exception {
myFixture.tearDown();
myFixture = null;
super.tearDown();
}
protected String getTestFileName() {
@@ -15,13 +15,17 @@
*/
package org.intellij.lang.xpath;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
public class XPath2CompletionTest extends TestBase {
public void testCastInsert() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
doXPathCompletion();
}
public void testTreatInsert() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
doXPathCompletion();
}
@@ -15,9 +15,16 @@
*/
package org.intellij.lang.xpath;
public class XPathCompletionTest extends TestBase {
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
public void testAxis() throws Throwable {
public class XPathCompletionTest extends TestBase {
@Override
protected void setUp() throws Exception {
super.setUp();
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
public void testAxis() throws Throwable {
doXPathCompletion("ancestor", "ancestor-or-self", "attribute");
}
@@ -16,6 +16,7 @@
package org.intellij.plugins.relaxNG;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import org.intellij.plugins.testUtil.CopyFile;
/**
@@ -24,6 +25,12 @@ import org.intellij.plugins.testUtil.CopyFile;
* Date: 22.08.2007
*/
public class RncCompletionTest extends HighlightingTestBase {
@Override
protected void setUp() throws Exception {
super.setUp();
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
}
public String getTestDataPath() {
return "completion/rnc";
}
@@ -16,6 +16,7 @@
package org.intellij.plugins.relaxNG;
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
import org.intellij.plugins.testUtil.CopyFile;
/**
@@ -42,6 +43,7 @@ public class RngCompletionTest extends HighlightingTestBase {
}
public void testCompleteRef4() throws Throwable {
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
doTestCompletion("complete-ref-4", "rng");
}
}