i18n: Internationalize part of the 'idea' module

This commit is contained in:
Yan Zhulanow
2020-02-21 22:36:20 +09:00
committed by Dmitry Gridin
parent fff9ab5ac3
commit 040204e36e
94 changed files with 964 additions and 344 deletions
@@ -1,8 +1,172 @@
fix.insert.delegation.call=Insert ''{0}()'' call
fix.introduce.non.null.assertion=Add non-null asserted (!!) call
fix.remove.non.null.assertion=Remove unnecessary non-null assertion (!!)
fix.add.annotation.target=Add annotation target
fix.add.const.modifier=Add ''const'' modifier
fix.add.constructor.parameter=Add constructor parameter ''{0}''
fix.make.data.class=Make ''{0}'' a ''data'' class
fix.add.default.constructor=Add default constructor to ''expect'' class
fix.add.explicit.import=Add explicit import
fix.add.function.body=Add function body
fix.add.is.to.when=Add ''is'' before ''{0}''
fix.add.new.line.after.annotations=Add new line after annotations
fix.make.type.parameter.reified=Make {0} reified and {1} inline
fix.add.return.last.expression=Add ''return'' to last expression
fix.add.return.before.expression=Add ''return'' before the expression
fix.add.return.before.lambda.expression=Add ''run'' before the lambda expression
fix.add.semicolon.lambda.expression=Terminate preceding call with semicolon
fix.add.spread.operator.after.sam=Add a spread operator before an array passing as ''vararg''
fix.add.else.branch.when=Add else branch
fix.replace.with.assign.function.call=Replace with ''{0}'' call
fix.assign.to.property=Assign to property
fix.change.mutability.change.to.val=Change ''{0}'' to ''val''
fix.change.type.argument=Change type argument to {0}
fix.change.to.function.invocation=Change to function invocation
fix.change.to.mutable.type=Change type to {0}
fix.change.to.property.access.family.remove=Remove invocation
fix.change.to.property.access.family.change=Change to property access
fix.change.to.labeled.return.family=Change to return with label
fix.change.to.labeled.return.text=Change to ''{0}''
fix.change.suspend.hierarchy.add=Add ''suspend'' modifier to all functions in hierarchy
fix.change.suspend.hierarchy.remove=Remove ''suspend'' modifier from all functions in hierarchy
fix.change.progress.looking.inheritors=Looking for class {0} inheritors…
fix.change.progress.analyzing.class.hierarchy=Analyzing class hierarchy…
fix.change.return.type.family=Change type
fix.change.return.type.text.primary.constructor=Change parameter ''{0}'' type of primary constructor of class ''{1}'' to ''{2}''
fix.change.return.type.text.function=Change parameter ''{0}'' type of function of class ''{1}'' to ''{2}''
fix.change.return.type.lambda=Change lambda expression return type to {0}
fix.change.return.type.remove.explicit.return.type=Remove explicitly specified return type
fix.change.return.type.remove.explicit.return.type.of=Remove explicitly specified return type of {0}
fix.change.return.type.return.type.text=Change return type to ''{0}''
fix.change.return.type.return.type.text.of=Change return type of {0} to ''{1}''
fix.change.return.type.type.text=Change type to ''{0}''
fix.change.return.type.type.text.of=Change type of {0} to ''{1}''
fix.change.return.type.presentation.property=property {0}
fix.change.return.type.presentation.function=function {0}
fix.change.return.type.presentation.enclosing.function=enclosing function
fix.change.return.type.presentation.enclosing=enclosing {0}
fix.change.return.type.presentation.called.function=called function
fix.change.return.type.presentation.accessed=accessed {0}
fix.change.return.type.presentation.called=called {0}
fix.change.return.type.presentation.base=base {0}
fix.cast.expression.family=Cast expression
fix.cast.expression.text=Cast expression ''{0}'' to ''{1}''
fix.change.accessor.family=Change accessor type
fix.change.accessor.getter=Change getter type to {0}
fix.change.accessor.setter.parameter=Change setter parameter type to {0}
fix.create.from.usage.dialog.title=Create from usage
fix.add.remaining.branches=Add remaining branches
fix.add.remaining.branches.with.star.import=Add remaining branches with * import
fix.add.type.annnotation.family=Add type annotation
fix.add.type.annnotation.text=Add type ''{0}'' to parameter ''{1}''
fix.add.tostring.call.family=Add ''toString()'' call
fix.add.tostring.call.text=Add ''toString()'' call
fix.add.tostring.call.text.safe=Add safe ''?.toString()'' call
fix.add.star.projection.family=Add star projections
fix.add.star.projection.text=Add ''{0}''
fix.change.to.star.projection.family=Change to star projection
fix.change.to.star.projection.text=Change type arguments to {0}
fix.change.to.use.spread.operator.family=Change to use spread operator
fix.change.to.use.spread.operator.text=Change ''{0}'' to ''{0}''
fix.change.type.family=Change type
fix.change.type.text=Change type from ''{0}'' to ''{1}''
fix.add.suspend.modifier.function=Make {0} suspend
fix.add.suspend.modifier.function.generic=Make containing function suspend
fix.add.suspend.modifier.receiver=Make {0} type suspend
fix.add.suspend.modifier.receiver.generic=Make receiver type suspend
fix.add.property.to.supertype.family=Add property to supertype
fix.add.property.to.supertype.text=Add ''{0}'' to ''{1}''
fix.add.property.to.supertype.text.generic=Add property to supertype…
fix.add.property.to.supertype.progress=Add property to type
fix.add.property.to.supertype.choose.type=Choose Type
fix.add.function.parameters.change.signature.constructor=Change the signature of constructor ''{0}''
fix.add.function.parameters.change.signature.function=Change the signature of function ''{0}''
fix.add.function.parameters.add.parameter.constructor=Add {0,number,ordinal} {1,choice,1#parameter|2#parameters to constructor {2}
fix.add.function.parameters.add.parameter.function=Add {0,number,ordinal} {1,choice,1#parameter|2#parameters to function {2}
fix.add.function.parameters.add.parameter.generic.constructor=Add parameter to constructor {0}
fix.add.function.parameters.add.parameter.generic.function=Add parameter to function {0}
fix.change.signature.family=Change signature of function/constructor
fix.change.signature.function.family=Change function signature
fix.change.signature.function.text=Change function signature to ''{0}''
fix.change.signature.function.text.generic=Change function signature…
fix.change.signature.function.popup.title=Choose Signature
fix.change.signature.lambda=Change the signature of lambda expression
fix.change.signature.remove.parameter=Remove parameter ''{0}''
fix.change.signature.unavailable=<not available>
fix.change.signature.error=<error>
fix.change.signature.unnamed.parameter=parameter
fix.change.object.to.class=Change ''object'' to ''class''
fix.add.function.supertype.family=Add function to supertype
fix.add.function.supertype.text=Add function to supertype…
fix.add.function.supertype.progress=Add Function to Type
fix.add.function.supertype.choose.type=Choose Type
fix.add.function.supertype.add.to=Add ''{0}'' to ''{1}''
fix.add.generic.upperbound.text=Add ''{0}'' as upper bound for {1}
fix.add.generic.upperbound.family=Add generic upper bound
fix.add.modifier.inline.parameter.family=Add ''{0}'' to parameter
fix.add.modifier.inline.parameter.text=Add ''{0}'' to parameter ''{1}''
fix.add.modifier.inline.function.family=Add ''inline'' to function
fix.add.modifier.inline.function.text=Add ''inline'' to function ''{0}''
fix.add.array.of.type.text=Add {0} wrapper
fix.add.array.of.type.family=Add ''arrayOf'' wrapper
fix.add.loop.label.text.generic=Add label to loop
fix.add.loop.label.text=Add ''{0}'' to {1}
fix.add.modifier.family=Add modifier
fix.add.modifier.text=Make {0} ''{1}''
fix.add.modifier.text.generic=Add ''{0}'' modifier
fix.add.argument.name.family=Add name to argument
fix.add.argument.name.text.generic=Add name to argument…
fix.add.argument.name.text=Add name to argument: {0}
fix.add.argument.name.step.choose.parameter.name=Choose parameter name
fix.change.feature.support.family=Enable/Disable {0} support
fix.change.feature.support.enabled=Enable {0} support
fix.change.feature.support.enabled.warning=Enable {0} support (with warning)
fix.change.feature.support.disabled=Disable {0} support
fix.create.expect.actual=Create expect / actual declaration
fix.create.missing.actual.members=Add missing actual members
fix.create.declaration.error=Can not generate {0}: {1}
fix.create.declaration.error.inaccessible.type=Inaccessible type
fix.create.declaration.error.some.types.inaccessible=Some types are not accessible:
fix.add.annotation.family=Add annotation
fix.add.annotation.text.self=Add ''{0}'' annotation
fix.add.annotation.text.declaration=Add ''{0}'' annotation to {1}
fix.add.annotation.text.containing.class=Add ''{0}'' annotation to containing class {1}
fix.import=Import
fix.change.return.type=Change type
fix.import.kind.delegate.accessors=Delegate accessors
fix.import.kind.component.functions=Component functions
fix.import.exclude=Exclude ''{0}'' from auto-import
action.add.import.chooser.title=Imports
@@ -13,6 +177,9 @@ goto.super.chooser.class.title=Choose super class or interface
inspection.unused.receiver.parameter=Receiver parameter is never used
fix.unused.receiver.parameter.remove=Remove redundant receiver parameter
inspection.migration.title=Code Migration
inspection.migration.profile.name=Migration
options.color.attribute.descriptor.annotation=Annotation//Annotation name
options.color.attribute.descriptor.annotation.attribute.name=Annotation//Annotation attribute name
options.color.attribute.descriptor.builtin.annotation=Keywords//Modifier
@@ -145,5 +312,158 @@ dialog.import.on.paste.title3=Select Import to Remove
copy.paste.reference.notification=<html>{0} {0, choice, 1#import was|2#imports were} added<p><span><a href='show'>Review Added Imports...</a></span></html>
# Experimental features
experimental.ml.completion=ML Completion for Kotlin
experimental.ml.completion=ML Completion for Kotlin
plugin.verifier.compatibility.issue.title=Compatibility issue
plugin.verifier.compatibility.issue.message=Installed Kotlin plugin version ({0}) is not compatible with {1}.\nSome functionality may be broken.\n\nPlease reinstall the Kotlin plugin.
plugin.updater.notification.group=Kotlin plugin updates
plugin.updater.notification.title=Kotlin
plugin.updater.notification.message=A new version {0} of the Kotlin plugin is available. <b><a href="#">Install</a></b>
plugin.updater.downloading=Downloading plugins
plugin.updater.not.installed=Plugin update was not installed. <a href="#">See the log for more information</a>
plugin.updater.not.installed.misc=Plugin update was not installed: {0}. <a href="#">See the log for more information</a>
plugin.updater.error.check.failed=Kotlin plugin update check failed
plugin.updater.error.unexpected.repository.response=Unexpected plugin repository response
plugin.updater.error.cant.find.plugin.version=Couldn't find plugin version in repository response
plugin.updater.error.custom.repository=Checking custom plugin repository {0} failed
quick.doc.text.enum.ordinal=Enum constant ordinal: {0}
quick.doc.text.tailrec=''tailrec'' marks a function as <a href="https://kotlinlang.org/docs/reference/functions.html#tail-recursive-functions">tail-recursive</a> (allowing the compiler to replace recursion with iteration)
quick.doc.text.lateinit=''lateinit'' allows initializing a <a href="https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties-and-variables">not-null property outside of a constructor</a>
quick.doc.no.documentation=No documentation available
quick.doc.section.deprecated=Deprecated:
quick.doc.section.replace.with=Replace with:
quick.doc.section.java.declaration=Java declaration:
action.decompile.java.name=Decompile to Java
action.decompile.busy.text=Kotlin Classfile
action.j2k.name=Convert Java to Kotlin
action.j2k.task.name=Convert files from Java to Kotlin
action.j2k.correction.investigate=Investigate Errors
action.j2k.correction.proceed=Proceed with Conversion
action.j2k.correction.required=Some code in the rest of your project may require corrections after performing this conversion. Do you want to find such code and correct it too?
action.j2k.correction.errors.single=''{0}'' contains syntax errors, the conversion result may be incorrect
action.j2k.correction.errors.multiple=''{0}'' and {1} other Java files contain syntax errors, the conversion result may be incorrect
action.j2k.error.cant.save.result=Failed to save conversion result: {0}
action.j2k.error.cant.find.document=couldn't find document for ''{0}''
action.j2k.error.read.only=file ''{0}'' is read-only
action.j2k.errornothing.to.convert=Nothing to convert:<br>No writable Java files found
formatter.settings.title=Kotlin Formatter Settings
action.generate.functions.already.defined=Functions {0} are already defined for class {1}. Do you want to delete them and proceed?
action.generate.equals.choose.equals=Choose properties to be included in ''equals()''
action.generate.equals.choose.hashcode=Choose properties to be included in ''hashCode()''
action.generate.secondary.constructor.choose.properties=Choose Properties to Initialize by Constructor
action.generate.secondary.constructor.error.already.exists=Constructor already exists
action.generate.test.support.choose.framework=Choose Framework
action.generate.test.support.generate.test.function=Generate test function
action.generate.test.support.choose.test.name=Choose test name:
action.generate.test.support.edit.template=Edit Template
action.generate.test.support.error.no.template.found=No template found for {0}:{1}
action.generate.test.support.error.cant.convert.java.template=Couldn't convert Java template to Kotlin
action.generate.test.support.error.cant.generate.method=Can not generate method: {0}
action.generate.tostring.name=Generate toString()
action.generate.tostring.template.single=Single template
action.generate.tostring.template.multiple=Multiple templates with concatenation
action.generate.tostring.choose.implementation=Choose implementation:
action.generate.tostring.generate.super.call=Generate call to super.toString()
action.new.file.text=Kotlin File/Class
action.new.file.description=Creates new Kotlin file or class
action.new.file.dialog.title=New Kotlin File/Class
action.new.file.dialog.file.title=File
action.new.file.dialog.file.description=Kotlin File
action.new.file.dialog.class.title=Class
action.new.file.dialog.class.description=Kotlin Class
action.new.file.dialog.interface.title=Interface
action.new.file.dialog.interface.description=Kotlin Interface
action.new.file.dialog.enum.title=Enum class
action.new.file.dialog.enum.description=Kotlin Enum
action.new.file.dialog.object.title=Object
action.new.file.dialog.object.description=Kotlin Object
action.new.file.error.empty.name=Name can't be empty
action.new.file.error.empty.name.part=Name can't have empty parts
action.new.script.name=Kotlin Script
action.new.script.description=Creates new Kotlin script
action.new.script.dialog.title=New Kotlin Script
action.new.script.template.name=Kotlin Script
action.new.worksheet.name=Kotlin Worksheet
action.new.worksheet.description=Creates new Kotlin Worksheet
action.new.worksheet.dialog.title=New Kotlin Worksheet
action.new.worksheet.template.name=Kotlin Worksheet
breadcrumbs.tooltip.indexing=Indexing…
copy.paste.resolve.references=Resolve pasted references
type.provider.anonymous.object=anonymous object
type.provider.unknown.type=Type is unknown
type.provider.smart.cast.from=(smart cast from {0})
type.provider.no.expression.found=No expression found
optimize.imports.collect.unused.imports=Collect unused imports
optimize.imports.task.removing.redundant.imports=Removing redundant imports
kdoc.section.title.receiver=Receiver
kdoc.section.title.parameters=Params
kdoc.section.title.returns=Returns
kdoc.section.title.throws=Throws
kdoc.section.title.author=Author
kdoc.section.title.since=Since
kdoc.section.title.samples=Samples
kdoc.section.title.see.also=See Also
kdoc.comment.unresolved=Unresolved
livetemplate.description.main=main() function
livetemplate.description.soutp=Prints function parameter names and values to System.out
livetemplate.description.iter=Iterate over elements of iterable (for-in loop)
livetemplate.description.ifn=Inserts ''if null'' expression
livetemplate.description.inn=Inserts ''if not null'' expression
livetemplate.description.void=Function returning nothing
livetemplate.description.fun0=Function with no parameters
livetemplate.description.fun1=Function with one parameter
livetemplate.description.fun2=Function with two parameters
livetemplate.description.interface=Interface
livetemplate.description.singleton=Singleton
livetemplate.description.closure=Closure (function without name)
livetemplate.description.anonymous=Anonymous class
livetemplate.description.exfun=Extension function
livetemplate.description.exval=Extension read-only property
livetemplate.description.exvar=Extension read-write property
hints.progress.calculating.parameter.info=Calculating parameter info
hints.title.property.type.enabled=Show property type hints
hints.title.property.type.disabled=Do not show property type hints
hints.title.locals.type.enabled=Show local variable type hints
hints.title.locals.type.disabled=Do not show local variable type hints
hints.title.function.type.enabled=Show function return type hints
hints.title.function.type.disabled=Do not show function return type hints
hints.title.parameter.type.enabled=Show parameter type hints
hints.title.parameter.type.disabled=Do not show parameter type hints
hints.title.argument.name.enabled=Show argument name hints
hints.title.argument.name.disabled=Do not show argument name hints
hints.title.return.expression.enabled=Show lambda return expression hints
hints.title.return.expression.disabled=Do not show lambda return expression hints
hints.title.implicit.parameters.enabled=Show hints for implicit receivers and parameters of lambdas
hints.title.implicit.parameters.disabled=Do not show hints for implicit receivers and parameters of lambdas
hints.title.suspend.calls.enabled=Show hints for suspending calls
hints.title.suspend.calls.disabled=Do not show hints for suspending calls
presentation.text.paren=({0})
presentation.text.in.container.paren=(in {0})
presentation.text.in.container={0} in {1}
presentation.text.for.receiver.in.container.paren=(for {0} in {1})
presentation.text.object.in.container=object in {0}
project.view.class.initializer=class initializer
>>>>>>> i18n: Internationalize part of the 'idea' module
@@ -17,10 +17,8 @@ object KotlinPluginCompatibilityVerifier {
if (kotlinVersion.platformVersion.platform != platformVersion.platform) {
Messages.showWarningDialog(
"Installed Kotlin plugin version ($kotlinVersion) is not compatible with $platformVersion.\n" +
"Some functionality may be broken.\n\n" +
"Please reinstall the Kotlin plugin.",
"Compatibility issue"
KotlinBundle.message("plugin.verifier.compatibility.issue.message", kotlinVersion, platformVersion),
KotlinBundle.message("plugin.verifier.compatibility.issue.title")
)
}
}
@@ -90,7 +90,10 @@ sealed class PluginUpdateStatus {
class KotlinPluginUpdater : Disposable {
private var updateDelay = INITIAL_UPDATE_DELAY
private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, this)
private val notificationGroup = NotificationGroup("Kotlin plugin updates", NotificationDisplayType.STICKY_BALLOON, true)
private val notificationGroup = NotificationGroup(
KotlinBundle.message("plugin.updater.notification.group"),
NotificationDisplayType.STICKY_BALLOON, true
)
@Volatile
private var checkQueued = false
@@ -156,7 +159,7 @@ class KotlinPluginUpdater : Disposable {
updateStatus = updateStatus.mergeWith(customUpdateStatus)
}
} catch (e: Exception) {
updateStatus = PluginUpdateStatus.fromException("Kotlin plugin update check failed", e)
updateStatus = PluginUpdateStatus.fromException(KotlinBundle.message("plugin.updater.error.check.failed"), e)
}
}
@@ -197,7 +200,10 @@ class KotlinPluginUpdater : Disposable {
JDOMUtil.load(it.inputStream)
}
if (responseDoc.name != "plugin-repository") {
return PluginUpdateStatus.CheckFailed("Unexpected plugin repository response", JDOMUtil.writeElement(responseDoc, "\n"))
return PluginUpdateStatus.CheckFailed(
KotlinBundle.message("plugin.updater.error.unexpected.repository.response"),
JDOMUtil.writeElement(responseDoc, "\n")
)
}
if (responseDoc.children.isEmpty()) {
// No plugin version compatible with current IDEA build; don't retry updates
@@ -205,7 +211,7 @@ class KotlinPluginUpdater : Disposable {
}
val newVersion = responseDoc.getChild("category")?.getChild("idea-plugin")?.getChild("version")?.text
?: return PluginUpdateStatus.CheckFailed(
"Couldn't find plugin version in repository response",
KotlinBundle.message("plugin.updater.error.cant.find.plugin.version"),
JDOMUtil.writeElement(responseDoc, "\n")
)
val pluginDescriptor = initPluginDescriptor(newVersion)
@@ -216,7 +222,7 @@ class KotlinPluginUpdater : Disposable {
val plugins = try {
RepositoryHelper.loadPlugins(host, null)
} catch (e: Exception) {
return PluginUpdateStatus.fromException("Checking custom plugin repository $host failed", e)
return PluginUpdateStatus.fromException(KotlinBundle.message("plugin.updater.error.custom.repository", host), e)
}
val kotlinPlugin = plugins.find { pluginDescriptor ->
@@ -241,8 +247,8 @@ class KotlinPluginUpdater : Disposable {
private fun notifyPluginUpdateAvailable(update: PluginUpdateStatus.Update) {
val notification = notificationGroup.createNotification(
"Kotlin",
"A new version ${update.pluginDescriptor.version} of the Kotlin plugin is available. <b><a href=\"#\">Install</a></b>",
KotlinBundle.message("plugin.updater.notification.title"),
KotlinBundle.message("plugin.updater.notification.message", update.pluginDescriptor.version),
NotificationType.INFORMATION,
NotificationListener { notification, _ ->
notification.expire()
@@ -261,7 +267,7 @@ class KotlinPluginUpdater : Disposable {
val descriptor = update.pluginDescriptor
val pluginDownloader = PluginDownloader.createDownloader(descriptor, update.hostToInstallFrom, null)
ProgressManager.getInstance().run(object : Task.Backgroundable(
null, "Downloading plugins", true, PluginManagerUISettings.getInstance()
null, KotlinBundle.message("plugin.updater.downloading"), true, PluginManagerUISettings.getInstance()
) {
override fun run(indicator: ProgressIndicator) {
var installed = false
@@ -300,10 +306,12 @@ class KotlinPluginUpdater : Disposable {
}
private fun notifyNotInstalled(message: String?) {
val fullMessage = message?.let { ": $it" } ?: ""
val notification = notificationGroup.createNotification(
"Kotlin",
"Plugin update was not installed$fullMessage. <a href=\"#\">See the log for more information</a>",
KotlinBundle.message("plugin.updater.notification.title"),
when (message) {
null -> KotlinBundle.message("plugin.updater.not.installed")
else -> KotlinBundle.message("plugin.updater.not.installed.misc", message)
},
NotificationType.INFORMATION,
NotificationListener { notification, _ ->
val logFile = File(PathManager.getLogPath(), "idea.log")
@@ -90,7 +90,10 @@ sealed class PluginUpdateStatus {
class KotlinPluginUpdater : Disposable {
private var updateDelay = INITIAL_UPDATE_DELAY
private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, this)
private val notificationGroup = NotificationGroup("Kotlin plugin updates", NotificationDisplayType.STICKY_BALLOON, true)
private val notificationGroup = NotificationGroup(
KotlinBundle.message("plugin.updater.notification.group"),
NotificationDisplayType.STICKY_BALLOON, true
)
@Volatile
private var checkQueued = false
@@ -156,7 +159,7 @@ class KotlinPluginUpdater : Disposable {
updateStatus = updateStatus.mergeWith(customUpdateStatus)
}
} catch (e: Exception) {
updateStatus = PluginUpdateStatus.fromException("Kotlin plugin update check failed", e)
updateStatus = PluginUpdateStatus.fromException(KotlinBundle.message("plugin.updater.error.check.failed"), e)
}
}
@@ -197,7 +200,10 @@ class KotlinPluginUpdater : Disposable {
JDOMUtil.load(it.inputStream)
}
if (responseDoc.name != "plugin-repository") {
return PluginUpdateStatus.CheckFailed("Unexpected plugin repository response", JDOMUtil.writeElement(responseDoc, "\n"))
return PluginUpdateStatus.CheckFailed(
KotlinBundle.message("plugin.updater.error.unexpected.repository.response"),
JDOMUtil.writeElement(responseDoc, "\n")
)
}
if (responseDoc.children.isEmpty()) {
// No plugin version compatible with current IDEA build; don't retry updates
@@ -205,7 +211,7 @@ class KotlinPluginUpdater : Disposable {
}
val newVersion = responseDoc.getChild("category")?.getChild("idea-plugin")?.getChild("version")?.text
?: return PluginUpdateStatus.CheckFailed(
"Couldn't find plugin version in repository response",
KotlinBundle.message("plugin.updater.error.cant.find.plugin.version"),
JDOMUtil.writeElement(responseDoc, "\n")
)
val pluginDescriptor = initPluginDescriptor(newVersion)
@@ -216,7 +222,7 @@ class KotlinPluginUpdater : Disposable {
val plugins = try {
RepositoryHelper.loadPlugins(host, null)
} catch (e: Exception) {
return PluginUpdateStatus.fromException("Checking custom plugin repository $host failed", e)
return PluginUpdateStatus.fromException(KotlinBundle.message("plugin.updater.error.custom.repository", host), e)
}
val kotlinPlugin = plugins.find { pluginDescriptor ->
@@ -241,8 +247,8 @@ class KotlinPluginUpdater : Disposable {
private fun notifyPluginUpdateAvailable(update: PluginUpdateStatus.Update) {
val notification = notificationGroup.createNotification(
"Kotlin",
"A new version ${update.pluginDescriptor.version} of the Kotlin plugin is available. <b><a href=\"#\">Install</a></b>",
KotlinBundle.message("plugin.updater.notification.title"),
KotlinBundle.message("plugin.updater.notification.message", update.pluginDescriptor.version),
NotificationType.INFORMATION,
NotificationListener { notification, _ ->
notification.expire()
@@ -261,7 +267,7 @@ class KotlinPluginUpdater : Disposable {
val descriptor = update.pluginDescriptor
val pluginDownloader = PluginDownloader.createDownloader(descriptor, update.hostToInstallFrom, null)
ProgressManager.getInstance().run(object : Task.Backgroundable(
null, "Downloading plugins", true, PluginManagerUISettings.getInstance()
null, KotlinBundle.message("plugin.updater.downloading"), true, PluginManagerUISettings.getInstance()
) {
override fun run(indicator: ProgressIndicator) {
var installed = false
@@ -300,10 +306,12 @@ class KotlinPluginUpdater : Disposable {
}
private fun notifyNotInstalled(message: String?) {
val fullMessage = message?.let { ": $it" } ?: ""
val notification = notificationGroup.createNotification(
"Kotlin",
"Plugin update was not installed$fullMessage. <a href=\"#\">See the log for more information</a>",
KotlinBundle.message("plugin.updater.notification.title"),
when (message) {
null -> KotlinBundle.message("plugin.updater.not.installed")
else -> KotlinBundle.message("plugin.updater.not.installed.misc", message)
},
NotificationType.INFORMATION,
NotificationListener { notification, _ ->
val logFile = File(PathManager.getLogPath(), "idea.log")
@@ -22,8 +22,6 @@ import com.intellij.psi.PsiWhiteSpace
import org.jetbrains.kotlin.asJava.LightClassUtil
import org.jetbrains.kotlin.asJava.elements.KtLightDeclaration
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.DocumentationURLs.LATE_INITIALIZED_PROPERTIES_AND_VARIABLES_URL
import org.jetbrains.kotlin.idea.DocumentationURLs.TAIL_RECURSIVE_FUNCTIONS_URL
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
@@ -57,14 +55,6 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.utils.addToStdlib.constant
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
private object DocumentationURLs {
const val LATE_INITIALIZED_PROPERTIES_AND_VARIABLES_URL =
"https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties-and-variables"
const val TAIL_RECURSIVE_FUNCTIONS_URL =
"https://kotlinlang.org/docs/reference/functions.html#tail-recursive-functions"
}
class HtmlClassifierNamePolicy(val base: ClassifierNamePolicy) : ClassifierNamePolicy {
override fun renderClassifier(classifier: ClassifierDescriptor, renderer: DescriptorRenderer): String {
if (DescriptorUtils.isAnonymousObject(classifier)) {
@@ -272,7 +262,7 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
definition {
it.inherit()
ordinal?.let {
append("<br>Enum constant ordinal: $ordinal")
append("<br>").append(KotlinBundle.message("quick.doc.text.enum.ordinal", ordinal))
}
}
}
@@ -286,17 +276,8 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
return renderKotlinDeclaration(origin, quickNavigation)
} else if (element.isModifier()) {
when (element.text) {
KtTokens.LATEINIT_KEYWORD.value -> {
return "lateinit allows initializing a ${a(
LATE_INITIALIZED_PROPERTIES_AND_VARIABLES_URL,
"non-null property outside of a constructor"
)}"
}
KtTokens.TAILREC_KEYWORD.value -> {
return "tailrec marks a function as ${a(TAIL_RECURSIVE_FUNCTIONS_URL, "tail-recursive")} " +
"(allowing the compiler to replace recursion with iteration)"
}
KtTokens.LATEINIT_KEYWORD.value -> return KotlinBundle.message("quick.doc.text.lateinit")
KtTokens.TAILREC_KEYWORD.value -> return KotlinBundle.message("quick.doc.text.tailrec")
}
}
@@ -328,7 +309,7 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
LOG.info("Failed to find descriptor for declaration " + declaration.getElementTextWithContext())
return KDocTemplate.NoDocTemplate().apply {
error {
append("No documentation available")
append(KotlinBundle.message("quick.doc.no.documentation"))
}
}
}
@@ -455,14 +436,14 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
deprecation {
deprecationInfo.message?.let { message ->
append(SECTION_HEADER_START)
append("Deprecated:")
append(KotlinBundle.message("quick.doc.section.deprecated"))
append(SECTION_SEPARATOR)
append(message.htmlEscape())
append(SECTION_END)
}
deprecationInfo.deprecatedByAnnotationReplaceWithExpression()?.let { replaceWith ->
append(SECTION_HEADER_START)
append("Replace with:")
append(KotlinBundle.message("quick.doc.section.replace.with"))
append(SECTION_SEPARATOR)
wrapTag("code") { append(replaceWith.htmlEscape()) }
append(SECTION_END)
@@ -482,10 +463,6 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
wrap("<$tag>", "</$tag>", body)
}
private fun a(url: String, text: String): String {
return """<a href="$url">$text</a>"""
}
private fun mixKotlinToJava(
declarationDescriptor: DeclarationDescriptor,
element: PsiElement,
@@ -496,7 +473,7 @@ class KotlinQuickDocumentationProvider : AbstractDocumentationProvider() {
val originalInfo = JavaDocumentationProvider().getQuickNavigateInfo(element, originalElement)
if (originalInfo != null) {
val renderedDecl = constant { DESCRIPTOR_RENDERER.withOptions { withDefinedIn = false } }.render(declarationDescriptor)
return "$renderedDecl<br/>Java declaration:<br/>$originalInfo"
return "$renderedDecl<br/>" + KotlinBundle.message("quick.doc.section.java.declaration") + "<br/>$originalInfo"
}
return null
@@ -13,6 +13,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.roots.LibraryOrderEntry
import com.intellij.openapi.util.ActionCallback
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.internal.showDecompiledCode
import org.jetbrains.kotlin.idea.util.isRunningInCidrIde
import org.jetbrains.kotlin.psi.KtFile
@@ -52,14 +53,14 @@ class DecompileKotlinToJavaActionProvider : AttachSourcesProvider {
if (psiFile !is KtFile || !psiFile.canBeDecompiledToJava()) return emptyList()
return listOf(object : AttachSourcesProvider.AttachSourcesAction {
override fun getName() = "Decompile to Java"
override fun getName() = KotlinBundle.message("action.decompile.java.name")
override fun perform(orderEntriesContainingFile: List<LibraryOrderEntry>?): ActionCallback {
showDecompiledCode(psiFile)
return ActionCallback.DONE
}
override fun getBusyText() = "Kotlin Classfile"
override fun getBusyText() = KotlinBundle.message("action.decompile.busy.text")
})
}
}
@@ -46,6 +46,7 @@ import com.intellij.psi.PsiErrorElement
import com.intellij.psi.PsiJavaFile
import com.intellij.psi.PsiManager
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.configuration.ExperimentalFeatures
import org.jetbrains.kotlin.idea.core.util.toPsiFile
@@ -78,7 +79,7 @@ class JavaToKotlinAction : AnAction() {
}
}
val title = "Convert Java to Kotlin"
val title = KotlinBundle.message("action.j2k.name")
private fun saveResults(javaFiles: List<PsiJavaFile>, convertedTexts: List<String>): List<VirtualFile> {
val result = ArrayList<VirtualFile>()
@@ -86,13 +87,13 @@ class JavaToKotlinAction : AnAction() {
try {
val document = PsiDocumentManager.getInstance(psiFile.project).getDocument(psiFile)
val errorMessage = when {
document == null -> "couldn't find document for ${psiFile.name}"
!document.isWritable -> "file `${psiFile.name}` is read-only"
document == null -> KotlinBundle.message("action.j2k.error.cant.find.document", psiFile.name)
!document.isWritable -> KotlinBundle.message("action.j2k.error.read.only", psiFile.name)
else -> null
}
if (errorMessage != null) {
MessagesEx.error(psiFile.project, "Failed to save conversion result: $errorMessage")
.showLater()
val message = KotlinBundle.message("action.j2k.error.cant.save.result", errorMessage)
MessagesEx.error(psiFile.project, message).showLater()
continue
}
document!!.replaceString(0, document.textLength, text)
@@ -176,8 +177,7 @@ class JavaToKotlinAction : AnAction() {
val result = converterResult ?: return emptyList()
val externalCodeProcessing = result.externalCodeProcessing
if (enableExternalCodeProcessing && externalCodeProcessing != null) {
val question =
"Some code in the rest of your project may require corrections after performing this conversion. Do you want to find such code and correct it too?"
val question = KotlinBundle.message("action.j2k.correction.required")
if (!askExternalCodeProcessing || (Messages.showYesNoDialog(
project,
question,
@@ -200,7 +200,7 @@ class JavaToKotlinAction : AnAction() {
}
}
return project.executeWriteCommand("Convert files from Java to Kotlin", null) {
return project.executeWriteCommand(KotlinBundle.message("action.j2k.task.name"), null) {
CommandProcessor.getInstance().markCurrentCommandAsGlobal(project)
val newFiles = saveResults(javaFiles, result.results)
@@ -228,7 +228,7 @@ class JavaToKotlinAction : AnAction() {
if (javaFiles.isEmpty()) {
val statusBar = WindowManager.getInstance().getStatusBar(project)
JBPopupFactory.getInstance()
.createHtmlTextBalloonBuilder("Nothing to convert:<br>No writable Java files found", MessageType.ERROR, null)
.createHtmlTextBalloonBuilder(KotlinBundle.message("action.j2k.errornothing.to.convert"), MessageType.ERROR, null)
.createBalloon()
.showInCenterOf(statusBar.component)
}
@@ -239,12 +239,14 @@ class JavaToKotlinAction : AnAction() {
if (firstSyntaxError != null) {
val count = javaFiles.filter { PsiTreeUtil.hasErrorElements(it) }.count()
val question = firstSyntaxError.containingFile.name +
(if (count > 1) " and ${count - 1} more Java files" else " file") +
" contain syntax errors, the conversion result may be incorrect"
val okText = "Investigate Errors"
val cancelText = "Proceed with Conversion"
assert(count > 0)
val firstFileName = firstSyntaxError.containingFile.name
val question = when (count) {
1 -> KotlinBundle.message("action.j2k.correction.errors.single", firstFileName)
else -> KotlinBundle.message("action.j2k.correction.errors.multiple", firstFileName, count - 1)
}
val okText = KotlinBundle.message("action.j2k.correction.investigate")
val cancelText = KotlinBundle.message("action.j2k.correction.proceed")
if (Messages.showOkCancelDialog(
project,
question,
@@ -203,7 +203,7 @@ class KotlinAddImportAction internal constructor(
return object : BaseListPopupStep<String>(null, toExclude) {
override fun getTextFor(value: String): String {
return "Exclude '$value' from auto-import"
return KotlinBundle.message("fix.import.exclude", value)
}
override fun onChosen(selectedValue: String, finalChoice: Boolean): PopupStep<Any>? {
@@ -40,6 +40,7 @@ import com.intellij.psi.PsiDirectory
import com.intellij.psi.PsiFile
import com.intellij.util.IncorrectOperationException
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.statistics.FUSEventGroups
@@ -53,8 +54,8 @@ import org.jetbrains.kotlin.psi.KtNamedDeclaration
import java.util.*
class NewKotlinFileAction : CreateFileFromTemplateAction(
"Kotlin File/Class",
"Creates new Kotlin file or class",
KotlinBundle.message("action.new.file.text"),
KotlinBundle.message("action.new.file.description"),
KotlinFileType.INSTANCE.icon
), DumbAware {
override fun postProcess(createdElement: PsiFile?, templateName: String?, customProperties: Map<String, String>?) {
@@ -85,17 +86,39 @@ class NewKotlinFileAction : CreateFileFromTemplateAction(
}
override fun buildDialog(project: Project, directory: PsiDirectory, builder: CreateFileFromTemplateDialog.Builder) {
builder.setTitle("New Kotlin File/Class")
.addKind("File", KotlinFileType.INSTANCE.icon, "Kotlin File")
.addKind("Class", KotlinIcons.CLASS, "Kotlin Class")
.addKind("Interface", KotlinIcons.INTERFACE, "Kotlin Interface")
.addKind("Enum class", KotlinIcons.ENUM, "Kotlin Enum")
.addKind("Object", KotlinIcons.OBJECT, "Kotlin Object")
builder.setTitle(KotlinBundle.message("action.new.file.dialog.title"))
.addKind(
KotlinBundle.message("action.new.file.dialog.file.title"),
KotlinFileType.INSTANCE.icon,
KotlinBundle.message("action.new.file.dialog.file.description")
)
.addKind(
KotlinBundle.message("action.new.file.dialog.class.title"),
KotlinIcons.CLASS,
KotlinBundle.message("action.new.file.dialog.class.description")
)
.addKind(
KotlinBundle.message("action.new.file.dialog.interface.title"),
KotlinIcons.INTERFACE,
KotlinBundle.message("action.new.file.dialog.interface.description")
)
.addKind(
KotlinBundle.message("action.new.file.dialog.enum.title"),
KotlinIcons.ENUM,
KotlinBundle.message("action.new.file.dialog.enum.description")
)
.addKind(
KotlinBundle.message("action.new.file.dialog.object.title"),
KotlinIcons.OBJECT,
KotlinBundle.message("action.new.file.dialog.object.description")
)
builder.setValidator(NameValidator)
}
override fun getActionName(directory: PsiDirectory, newName: String, templateName: String) = "Kotlin File/Class"
override fun getActionName(directory: PsiDirectory, newName: String, templateName: String): String {
return KotlinBundle.message("action.new.file.text")
}
override fun isAvailable(dataContext: DataContext): Boolean {
if (super.isAvailable(dataContext)) {
@@ -124,12 +147,12 @@ class NewKotlinFileAction : CreateFileFromTemplateAction(
private object NameValidator : InputValidatorEx {
override fun getErrorText(inputString: String): String? {
if (inputString.trim().isEmpty()) {
return "Name can't be empty"
return KotlinBundle.message("action.new.file.error.empty.name")
}
val parts: List<String> = inputString.split(*FQNAME_SEPARATORS)
if (parts.any { it.trim().isEmpty() }) {
return "Name can't have empty parts"
return KotlinBundle.message("action.new.file.error.empty.name.part")
}
return null
@@ -208,7 +231,10 @@ class NewKotlinFileAction : CreateFileFromTemplateAction(
fun createFileFromTemplate(name: String, template: FileTemplate, dir: PsiDirectory): PsiFile? {
val directorySeparators = if (template.name == "Kotlin File") FILE_SEPARATORS else FQNAME_SEPARATORS
val directorySeparators = when (template.name) {
KotlinBundle.message("action.new.file.dialog.file.description") -> FILE_SEPARATORS
else -> FQNAME_SEPARATORS
}
val (className, targetDir) = findOrCreateTarget(dir, name, directorySeparators)
val service = DumbService.getInstance(dir.project)
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiDirectory
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.psi.KtFile
@@ -28,10 +29,10 @@ open class NewKotlinScriptAction(
), DumbAware {
constructor() : this(
actionName = "Kotlin Script",
description = "Creates new Kotlin script",
dialogTitle = "New Kotlin Script",
templateName = "Kotlin Script"
actionName = KotlinBundle.message("action.new.script.name"),
description = KotlinBundle.message("action.new.script.description"),
dialogTitle = KotlinBundle.message("action.new.script.dialog.title"),
templateName = KotlinBundle.message("action.new.script.template.name")
)
override fun postProcess(createdElement: PsiFile, templateName: String?, customProperties: Map<String, String>?) {
@@ -8,14 +8,15 @@ package org.jetbrains.kotlin.idea.actions
import com.intellij.ide.fileTemplates.FileTemplate
import com.intellij.psi.PsiDirectory
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.idea.KotlinBundle
const val KOTLIN_WORKSHEET_EXTENSION: String = "ws.kts"
class NewKotlinWorksheetAction : NewKotlinScriptAction(
actionName = "Kotlin Worksheet",
description = "Creates new Kotlin Worksheet",
dialogTitle = "New Kotlin Worksheet",
templateName = "Kotlin Worksheet"
actionName = KotlinBundle.message("action.new.worksheet.name"),
description = KotlinBundle.message("action.new.worksheet.description"),
dialogTitle = KotlinBundle.message("action.new.worksheet.dialog.title"),
templateName = KotlinBundle.message("action.new.worksheet.template.name")
) {
override fun createFileFromTemplate(name: String, template: FileTemplate, dir: PsiDirectory): PsiFile? {
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.VerticalFlowLayout
import com.intellij.refactoring.classMembers.AbstractMemberInfoModel
import com.intellij.ui.NonFocusableCheckBox
import com.intellij.util.containers.HashMap
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.isInheritable
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPanel
@@ -60,13 +61,13 @@ class KotlinGenerateEqualsWizard(
init {
equalsPanel = if (needEquals) {
KotlinMemberSelectionPanel("Choose properties to be included in equals()", memberInfos, null).apply {
KotlinMemberSelectionPanel(KotlinBundle.message("action.generate.equals.choose.equals"), memberInfos, null).apply {
table.memberInfoModel = MemberInfoModelImpl
}
} else null
hashCodePanel = if (needHashCode) {
KotlinMemberSelectionPanel("Choose properties to be included in hashCode()", memberInfos, null).apply {
KotlinMemberSelectionPanel(KotlinBundle.message("action.generate.equals.choose.hashcode"), memberInfos, null).apply {
table.memberInfoModel = MemberInfoModelImpl
}
} else null
@@ -25,6 +25,7 @@ import com.intellij.openapi.ui.VerticalFlowLayout
import com.intellij.refactoring.classMembers.AbstractMemberInfoModel
import com.intellij.ui.NonFocusableCheckBox
import com.intellij.util.containers.HashMap
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.isInheritable
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberInfo
import org.jetbrains.kotlin.idea.refactoring.memberInfo.KotlinMemberSelectionPanel
@@ -60,13 +61,13 @@ class KotlinGenerateEqualsWizard(
init {
equalsPanel = if (needEquals) {
KotlinMemberSelectionPanel("Choose properties to be included in equals()", memberInfos, null).apply {
KotlinMemberSelectionPanel(KotlinBundle.message("action.generate.equals.choose.equals"), memberInfos, null).apply {
table.memberInfoModel = MemberInfoModelImpl
}
} else null
hashCodePanel = if (needHashCode) {
KotlinMemberSelectionPanel("Choose properties to be included in hashCode()", memberInfos, null).apply {
KotlinMemberSelectionPanel(KotlinBundle.message("action.generate.equals.choose.hashcode"), memberInfos, null).apply {
table.memberInfoModel = MemberInfoModelImpl
}
} else null
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.*
@@ -81,7 +82,7 @@ class KotlinGenerateSecondaryConstructorAction : KotlinGenerateMemberActionBase<
if (ApplicationManager.getApplication().isUnitTestMode || candidates.isEmpty()) return candidates
return with(MemberChooser(candidates.toTypedArray(), true, true, klass.project, false, null)) {
title = "Choose Properties to Initialize by Constructor"
title = KotlinBundle.message("action.generate.secondary.constructor.choose.properties")
setCopyJavadocVisible(false)
selectElements(candidates.filter { shouldPreselect(it.element) }.toTypedArray())
show()
@@ -118,7 +119,8 @@ class KotlinGenerateSecondaryConstructorAction : KotlinGenerateMemberActionBase<
}
if (prototypes.isEmpty()) {
CommonRefactoringUtil.showErrorHint(targetClass.project, editor, "Constructor already exists", commandName, null)
val errorText = KotlinBundle.message("action.generate.secondary.constructor.error.already.exists")
CommonRefactoringUtil.showErrorHint(targetClass.project, editor, errorText, commandName, null)
return emptyList()
}
@@ -30,6 +30,7 @@ import com.intellij.ui.components.JBList
import com.intellij.util.IncorrectOperationException
import org.jetbrains.kotlin.asJava.toLightClass
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
import org.jetbrains.kotlin.idea.core.insertMember
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideMemberChooserObject.BodyType
@@ -64,7 +65,7 @@ abstract class KotlinGenerateTestSupportActionBase(
list.cellRenderer = TestFrameworkListCellRenderer()
PopupChooserBuilder<TestFramework>(list).setFilteringEnabled { (it as TestFramework).name }
.setTitle("Choose Framework")
.setTitle(KotlinBundle.message("action.generate.test.support.choose.framework"))
.setItemChoosenCallback { consumer(list.selectedValue as TestFramework) }
.setMovable(true)
.createPopup()
@@ -136,7 +137,7 @@ abstract class KotlinGenerateTestSupportActionBase(
private fun doGenerate(editor: Editor, file: PsiFile, klass: KtClassOrObject, framework: TestFramework) {
val project = file.project
val commandName = "Generate test function"
val commandName = KotlinBundle.message("action.generate.test.support.generate.test.function")
val fileTemplateDescriptor = methodKind.getFileTemplateDescriptor(framework)
val fileTemplate = FileTemplateManager.getInstance(project).getCodeTemplate(fileTemplateDescriptor.fileName)
@@ -145,8 +146,8 @@ abstract class KotlinGenerateTestSupportActionBase(
if (templateText.contains(NAME_VAR)) {
name = if (templateText.contains("test$NAME_VAR")) "Name" else "name"
if (!ApplicationManager.getApplication().isUnitTestMode) {
name = Messages.showInputDialog("Choose test name: ", commandName, null, name, NAME_VALIDATOR)
?: return
val message = KotlinBundle.message("action.generate.test.support.choose.test.name")
name = Messages.showInputDialog(message, commandName, null, name, NAME_VALIDATOR) ?: return
}
templateText = fileTemplate.text.replace(NAME_VAR, DUMMY_NAME)
@@ -161,7 +162,7 @@ abstract class KotlinGenerateTestSupportActionBase(
val psiMethod = factory.createMethodFromText(templateText, null)
psiMethod.throwsList.referenceElements.forEach { it.delete() }
var function = psiMethod.j2k() as? KtNamedFunction ?: run {
errorHint = "Couldn't convert Java template to Kotlin"
errorHint = KotlinBundle.message("action.generate.test.support.error.cant.convert.java.template")
return@executeWriteCommand
}
name?.let {
@@ -187,7 +188,8 @@ abstract class KotlinGenerateTestSupportActionBase(
}
errorHint?.let { HintManager.getInstance().showErrorHint(editor, it) }
} catch (e: IncorrectOperationException) {
HintManager.getInstance().showErrorHint(editor, "Cannot generate method: " + e.message)
val message = KotlinBundle.message("action.generate.test.support.error.cant.generate.method", e.message)
HintManager.getInstance().showErrorHint(editor, message)
}
}
@@ -231,12 +233,16 @@ abstract class KotlinGenerateTestSupportActionBase(
val targetClass = getTargetClass(editor, file) ?: return null
val frameworks = findSuitableFrameworks(targetClass).ifEmpty { return null }
return object : AnAction("Edit Template") {
return object : AnAction(KotlinBundle.message("action.generate.test.support.edit.template")) {
override fun actionPerformed(e: AnActionEvent) {
chooseAndPerform(editor, frameworks) {
val descriptor = methodKind.getFileTemplateDescriptor(it)
if (descriptor == null) {
HintManager.getInstance().showErrorHint(editor, "No template found for ${it.name}:${templatePresentation.text}")
val message = KotlinBundle.message(
"action.generate.test.support.error.no.template.found",
it.name, templatePresentation.text
)
HintManager.getInstance().showErrorHint(editor, message)
return@chooseAndPerform
}
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
@@ -66,7 +67,7 @@ class KotlinGenerateToStringAction : KotlinGenerateMemberActionBase<KotlinGenera
)
enum class Generator(val text: String) {
SINGLE_TEMPLATE("Single template") {
SINGLE_TEMPLATE(KotlinBundle.message("action.generate.tostring.template.single")) {
override fun generate(info: Info): String {
val className = info.classDescriptor.name.asString()
@@ -86,7 +87,7 @@ class KotlinGenerateToStringAction : KotlinGenerateMemberActionBase<KotlinGenera
}
},
MULTIPLE_TEMPLATES("Multiple templates with concatenation") {
MULTIPLE_TEMPLATES(KotlinBundle.message("action.generate.tostring.template.multiple")) {
override fun generate(info: Info): String {
val className = info.classDescriptor.name.asString()
@@ -169,7 +170,7 @@ class KotlinGenerateToStringAction : KotlinGenerateMemberActionBase<KotlinGenera
val memberChooserObjects = properties.map { DescriptorMemberChooserObject(it, it.unsafeResolveToDescriptor()) }.toTypedArray()
val headerPanel = ToStringMemberChooserHeaderPanel(!superToString.builtIns.isMemberOfAny(superToString))
val chooser = MemberChooser<DescriptorMemberChooserObject>(memberChooserObjects, true, true, project, false, headerPanel).apply {
title = "Generate toString()"
title = KotlinBundle.message("action.generate.tostring.name")
setCopyJavadocVisible(false)
selectElements(memberChooserObjects)
}
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.actions.generate;
import com.intellij.openapi.ui.ComboBox;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.generate.template.toString.ToStringTemplatesManager;
import org.jetbrains.kotlin.idea.KotlinBundle;
import javax.swing.*;
import java.awt.*;
@@ -50,7 +51,7 @@ public class ToStringMemberChooserHeaderPanel extends JPanel {
);
comboBox.setSelectedItem(ToStringTemplatesManager.getInstance().getDefaultTemplate());
JLabel templatesLabel = new JLabel("Choose implementation: ");
JLabel templatesLabel = new JLabel(KotlinBundle.message("action.generate.tostring.choose.implementation"));
templatesLabel.setDisplayedMnemonic('i');
templatesLabel.setLabelFor(comboBox);
@@ -65,7 +66,7 @@ public class ToStringMemberChooserHeaderPanel extends JPanel {
add(comboBox, constraints);
if (allowSuperCall) {
generateSuperCheckBox = new JCheckBox("Generate call to super.toString()");
generateSuperCheckBox = new JCheckBox(KotlinBundle.message("action.generate.tostring.generate.super.call"));
generateSuperCheckBox.setMnemonic('s');
constraints.gridx = 2;
constraints.weightx = 0.0;
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.CodeInsightBundle
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.ui.Messages
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
import org.jetbrains.kotlin.idea.core.overrideImplement.OverrideMemberChooserObject
import org.jetbrains.kotlin.idea.core.overrideImplement.generateMember
@@ -60,7 +61,7 @@ fun confirmMemberRewrite(targetClass: KtClass, vararg descriptors: FunctionDescr
if (ApplicationManager.getApplication().isUnitTestMode) return true
val functionsText = descriptors.joinToString(separator = " and ") { "'${MEMBER_RENDERER.render(it)}'" }
val message = "Functions $functionsText are already defined\nfor class ${targetClass.name}. Do you want to delete them and proceed?"
val message = KotlinBundle.message("action.generate.functions.already.defined", functionsText, targetClass.name)
return Messages.showYesNoDialog(
targetClass.project, message,
CodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.actions.internal
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.ui.Messages
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.formatter.KotlinFormatterUsageCollector
class KotlinFormattingSettingsStatusAction : AnAction() {
@@ -19,7 +20,7 @@ class KotlinFormattingSettingsStatusAction : AnAction() {
Messages.showInfoMessage(
project,
"formatterKind = $formatterKind",
"Kotlin Formatter Settings"
KotlinBundle.message("formatter.settings.title")
)
}
}
@@ -24,6 +24,7 @@ import com.intellij.refactoring.util.RefactoringDescriptionLocation
import com.intellij.usageView.UsageViewShortNameLocation
import com.intellij.xml.breadcrumbs.BreadcrumbsInfoProvider
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isElseIf
import org.jetbrains.kotlin.idea.intentions.loopToCallChain.unwrapIfLabeled
@@ -214,7 +215,7 @@ class KotlinBreadcrumbsInfoProvider : BreadcrumbsInfoProvider() {
override fun elementTooltip(element: KtDeclaration): String = try {
ElementDescriptionUtil.getElementDescription(element, RefactoringDescriptionLocation.WITH_PARENT)
} catch (e: IndexNotReadyException) {
"Indexing..."
KotlinBundle.message("breadcrumbs.tooltip.indexing")
}
}
@@ -39,6 +39,7 @@ import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.allowResolveInDispatchThread
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
@@ -325,7 +326,7 @@ class KotlinCopyPasteReferenceProcessor : CopyPastePostProcessor<BasicKotlinRefe
file: KtFile,
findReferenceProvider: (indicator: ProgressIndicator) -> List<ReferenceToRestoreData>
) {
val task = object : Task.Backgroundable(project, "Resolving pasted references ...", true) {
val task = object : Task.Backgroundable(project, KotlinBundle.message("copy.paste.resolve.references"), true) {
override fun run(indicator: ProgressIndicator) {
assert(!ApplicationManager.getApplication().isWriteAccessAllowed) {
"Resolving references on dispatch thread leads to live lock"
@@ -13,6 +13,7 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
@@ -44,7 +45,7 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
classifierNamePolicy = object : ClassifierNamePolicy {
override fun renderClassifier(classifier: ClassifierDescriptor, renderer: DescriptorRenderer): String {
if (DescriptorUtils.isAnonymousObject(classifier)) {
return "&lt;anonymous object&gt;"
return "&lt;" + KotlinBundle.message("type.provider.anonymous.object") + "&gt;"
}
return ClassifierNamePolicy.SHORT.renderClassifier(classifier, renderer)
}
@@ -103,26 +104,29 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
if (element is KtCallableDeclaration) {
val descriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, element] as? CallableDescriptor
if (descriptor != null) {
return descriptor.returnType?.let { typeRenderer.renderType(it) } ?: "Type is unknown"
return descriptor.returnType?.let { typeRenderer.renderType(it) } ?: KotlinBundle.message("type.provider.unknown.type")
}
}
val expressionTypeInfo = bindingContext[BindingContext.EXPRESSION_TYPE_INFO, element] ?: noTypeInfo(DataFlowInfo.EMPTY)
val expressionType = element.getType(bindingContext) ?: getTypeForArgumentName(element, bindingContext)
val result = expressionType?.let { typeRenderer.renderType(it) } ?: return "Type is unknown"
val result = expressionType?.let { typeRenderer.renderType(it) } ?: return KotlinBundle.message("type.provider.unknown.type")
val dataFlowValueFactory = element.getResolutionFacade().frontendService<DataFlowValueFactory>()
val dataFlowValue =
dataFlowValueFactory.createDataFlowValue(element, expressionType, bindingContext, element.findModuleDescriptor())
val types = expressionTypeInfo.dataFlowInfo.getStableTypes(dataFlowValue, element.languageVersionSettings)
if (types.isNotEmpty()) return types.joinToString(separator = " & ") { typeRenderer.renderType(it) } + " (smart cast from " + result + ")"
if (types.isNotEmpty()) {
return types.joinToString(separator = " & ") { typeRenderer.renderType(it) } +
" " + KotlinBundle.message("type.provider.smart.cast.from", result)
}
val smartCast = bindingContext[BindingContext.SMARTCAST, element]
if (smartCast != null && element is KtReferenceExpression) {
val declaredType = (bindingContext[BindingContext.REFERENCE_TARGET, element] as? CallableDescriptor)?.returnType
if (declaredType != null) {
return result + " (smart cast from " + typeRenderer.renderType(declaredType) + ")"
return result + " " + KotlinBundle.message("type.provider.smart.cast.from", typeRenderer.renderType(declaredType))
}
}
return result
@@ -137,5 +141,5 @@ class KotlinExpressionTypeProvider : ExpressionTypeProvider<KtExpression>() {
return parameter.type
}
override fun getErrorHint(): String = "No expression found"
override fun getErrorHint(): String = KotlinBundle.message("type.provider.no.expression.found")
}
@@ -29,6 +29,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.refactoring.RefactoringHelper
import com.intellij.usageView.UsageInfo
import com.intellij.util.IncorrectOperationException
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
import org.jetbrains.kotlin.idea.util.application.runReadAction
@@ -98,8 +99,8 @@ class KotlinOptimizeImportsRefactoringHelper : RefactoringHelper<Set<KtFile>> {
}
companion object {
private const val COLLECT_UNUSED_IMPORTS_TITLE = "Collect unused imports"
private const val REMOVING_REDUNDANT_IMPORTS_TITLE = "Removing redundant imports"
private val COLLECT_UNUSED_IMPORTS_TITLE = KotlinBundle.message("optimize.imports.collect.unused.imports")
private val REMOVING_REDUNDANT_IMPORTS_TITLE = KotlinBundle.message("optimize.imports.task.removing.redundant.imports")
}
override fun prepareOperation(usages: Array<UsageInfo>): Set<KtFile> {
@@ -25,6 +25,7 @@ import org.intellij.markdown.MarkdownTokenTypes
import org.intellij.markdown.ast.ASTNode
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
import org.intellij.markdown.parser.MarkdownParser
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.util.wrapTag
import org.jetbrains.kotlin.kdoc.psi.impl.KDocLink
@@ -58,18 +59,18 @@ object KDocRenderer {
}
fun StringBuilder.appendKDocSection(section: KDocSection) {
renderTag(section.findTagByName("receiver"), "Receiver", this)
renderTag(section.findTagByName("receiver"), KotlinBundle.message("kdoc.section.title.receiver"), this)
val paramTags = section.findTagsByName("param").filter { it.getSubjectName() != null }
renderTagList(paramTags, "Params", this)
renderTagList(paramTags, KotlinBundle.message("kdoc.section.title.parameters"), this)
renderTag(section.findTagByName("return"), "Returns", this)
renderTag(section.findTagByName("return"), KotlinBundle.message("kdoc.section.title.returns"), this)
val throwsTags = (section.findTagsByName("exception").union(section.findTagsByName("throws")))
.filter { it.getSubjectName() != null }
renderTagList(throwsTags, "Throws", this)
renderTagList(throwsTags, KotlinBundle.message("kdoc.section.title.throws"), this)
renderTag(section.findTagByName("author"), "Author", this)
renderTag(section.findTagByName("since"), "Since", this)
renderTag(section.findTagByName("author"), KotlinBundle.message("kdoc.section.title.author"), this)
renderTag(section.findTagByName("since"), KotlinBundle.message("kdoc.section.title.since"), this)
renderSeeAlso(section, this)
@@ -113,7 +114,7 @@ object KDocRenderer {
private fun renderSamplesList(sampleTags: List<KDocTag>, to: StringBuilder) {
if (sampleTags.isEmpty()) return
to.renderSection("Samples") {
to.renderSection(KotlinBundle.message("kdoc.section.title.samples")) {
sampleTags.forEach {
it.getSubjectLink()?.let { subjectLink ->
append("<p>")
@@ -122,7 +123,7 @@ object KDocRenderer {
wrapTag("pre") {
wrapTag("code") {
if (target == null)
to.append("// Unresolved")
to.append("// " + KotlinBundle.message("kdoc.comment.unresolved"))
else {
to.append(trimCommonIndent(target.extractExampleText()).htmlEscape())
}
@@ -137,7 +138,7 @@ object KDocRenderer {
val seeTags = docComment.findTagsByName("see")
if (seeTags.isEmpty()) return
to.renderSection("See Also") {
to.renderSection(KotlinBundle.message("kdoc.section.title.see.also")) {
seeTags.forEachIndexed { index, tag ->
val subjectName = tag.getSubjectName()
if (subjectName != null) {
@@ -6,8 +6,12 @@
package org.jetbrains.kotlin.idea.migration
import com.intellij.openapi.actionSystem.AnActionEvent
import org.jetbrains.kotlin.idea.KotlinBundle
class CodeMigrationAction : CodeInspectionAction("Code Migration", "Code migration") {
class CodeMigrationAction : CodeInspectionAction(
KotlinBundle.message("inspection.migration.title"),
KotlinBundle.message("inspection.migration.title")
) {
override fun update(e: AnActionEvent) {
super.update(e)
@@ -14,6 +14,7 @@ import com.intellij.openapi.util.WriteExternalException
import com.intellij.profile.codeInspection.InspectionProfileManager
import com.intellij.psi.PsiElement
import org.jdom.Element
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
import org.jetbrains.kotlin.idea.quickfix.migration.MigrationFix
import java.util.*
@@ -33,7 +34,7 @@ fun createMigrationProfile(
rootProfile.collectDependentInspections(toolWrapper, allWrappers, managerEx.project)
}
val model = createSimple("Migration", managerEx.project, migrationFixWrappers)
val model = createSimple(KotlinBundle.message("inspection.migration.profile.name"), managerEx.project, migrationFixWrappers)
try {
val element = Element("toCopy")
for (wrapper in migrationFixWrappers) {
@@ -16,6 +16,7 @@ import com.intellij.openapi.util.WriteExternalException
import com.intellij.profile.codeInspection.InspectionProfileManager
import com.intellij.psi.PsiElement
import org.jdom.Element
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
import org.jetbrains.kotlin.idea.quickfix.migration.MigrationFix
import java.util.*
@@ -35,7 +36,7 @@ fun createMigrationProfile(
rootProfile.collectDependentInspections(toolWrapper, allWrappers, managerEx.project)
}
val model = createSimple("Migration", managerEx.project, migrationFixWrappers)
val model = createSimple(KotlinBundle.message("inspection.migration.profile.name"), managerEx.project, migrationFixWrappers)
try {
val element = Element("toCopy")
for (wrapper in migrationFixWrappers) {
@@ -30,6 +30,7 @@ import com.intellij.ui.JBColor
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.core.OptionalParametersHelper
@@ -197,7 +198,7 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
if (ApplicationManager.getApplication()?.isDispatchThread == true) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(
task,
"Calculating parameter info", true, argumentList.project
KotlinBundle.message("hints.progress.calculating.parameter.info"), true, argumentList.project
)
} else {
task.run()
@@ -15,6 +15,7 @@ import com.intellij.openapi.application.ApplicationManager
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getReturnTypeReference
import org.jetbrains.kotlin.name.Name
@@ -24,9 +25,13 @@ import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
enum class HintType(val desc: String, defaultEnabled: Boolean) {
enum class HintType(val showDesc: String, val doNotShowDesc: String, defaultEnabled: Boolean) {
PROPERTY_HINT("Show property type hints", false) {
PROPERTY_HINT(
KotlinBundle.message("hints.title.property.type.enabled"),
KotlinBundle.message("hints.title.property.type.disabled"),
false
) {
override fun provideHints(elem: PsiElement): List<InlayInfo> {
return providePropertyTypeHint(elem)
}
@@ -34,7 +39,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
override fun isApplicable(elem: PsiElement): Boolean = elem is KtProperty && elem.getReturnTypeReference() == null && !elem.isLocal
},
LOCAL_VARIABLE_HINT("Show local variable type hints", false) {
LOCAL_VARIABLE_HINT(
KotlinBundle.message("hints.title.locals.type.enabled"),
KotlinBundle.message("hints.title.locals.type.disabled"),
false
) {
override fun provideHints(elem: PsiElement): List<InlayInfo> {
return providePropertyTypeHint(elem)
}
@@ -45,7 +54,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
(elem is KtDestructuringDeclarationEntry && elem.getReturnTypeReference() == null)
},
FUNCTION_HINT("Show function return type hints", false) {
FUNCTION_HINT(
KotlinBundle.message("hints.title.function.type.enabled"),
KotlinBundle.message("hints.title.function.type.disabled"),
false
) {
override fun provideHints(elem: PsiElement): List<InlayInfo> {
(elem as? KtNamedFunction)?.let { namedFunc ->
namedFunc.valueParameterList?.let { paramList ->
@@ -59,7 +72,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
elem is KtNamedFunction && !(elem.hasBlockBody() || elem.hasDeclaredReturnType())
},
PARAMETER_TYPE_HINT("Show parameter type hints ", false) {
PARAMETER_TYPE_HINT(
KotlinBundle.message("hints.title.parameter.type.enabled"),
KotlinBundle.message("hints.title.parameter.type.disabled"),
false
) {
override fun provideHints(elem: PsiElement): List<InlayInfo> {
(elem as? KtParameter)?.let { param ->
param.nameIdentifier?.let { ident ->
@@ -72,7 +89,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
override fun isApplicable(elem: PsiElement): Boolean = elem is KtParameter && elem.typeReference == null && !elem.isLoopParameter
},
PARAMETER_HINT("Show argument name hints", true) {
PARAMETER_HINT(
KotlinBundle.message("hints.title.argument.name.enabled"),
KotlinBundle.message("hints.title.argument.name.disabled"),
true
) {
override fun provideHints(elem: PsiElement): List<InlayInfo> {
val callElement = elem.getStrictParentOfType<KtCallElement>() ?: return emptyList()
return provideArgumentNameHints(callElement)
@@ -81,7 +102,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
override fun isApplicable(elem: PsiElement): Boolean = elem is KtValueArgumentList
},
LAMBDA_RETURN_EXPRESSION("Show lambda return expression hints", true) {
LAMBDA_RETURN_EXPRESSION(
KotlinBundle.message("hints.title.return.expression.enabled"),
KotlinBundle.message("hints.title.return.expression.disabled"),
true
) {
override fun isApplicable(elem: PsiElement) =
elem is KtExpression && elem !is KtFunctionLiteral && !elem.isNameReferenceInCall()
@@ -96,7 +121,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
}
},
LAMBDA_IMPLICIT_PARAMETER_RECEIVER("Show hints for implicit receivers and parameters of lambdas", true) {
LAMBDA_IMPLICIT_PARAMETER_RECEIVER(
KotlinBundle.message("hints.title.implicit.parameters.enabled"),
KotlinBundle.message("hints.title.implicit.parameters.disabled"),
true
) {
override fun isApplicable(elem: PsiElement) = elem is KtFunctionLiteral
override fun provideHints(elem: PsiElement): List<InlayInfo> {
@@ -107,7 +136,11 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
}
},
SUSPENDING_CALL("Show hints for suspending calls", false) {
SUSPENDING_CALL(
KotlinBundle.message("hints.title.suspend.calls.enabled"),
KotlinBundle.message("hints.title.suspend.calls.disabled"),
false
) {
override fun isApplicable(elem: PsiElement) = elem.isNameReferenceInCall() && ApplicationManager.getApplication().isInternal
override fun provideHints(elem: PsiElement): List<InlayInfo> {
@@ -135,7 +168,7 @@ enum class HintType(val desc: String, defaultEnabled: Boolean) {
abstract fun isApplicable(elem: PsiElement): Boolean
abstract fun provideHints(elem: PsiElement): List<InlayInfo>
val option = Option("SHOW_${this.name}", desc, defaultEnabled)
val option = Option("SHOW_${this.name}", this.showDesc, defaultEnabled)
val enabled
get() = option.get()
}
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.idea.parameterInfo.custom
import com.intellij.codeInsight.CodeInsightBundle
import com.intellij.codeInsight.hints.InlayParameterHintsExtension
import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.codeInsight.intention.LowPriorityAction
@@ -19,12 +18,7 @@ import org.jetbrains.kotlin.idea.util.refreshAllOpenEditors
class DisableReturnLambdaHintOptionAction : IntentionAction, LowPriorityAction {
override fun getText(): String {
val optionName = HintType.LAMBDA_RETURN_EXPRESSION.option.name
return if (optionName.startsWith("show", ignoreCase = true)) {
"Do not ${optionName.toLowerCase()}"
} else {
CodeInsightBundle.message("inlay.hints.disable.custom.option", optionName)
}
return HintType.LAMBDA_RETURN_EXPRESSION.doNotShowDesc
}
override fun getFamilyName(): String = text
@@ -11,6 +11,7 @@ import com.intellij.navigation.ItemPresentationProvider
import com.intellij.openapi.editor.colors.CodeInsightColors
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.util.Iconable
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinIconProvider
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -31,7 +32,7 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
if ((declaration is KtFunction && declaration.isLocal) || (declaration is KtClassOrObject && declaration.isLocal)) {
val containingDeclaration = declaration.getStrictParentOfType<KtNamedDeclaration>() ?: return null
val containerName = containingDeclaration.fqName ?: containingDeclaration.name
return "(in $containerName)"
return KotlinBundle.message("presentation.text.in.container.paren", containerName)
}
val name = declaration.fqName
@@ -39,7 +40,7 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
val containerText = if (name != null) {
val qualifiedContainer = name.parent().toString()
if (parent is KtFile && declaration.hasModifier(KtTokens.PRIVATE_KEYWORD)) {
"${parent.name} in $qualifiedContainer"
KotlinBundle.message("presentation.text.in.container", parent.name, qualifiedContainer)
} else {
qualifiedContainer
}
@@ -49,9 +50,11 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
val receiverTypeRef = (declaration as? KtCallableDeclaration)?.receiverTypeReference
return when {
receiverTypeRef != null -> "(for " + receiverTypeRef.text + " in " + containerText + ")"
parent is KtFile -> "($containerText)"
else -> "(in $containerText)"
receiverTypeRef != null -> {
KotlinBundle.message("presentation.text.for.receiver.in.container.paren", receiverTypeRef.text, containerText)
}
parent is KtFile -> KotlinBundle.message("presentation.text.paren", containerText)
else -> KotlinBundle.message("presentation.text.in.container.paren", containerText)
}
}
@@ -59,7 +62,7 @@ open class KotlinDefaultNamedDeclarationPresentation(private val declaration: Kt
val objectLiteral = declaration.getStrictParentOfType<KtObjectLiteralExpression>() ?: return null
val container = objectLiteral.getStrictParentOfType<KtNamedDeclaration>() ?: return null
val containerFqName = container.fqName?.asString() ?: return null
return "object in $containerFqName"
return KotlinBundle.message("presentation.text.object.in.container", containerFqName)
}
override fun getIcon(unused: Boolean) =
@@ -90,7 +93,7 @@ class KtFunctionPresenter : ItemPresentationProvider<KtFunction> {
override fun getLocationString(): String? {
if (function is KtConstructor<*>) {
val name = function.getContainingClassOrObject().fqName ?: return null
return "(in $name)"
return KotlinBundle.message("presentation.text.in.container.paren", name)
}
return super.getLocationString()
@@ -23,6 +23,7 @@ import com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import org.jetbrains.kotlin.idea.KotlinBundle;
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
import org.jetbrains.kotlin.psi.*;
@@ -31,7 +32,7 @@ import java.util.Collections;
import java.util.List;
public class KtDeclarationTreeNode extends AbstractPsiBasedNode<KtDeclaration> {
public static final String CLASS_INITIALIZER = "<class initializer>";
public static final String CLASS_INITIALIZER = "<" + KotlinBundle.message("project.view.class.initializer") + ">";
protected KtDeclarationTreeNode(Project project, KtDeclaration ktDeclaration, ViewSettings viewSettings) {
super(project, ktDeclaration, viewSettings);
@@ -23,6 +23,7 @@ import com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import org.jetbrains.kotlin.idea.KotlinBundle;
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
import org.jetbrains.kotlin.psi.*;
@@ -31,7 +32,7 @@ import java.util.Collections;
import java.util.List;
public class KtDeclarationTreeNode extends AbstractPsiBasedNode<KtDeclaration> {
public static final String CLASS_INITIALIZER = "<class initializer>";
public static final String CLASS_INITIALIZER = "<" + KotlinBundle.message("project.view.class.initializer") + ">";
protected KtDeclarationTreeNode(Project project, KtDeclaration ktDeclaration, ViewSettings viewSettings) {
super(project, ktDeclaration, viewSettings);
@@ -11,6 +11,7 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
import org.jetbrains.kotlin.idea.facet.KotlinFacet
@@ -24,16 +25,22 @@ abstract class AbstractChangeFeatureSupportLevelFix(
protected val featureSupportEnabled: Boolean
get() = featureSupport == LanguageFeature.State.ENABLED || featureSupport == LanguageFeature.State.ENABLED_WITH_WARNING
final override fun getFamilyName() = "Enable/Disable $featureShortName support"
final override fun getFamilyName() = KotlinBundle.message("fix.change.feature.support.family", featureShortName)
override fun getText(): String = getFixText(featureSupport, featureShortName)
companion object {
fun getFixText(state: LanguageFeature.State, featureShortName: String): String {
return when (state) {
LanguageFeature.State.ENABLED -> "Enable $featureShortName support"
LanguageFeature.State.ENABLED_WITH_WARNING -> "Enable $featureShortName support (with warning)"
LanguageFeature.State.ENABLED_WITH_ERROR, LanguageFeature.State.DISABLED -> "Disable $featureShortName support"
LanguageFeature.State.ENABLED -> {
KotlinBundle.message("fix.change.feature.support.enabled", featureShortName)
}
LanguageFeature.State.ENABLED_WITH_WARNING -> {
KotlinBundle.message("fix.change.feature.support.enabled.warning", featureShortName)
}
LanguageFeature.State.ENABLED_WITH_ERROR, LanguageFeature.State.DISABLED -> {
KotlinBundle.message("fix.change.feature.support.disabled", featureShortName)
}
}
}
}
@@ -496,7 +496,11 @@ internal class DelegateAccessorsImportFix(
override fun createAction(project: Project, editor: Editor, element: KtExpression): KotlinAddImportAction {
if (solveSeveralProblems) {
return createGroupedImportsAction(project, editor, element, "Delegate accessors", suggestions)
return createGroupedImportsAction(
project, editor, element,
KotlinBundle.message("fix.import.kind.delegate.accessors"),
suggestions
)
}
return super.createAction(project, editor, element)
@@ -537,7 +541,11 @@ internal class ComponentsImportFix(
override fun createAction(project: Project, editor: Editor, element: KtExpression): KotlinAddImportAction {
if (solveSeveralProblems) {
return createGroupedImportsAction(project, editor, element, "Component functions", suggestions)
return createGroupedImportsAction(
project, editor, element,
KotlinBundle.message("fix.import.kind.component.functions"),
suggestions
)
}
return super.createAction(project, editor, element)
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.util.addAnnotation
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtDeclaration
@@ -15,17 +16,28 @@ import org.jetbrains.kotlin.psi.KtFile
open class AddAnnotationFix(
element: KtDeclaration,
private val annotationFqName: FqName,
private val suffix: String = "",
private val kind: Kind = Kind.Self,
private val argumentClassFqName: FqName? = null
) : KotlinQuickFixAction<KtDeclaration>(element) {
override fun getText(): String {
val argumentsAsString = argumentClassFqName?.shortName()?.let { "($it::class)" } ?: ""
return "Add '@${annotationFqName.shortName()}$argumentsAsString' annotation$suffix"
val annotationArguments = (argumentClassFqName?.shortName()?.let { "($it::class)" } ?: "")
val annotationCall = annotationFqName.shortName().asString() + annotationArguments
return when (kind) {
Kind.Self -> KotlinBundle.message("fix.add.annotation.text.self", annotationCall)
is Kind.Declaration -> KotlinBundle.message("fix.add.annotation.text.declaration", annotationCall, kind.name ?: "?")
is Kind.ContainingClass -> KotlinBundle.message("fix.add.annotation.text.containing.class", annotationCall, kind.name ?: "?")
}
}
override fun getFamilyName(): String = "Add annotation"
override fun getFamilyName(): String = KotlinBundle.message("fix.add.annotation.family")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
element?.addAnnotation(annotationFqName, annotationInnerText = argumentClassFqName?.let { "$it::class" })
}
sealed class Kind {
object Self : Kind()
class Declaration(val name: String?) : Kind()
class ContainingClass(val name: String?) : Kind()
}
}
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors.WRONG_ANNOTATION_TARGET
import org.jetbrains.kotlin.diagnostics.Errors.WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
@@ -37,7 +38,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
class AddAnnotationTargetFix(annotationEntry: KtAnnotationEntry) : KotlinQuickFixAction<KtAnnotationEntry>(annotationEntry) {
override fun getText() = "Add annotation target"
override fun getText() = KotlinBundle.message("fix.add.annotation.target")
override fun getFamilyName() = text
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
@@ -25,8 +26,8 @@ class AddArrayOfTypeFix(expression: KtExpression, expectedType: KotlinType) : Ko
}
override fun getText() = "Add $prefix wrapper"
override fun getFamilyName() = "Add arrayOf wrapper"
override fun getText() = KotlinBundle.message("fix.add.array.of.type.text", prefix)
override fun getFamilyName() = KotlinBundle.message("fix.add.array.of.type.family")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -28,6 +28,7 @@ import com.intellij.psi.search.searches.ReferencesSearch
import org.jetbrains.kotlin.asJava.LightClassUtil
import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.intentions.SelfTargetingIntention
import org.jetbrains.kotlin.idea.search.allScope
@@ -67,7 +68,9 @@ class AddConstModifierFix(property: KtProperty) : AddModifierFix(property, KtTok
}
}
class AddConstModifierIntention : SelfTargetingIntention<KtProperty>(KtProperty::class.java, "Add 'const' modifier") {
class AddConstModifierIntention : SelfTargetingIntention<KtProperty>(
KtProperty::class.java, KotlinBundle.message("fix.add.const.modifier")
) {
override fun applyTo(element: KtProperty, editor: Editor?) {
AddConstModifierFix.addConstModifier(element)
}
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
@@ -27,7 +28,7 @@ class AddConstructorParameterFromSuperTypeCallFix(
) : KotlinQuickFixAction<KtValueArgumentList>(constructor) {
private val parameterTypeSourceCode = IdeDescriptorRenderers.SOURCE_CODE_TYPES.renderType(parameterType)
override fun getText() = "Add constructor parameter '$parameterName'"
override fun getText() = KotlinBundle.message("fix.add.constructor.parameter", parameterName)
override fun getFamilyName() = text
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.core.isVisible
@@ -23,7 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
class AddDataModifierFix(element: KtClass, private val fqName: String) : AddModifierFix(element, KtTokens.DATA_KEYWORD) {
override fun getText() = "Make '$fqName' data class"
override fun getText() = KotlinBundle.message("fix.make.data.class", fqName)
override fun getFamilyName() = text
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
@@ -18,7 +19,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
class AddDefaultConstructorFix(expectClass: KtClass) : KotlinQuickFixAction<KtClass>(expectClass) {
override fun getText() = "Add default constructor to expect class"
override fun getText() = KotlinBundle.message("fix.add.default.constructor")
override fun getFamilyName() = text
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
import org.jetbrains.kotlin.idea.imports.importableFqName
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
@@ -26,7 +27,7 @@ internal class AddExplicitImportForDeprecatedVisibilityFix(expression: KtElement
override fun getFamilyName(): String = text
override fun getText(): String = "Add explicit import"
override fun getText(): String = KotlinBundle.message("fix.add.explicit.import")
object Factory : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
@@ -19,13 +19,14 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
class AddFunctionBodyFix(element: KtFunction) : KotlinQuickFixAction<KtFunction>(element) {
override fun getFamilyName() = "Add function body"
override fun getFamilyName() = KotlinBundle.message("fix.add.function.body")
override fun getText() = familyName
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.CollectingNameValidator
import org.jetbrains.kotlin.idea.util.getDataFlowAwareTypes
@@ -44,9 +45,17 @@ import java.util.*
class AddFunctionParametersFix(
callElement: KtCallElement,
functionDescriptor: FunctionDescriptor,
private val hasTypeMismatches: Boolean,
private val argumentIndex: Int? = null
private val kind: Kind
) : ChangeFunctionSignatureFix(callElement, functionDescriptor) {
sealed class Kind {
object ChangeSignature : Kind()
object AddParameterGeneric : Kind()
class AddParameter(val argumentIndex: Int) : Kind()
}
private val argumentIndex: Int?
get() = (kind as? Kind.AddParameter)?.argumentIndex
private val callElement: KtCallElement?
get() = element as? KtCallElement
@@ -60,31 +69,40 @@ class AddFunctionParametersFix(
val newParametersCnt = arguments.size - parameters.size
assert(newParametersCnt > 0)
val subjectSuffix = if (newParametersCnt > 1) "s" else ""
val callableDescription = if (isConstructor()) {
val className = functionDescriptor.containingDeclaration.name.asString()
"constructor '$className'"
} else {
val functionName = functionDescriptor.name.asString()
"function '$functionName'"
val declarationName = when {
isConstructor() -> functionDescriptor.containingDeclaration.name.asString()
else -> functionDescriptor.name.asString()
}
val parameterOrdinal = argumentIndex?.let {
val number = (it + 1).toString()
val suffix = when {
number.endsWith("1") -> "st"
number.endsWith("2") -> "nd"
number.endsWith("3") -> "rd"
else -> "th"
return when (kind) {
is Kind.ChangeSignature -> {
if (isConstructor()) {
KotlinBundle.message("fix.add.function.parameters.change.signature.constructor", declarationName)
} else {
KotlinBundle.message("fix.add.function.parameters.change.signature.function", declarationName)
}
}
"$number$suffix "
} ?: ""
return if (hasTypeMismatches)
"Change the signature of $callableDescription"
else
"Add ${parameterOrdinal}parameter$subjectSuffix to $callableDescription"
is Kind.AddParameterGeneric -> {
if (isConstructor()) {
KotlinBundle.message("fix.add.function.parameters.add.parameter.generic.constructor", declarationName)
} else {
KotlinBundle.message("fix.add.function.parameters.add.parameter.generic.function", declarationName)
}
}
is Kind.AddParameter -> {
if (isConstructor()) {
KotlinBundle.message(
"fix.add.function.parameters.add.parameter.constructor",
kind.argumentIndex + 1, newParametersCnt, declarationName
)
} else {
KotlinBundle.message(
"fix.add.function.parameters.add.parameter.function",
kind.argumentIndex + 1, newParametersCnt, declarationName
)
}
}
}
}
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
@@ -105,6 +123,8 @@ class AddFunctionParametersFix(
private fun addParameterConfiguration(): KotlinChangeSignatureConfiguration {
return object : KotlinChangeSignatureConfiguration {
override fun configure(originalDescriptor: KotlinMethodDescriptor): KotlinMethodDescriptor {
val argumentIndex = this@AddFunctionParametersFix.argumentIndex
return originalDescriptor.modify(fun(descriptor: KotlinMutableMethodDescriptor) {
val callElement = callElement ?: return
val arguments = callElement.valueArguments
@@ -155,7 +175,7 @@ class AddFunctionParametersFix(
override fun performSilently(affectedFunctions: Collection<PsiElement>): Boolean {
val onlyFunction = affectedFunctions.singleOrNull() ?: return false
return !hasTypeMismatches && !isConstructor() && !hasOtherUsages(onlyFunction)
return kind != Kind.ChangeSignature && !isConstructor() && !hasOtherUsages(onlyFunction)
}
}
}
@@ -211,7 +231,7 @@ class AddFunctionParametersFix(
val parameters = functionDescriptor.valueParameters
val arguments = originalElement.valueArguments
return if (arguments.size > parameters.size) {
AddFunctionParametersFix(originalElement, functionDescriptor, false, argumentIndex)
AddFunctionParametersFix(originalElement, functionDescriptor, Kind.AddParameter(argumentIndex))
} else {
null
}
@@ -29,6 +29,7 @@ import com.intellij.util.PlatformIcons
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.ShortenReferences
@@ -66,10 +67,10 @@ class AddFunctionToSupertypeFix private constructor(
return if (single != null)
actionName(single)
else
"Add function to supertype..."
KotlinBundle.message("fix.add.function.supertype.text")
}
override fun getFamilyName() = "Add function to supertype"
override fun getFamilyName() = KotlinBundle.message("fix.add.function.supertype.family")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
CommandProcessor.getInstance().runUndoTransparentAction {
@@ -82,7 +83,7 @@ class AddFunctionToSupertypeFix private constructor(
}
private fun addFunction(functionData: FunctionData, project: Project) {
project.executeWriteCommand("Add Function to Type") {
project.executeWriteCommand(KotlinBundle.message("fix.add.function.supertype.progress")) {
val classBody = functionData.targetClass.getOrCreateBody()
val functionElement = KtPsiFactory(project).createFunction(functionData.sourceCode)
@@ -98,7 +99,7 @@ class AddFunctionToSupertypeFix private constructor(
}
private fun createFunctionPopup(project: Project): ListPopupStep<*> {
return object : BaseListPopupStep<FunctionData>("Choose Type", functions) {
return object : BaseListPopupStep<FunctionData>(KotlinBundle.message("fix.add.function.supertype.choose.type"), functions) {
override fun isAutoSelectionEnabled() = false
override fun onChosen(selectedValue: FunctionData, finalChoice: Boolean): PopupStep<*>? {
@@ -113,7 +114,12 @@ class AddFunctionToSupertypeFix private constructor(
}
}
private fun actionName(functionData: FunctionData) = "Add '${functionData.signaturePreview}' to '${functionData.targetClass.name}'"
private fun actionName(functionData: FunctionData): String {
return KotlinBundle.message(
"fix.add.function.supertype.add.to",
functionData.signaturePreview, functionData.targetClass.name
)
}
companion object : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.psi.KtFile
@@ -30,8 +31,15 @@ class AddGenericUpperBoundFix(
) : KotlinQuickFixAction<KtTypeParameter>(typeParameter) {
private val renderedUpperBound: String = IdeDescriptorRenderers.SOURCE_CODE.renderType(upperBound)
override fun getText() = element?.let { "Add '$renderedUpperBound' as upper bound for ${it.name}" } ?: ""
override fun getFamilyName() = "Add generic upper bound"
override fun getText(): String {
val element = this.element
return when {
element != null -> KotlinBundle.message("fix.add.generic.upperbound.text", renderedUpperBound, element.name)
else -> null
} ?: ""
}
override fun getFamilyName() = KotlinBundle.message("fix.add.generic.upperbound.family")
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
val element = element ?: return false
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.codeInsight.intention.IntentionAction
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtElement
@@ -21,8 +22,15 @@ class AddInlineModifierFix(
modifier: KtModifierKeywordToken
) : AddModifierFix(parameter, modifier) {
override fun getText() = element?.let { "Add '${modifier.value}' to parameter '${it.name}'" } ?: ""
override fun getFamilyName() = "Add '${modifier.value}' to parameter"
override fun getText(): String {
val element = this.element
return when {
element != null -> KotlinBundle.message("fix.add.modifier.inline.parameter.text", modifier.value, element.name)
else -> null
} ?: ""
}
override fun getFamilyName() = KotlinBundle.message("fix.add.modifier.inline.parameter.family", modifier.value)
companion object {
private fun KtElement.findParameterWithName(name: String): KtParameter? {
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtFunction
@@ -17,9 +18,8 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
class AddInlineToFunctionFix(function: KtFunction) :
KotlinQuickFixAction<KtFunction>(function) {
override fun getFamilyName(): String = "Add 'inline' to function"
override fun getText(): String = "Add 'inline' to function '${element?.name}'"
override fun getFamilyName(): String = KotlinBundle.message("fix.add.modifier.inline.function.family")
override fun getText(): String = KotlinBundle.message("fix.add.modifier.inline.function.text", element?.name)
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
element?.addModifier(KtTokens.INLINE_KEYWORD)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
@@ -18,9 +19,7 @@ class AddIsToWhenConditionFix(
expression: KtWhenConditionWithExpression,
private val referenceText: String
) : KotlinQuickFixAction<KtWhenConditionWithExpression>(expression) {
override fun getText(): String = "Add 'is' before '$referenceText'"
override fun getText(): String = KotlinBundle.message("fix.add.is.to.when", referenceText)
override fun getFamilyName(): String = text
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.psi.psiUtil.parents
@@ -31,9 +32,17 @@ class AddLoopLabelFix(
private val existingLabelName = (loop.parent as? KtLabeledExpression)?.getLabelName()
private val description =
if (existingLabelName != null) "Add '@$existingLabelName' to ${jumpExpression.text}"
else "Add label to loop"
private val description = run {
when {
existingLabelName != null -> {
val labelName = "@$existingLabelName"
KotlinBundle.message("fix.add.loop.label.text", labelName, jumpExpression.text)
}
else -> {
KotlinBundle.message("fix.add.loop.label.text.generic")
}
}
}
override fun getText() = description
override fun getFamilyName() = text
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
@@ -49,12 +50,12 @@ open class AddModifierFix(
override fun getText(): String {
val element = element ?: return ""
if (modifier in modalityModifiers || modifier in VISIBILITY_MODIFIERS || modifier == CONST_KEYWORD) {
return "Make ${getElementName(element)} ${modifier.value}"
return KotlinBundle.message("fix.add.modifier.text", getElementName(element), modifier.value)
}
return "Add '${modifier.value}' modifier"
return KotlinBundle.message("fix.add.modifier.text.generic", modifier.value)
}
override fun getFamilyName() = "Add modifier"
override fun getFamilyName() = KotlinBundle.message("fix.add.modifier.family")
private fun invokeOnElement(element: KtModifierListOwner?) {
element?.addModifier(modifier)
@@ -24,6 +24,7 @@ import com.intellij.openapi.ui.popup.ListPopupStep
import com.intellij.openapi.ui.popup.PopupStep
import com.intellij.openapi.ui.popup.util.BaseListPopupStep
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.util.application.executeWriteCommand
@@ -57,13 +58,15 @@ class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction<KtV
}
override fun getText(): String {
return calculatePossibleArgumentNames()
.singleOrNull()
?.let { "Add name to argument: '${createArgumentWithName(it, reformat = false).text}'" }
?: "Add name to argument..."
val argumentName = calculatePossibleArgumentNames().singleOrNull()
if (argumentName != null) {
return KotlinBundle.message("fix.add.argument.name.text", createArgumentWithName(argumentName, reformat = false).text)
} else {
return KotlinBundle.message("fix.add.argument.name.text.generic")
}
}
override fun getFamilyName() = "Add name to argument"
override fun getFamilyName() = KotlinBundle.message("fix.add.argument.name.family")
private fun calculatePossibleArgumentNames(): List<Name> {
val callElement = element!!.getParentOfType<KtCallElement>(true) ?: return emptyList()
@@ -89,7 +92,7 @@ class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction<KtV
}
private fun addName(project: Project, argument: KtValueArgument, name: Name) {
project.executeWriteCommand("Add name to argument") {
project.executeWriteCommand(KotlinBundle.message("fix.add.argument.name.family")) {
argument.replace(createArgumentWithName(name))
}
}
@@ -104,7 +107,7 @@ class AddNameToArgumentFix(argument: KtValueArgument) : KotlinQuickFixAction<KtV
}
private fun getNamePopup(project: Project, names: List<Name>): ListPopupStep<Name> {
return object : BaseListPopupStep<Name>("Choose parameter name", names) {
return object : BaseListPopupStep<Name>(KotlinBundle.message("fix.add.argument.name.step.choose.parameter.name"), names) {
override fun onChosen(selectedValue: Name, finalChoice: Boolean): PopupStep<*>? {
addName(project, element!!, selectedValue)
return PopupStep.FINAL_CHOICE
@@ -8,13 +8,14 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.util.createIntentionForFirstParentOfType
import org.jetbrains.kotlin.psi.KtAnnotatedExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
class AddNewLineAfterAnnotationsFix(element: KtAnnotatedExpression) : KotlinQuickFixAction<KtAnnotatedExpression>(element) {
override fun getText() = "Add new line after annotations"
override fun getText() = KotlinBundle.message("fix.add.new.line.after.annotations")
override fun getFamilyName() = text
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.Modality.ABSTRACT
import org.jetbrains.kotlin.descriptors.Modality.SEALED
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.ShortenReferences
@@ -43,10 +44,10 @@ class AddPropertyToSupertypeFix private constructor(
override fun getText(): String {
val single = properties.singleOrNull()
return if (single != null) actionName(single) else "Add property to supertype..."
return if (single != null) actionName(single) else KotlinBundle.message("fix.add.property.to.supertype.text.generic")
}
override fun getFamilyName() = "Add property to supertype"
override fun getFamilyName() = KotlinBundle.message("fix.add.property.to.supertype.family")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
CommandProcessor.getInstance().runUndoTransparentAction {
@@ -59,7 +60,7 @@ class AddPropertyToSupertypeFix private constructor(
}
private fun addProperty(propertyData: PropertyData, project: Project) {
project.executeWriteCommand("Add Property to Type") {
project.executeWriteCommand(KotlinBundle.message("fix.add.property.to.supertype.progress")) {
val classBody = propertyData.targetClass.getOrCreateBody()
val propertyElement = KtPsiFactory(project).createProperty(propertyData.sourceCode)
@@ -75,7 +76,7 @@ class AddPropertyToSupertypeFix private constructor(
}
private fun createPropertyPopup(project: Project): ListPopupStep<*> {
return object : BaseListPopupStep<PropertyData>("Choose Type", properties) {
return object : BaseListPopupStep<PropertyData>(KotlinBundle.message("fix.add.property.to.supertype.choose.type"), properties) {
override fun isAutoSelectionEnabled() = false
override fun onChosen(selectedValue: PropertyData, finalChoice: Boolean): PopupStep<*>? {
@@ -90,7 +91,9 @@ class AddPropertyToSupertypeFix private constructor(
}
}
private fun actionName(propertyData: PropertyData) = "Add '${propertyData.signaturePreview}' to '${propertyData.targetClass.name}'"
private fun actionName(propertyData: PropertyData): String {
return KotlinBundle.message("fix.add.property.to.supertype.text", propertyData.signaturePreview, propertyData.targetClass.name)
}
companion object : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
@@ -38,6 +38,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtTypeParameter
@@ -51,7 +52,8 @@ class AddReifiedToTypeParameterOfFunctionFix(
private val inlineFix = AddInlineToFunctionWithReifiedFix(function)
private val elementName = getElementName(function)
override fun getText() = element?.let { "Make ${getElementName(it)} reified and $elementName inline" } ?: ""
override fun getText() =
element?.let { KotlinBundle.message("fix.make.type.parameter.reified", getElementName(it), elementName) } ?: ""
override fun invokeImpl(project: Project, editor: Editor?, file: PsiFile) {
super.invokeImpl(project, editor, file)
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
@@ -22,7 +23,7 @@ import org.jetbrains.kotlin.types.isError
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
class AddReturnToLastExpressionInFunctionFix(element: KtDeclarationWithBody) : KotlinQuickFixAction<KtDeclarationWithBody>(element) {
override fun getText() = "Add 'return' to last expression"
override fun getText() = KotlinBundle.message("fix.add.return.last.expression")
override fun getFamilyName() = text
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.psi.*
@@ -19,7 +20,7 @@ import org.jetbrains.kotlin.types.isError
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
class AddReturnToUnusedLastExpressionInFunctionFix(element: KtElement) : KotlinQuickFixAction<KtElement>(element) {
override fun getText() = "Add 'return' before the expression"
override fun getText() = KotlinBundle.message("fix.add.return.before.expression")
override fun getFamilyName() = text
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
@@ -21,12 +21,13 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtLambdaExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
class AddRunToLambdaFix(element: KtLambdaExpression) : KotlinQuickFixAction<KtLambdaExpression>(element) {
override fun getText() = "Add 'run' before the lambda expression"
override fun getText() = KotlinBundle.message("fix.add.return.before.lambda.expression")
override fun getFamilyName() = text
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -11,13 +11,14 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.KtNodeTypes
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.util.createIntentionForFirstParentOfType
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.startOffset
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
class AddSemicolonBeforeLambdaExpressionFix(element: KtLambdaExpression) : KotlinQuickFixAction<KtLambdaExpression>(element) {
override fun getText(): String = "Terminate preceding call with semicolon"
override fun getText(): String = KotlinBundle.message("fix.add.semicolon.lambda.expression")
override fun getFamilyName(): String = text
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
@@ -24,7 +25,7 @@ object AddSpreadOperatorForArrayAsVarargAfterSamFixFactory : KotlinSingleIntenti
}
class AddSpreadOperatorForArrayAsVarargAfterSamFix(element: PsiElement) : KotlinQuickFixAction<PsiElement>(element) {
override fun getFamilyName() = "Add a spread operator before an array passing as vararg"
override fun getFamilyName() = KotlinBundle.message("fix.add.spread.operator.after.sam")
override fun getText() = familyName
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.util.getResolutionScope
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
@@ -38,13 +39,14 @@ object AddStarProjectionsFixFactory : KotlinSingleIntentionActionFactory() {
}
}
private val starProjectionFixFamilyName = "Add star projections"
private val starProjectionFixFamilyName = KotlinBundle.message("fix.add.star.projection.family")
class AddStarProjectionsFix(element: KtUserType, private val argumentCount: Int) : KotlinQuickFixAction<KtUserType>(element) {
override fun getFamilyName() = starProjectionFixFamilyName
override fun getText() = "Add '${TypeReconstructionUtil.getTypeNameAndStarProjectionsString("", argumentCount)}'"
override fun getText() =
KotlinBundle.message("fix.add.star.projection.text", TypeReconstructionUtil.getTypeNameAndStarProjectionsString("", argumentCount))
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.builtins.isFunctionType
import org.jetbrains.kotlin.cfg.pseudocode.containingDeclarationForPseudocode
import org.jetbrains.kotlin.descriptors.ValueDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -21,8 +22,20 @@ class AddSuspendModifierFix(
) : AddModifierFix(element, KtTokens.SUSPEND_KEYWORD) {
override fun getText() = when (element) {
is KtNamedFunction -> "Make ${declarationName ?: "containing function"} suspend"
is KtTypeReference -> "Make ${declarationName ?: "receiver"} type suspend"
is KtNamedFunction -> {
if (declarationName != null) {
KotlinBundle.message("fix.add.suspend.modifier.function", declarationName)
} else {
KotlinBundle.message("fix.add.suspend.modifier.function.generic")
}
}
is KtTypeReference -> {
if (declarationName != null) {
KotlinBundle.message("fix.add.suspend.modifier.receiver", declarationName)
} else {
KotlinBundle.message("fix.add.suspend.modifier.receiver.generic")
}
}
else -> super.getText()
}
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.codeInsight.intention.LowPriorityAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.replaced
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
@@ -17,8 +18,14 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
class AddToStringFix(element: KtExpression, private val nullable: Boolean) : KotlinQuickFixAction<KtExpression>(element),
LowPriorityAction {
override fun getFamilyName() = "Add 'toString()' call"
override fun getText() = if (nullable) "Add safe '?.toString()' call" else "Add 'toString()' call"
override fun getFamilyName() = KotlinBundle.message("fix.add.tostring.call.family")
override fun getText(): String {
return when (nullable) {
true -> KotlinBundle.message("fix.add.tostring.call.text.safe")
false -> KotlinBundle.message("fix.add.tostring.call.text")
}
}
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.project.builtIns
@@ -53,8 +54,10 @@ class AddTypeAnnotationToValueParameterFix(element: KtParameter) : KotlinQuickFi
return element.typeReference == null && typeNameShort != null
}
override fun getFamilyName() = "Add type annotation"
override fun getText() = element?.let { "Add type '$typeNameShort' to parameter '${it.name}'" } ?: ""
override fun getFamilyName() = KotlinBundle.message("fix.add.type.annnotation.family")
override fun getText() =
element?.let { KotlinBundle.message("fix.add.type.annnotation.text", typeNameShort, it.name) } ?: ""
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightUtilCore
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.KtWhenEntry
@@ -28,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
class AddWhenElseBranchFix(element: KtWhenExpression) : KotlinQuickFixAction<KtWhenExpression>(element) {
override fun getFamilyName() = "Add else branch"
override fun getFamilyName() = KotlinBundle.message("fix.add.else.branch.when")
override fun getText() = familyName
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.cfg.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.quoteIfNeeded
@@ -40,7 +41,13 @@ class AddWhenRemainingBranchesFix(
override fun getFamilyName() = text
override fun getText() = "Add remaining branches" + if (withImport) " with * import" else ""
override fun getText(): String {
if (withImport) {
return KotlinBundle.message("fix.add.remaining.branches.with.star.import")
} else {
return KotlinBundle.message("fix.add.remaining.branches")
}
}
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
return isAvailable(element)
@@ -10,6 +10,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.lexer.KtTokens
@@ -37,7 +38,11 @@ object AssignOperatorAmbiguityFactory : KotlinIntentionActionsFactory() {
val property = left.mainReference?.resolve() as? KtProperty
val propertyName = property?.name
if (property != null && propertyName != null && property.isLocal) {
fixes.add(ChangeVariableMutabilityFix(property, false, "Change '$propertyName' to val"))
val fix = ChangeVariableMutabilityFix(
property, false,
KotlinBundle.message("fix.change.mutability.change.to.val", propertyName)
)
fixes.add(fix)
}
fixes.add(ReplaceWithAssignFunctionCallFix(element, operationText))
}
@@ -56,7 +61,10 @@ private class ReplaceWithAssignFunctionCallFix(
element: KtBinaryExpression,
private val operationText: String
) : KotlinQuickFixAction<KtBinaryExpression>(element) {
override fun getText() = "Replace with '${operationText}Assign()' call"
override fun getText(): String {
val call = operationText + "Assign()"
return KotlinBundle.message("fix.replace.with.assign.function.call", call)
}
override fun getFamilyName() = text
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.util.getResolutionScope
@@ -21,8 +22,7 @@ import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
import org.jetbrains.kotlin.types.KotlinType
class AssignToPropertyFix(element: KtNameReferenceExpression) : KotlinQuickFixAction<KtNameReferenceExpression>(element) {
override fun getText() = "Assign to property"
override fun getText() = KotlinBundle.message("fix.assign.to.property")
override fun getFamilyName() = text
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.replaced
@@ -31,8 +32,8 @@ class CastExpressionFix(element: KtExpression, type: KotlinType) : KotlinQuickFi
&& expressionType != type.makeNullable() //covered by AddExclExclCallFix
}
override fun getFamilyName() = "Cast expression"
override fun getText() = element?.let { "Cast expression '${it.text}' to '$typePresentation'" } ?: ""
override fun getFamilyName() = KotlinBundle.message("fix.cast.expression.family")
override fun getText() = element?.let { KotlinBundle.message("fix.cast.expression.text", it.text, typePresentation) } ?: ""
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) = upOrDownCast
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.replaced
@@ -24,14 +25,18 @@ class ChangeAccessorTypeFix(element: KtPropertyAccessor) : KotlinQuickFixAction<
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) = getType() != null
override fun getFamilyName() = "Change accessor type"
override fun getFamilyName() = KotlinBundle.message("fix.change.accessor.family")
override fun getText(): String {
val element = element ?: return ""
val type = getType() ?: return familyName
val renderedType = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(type)
val target = if (element.isGetter) "getter" else "setter parameter"
return "Change $target type to $renderedType"
return if (element.isGetter) {
KotlinBundle.message("fix.change.accessor.getter", renderedType)
} else {
KotlinBundle.message("fix.change.accessor.setter.parameter", renderedType)
}
}
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -77,9 +77,10 @@ abstract class ChangeCallableReturnTypeFix(
val containerName = container?.name?.takeUnless { it.isSpecial }?.asString()
val fullName = if (containerName != null) "'$containerName.$name'" else "'$name'"
if (element is KtParameter) {
return "property $fullName"
return KotlinBundle.message("fix.change.return.type.presentation.property", fullName)
} else {
return KotlinBundle.message("fix.change.return.type.presentation.function", fullName)
}
return "function $fullName"
} else {
return null
}
@@ -91,22 +92,27 @@ abstract class ChangeCallableReturnTypeFix(
class ForEnclosing(element: KtFunction, type: KotlinType) : ChangeCallableReturnTypeFix(element, type), HighPriorityAction {
override fun functionPresentation(): String? {
val presentation = super.functionPresentation() ?: return "enclosing function"
return "enclosing $presentation"
val presentation = super.functionPresentation()
?: return KotlinBundle.message("fix.change.return.type.presentation.enclosing.function")
return KotlinBundle.message("fix.change.return.type.presentation.enclosing", presentation)
}
}
class ForCalled(element: KtCallableDeclaration, type: KotlinType) : ChangeCallableReturnTypeFix(element, type) {
override fun functionPresentation(): String? {
val presentation = super.functionPresentation() ?: return "called function"
return if (element is KtParameter) "accessed $presentation" else "called $presentation"
val presentation = super.functionPresentation()
?: return KotlinBundle.message("fix.change.return.type.presentation.called.function")
return when (element) {
is KtParameter -> KotlinBundle.message("fix.change.return.type.presentation.accessed", presentation)
else -> KotlinBundle.message("fix.change.return.type.presentation.called", presentation)
}
}
}
class ForOverridden(element: KtFunction, type: KotlinType) : ChangeCallableReturnTypeFix(element, type) {
override fun functionPresentation(): String? {
val presentation = super.functionPresentation() ?: return null
return "base $presentation"
return KotlinBundle.message("fix.change.return.type.presentation.base", presentation)
}
}
@@ -121,20 +127,28 @@ abstract class ChangeCallableReturnTypeFix(
if (isUnitType && element is KtFunction && element.hasBlockBody()) {
return if (functionPresentation == null)
"Remove explicitly specified return type"
KotlinBundle.message("fix.change.return.type.remove.explicit.return.type")
else
"Remove explicitly specified return type of $functionPresentation"
KotlinBundle.message("fix.change.return.type.remove.explicit.return.type.of", functionPresentation)
}
val typeName = if (element is KtFunction) "return type" else "type"
return if (functionPresentation == null)
"Change $typeName to '$typePresentation'"
else
"Change $typeName of $functionPresentation to '$typePresentation'"
return when (element) {
is KtFunction -> {
if (functionPresentation != null)
KotlinBundle.message("fix.change.return.type.return.type.text.of", functionPresentation, typePresentation)
else
KotlinBundle.message("fix.change.return.type.return.type.text", typePresentation)
}
else -> {
if (functionPresentation != null)
KotlinBundle.message("fix.change.return.type.type.text.of", functionPresentation, typePresentation)
else
KotlinBundle.message("fix.change.return.type.type.text", typePresentation)
}
}
}
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type")
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type.family")
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean {
return !typeContainsError &&
@@ -92,9 +92,8 @@ class ChangeFunctionLiteralReturnTypeFix(
null
}
override fun getText() = appropriateQuickFix?.text ?: "Change lambda expression return type to '$typePresentation'"
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type")
override fun getText() = appropriateQuickFix?.text ?: KotlinBundle.message("fix.change.return.type.lambda", typePresentation)
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type.family")
override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean =
functionLiteralReturnTypeRef != null || appropriateQuickFix != null && appropriateQuickFix.isAvailable(
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.CollectingNameValidator
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
@@ -37,7 +38,7 @@ class ChangeFunctionLiteralSignatureFix private constructor(
private val parameterTypes: List<KotlinType>
) : ChangeFunctionSignatureFix(functionLiteral, functionDescriptor) {
override fun getText() = "Change the signature of lambda expression"
override fun getText() = KotlinBundle.message("fix.change.signature.lambda")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.KotlinNameSuggester
@@ -113,7 +114,11 @@ abstract class ChangeFunctionSignatureFix(
KotlinTypeChecker.DEFAULT.isSubtypeOf(dataFlowAwareType, parameter.type)
} ?: true
}
return AddFunctionParametersFix(originalElement, functionDescriptor, hasTypeMismatches)
val kind = when {
hasTypeMismatches -> AddFunctionParametersFix.Kind.ChangeSignature
else -> AddFunctionParametersFix.Kind.AddParameterGeneric
}
return AddFunctionParametersFix(originalElement, functionDescriptor, kind)
}
}
@@ -125,15 +130,14 @@ abstract class ChangeFunctionSignatureFix(
functionDescriptor: FunctionDescriptor,
private val parameterToRemove: ValueParameterDescriptor
) : ChangeFunctionSignatureFix(element, functionDescriptor) {
override fun getText() = "Remove parameter '${parameterToRemove.name.asString()}'"
override fun getText() = KotlinBundle.message("fix.change.signature.remove.parameter", parameterToRemove.name.asString())
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
runRemoveParameter(parameterToRemove, element ?: return)
}
}
const val FAMILY_NAME = "Change signature of function/constructor"
val FAMILY_NAME = KotlinBundle.message("fix.change.signature.family")
fun runRemoveParameter(parameterDescriptor: ValueParameterDescriptor, context: PsiElement) {
val functionDescriptor = parameterDescriptor.containingDeclaration as FunctionDescriptor
@@ -152,7 +156,7 @@ abstract class ChangeFunctionSignatureFix(
override fun forcePerformForSelectedFunctionOnly() = false
},
context,
"Remove parameter '${parameterDescriptor.name.asString()}'"
KotlinBundle.message("fix.change.signature.remove.parameter", parameterDescriptor.name.asString())
)
}
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
@@ -230,11 +231,13 @@ class ChangeMemberFunctionSignatureFix private constructor(
override fun getText(): String {
val single = signatures.singleOrNull()
return if (single != null) "Change function signature to '${single.preview}'"
else "Change function signature..."
return when {
single != null -> KotlinBundle.message("fix.change.signature.function.text", single.preview)
else -> KotlinBundle.message("fix.change.signature.function.text.generic")
}
}
override fun getFamilyName() = "Change function signature"
override fun getFamilyName() = KotlinBundle.message("fix.change.signature.function.family")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -291,7 +294,10 @@ class ChangeMemberFunctionSignatureFix private constructor(
private val signaturePopup: BaseListPopupStep<Signature>
get() {
return object : BaseListPopupStep<Signature>("Choose Signature", signatures) {
return object : BaseListPopupStep<Signature>(
KotlinBundle.message("fix.change.signature.function.popup.title"),
signatures
) {
override fun isAutoSelectionEnabled() = false
override fun onChosen(selectedValue: Signature, finalChoice: Boolean): PopupStep<Any>? {
@@ -310,7 +316,7 @@ class ChangeMemberFunctionSignatureFix private constructor(
private fun changeSignature(signature: Signature) {
PsiDocumentManager.getInstance(project).commitAllDocuments()
project.executeWriteCommand("Change Function Signature") {
project.executeWriteCommand(KotlinBundle.message("fix.change.signature.function.family")) {
val patternFunction = KtPsiFactory(project).createFunction(signature.sourceCode)
val newTypeRef = function.setTypeReference(patternFunction.typeReference)
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtConstructor
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtObjectDeclaration
@@ -15,7 +16,7 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
class ChangeObjectToClassFix(element: KtObjectDeclaration) : KotlinQuickFixAction<KtObjectDeclaration>(element) {
override fun getText(): String = "Change object to class"
override fun getText(): String = KotlinBundle.message("fix.change.object.to.class")
override fun getFamilyName(): String = text
@@ -44,13 +44,23 @@ class ChangeParameterTypeFix(element: KtParameter, type: KotlinType) : KotlinQui
override fun getText(): String {
val element = element ?: return ""
return if (isPrimaryConstructorParameter)
"Change parameter '${element.name}' type of primary constructor of class '$containingDeclarationName' to '$typePresentation'"
else
"Change parameter '${element.name}' type of function '$containingDeclarationName' to '$typePresentation'"
return when {
isPrimaryConstructorParameter -> {
KotlinBundle.message(
"fix.change.return.type.text.primary.constructor",
element.name, containingDeclarationName, typePresentation
)
}
else -> {
KotlinBundle.message(
"fix.change.return.type.text.function",
element.name, containingDeclarationName, typePresentation
)
}
}
}
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type")
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type.family")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.quickfix.createFromUsage.callableBuilder.getReturnTypeReference
import org.jetbrains.kotlin.idea.references.mainReference
@@ -25,7 +26,7 @@ class ChangeSuperTypeListEntryTypeArgumentFix(
private val typeArgumentIndex: Int
) : KotlinQuickFixAction<KtSuperTypeListEntry>(element) {
override fun getText() = "Change type argument to $type"
override fun getText() = KotlinBundle.message("fix.change.type.argument", type)
override fun getFamilyName() = text
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde
import org.jetbrains.kotlin.idea.core.util.runSynchronouslyWithProgress
@@ -46,9 +47,9 @@ class ChangeSuspendInHierarchyFix(
) : KotlinQuickFixAction<KtNamedFunction>(element) {
override fun getFamilyName(): String {
return if (addModifier) {
"Add 'suspend' modifier to all functions in hierarchy"
KotlinBundle.message("fix.change.suspend.hierarchy.add")
} else {
"Remove 'suspend' modifier from all functions in hierarchy"
KotlinBundle.message("fix.change.suspend.hierarchy.remove")
}
}
@@ -70,7 +71,7 @@ class ChangeSuspendInHierarchyFix(
val baseClass = DescriptorToSourceUtilsIde.getAnyDeclaration(project, baseClassDescriptor) ?: return@forEach
val name = (baseClass as? PsiNamedElement)?.name ?: return@forEach
progressIndicator.text = "Looking for class $name inheritors..."
progressIndicator.text = KotlinBundle.message("fix.change.progress.looking.inheritors", name)
val classes = listOf(baseClass) + HierarchySearchRequest(baseClass, baseClass.useScope).searchInheritors()
classes.mapNotNullTo(result) {
val subClass = it.unwrapped as? KtClassOrObject ?: return@mapNotNullTo null
@@ -88,7 +89,7 @@ class ChangeSuspendInHierarchyFix(
}
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val functions = project.runSynchronouslyWithProgress("Analyzing class hierarchy...", true) {
val functions = project.runSynchronouslyWithProgress(KotlinBundle.message("fix.change.progress.analyzing.class.hierarchy"), true) {
runReadAction { findAllFunctionToProcess(project) }
} ?: return
@@ -19,10 +19,11 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.*
class ChangeToFunctionInvocationFix(element: KtExpression) : KotlinQuickFixAction<KtExpression>(element) {
override fun getFamilyName() = "Change to function invocation"
override fun getFamilyName() = KotlinBundle.message("fix.change.to.function.invocation")
override fun getText() = familyName
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.util.findLabelAndCall
import org.jetbrains.kotlin.name.Name
@@ -22,8 +23,8 @@ class ChangeToLabeledReturnFix(
element: KtReturnExpression, val labeledReturn: String
) : KotlinQuickFixAction<KtReturnExpression>(element) {
override fun getFamilyName() = "Change to return with label"
override fun getText() = "Change to '$labeledReturn'"
override fun getFamilyName() = KotlinBundle.message("fix.change.to.labeled.return.family")
override fun getText() = KotlinBundle.message("fix.change.to.labeled.return.text", labeledReturn)
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val returnExpression = element ?: return
@@ -10,6 +10,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.idea.core.replaced
@@ -23,8 +24,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.KotlinType
class ChangeToMutableCollectionFix(property: KtProperty, private val type: String) : KotlinQuickFixAction<KtProperty>(property) {
override fun getText() = "Change type to Mutable$type"
override fun getText() = KotlinBundle.message("fix.change.to.mutable.type", "Mutable$type")
override fun getFamilyName() = text
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.intentions.getCallableDescriptor
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtExpression
@@ -19,7 +20,10 @@ class ChangeToPropertyAccessFix(
private val isObjectCall: Boolean
) : KotlinQuickFixAction<KtCallExpression>(element) {
override fun getFamilyName() = if (isObjectCall) "Remove invocation" else "Change to property access"
override fun getFamilyName() = when {
isObjectCall -> KotlinBundle.message("fix.change.to.property.access.family.remove")
else -> KotlinBundle.message("fix.change.to.property.access.family.change")
}
override fun getText() = familyName
@@ -9,6 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
import org.jetbrains.kotlin.lexer.KtTokens
@@ -22,9 +23,19 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
class ChangeToStarProjectionFix(element: KtTypeElement) : KotlinQuickFixAction<KtTypeElement>(element) {
override fun getFamilyName() = "Change to star projection"
override fun getFamilyName() = KotlinBundle.message("fix.change.to.star.projection.family")
override fun getText() = element?.let { "Change type arguments to <${it.typeArgumentsAsTypes.joinToString { "*" }}>" } ?: ""
override fun getText(): String {
val element = this.element
return when {
element != null -> {
val type = element.typeArgumentsAsTypes.joinToString { "*" }
KotlinBundle.message("fix.change.to.star.projection.text", "<$type>")
}
else -> null
} ?: ""
}
public override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -18,14 +18,15 @@ package org.jetbrains.kotlin.idea.quickfix
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
class ChangeToUseSpreadOperatorFix(element: KtExpression) : KotlinQuickFixAction<KtExpression>(element) {
override fun getFamilyName() = "Change to use spread operator"
override fun getFamilyName() = KotlinBundle.message("fix.change.to.use.spread.operator.family")
override fun getText() = "Change '${element?.text}' to '*${element?.text}'"
override fun getText() = KotlinBundle.message("fix.change.to.use.spread.operator.text", element?.text, "*${element?.text}")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -9,6 +9,7 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil
import org.jetbrains.kotlin.idea.core.replaced
@@ -19,11 +20,14 @@ import org.jetbrains.kotlin.psi.KtTypeReference
import org.jetbrains.kotlin.types.KotlinType
class ChangeTypeFix(element: KtTypeReference, private val type: KotlinType) : KotlinQuickFixAction<KtTypeReference>(element) {
override fun getFamilyName() = "Change type"
override fun getFamilyName() = KotlinBundle.message("fix.change.type.family")
override fun getText(): String {
val currentTypeText = element?.text ?: return ""
return "Change type from '$currentTypeText' to '${QuickFixUtil.renderTypeWithFqNameOnClash(type, currentTypeText)}'"
return KotlinBundle.message(
"fix.change.type.text",
currentTypeText, QuickFixUtil.renderTypeWithFqNameOnClash(type, currentTypeText)
)
}
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
@@ -78,7 +78,7 @@ open class ChangeVariableTypeFix(element: KtVariableDeclaration, type: KotlinTyp
}
}
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type")
override fun getFamilyName() = KotlinBundle.message("fix.change.return.type.family")
override fun isAvailable(project: Project, editor: Editor?, file: KtFile) = !typeContainsError
@@ -66,26 +66,26 @@ object ExperimentalFixesFactory : KotlinIntentionActionsFactory() {
val result = mutableListOf<IntentionAction>()
run {
val suffix = " to '${containingDeclaration.name}'"
val kind = AddAnnotationFix.Kind.Declaration(containingDeclaration.name)
if (isApplicableTo(containingDeclaration, applicableTargets)) {
result.add(AddAnnotationFix(containingDeclaration, annotationFqName, suffix))
result.add(AddAnnotationFix(containingDeclaration, annotationFqName, kind))
}
result.add(
AddAnnotationFix(
containingDeclaration, moduleDescriptor.OPT_IN_FQ_NAME, suffix, annotationFqName
containingDeclaration, moduleDescriptor.OPT_IN_FQ_NAME, kind, annotationFqName
)
)
}
if (containingDeclaration is KtCallableDeclaration) {
val containingClassOrObject = containingDeclaration.containingClassOrObject
if (containingClassOrObject != null) {
val suffix = " to containing class '${containingClassOrObject.name}'"
val kind = AddAnnotationFix.Kind.ContainingClass(containingClassOrObject.name)
if (isApplicableTo(containingClassOrObject, applicableTargets)) {
result.add(AddAnnotationFix(containingClassOrObject, annotationFqName, suffix))
result.add(AddAnnotationFix(containingClassOrObject, annotationFqName, kind))
} else {
result.add(
AddAnnotationFix(
containingClassOrObject, moduleDescriptor.OPT_IN_FQ_NAME, suffix, annotationFqName
containingClassOrObject, moduleDescriptor.OPT_IN_FQ_NAME, kind, annotationFqName
)
)
}
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithAllCompilerChecks
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
@@ -274,7 +275,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
}
null
} else {
val dialog = object : DialogWithEditor(project, "Create from usage", "") {
val dialog = object : DialogWithEditor(project, KotlinBundle.message("fix.create.from.usage.dialog.title"), "") {
override fun doOKAction() {
project.executeWriteCommand("Premature end of template") {
TemplateManagerImpl.getTemplateState(editor)?.gotoEnd(false)
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.ShortenReferences
@@ -39,17 +40,17 @@ internal class ChangeMethodParameters(
override fun getText(): String {
val target = element ?: return "<not available>"
val target = element ?: return KotlinBundle.message("fix.change.signature.unavailable")
val helper = JvmPsiConversionHelper.getInstance(target.project)
val parametersString = request.expectedParameters.joinToString(", ", "(", ")") { ep ->
val kotlinType =
ep.expectedTypes.firstOrNull()?.theType?.let { helper.convertType(it).resolveToKotlinType(target.getResolutionFacade()) }
"${ep.semanticNames.firstOrNull() ?: "parameter"}: ${kotlinType?.let {
val parameterName = ep.semanticNames.firstOrNull() ?: KotlinBundle.message("fix.change.signature.unnamed.parameter")
"$parameterName: ${kotlinType?.let {
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(it)
} ?: "<error>"}"
} ?: KotlinBundle.message("fix.change.signature.error")}"
}
val shortenParameterString = StringUtil.shortenTextWithEllipsis(parametersString, 30, 5)
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.ShortenReferences
@@ -40,17 +41,17 @@ internal class ChangeMethodParameters(
override fun getText(): String {
val target = element ?: return "<not available>"
val target = element ?: return KotlinBundle.message("fix.change.signature.unavailable")
val helper = JvmPsiConversionHelper.getInstance(target.project)
val parametersString = request.expectedParameters.joinToString(", ", "(", ")") { ep ->
val kotlinType =
ep.expectedTypes.firstOrNull()?.theType?.let { helper.convertType(it).resolveToKotlinType(target.getResolutionFacade()) }
"${ep.semanticNames.firstOrNull() ?: "parameter"}: ${kotlinType?.let {
val parameterName = ep.semanticNames.firstOrNull() ?: KotlinBundle.message("fix.change.signature.unnamed.parameter")
"$parameterName: ${kotlinType?.let {
IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(it)
} ?: "<error>"}"
} ?: KotlinBundle.message("fix.change.signature.error")}"
}
val shortenParameterString = StringUtil.shortenTextWithEllipsis(parametersString, 30, 5)
@@ -13,6 +13,7 @@ import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.psi.formatter.FormatterUtil
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
import org.jetbrains.kotlin.idea.quickfix.TypeAccessibilityChecker
@@ -28,7 +29,7 @@ abstract class AbstractCreateDeclarationFix<D : KtNamedDeclaration>(
protected val generateIt: KtPsiFactory.(Project, TypeAccessibilityChecker, D) -> D?
) : KotlinQuickFixAction<D>(declaration) {
override fun getFamilyName(): String = "Create expect / actual declaration"
override fun getFamilyName(): String = KotlinBundle.message("fix.create.expect.actual")
protected val elementType: String = element.getTypeDescription()
@@ -60,12 +61,16 @@ abstract class AbstractCreateDeclarationFix<D : KtNamedDeclaration>(
factory.generateIt(project, TypeAccessibilityChecker.create(project, module), element) ?: return@runWhenSmart
} catch (e: KotlinTypeInaccessibleException) {
if (editor != null) {
showErrorHint(project, editor, escapeXml("Cannot generate $elementType: " + e.message), "Inaccessible type")
showErrorHint(
project, editor,
escapeXml(KotlinBundle.message("fix.create.declaration.error", elementType, e.message)),
KotlinBundle.message("fix.create.declaration.error.inaccessible.type")
)
}
return@runWhenSmart
}
project.executeWriteCommand("Create expect / actual declaration") {
project.executeWriteCommand(KotlinBundle.message("fix.create.expect.actual")) {
if (targetFile.packageDirective?.fqName != originalFile.packageDirective?.fqName &&
targetFile.declarations.isEmpty()
) {
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.toDescriptor
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
@@ -45,7 +46,7 @@ class AddActualFix(
override fun getFamilyName() = text
override fun getText() = "Add missing actual members"
override fun getText() = KotlinBundle.message("fix.create.missing.actual.members")
override fun invoke(project: Project, editor: Editor?, file: KtFile) {
val element = element ?: return
@@ -85,7 +86,7 @@ class AddActualFix(
if (errors.isNotEmpty()) {
val message = errors.entries.joinToString(
separator = "\n",
prefix = "Some types are not accessible:\n"
prefix = KotlinBundle.message("fix.create.declaration.error.some.types.inaccessible") + "\n"
) { (declaration, error) ->
getExpressionShortText(declaration) + " -> " + error.message
}