Revert "Completion fix for reserved 'async' syntax"

This reverts commit 318f0c89b2.
This commit is contained in:
Denis Zharkov
2016-05-19 14:09:05 +03:00
parent 3ede8f97e6
commit 5c1e17c8e7
10 changed files with 3 additions and 111 deletions
@@ -25,7 +25,6 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
import org.jetbrains.kotlin.idea.util.CallType
import org.jetbrains.kotlin.lexer.KtTokens
@@ -77,10 +76,10 @@ sealed class KotlinFunctionInsertHandler(callType: CallType<*>) : KotlinCallable
val startOffset = context.startOffset
val element = context.file.findElementAt(startOffset) ?: return
addArguments(context, element, item)
addArguments(context, element)
}
private fun addArguments(context: InsertionContext, offsetElement: PsiElement, item: LookupElement) {
private fun addArguments(context : InsertionContext, offsetElement : PsiElement) {
val completionChar = context.completionChar
if (completionChar == '(') { //TODO: more correct behavior related to braces type
context.setAddCompletionChar(false)
@@ -126,12 +125,6 @@ sealed class KotlinFunctionInsertHandler(callType: CallType<*>) : KotlinCallable
offset += 2
}
// insert additional brackets for reserved syntax: "async {}"
if (insertLambda && (item.`object` as? DeclarationLookupObject)?.name?.identifier == "async") {
document.insertString(offset, "()")
offset += 2
}
var openingBracketOffset = chars.indexOfSkippingSpace(openingBracket, offset)
var closeBracketOffset = openingBracketOffset?.let { chars.indexOfSkippingSpace(closingBracket, it + 1) }
var inBracketsShift = 0
@@ -219,4 +212,4 @@ sealed class KotlinFunctionInsertHandler(callType: CallType<*>) : KotlinCallable
psiDocumentManager.commitAllDocuments()
psiDocumentManager.doPostponedOperationsAndUnblockDocument(context.document)
}
}
}
@@ -1,7 +0,0 @@
fun async(a: () -> Unit) {}
fun test() {
asy<caret>
}
// ELEMENT: async
@@ -1,7 +0,0 @@
fun async(a: () -> Unit) {}
fun test() {
async() { <caret> }
}
// ELEMENT: async
@@ -1,7 +0,0 @@
fun async (p: Int, a: () -> Unit) {}
fun test() {
asy<caret>
}
// ELEMENT: async
@@ -1,7 +0,0 @@
fun async (p: Int, a: () -> Unit) {}
fun test() {
async(<caret>)
}
// ELEMENT: async
@@ -1,10 +0,0 @@
fun asyFoo(a: () -> Unit) {}
fun async(a: () -> Unit) {}
fun test() {
asy<caret>Foo { }
}
// ELEMENT: async
// CHAR: '\t'
@@ -1,10 +0,0 @@
fun asyFoo(a: () -> Unit) {}
fun async(a: () -> Unit) {}
fun test() {
async() { }
}
// ELEMENT: async
// CHAR: '\t'
@@ -1,10 +0,0 @@
fun asyFoo(p: Int, a: () -> Unit) {}
fun async(q: Int, a: () -> Unit) {}
fun test() {
asy<caret>Foo(5) { }
}
// ELEMENT: async
// CHAR: '\t'
@@ -1,10 +0,0 @@
fun asyFoo(p: Int, a: () -> Unit) {}
fun async(q: Int, a: () -> Unit) {}
fun test() {
async(<caret>5) { }
}
// ELEMENT: async
// CHAR: '\t'
@@ -402,39 +402,6 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt");
doTest(fileName);
}
@TestMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/async")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Async extends AbstractBasicCompletionHandlerTest {
public void testAllFilesPresentInAsync() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/handlers/basic/highOrderFunctions/async"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("AsyncSimple.kt")
public void testAsyncSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/async/AsyncSimple.kt");
doTest(fileName);
}
@TestMetadata("AsyncWithoutLambda.kt")
public void testAsyncWithoutLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/async/AsyncWithoutLambda.kt");
doTest(fileName);
}
@TestMetadata("FromFooToAsync.kt")
public void testFromFooToAsync() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/async/FromFooToAsync.kt");
doTest(fileName);
}
@TestMetadata("FromFooToAsync2.kt")
public void testFromFooToAsync2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/async/FromFooToAsync2.kt");
doTest(fileName);
}
}
}
@TestMetadata("idea/idea-completion/testData/handlers/basic/override")