Introduce Variable: Do not suggest expressions without type
#KT-12922 Fixed
This commit is contained in:
@@ -241,6 +241,7 @@ Using 'this' as function argument in constructor of non-final class
|
|||||||
- [`KT-13082`](https://youtrack.jetbrains.com/issue/KT-13082) Rename: Fix exception on property rename preview
|
- [`KT-13082`](https://youtrack.jetbrains.com/issue/KT-13082) Rename: Fix exception on property rename preview
|
||||||
- [`KT-13207`](https://youtrack.jetbrains.com/issue/KT-13207) Safe delete: Fix exception when removing any function in 2016.2
|
- [`KT-13207`](https://youtrack.jetbrains.com/issue/KT-13207) Safe delete: Fix exception when removing any function in 2016.2
|
||||||
- [`KT-12945`](https://youtrack.jetbrains.com/issue/KT-12945) Rename: Fix function description in super method warning dialog
|
- [`KT-12945`](https://youtrack.jetbrains.com/issue/KT-12945) Rename: Fix function description in super method warning dialog
|
||||||
|
- [`KT-12922`](https://youtrack.jetbrains.com/issue/KT-12922) Introduce Variable: Do not suggest expressions without type
|
||||||
|
|
||||||
##### New features
|
##### New features
|
||||||
|
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ public class KotlinRefactoringUtil {
|
|||||||
KtExpression expression = (KtExpression)element;
|
KtExpression expression = (KtExpression)element;
|
||||||
BindingContext bindingContext = ResolutionUtils.analyze(expression, BodyResolveMode.FULL);
|
BindingContext bindingContext = ResolutionUtils.analyze(expression, BodyResolveMode.FULL);
|
||||||
KotlinType expressionType = bindingContext.getType(expression);
|
KotlinType expressionType = bindingContext.getType(expression);
|
||||||
if (expressionType != null && KotlinBuiltIns.isUnit(expressionType)) {
|
if (expressionType == null || KotlinBuiltIns.isUnit(expressionType)) {
|
||||||
addElement = false;
|
addElement = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
<caret>Arrays.asList(1, 2, 3)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val asList = Arrays.asList(1, 2, 3)
|
||||||
|
}
|
||||||
-1
@@ -5,5 +5,4 @@ fun main(args: Array<String>) {
|
|||||||
1.0
|
1.0
|
||||||
1.0 + 1
|
1.0 + 1
|
||||||
Math.pow(...)
|
Math.pow(...)
|
||||||
print(...)
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
+6
@@ -373,6 +373,12 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
|
|||||||
doIntroduceVariableTest(fileName);
|
doIntroduceVariableTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("skipClassReference.kt")
|
||||||
|
public void testSkipClassReference() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/skipClassReference.kt");
|
||||||
|
doIntroduceVariableTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("StringInjection.kt")
|
@TestMetadata("StringInjection.kt")
|
||||||
public void testStringInjection() throws Exception {
|
public void testStringInjection() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/StringInjection.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/StringInjection.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user