JetWholeProjectForEachElementOfTypeFix - not too much duplicating string arguments
This commit is contained in:
@@ -166,9 +166,6 @@ migrate.class.object.to.companion.in.whole.project.modal.title=Replacing 'class'
|
||||
migrate.class.object.to.companion.in.whole.project.family=Replace 'class' Keyword with 'companion' Modifier in Whole Project
|
||||
migrate.lambda.syntax=Migrate lambda syntax
|
||||
migrate.lambda.syntax.family=Migrate lambda syntax
|
||||
migrate.lambda.syntax.in.whole.project=Migrate lambda syntax in whole project
|
||||
migrate.lambda.syntax.in.whole.project.modal.title=Migrating lambda syntax in whole project
|
||||
migrate.lambda.syntax.in.whole.project.family=Migrate lambda syntax in whole project
|
||||
remove.val.var.from.parameter=Remove ''{0}'' from parameter
|
||||
add.override.to.equals.hashCode.toString=Add 'override' to equals, hashCode, toString in project
|
||||
add.when.else.branch.action.family.name=Add Else Branch
|
||||
@@ -219,15 +216,9 @@ add.name.to.parameter.name.chooser.title=Choose parameter name
|
||||
|
||||
replace.java.class.argument=Replace javaClass<T>() with T::class
|
||||
replace.java.class.argument.family=Replace javaClass<T>() with T::class
|
||||
replace.java.class.argument.in.whole.project=Replace javaClass<T>() with T::class in whole project
|
||||
replace.java.class.argument.in.whole.project.family=Replace javaClass<T>() with T::class in whole project
|
||||
replace.java.class.argument.in.whole.project.modal.title=Replacing javaClass<T>() with T::class in whole project
|
||||
|
||||
replace.java.class.parameter=Replace Class<T> with KClass<T> in whole annotation
|
||||
replace.java.class.parameter.family=Replace Class<T> with KClass<T> in whole annotation
|
||||
replace.java.class.parameter.in.whole.project=Replace Class<T> with KClass<T> for each annotation in project
|
||||
replace.java.class.parameter.in.whole.project.family=Replace Class<T> with KClass<T> for each annotation in project
|
||||
replace.java.class.parameter.in.whole.project.modal.title=Replacing Class<T> with KClass<T> for each annotation in project
|
||||
|
||||
property.is.implemented.too.many=Has implementations
|
||||
property.is.overridden.too.many=Is overridden in subclasses
|
||||
|
||||
@@ -44,9 +44,7 @@ public class DeprecatedAnnotationSyntaxFix(element: JetAnnotation) : JetIntentio
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetAnnotation>(
|
||||
predicate = { it.isDeprecated() },
|
||||
taskProcessor = { replaceWithAtAnnotationEntries(it) },
|
||||
modalTitle = "Replacing deprecated annotations syntax",
|
||||
name = "Replace with '@' annotations in whole project",
|
||||
familyName = "Replace with '@' annotations in whole project"
|
||||
name = "Replace with '@' annotations in whole project"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -51,9 +51,7 @@ class DeprecatedEnumEntryDelimiterSyntaxFix(element: JetEnumEntry): JetIntention
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetEnumEntry>(
|
||||
predicate = { DeclarationsChecker.enumEntryUsesDeprecatedOrNoDelimiter(it) },
|
||||
taskProcessor = { insertLackingCommaSemicolon(it) },
|
||||
modalTitle = "Replacing deprecated enum entry delimiter syntax",
|
||||
name = "Insert lacking comma(s) / semicolon(s) in the whole project",
|
||||
familyName = "Insert lacking comma(s) / semicolon(s) in the whole project"
|
||||
name = "Insert lacking comma(s) / semicolon(s) in the whole project"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -54,9 +54,7 @@ class DeprecatedEnumEntrySuperConstructorSyntaxFix(element: JetEnumEntry): JetIn
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetEnumEntry>(
|
||||
predicate = { DeclarationsChecker.enumEntryUsesDeprecatedSuperConstructor(it) },
|
||||
taskProcessor = { changeConstructorToShort(it) },
|
||||
modalTitle = "Replacing deprecated enum constructor syntax",
|
||||
name = "Change to short enum entry super constructor in the whole project",
|
||||
familyName = "Change to short enum entry super constructor in the whole project"
|
||||
name = "Change to short enum entry super constructor in the whole project"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,7 @@ public class DeprecatedLambdaSyntaxFix(element: JetFunctionLiteralExpression) :
|
||||
JetWholeProjectForEachElementOfTypeFix.createByTaskFactory(
|
||||
taskFactory = fun (it: JetFunctionLiteralExpression) = fixTaskFactory(it),
|
||||
taskProcessor = { it.runFix() },
|
||||
modalTitle = JetBundle.message("migrate.lambda.syntax.in.whole.project.modal.title"),
|
||||
name = JetBundle.message("migrate.lambda.syntax.in.whole.project"),
|
||||
familyName = JetBundle.message("migrate.lambda.syntax.in.whole.project.family")
|
||||
name = "Migrate lambda syntax in whole project"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||
|
||||
public class DeprecatedTraitSyntaxFix(element: PsiElement): JetIntentionAction<PsiElement>(element), CleanupFix {
|
||||
override fun getFamilyName() = "Replace with 'interface'"
|
||||
override fun getFamilyName() = "Replace 'trait' with 'interface'"
|
||||
override fun getText() = getFamilyName()
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: JetFile?)
|
||||
@@ -48,9 +48,7 @@ public class DeprecatedTraitSyntaxFix(element: PsiElement): JetIntentionAction<P
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetClass>(
|
||||
predicate = { it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD) != null },
|
||||
taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD).getPsi())},
|
||||
modalTitle = "Replacing deprecated trait syntax",
|
||||
name = "Replace with 'interface' in whole project",
|
||||
familyName = "Replace with 'interface' in whole project"
|
||||
name = "Replace 'trait' with 'interface' in whole project"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,14 +115,13 @@ public abstract class JetWholeProjectModalByCollectionAction<T : Any>(modalTitle
|
||||
}
|
||||
|
||||
class JetWholeProjectForEachElementOfTypeFix<T> private (
|
||||
val collectingVisitorFactory: (MutableCollection<T>) -> JetVisitorVoid,
|
||||
val tasksProcessor: (Collection<T>) -> Unit,
|
||||
modalTitle: String,
|
||||
val name: String,
|
||||
val familyNameText: String
|
||||
) : JetWholeProjectModalByCollectionAction<T>(modalTitle) {
|
||||
private val collectingVisitorFactory: (MutableCollection<T>) -> JetVisitorVoid,
|
||||
private val tasksProcessor: (Collection<T>) -> Unit,
|
||||
private val name: String,
|
||||
private val familyName: String = name
|
||||
) : JetWholeProjectModalByCollectionAction<T>("Applying '$name'") {
|
||||
|
||||
override fun getFamilyName() = familyNameText
|
||||
override fun getFamilyName() = familyName
|
||||
override fun getText() = name
|
||||
|
||||
override fun collectTasksForFile(project: Project, file: JetFile, accumulator: MutableCollection<T>) {
|
||||
@@ -134,13 +133,11 @@ class JetWholeProjectForEachElementOfTypeFix<T> private (
|
||||
inline fun <reified E : JetElement> createByPredicate(
|
||||
noinline predicate: (E) -> Boolean,
|
||||
noinline taskProcessor: (E) -> Unit,
|
||||
modalTitle: String,
|
||||
name: String,
|
||||
familyName: String
|
||||
familyName: String = name
|
||||
) = createByTaskFactory<E, E>(
|
||||
taskFactory = { if (predicate(it)) it else null },
|
||||
taskProcessor = taskProcessor,
|
||||
modalTitle = modalTitle,
|
||||
name = name,
|
||||
familyName = familyName
|
||||
)
|
||||
@@ -148,13 +145,11 @@ class JetWholeProjectForEachElementOfTypeFix<T> private (
|
||||
inline fun <reified E : JetElement, D : Any> createByTaskFactory(
|
||||
noinline taskFactory: (E) -> D?,
|
||||
noinline taskProcessor: (D) -> Unit,
|
||||
modalTitle: String,
|
||||
name: String,
|
||||
familyName: String
|
||||
familyName: String = name
|
||||
) = createForMultiTask<E, D>(
|
||||
tasksFactory = { taskFactory(it).singletonOrEmptyList() },
|
||||
tasksProcessor = { it.forEach(taskProcessor) },
|
||||
modalTitle = modalTitle,
|
||||
name = name,
|
||||
familyName = familyName
|
||||
)
|
||||
@@ -162,15 +157,13 @@ class JetWholeProjectForEachElementOfTypeFix<T> private (
|
||||
inline fun <reified E : JetElement, D> createForMultiTask(
|
||||
noinline tasksFactory: (E) -> Collection<D>,
|
||||
noinline tasksProcessor: (Collection<D>) -> Unit,
|
||||
modalTitle: String,
|
||||
name: String,
|
||||
familyName: String
|
||||
familyName: String = name
|
||||
) = JetWholeProjectForEachElementOfTypeFix(
|
||||
collectingVisitorFactory = { accumulator -> flatMapDescendantsOfTypeVisitor(accumulator, tasksFactory) },
|
||||
tasksProcessor = tasksProcessor,
|
||||
modalTitle = modalTitle,
|
||||
name = name,
|
||||
familyNameText = familyName
|
||||
familyName = familyName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,7 @@ public class MissingConstructorKeywordFix(element: JetPrimaryConstructor) : JetI
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetPrimaryConstructor>(
|
||||
predicate = { it.getModifierList() != null && !it.hasConstructorKeyword() },
|
||||
taskProcessor = { it.addConstructorKeyword() },
|
||||
modalTitle = "Adding missing 'constructor' keyword",
|
||||
name = "Add missing 'constructor' keyword in whole project",
|
||||
familyName = "Add missing 'constructor' keyword in whole project"
|
||||
name = "Add missing 'constructor' keyword in whole project"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,7 @@ public class RemoveNameFromFunctionExpressionFix(element: JetNamedFunction) : Je
|
||||
JetWholeProjectForEachElementOfTypeFix.createByPredicate<JetNamedFunction>(
|
||||
predicate = { isFunctionExpression(it) },
|
||||
taskProcessor = { removeNameFromFunction(it) },
|
||||
modalTitle = "Removing identifier from function expressions",
|
||||
name = "Remove identifier from function expressions in the whole project",
|
||||
familyName = "Remove identifier from function expressions in the whole project"
|
||||
name = "Remove identifier from function expressions in the whole project"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +50,10 @@ public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIn
|
||||
if (!(diagnostic.getPsiElement().getNonStrictParentOfType<JetAnnotationEntry>()?.looksLikeObsoleteLabelWithReferencesInCode()
|
||||
?: false)) return@factory null
|
||||
|
||||
JetWholeProjectForEachElementOfTypeFix.createForMultiTask<JetAnnotatedExpression, JetAnnotationEntry>(
|
||||
JetWholeProjectForEachElementOfTypeFix.createForMultiTaskOnElement<JetAnnotatedExpression, JetAnnotationEntry>(
|
||||
tasksFactory = { collectTasks(it) },
|
||||
tasksProcessor ={ it.forEach { ann -> replaceWithLabel(ann) } },
|
||||
modalTitle = "Replacing labels with obsolete syntax",
|
||||
name = "Update obsolete label syntax in whole project",
|
||||
familyName = "Update obsolete label syntax in whole project"
|
||||
name = "Update obsolete label syntax in whole project"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -50,9 +50,7 @@ public class ReplaceJavaClassAsAnnotationArgumentFix(
|
||||
JetWholeProjectForEachElementOfTypeFix.createForMultiTask<JetAnnotationEntry, ReplacementTask>(
|
||||
tasksFactory = { createReplacementTasks(it) },
|
||||
tasksProcessor = ::processTasks,
|
||||
modalTitle = JetBundle.message("replace.java.class.argument.in.whole.project.modal.title"),
|
||||
name = JetBundle.message("replace.java.class.argument.in.whole.project"),
|
||||
familyName = JetBundle.message("replace.java.class.argument.in.whole.project.family")
|
||||
name = "Replace javaClass<T>() with T::class in whole project"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -48,9 +48,7 @@ public class ReplaceJavaClassAsAnnotationParameterFix(
|
||||
JetWholeProjectForEachElementOfTypeFix.createForMultiTask(
|
||||
tasksFactory = ::createReplacementTasksForAnnotationClass,
|
||||
tasksProcessor = ::processTasks,
|
||||
modalTitle = JetBundle.message("replace.java.class.parameter.in.whole.project.modal.title"),
|
||||
name = JetBundle.message("replace.java.class.parameter.in.whole.project"),
|
||||
familyName = JetBundle.message("replace.java.class.parameter.in.whole.project.family")
|
||||
name = "Replace Class<T> with KClass<T> for each annotation in project"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'interface'" "true"
|
||||
// "Replace 'trait' with 'interface'" "true"
|
||||
|
||||
<caret>trait Foo {
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace with 'interface'" "true"
|
||||
// "Replace 'trait' with 'interface'" "true"
|
||||
|
||||
<caret>interface Foo {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user