mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
one-letter prefix is not a subject for middle-word matching
This commit is contained in:
@@ -110,7 +110,6 @@ public class CompletionStyleTest extends LightCodeInsightTestCase{
|
||||
|
||||
configureByFile(path + "/before3.java");
|
||||
performSmartCompletion();
|
||||
select(Lookup.NORMAL_SELECT_CHAR, 0);
|
||||
checkResultByFile(path + "/after3.java");
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -558,11 +558,15 @@ public interface Test {
|
||||
|
||||
edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT) }
|
||||
assert myFixture.editor.caretModel.offset == offset + 1
|
||||
joinAutopopup()
|
||||
joinCompletion()
|
||||
assertContains "iterable"
|
||||
assertEquals 'iterable', lookup.currentItem.lookupString
|
||||
|
||||
edt { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT) }
|
||||
assert myFixture.editor.caretModel.offset == offset
|
||||
joinAutopopup()
|
||||
joinCompletion()
|
||||
assertContains "if", "iterable", "int"
|
||||
assertEquals 'iterable', lookup.currentItem.lookupString
|
||||
|
||||
@@ -773,7 +777,7 @@ class Foo {
|
||||
public void testRestartWithVisibleLookup() {
|
||||
registerContributor(LongContributor, LoadingOrder.FIRST)
|
||||
|
||||
myFixture.configureByText("a.java", """ class Foo { { int abcdef; a<caret> } } """)
|
||||
myFixture.configureByText("a.java", """ class Foo { { int abcdef, abcdefg; ab<caret> } } """)
|
||||
myFixture.completeBasic()
|
||||
while (!lookup.shown) {
|
||||
Thread.sleep(1)
|
||||
@@ -781,10 +785,10 @@ class Foo {
|
||||
def l = lookup
|
||||
edt {
|
||||
assert lookup.calculating
|
||||
myFixture.type 'b'
|
||||
myFixture.type 'c'
|
||||
}
|
||||
joinCommit {
|
||||
myFixture.type 'c'
|
||||
myFixture.type 'd'
|
||||
}
|
||||
joinAutopopup()
|
||||
joinCompletion()
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testNamesInMethod1() throws Exception {
|
||||
configureByFile("MethodTagName1.java");
|
||||
assertStringItems("see", "serialData", "since", "class", "throws");
|
||||
assertStringItems("see", "serialData", "since");
|
||||
}
|
||||
|
||||
public void testParamValueCompletion() throws Exception {
|
||||
|
||||
+2
-2
@@ -85,9 +85,9 @@ public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
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 testInstanceOf1() throws Exception { doTest(false); }
|
||||
public void testInstanceOf2() throws Exception { doTest(false); }
|
||||
public void testInstanceOf3() throws Exception { doTest(true); }
|
||||
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"); }
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ public class VariablesCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
public void testFieldOutOfAnonymous() throws Exception {
|
||||
doSelectTest("TestFieldOutOfAnonymous.java", "TestFieldOutOfAnonymousResult.java");
|
||||
doTest("TestFieldOutOfAnonymous.java", "TestFieldOutOfAnonymousResult.java");
|
||||
}
|
||||
|
||||
public void testUnresolvedMethodName() throws Exception {
|
||||
|
||||
@@ -56,6 +56,10 @@ public class BackspaceHandler extends EditorActionHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (process != null) {
|
||||
process.prefixUpdated();
|
||||
}
|
||||
|
||||
if (hideOffset < editor.getCaretModel().getOffset()) {
|
||||
if (process != null) {
|
||||
process.scheduleRestart();
|
||||
|
||||
@@ -214,6 +214,15 @@ public class NameUtilTest extends UsefulTestCase {
|
||||
assertMatches("text*:sh", "textField:shouldChangeCharactersInRange:replacementString:");
|
||||
}
|
||||
|
||||
public void testMiddleMatchingMinimumTwoConsecutiveLettersInWordMiddle() {
|
||||
assertMatches("*fo", "reformat");
|
||||
assertMatches("*f", "reFormat");
|
||||
assertMatches("*f", "format");
|
||||
assertMatches("*f", "Format");
|
||||
assertMatches("*Stri", "string");
|
||||
assertDoesntMatch("*f", "reformat");
|
||||
}
|
||||
|
||||
public void testMiddleMatching() {
|
||||
assertTrue(caseInsensitiveMatcher("*old").matches("folder"));
|
||||
assertMatches("SWU*H*7", "SWUpgradeHdlrFSPR7Test");
|
||||
@@ -395,9 +404,9 @@ public class NameUtilTest extends UsefulTestCase {
|
||||
public void testPreferStartMatchToMiddleMatch() {
|
||||
assertPreference(" fb", "FooBar", "_fooBar", NameUtil.MatchingCaseSensitivity.NONE);
|
||||
assertPreference("*foo", "barFoo", "foobar");
|
||||
assertPreference("*f", "barfoo", "barFoo");
|
||||
assertPreference("*f", "barfoo", "foo");
|
||||
assertPreference("*f", "asdf", "Foo", NameUtil.MatchingCaseSensitivity.NONE);
|
||||
assertPreference("*fo", "barfoo", "barFoo");
|
||||
assertPreference("*fo", "barfoo", "foo");
|
||||
assertPreference("*fo", "asdfo", "Foo", NameUtil.MatchingCaseSensitivity.NONE);
|
||||
assertPreference(" sto", "ArrayStoreException", "StackOverflowError", NameUtil.MatchingCaseSensitivity.NONE);
|
||||
assertPreference(" EUC-", "x-EUC-TW", "EUC-JP");
|
||||
assertPreference(" boo", "Boolean", "boolean", NameUtil.MatchingCaseSensitivity.NONE);
|
||||
@@ -450,10 +459,10 @@ public class NameUtilTest extends UsefulTestCase {
|
||||
public void run() {
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
for (MinusculeMatcher matcher : matching) {
|
||||
assertTrue(matcher.matches(longName));
|
||||
assertTrue(matcher.toString(), matcher.matches(longName));
|
||||
}
|
||||
for (MinusculeMatcher matcher : nonMatching) {
|
||||
assertFalse(matcher.matches(longName));
|
||||
assertFalse(matcher.toString(), matcher.matches(longName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +177,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
|
||||
@Nullable
|
||||
private FList<TextRange> skipChars(String name, int patternIndex, int nameIndex, boolean maySkipNextChar) {
|
||||
boolean veryStart = patternIndex == 0;
|
||||
while ('*' == myPattern[patternIndex]) {
|
||||
patternIndex++;
|
||||
if (patternIndex == myPattern.length) {
|
||||
@@ -201,6 +202,17 @@ public class MinusculeMatcher implements Matcher {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (veryStart && next > 0 && !NameUtil.isWordStart(name, next)) {
|
||||
if (next == name.length() - 1) {
|
||||
return null;
|
||||
}
|
||||
if (patternIndex == myPattern.length - 1 ||
|
||||
myPattern[patternIndex + 1] != name.charAt(next + 1) && Character.isLetter(myPattern[patternIndex + 1])) {
|
||||
fromIndex = next + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
FList<TextRange> ranges = matchName(name, patternIndex, next);
|
||||
if (ranges != null) {
|
||||
return ranges;
|
||||
@@ -324,4 +336,12 @@ public class MinusculeMatcher implements Matcher {
|
||||
|
||||
return matchName(name, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MinusculeMatcher{" +
|
||||
"myPattern=" + new String(myPattern) +
|
||||
", myOptions=" + myOptions +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user