diff --git a/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinCallableInsertHandler.kt b/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinCallableInsertHandler.kt index 4052fbfd3a5..54ca749dfef 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinCallableInsertHandler.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinCallableInsertHandler.kt @@ -153,8 +153,7 @@ public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val if (completionChar == Lookup.REPLACE_SELECT_CHAR) { offset = skipSpaces(chars, offset) if (offset < document.getTextLength()) { - val c = chars[offset] - if (c == '<') { + if (chars[offset] == '<') { PsiDocumentManager.getInstance(context.getProject()).commitDocument(document) val psiFile = context.getFile() val token = psiFile.findElementAt(offset) diff --git a/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinClassInsertHandler.kt b/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinClassInsertHandler.kt index 3e8557165da..06dffb668d0 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinClassInsertHandler.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/handlers/KotlinClassInsertHandler.kt @@ -29,7 +29,6 @@ import com.intellij.psi.PsiClass import org.jetbrains.jet.lang.psi.JetNameReferenceExpression import org.jetbrains.jet.plugin.caches.resolve.getResolutionFacade import org.jetbrains.jet.lang.resolve.BindingContext -import org.jetbrains.jet.lang.resolve.DescriptorUtils import org.jetbrains.jet.lang.resolve.lazy.BodyResolveMode import org.jetbrains.jet.lang.descriptors.ClassKind @@ -53,13 +52,7 @@ public object KotlinClassInsertHandler : BaseDeclarationInsertHandler() { if (nameRef != null) { val bindingContext = nameRef.getResolutionFacade().analyze(nameRef, BodyResolveMode.PARTIAL) val target = bindingContext[BindingContext.REFERENCE_TARGET, nameRef] as? ClassDescriptor - if (target != null) { - val realTarget = if (target.getKind() == ClassKind.CLASS_OBJECT) - target.getContainingDeclaration() as ClassDescriptor - else - target - if (DescriptorUtils.getFqName(realTarget).asString() == qualifiedName) return - } + if (target != null && qualifiedNameForSourceCode(target) == qualifiedName) return } val tempPrefix = if (nameRef != null) diff --git a/idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt b/idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt new file mode 100644 index 00000000000..5a5a0971bb4 --- /dev/null +++ b/idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt @@ -0,0 +1,8 @@ +fun foo(p: Int){} + +fun f() { + f + (a + b).x() +} + +// ELEMENT: foo diff --git a/idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt.after b/idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt.after new file mode 100644 index 00000000000..0591fc7c5fd --- /dev/null +++ b/idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt.after @@ -0,0 +1,8 @@ +fun foo(p: Int){} + +fun f() { + foo() + (a + b).x() +} + +// ELEMENT: foo diff --git a/idea/tests/org/jetbrains/jet/completion/handlers/BasicCompletionHandlerTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/handlers/BasicCompletionHandlerTestGenerated.java index 412607e058f..660ea15e481 100644 --- a/idea/tests/org/jetbrains/jet/completion/handlers/BasicCompletionHandlerTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/completion/handlers/BasicCompletionHandlerTestGenerated.java @@ -42,6 +42,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } + @TestMetadata("DoNotUseParenthesisOnNextLine.kt") + public void testDoNotUseParenthesisOnNextLine() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/DoNotUseParenthesisOnNextLine.kt"); + doTest(fileName); + } + @TestMetadata("ExtensionReceiverTypeArg.kt") public void testExtensionReceiverTypeArg() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/ExtensionReceiverTypeArg.kt");