feat: Add Kotlin support #56
17 changed files with 130 additions and 2 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -135,9 +135,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.31"
|
||||
version = "1.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f"
|
||||
checksum = "c8293772165d9345bdaaa39b45b2109591e63fe5e6fbc23c6ff930a048aa310b"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
@ -642,6 +642,7 @@ dependencies = [
|
|||
"tree-sitter-java",
|
||||
"tree-sitter-javascript",
|
||||
"tree-sitter-json",
|
||||
"tree-sitter-kotlin-ng",
|
||||
"tree-sitter-lua",
|
||||
"tree-sitter-php",
|
||||
"tree-sitter-python",
|
||||
|
@ -1118,6 +1119,16 @@ dependencies = [
|
|||
"tree-sitter-language",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-kotlin-ng"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e800ebbda938acfbf224f4d2c34947a31994b1295ee6e819b65226c7b51b4450"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter-language",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-language"
|
||||
version = "0.1.2"
|
||||
|
|
|
@ -22,6 +22,7 @@ tree-sitter-json = "0.23"
|
|||
tree-sitter-yaml = "0.6.1"
|
||||
tree-sitter-toml-ng = "0.6.0"
|
||||
tree-sitter-java = "0.23"
|
||||
tree-sitter-kotlin-ng = "1.1.0"
|
||||
tree-sitter-html = "0.23"
|
||||
tree-sitter-javascript = "0.23"
|
||||
tree-sitter-cpp = "0.23"
|
||||
|
|
|
@ -14,6 +14,7 @@ Mergiraf currently supports the following programming languages:
|
|||
* PHP (*.php)
|
||||
* Solidity (*.sol)
|
||||
* Lua (*.lua)
|
||||
* Kotlin (*.kt)
|
||||
|
||||
and the following declarative file formats:
|
||||
* JSON (*.json)
|
||||
|
|
|
@ -61,6 +61,7 @@ Then, you also need to specify for which sorts of files this merge driver should
|
|||
*.php merge=mergiraf
|
||||
*.sol merge=mergiraf
|
||||
*.lua merge=mergiraf
|
||||
*.kt merge=mergiraf
|
||||
```
|
||||
|
||||
Or run:
|
||||
|
|
3
examples/kotlin/working/class_body/Base.kt
Normal file
3
examples/kotlin/working/class_body/Base.kt
Normal file
|
@ -0,0 +1,3 @@
|
|||
object MergeAlgorithm {
|
||||
var diff3 = false
|
||||
}
|
6
examples/kotlin/working/class_body/Expected.kt
Normal file
6
examples/kotlin/working/class_body/Expected.kt
Normal file
|
@ -0,0 +1,6 @@
|
|||
object MergeAlgorithm {
|
||||
|
||||
var diff3 = false
|
||||
var verbose = true
|
||||
|
||||
var timeout = 1000
|
||||
}
|
4
examples/kotlin/working/class_body/Left.kt
Normal file
4
examples/kotlin/working/class_body/Left.kt
Normal file
|
@ -0,0 +1,4 @@
|
|||
object MergeAlgorithm {
|
||||
var diff3 = false
|
||||
var verbose = true
|
||||
}
|
4
examples/kotlin/working/class_body/Right.kt
Normal file
4
examples/kotlin/working/class_body/Right.kt
Normal file
|
@ -0,0 +1,4 @@
|
|||
object MergeAlgorithm {
|
||||
var diff3 = false
|
||||
var timeout = 1000
|
||||
}
|
5
examples/kotlin/working/function_modifiers/Base.kt
Normal file
5
examples/kotlin/working/function_modifiers/Base.kt
Normal file
|
@ -0,0 +1,5 @@
|
|||
object Recipe {
|
||||
override fun demonstrate() {
|
||||
LOGGER.info { "Demo time!" }
|
||||
}
|
||||
}
|
6
examples/kotlin/working/function_modifiers/Expected.kt
Normal file
6
examples/kotlin/working/function_modifiers/Expected.kt
Normal file
|
@ -0,0 +1,6 @@
|
|||
object Recipe {
|
||||
override final
|
||||
protected fun demonstrate() {
|
||||
LOGGER.info { "Demo time!" }
|
||||
}
|
||||
}
|
5
examples/kotlin/working/function_modifiers/Left.kt
Normal file
5
examples/kotlin/working/function_modifiers/Left.kt
Normal file
|
@ -0,0 +1,5 @@
|
|||
object Recipe {
|
||||
override final fun demonstrate() {
|
||||
LOGGER.info { "Demo time!" }
|
||||
}
|
||||
}
|
5
examples/kotlin/working/function_modifiers/Right.kt
Normal file
5
examples/kotlin/working/function_modifiers/Right.kt
Normal file
|
@ -0,0 +1,5 @@
|
|||
object Recipe {
|
||||
override protected fun demonstrate() {
|
||||
LOGGER.info { "Demo time!" }
|
||||
}
|
||||
}
|
6
examples/kotlin/working/imports/Base.kt
Normal file
6
examples/kotlin/working/imports/Base.kt
Normal file
|
@ -0,0 +1,6 @@
|
|||
package com.example.foo
|
||||
|
||||
import com.example.foo.core.Config
|
||||
|
||||
object Obj {
|
||||
}
|
9
examples/kotlin/working/imports/Expected.kt
Normal file
9
examples/kotlin/working/imports/Expected.kt
Normal file
|
@ -0,0 +1,9 @@
|
|||
package com.example.foo
|
||||
|
||||
import com.example.foo.core.Config
|
||||
import com.example.foo.core.Logger
|
||||
import com.example.foo.util.Helper
|
||||
import com.example.foo.util.Legacy
|
||||
|
||||
object Obj {
|
||||
}
|
7
examples/kotlin/working/imports/Left.kt
Normal file
7
examples/kotlin/working/imports/Left.kt
Normal file
|
@ -0,0 +1,7 @@
|
|||
package com.example.foo
|
||||
|
||||
import com.example.foo.core.Config
|
||||
import com.example.foo.core.Logger
|
||||
|
||||
object Obj {
|
||||
}
|
8
examples/kotlin/working/imports/Right.kt
Normal file
8
examples/kotlin/working/imports/Right.kt
Normal file
|
@ -0,0 +1,8 @@
|
|||
package com.example.foo
|
||||
|
||||
import com.example.foo.core.Config
|
||||
import com.example.foo.util.Helper
|
||||
import com.example.foo.util.Legacy
|
||||
|
||||
object Obj {
|
||||
}
|
|
@ -102,6 +102,52 @@ pub static SUPPORTED_LANGUAGES: LazyLock<Vec<LangProfile>> = LazyLock::new(|| {
|
|||
signature("element_value_pair", vec![vec![Field("key")]]),
|
||||
],
|
||||
},
|
||||
LangProfile {
|
||||
name: "Kotlin",
|
||||
extensions: vec![".kt"],
|
||||
language: tree_sitter_kotlin_ng::LANGUAGE.into(),
|
||||
atomic_nodes: vec![],
|
||||
commutative_parents: vec![
|
||||
// top-level node, for imports and class declarations
|
||||
CommutativeParent::without_delimiters("source_file", "\n\n")
|
||||
.restricted_to_groups(&[&["import"], &["function_declaration"]]),
|
||||
CommutativeParent::new("class_body", " {\n", "\n\n", "\n}\n")
|
||||
.restricted_to_groups(&[&["property_declaration"], &["function_declaration"]]),
|
||||
CommutativeParent::without_delimiters("modifiers", "\n").restricted_to_groups(&[
|
||||
&["annotation"],
|
||||
&[
|
||||
"visibility_modifier",
|
||||
"inheritance_modifier",
|
||||
"member_modifier",
|
||||
],
|
||||
]),
|
||||
CommutativeParent::without_delimiters("class_declaration", ", ")
|
||||
.restricted_to_groups(&[&["delegation_specifier"]]),
|
||||
],
|
||||
signatures: vec![
|
||||
signature("import", vec![vec![]]),
|
||||
signature(
|
||||
"function_declaration",
|
||||
vec![
|
||||
vec![Field("name")],
|
||||
vec![
|
||||
ChildType("function_value_parameters"),
|
||||
ChildType("parameter"),
|
||||
ChildType("user_type"),
|
||||
],
|
||||
],
|
||||
),
|
||||
signature("delegation_specifier", vec![vec![]]),
|
||||
signature("public", vec![vec![]]),
|
||||
signature("protected", vec![vec![]]),
|
||||
signature("private", vec![vec![]]),
|
||||
signature("internal", vec![vec![]]),
|
||||
signature("final", vec![vec![]]),
|
||||
signature("open", vec![vec![]]),
|
||||
signature("abstract", vec![vec![]]),
|
||||
signature("override", vec![vec![]]),
|
||||
],
|
||||
},
|
||||
LangProfile {
|
||||
name: "Rust",
|
||||
extensions: vec![".rs"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue
very meta:)