DirectiveBasedActionUtils: don't allow to specify ACTION directives that won't be checked anyway
This commit is contained in:
+7
-2
@@ -45,19 +45,24 @@ public object DirectiveBasedActionUtils {
|
||||
public fun checkAvailableActionsAreExpected(file: JetFile, availableActions: Collection<IntentionAction>) {
|
||||
val expectedActions = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:").sort()
|
||||
|
||||
UsefulTestCase.assertEmpty("Irrelevant actions should not be specified in ACTION directive for they are not checked anyway",
|
||||
expectedActions.filter { isIrrelevantAction(it) })
|
||||
|
||||
val actualActions = availableActions.map { it.getText() }.sort()
|
||||
|
||||
UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position. Use // ACTION: directive",
|
||||
filterOutIrrelevantActions(actualActions),
|
||||
filterOutIrrelevantActions(expectedActions))
|
||||
expectedActions)
|
||||
}
|
||||
|
||||
//TODO: hack, implemented because irrelevant actions behave in different ways on build server and locally
|
||||
// this behaviour should be investigated and hack can be removed
|
||||
private fun filterOutIrrelevantActions(actions: Collection<String>): Collection<String> {
|
||||
return actions.filter { action -> IRRELEVANT_ACTION_PREFIXES.none { action.startsWith(it) } }
|
||||
return actions.filter { !isIrrelevantAction(it) }
|
||||
}
|
||||
|
||||
private fun isIrrelevantAction(action: String) = IRRELEVANT_ACTION_PREFIXES.any { action.startsWith(it) }
|
||||
|
||||
private val IRRELEVANT_ACTION_PREFIXES = listOf(
|
||||
"Disable ",
|
||||
"Edit intention settings",
|
||||
|
||||
Vendored
-2
@@ -1,9 +1,7 @@
|
||||
// "class com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase" "false"
|
||||
// ERROR: Unresolved reference: SomeTest
|
||||
// ACTION: Create class 'SomeTest'
|
||||
// ACTION: Edit intention settings
|
||||
// ACTION: Replace safe access expression with 'if' expression
|
||||
// ACTION: Disable 'Replace Safe Access Expression with 'if' Expression'
|
||||
|
||||
package testing
|
||||
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
// "Create property 'foo'" "false"
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Disable 'Convert to Expression Body'
|
||||
// ACTION: Edit intention settings
|
||||
// ACTION: Create parameter 'foo'
|
||||
// ACTION: Create local variable 'foo'
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
Vendored
-2
@@ -1,7 +1,5 @@
|
||||
// "Create property 'foo'" "false"
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Disable 'Convert to Expression Body'
|
||||
// ACTION: Edit intention settings
|
||||
// ACTION: Create extension property 'foo'
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
// "Change 'A.x' type to '(Int) -> Int'" "false"
|
||||
// ACTION: Change 'C.x' type to '(String) -> Int'
|
||||
// ACTION: Disable inspection
|
||||
// ACTION: Edit inspection profile setting
|
||||
// ERROR: <html>Return type is '(kotlin.Int) → kotlin.Int', which is not a subtype of overridden<br/><b>internal</b> <b>abstract</b> <b>val</b> x: (kotlin.String) → kotlin.Int <i>defined in</i> A</html>
|
||||
interface A {
|
||||
val x: (String) -> Int
|
||||
|
||||
@@ -3,12 +3,6 @@
|
||||
// ACTION: Add function body
|
||||
// ACTION: Make 'foo' abstract
|
||||
// ACTION: Convert member to extension
|
||||
// ACTION: Disable 'Convert to extension'
|
||||
// ACTION: Disable inspection
|
||||
// ACTION: Disable inspection
|
||||
// ACTION: Edit inspection profile setting
|
||||
// ACTION: Edit inspection profile setting
|
||||
// ACTION: Edit intention settings
|
||||
|
||||
package a
|
||||
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
// "Change 'B.x' type to '(String) -> [ERROR : Ay]'" "false"
|
||||
// ACTION: Change 'A.x' type to '(Int) -> Int'
|
||||
// ACTION: Disable inspection
|
||||
// ACTION: Edit inspection profile setting
|
||||
// ERROR: <html>Return type is '(kotlin.Int) → kotlin.Int', which is not a subtype of overridden<br/><b>internal</b> <b>abstract</b> <b>val</b> x: (kotlin.String) → [ERROR : Ay] <i>defined in</i> A</html>
|
||||
// ERROR: Unresolved reference: Ay
|
||||
interface A {
|
||||
|
||||
-2
@@ -1,7 +1,5 @@
|
||||
// "Change parameter 'z' type of function 'foo' to '(Int) -> String'" "false"
|
||||
|
||||
// ACTION: Edit intention settings
|
||||
|
||||
fun foo(y: Int = 0, z: (Int) -> String = {""}) {
|
||||
foo {
|
||||
""<caret> as Int
|
||||
|
||||
-2
@@ -1,6 +1,4 @@
|
||||
// "Change 'foo' function return type to '([ERROR : NoSuchType]) -> Int'" "false"
|
||||
// ACTION: Disable 'Make Types Implicit In Lambda (May Break Code)'
|
||||
// ACTION: Edit intention settings
|
||||
// ACTION: Create annotation 'NoSuchType'
|
||||
// ACTION: Create class 'NoSuchType'
|
||||
// ACTION: Create enum 'NoSuchType'
|
||||
|
||||
-2
@@ -1,8 +1,6 @@
|
||||
// "Change 'AA.f' function return type to 'Boolean'" "false"
|
||||
// ACTION: Change 'AAA.g' function return type to 'Int'
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Disable 'Convert to Expression Body'
|
||||
// ACTION: Edit intention settings
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Boolean</td></tr><tr><td>Found:</td><td>kotlin.Int</td></tr></table></html>
|
||||
interface A {
|
||||
fun f(): Int
|
||||
|
||||
-4
@@ -1,10 +1,6 @@
|
||||
// "Change 'AA.contains' function return type to 'Int'" "false"
|
||||
// ACTION: Change 'AAA.g' function return type to 'Boolean'
|
||||
// ACTION: Convert to expression body
|
||||
// ACTION: Disable 'Convert to Expression Body'
|
||||
// ACTION: Disable 'Replace Overloaded Operator With Function Call'
|
||||
// ACTION: Edit intention settings
|
||||
// ACTION: Edit intention settings
|
||||
// ACTION: Replace overloaded operator with function call
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.Boolean</td></tr></table></html>
|
||||
interface A {
|
||||
|
||||
Reference in New Issue
Block a user