1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 03:09:51 +03:00
aports/community/ast-grep/remove-some-parsers.patch
2024-11-11 12:54:51 +00:00

238 lines
6.2 KiB
Diff

From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sat, 26 Oct 2024 18:32:34 +0200
Subject: Remove some big parsers
Remove parsers for less used languages (on Linux) that contribute most
to the size of the resulting binary. This cuts the size by half - from
~41 MiB to ~20 MiB.
ast-grep provides some support for dynamically loaded parsers, but it's
still experimental and it would require a non-trivial work to use it
for loading "built-in" parsers.
--- a/crates/language/src/parsers.rs
+++ b/crates/language/src/parsers.rs
@@ -18,7 +18,7 @@
tree_sitter_cpp::language().into()
}
pub fn language_c_sharp() -> TSLanguage {
- tree_sitter_c_sharp::language().into()
+ unimplemented!("this ast-grep was compiled without c-sharp tree-sitter parser.") // XXX-Patched
}
pub fn language_css() -> TSLanguage {
tree_sitter_css::language().into()
@@ -27,13 +27,13 @@
tree_sitter_dart::language().into()
}
pub fn language_elixir() -> TSLanguage {
- tree_sitter_elixir::language().into()
+ unimplemented!("this ast-grep was compiled without elixir tree-sitter parser.") // XXX-Patched
}
pub fn language_go() -> TSLanguage {
tree_sitter_go::language().into()
}
pub fn language_haskell() -> TSLanguage {
- tree_sitter_haskell::language().into()
+ unimplemented!("this ast-grep was compiled without haskell tree-sitter parser.") // XXX-Patched
}
pub fn language_html() -> TSLanguage {
tree_sitter_html::language().into()
@@ -48,7 +48,7 @@
tree_sitter_json::language().into()
}
pub fn language_kotlin() -> TSLanguage {
- tree_sitter_kotlin::language().into()
+ unimplemented!("this ast-grep was compiled without kotlin tree-sitter parser.") // XXX-Patched
}
pub fn language_lua() -> TSLanguage {
tree_sitter_lua::language().into()
@@ -66,13 +66,13 @@
tree_sitter_rust::language().into()
}
pub fn language_scala() -> TSLanguage {
- tree_sitter_scala::language().into()
+ unimplemented!("this ast-grep was compiled without scala tree-sitter parser.") // XXX-Patched
}
pub fn language_sql() -> TSLanguage {
tree_sitter_sequel::language().into()
}
pub fn language_swift() -> TSLanguage {
- tree_sitter_swift::language().into()
+ unimplemented!("this ast-grep was compiled without swift tree-sitter parser.") // XXX-Patched
}
pub fn language_tsx() -> TSLanguage {
tree_sitter_typescript::language_tsx().into()
--- a/crates/language/Cargo.toml
+++ b/crates/language/Cargo.toml
@@ -46,25 +46,25 @@
"tree-sitter-bash",
"tree-sitter-c",
"tree-sitter-cpp",
- "tree-sitter-c-sharp",
+ # "tree-sitter-c-sharp", XXX-Patched
"tree-sitter-css",
"tree-sitter-dart",
- "tree-sitter-elixir",
+ # "tree-sitter-elixir", XXX-Patched
"tree-sitter-go",
- "tree-sitter-haskell",
+ # "tree-sitter-haskell", XXX-Patched
"tree-sitter-html",
"tree-sitter-java",
"tree-sitter-javascript",
"tree-sitter-json",
- "tree-sitter-kotlin",
+ # "tree-sitter-kotlin", XXX-Patched
"tree-sitter-lua",
"tree-sitter-php",
"tree-sitter-python",
"tree-sitter-ruby",
"tree-sitter-rust",
- "tree-sitter-scala",
+ # "tree-sitter-scala", XXX-Patched
"tree-sitter-sequel",
- "tree-sitter-swift",
+ # "tree-sitter-swift", XXX-Patched
"tree-sitter-typescript",
"tree-sitter-yaml",
]
--- a/crates/language/src/csharp.rs
+++ b/crates/language/src/csharp.rs
@@ -9,6 +9,7 @@
}
#[test]
+#[ignore]
fn test_c_sharp_pattern() {
let target = "if (table == null) ThrowHelper.ThrowArgumentNullException(nameof(table));";
test_match("int $A = 0;", "int nint = 0;");
@@ -22,6 +23,7 @@
}
#[test]
+#[ignore]
fn test_c_sharp_replace() -> Result<(), TSParseError> {
let ret = test_replace("int @int = 0;", "int $A = 0", "bool @bool = true")?;
assert_eq!(ret, "bool @bool = true;");
--- a/crates/language/src/elixir.rs
+++ b/crates/language/src/elixir.rs
@@ -14,6 +14,7 @@
}
#[test]
+#[ignore]
fn test_elixir_str() {
test_match("IO.puts(\"$A\")", "IO.puts(\"123\")");
test_match("IO.puts($A)", "IO.puts(123)");
@@ -22,6 +23,7 @@
}
#[test]
+#[ignore]
fn test_elixir_pattern() {
test_match("$A", ":ok");
test_match("$A != nil", "a != nil");
@@ -45,6 +47,7 @@
}
#[test]
+#[ignore]
fn test_elixir_replace() -> Result<(), TSParseError> {
let ret = test_replace(
"Stream.map([1, 2, 3], fn x -> x * 2 end)",
--- a/crates/language/src/haskell.rs
+++ b/crates/language/src/haskell.rs
@@ -14,6 +14,7 @@
}
#[test]
+#[ignore]
fn test_haskell_str() {
test_match("return $A", "return 3");
test_match(r#""abc""#, r#""abc""#);
@@ -31,6 +32,7 @@
}
#[test]
+#[ignore]
fn test_haskell_replace() -> Result<(), TSParseError> {
let ret = test_replace(
r#"
--- a/crates/language/src/kotlin.rs
+++ b/crates/language/src/kotlin.rs
@@ -14,6 +14,7 @@
}
#[test]
+#[ignore]
fn test_kotlin_str() {
test_match("println($A)", "println(123)");
test_match("println('123')", "println('123')");
@@ -22,6 +23,7 @@
}
#[test]
+#[ignore]
fn test_kotlin_pattern() {
test_match("$A = 0", "a = 0");
test_match(
@@ -39,6 +41,7 @@
}
#[test]
+#[ignore]
fn test_kotlin_replace() -> Result<(), TSParseError> {
let ret = test_replace(
r#"
--- a/crates/language/src/swift.rs
+++ b/crates/language/src/swift.rs
@@ -14,6 +14,7 @@
}
#[test]
+#[ignore]
fn test_swift_str() {
test_match("println(\"123\")", "println(\"123\")");
test_non_match("println(\"123\")", "println(\"456\")");
@@ -21,6 +22,7 @@
}
#[test]
+#[ignore]
fn test_swift_pattern() {
test_match("fun($A)", "fun(123)");
test_match("foo($$$)", "foo(1, 2, 3)");
@@ -50,6 +52,7 @@
}"#;
#[test]
+#[ignore]
fn test_swift_replace() -> Result<(), TSParseError> {
let ret = test_replace(
SOURCE,
--- a/crates/language/src/scala.rs
+++ b/crates/language/src/scala.rs
@@ -18,6 +18,7 @@
}
#[test]
+#[ignore]
fn test_scala_str() {
test_match("println($A)", "println(123)");
test_match("println(\"123\")", "println(\"123\")");
@@ -26,6 +27,7 @@
}
#[test]
+#[ignore]
fn test_scala_pattern() {
test_match("val $A = 0", "val a = 0");
test_match("foo($VAR)", "foo(bar)");
@@ -44,6 +46,7 @@
}
#[test]
+#[ignore]
fn test_scala_replace() -> Result<(), TSParseError> {
let ret = test_replace(
"foo.filter(_ == bar)",