nextflow-io / language-server

The Nextflow language server
Apache License 2.0
9 stars 0 forks source link

Reformatted function loses types and `throw` keyword #42

Closed Midnighter closed 3 weeks ago

Midnighter commented 3 weeks ago

My function

String get_simple_name(Path filename) {
    // If the input has a gzip compression, strip the file extension.
    if (is_compressed(filename)) {
        filename = java.nio.file.Paths.get(filename.baseName)
    }
    // Strip an expected sequencing file extension.
    if (is_sequence(filename)) {
        filename = java.nio.file.Paths.get(filename.baseName)
    } else {
        throw new Exception("Unrecognized sequencing file extension '${filename.extension}'.")
    }
    return filename.name
}

was turned into

def get_simple_name(filename) {
    // If the input has a gzip compression, strip the file extension.
    if (is_compressed(filename)) {
        filename = java.nio.file.Paths.get(filename.baseName)
    }
    // Strip an expected sequencing file extension.
    if (is_sequence(filename)) {
        filename = java.nio.file.Paths.get(filename.baseName)
    }
    else {
new Exception("Unrecognized sequencing file extension '${filename.extension}'.")    }
    return filename.name
}
bentsherman commented 3 weeks ago

Thanks for reporting the throw statement issue.

The types being removed is intentional because Groovy-style type annotations are not supported anymore. We will re-add type annotations later but likely with a different syntax. For now I suggest you use a doc comment:

/**
 * Get the simple name of a file.
 *
 * @param filename: Path
 * @return String
 */
def get_simple_name(filename) {
  // ...
}