first letter case sensitivity should match pattern start with name start even in middle matches

This commit is contained in:
peter
2013-09-02 09:24:17 +02:00
parent ec36ca85a5
commit 44011ffd99
11 changed files with 49 additions and 69 deletions

View File

@@ -1,5 +1,5 @@
public class A {
void foo(Foo myXxxxxxxxx) {
Xxxxx<caret>
xxxxx<caret>
}
}

View File

@@ -1,5 +1,5 @@
public class A {
void foo(Foo myXxxxxxxxx) {
Xxxxx<caret>
xxxxx<caret>
}
}

View File

@@ -1,12 +0,0 @@
public class Foo {
Zoo foo() {
return r<caret>
}
void rMethod() {}
}
enum Zoo {
LEFT, RIGHT
}

View File

@@ -3,6 +3,6 @@ import java.lang.String;
public class Foo {
void foo(Object vx) {
String s = "" + v<caret>
String s = "" + v<caret>z
}
}

View File

@@ -74,15 +74,15 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
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 testMethodScope5() throws Exception { doTest(false); }
public void testExtraBracketAfterFinally1() throws Exception { doTest(false); }
public void testExtraBracketAfterFinally2() throws Exception { doTest(false); }
public void testExtendsInCastTypeParameters() throws Exception { doTest(false); }
public void testExtendsInCastTypeParameters2() throws Exception { doTest(2, "extends", "super"); }
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 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); }
@@ -91,9 +91,9 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
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 testThrowsOnSeparateLine() throws Exception { doTest(false); }
public void testDefaultInAnno() throws Exception { doTest(false); }
public void testNullInMethodCall() throws Exception { doTest(true); }
public void testNullInMethodCall() throws Exception { doTest(false); }
public void testNullInMethodCall2() throws Exception { doTest(false); }
public void testNewInMethodRefs() throws Exception { doTest(1, "new"); }
public void testSpaceAfterInstanceof() throws Exception { doTest(false); }

View File

@@ -102,11 +102,11 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testDispreferDeclared() throws Throwable {
checkPreferredItems(0, "aabbb", "aaa", "Aaaaaaa");
checkPreferredItems(0, "aabbb", "aaa");
}
public void testDispreferDeclaredOfExpectedType() throws Throwable {
checkPreferredItems(0, "aabbb", "aaa", "Aaaaaaa");
checkPreferredItems(0, "aabbb", "aaa");
}
public void testDispreferImpls() throws Throwable {
@@ -600,12 +600,4 @@ interface TxANotAnno {}
assertPreferredItems 0, 'setText', 'setOurText'
}
public void testEnumConstantStartMatching() {
checkPreferredItems(0, 'rMethod', 'Zoo.RIGHT')
myFixture.type('i\n;\nreturn r')
myFixture.completeBasic()
assertPreferredItems 0, 'Zoo.RIGHT', 'rMethod'
}
}

View File

