[toml] Handle quoted key segments in getName

Keys `foo` and `"foo"` introduce the same named entity, and so
should have the same name.

closes https://github.com/JetBrains/intellij-community/pull/1754

GitOrigin-RevId: 2920a63b6a28fcfe374478434e2e017b7aaf502c
This commit is contained in:
Christophe Rhodes
2021-10-06 20:12:26 +00:00
committed by intellij-monorepo-bot
parent 9c0e634333
commit 16c27d5e50
@@ -18,6 +18,7 @@ import com.intellij.psi.tree.IElementType
import com.intellij.psi.util.PsiTreeUtil
import org.toml.lang.psi.*
import org.toml.lang.psi.TomlElementTypes.*
import org.toml.lang.psi.ext.TomlLiteralKind
class TomlKeyValueImpl(type: IElementType) : CompositePsiElement(type), TomlKeyValue {
@@ -36,7 +37,10 @@ class TomlKeyValueImpl(type: IElementType) : CompositePsiElement(type), TomlKeyV
class TomlKeySegmentImpl(type: IElementType) : CompositePsiElement(type), TomlKeySegment {
override fun getName(): String = text
override fun getName(): String = when (val child = node.findChildByType(TOML_SINGLE_LINE_STRINGS)) {
null -> text
else -> (TomlLiteralKind.fromAstNode(child) as? TomlLiteralKind.String)?.value ?: text
}
override fun setName(name: String): PsiElement {
return replace(TomlPsiFactory(project).createKeySegment(name))