Flatten nullable types in Kotlin

Workaround for #589 and #411
significant_whitespace
Wilfred Hughes 2023-10-26 08:55:43 +07:00
parent 8400000b3b
commit 778a6bee9a
5 changed files with 17 additions and 3 deletions

@ -4,7 +4,8 @@
Added support for SCSS.
Updated the Kotlin parser.
Updated the Kotlin parser and improved handling of Kotlin nullable
types.
### Command Line Interface

@ -1,5 +1,5 @@
sample_files/Session_before.kt sample_files/Session_after.kt
7b0c38d1fcc9b4e20c5fcf0070cb1620 -
80c53658ee849d38f397863803677a02 -
sample_files/ada_before.adb sample_files/ada_after.adb
626e22f4f256ae591ece3f280176b3f7 -
@ -151,6 +151,9 @@ sample_files/newick_before.nwk sample_files/newick_after.nwk
sample_files/nix_before.nix sample_files/nix_after.nix
e00b95a4cf3fa3edf994155d8656063f -
sample_files/nullable_before.kt sample_files/nullable_after.kt
66da628a2c20e18059b8669aaa14a163 -
sample_files/ocaml_before.ml sample_files/ocaml_after.ml
2113c6c7959b8099f678d13953f7f44a -

@ -0,0 +1,3 @@
class Foo {
val str: String
}

@ -0,0 +1,3 @@
class Foo {
val str: String?
}

@ -615,7 +615,11 @@ pub fn from_language(language: guess::Language) -> TreeSitterConfig {
let language = unsafe { tree_sitter_kotlin() };
TreeSitterConfig {
language,
atom_nodes: vec!["line_string_literal", "character_literal"]
// Flattening nullable type means we can't diff the
// structure of complex types within, but it beats
// ignoring nullable changes.
// https://github.com/Wilfred/difftastic/issues/411
atom_nodes: vec!["line_string_literal", "character_literal", "nullable_type"]
.into_iter()
.collect(),
delimiter_tokens: vec![("(", ")"), ("{", "}"), ("[", "]"), ("<", ">")]