mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-178141 Case sensitive completion: First Letter - doesn't work correctly if class starts with special symbol
check first letter after the underscore
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
class Zoo {
|
||||
void zoo(String fooBar, String __foo_bar) {
|
||||
foo<caret>
|
||||
}
|
||||
}
|
||||
+4
@@ -443,6 +443,10 @@ interface TxANotAnno {}
|
||||
checkPreferredItems(0, 'fooBar', '_fooBar', 'FooBar')
|
||||
}
|
||||
|
||||
void testDispreferUnderscoredCaseMatch() {
|
||||
checkPreferredItems(0, 'fooBar', '__foo_bar')
|
||||
}
|
||||
|
||||
void testStatisticsMattersOnNextCompletion() {
|
||||
configureByFile(getTestName(false) + ".java")
|
||||
myFixture.completeBasic()
|
||||
|
||||
+14
-2
@@ -63,14 +63,26 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
@Override
|
||||
public boolean prefixMatches(@NotNull final String name) {
|
||||
if (name.startsWith("_") &&
|
||||
myPrefix.length() > 0 && Character.isLetter(myPrefix.charAt(0)) &&
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE == CodeInsightSettings.FIRST_LETTER) {
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE == CodeInsightSettings.FIRST_LETTER &&
|
||||
firstLetterCaseDiffers(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return myMatcher.matches(name);
|
||||
}
|
||||
|
||||
private boolean firstLetterCaseDiffers(String name) {
|
||||
int nameFirst = skipUnderscores(name);
|
||||
int prefixFirst = skipUnderscores(myPrefix);
|
||||
return nameFirst < name.length() &&
|
||||
prefixFirst < myPrefix.length() &&
|
||||
caseDiffers(name.charAt(nameFirst), myPrefix.charAt(prefixFirst));
|
||||
}
|
||||
|
||||
private static boolean caseDiffers(char c1, char c2) {
|
||||
return Character.isLowerCase(c1) != Character.isLowerCase(c2) || Character.isUpperCase(c1) != Character.isUpperCase(c2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prefixMatches(@NotNull final LookupElement element) {
|
||||
return prefixMatchersInternal(element, !element.isCaseSensitive());
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.jetbrains.python.documentation.PyDocumentationSettings;
|
||||
import com.jetbrains.python.documentation.docstrings.DocStringFormat;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
@@ -1067,7 +1068,7 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
"@six.add_metaclass(M)\n" +
|
||||
"class C(object):\n" +
|
||||
" def foo(self):\n" +
|
||||
" C.ba<caret>x()");
|
||||
" C.ba<caret>()");
|
||||
|
||||
assertNotNull(suggested);
|
||||
assertContainsElements(suggested, "baz");
|
||||
@@ -1081,7 +1082,7 @@ public class PythonCompletionTest extends PyTestCase {
|
||||
"@a_m(M)\n" +
|
||||
"class C(object):\n" +
|
||||
" def foo(self):\n" +
|
||||
" C.ba<caret>x()");
|
||||
" C.ba<caret>()");
|
||||
|
||||
assertNotNull(suggested);
|
||||
assertContainsElements(suggested, "baz");
|
||||
|
||||
Reference in New Issue
Block a user