Skip to content

Proto generation fails on Windows with trailing comments #2905

Open
grepdemos/wire
#5
@yschimke

Description

@yschimke
enum ImageState {
    IMAGE_STATE_UNSPECIFIED = 0;
    IMAGE_STATE_READONLY = 1;     /* unlocked */
    IMAGE_STATE_MUSTLOCK = 2;     /* must be locked */
    IMAGE_STATE_LOCKED = 3;       /* locked */
    IMAGE_STATE_LOCKED_EMPTY = 4; /* locked and empty */
    IMAGE_STATE_TEMPORARY = 5;    /* copied to temp file (no lock needed) */
}

fails with

Caused by: java.lang.IllegalStateException: Syntax error in C:\Users\yuri\StudioProjects\emulator-tools\emulator-proto\src\commonMain\proto/avd_service.proto:51:50: no syntax may follow trailing comment
	at com.squareup.wire.schema.internal.parser.SyntaxReader.unexpected(SyntaxReader.kt:424)
	at com.squareup.wire.schema.internal.parser.SyntaxReader.tryAppendTrailingDocumentation(SyntaxReader.kt:467)
	at com.squareup.wire.schema.internal.parser.ProtoParser.readEnumConstant(ProtoParser.kt:569)
	at com.squareup.wire.schema.internal.parser.ProtoParser.readDeclaration(ProtoParser.kt:169)
	at com.squareup.wire.schema.internal.parser.ProtoParser.readEnumElement(ProtoParser.kt:294)
	at com.squareup.wire.schema.internal.parser.ProtoParser.readDeclaration(ProtoParser.kt:148)
	at com.squareup.wire.schema.internal.parser.ProtoParser.readProtoFile(ProtoParser.kt:69)
	at com.squareup.wire.schema.internal.parser.ProtoParser$Companion.parse(ProtoParser.kt:664)
	at com.squareup.wire.schema.RootsKt.parse(Roots.kt:66)
	at com.squareup.wire.schema.internal.CommonSchemaLoader.load(CommonSchemaLoader.kt:166)
	at com.squareup.wire.schema.internal.CommonSchemaLoader.loadSourcePathFiles$wire_schema(CommonSchemaLoader.kt:120)
	at com.squareup.wire.schema.internal.CommonSchemaLoader.loadSchema(CommonSchemaLoader.kt:103)
	at com.squareup.wire.schema.SchemaLoader.loadSchema(SchemaLoader.kt:77)
	at com.squareup.wire.schema.WireRun.execute$wire_schema(WireRun.kt:248)
	at com.squareup.wire.schema.WireRun.execute(WireRun.kt:234)
	at com.squareup.wire.gradle.WireTask.generateWireFiles(WireTask.kt:178)

Check seems harsh

        // Ensure nothing follows a trailing star comment.
        while (pos < data.size) {
          val c = data[pos++]
          if (c == '\n') {
            newline()
            break
          }
          expect(c == ' ' || c == '\t') { "no syntax may follow trailing comment" }
        }

Activity

linked a pull request that will close this issue on Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Proto generation fails on Windows with trailing comments · Issue #2905 · square/wire