mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generate FirefoxProtocolReader with new kotlin generator
This commit is contained in:
@@ -77,8 +77,7 @@ class TextOutput(val out: StringBuilder) {
|
||||
}
|
||||
|
||||
fun openBlock(): TextOutput {
|
||||
openBlock(true)
|
||||
return this
|
||||
return openBlock(true)
|
||||
}
|
||||
|
||||
inline fun block(addNewLine: Boolean = true, writer: () -> Unit): TextOutput {
|
||||
@@ -88,16 +87,18 @@ class TextOutput(val out: StringBuilder) {
|
||||
return this
|
||||
}
|
||||
|
||||
fun openBlock(addNewLine: Boolean) {
|
||||
fun openBlock(addNewLine: Boolean): TextOutput {
|
||||
space().append('{')
|
||||
if (addNewLine) {
|
||||
newLine()
|
||||
}
|
||||
indentIn()
|
||||
return this
|
||||
}
|
||||
|
||||
fun closeBlock() {
|
||||
fun closeBlock(): TextOutput {
|
||||
indentOut().newLine().append('}')
|
||||
return this
|
||||
}
|
||||
|
||||
fun comma() = append(',').space()
|
||||
|
||||
@@ -215,13 +215,13 @@ internal class TypeWriter<T>(val typeClass: Class<T>, jsonSuperClass: TypeRef<*>
|
||||
fieldLoader.valueReader.writeReadCode(classScope, false, out)
|
||||
|
||||
if (primitiveValueName != null) {
|
||||
out.newLine().append("else").openBlock()
|
||||
out.closeBlock().newLine().append("else").block {
|
||||
assignField(out, "${primitiveValueName}Type")
|
||||
out.append("reader.peek()").newLine()
|
||||
|
||||
assignField(out, "${primitiveValueName}Type")
|
||||
out.append("reader.peek()").newLine()
|
||||
|
||||
assignField(out, primitiveValueName)
|
||||
out + "reader.nextString(true)"
|
||||
assignField(out, primitiveValueName)
|
||||
out + "reader.nextString(true)"
|
||||
}
|
||||
}
|
||||
|
||||
if (stopIfAllFieldsWereRead && !isTracedStop) {
|
||||
|
||||
@@ -18,7 +18,11 @@ val JSON_READER_PARAMETER_DEF = "$READER_NAME: $JSON_READER_CLASS_NAME"
|
||||
internal fun writeJavaTypeName(arg: Type, out: TextOutput) {
|
||||
if (arg is Class<*>) {
|
||||
val name = arg.canonicalName
|
||||
out.append(if (name == "java.util.List") "List" else name)
|
||||
out.append(
|
||||
if (name == "java.util.List") "List"
|
||||
else if (name == "java.lang.String") "String?"
|
||||
else name
|
||||
)
|
||||
}
|
||||
else if (arg is ParameterizedType) {
|
||||
writeJavaTypeName(arg.rawType, out)
|
||||
|
||||
Reference in New Issue
Block a user