Cleanup in modules: j2k, jps, ant and generators.

This commit is contained in:
Ilya Gorbunov
2015-12-29 03:42:55 +03:00
parent da4b1ae0fb
commit fcfb063eca
16 changed files with 60 additions and 60 deletions
@@ -25,7 +25,7 @@ class GenerateArrays(out: PrintWriter) : BuiltInsSourceGenerator(out) {
override fun generateBody() {
for (kind in PrimitiveType.values()) {
val typeLower = kind.name().toLowerCase()
val typeLower = kind.name.toLowerCase()
val s = kind.capitalized
val defaultValue = when(kind) { PrimitiveType.BOOLEAN -> "false"; else -> "zero" }
out.println("/**")
@@ -29,7 +29,7 @@ enum class PrimitiveType {
DOUBLE,
BOOLEAN;
val capitalized: String get() = name().toLowerCase().capitalize()
val capitalized: String get() = name.toLowerCase().capitalize()
companion object {
val exceptBoolean = PrimitiveType.values().filterNot { it == BOOLEAN }
val onlyNumeric = PrimitiveType.values().filterNot { it == BOOLEAN || it == CHAR }
@@ -45,7 +45,7 @@ enum class ProgressionKind {
FLOAT,
DOUBLE;
val capitalized: String get() = name().toLowerCase().capitalize()
val capitalized: String get() = name.toLowerCase().capitalize()
}
fun progressionIncrementType(kind: ProgressionKind) = when (kind) {
@@ -133,7 +133,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) {
private fun generateDoc(kind: PrimitiveType) {
out.println("/**")
out.println(" * Represents a ${typeDescriptions[kind]}.")
out.println(" * On the JVM, non-nullable values of this type are represented as values of the primitive type `${kind.name().toLowerCase()}`.")
out.println(" * On the JVM, non-nullable values of this type are represented as values of the primitive type `${kind.name.toLowerCase()}`.")
out.println(" */")
}
@@ -63,7 +63,7 @@ fun generate(): String {
for (function in functions) {
val parametersTypes = function.getParametersTypes()
when (parametersTypes.size()) {
when (parametersTypes.size) {
1 -> unaryOperationsMap.add(Triple(function.getName().asString(), parametersTypes, function is FunctionDescriptor))
2 -> binaryOperationsMap.add(function.getName().asString() to parametersTypes)
else -> throw IllegalStateException("Couldn't add following method from builtins to operations map: ${function.getName()} in class ${descriptor.getName()}")
@@ -34,7 +34,7 @@ public class ProtoBufConsistencyTest : TestCase() {
val classFqName = protoPath.packageName + "." + protoPath.debugClassName
val klass = javaClass.getClassLoader().loadClass(classFqName) ?: error("Class not found: $classFqName")
for (field in klass.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == javaClass<GeneratedExtension<*, *>>()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == GeneratedExtension::class.java) {
// The only place where type information for an extension is stored is the field's declared generic type.
// The message type which this extension extends is the first argument to GeneratedExtension<*, *>
val containingType = (field.getGenericType() as ParameterizedType).getActualTypeArguments().first() as Class<*>
@@ -45,8 +45,8 @@ public class ProtoBufConsistencyTest : TestCase() {
}
}
for ((key, descriptors) in extensions.asMap().entrySet()) {
if (descriptors.size() > 1) {
for ((key, descriptors) in extensions.asMap().entries) {
if (descriptors.size > 1) {
fail("""
Several extensions to the same message type with the same index were found.
This will cause different hard-to-debug problems if these extensions are used at the same time during (de-)serialization of the message.