@@ -197,7 +197,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
@Override
protected void tearDown() throws Exception {
CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = true
CodeInsightSettings.instance.AUTOCOMPLETE_ON_CODE_COMPLETION = true
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER
super.tearDown()
}
@@ -273,7 +274,6 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
public void testMethodInAnnotation() throws Exception {
configureByFile("Annotation.java");
myFixture.type('\n')
checkResultByFile("Annotation_after.java");
}
@@ -440,7 +440,7 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
}
public void testAtUnderClass() throws Throwable {
doTest('\n');
doTest();
}
public void testLocalClassName() throws Throwable { doTest(); }
@@ -694,15 +694,15 @@ public class ListUtils {
public void testBreakInSwitch() throws Throwable { doTest() }
public void testSuperInConstructor() throws Throwable {
doTest('\n');
doTest();
}
public void testSuperInConstructorWithParams() throws Throwable {
doTest('\n');
doTest();
}
public void testSuperInMethod() throws Throwable {
doTest('\n');
doTest();
}
public void testSecondMethodParameterName() throws Throwable {
@@ -771,7 +771,7 @@ public class ListUtils {
}
public void testSameNamedVariableInNestedClasses() throws Throwable {
doTest('\n');
doTest();
}
public void testHonorUnderscoreInPrefix() throws Throwable {
@@ -843,13 +843,12 @@ public class ListUtils {
final String path = getTestName(false) + ".java";
configureByFile(path);
checkResultByFile(path);
assertStringItems("fai1", "fai2", "FunctionalInterface");
assertStringItems("fai1", "fai2");
}
public void testProtectedInaccessibleOnSecondInvocation() throws Throwable {
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.complete(CompletionType.BASIC, 2);
myFixture.type('\n')
checkResult()
}
@@ -922,17 +921,12 @@ public class ListUtils {
public void testClassReferenceInFor2() throws Throwable { doTest ' ' }
public void testClassReferenceInFor3() throws Throwable {
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE
try {
doTest ' '
}
finally {
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER
}
doTest ' '
}
public void testEnumConstantFromEnumMember() throws Throwable { doTest(); }
public void testPrimitiveMethodParameter() throws Throwable { doTest('\n'); }
public void testPrimitiveMethodParameter() throws Throwable { doTest(); }
public void testNewExpectedClassParens() throws Throwable { doTest('\n'); }
@@ -1189,19 +1183,14 @@ class XInternalError {}
public void testDontPreselectCaseInsensitivePrefixMatch() {
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE
try {
myFixture.configureByText "a.java", "import java.io.*; class Foo {{ int fileSize; fil<caret>x }}"
myFixture.completeBasic()
assert lookup.currentItem.lookupString == 'fileSize'
myFixture.type('e')
assert lookup.items[0].lookupString == 'File'
assert lookup.items[1].lookupString == 'fileSize'
assert lookup.currentItem == lookup.items[1]
}
finally {
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER
}
myFixture.configureByText "a.java", "import java.io.*; class Foo {{ int fileSize; fil<caret>x }}"
myFixture.completeBasic()
assert lookup.currentItem.lookupString == 'fileSize'
myFixture.type('e')
assert lookup.items[0].lookupString == 'File'
assert lookup.items[1].lookupString == 'fileSize'
assert lookup.currentItem == lookup.items[1]
}
public void testNoGenericsWhenChoosingWithParen() { doTest('Ma(') }

View File

@@ -306,13 +306,15 @@ public class NameUtilMatchingTest extends UsefulTestCase {
public void testMiddleMatchingFirstLetterSensitive() {
assertTrue(firstLetterMatcher(" cl").matches("getClass"));
assertTrue(firstLetterMatcher(" EUC-").matches("x-EUC-TW"));
assertFalse(firstLetterMatcher(" EUC-").matches("x-EUC-TW"));
assertTrue(firstLetterMatcher(" a").matches("aaa"));
assertFalse(firstLetterMatcher(" a").matches("Aaa"));
assertFalse(firstLetterMatcher(" a").matches("Aaa"));
assertFalse(firstLetterMatcher(" _bl").matches("_top"));
assertFalse(firstLetterMatcher("*Ch").matches("char"));
assertTrue(firstLetterMatcher("*codes").matches("CFLocaleCopyISOCountryCodes"));
assertTrue(firstLetterMatcher("*Codes").matches("CFLocaleCopyISOCountryCodes"));
assertFalse(firstLetterMatcher("*codes").matches("CFLocaleCopyISOCountryCodes"));
assertTrue(firstLetterMatcher("*codes").matches("getCFLocaleCopyISOCountryCodes"));
assertTrue(firstLetterMatcher("*Bcomp").matches("BaseComponent"));
}
@@ -548,7 +550,7 @@ public class NameUtilMatchingTest extends UsefulTestCase {
}
public void testMeaningfulMatchingDegree() {
assertTrue(new MinusculeMatcher(" EUC-", NameUtil.MatchingCaseSensitivity.FIRST_LETTER).matchingDegree("x-EUC-TW") > Integer.MIN_VALUE);
assertTrue(caseInsensitiveMatcher(" EUC-").matchingDegree("x-EUC-TW") > Integer.MIN_VALUE);
}
private static void assertPreference(@NonNls String pattern,

View File

@@ -390,9 +390,18 @@ public class MinusculeMatcher implements Matcher {
}
private boolean isFirstCharMatching(@NotNull String name, int nameIndex, int patternIndex) {
boolean ignoreCase = myOptions == NameUtil.MatchingCaseSensitivity.FIRST_LETTER && nameIndex > 0 ||
myOptions == NameUtil.MatchingCaseSensitivity.NONE;
return nameIndex < name.length() && charEquals(myPattern[patternIndex],patternIndex, name.charAt(nameIndex), ignoreCase);
if (nameIndex >= name.length()) return false;
boolean ignoreCase = myOptions != NameUtil.MatchingCaseSensitivity.ALL;
char patternChar = myPattern[patternIndex];
if (!charEquals(patternChar, patternIndex, name.charAt(nameIndex), ignoreCase)) return false;
if (myOptions == NameUtil.MatchingCaseSensitivity.FIRST_LETTER &&
(patternIndex == 0 || patternIndex == 1 && isWildcard(0)) &&
Character.isUpperCase(patternChar) != Character.isUpperCase(name.charAt(0))) {
return false;
}
return true;
}
private boolean isWildcard(int patternIndex) {

View File

@@ -114,10 +114,10 @@ class GroovyAutoPopupTest extends CompletionAutoPopupTestCase {
}
public void testClassesAndPackagesInUnqualifiedImports() {
myFixture.addClass("package xxxxx; public class Xxxxxxxxx {}")
myFixture.addClass("package xxxxx; public class xxxxxxxxx {}")
myFixture.configureByText 'a.groovy', 'package foo; import <caret>'
type 'xxx'
assert myFixture.lookupElementStrings == ['xxxxx', 'Xxxxxxxxx']
assert myFixture.lookupElementStrings == ['xxxxxxxxx', 'xxxxx']
}

View File

@@ -40,7 +40,7 @@ class GroovyTransformationsTest extends LightCodeInsightFixtureTestCase {
public void testSingletonTransform() throws Throwable { doVariantsTest('instance', 'newInstance', 'newInstance', 'isInstance', 'getInstance', 'setInstance') }
public void testCategoryTransform() throws Throwable { doVariantsTest('name', 'getName', 'FileNameByRegexFinder', 'FileNameFinder', 'FilenameFilter', 'IFileNameFinder') }
public void testCategoryTransform() throws Throwable { doVariantsTest('name', 'getName') }
public void testMixinTransform() throws Throwable { doPlainTest() }