Added test for update on typing
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun <T> f(t1: T, t2: T){}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
f(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TYPE: "1"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Text: (<highlight>t1: Int</highlight>, t2: Int), Disabled: false, Strikeout: false, Green: true
|
||||||
|
*/
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun fff(p: String, c: Char) {}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
fff(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TYPE: "1, "
|
||||||
|
|
||||||
|
//Text: (p: String, <highlight>c: Char</highlight>), Disabled: true, Strikeout: false, Green: true
|
||||||
+14
-1
@@ -16,14 +16,17 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.parameterInfo
|
package org.jetbrains.kotlin.idea.parameterInfo
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiDocumentManager
|
||||||
import com.intellij.psi.PsiWhiteSpace
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
|
import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
|
||||||
import org.jetbrains.kotlin.lexer.JetTokens
|
import org.jetbrains.kotlin.lexer.JetTokens
|
||||||
import org.jetbrains.kotlin.psi.JetFile
|
import org.jetbrains.kotlin.psi.JetFile
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||||
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
||||||
abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCase() {
|
abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCase() {
|
||||||
@@ -50,9 +53,19 @@ abstract class AbstractFunctionParameterInfoTest : LightCodeInsightFixtureTestCa
|
|||||||
val mockCreateParameterInfoContext = MockCreateParameterInfoContext(file, myFixture)
|
val mockCreateParameterInfoContext = MockCreateParameterInfoContext(file, myFixture)
|
||||||
val parameterOwner = parameterInfoHandler.findElementForParameterInfo(mockCreateParameterInfoContext)
|
val parameterOwner = parameterInfoHandler.findElementForParameterInfo(mockCreateParameterInfoContext)
|
||||||
|
|
||||||
val updateContext = MockUpdateParameterInfoContext(file, myFixture)
|
val textToType = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// TYPE:")
|
||||||
|
if (textToType != null) {
|
||||||
|
project.executeWriteCommand("") {
|
||||||
|
val caretModel = myFixture.editor.caretModel
|
||||||
|
val offset = caretModel.offset
|
||||||
|
myFixture.getDocument(file).insertString(offset, textToType)
|
||||||
|
caretModel.moveToOffset(offset + textToType.length())
|
||||||
|
}
|
||||||
|
PsiDocumentManager.getInstance(project).commitAllDocuments()
|
||||||
|
}
|
||||||
|
|
||||||
//to update current parameter index
|
//to update current parameter index
|
||||||
|
val updateContext = MockUpdateParameterInfoContext(file, myFixture)
|
||||||
val elementForUpdating = parameterInfoHandler.findElementForUpdatingParameterInfo(updateContext)
|
val elementForUpdating = parameterInfoHandler.findElementForUpdatingParameterInfo(updateContext)
|
||||||
if (elementForUpdating != null) {
|
if (elementForUpdating != null) {
|
||||||
parameterInfoHandler.updateParameterInfo(elementForUpdating, updateContext)
|
parameterInfoHandler.updateParameterInfo(elementForUpdating, updateContext)
|
||||||
|
|||||||
+24
-12
@@ -149,27 +149,33 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("SubstituteFromParameters1.kt")
|
@TestMetadata("SubstituteFromArguments1.kt")
|
||||||
public void testSubstituteFromParameters1() throws Exception {
|
public void testSubstituteFromArguments1() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters1.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments1.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("SubstituteFromParameters2.kt")
|
@TestMetadata("SubstituteFromArguments2.kt")
|
||||||
public void testSubstituteFromParameters2() throws Exception {
|
public void testSubstituteFromArguments2() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters2.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments2.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("SubstituteFromParameters3.kt")
|
@TestMetadata("SubstituteFromArguments3.kt")
|
||||||
public void testSubstituteFromParameters3() throws Exception {
|
public void testSubstituteFromArguments3() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters3.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments3.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("SubstituteFromParameters4.kt")
|
@TestMetadata("SubstituteFromArguments4.kt")
|
||||||
public void testSubstituteFromParameters4() throws Exception {
|
public void testSubstituteFromArguments4() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromParameters4.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArguments4.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SubstituteFromArgumentsOnTyping.kt")
|
||||||
|
public void testSubstituteFromArgumentsOnTyping() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/SubstituteFromArgumentsOnTyping.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,4 +196,10 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete
|
|||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/TwoFunctionsGrey.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/TwoFunctionsGrey.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("UpdateOnTyping.kt")
|
||||||
|
public void testUpdateOnTyping() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/UpdateOnTyping.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user