diff --git a/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java new file mode 100644 index 000000000000..154d4a1aa042 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem.java @@ -0,0 +1,14 @@ +class Super { + public static final Super FOO = null; +} +class Super2 { +} + +class Intermediate { + void foo(Super s, int a) {} + void bar() { + foo(Su) + } +} + + diff --git a/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java new file mode 100644 index 000000000000..b284b6955f22 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/ExpectedTypesDotSelectsItem_after.java @@ -0,0 +1,14 @@ +class Super { + public static final Super FOO = null; +} +class Super2 { +} + +class Intermediate { + void foo(Super s, int a) {} + void bar() { + foo(Super.) + } +} + + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index a87ed8d43a49..6368592acdef 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -860,8 +860,8 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase { public void testQualifyInnerMembers() throws Throwable { doTest('\n') } public void testSuggestExpectedTypeMembers() throws Throwable { doTest('\n') } - public void testSuggestExpectedTypeMembersInCall() throws Throwable { doTest('\n') } + public void testExpectedTypesDotSelectsItem() throws Throwable { doTest('.') } public void testSuggestExpectedTypeMembersNonImported() throws Throwable { myFixture.addClass("package foo; public class Super { public static final Super FOO = null; }") diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java index c05a879af148..936028d22020 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupTypedHandler.java @@ -163,14 +163,14 @@ public class LookupTypedHandler extends TypedHandlerDelegate { final LookupElement currentItem = lookup.getCurrentItem(); if (currentItem != null && charTyped != ' ') { if (charTyped != '*' || filtersDecision != CharFilter.Result.SELECT_ITEM_AND_FINISH_LOOKUP) { - String postfix = lookup.getAdditionalPrefix() + charTyped; - final PrefixMatcher matcher = lookup.itemMatcher(currentItem); - if (matcher.cloneWithPrefix(matcher.getPrefix() + postfix).prefixMatches(currentItem)) { + if (charTyped == '*') { return CharFilter.Result.ADD_TO_PREFIX; } - for (final LookupElement element : lookup.getItems()) { - PrefixMatcher elementMatcher = lookup.itemMatcher(element); - if (elementMatcher.cloneWithPrefix(elementMatcher.getPrefix() + postfix).prefixMatches(element)) { + + String postfix = lookup.getAdditionalPrefix() + charTyped; + final PrefixMatcher matcher = lookup.itemMatcher(currentItem); + for (String lookupString : currentItem.getAllLookupStrings()) { + if (lookupString.startsWith(matcher.getPrefix() + postfix)) { return CharFilter.Result.ADD_TO_PREFIX; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java index 12c18d53385d..10809912feb9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateCharFilter.java @@ -27,6 +27,8 @@ public class LiveTemplateCharFilter extends CharFilter { public Result acceptChar(char c, int prefixLength, Lookup lookup) { LookupElement item = lookup.getCurrentItem(); if (item instanceof LiveTemplateLookupElement) { + if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX; + if (c == ((LiveTemplateLookupElement)item).getTemplate().getShortcutChar()) { return Result.SELECT_ITEM_AND_FINISH_LOOKUP; } diff --git a/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java b/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java index 9d5c7f785298..9f099628a0cc 100644 --- a/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java +++ b/xml/impl/src/com/intellij/codeInsight/completion/XmlCharFilter.java @@ -89,6 +89,7 @@ public class XmlCharFilter extends CharFilter { if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX; switch(c){ case '-': + case ':': return Result.ADD_TO_PREFIX; case '/': if (isWithinTag(lookup)) {