[CMI] Add ability to copy ParsedCodeMetaInfo
This commit is contained in:
+7
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.codeMetaInfo.model
|
package org.jetbrains.kotlin.codeMetaInfo.model
|
||||||
|
|
||||||
import org.jetbrains.kotlin.codeMetaInfo.renderConfigurations.AbstractCodeMetaInfoRenderConfiguration
|
import org.jetbrains.kotlin.codeMetaInfo.renderConfigurations.ParsedCodeMetaInfoRenderConfiguration
|
||||||
|
|
||||||
class ParsedCodeMetaInfo(
|
class ParsedCodeMetaInfo(
|
||||||
override val start: Int,
|
override val start: Int,
|
||||||
@@ -14,7 +14,7 @@ class ParsedCodeMetaInfo(
|
|||||||
override val tag: String,
|
override val tag: String,
|
||||||
val description: String?
|
val description: String?
|
||||||
) : CodeMetaInfo {
|
) : CodeMetaInfo {
|
||||||
override val renderConfiguration = object : AbstractCodeMetaInfoRenderConfiguration(false) {}
|
override val renderConfiguration = ParsedCodeMetaInfoRenderConfiguration
|
||||||
|
|
||||||
override fun asString(): String = renderConfiguration.asString(this)
|
override fun asString(): String = renderConfiguration.asString(this)
|
||||||
|
|
||||||
@@ -29,4 +29,9 @@ class ParsedCodeMetaInfo(
|
|||||||
result = 31 * result + tag.hashCode()
|
result = 31 * result + tag.hashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun copy(): ParsedCodeMetaInfo {
|
||||||
|
return ParsedCodeMetaInfo(start, end, attributes.toMutableList(), tag, description)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.codeMetaInfo.renderConfigurations
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo
|
||||||
|
import org.jetbrains.kotlin.codeMetaInfo.model.ParsedCodeMetaInfo
|
||||||
|
|
||||||
|
object ParsedCodeMetaInfoRenderConfiguration : AbstractCodeMetaInfoRenderConfiguration() {
|
||||||
|
override fun asString(codeMetaInfo: CodeMetaInfo): String {
|
||||||
|
require(codeMetaInfo is ParsedCodeMetaInfo)
|
||||||
|
return super.asString(codeMetaInfo) + (codeMetaInfo.description?.let { "(\"$it\")" } ?: "")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user