Extract function: add default name for parameter

This commit is contained in:
Natalia Ukhorskaya
2014-12-23 16:43:11 +03:00
parent 87ab271f58
commit a894979c81
4 changed files with 23 additions and 1 deletions
@@ -610,7 +610,7 @@ private fun ExtractionData.inferParametersInfo(
with (parameter) {
if (currentName == null) {
currentName = JetNameSuggester.suggestNames(parameterType, varNameValidator, null).first()
currentName = JetNameSuggester.suggestNames(parameterType, varNameValidator, "p").first()
}
mirrorVarName = if (descriptorToExtract in modifiedVarDescriptors) varNameValidator.validateName(name) else null
info.parameters.add(this)
@@ -0,0 +1,6 @@
// PARAM_TYPES: kotlin.Array<T>, kotlin.Cloneable, Any
// PARAM_DESCRIPTOR: internal fun <T> kotlin.Array<T>.test(): kotlin.Unit defined in root package
// SIBLING:
fun <T> Array<T>.test() {
<selection>this.isEmpty()</selection>
}
@@ -0,0 +1,10 @@
// PARAM_TYPES: kotlin.Array<T>, kotlin.Cloneable, Any
// PARAM_DESCRIPTOR: internal fun <T> kotlin.Array<T>.test(): kotlin.Unit defined in root package
// SIBLING:
fun <T> Array<T>.test() {
unit()
}
private fun <T> Array<T>.unit() {
this.isEmpty()
}
@@ -354,6 +354,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/extractFunction/basic"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("extensionFunForArray.kt")
public void testExtensionFunForArray() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/extensionFunForArray.kt");
doExtractFunctionTest(fileName);
}
@TestMetadata("fragmentWithComment.kt")
public void testFragmentWithComment() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/extractFunction/basic/fragmentWithComment.kt");