Fixed KT-6235 Get rid of `` for identifier "type" in converter
#KT-6235 Fixed
This commit is contained in:
@@ -18,7 +18,8 @@ package org.jetbrains.jet.j2k.ast
|
|||||||
|
|
||||||
import org.jetbrains.jet.j2k.CodeBuilder
|
import org.jetbrains.jet.j2k.CodeBuilder
|
||||||
import com.intellij.psi.PsiNameIdentifierOwner
|
import com.intellij.psi.PsiNameIdentifierOwner
|
||||||
import org.jetbrains.jet.j2k.CodeConverter
|
import org.jetbrains.jet.lexer.JetKeywordToken
|
||||||
|
import org.jetbrains.jet.lexer.JetTokens
|
||||||
|
|
||||||
fun PsiNameIdentifierOwner.declarationIdentifier(): Identifier {
|
fun PsiNameIdentifierOwner.declarationIdentifier(): Identifier {
|
||||||
val name = getName()
|
val name = getName()
|
||||||
@@ -35,7 +36,7 @@ class Identifier(
|
|||||||
get() = name.isEmpty()
|
get() = name.isEmpty()
|
||||||
|
|
||||||
private fun toKotlin(): String {
|
private fun toKotlin(): String {
|
||||||
if (quotingNeeded && ONLY_KOTLIN_KEYWORDS.contains(name) || name.contains("$")) {
|
if (quotingNeeded && KEYWORDS.contains(name) || name.contains("$")) {
|
||||||
return quote(name)
|
return quote(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,9 +54,7 @@ class Identifier(
|
|||||||
class object {
|
class object {
|
||||||
val Empty = Identifier("")
|
val Empty = Identifier("")
|
||||||
|
|
||||||
val ONLY_KOTLIN_KEYWORDS: Set<String> = setOf(
|
private val KEYWORDS = JetTokens.KEYWORDS.getTypes().map { (it as JetKeywordToken).getValue() }.toSet()
|
||||||
"package", "as", "type", "val", "var", "fun", "is", "in", "object", "when", "trait", "This"
|
|
||||||
)
|
|
||||||
|
|
||||||
fun toKotlin(name: String): String = Identifier(name).toKotlin()
|
fun toKotlin(name: String): String = Identifier(name).toKotlin()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
val `as`: Int
|
val `as`: Int
|
||||||
val `type`: Int
|
val type: Int
|
||||||
val `val`: Int
|
val `val`: Int
|
||||||
val `var`: Int
|
val `var`: Int
|
||||||
val `fun`: Int
|
val `fun`: Int
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// ERROR: Unresolved reference: `as`
|
// ERROR: Unresolved reference: `as`
|
||||||
package test
|
package test
|
||||||
|
|
||||||
import `as`.`type`.`val`.`var`.`fun`.`is`.`in`.`object`.`when`.`trait`.`This`
|
import `as`.type.`val`.`var`.`fun`.`is`.`in`.`object`.`when`.`trait`.`This`
|
||||||
|
|
||||||
class Test
|
class Test
|
||||||
Reference in New Issue
Block a user