Corrections after review + one more test added

This commit is contained in:
Valentin Kipyatkov
2014-12-24 14:16:40 +03:00
parent bfdbbe0247
commit 64da34e78b
5 changed files with 24 additions and 10 deletions
@@ -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)
@@ -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)
@@ -0,0 +1,8 @@
fun foo(p: Int){}
fun f() {
f<caret>
(a + b).x()
}
// ELEMENT: foo
@@ -0,0 +1,8 @@
fun foo(p: Int){}
fun f() {
foo(<caret>)
(a + b).x()
}
// ELEMENT: foo
@@ -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");