Capitalize/decapitalize only ASCII characters across project
Use {de,}capitalizeAsciiOnly and to{Lower,Upper}CaseAsciiOnly where
possible, and stdlib's functions with Locale.US everywhere else.
Otherwise, if the default system locale is Turkish, the capital latin
letter "I" is transformed in toLowerCase to "ı" (see
https://github.com/JetBrains/kotlin/blob/66bc142f92085047a1ca64f9a291f0496e33dd98/libraries/stdlib/jvm/test/text/StringJVMTest.kt#L119),
which for example breaks the codegen for `intArrayOf` in
KT-25400/KT-43405.
Similarly, lower case latin letter "i" is transformed to "İ".
#KT-13631 Fixed
#KT-25400 Fixed
#KT-43405 Fixed
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.kdoc.parser
|
||||
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toUpperCaseAsciiOnly
|
||||
|
||||
enum class KDocKnownTag(val isReferenceRequired: Boolean, val isSectionStart: Boolean) {
|
||||
AUTHOR(false, false),
|
||||
THROWS(true, false),
|
||||
@@ -37,7 +39,7 @@ enum class KDocKnownTag(val isReferenceRequired: Boolean, val isSectionStart: Bo
|
||||
tagName.subSequence(1, tagName.length)
|
||||
} else tagName
|
||||
try {
|
||||
return valueOf(name.toString().toUpperCase())
|
||||
return valueOf(name.toString().toUpperCaseAsciiOnly())
|
||||
} catch (ignored: IllegalArgumentException) {
|
||||
}
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@ import com.intellij.psi.impl.source.tree.LazyParseablePsiElement
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.kdoc.lexer.KDocTokens
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
|
||||
import org.jetbrains.kotlin.kdoc.psi.api.KDoc
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
|
||||
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
|
||||
class KDocImpl(buffer: CharSequence?) : LazyParseablePsiElement(KDocTokens.KDOC, buffer), KDoc {
|
||||
|
||||
@@ -37,10 +38,10 @@ class KDocImpl(buffer: CharSequence?) : LazyParseablePsiElement(KDocTokens.KDOC,
|
||||
getChildrenOfType<KDocSection>().firstOrNull { it.name == name }
|
||||
|
||||
override fun findSectionByTag(tag: KDocKnownTag): KDocSection? =
|
||||
findSectionByName(tag.name.toLowerCase())
|
||||
findSectionByName(tag.name.toLowerCaseAsciiOnly())
|
||||
|
||||
override fun findSectionByTag(tag: KDocKnownTag, subjectName: String): KDocSection? =
|
||||
getChildrenOfType<KDocSection>().firstOrNull {
|
||||
it.name == tag.name.toLowerCase() && it.getSubjectName() == subjectName
|
||||
it.name == tag.name.toLowerCaseAsciiOnly() && it.getSubjectName() == subjectName
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user