Skip to content

[Bug] Newline after @throws breaks parsing of exception type #4500

@juliamcclellan

Description

@juliamcclellan

What is happening? What should have happened instead?

ktfmt sometimes moves the exception type for a @throws tag onto the next line if the exception type is very long. When this happens the parsed Throws doc tag has an empty string name, a null exceptionAddress, and the child P merges the text of the exception type and description.

Reproducer

/**
 * @throws
 *   this.is.a.very.long.pkg.name.IllegalArgumentException
 *   for a bad argument
 * @throws IllegalStateException for a bad state
 */
fun foo() = Unit

This is the documentation on the DFunction:

Description(root=CustomDocTag(children=[], params={}, name=MARKDOWN_FILE))
Throws(root=CustomDocTag(children=[P(children=[Text(body=this.is.a.very.long.pkg.name.IllegalArgumentException for a bad argument, children=[], params={})], params={})], params={}, name=MARKDOWN_FILE), name=, exceptionAddress=null)
Throws(root=CustomDocTag(children=[P(children=[Text(body=for a bad state, children=[], params={})], params={})], params={}, name=MARKDOWN_FILE), name=IllegalStateException, exceptionAddress=kotlin/IllegalStateException///PointingToDeclaration/)

Dokka version

2.2.0-dev-415

Kotlin Gradle Plugin (KGP) version

No response

Android Gradle Plugin (AGP) version (if applicable)

No response

Build tool

Gradle

Project type

  • Kotlin Multiplatform (KMP)
  • Android
  • JVM
  • Other

Anything else? (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked: parserDepends on fixes inside Lexer/Parser inside Kotlin Compiler Frontendbug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions