Dropped inspection for functions matching operator convention - only intention left

This commit is contained in:
Valentin Kipyatkov
2015-10-19 09:57:46 +03:00
parent ff60a13228
commit 0a5255ee4e
20 changed files with 62 additions and 97 deletions
@@ -1,6 +0,0 @@
<html>
<body>
This inspection reports functions that were overloading operators according to pre-M14 naming conventions
but are not annotated with the 'operator' modifier. The quickfix for the inspection adds the modifier.
</body>
</html>
-7
View File
@@ -1238,13 +1238,6 @@
level="WARNING"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.AddOperatorModifierInspection"
displayName="Missing 'operator' modifier"
groupName="Kotlin"
language="kotlin"
enabledByDefault="true"
level="WARNING"/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.ConflictingExtensionPropertyInspection"
displayName="Extension property conflicts with synthetic one"
groupName="Kotlin"
@@ -20,17 +20,10 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.util.OperatorChecks
//TODO: do we really need it?
public class AddOperatorModifierInspection : IntentionBasedInspection<JetNamedFunction>(
listOf(IntentionBasedInspection.IntentionData(AddOperatorModifierIntention())),
"Function defines an operator but isn't annotated as such",
JetNamedFunction::class.java)
class AddOperatorModifierIntention : JetSelfTargetingRangeIntention<JetNamedFunction>(JetNamedFunction::class.java, "Add 'operator' modifier") {
override fun applicabilityRange(element: JetNamedFunction): TextRange? {
val nameIdentifier = element.nameIdentifier ?: return null
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.AddOperatorModifierIntention
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
class A {
fun <caret>contains(other: A): Boolean = true
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
class A {
operator fun <caret>contains(other: A): Boolean = true
}
@@ -0,0 +1,4 @@
// IS_APPLICABLE: false
class A {
fun <caret>contains(other: A): Int = -1
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
class A {
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
class A {
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
open class A {
open fun plus(other: A): A = A()
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
open class A {
open fun plus(other: A): A = A()
}
@@ -1,6 +1,4 @@
// "Add 'operator' modifier" "false"
// ACTION: Convert to block body
// ACTION: Specify return type explicitly
// IS_APPLICABLE: false
open class A {
open operator fun plus(a: A) = A()
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
class A {
public fun <caret>plus(other: A): A = A()
}
@@ -1,4 +1,3 @@
// "Add 'operator' modifier" "true"
class A {
public operator fun plus(other: A): A = A()
}
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
class A {
}
fun <caret>plus(other: A): A = A()
@@ -1 +0,0 @@
org.jetbrains.kotlin.idea.intentions.AddOperatorModifierInspection
@@ -1,7 +0,0 @@
// "Add 'operator' modifier" "false"
// ACTION: Convert member to extension
// ACTION: Convert to block body
// ACTION: Remove explicit type specification
class A {
fun <caret>contains(other: A): Int = -1
}
@@ -1,7 +0,0 @@
// "Add 'operator' modifier" "false"
// ACTION: Convert to block body
// ACTION: Remove explicit type specification
class A {
}
fun <caret>plus(other: A): A = A()
@@ -311,6 +311,57 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
@TestMetadata("idea/testData/intentions/addOperatorModifier")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class AddOperatorModifier extends AbstractIntentionTest {
public void testAllFilesPresentInAddOperatorModifier() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addOperatorModifier"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("containsBool.kt")
public void testContainsBool() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/containsBool.kt");
doTest(fileName);
}
@TestMetadata("containsInt.kt")
public void testContainsInt() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/containsInt.kt");
doTest(fileName);
}
@TestMetadata("extension.kt")
public void testExtension() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/extension.kt");
doTest(fileName);
}
@TestMetadata("forOverride.kt")
public void testForOverride() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/forOverride.kt");
doTest(fileName);
}
@TestMetadata("overridden.kt")
public void testOverridden() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/overridden.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/simple.kt");
doTest(fileName);
}
@TestMetadata("toplevel.kt")
public void testToplevel() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addOperatorModifier/toplevel.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/intentions/branched")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -4295,57 +4295,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
}
}
@TestMetadata("idea/testData/quickfix/migration/operatorModifier")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class OperatorModifier extends AbstractQuickFixTest {
public void testAllFilesPresentInOperatorModifier() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/migration/operatorModifier"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("containsBool.kt")
public void testContainsBool() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/containsBool.kt");
doTest(fileName);
}
@TestMetadata("containsInt.kt")
public void testContainsInt() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/containsInt.kt");
doTest(fileName);
}
@TestMetadata("extension.kt")
public void testExtension() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/extension.kt");
doTest(fileName);
}
@TestMetadata("forOverride.kt")
public void testForOverride() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/forOverride.kt");
doTest(fileName);
}
@TestMetadata("overridden.kt")
public void testOverridden() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/overridden.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/simple.kt");
doTest(fileName);
}
@TestMetadata("toplevel.kt")
public void testToplevel() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/migration/operatorModifier/toplevel.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/quickfix/migration/removeNameFromFunctionExpression")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)