removing static type assertions work in progress

This commit is contained in:
Dmitry Jemerov
2015-10-07 12:19:37 +02:00
parent 8f87efc0a2
commit 1523d5bcbf
149 changed files with 514 additions and 867 deletions
@@ -99,7 +99,7 @@ public object UsageTypeUtils {
with(refExpr.getParentOfTypeAndBranch<JetBinaryExpressionWithTypeRHS>(){ getRight() }) {
val opType = this?.getOperationReference()?.getReferencedNameElementType()
opType == JetTokens.AS_KEYWORD || opType == JetTokens.AS_SAFE || opType == JetTokens.COLON
opType == JetTokens.AS_KEYWORD || opType == JetTokens.AS_SAFE
} ->
CLASS_CAST_TO
@@ -167,7 +167,6 @@ public class KotlinCompletionContributor : CompletionContributor() {
val inIncompleteSignature = blockChild.siblings(forward = false, withItself = false).all {
when (it) {
is PsiWhiteSpace, is PsiComment -> true
is JetBinaryExpressionWithTypeRHS -> it.getOperationReference().getReferencedNameElementType() == JetTokens.COLON
else -> false
}
}
@@ -95,7 +95,6 @@ public class QuickFixRegistrar : QuickFixContributor {
VIRTUAL_MEMBER_HIDDEN.registerFactory(AddModifierFix.createFactory(OVERRIDE_KEYWORD))
USELESS_CAST.registerFactory(RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory("Remove cast"))
DEPRECATED_STATIC_ASSERT.registerFactory(RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory("Remove static type assertion"))
val changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory()
WRONG_SETTER_PARAMETER_TYPE.registerFactory(changeAccessorTypeFactory)
@@ -28,9 +28,6 @@ fun test() {
a as?
String
a :
String
a in
1..2
@@ -28,9 +28,6 @@ fun test() {
a as?
String
a :
String
a in
1..2
@@ -28,9 +28,6 @@ fun test() {
a as?
String
a :
String
a in
1..2
@@ -1,5 +1,5 @@
fun main(args: Array<String>) {
asse<caret>rt(false, "mess": kotlin.String)
asse<caret>rt(false, "mess" as kotlin.String)
}
// WITH_RUNTIME
@@ -1,6 +1,6 @@
fun main(args: Array<String>) {
if (!false) {
throw AssertionError("mess": kotlin.String)
throw AssertionError("mess" as kotlin.String)
}
}
@@ -1,6 +1,6 @@
// IS_APPLICABLE: true
fun foo() {
<caret>bar({ 2 * it }: (Int) -> Int)
<caret>bar({ 2 * it } as (Int) -> Int)
}
fun bar<T>(t: T): Int = 1
@@ -1,6 +1,6 @@
// IS_APPLICABLE: true
fun foo() {
bar<(Int) -> Int>({ 2 * it }: (Int) -> Int)
bar<(Int) -> Int>({ 2 * it } as (Int) -> Int)
}
fun bar<T>(t: T): Int = 1
@@ -1,4 +0,0 @@
// "Remove static type assertion" "true"
fun foo(a: String) {
val b = a <caret>: Any
}
@@ -1,4 +0,0 @@
// "Remove static type assertion" "true"
fun foo(a: String) {
val b = a
}
+1 -1
View File
@@ -1,7 +1,7 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
call("": String?<caret>?)
call("" as String?<caret>?)
}
fun call(s: String?) {}
-5
View File
@@ -1,5 +0,0 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
""<caret>!! : String
}
@@ -1,6 +0,0 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
(""<caret>!! : String)
}
@@ -2,7 +2,7 @@
fun foo() {
var v = Box<String?>()
(v: Box<String?<caret>?>)++
(v as Box<String?<caret>?>)++
}
class Box<T> {
@@ -2,7 +2,7 @@
fun foo() {
var v = Box<String?>()
++(v: Box<String?<caret>?>)
++(v as Box<String?<caret>?>)
}
class Box<T> {
@@ -3941,12 +3941,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/expressions"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("removeStaticTypeAssertion.kt")
public void testRemoveStaticTypeAssertion() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/removeStaticTypeAssertion.kt");
doTest(fileName);
}
@TestMetadata("removeUselessCast.kt")
public void testRemoveUselessCast() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/expressions/removeUselessCast.kt");
@@ -5687,12 +5681,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
doTest(fileName);
}
@TestMetadata("colon.kt")
public void testColon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/suppress/forStatement/colon.kt");
doTest(fileName);
}
@TestMetadata("doWhile.kt")
public void testDoWhile() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/suppress/forStatement/doWhile.kt");