diff --git a/WORKSPACE b/WORKSPACE index 199c486e87bb..5c3f1fbb7f48 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -347,6 +347,7 @@ crates_repository( "//docker-images/syntax-highlighter:crates/scip-syntax/Cargo.toml", "//docker-images/syntax-highlighter:crates/scip-treesitter/Cargo.toml", "//docker-images/syntax-highlighter:crates/scip-treesitter-languages/Cargo.toml", + "//docker-images/syntax-highlighter:crates/scip-treesitter-cli/Cargo.toml", "//docker-images/syntax-highlighter:crates/sg-syntax/Cargo.toml", ], ) @@ -364,7 +365,7 @@ load("@rules_oci//oci:dependencies.bzl", "rules_oci_dependencies") rules_oci_dependencies() -load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "LATEST_ZOT_VERSION", "oci_register_toolchains") +load("@rules_oci//oci:repositories.bzl", "LATEST_CRANE_VERSION", "oci_register_toolchains") oci_register_toolchains( name = "oci", diff --git a/docker-images/syntax-highlighter/Cargo.Bazel.lock b/docker-images/syntax-highlighter/Cargo.Bazel.lock index 60a10a8f9f57..7ad584782e2b 100644 --- a/docker-images/syntax-highlighter/Cargo.Bazel.lock +++ b/docker-images/syntax-highlighter/Cargo.Bazel.lock @@ -1,5 +1,5 @@ { - "checksum": "0a89d8e5a2606956436c92f8ef0f3b55565d77ab6f366e9ee8da15a60954f38f", + "checksum": "a30200fddef89273f32721d5e5e6b1e44a4d56104443ffb9e2bc722f6ca165ab", "crates": { "addr2line 0.20.0": { "name": "addr2line", @@ -457,6 +457,69 @@ }, "license": "MIT OR Apache-2.0" }, + "assert_cmd 2.0.12": { + "name": "assert_cmd", + "version": "2.0.12", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/assert_cmd/2.0.12/download", + "sha256": "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" + } + }, + "targets": [ + { + "Library": { + "crate_name": "assert_cmd", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "assert_cmd", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "anstyle 1.0.1", + "target": "anstyle" + }, + { + "id": "bstr 1.6.0", + "target": "bstr" + }, + { + "id": "doc-comment 0.3.3", + "target": "doc_comment" + }, + { + "id": "predicates 3.0.4", + "target": "predicates" + }, + { + "id": "predicates-core 1.0.6", + "target": "predicates_core" + }, + { + "id": "predicates-tree 1.0.9", + "target": "predicates_tree" + }, + { + "id": "wait-timeout 0.2.0", + "target": "wait_timeout" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "2.0.12" + }, + "license": "MIT OR Apache-2.0" + }, "async-stream 0.3.5": { "name": "async-stream", "version": "0.3.5", @@ -1110,6 +1173,58 @@ }, "license": "MIT" }, + "bstr 1.6.0": { + "name": "bstr", + "version": "1.6.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/bstr/1.6.0/download", + "sha256": "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" + } + }, + "targets": [ + { + "Library": { + "crate_name": "bstr", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "bstr", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "alloc", + "default", + "std", + "unicode" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "memchr 2.5.0", + "target": "memchr" + }, + { + "id": "regex-automata 0.3.6", + "target": "regex_automata" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "1.6.0" + }, + "license": "MIT OR Apache-2.0" + }, "bumpalo 3.13.0": { "name": "bumpalo", "version": "3.13.0", @@ -1502,6 +1617,7 @@ ], "crate_features": { "common": [ + "cargo", "color", "default", "derive", @@ -1567,6 +1683,7 @@ ], "crate_features": { "common": [ + "cargo", "color", "error-context", "help", @@ -1590,6 +1707,10 @@ "id": "clap_lex 0.5.0", "target": "clap_lex" }, + { + "id": "once_cell 1.18.0", + "target": "once_cell" + }, { "id": "strsim 0.10.0", "target": "strsim" @@ -1832,6 +1953,13 @@ "compile_data_glob": [ "**" ], + "crate_features": { + "common": [ + "ansi-parsing", + "unicode-width" + ], + "selects": {} + }, "deps": { "common": [ { @@ -1841,6 +1969,10 @@ { "id": "libc 0.2.147", "target": "libc" + }, + { + "id": "unicode-width 0.1.10", + "target": "unicode_width" } ], "selects": { @@ -2636,6 +2768,36 @@ }, "license": "MIT OR Apache-2.0" }, + "difflib 0.4.0": { + "name": "difflib", + "version": "0.4.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/difflib/0.4.0/download", + "sha256": "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + } + }, + "targets": [ + { + "Library": { + "crate_name": "difflib", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "difflib", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.4.0" + }, + "license": "MIT" + }, "dirs-next 2.0.0": { "name": "dirs-next", "version": "2.0.0", @@ -2732,6 +2894,59 @@ }, "license": "MIT OR Apache-2.0" }, + "doc-comment 0.3.3": { + "name": "doc-comment", + "version": "0.3.3", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/doc-comment/0.3.3/download", + "sha256": "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + } + }, + "targets": [ + { + "Library": { + "crate_name": "doc_comment", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "doc_comment", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "doc-comment 0.3.3", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "0.3.3" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT" + }, "either 1.9.0": { "name": "either", "version": "1.9.0", @@ -3322,6 +3537,53 @@ }, "license": "MIT OR Apache-2.0" }, + "float-cmp 0.9.0": { + "name": "float-cmp", + "version": "0.9.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/float-cmp/0.9.0/download", + "sha256": "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + } + }, + "targets": [ + { + "Library": { + "crate_name": "float_cmp", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "float_cmp", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "num-traits", + "ratio" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "num-traits 0.2.16", + "target": "num_traits" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.9.0" + }, + "license": "MIT" + }, "fnv 1.0.7": { "name": "fnv", "version": "1.0.7", @@ -4741,49 +5003,19 @@ }, "license": "Apache-2.0 OR MIT" }, - "inlinable_string 0.1.15": { - "name": "inlinable_string", - "version": "0.1.15", - "repository": { - "Http": { - "url": "https://crates.io/api/v1/crates/inlinable_string/0.1.15/download", - "sha256": "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" - } - }, - "targets": [ - { - "Library": { - "crate_name": "inlinable_string", - "crate_root": "src/lib.rs", - "srcs": [ - "**/*.rs" - ] - } - } - ], - "library_target_name": "inlinable_string", - "common_attrs": { - "compile_data_glob": [ - "**" - ], - "edition": "2018", - "version": "0.1.15" - }, - "license": "Apache-2.0/MIT" - }, - "insta 1.31.0": { - "name": "insta", - "version": "1.31.0", + "indicatif 0.17.7": { + "name": "indicatif", + "version": "0.17.7", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/insta/1.31.0/download", - "sha256": "a0770b0a3d4c70567f0d58331f3088b0e4c4f56c9b8d764efe654b4a5d46de3a" + "url": "https://crates.io/api/v1/crates/indicatif/0.17.7/download", + "sha256": "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" } }, "targets": [ { "Library": { - "crate_name": "insta", + "crate_name": "indicatif", "crate_root": "src/lib.rs", "srcs": [ "**/*.rs" @@ -4791,16 +5023,15 @@ } } ], - "library_target_name": "insta", + "library_target_name": "indicatif", "common_attrs": { "compile_data_glob": [ "**" ], "crate_features": { "common": [ - "colors", - "console", - "default" + "default", + "unicode-width" ], "selects": {} }, @@ -4811,29 +5042,164 @@ "target": "console" }, { - "id": "lazy_static 1.4.0", - "target": "lazy_static" - }, - { - "id": "linked-hash-map 0.5.6", - "target": "linked_hash_map" + "id": "number_prefix 0.4.0", + "target": "number_prefix" }, { - "id": "similar 2.2.1", - "target": "similar" + "id": "portable-atomic 1.5.0", + "target": "portable_atomic" }, { - "id": "yaml-rust 0.4.5", - "target": "yaml_rust" - } + "id": "unicode-width 0.1.10", + "target": "unicode_width" + } + ], + "selects": { + "cfg(target_arch = \"wasm32\")": [ + { + "id": "instant 0.1.12", + "target": "instant" + } + ] + } + }, + "edition": "2021", + "version": "0.17.7" + }, + "license": "MIT" + }, + "inlinable_string 0.1.15": { + "name": "inlinable_string", + "version": "0.1.15", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/inlinable_string/0.1.15/download", + "sha256": "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + } + }, + "targets": [ + { + "Library": { + "crate_name": "inlinable_string", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "inlinable_string", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.1.15" + }, + "license": "Apache-2.0/MIT" + }, + "insta 1.34.0": { + "name": "insta", + "version": "1.34.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/insta/1.34.0/download", + "sha256": "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc" + } + }, + "targets": [ + { + "Library": { + "crate_name": "insta", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "insta", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "colors", + "console", + "default" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "console 0.15.7", + "target": "console" + }, + { + "id": "lazy_static 1.4.0", + "target": "lazy_static" + }, + { + "id": "linked-hash-map 0.5.6", + "target": "linked_hash_map" + }, + { + "id": "similar 2.2.1", + "target": "similar" + }, + { + "id": "yaml-rust 0.4.5", + "target": "yaml_rust" + } ], "selects": {} }, "edition": "2018", - "version": "1.31.0" + "version": "1.34.0" }, "license": "Apache-2.0" }, + "instant 0.1.12": { + "name": "instant", + "version": "0.1.12", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/instant/0.1.12/download", + "sha256": "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "instant", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "instant", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "cfg-if 1.0.0", + "target": "cfg_if" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.1.12" + }, + "license": "BSD-3-Clause" + }, "is-terminal 0.4.9": { "name": "is-terminal", "version": "0.4.9", @@ -4934,6 +5300,53 @@ }, "license": "MIT/Apache-2.0" }, + "itertools 0.11.0": { + "name": "itertools", + "version": "0.11.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/itertools/0.11.0/download", + "sha256": "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" + } + }, + "targets": [ + { + "Library": { + "crate_name": "itertools", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "itertools", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "use_alloc", + "use_std" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "either 1.9.0", + "target": "either" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.11.0" + }, + "license": "MIT OR Apache-2.0" + }, "itoa 1.0.9": { "name": "itoa", "version": "1.0.9", @@ -6103,6 +6516,36 @@ }, "license": "MIT" }, + "normalize-line-endings 0.3.0": { + "name": "normalize-line-endings", + "version": "0.3.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/normalize-line-endings/0.3.0/download", + "sha256": "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + } + }, + "targets": [ + { + "Library": { + "crate_name": "normalize_line_endings", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "normalize_line_endings", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2015", + "version": "0.3.0" + }, + "license": "Apache-2.0" + }, "nu-ansi-term 0.46.0": { "name": "nu-ansi-term", "version": "0.46.0", @@ -6265,6 +6708,43 @@ }, "license": "MIT OR Apache-2.0" }, + "number_prefix 0.4.0": { + "name": "number_prefix", + "version": "0.4.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/number_prefix/0.4.0/download", + "sha256": "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + } + }, + "targets": [ + { + "Library": { + "crate_name": "number_prefix", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "number_prefix", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "std" + ], + "selects": {} + }, + "edition": "2015", + "version": "0.4.0" + }, + "license": "MIT" + }, "object 0.31.1": { "name": "object", "version": "0.31.1", @@ -7047,19 +7527,215 @@ }, "license": "MIT" }, - "plotters 0.3.5": { - "name": "plotters", - "version": "0.3.5", + "plotters 0.3.5": { + "name": "plotters", + "version": "0.3.5", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/plotters/0.3.5/download", + "sha256": "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" + } + }, + "targets": [ + { + "Library": { + "crate_name": "plotters", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "plotters", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "area_series", + "line_series", + "plotters-svg", + "svg_backend" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "num-traits 0.2.16", + "target": "num_traits" + }, + { + "id": "plotters-backend 0.3.5", + "target": "plotters_backend" + }, + { + "id": "plotters-svg 0.3.5", + "target": "plotters_svg" + } + ], + "selects": { + "cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))": [ + { + "id": "wasm-bindgen 0.2.87", + "target": "wasm_bindgen" + }, + { + "id": "web-sys 0.3.64", + "target": "web_sys" + } + ] + } + }, + "edition": "2018", + "version": "0.3.5" + }, + "license": "MIT" + }, + "plotters-backend 0.3.5": { + "name": "plotters-backend", + "version": "0.3.5", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/plotters-backend/0.3.5/download", + "sha256": "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + } + }, + "targets": [ + { + "Library": { + "crate_name": "plotters_backend", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "plotters_backend", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.3.5" + }, + "license": "MIT" + }, + "plotters-svg 0.3.5": { + "name": "plotters-svg", + "version": "0.3.5", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/plotters-svg/0.3.5/download", + "sha256": "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" + } + }, + "targets": [ + { + "Library": { + "crate_name": "plotters_svg", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "plotters_svg", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "plotters-backend 0.3.5", + "target": "plotters_backend" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "0.3.5" + }, + "license": "MIT" + }, + "portable-atomic 1.5.0": { + "name": "portable-atomic", + "version": "1.5.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/portable-atomic/1.5.0/download", + "sha256": "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023" + } + }, + "targets": [ + { + "Library": { + "crate_name": "portable_atomic", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "portable_atomic", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": { + "common": [ + "default", + "fallback" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "portable-atomic 1.5.0", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2018", + "version": "1.5.0" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "Apache-2.0 OR MIT" + }, + "ppv-lite86 0.2.17": { + "name": "ppv-lite86", + "version": "0.2.17", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/plotters/0.3.5/download", - "sha256": "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" + "url": "https://crates.io/api/v1/crates/ppv-lite86/0.2.17/download", + "sha256": "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" } }, "targets": [ { "Library": { - "crate_name": "plotters", + "crate_name": "ppv_lite86", "crate_root": "src/lib.rs", "srcs": [ "**/*.rs" @@ -7067,66 +7743,36 @@ } } ], - "library_target_name": "plotters", + "library_target_name": "ppv_lite86", "common_attrs": { "compile_data_glob": [ "**" ], "crate_features": { "common": [ - "area_series", - "line_series", - "plotters-svg", - "svg_backend" + "simd", + "std" ], "selects": {} }, - "deps": { - "common": [ - { - "id": "num-traits 0.2.16", - "target": "num_traits" - }, - { - "id": "plotters-backend 0.3.5", - "target": "plotters_backend" - }, - { - "id": "plotters-svg 0.3.5", - "target": "plotters_svg" - } - ], - "selects": { - "cfg(all(target_arch = \"wasm32\", not(target_os = \"wasi\")))": [ - { - "id": "wasm-bindgen 0.2.87", - "target": "wasm_bindgen" - }, - { - "id": "web-sys 0.3.64", - "target": "web_sys" - } - ] - } - }, "edition": "2018", - "version": "0.3.5" + "version": "0.2.17" }, - "license": "MIT" + "license": "MIT/Apache-2.0" }, - "plotters-backend 0.3.5": { - "name": "plotters-backend", - "version": "0.3.5", + "predicates 3.0.4": { + "name": "predicates", + "version": "3.0.4", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/plotters-backend/0.3.5/download", - "sha256": "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + "url": "https://crates.io/api/v1/crates/predicates/3.0.4/download", + "sha256": "6dfc28575c2e3f19cb3c73b93af36460ae898d426eba6fc15b9bd2a5220758a0" } }, "targets": [ { "Library": { - "crate_name": "plotters_backend", + "crate_name": "predicates", "crate_root": "src/lib.rs", "srcs": [ "**/*.rs" @@ -7134,29 +7780,73 @@ } } ], - "library_target_name": "plotters_backend", + "library_target_name": "predicates", "common_attrs": { "compile_data_glob": [ "**" ], - "edition": "2018", - "version": "0.3.5" + "crate_features": { + "common": [ + "color", + "default", + "diff", + "float-cmp", + "normalize-line-endings", + "regex" + ], + "selects": {} + }, + "deps": { + "common": [ + { + "id": "anstyle 1.0.1", + "target": "anstyle" + }, + { + "id": "difflib 0.4.0", + "target": "difflib" + }, + { + "id": "float-cmp 0.9.0", + "target": "float_cmp" + }, + { + "id": "itertools 0.11.0", + "target": "itertools" + }, + { + "id": "normalize-line-endings 0.3.0", + "target": "normalize_line_endings" + }, + { + "id": "predicates-core 1.0.6", + "target": "predicates_core" + }, + { + "id": "regex 1.9.3", + "target": "regex" + } + ], + "selects": {} + }, + "edition": "2021", + "version": "3.0.4" }, - "license": "MIT" + "license": "MIT OR Apache-2.0" }, - "plotters-svg 0.3.5": { - "name": "plotters-svg", - "version": "0.3.5", + "predicates-core 1.0.6": { + "name": "predicates-core", + "version": "1.0.6", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/plotters-svg/0.3.5/download", - "sha256": "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" + "url": "https://crates.io/api/v1/crates/predicates-core/1.0.6/download", + "sha256": "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" } }, "targets": [ { "Library": { - "crate_name": "plotters_svg", + "crate_name": "predicates_core", "crate_root": "src/lib.rs", "srcs": [ "**/*.rs" @@ -7164,38 +7854,29 @@ } } ], - "library_target_name": "plotters_svg", + "library_target_name": "predicates_core", "common_attrs": { "compile_data_glob": [ "**" ], - "deps": { - "common": [ - { - "id": "plotters-backend 0.3.5", - "target": "plotters_backend" - } - ], - "selects": {} - }, - "edition": "2018", - "version": "0.3.5" + "edition": "2021", + "version": "1.0.6" }, - "license": "MIT" + "license": "MIT OR Apache-2.0" }, - "ppv-lite86 0.2.17": { - "name": "ppv-lite86", - "version": "0.2.17", + "predicates-tree 1.0.9": { + "name": "predicates-tree", + "version": "1.0.9", "repository": { "Http": { - "url": "https://crates.io/api/v1/crates/ppv-lite86/0.2.17/download", - "sha256": "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + "url": "https://crates.io/api/v1/crates/predicates-tree/1.0.9/download", + "sha256": "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" } }, "targets": [ { "Library": { - "crate_name": "ppv_lite86", + "crate_name": "predicates_tree", "crate_root": "src/lib.rs", "srcs": [ "**/*.rs" @@ -7203,22 +7884,28 @@ } } ], - "library_target_name": "ppv_lite86", + "library_target_name": "predicates_tree", "common_attrs": { "compile_data_glob": [ "**" ], - "crate_features": { + "deps": { "common": [ - "simd", - "std" + { + "id": "predicates-core 1.0.6", + "target": "predicates_core" + }, + { + "id": "termtree 0.4.1", + "target": "termtree" + } ], "selects": {} }, - "edition": "2018", - "version": "0.2.17" + "edition": "2021", + "version": "1.0.9" }, - "license": "MIT/Apache-2.0" + "license": "MIT OR Apache-2.0" }, "pretty_assertions 1.4.0": { "name": "pretty_assertions", @@ -8363,6 +9050,7 @@ "common": [ "alloc", "dfa-onepass", + "dfa-search", "hybrid", "meta", "nfa-backtrack", @@ -9552,7 +10240,7 @@ "target": "clap" }, { - "id": "insta 1.31.0", + "id": "insta 1.34.0", "target": "insta" }, { @@ -9649,6 +10337,71 @@ }, "license": null }, + "scip-treesitter-cli 0.1.0": { + "name": "scip-treesitter-cli", + "version": "0.1.0", + "repository": null, + "targets": [], + "library_target_name": null, + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "anyhow 1.0.75", + "target": "anyhow" + }, + { + "id": "assert_cmd 2.0.12", + "target": "assert_cmd" + }, + { + "id": "clap 4.3.23", + "target": "clap" + }, + { + "id": "indicatif 0.17.7", + "target": "indicatif" + }, + { + "id": "insta 1.34.0", + "target": "insta" + }, + { + "id": "lazy_static 1.4.0", + "target": "lazy_static" + }, + { + "id": "predicates 3.0.4", + "target": "predicates" + }, + { + "id": "protobuf 3.2.0", + "target": "protobuf" + }, + { + "id": "scip 0.1.1", + "target": "scip" + } + ], + "selects": {} + }, + "edition": "2021", + "proc_macro_deps": { + "common": [ + { + "id": "paste 1.0.14", + "target": "paste" + } + ], + "selects": {} + }, + "version": "0.1.0" + }, + "license": null + }, "scip-treesitter-languages 0.1.0": { "name": "scip-treesitter-languages", "version": "0.1.0", @@ -10183,7 +10936,7 @@ "deps_dev": { "common": [ { - "id": "insta 1.31.0", + "id": "insta 1.34.0", "target": "insta" }, { @@ -11145,6 +11898,36 @@ }, "license": "MIT OR Apache-2.0" }, + "termtree 0.4.1": { + "name": "termtree", + "version": "0.4.1", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/termtree/0.4.1/download", + "sha256": "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + } + }, + "targets": [ + { + "Library": { + "crate_name": "termtree", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "termtree", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "edition": "2018", + "version": "0.4.1" + }, + "license": "MIT" + }, "textwrap 0.16.0": { "name": "textwrap", "version": "0.16.0", @@ -14138,6 +14921,47 @@ }, "license": "MIT/Apache-2.0" }, + "wait-timeout 0.2.0": { + "name": "wait-timeout", + "version": "0.2.0", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/wait-timeout/0.2.0/download", + "sha256": "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" + } + }, + "targets": [ + { + "Library": { + "crate_name": "wait_timeout", + "crate_root": "src/lib.rs", + "srcs": [ + "**/*.rs" + ] + } + } + ], + "library_target_name": "wait_timeout", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [], + "selects": { + "cfg(unix)": [ + { + "id": "libc 0.2.147", + "target": "libc" + } + ] + } + }, + "edition": "2015", + "version": "0.2.0" + }, + "license": "MIT/Apache-2.0" + }, "walkdir 2.3.3": { "name": "walkdir", "version": "2.3.3", @@ -16140,6 +16964,7 @@ "scip-macros 0.1.0": "docker-images/syntax-highlighter/crates/scip-macros", "scip-syntax 0.1.0": "docker-images/syntax-highlighter/crates/scip-syntax", "scip-treesitter 0.1.0": "docker-images/syntax-highlighter/crates/scip-treesitter", + "scip-treesitter-cli 0.1.0": "docker-images/syntax-highlighter/crates/scip-treesitter-cli", "scip-treesitter-languages 0.1.0": "docker-images/syntax-highlighter/crates/scip-treesitter-languages", "sg-syntax 0.1.0": "docker-images/syntax-highlighter/crates/sg-syntax", "syntect_server 1.0.1": "docker-images/syntax-highlighter" @@ -16432,6 +17257,10 @@ "x86_64-unknown-linux-gnu", "x86_64-unknown-none" ], + "cfg(target_arch = \"wasm32\")": [ + "wasm32-unknown-unknown", + "wasm32-wasi" + ], "cfg(target_os = \"dragonfly\")": [], "cfg(target_os = \"hermit\")": [], "cfg(target_os = \"redox\")": [], diff --git a/docker-images/syntax-highlighter/Cargo.lock b/docker-images/syntax-highlighter/Cargo.lock index 5596e0c6a7c9..f30578325b96 100644 --- a/docker-images/syntax-highlighter/Cargo.lock +++ b/docker-images/syntax-highlighter/Cargo.lock @@ -87,6 +87,21 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "assert_cmd" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88903cb14723e4d4003335bb7f8a14f27691649105346a0f0957466c096adfe6" +dependencies = [ + "anstyle", + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + [[package]] name = "async-stream" version = "0.3.5" @@ -209,6 +224,17 @@ dependencies = [ "wyz", ] +[[package]] +name = "bstr" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +dependencies = [ + "memchr", + "regex-automata 0.3.6", + "serde", +] + [[package]] name = "bumpalo" version = "3.13.0" @@ -301,6 +327,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex 0.5.0", + "once_cell", "strsim", ] @@ -357,6 +384,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", + "unicode-width", "windows-sys 0.45.0", ] @@ -392,7 +420,7 @@ dependencies = [ "ciborium", "clap 3.2.25", "criterion-plot", - "itertools", + "itertools 0.10.5", "lazy_static", "num-traits", "oorandom", @@ -413,7 +441,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" dependencies = [ "cast", - "itertools", + "itertools 0.10.5", ] [[package]] @@ -504,6 +532,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + [[package]] name = "dirs-next" version = "2.0.0" @@ -525,6 +559,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "either" version = "1.9.0" @@ -630,6 +670,15 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + [[package]] name = "fnv" version = "1.0.7" @@ -880,6 +929,19 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "indicatif" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + [[package]] name = "inlinable_string" version = "0.1.15" @@ -888,9 +950,9 @@ checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" [[package]] name = "insta" -version = "1.31.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0770b0a3d4c70567f0d58331f3088b0e4c4f56c9b8d764efe654b4a5d46de3a" +checksum = "5d64600be34b2fcfc267740a243fa7744441bb4947a619ac4e5bb6507f35fbfc" dependencies = [ "console", "lazy_static", @@ -899,6 +961,15 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "is-terminal" version = "0.4.9" @@ -919,6 +990,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" @@ -1109,6 +1189,12 @@ dependencies = [ "memoffset 0.6.5", ] +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -1138,6 +1224,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.31.1" @@ -1311,12 +1403,49 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "portable-atomic" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023" + [[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "predicates" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dfc28575c2e3f19cb3c73b93af36460ae898d426eba6fc15b9bd2a5220758a0" +dependencies = [ + "anstyle", + "difflib", + "float-cmp", + "itertools 0.11.0", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "pretty_assertions" version = "1.4.0" @@ -1730,7 +1859,7 @@ dependencies = [ "bitvec", "clap 4.3.23", "insta", - "itertools", + "itertools 0.10.5", "once_cell", "protobuf", "regex", @@ -1755,6 +1884,25 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "scip-treesitter-cli" +version = "0.1.0" +dependencies = [ + "anyhow", + "assert_cmd", + "clap 4.3.23", + "indicatif", + "insta", + "lazy_static", + "paste", + "predicates", + "protobuf", + "scip", + "scip-syntax", + "scip-treesitter", + "scip-treesitter-languages", +] + [[package]] name = "scip-treesitter-languages" version = "0.1.0" @@ -2019,6 +2167,7 @@ dependencies = [ "scip", "scip-syntax", "scip-treesitter", + "scip-treesitter-cli", "scip-treesitter-languages", "serde", "serde_json", @@ -2045,6 +2194,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + [[package]] name = "textwrap" version = "0.16.0" @@ -2554,6 +2709,15 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] + [[package]] name = "walkdir" version = "2.3.3" diff --git a/docker-images/syntax-highlighter/Cargo.toml b/docker-images/syntax-highlighter/Cargo.toml index 076691e58763..1d08f898da74 100644 --- a/docker-images/syntax-highlighter/Cargo.toml +++ b/docker-images/syntax-highlighter/Cargo.toml @@ -23,6 +23,7 @@ base64 = "0.13.0" sg-syntax = { path = "./crates/sg-syntax" } scip-treesitter = { path = "./crates/scip-treesitter" } scip-treesitter-languages = { path = "./crates/scip-treesitter-languages" } +scip-treesitter-cli = { path = "./crates/scip-treesitter-cli" } scip-syntax = { path = "./crates/scip-syntax" } # March 20, 2023 - Pinned explicitly with features that match the features # required by rocket. Once bazel rules correctly roll up all the features, @@ -45,11 +46,13 @@ members = [ "crates/scip-syntax", "crates/scip-treesitter", "crates/scip-treesitter-languages", + "crates/scip-treesitter-cli", ] [workspace.dependencies] anyhow = "1" -clap = { version = "4.1.11", features = [ "derive" ] } +# "cargo" feature is enabled for using the `crate_version` macro +clap = { version = "4.1.11", features = [ "derive", "cargo"] } itertools = "0.10.5" rocket = { version = "0.5.0-rc.1", features = ["json"] } # See https://stackoverflow.com/questions/76905691/bazel-unable-to-build-external-rust-dependency-with-feature-serde1 diff --git a/docker-images/syntax-highlighter/README.md b/docker-images/syntax-highlighter/README.md index 3361b73651db..7dc470ea2bbc 100644 --- a/docker-images/syntax-highlighter/README.md +++ b/docker-images/syntax-highlighter/README.md @@ -5,6 +5,7 @@ Crates: - The main `syntect_server` executable - `crates/scip-treesitter-languages/`: All the grammars and parsers live here to make shipping parsers with the same tree-sitter version (and associated build tooling) very easy. All new grammars and parsers should be added here. - `crates/scip-treesitter/`: Associated utilities for tree-sitter and scip. Not required to be used for other projects +- `crates/scip-treesitter-cli/`: Command line tool that produces a SCIP index file from the analysis performed by other `scip-*` crates in this project - `crates/scip-syntax/`: local navigation calculation (and some other utilities) live here. - `crates/sg-syntax/`: Sourcegraph code to glue together whatever from the above crates to be used for our purposes. diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/src/ctags.rs b/docker-images/syntax-highlighter/crates/scip-syntax/src/ctags.rs index 31fb404abb67..d676e4de4873 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/src/ctags.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/src/ctags.rs @@ -194,7 +194,7 @@ pub fn generate_tags( let filepath = path.file_name()?.to_str()?; let parser = BundledParser::get_parser_from_extension(extension)?; - let (root_scope, _) = match get_globals(&parser, file_data)? { + let (root_scope, _) = match get_globals(parser, file_data)? { Ok(vals) => vals, Err(err) => { // TODO: Not sure I want to keep this or not diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/src/globals.rs b/docker-images/syntax-highlighter/crates/scip-syntax/src/globals.rs index 93fc6d56cceb..419044933fbb 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/src/globals.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/src/globals.rs @@ -330,7 +330,7 @@ pub mod test { #[test] fn test_enclosing_range() -> Result<()> { let config = - crate::languages::get_tag_configuration(&BundledParser::Go).expect("to have parser"); + crate::languages::get_tag_configuration(BundledParser::Go).expect("to have parser"); let source_code = include_str!("../testdata/scopes_of_go.go"); let doc = parse_file_for_lang(config, source_code)?; diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/src/languages.rs b/docker-images/syntax-highlighter/crates/scip-syntax/src/languages.rs index 4a2e7942b2b8..8fcf368e6cc0 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/src/languages.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/src/languages.rs @@ -42,7 +42,7 @@ impl TagConfiguration { let included_lang = included_lang.trim(); let parser = BundledParser::get_parser(included_lang).expect("valid language"); - let configuration = get_tag_configuration(&parser).expect("valid config"); + let configuration = get_tag_configuration(parser).expect("valid config"); format!("{}\n{}", configuration.query_text, tag_query) } @@ -241,7 +241,7 @@ mod tags { create_tags_configuration!(go, BundledParser::Go, "go", "go"); create_tags_configuration!(zig, BundledParser::Zig, "zig"); - pub fn get_tag_configuration(parser: &BundledParser) -> Option<&'static TagConfiguration> { + pub fn get_tag_configuration(parser: BundledParser) -> Option<&'static TagConfiguration> { match parser { BundledParser::C => Some(c()), BundledParser::Javascript => Some(javascript()), diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/src/lib.rs b/docker-images/syntax-highlighter/crates/scip-syntax/src/lib.rs index ea2eced085e1..95be029ccc2b 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/src/lib.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/src/lib.rs @@ -9,7 +9,7 @@ pub mod locals; pub mod symbols; pub mod ts_scip; -pub fn get_symbols(parser: &BundledParser, source_bytes: &[u8]) -> Result { +pub fn get_symbols(parser: BundledParser, source_bytes: &[u8]) -> Result { let config = match crate::languages::get_tag_configuration(parser) { Some(config) => config, None => return Err(anyhow::anyhow!("Missing config for language")), @@ -22,7 +22,7 @@ pub fn get_symbols(parser: &BundledParser, source_bytes: &[u8]) -> Result Option> { let config = languages::get_tag_configuration(parser)?; @@ -64,7 +64,7 @@ mod test { let parser = BundledParser::get_parser_from_extension(extension).expect("to have parser"); let config = - crate::languages::get_tag_configuration(&parser).expect("to have rust parser"); + crate::languages::get_tag_configuration(parser).expect("to have rust parser"); let doc = crate::globals::test::parse_file_for_lang(config, &source_code) .expect("to parse document"); let dumped = dump_document(&doc, &source_code).expect("to dumb document"); diff --git a/docker-images/syntax-highlighter/crates/scip-syntax/src/symbols.rs b/docker-images/syntax-highlighter/crates/scip-syntax/src/symbols.rs index c81a0074b4d2..8260f8fb5633 100644 --- a/docker-images/syntax-highlighter/crates/scip-syntax/src/symbols.rs +++ b/docker-images/syntax-highlighter/crates/scip-syntax/src/symbols.rs @@ -349,7 +349,7 @@ mod test { #[test] fn generates_some_go_symbols() -> Result<()> { - let config = crate::languages::get_tag_configuration(&BundledParser::Go).unwrap(); + let config = crate::languages::get_tag_configuration(BundledParser::Go).unwrap(); let source_code = include_str!("../testdata/symbols.go"); let document = parse_file_for_lang(config, source_code)?; let dumped = dump_document(&document, source_code)?; diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-cli/BUILD.bazel b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/BUILD.bazel new file mode 100644 index 000000000000..0d615483f507 --- /dev/null +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/BUILD.bazel @@ -0,0 +1,53 @@ +load("@crate_index//:defs.bzl", "aliases", "all_crate_deps") +load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test") + +rust_binary( + name = "scip-treesitter-cli", + srcs = ["src/main.rs"], + aliases = aliases(), + proc_macro_deps = all_crate_deps( + proc_macro = True, + ), + visibility = ["//visibility:public"], + deps = all_crate_deps( + normal = True, + ) + [ + "//docker-images/syntax-highlighter/crates/scip-syntax", + "//docker-images/syntax-highlighter/crates/scip-treesitter", + "//docker-images/syntax-highlighter/crates/scip-treesitter-languages", + ], +) + +rust_test( + name = "unit_test", + srcs = ["src/main.rs"], + compile_data = glob( + [ + "testdata/**", + ], + allow_empty = False, + ), + # Make sure this name matches the crate name in cargo configuration + # This is to ensure that snapshots produced by Bazel tests and + # ones produced by `cargo test` command - otherwise insta testing will fail! + crate = ":scip-treesitter-cli", + data = glob( + ["testdata/**"], + ) + [":scip-treesitter-cli"] + + glob( + ["src/snapshots/**"], + allow_empty = False, + ), + env = { + "INSTA_WORKSPACE_ROOT": ".", + "RUST_BACKTRACE": "1", + "SCIP_CLI_LOCATION": "$(rootpath :scip-treesitter-cli)", + }, + deps = all_crate_deps( + normal = True, + ) + [ + "//docker-images/syntax-highlighter/crates/scip-syntax", + "//docker-images/syntax-highlighter/crates/scip-treesitter", + "//docker-images/syntax-highlighter/crates/scip-treesitter-languages", + ], +) diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-cli/Cargo.toml b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/Cargo.toml new file mode 100644 index 000000000000..1f596c0f829f --- /dev/null +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "scip-treesitter-cli" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +lazy_static = "1.0" +paste = "1.0.6" +assert_cmd = "2.0.12" +predicates = "3.0.4" +insta = "1.34.0" +indicatif = "0.17.7" + +protobuf = { workspace = true } +scip = { workspace = true } +anyhow = { workspace = true } +clap = { workspace = true } + +scip-syntax = { path = "../scip-syntax" } +scip-treesitter-languages = { path = "../scip-treesitter-languages" } +scip-treesitter= { path = "../scip-treesitter" } diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-cli/README.md b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/README.md new file mode 100644 index 000000000000..7f0d1286fc77 --- /dev/null +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/README.md @@ -0,0 +1,28 @@ +# scip-treesitter-cli + +A command line tool that uses other scip-* crates to produce a SCIP file containing +global and local symbols discovered during analysis. + +## Usage + +**Indexing** (`index --help` for more details) + +``` +scip-treesitter-cli index --language java --out ./index.scip file1.java file2.java ... +``` + +## Contributing + +This is a standard Rust CLI project, with a single runnable entry point - the CLI itself. + +1. Run tests: `cargo test` + + We use Insta for snapshot testing, if you're changing the output produced by the CLI, + run `cargo test` and then `cargo insta review` to accept/reject changes in symbols + +2. Run CLI: `cargo run -- index --language java --out ./index.scip file1.java file2.java ...` + +On CI, Bazel is used instead of Cargo. + +1. Run tests: `bazel test //docker-images/syntax-highlighter/crates/scip-treesitter-cli:unit_test` +2. Build CLI: `bazel build //docker-images/syntax-highlighter/crates/scip-treesitter-cli:scip-treesitter-cli` diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-cli/src/main.rs b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/src/main.rs new file mode 100644 index 000000000000..bcaf7330a321 --- /dev/null +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/src/main.rs @@ -0,0 +1,320 @@ +use clap::{Parser, Subcommand, ValueEnum}; +use indicatif::{ProgressBar, ProgressStyle}; +use protobuf::{CodedInputStream, Message}; +use scip::types::Document; +use scip_syntax::{get_locals, get_symbols}; +use scip_treesitter_languages::parsers::BundledParser; + +use anyhow::Result; +use std::{fs::File, io::BufReader, path::PathBuf}; + +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +#[command(propagate_version = true)] +struct Cli { + #[command(subcommand)] + command: Commands, +} + +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] +enum AnalysisMode { + /// Only extract occurrences of local definitions + Locals, + /// Only extract globally-accessible symbols + Globals, + /// Locals + Globals, extract everything + Full, +} + +impl AnalysisMode { + fn locals(self) -> bool { + return self == AnalysisMode::Locals || self == AnalysisMode::Full; + } + fn globals(self) -> bool { + return self == AnalysisMode::Globals || self == AnalysisMode::Full; + } +} + +#[derive(Subcommand)] +enum Commands { + /// Index source files using Tree Sitter parser for a given language + /// and produce a SCIP file + Index { + /// + #[arg(short, long)] + language: String, + + /// Path where the SCIP index will be written + #[arg(short, long, default_value = "./index.scip")] + out: String, + + /// List of files to analyse + filenames: Vec, + + /// Analysis mode + #[arg(short, long, default_value = "full")] + mode: AnalysisMode, + + /// Fail on first error + #[arg(long, default_value_t = false)] + fail_fast: bool, + + /// Project root to write to SCIP index + #[arg(short, long, default_value = "./")] + project_root: String, + }, +} + +struct Options { + analysis_mode: AnalysisMode, + /// When true, fail on first encountered error + /// Otherwise errors are logged but they don't + /// interrupt the process + fail_fast: bool, +} + +pub fn main() { + let cli = Cli::parse(); + + match cli.command { + Commands::Index { + language, + out, + filenames, + mode, + fail_fast, + project_root, + } => index_command( + language, + filenames, + PathBuf::from(out), + PathBuf::from(project_root), + Options { + analysis_mode: mode, + fail_fast, + }, + ), + } +} + +fn index_command( + language: String, + filenames: Vec, + out: PathBuf, + project_root: PathBuf, + options: Options, +) { + let p = BundledParser::get_parser(&language).unwrap(); + + let mut index = scip::types::Index { + metadata: Some(scip::types::Metadata { + tool_info: Some(scip::types::ToolInfo { + name: "scip-treesitter-cli".to_string(), + version: clap::crate_version!().to_string(), + arguments: vec![], + ..Default::default() + }) + .into(), + project_root: format!( + "file://{}", + project_root + .canonicalize() + .expect("Failed to canonicalize project root") + .display() + ), + ..Default::default() + }) + .into(), + ..Default::default() + }; + + let bar = ProgressBar::new(filenames.len() as u64); + + bar.set_style( + ProgressStyle::with_template( + "[{elapsed_precise}] {bar:40.cyan/blue} {pos:>7}/{len:7}\n {msg}", + ) + .unwrap() + .progress_chars("##-"), + ); + + for (_, filename) in filenames.iter().enumerate() { + let contents = std::fs::read(filename).unwrap(); + bar.set_message(filename.clone()); + bar.inc(1); + match index_content(contents, p, &options) { + Ok(mut document) => { + document.relative_path = filename.to_string(); + index.documents.push(document); + } + Err(error) => { + if options.fail_fast { + panic!("Failed to index {filename}: {:?}", error); + } else { + eprintln!("Failed to index {filename}: {:?}", error) + } + } + } + } + + bar.finish(); + + eprintln!(""); + + eprintln!( + "Writing index for {} documents into {}", + index.documents.len(), + out.display() + ); + + write_message_to_file(out, index).expect("to write the file"); +} + +fn index_content(contents: Vec, parser: BundledParser, options: &Options) -> Result { + let mut document: Document; + + if options.analysis_mode.globals() { + document = get_symbols(parser, &contents).unwrap(); + } else { + document = Document::new(); + } + + if options.analysis_mode.locals() { + let locals = get_locals(parser, &contents); + + match locals { + Some(Ok(occurrences)) => { + for occ in occurrences { + document.occurrences.push(occ); + } + } + Some(Err(e)) => return Err(e), + None => {} + } + } + + return Ok(document); +} + +fn write_message_to_file

( + path: P, + msg: impl protobuf::Message, +) -> Result<(), Box> +where + P: AsRef, +{ + use std::io::Write; + + let res = msg.write_to_bytes()?; + let output = std::fs::File::create(path)?; + let mut writer = std::io::BufWriter::new(output); + writer.write_all(&res)?; + + Ok(()) +} + +fn read_index_from_file(file: PathBuf) -> scip::types::Index { + let mut candidate_idx = scip::types::Index::new(); + let candidate_f = File::open(file).unwrap(); + + let mut reader = BufReader::new(candidate_f); + let mut cis = CodedInputStream::from_buf_read(&mut reader); + + candidate_idx.merge_from(&mut cis).unwrap(); + return candidate_idx; +} + +#[cfg(test)] +mod tests { + use crate::read_index_from_file; + use assert_cmd::cargo::cargo_bin; + use assert_cmd::prelude::*; + use std::collections::HashMap; + use std::process::Command; + use std::{env::temp_dir, path::PathBuf}; + + lazy_static::lazy_static! { + static ref BINARY_LOCATION: PathBuf = { + let mut c: PathBuf; + match std::env::var("SCIP_CLI_LOCATION") { + Ok(va) => { + c = { + std::env::current_dir().unwrap().join(va) + } + } + _ => c = cargo_bin("scip-treesitter-cli") + } + + c + }; + } + + use scip_treesitter::snapshot::{dump_document_with_config, EmitSymbol, SnapshotOptions}; + + fn snapshot_syntax_document(doc: &scip::types::Document, source: &str) -> String { + dump_document_with_config( + doc, + source, + SnapshotOptions { + emit_symbol: EmitSymbol::All, + ..Default::default() + }, + ) + .expect("dump document") + } + + #[test] + fn java_e2e() { + let out_dir = temp_dir(); + let setup = HashMap::from([( + PathBuf::from("globals.java"), + include_str!("../testdata/globals.java").to_string(), + )]); + + run_index(&out_dir, &setup, vec!["--language", "java"]); + + let index = read_index_from_file(out_dir.join("index.scip")); + + for doc in &index.documents { + let path = &doc.relative_path; + let dumped = + snapshot_syntax_document(doc, setup.get(&PathBuf::from(&path)).expect("??")); + + insta::assert_snapshot!(path.clone(), dumped); + } + } + + fn prepare(temp: &PathBuf, files: &HashMap) { + for (path, contents) in files.iter() { + let file_path = temp.join(path); + write_file(&file_path, contents); + } + } + + fn run_index(location: &PathBuf, files: &HashMap, extra_arguments: Vec<&str>) { + prepare(location, files); + + let mut base_args = vec!["index"]; + base_args.extend(extra_arguments); + + let mut cmd = Command::new(BINARY_LOCATION.to_str().unwrap()); + + cmd.args(base_args); + + for (path, _) in files.iter() { + cmd.arg(path.to_str().unwrap()); + } + + cmd.current_dir(location); + + cmd.assert().success(); + } + + fn write_file(path: &PathBuf, contents: &String) { + use std::io::Write; + + let output = std::fs::File::create(path).unwrap(); + let mut writer = std::io::BufWriter::new(output); + writer.write_all(contents.as_bytes()).unwrap(); + } +} diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-cli/src/snapshots/scip_treesitter_cli__tests__globals.java.snap b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/src/snapshots/scip_treesitter_cli__tests__globals.java.snap new file mode 100644 index 000000000000..fb8a7c2a6b71 --- /dev/null +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/src/snapshots/scip_treesitter_cli__tests__globals.java.snap @@ -0,0 +1,88 @@ +--- +source: crates/scip-treesitter-cli/src/main.rs +expression: dumped +--- + package MyPackage; + + public class globals { +// ^^^^^^^ definition scip-ctags globals# + private static int field1; +// ^^^^^^ definition scip-ctags globals#field1. +// ^^^^^^ definition local 1 + protected static int field2; +// ^^^^^^ definition scip-ctags globals#field2. +// ^^^^^^ definition local 2 + public static int field3; +// ^^^^^^ definition scip-ctags globals#field3. +// ^^^^^^ definition local 3 + private int field4; +// ^^^^^^ definition scip-ctags globals#field4. +// ^^^^^^ definition local 4 + protected int field5; +// ^^^^^^ definition scip-ctags globals#field5. +// ^^^^^^ definition local 5 + public int field6; +// ^^^^^^ definition scip-ctags globals#field6. +// ^^^^^^ definition local 6 + + private static void method1() {} +// ^^^^^^^ definition scip-ctags globals#method1(). + protected static void method2() {} +// ^^^^^^^ definition scip-ctags globals#method2(). + public static void method3() {} +// ^^^^^^^ definition scip-ctags globals#method3(). + private void method4() {} +// ^^^^^^^ definition scip-ctags globals#method4(). + protected void method5() {} +// ^^^^^^^ definition scip-ctags globals#method5(). + public void method6() {} +// ^^^^^^^ definition scip-ctags globals#method6(). + + public static final String COOLEST_STRING = "probably this one"; +// ^^^^^^^^^^^^^^ definition scip-ctags globals#COOLEST_STRING. +// ^^^^^^^^^^^^^^ definition local 7 + + public class ClassInAClass { +// ^^^^^^^^^^^^^ definition scip-ctags globals#ClassInAClass# + boolean classy = true; +// ^^^^^^ definition scip-ctags globals#ClassInAClass#classy. +// ^^^^^^ definition local 8 + + public static enum Enum { +// ^^^^ definition scip-ctags globals#ClassInAClass#Enum# + these, +// ^^^^^ definition scip-ctags globals#ClassInAClass#Enum#these. +// ^^^^^ definition local 9 + should, +// ^^^^^^ definition scip-ctags globals#ClassInAClass#Enum#should. +// ^^^^^^ definition local 10 + be, +// ^^ definition scip-ctags globals#ClassInAClass#Enum#be. +// ^^ definition local 11 + recognized, +// ^^^^^^^^^^ definition scip-ctags globals#ClassInAClass#Enum#recognized. +// ^^^^^^^^^^ definition local 12 + as, +// ^^ definition scip-ctags globals#ClassInAClass#Enum#as. +// ^^ definition local 13 + terms +// ^^^^^ definition scip-ctags globals#ClassInAClass#Enum#terms. +// ^^^^^ definition local 14 + } + + public interface Goated { +// ^^^^^^ definition scip-ctags globals#ClassInAClass#Goated# + boolean withTheSauce(); +// ^^^^^^^^^^^^ definition scip-ctags globals#ClassInAClass#Goated#withTheSauce(). + } + + public void myCoolMethod() { +// ^^^^^^^^^^^^ definition scip-ctags globals#ClassInAClass#myCoolMethod(). + class WhatIsGoingOn {} +// ^^^^^^^^^^^^^ definition scip-ctags globals#ClassInAClass#WhatIsGoingOn# + boolean iThinkThisIsAllowedButWeDontReallyCare = true; +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition local 15 + } + } + } + diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-cli/testdata/globals.java b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/testdata/globals.java new file mode 100644 index 000000000000..782bba6b5e6c --- /dev/null +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-cli/testdata/globals.java @@ -0,0 +1,41 @@ +package MyPackage; + +public class globals { + private static int field1; + protected static int field2; + public static int field3; + private int field4; + protected int field5; + public int field6; + + private static void method1() {} + protected static void method2() {} + public static void method3() {} + private void method4() {} + protected void method5() {} + public void method6() {} + + public static final String COOLEST_STRING = "probably this one"; + + public class ClassInAClass { + boolean classy = true; + + public static enum Enum { + these, + should, + be, + recognized, + as, + terms + } + + public interface Goated { + boolean withTheSauce(); + } + + public void myCoolMethod() { + class WhatIsGoingOn {} + boolean iThinkThisIsAllowedButWeDontReallyCare = true; + } + } +} diff --git a/docker-images/syntax-highlighter/crates/scip-treesitter-languages/src/parsers.rs b/docker-images/syntax-highlighter/crates/scip-treesitter-languages/src/parsers.rs index ae6c52a47580..1cd8c4c85563 100644 --- a/docker-images/syntax-highlighter/crates/scip-treesitter-languages/src/parsers.rs +++ b/docker-images/syntax-highlighter/crates/scip-treesitter-languages/src/parsers.rs @@ -1,6 +1,6 @@ use tree_sitter::Language; -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum BundledParser { C, Cpp, @@ -29,7 +29,7 @@ pub enum BundledParser { } impl BundledParser { - pub fn get_language(&self) -> Language { + pub fn get_language(self) -> Language { match self { BundledParser::C => tree_sitter_c::language(), BundledParser::Cpp => tree_sitter_cpp::language(), diff --git a/docker-images/syntax-highlighter/rust-toolchain.toml b/docker-images/syntax-highlighter/rust-toolchain.toml index 75fed73379d6..4fc41ee80d3a 100644 --- a/docker-images/syntax-highlighter/rust-toolchain.toml +++ b/docker-images/syntax-highlighter/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.68.0" +channel = "1.69.0" # Keep in sync with /WORKSPACE and docker-images/syntax-highlighter/Dockerfile diff --git a/docker-images/syntax-highlighter/src/main.rs b/docker-images/syntax-highlighter/src/main.rs index 77ea258060bd..35aac5082887 100644 --- a/docker-images/syntax-highlighter/src/main.rs +++ b/docker-images/syntax-highlighter/src/main.rs @@ -75,7 +75,7 @@ fn symbols(q: Json) -> JsonValue { None => return json!({"error": "Could not infer parser from extension"}), }; - let document = match scip_syntax::get_symbols(&parser, q.content.as_bytes()) { + let document = match scip_syntax::get_symbols(parser, q.content.as_bytes()) { Ok(vals) => vals, Err(err) => { return jsonify_err(err);