Fix warnings in generator modules
This commit is contained in:
@@ -35,7 +35,8 @@ fun main(args: Array<String>) {
|
||||
ComparableOps
|
||||
)
|
||||
|
||||
COPYRIGHT_NOTICE = readCopyrightNoticeFromProfile { Thread.currentThread().contextClassLoader.getResourceAsStream("apache.xml").reader() }
|
||||
COPYRIGHT_NOTICE =
|
||||
readCopyrightNoticeFromProfile { Thread.currentThread().contextClassLoader.getResourceAsStream("apache.xml")!!.reader() }
|
||||
|
||||
val targetBaseDirs = mutableMapOf<KotlinTarget, File>()
|
||||
|
||||
@@ -62,7 +63,7 @@ fun main(args: Array<String>) {
|
||||
val platformSuffix = when (val platform = target.platform) {
|
||||
Platform.Common -> ""
|
||||
Platform.Native -> if (target.backend == Backend.Wasm) "Wasm" else "Native"
|
||||
else -> platform.name.toLowerCase().capitalize()
|
||||
else -> platform.name.lowercase().capitalize()
|
||||
}
|
||||
targetDir.resolve("_${source.name.capitalize()}$platformSuffix.kt")
|
||||
}
|
||||
@@ -71,5 +72,5 @@ fun main(args: Array<String>) {
|
||||
fun File.resolveExistingDir(subpath: String) = resolve(subpath).also { it.requireExistingDir() }
|
||||
|
||||
fun File.requireExistingDir() {
|
||||
require(isDirectory) { "Directory $this doesn't exist"}
|
||||
require(isDirectory) { "Directory $this doesn't exist" }
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ internal abstract class OneToManyMappingsBuilder(bmpUnicodeDataLines: List<Unico
|
||||
|
||||
val charCode = line.char.hexToInt()
|
||||
|
||||
check(charCode <= Char.MAX_VALUE.toInt()) { "Handle special casing for the supplementary code point: $line" }
|
||||
check(charCode <= Char.MAX_VALUE.code) { "Handle special casing for the supplementary code point: $line" }
|
||||
|
||||
val mapping = mapping(charCode, line) ?: return
|
||||
|
||||
@@ -55,4 +55,4 @@ internal abstract class OneToManyMappingsBuilder(bmpUnicodeDataLines: List<Unico
|
||||
|
||||
abstract fun SpecialCasingLine.mapping(): List<String>?
|
||||
abstract fun UnicodeDataLine.mapping(): String
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ internal abstract class MappingsBuilder {
|
||||
val equivalent = mappingEquivalent(line)?.hexToInt() ?: return
|
||||
val mapping = equivalent - charCode
|
||||
|
||||
check((charCode > Char.MAX_VALUE.toInt()) == (equivalent > Char.MAX_VALUE.toInt())) { "Handle when equivalent mapping is out of BMP." }
|
||||
check((charCode > Char.MAX_VALUE.code) == (equivalent > Char.MAX_VALUE.code)) { "Handle when equivalent mapping is out of BMP." }
|
||||
|
||||
if (patterns.isEmpty()) {
|
||||
patterns.add(createPattern(charCode, line.categoryCode, mapping))
|
||||
@@ -69,4 +69,4 @@ internal abstract class MappingsBuilder {
|
||||
private fun createPattern(charCode: Int, categoryCode: String, mapping: Int): MappingPattern {
|
||||
return EqualDistanceMappingPattern.from(charCode, categoryCode, mapping)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ private fun periodPatternCategory(categoryIds: Array<String>): Int {
|
||||
return pattern
|
||||
}
|
||||
|
||||
private fun gapPatternCategory(start: Int, end: Int, gaps: List<GapRangePattern.Companion.Gap>): Int {
|
||||
private fun gapPatternCategory(start: Int, @Suppress("UNUSED_PARAMETER") end: Int, gaps: List<GapRangePattern.Companion.Gap>): Int {
|
||||
var pattern = 0
|
||||
var shift = 2
|
||||
for (i in gaps.indices) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
@@ -680,7 +680,7 @@ object ArrayOps : TemplateGroupBase() {
|
||||
if (primitive == null)
|
||||
"return this.asDynamic().concat(arrayOf(element))"
|
||||
else
|
||||
"return plus(${primitive.name.toLowerCase()}ArrayOf(element))"
|
||||
"return plus(${primitive.name.lowercase()}ArrayOf(element))"
|
||||
}
|
||||
}
|
||||
on(Platform.Native) {
|
||||
@@ -946,7 +946,7 @@ object ArrayOps : TemplateGroupBase() {
|
||||
val f_copyOfRangeJvmImpl = fn("copyOfRangeImpl(fromIndex: Int, toIndex: Int)") {
|
||||
include(InvariantArraysOfObjects, ArraysOfPrimitives)
|
||||
platforms(Platform.JVM)
|
||||
} builderWith { primitive ->
|
||||
} builderWith { _ ->
|
||||
since("1.3")
|
||||
visibility("internal")
|
||||
annotation("@PublishedApi")
|
||||
|
||||
@@ -409,6 +409,7 @@ object Mapping : TemplateGroupBase() {
|
||||
when (containerFamily) {
|
||||
Iterables -> include(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences)
|
||||
Sequences -> include(Sequences, Iterables, ArraysOfObjects)
|
||||
else -> {}
|
||||
}
|
||||
} builder {
|
||||
inlineOnly()
|
||||
@@ -447,6 +448,7 @@ object Mapping : TemplateGroupBase() {
|
||||
when (containerFamily) {
|
||||
Iterables -> include(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned, CharSequences)
|
||||
Sequences -> include(Sequences, Iterables, ArraysOfObjects)
|
||||
else -> {}
|
||||
}
|
||||
} builder {
|
||||
inlineOnly()
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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 templates
|
||||
|
||||
fun String.capitalize(): String =
|
||||
replaceFirstChar(Char::uppercaseChar)
|
||||
|
||||
fun String.decapitalize(): String =
|
||||
replaceFirstChar(Char::lowercaseChar)
|
||||
@@ -361,6 +361,7 @@ class MemberBuilder(
|
||||
when (inline) {
|
||||
Inline.Only -> builder.append("@kotlin.internal.InlineOnly").append('\n')
|
||||
Inline.YesSuppressWarning -> suppressions.add("NOTHING_TO_INLINE")
|
||||
else -> {}
|
||||
}
|
||||
|
||||
if (suppressions.isNotEmpty()) {
|
||||
|
||||
@@ -213,7 +213,7 @@ class PairPrimitiveMemberDefinition : MemberTemplateDefinition<Pair<PrimitiveTyp
|
||||
}
|
||||
|
||||
init {
|
||||
builderWith { (p1, p2) -> primitive = p1 }
|
||||
builderWith { (p1, _) -> primitive = p1 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,40 +75,41 @@ fun List<MemberBuilder>.writeTo(file: File, targetedSource: TargetedSourceFile)
|
||||
println("Generating file: $file")
|
||||
file.parentFile.mkdirs()
|
||||
FileWriter(file).use { writer ->
|
||||
writer.appendln(COPYRIGHT_NOTICE)
|
||||
writer.appendLine(COPYRIGHT_NOTICE)
|
||||
|
||||
when (target.platform) {
|
||||
Platform.Common, Platform.JVM -> {
|
||||
if (sourceFile.multifile) {
|
||||
writer.appendln("@file:kotlin.jvm.JvmMultifileClass")
|
||||
writer.appendLine("@file:kotlin.jvm.JvmMultifileClass")
|
||||
}
|
||||
|
||||
writer.appendln("@file:kotlin.jvm.JvmName(\"${sourceFile.jvmClassName}\")")
|
||||
writer.appendLine("@file:kotlin.jvm.JvmName(\"${sourceFile.jvmClassName}\")")
|
||||
sourceFile.jvmPackageName?.let {
|
||||
writer.appendln("@file:kotlin.jvm.JvmPackageName(\"$it\")")
|
||||
writer.appendLine("@file:kotlin.jvm.JvmPackageName(\"$it\")")
|
||||
}
|
||||
writer.appendln()
|
||||
writer.appendLine()
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
writer.append("package ${sourceFile.packageName ?: "kotlin"}\n\n")
|
||||
writer.append("${autoGeneratedWarning("GenerateStandardLib.kt")}\n\n")
|
||||
if (target.platform == Platform.JS) {
|
||||
writer.appendln("import kotlin.js.*")
|
||||
writer.appendLine("import kotlin.js.*")
|
||||
if (sourceFile == SourceFile.Arrays) {
|
||||
writer.appendln("import primitiveArrayConcat")
|
||||
writer.appendln("import withType")
|
||||
writer.appendLine("import primitiveArrayConcat")
|
||||
writer.appendLine("import withType")
|
||||
}
|
||||
}
|
||||
if (target.platform == Platform.Common) {
|
||||
writer.appendln("import kotlin.random.*")
|
||||
writer.appendLine("import kotlin.random.*")
|
||||
}
|
||||
if (sourceFile.packageName == "kotlin.collections") {
|
||||
writer.appendln("import kotlin.ranges.contains")
|
||||
writer.appendln("import kotlin.ranges.reversed")
|
||||
writer.appendLine("import kotlin.ranges.contains")
|
||||
writer.appendLine("import kotlin.ranges.reversed")
|
||||
}
|
||||
|
||||
writer.appendln()
|
||||
writer.appendLine()
|
||||
|
||||
for (f in this) {
|
||||
f.build(writer)
|
||||
|
||||
Reference in New Issue
Block a user