Remove object name and type in project view
This commit is contained in:
@@ -423,6 +423,7 @@ presentation.text.for.receiver.in.container.paren=(for {0} in {1})
|
|||||||
presentation.text.object.in.container=object in {0}
|
presentation.text.object.in.container=object in {0}
|
||||||
|
|
||||||
project.view.class.initializer=class initializer
|
project.view.class.initializer=class initializer
|
||||||
|
project.view.class.error.name=no name provided
|
||||||
|
|
||||||
copy.text.adding.imports=Adding imports ...
|
copy.text.adding.imports=Adding imports ...
|
||||||
copy.text.clipboard.content.seems.to.be.java.code.do.you.want.to.convert.it.to.kotlin=Clipboard content seems to be Java code. Do you want to convert it to Kotlin?
|
copy.text.clipboard.content.seems.to.be.java.code.do.you.want.to.convert.it.to.kotlin=Clipboard content seems to be Java code. Do you want to convert it to Kotlin?
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ internal class KtDeclarationTreeNode(
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val CLASS_INITIALIZER = "<" + KotlinBundle.message("project.view.class.initializer") + ">"
|
private val CLASS_INITIALIZER = "<" + KotlinBundle.message("project.view.class.initializer") + ">"
|
||||||
|
private val ERROR_NAME = "<" + KotlinBundle.message("project.view.class.error.name") + ">"
|
||||||
|
|
||||||
|
private fun String?.orErrorName() = if (!isNullOrBlank()) this else ERROR_NAME
|
||||||
|
|
||||||
fun tryGetRepresentableText(declaration: KtDeclaration, project: Project): String? {
|
fun tryGetRepresentableText(declaration: KtDeclaration, project: Project): String? {
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ internal class KtDeclarationTreeNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KtProperty.presentableText() = buildString {
|
fun KtProperty.presentableText() = buildString {
|
||||||
append(name)
|
append(name.orErrorName())
|
||||||
typeReference?.text?.let { reference ->
|
typeReference?.text?.let { reference ->
|
||||||
appendColon()
|
appendColon()
|
||||||
append(reference)
|
append(reference)
|
||||||
@@ -58,7 +61,7 @@ internal class KtDeclarationTreeNode(
|
|||||||
append(receiverReference)
|
append(receiverReference)
|
||||||
append('.')
|
append('.')
|
||||||
}
|
}
|
||||||
append(name)
|
append(name.orErrorName())
|
||||||
append("(")
|
append("(")
|
||||||
val valueParameters = valueParameters
|
val valueParameters = valueParameters
|
||||||
valueParameters.forEachIndexed { index, parameter ->
|
valueParameters.forEachIndexed { index, parameter ->
|
||||||
@@ -86,21 +89,7 @@ internal class KtDeclarationTreeNode(
|
|||||||
if (isCompanion()) {
|
if (isCompanion()) {
|
||||||
append("companion object")
|
append("companion object")
|
||||||
} else {
|
} else {
|
||||||
append("object")
|
append(name.orErrorName())
|
||||||
if (!name.isNullOrEmpty()) {
|
|
||||||
append(" $name")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (superTypeListEntries.any()) {
|
|
||||||
appendColon()
|
|
||||||
val lastIndex = superTypeListEntries.size - 1
|
|
||||||
superTypeListEntries.forEachIndexed { index, entry ->
|
|
||||||
entry.typeReference?.text?.let {
|
|
||||||
if (index > 0 && index != lastIndex) append(", ")
|
|
||||||
append(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +98,7 @@ internal class KtDeclarationTreeNode(
|
|||||||
is KtFunction -> declaration.presentableText()
|
is KtFunction -> declaration.presentableText()
|
||||||
is KtObjectDeclaration -> declaration.presentableText()
|
is KtObjectDeclaration -> declaration.presentableText()
|
||||||
is KtAnonymousInitializer -> CLASS_INITIALIZER
|
is KtAnonymousInitializer -> CLASS_INITIALIZER
|
||||||
else -> declaration.name
|
else -> declaration.name.orErrorName()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user