This commit is contained in:
Christoph Hegemann 2024-08-14 15:24:28 -04:00 committed by GitHub
commit 9cc320d93f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 2583 additions and 1583 deletions

File diff suppressed because it is too large Load Diff

View File

@ -272,12 +272,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.0.83"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2"
[[package]]
name = "cfg-if"
@ -1132,9 +1129,9 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.5.0"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "memoffset"
@ -1703,14 +1700,14 @@ dependencies = [
[[package]]
name = "regex"
version = "1.9.3"
version = "1.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata 0.3.6",
"regex-syntax 0.7.4",
"regex-automata 0.4.7",
"regex-syntax 0.8.4",
]
[[package]]
@ -1727,10 +1724,16 @@ name = "regex-automata"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
[[package]]
name = "regex-automata"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.7.4",
"regex-syntax 0.8.4",
]
[[package]]
@ -1741,9 +1744,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.7.4"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
[[package]]
name = "rocket"
@ -2232,18 +2235,18 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]]
name = "thiserror"
version = "1.0.47"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f"
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.47"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b"
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
dependencies = [
"proc-macro2",
"quote",
@ -2457,9 +2460,8 @@ dependencies = [
[[package]]
name = "tree-sitter"
version = "0.20.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
version = "0.22.6"
source = "git+https://github.com/tree-sitter/tree-sitter?rev=d35e40185a8972cf7ce2b3cebdea8b1369d3789a#d35e40185a8972cf7ce2b3cebdea8b1369d3789a"
dependencies = [
"cc",
"regex",
@ -2490,7 +2492,7 @@ dependencies = [
"tree-sitter-ruby",
"tree-sitter-rust",
"tree-sitter-scala",
"tree-sitter-sql",
"tree-sitter-sequel",
"tree-sitter-typescript",
"tree-sitter-xlsg",
"tree-sitter-zig",
@ -2498,9 +2500,9 @@ dependencies = [
[[package]]
name = "tree-sitter-c"
version = "0.20.6"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30b03bdf218020057abee831581a74bff8c298323d6c6cd1a70556430ded9f4b"
checksum = "f956d5351d62652864a4ff3ae861747e7a1940dc96c9998ae400ac0d3ce30427"
dependencies = [
"cc",
"tree-sitter",
@ -2508,9 +2510,9 @@ dependencies = [
[[package]]
name = "tree-sitter-c-sharp"
version = "0.20.0"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9ab3dc608f34924fa9e10533a95f62dbc14b6de0ddd7107722eba66fe19ae31"
checksum = "8997ad04502208449025114e434c9024a33a74e700513c702a9d2cac6522a771"
dependencies = [
"cc",
"tree-sitter",
@ -2518,9 +2520,9 @@ dependencies = [
[[package]]
name = "tree-sitter-cpp"
version = "0.20.3"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b4b625f46a7370544b9cf0545532c26712ae49bfc02eb09825db358b9f79e1"
checksum = "1d509a22a992790d38f2c291961ff8a1ff016c437c7ec6befc9220b8eec8918c"
dependencies = [
"cc",
"tree-sitter",
@ -2529,7 +2531,7 @@ dependencies = [
[[package]]
name = "tree-sitter-dart"
version = "0.0.1"
source = "git+https://github.com/UserNobody14/tree-sitter-dart?rev=923fbe0d3e62340ea78422551166ce946bc05222#923fbe0d3e62340ea78422551166ce946bc05222"
source = "git+https://github.com/UserNobody14/tree-sitter-dart?rev=cf72df5d4a623ca705e81bf9e9d264e1fe9d5da0#cf72df5d4a623ca705e81bf9e9d264e1fe9d5da0"
dependencies = [
"cc",
"tree-sitter",
@ -2537,9 +2539,9 @@ dependencies = [
[[package]]
name = "tree-sitter-go"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad6d11f19441b961af2fda7f12f5d0dac325f6d6de83836a1d3750018cc5114"
checksum = "55cb318be5ccf75f44e054acf6898a5c95d59b53443eed578e16be0cd7ec037f"
dependencies = [
"cc",
"tree-sitter",
@ -2548,7 +2550,7 @@ dependencies = [
[[package]]
name = "tree-sitter-hack"
version = "0.0.4"
source = "git+https://github.com/slackhq/tree-sitter-hack?rev=fca1e294f6dce8ec5659233a6a21f5bd0ed5b4f2#fca1e294f6dce8ec5659233a6a21f5bd0ed5b4f2"
source = "git+https://github.com/kritzcreek/tree-sitter-hack?rev=2a1f331c3b43a2262823f788a222e15a264d1062#2a1f331c3b43a2262823f788a222e15a264d1062"
dependencies = [
"cc",
"tree-sitter",
@ -2556,10 +2558,10 @@ dependencies = [
[[package]]
name = "tree-sitter-highlight"
version = "0.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "042342584c5a7a0b833d9fc4e2bdab3f9868ddc6c4b339a1e01451c6720868bc"
version = "0.22.6"
source = "git+https://github.com/tree-sitter/tree-sitter?rev=d35e40185a8972cf7ce2b3cebdea8b1369d3789a#d35e40185a8972cf7ce2b3cebdea8b1369d3789a"
dependencies = [
"lazy_static",
"regex",
"thiserror",
"tree-sitter",
@ -2567,9 +2569,9 @@ dependencies = [
[[package]]
name = "tree-sitter-java"
version = "0.20.2"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2adc5696bf5abf761081d7457d2bb82d0e3b28964f4214f63fd7e720ef462653"
checksum = "33bc21adf831a773c075d9d00107ab43965e6a6ea7607b47fd9ec6f3db4b481b"
dependencies = [
"cc",
"tree-sitter",
@ -2577,9 +2579,9 @@ dependencies = [
[[package]]
name = "tree-sitter-javascript"
version = "0.20.0"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2490fab08630b2c8943c320f7b63473cbf65511c8d83aec551beb9b4375906ed"
checksum = "8710a71bc6779e33811a8067bdda3ed08bed1733296ff915e44faf60f8c533d7"
dependencies = [
"cc",
"tree-sitter",
@ -2588,7 +2590,7 @@ dependencies = [
[[package]]
name = "tree-sitter-jsonnet"
version = "0.0.1"
source = "git+https://github.com/sourcegraph/tree-sitter-jsonnet?rev=009e6f06266f46ae07077dd6c8026ded56ab7dd8#009e6f06266f46ae07077dd6c8026ded56ab7dd8"
source = "git+https://github.com/kritzcreek/tree-sitter-jsonnet?rev=bc147652f72a14c9627deae5c9c33a81e452d391#bc147652f72a14c9627deae5c9c33a81e452d391"
dependencies = [
"cc",
"tree-sitter",
@ -2596,8 +2598,9 @@ dependencies = [
[[package]]
name = "tree-sitter-kotlin"
version = "0.2.11"
source = "git+https://github.com/fwcd/tree-sitter-kotlin?rev=100d79fd96b56a1b99099a8d2f3c114b8687acfb#100d79fd96b56a1b99099a8d2f3c114b8687acfb"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54ff60aeb036f5762515ceb31404512ea4f9599764bcd3857074bb82867bdd34"
dependencies = [
"cc",
"tree-sitter",
@ -2606,7 +2609,7 @@ dependencies = [
[[package]]
name = "tree-sitter-magik"
version = "0.0.1"
source = "git+https://github.com/sourcegraph/tree-sitter-magik?rev=dfabbd4e70ff311939cf48fdf90d340f07758d37#dfabbd4e70ff311939cf48fdf90d340f07758d37"
source = "git+https://github.com/kritzcreek/tree-sitter-magik?rev=d7614f9820563598b0e1e009b3e4707f60af405f#d7614f9820563598b0e1e009b3e4707f60af405f"
dependencies = [
"cc",
"tree-sitter",
@ -2615,7 +2618,7 @@ dependencies = [
[[package]]
name = "tree-sitter-matlab"
version = "1.0.2"
source = "git+https://github.com/acristoffers/tree-sitter-matlab?rev=6071891a8c39600203eba20513666cf93b4d650a#6071891a8c39600203eba20513666cf93b4d650a"
source = "git+https://github.com/kritzcreek/tree-sitter-matlab?rev=762d3ac3daf68cff04c376a42fd793b0f81ab9c1#762d3ac3daf68cff04c376a42fd793b0f81ab9c1"
dependencies = [
"cc",
"tree-sitter",
@ -2623,8 +2626,8 @@ dependencies = [
[[package]]
name = "tree-sitter-nickel"
version = "0.0.1"
source = "git+https://github.com/nickel-lang/tree-sitter-nickel?rev=d6c7eeb751038f934b5b1aa7ff236376d0235c56#d6c7eeb751038f934b5b1aa7ff236376d0235c56"
version = "0.2.0"
source = "git+https://github.com/kritzcreek/tree-sitter-nickel?rev=46a808abaa3d0f460c859af3c3b9467641f13063#46a808abaa3d0f460c859af3c3b9467641f13063"
dependencies = [
"cc",
"tree-sitter",
@ -2633,7 +2636,7 @@ dependencies = [
[[package]]
name = "tree-sitter-perl"
version = "0.0.1"
source = "git+https://github.com/sourcegraph/tree-sitter-perl?rev=e1b4844afd17b7dc019a436b1ac890568d79a1f2#e1b4844afd17b7dc019a436b1ac890568d79a1f2"
source = "git+https://github.com/sourcegraph/tree-sitter-perl?rev=fa0118e558b788c7ebd8646d3d1eea42dcf321ee#fa0118e558b788c7ebd8646d3d1eea42dcf321ee"
dependencies = [
"cc",
"tree-sitter",
@ -2642,7 +2645,7 @@ dependencies = [
[[package]]
name = "tree-sitter-pkl"
version = "0.16.0"
source = "git+https://github.com/apple/tree-sitter-pkl?rev=b79c8c4d2419e82324d9aca31e9de47ed8304f1f#b79c8c4d2419e82324d9aca31e9de47ed8304f1f"
source = "git+https://github.com/kritzcreek/tree-sitter-pkl?rev=372ce76dfae3395fcf083df23328c4eb67cc0119#372ce76dfae3395fcf083df23328c4eb67cc0119"
dependencies = [
"cc",
"tree-sitter",
@ -2651,7 +2654,7 @@ dependencies = [
[[package]]
name = "tree-sitter-pod"
version = "0.0.1"
source = "git+https://github.com/sourcegraph/tree-sitter-pod?rev=f422a0dca6847c692e811f06fd92c6a75d647222#f422a0dca6847c692e811f06fd92c6a75d647222"
source = "git+https://github.com/sourcegraph/tree-sitter-pod?rev=b99354aaa6b11c6d9edda3285567d94ed02c0e34#b99354aaa6b11c6d9edda3285567d94ed02c0e34"
dependencies = [
"cc",
"tree-sitter",
@ -2659,9 +2662,9 @@ dependencies = [
[[package]]
name = "tree-sitter-python"
version = "0.20.4"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c93b1b1fbd0d399db3445f51fd3058e43d0b4dcff62ddbdb46e66550978aa5"
checksum = "b4066c6cf678f962f8c2c4561f205945c84834cce73d981e71392624fdc390a9"
dependencies = [
"cc",
"tree-sitter",
@ -2669,9 +2672,9 @@ dependencies = [
[[package]]
name = "tree-sitter-ruby"
version = "0.20.0"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ac30cbb1560363ae76e1ccde543d6d99087421e228cc47afcec004b86bb711a"
checksum = "c0031f687c0772f2dad7b77104c43428611099a1804c81244ada21560f41f0b1"
dependencies = [
"cc",
"tree-sitter",
@ -2679,9 +2682,9 @@ dependencies = [
[[package]]
name = "tree-sitter-rust"
version = "0.20.4"
version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0832309b0b2b6d33760ce5c0e818cb47e1d72b468516bfe4134408926fa7594"
checksum = "277690f420bf90741dea984f3da038ace46c4fe6047cba57a66822226cde1c93"
dependencies = [
"cc",
"tree-sitter",
@ -2689,18 +2692,19 @@ dependencies = [
[[package]]
name = "tree-sitter-scala"
version = "0.20.2"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93df43ab4f2b3299fe97e73eb9b946bbca453b402bea8debf1fa69ab4e28412b"
checksum = "a464d8e2e1837cf20b34204c51c369da3483e55c3ea013c6db81a04439e17895"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-sql"
version = "0.0.2"
source = "git+https://github.com/sourcegraph/tree-sitter-sql?rev=6ea62b8d33c9e39f6de8a398a6885d1873ed7e91#6ea62b8d33c9e39f6de8a398a6885d1873ed7e91"
name = "tree-sitter-sequel"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e39194c44ad71033d8b09d225c03e154dee9b788c6a113bce7feb809f39480f"
dependencies = [
"cc",
"tree-sitter",
@ -2708,9 +2712,9 @@ dependencies = [
[[package]]
name = "tree-sitter-typescript"
version = "0.20.2"
version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "079c695c32d39ad089101c66393aeaca30e967fba3486a91f573d2f0e12d290a"
checksum = "ecb35d98a688378e56c18c9c159824fd16f730ccbea19aacf4f206e5d5438ed9"
dependencies = [
"cc",
"tree-sitter",
@ -2719,7 +2723,7 @@ dependencies = [
[[package]]
name = "tree-sitter-xlsg"
version = "0.0.1"
source = "git+https://github.com/sourcegraph/tree-sitter-xlsg?rev=d956b54ea151b12f19c945f7be421c3dcd3a77ba#d956b54ea151b12f19c945f7be421c3dcd3a77ba"
source = "git+https://github.com/sourcegraph/tree-sitter-xlsg?rev=deb2a12e617ad5e3720a1464848949cc46b375be#deb2a12e617ad5e3720a1464848949cc46b375be"
dependencies = [
"cc",
"tree-sitter",
@ -2728,7 +2732,7 @@ dependencies = [
[[package]]
name = "tree-sitter-zig"
version = "0.0.1"
source = "git+https://github.com/maxxnino/tree-sitter-zig?rev=2c7b6308d906d7aec4b3e1fafaaeca447a8a2c2f#2c7b6308d906d7aec4b3e1fafaaeca447a8a2c2f"
source = "git+https://github.com/maxxnino/tree-sitter-zig?rev=2bac4cc6c697d46a193905fef6d003bfa0bfabfd#2bac4cc6c697d46a193905fef6d003bfa0bfabfd"
dependencies = [
"cc",
"tree-sitter",

View File

@ -29,8 +29,12 @@ syntax-analysis = { path = "./crates/syntax-analysis" }
# we can remove this, but until then, this works just fine for building
# with bazel (and we rarely update rocket, so this is fine).
futures = { version = "^0.3.27", features = ["std"], default-features = false }
futures-util = { version = "^0.3.27", features = ["std"], default-features = false }
futures-task = { version = "^0.3.27", features = ["std"], default-features = false }
futures-util = { version = "^0.3.27", features = [
"std",
], default-features = false }
futures-task = { version = "^0.3.27", features = [
"std",
], default-features = false }
# Prior version do not build when cross-compiling. It's needed by transitive deps
# and this forces to bump it.
@ -43,6 +47,10 @@ members = [
"crates/scip-syntax",
]
[patch.crates-io]
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "d35e40185a8972cf7ce2b3cebdea8b1369d3789a" }
tree-sitter-highlight = { git = "https://github.com/tree-sitter/tree-sitter", rev = "d35e40185a8972cf7ce2b3cebdea8b1369d3789a" }
[workspace.dependencies]
anyhow = "1"
# "cargo" feature is enabled for using the `crate_version` macro
@ -56,8 +64,8 @@ serde_json = "1.0"
string-interner = "0.14.0"
# Since there is no version tag, we pin the dependency to a specific revision
syntect = { git = "https://github.com/sourcegraph/syntect", rev = "7e02c5b4085e6d935b960b8106cdd85da04532d2" }
tree-sitter = "0.20.9"
tree-sitter-highlight = "0.20.1"
tree-sitter = "0.22.6"
tree-sitter-highlight = "0.22.6"
walkdir = "2"
path-clean = "1"
camino = "1.1"

View File

@ -1,3 +1,46 @@
(identifier) @identifier
(field_identifier) @identifier ;; TODO: something better
(statement_identifier) @identifier
(type_identifier) @type
(primitive_type) @type.builtin
(sized_type_specifier) @type
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
"break" @keyword
"case" @keyword
"const" @keyword
"continue" @keyword
"default" @keyword
"do" @keyword
"else" @keyword
"enum" @keyword
"extern" @keyword
"for" @keyword
"if" @keyword
"inline" @keyword
"return" @keyword
"sizeof" @keyword
"static" @keyword
"struct" @keyword
"switch" @keyword
"typedef" @keyword
"union" @keyword
"volatile" @keyword
"while" @keyword
"#define" @keyword
"#elif" @keyword
"#else" @keyword
"#endif" @keyword
"#if" @keyword
"#ifdef" @keyword
"#ifndef" @keyword
"#include" @keyword
(preproc_directive) @keyword
"--" @identifier.operator
"-" @identifier.operator
"-=" @identifier.operator
@ -38,47 +81,4 @@
(preproc_function_def
name: (identifier) @identifier.function)
(field_identifier) @identifier ;; TODO: something better
(statement_identifier) @identifier
(type_identifier) @type
(primitive_type) @type.builtin
(sized_type_specifier) @type
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
(identifier) @identifier
(comment) @comment
"break" @keyword
"case" @keyword
"const" @keyword
"continue" @keyword
"default" @keyword
"do" @keyword
"else" @keyword
"enum" @keyword
"extern" @keyword
"for" @keyword
"if" @keyword
"inline" @keyword
"return" @keyword
"sizeof" @keyword
"static" @keyword
"struct" @keyword
"switch" @keyword
"typedef" @keyword
"union" @keyword
"volatile" @keyword
"while" @keyword
"#define" @keyword
"#elif" @keyword
"#else" @keyword
"#endif" @keyword
"#if" @keyword
"#ifdef" @keyword
"#ifndef" @keyword
"#include" @keyword
(preproc_directive) @keyword

View File

@ -1,42 +1,15 @@
(identifier) @variable
;; Methods
(method_declaration name: (identifier) @method)
(local_function_statement name: (identifier) @function)
(using_directive (identifier) @variable.module)
(qualified_name (identifier) @variable.module)
;; Preprocessors
(if_directive (identifier) @identifier.constant) @keyword
(endif_directive) @keyword
(elif_directive (identifier) @identifier.constant) @keyword
(else_directive) @keyword
(error_directive "error" @keyword)
(warning_directive "warning" @keyword)
(preproc_message) @string
;; Methods
(method_declaration name: (identifier) @method)
(invocation_expression
(member_access_expression
(generic_name
(identifier) @method)))
(invocation_expression
(member_access_expression
name: (identifier) @method))
(invocation_expression
function: (conditional_access_expression
(member_binding_expression
name: (identifier) @method)))
(invocation_expression
(identifier) @method)
(invocation_expression
function: (generic_name
. (identifier) @method))
;; Types
(variable_declaration type: (identifier) @type)
(interface_declaration name: (identifier) @type)
(class_declaration name: (identifier) @type)
(enum_declaration name: (identifier) @type)
@ -44,184 +17,39 @@
(record_declaration (identifier) @type)
(namespace_declaration name: (identifier) @type)
(object_creation_expression type: (identifier) @type)
(method_declaration type: (identifier) @type)
(method_declaration returns: (identifier) @type)
(variable_declaration type: (identifier) @type)
(property_declaration type: (identifier) @type)
(parameter type: (identifier) @type name: (identifier) @variable.parameter)
(constructor_declaration name: (identifier) @type)
(destructor_declaration name: (identifier) @type)
;; Parameter
(parameter (identifier) @variable.parameter)
(parameter
type: (identifier) @type
name: (identifier) @variable.parameter)
[
(implicit_type)
(nullable_type)
(pointer_type)
(function_pointer_type)
(predefined_type)]
@type.builtin
;; Enum
(enum_member_declaration (identifier) @identifier.constant)
;; Literals
[
(real_literal)
(integer_literal)]
@number
[
(character_literal)
(string_literal)
(verbatim_string_literal)
(interpolated_string_text)
(interpolated_verbatim_string_text)
"\""
"$\""
"@$\""
"$@\""] @string
(interpolation ["{" "}"] @string.escape)
[
(boolean_literal)
(null_literal)
(void_keyword)] @constant.builtin
;; Comments
(comment) @comment
;; Operator
(operator_declaration ["+" "-" "true" "false" "==" "!="] @method)
;; Tokens
[
";"
"."
","] @punctuation.delimiter
[
"--"
"-"
"-="
"&"
"&&"
"+"
"++"
"+="
"<"
"<<"
"="
"=="
"!"
"!="
"=>"
">"
">>"
"|"
"||"
"?"
"??"
"^"
"~"
"*"
"/"
"%"
":"] @operator
[
"("
")"
"["
"]"
"{"
"}"] @punctuation.bracket
;; Keywords
(modifier) @keyword
(this_expression) @keyword
(escape_sequence) @keyword
[
"as"
"base"
"break"
"case"
"catch"
"checked"
"class"
"continue"
"default"
"delegate"
"do"
"else"
"enum"
"event"
"explicit"
"finally"
"for"
"foreach"
"goto"
"if"
"implicit"
"interface"
"is"
"lock"
"namespace"
"operator"
"params"
"return"
"sizeof"
"stackalloc"
"struct"
"switch"
"throw"
"try"
"typeof"
"unchecked"
"using"
"while"
"new"
"await"
"in"
"yield"
"get"
"set"
"when"
"out"
"ref"
"from"
"join"
"on"
"equals"
"var"
"where"
"select"
"record"
"init"
"with"
"this"
"unmanaged"
"notnull"
"let"] @keyword
;; Linq
(from_clause (identifier) @variable)
(group_clause)
(order_by_clause)
(select_clause (identifier) @variable)
(query_continuation (identifier) @variable) @keyword
;; Record
(with_expression
(with_initializer_expression
(simple_assignment_expression
(identifier) @variable)))
;; event
(event_declaration (accessor_list (accessor_declaration ["add" "remove"] @keyword)))
(predefined_type)
] @type.builtin
;; Class
(base_list (identifier) @type)
;; Preprocessors
(preproc_if condition: (identifier) @identifier.constant)
(preproc_elif condition: (identifier) @identifier.constant)
(preproc_arg) @string
;; Members
; The constructor_declaration queries below assume that the left-hand side of
@ -235,8 +63,196 @@
(member_access_expression name: (identifier) @identifier.attribute)
(property_declaration name: (identifier) @identifier.attribute)
(initializer_expression (assignment_expression left: (identifier) @identifier.attribute))
(attribute_argument (name_equals . (identifier) @identifier.attribute))
(invocation_expression
(member_access_expression
(generic_name
(identifier) @identifier.function)))
(invocation_expression
(member_access_expression
name: (identifier) @identifier.function))
(invocation_expression
function: (conditional_access_expression
(member_binding_expression
name: (identifier) @identifier.function)))
(invocation_expression
(identifier) @identifier.function)
(invocation_expression
function: (generic_name
. (identifier) @identifier.function))
;; Enum
(enum_member_declaration (identifier) @identifier.constant)
;; Literals
[
(real_literal)
(integer_literal)
] @number
[
(character_literal)
(string_literal)
(raw_string_literal)
(verbatim_string_literal)
(interpolated_string_expression)
(interpolation_start)
(interpolation_quote)
(escape_sequence)
]@string
[
(boolean_literal)
(null_literal)
] @constant.builtin
;; Comments
(comment) @comment
;; Operator
[
"--"
"-"
"-="
"&"
"&="
"&&"
"+"
"++"
"+="
"<"
"<="
"<<"
"<<="
"="
"=="
"!"
"!="
"=>"
">"
">="
">>"
">>="
">>>"
">>>="
"|"
"|="
"||"
"?"
"??"
"??="
"^"
"^="
"~"
"*"
"*="
"/"
"/="
"%"
"%="
":"
] @operator
(operator_declaration ["+" "-" "true" "false" "==" "!="] @method)
;; Tokens
[
";"
"."
","
] @punctuation.delimiter
[
"("
")"
"["
"]"
"{"
"}"
(interpolation_brace)
] @punctuation.bracket
;; Keywords
[
(modifier)
"this"
(implicit_type)
] @keyword
[
"as"
"await"
"base"
"break"
"case"
"catch"
"checked"
"class"
"continue"
"default"
"delegate"
"do"
"else"
"enum"
"equals"
"event"
"explicit"
"finally"
"for"
"foreach"
"from"
"get"
"goto"
"if"
"implicit"
"in"
"init"
"interface"
"is"
"join"
"let"
"lock"
"namespace"
"new"
"notnull"
"on"
"operator"
"out"
"params"
"record"
"ref"
"return"
"select"
"set"
"sizeof"
"stackalloc"
"static"
"struct"
"switch"
"this"
"throw"
"try"
"typeof"
"unchecked"
"unmanaged"
"using"
"var"
"when"
"where"
"while"
"with"
"yield"
] @keyword
;; event
(event_declaration (accessor_list (accessor_declaration ["add" "remove"] @keyword)))
; (initializer_expression (assignment_expression left: (identifier) @identifier.attribute))
; (attribute_argument (name_equals . (identifier) @identifier.attribute))
(field_declaration (variable_declaration (variable_declarator . (identifier) @identifier.attribute)))
;; Lambda
@ -245,22 +261,13 @@
;; Attribute
(attribute name: (identifier) @type)
;; Parameter
(parameter type: (identifier) @type name: (identifier) @variable.parameter)
(parameter (identifier) @variable.parameter)
(parameter_modifier) @keyword
;; Sunset restricted types
(make_ref_expression "__makeref" @keyword)
(ref_value_expression "__refvalue" @keyword)
(ref_type_expression "__reftype" @keyword)
"__makeref" @keyword
"__refvalue" @keyword
"__reftype" @keyword
;; Typeof
(type_of_expression (identifier) @type)
;; Return
(return_statement (identifier) @variable)
(yield_statement (identifier) @variable)
; (type_of_expression (identifier) @type)
;; Type
(generic_name (identifier) @type)
@ -269,18 +276,8 @@
;; Type constraints
(type_parameter_constraints_clause (identifier) @property.definition)
(type_constraint (identifier) @type)
(type_parameter_constraint (identifier) @type)
;; Exception
(catch_declaration (identifier) @type (identifier) @variable)
(catch_declaration (identifier) @type)
;; Switch
(switch_statement (identifier) @variable)
(switch_expression (identifier) @variable)
;; Lock statement
(lock_statement (identifier) @variable)
(identifier) @variable

View File

@ -1,3 +1,21 @@
(literal_suffix) @identifier
(identifier) @identifier
(namespace_identifier) @identifier.module
(field_identifier) @identifier.attribute
(statement_identifier) @identifier.attribute
(type_identifier) @type
(primitive_type) @type.builtin
(sized_type_specifier) @type.builtin
(static_assert_declaration ("static_assert") @identifier.builtin)
(attribute name: (identifier) @identifier.attribute)
(this) @constant.builtin
(comment) @comment
(operator_name "operator" @keyword)
(operator_name) @identifier
(auto) @keyword
(string_literal) @string
(system_lib_string) @string
(raw_string_literal) @string
@ -24,24 +42,6 @@
(preproc_function_def
name: (identifier) @identifier.function)
(attribute name: (identifier) @identifier.attribute)
(field_identifier) @identifier.attribute
(statement_identifier) @identifier.attribute
(type_identifier) @type
(static_assert_declaration ("static_assert") @identifier.builtin)
(primitive_type) @type.builtin
(sized_type_specifier) @type.builtin
(literal_suffix) @identifier
(identifier) @identifier
(namespace_identifier) @identifier.module
(this) @constant.builtin
(comment) @comment
(operator_name "operator" @keyword)
(operator_name) @identifier
(auto) @keyword
[
"#define"
"#elif"
@ -65,7 +65,6 @@
"protected"
"private"
"final"
"virtual"
"friend"
"goto"
"do"
@ -96,4 +95,5 @@
"volatile"
"constexpr"
"while"
(virtual)
(preproc_directive)] @keyword

View File

@ -1,177 +1,5 @@
; Methods
; --------------------
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
; specifically identify a node as a function call
(((identifier) @function (#match? @function "^_?[a-z]"))
. (selector . (argument_part))) @function
; Annotations
; --------------------
(annotation
name: (identifier) @attribute)
; Operators and Tokens
; --------------------
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special
) @none
(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @none
(escape_sequence) @string.escape
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)
(type_parameters
"<" @punctuation.bracket
">" @punctuation.bracket)
[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
"~/"
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator
; Delimiters
; --------------------
[
";"
"."
","
] @punctuation.delimiter
; Types
; --------------------
((type_identifier) @type.builtin
(#match? @type.builtin "^(int|double|String|bool|List|Set|Map|Runes|Symbol)$"))
(type_identifier) @type
(class_definition
name: (identifier) @type)
(constructor_signature
name: (identifier) @type)
(scoped_identifier
scope: (identifier) @type)
(function_signature
name: (identifier) @function)
(getter_signature
(identifier) @function)
(setter_signature
name: (identifier) @function)
(type_identifier) @type
((scoped_identifier
scope: (identifier) @type
name: (identifier) @type)
(#match? @type "^[a-zA-Z]"))
; Enums
; -------------------
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @identifier.constant)
; Variables
; --------------------
; var keyword
(inferred_type) @keyword
((identifier) @type
(#match? @type "^_?[A-Z].*[a-z]"))
("Function" @type)
(this) @variable.builtin
; properties
((selector
(unconditional_assignable_selector (identifier) @function))
(selector (argument_part (arguments)))
)
(cascade_section
(cascade_selector (identifier) @function)
(argument_part (arguments))
)
(unconditional_assignable_selector
(identifier) @property)
(conditional_assignable_selector
(identifier) @property)
(cascade_section
(cascade_selector
(identifier) @property))
; assignments
(assignment_expression
left: (assignable_expression) @variable)
(this) @variable.builtin
; Parameters
; --------------------
(formal_parameter
name: (identifier) @identifier.parameter)
(named_argument
(label (identifier) @identifier.parameter))
; Literals
; --------------------
[
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessbile nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
] @number
(string_literal) @string
(symbol_literal (identifier) @constant) @constant
(true) @boolean
(false) @boolean
(null_literal) @constant.null
(documentation_comment) @comment
(comment) @comment
; Variable
(identifier) @variable
; Keywords
; --------------------
@ -242,5 +70,177 @@
"yield"
] @keyword
; Variable
(identifier) @variable
; Methods
; --------------------
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
; specifically identify a node as a function call
(((identifier) @function (#match? @function "^_?[a-z]"))
. (selector . (argument_part))) @function
; Annotations
; --------------------
(annotation
name: (identifier) @attribute)
; Operators and Tokens
; --------------------
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special
) @none
(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @none
(escape_sequence) @string.escape
[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
"~/"
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator
(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)
(type_parameters
"<" @punctuation.bracket
">" @punctuation.bracket)
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
; Delimiters
; --------------------
[
";"
"."
","
] @punctuation.delimiter
; Types
; --------------------
(type_identifier) @type
((type_identifier) @type.builtin
(#match? @type.builtin "^(int|double|String|bool|List|Set|Map|Runes|Symbol)$"))
(class_definition
name: (identifier) @type)
(constructor_signature
name: (identifier) @type)
(scoped_identifier
scope: (identifier) @type)
(function_signature
name: (identifier) @function)
(getter_signature
(identifier) @function)
(setter_signature
name: (identifier) @function)
((scoped_identifier
scope: (identifier) @type
name: (identifier) @type)
(#match? @type "^[a-zA-Z]"))
; Enums
; -------------------
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @identifier.constant)
; Variables
; --------------------
; var keyword
(inferred_type) @keyword
((identifier) @type
(#match? @type "^_?[A-Z].*[a-z]"))
("Function" @type)
(this) @variable.builtin
; properties
(unconditional_assignable_selector
(identifier) @property)
(conditional_assignable_selector
(identifier) @property)
(cascade_section
(cascade_selector
(identifier) @property))
((selector
(unconditional_assignable_selector (identifier) @function))
(selector (argument_part (arguments)))
)
(cascade_section
(cascade_selector (identifier) @function)
(argument_part (arguments))
)
; assignments
(assignment_expression
left: (assignable_expression) @variable)
(this) @variable.builtin
; Parameters
; --------------------
(formal_parameter
name: (identifier) @identifier.parameter)
(named_argument
(label (identifier) @identifier.parameter))
; Literals
; --------------------
[
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessbile nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
] @number
(string_literal) @string
(symbol_literal (identifier) @constant) @constant
(true) @boolean
(false) @boolean
(null_literal) @constant.null
(documentation_comment) @comment
(comment) @comment

View File

@ -1,36 +1,64 @@
;; Builtin types
; Identifiers
(identifier) @variable
(field_identifier) @identifier.property
(package_identifier) @variable.module
(type_identifier) @type
((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]+$"))
((identifier) @constant (#eq? @constant "_"))
(keyed_element . (literal_element (identifier) @identifier.attribute))
; Literals
(interpreted_string_literal) @string
(raw_string_literal) @string
(rune_literal) @string
(escape_sequence) @string.escape
(int_literal) @number
(float_literal) @float
(imaginary_literal) @number
(true) @boolean
(false) @boolean
(nil) @constant.null
(comment) @comment
; Builtin types
((type_identifier) @type.builtin
(#match? @type.builtin
"^(bool|byte|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$"))
;; Builtin functions
((identifier) @function.builtin
(#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
; Function calls
(parameter_declaration (identifier) @variable.parameter)
(variadic_parameter_declaration (identifier) @variable.parameter)
(call_expression
function: (identifier) @identifer.function)
function: (identifier) @identifier.function)
(call_expression
function: (selector_expression
field: (field_identifier) @identifier.function))
; Builtin functions
((identifier) @function.builtin
(#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
; Function definitions
(method_spec
(method_elem
name: (field_identifier) @identifier.function)
(function_declaration
name: (identifier) @identifier.function)
(method_declaration
name: (field_identifier) @identifier.function)
(type_parameter_declaration
name: (identifier) @identifier.parameter)
; Constants
@ -38,7 +66,6 @@
name: (identifier) @constant)
; Operators
[
"--"
"-"
@ -111,35 +138,3 @@
"case"
"switch"
"if"] @conditional
; Literals
(interpreted_string_literal) @string
(raw_string_literal) @string
(rune_literal) @string
(escape_sequence) @string.escape
(int_literal) @number
(float_literal) @float
(imaginary_literal) @number
(true) @boolean
(false) @boolean
(nil) @constant.null
(comment) @comment
;;
; Identifiers
(package_identifier) @variable.module
(type_identifier) @type
(keyed_element . (literal_element (identifier) @identifier.attribute))
((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]+$"))
((identifier) @constant (#eq? @constant "_"))
(identifier) @variable
(field_identifier) @identifier.property

View File

@ -53,5 +53,5 @@
(const_spec name: (_) @descriptor.term) @kind.constant @enclosing
(import_spec name: (_) @descriptor.term) @enclosing
(method_spec name: (_) @descriptor.method @kind.methodspec) @enclosing
(method_elem name: (_) @descriptor.method @kind.methodspec) @enclosing
(var_spec name: (_) @descriptor.term @kind.variable) @enclosing

View File

@ -4,35 +4,39 @@
; > docker run -v /local/path:/mount/path --tty --interactive hhvm/hhvm:latest /bin/bash -l
; > hhvm --version
(variable) @variable
((variable) @variable.builtin
(#eq? @variable.builtin "$this"))
(identifier) @variable
(pipe_variable) @variable
[
(array_type)
"arraykey"
"bool"
"dynamic"
"float"
"int"
"mixed"
"nonnull"
"noreturn"
"nothing"
"num"
"shape" ; also a keyword, but prefer highlighting as a type
"string"
"tuple" ; also a keyword, but prefer highlighting as a type
"void"
] @type.builtin
(type_specifier) @type
(type_specifier (qualified_identifier (identifier) @type))
[
(comment)
(xhp_comment)
] @comment
(scope_identifier) @keyword
(visibility_modifier) @keyword
(xhp_open
[
"<"
">"
] @tag.delimiter)
(xhp_close
[
"</"
">"
] @tag.delimiter)
(xhp_open_close
[
"<"
"/>"
] @tag.delimiter)
(new_expression
. (_) @type)
[
(abstract_modifier)
@ -42,6 +46,8 @@
(xhp_modifier)
(inout_modifier)
(reify_modifier)
(scope_identifier)
(visibility_modifier)
"?as"
"as"
"as"
@ -95,8 +101,13 @@
"yield"
] @keyword
(new_expression
. (_) @type)
[
"."
";"
"::"
":"
","
] @punctuation.delimiter
(new_expression
(qualified_identifier
@ -110,24 +121,6 @@
name: (xhp_identifier) @variable
)
[
(array_type)
"arraykey"
"bool"
"dynamic"
"float"
"int"
"mixed"
"nonnull"
"noreturn"
"nothing"
"num"
"shape" ; also a keyword, but prefer highlighting as a type
"string"
"tuple" ; also a keyword, but prefer highlighting as a type
"void"
] @type.builtin
(shape_type_specifier (open_modifier)) @type.builtin
(field_specifier (optional_modifier) @identifier.operator)
@ -170,75 +163,6 @@
"@lateinit"
] @identifier.attribute
[
"="
"??="
".="
"|="
"^="
"&="
"<<="
">>="
"+="
"-="
"*="
"/="
"%="
"**="
"==>"
"|>"
"??"
"||"
"&&"
"|"
"^"
"&"
"=="
"!="
"==="
"!=="
"<"
">"
"<="
">="
"<=>"
"<<"
">>"
"->"
"+"
"-"
"."
"*"
"/"
"%"
"**"
"++"
"--"
"!"
"?:"
"="
"??="
".="
"|="
"^="
"&="
"<<="
">>="
"+="
"-="
"*="
"/="
"%="
"**="
"=>"
; type modifiers
"@"
"?"
"~"
"?->"
"->"
] @operator
[
(integer)
(float)
@ -247,10 +171,13 @@
(parameter
(variable) @variable.parameter)
(call_expression
function: (scoped_identifier
(identifier) @function.call .))
(call_expression
function: (qualified_identifier
(identifier) @keyword .)
(#match? @keyword "(invariant|exit)"))
(identifier) @function.call .))
(call_expression
function: (qualified_identifier
@ -259,11 +186,9 @@
(call_expression
function: (qualified_identifier
(identifier) @function.call .))
(identifier) @keyword .)
(#match? @keyword "(invariant|exit)"))
(call_expression
function: (scoped_identifier
(identifier) @function.call .))
(call_expression
function: (selection_expression
@ -387,14 +312,6 @@
":"
] @identifier.operator)
[
"."
";"
"::"
":"
","
] @punctuation.delimiter
(qualified_identifier
"\\" @punctuation.delimiter)
@ -404,13 +321,92 @@
(heredoc)
] @string
[
"="
"??="
".="
"|="
"^="
"&="
"<<="
">>="
"+="
"-="
"*="
"/="
"%="
"**="
"==>"
"|>"
"??"
"||"
"&&"
"|"
"^"
"&"
"=="
"!="
"==="
"!=="
"<"
">"
"<="
">="
"<=>"
"<<"
">>"
"->"
"+"
"-"
"."
"*"
"/"
"%"
"**"
"++"
"--"
"!"
"?:"
"="
"??="
".="
"|="
"^="
"&="
"<<="
">>="
"+="
"-="
"*="
"/="
"%="
"**="
"=>"
; type modifiers
"@"
"?"
"~"
"?->"
"->"
] @operator
(xhp_open
[
"<"
">"
] @tag.delimiter)
(xhp_close
[
"</"
">"
] @tag.delimiter)
(xhp_open_close
[
"<"
"/>"
] @tag.delimiter)
(xhp_open (xhp_identifier) @tag (xhp_attribute)? @tag.attribute)
(xhp_close (xhp_identifier) @tag (xhp_attribute)? @tag.attribute)
(xhp_open_close (xhp_identifier) @tag (xhp_attribute)? @tag.attribute)
(type_specifier (qualified_identifier (identifier) @type))
(type_specifier) @type
(variable) @variable
(identifier) @variable
(pipe_variable) @variable

View File

@ -1,3 +1,13 @@
; Variables
(this) @identifier.builtin
(identifier) @identifier
((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
; Methods
(method_declaration
@ -40,8 +50,7 @@
(#match? @identifier.type "^[A-Z]"))
(record_pattern
(identifier) @identifier.type
)
(identifier) @identifier.type)
(constructor_declaration
name: (identifier) @identifier.type)
@ -54,15 +63,6 @@
(void_type)]
@identifier.builtin
; Variables
((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
(identifier) @identifier
(this) @identifier.builtin
; Literals
[

View File

@ -1,20 +1,11 @@
;; This file inherits from javascript/highlights.scm
;; This file should be kept in sync with tsx/highlights.scm
(jsx_opening_element
"<" @tag.delimiter
name: (identifier) @tag
">" @tag.delimiter)
; We need to match the tag characters individually since the version of the grammar we are using (v0.20.0) defines them that way
; when we update to the newest version we can remove this
(jsx_closing_element
["<" "/"] @tag.delimiter
name: (identifier) @tag
">" @tag.delimiter)
(jsx_self_closing_element
"<" @tag.delimiter
name: (identifier) @tag
["/" ">"] @tag.delimiter)
(jsx_attribute (property_identifier) @tag.attribute)
(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
(jsx_attribute (property_identifier) @tag.attribute)
(jsx_opening_element (["<" ">"]) @tag.delimiter)
(jsx_closing_element (["</" ">"]) @tag.delimiter)
(jsx_self_closing_element (["<" "/>"]) @tag.delimiter)

View File

@ -1,10 +1,23 @@
;; This file is adjusted from te original queries in
;; https://sourcegraph.com/github.com/tree-sitter/tree-sitter-javascript@15e85e80b851983fab6b12dce5a535f5a0df0f9c/-/blob/queries/highlights.scm
; Variables
;----------
(identifier) @variable
; Properties
;----------
(property_identifier) @property
(object (shorthand_property_identifier) @identifier)
(shorthand_property_identifier_pattern) @identifier
(shorthand_property_identifier) @identifier.attribute
(pair key: (property_identifier) @identifier.attribute)
; Function and method definitions
;--------------------------------
(function
(function_expression
name: (identifier) @identifier.function)
(function_declaration
name: (identifier) @identifier.function)
@ -13,20 +26,20 @@
(pair
key: (property_identifier) @identifier.function
value: [(function) (arrow_function)])
value: [(function_expression) (arrow_function)])
(assignment_expression
left: (member_expression
property: (property_identifier) @identifier.function)
right: [(function) (arrow_function)])
right: [(function_expression) (arrow_function)])
(variable_declarator
name: (identifier) @identifier.function
value: [(function) (arrow_function)])
value: [(function_expression) (arrow_function)])
(assignment_expression
left: (identifier) @identifier.function
right: [(function) (arrow_function)])
right: [(function_expression) (arrow_function)])
; Function and method calls
;--------------------------
@ -38,17 +51,6 @@
function: (member_expression
property: (property_identifier) @identifier.function))
; Variables
;----------
(pair key: (property_identifier) @identifier.attribute)
(shorthand_property_identifier) @identifier.attribute
(identifier) @variable
(property_identifier) @identifier
(shorthand_property_identifier_pattern) @identifier
(object (shorthand_property_identifier) @identifier)
(property_identifier) @property
; Literals
;---------
@ -64,12 +66,12 @@
(comment) @comment
[
(string_fragment)
(template_string)]
@string
(string ("\"" @string))
(string ("'" @string))
[
(string_fragment)
(template_string)
] @string
(regex) @string.special
(number) @number

View File

@ -17,13 +17,13 @@
(object
(pair
key: (property_identifier) @descriptor.method @kind.function
value: [(function) (arrow_function)]))
value: [(function_expression) (arrow_function)]))
((object
(pair
key: (property_identifier) @descriptor.term @kind.property
value: (_) @_value_type))
(#filter! @_value_type "function" "arrow_function"))
(#filter! @_value_type "function_expression" "arrow_function"))
;; }}}
;; class X { ... }

View File

@ -33,8 +33,21 @@
(number) @number
[ (true) (false) ] @boolean
[ (self) (dollar) ] @constant.builtin
(binaryop) @operator
(unaryop) @operator
; Operators
[
(multiplicative)
(additive)
(bitshift)
(comparison)
(equality)
(bitand)
(bitxor)
(bitor)
(and)
(or)
(unaryop)
] @operator
; It's possible for us to give a "special" highlight to

View File

@ -1,3 +1,16 @@
; Basics
(simple_identifier) @identifier
((simple_identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]*$"))
(type_identifier) @identifier.type
(interpolated_identifier) @identifier
; `this` keyword inside classes
(this_expression) @identifier.builtin
; `super` keyword inside classes
(super_expression) @identifier.builtin
;;; Annotations
(annotation
@ -58,11 +71,6 @@
;;; Function calls
(call_expression
. (simple_identifier) @function.builtin
(#match? @function.builtin "^(arrayOf|arrayOfNulls|byteArrayOf|shortArrayOf|intArrayOf|longArrayOf|ubyteArrayOf|ushortArrayOf|uintArrayOf|ulongArrayOf|floatArrayOf|doubleArrayOf|booleanArrayOf|charArrayOf|emptyArray|mapOf|setOf|listOf|emptyMap|emptySet|emptyList|mutableMapOf|mutableSetOf|mutableListOf|print|println|error|TODO|run|runCatching|repeat|lazy|lazyOf|enumValues|enumValueOf|assert|check|checkNotNull|require|requireNotNull|with|suspend|synchronized)$"
))
; function()
(call_expression
. (simple_identifier) @identifier.function)
@ -77,20 +85,13 @@
(navigation_suffix
(simple_identifier) @identifier.function) . ))
(call_expression
. (simple_identifier) @function.builtin
(#match? @function.builtin "^(arrayOf|arrayOfNulls|byteArrayOf|shortArrayOf|intArrayOf|longArrayOf|ubyteArrayOf|ushortArrayOf|uintArrayOf|ulongArrayOf|floatArrayOf|doubleArrayOf|booleanArrayOf|charArrayOf|emptyArray|mapOf|setOf|listOf|emptyMap|emptySet|emptyList|mutableMapOf|mutableSetOf|mutableListOf|print|println|error|TODO|run|runCatching|repeat|lazy|lazyOf|enumValues|enumValueOf|assert|check|checkNotNull|require|requireNotNull|with|suspend|synchronized)$"
))
;;; Identifiers
; Basics
((simple_identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]*$"))
(simple_identifier) @identifier
(interpolated_identifier) @identifier
; `this` keyword inside classes
(this_expression) @identifier.builtin
; `super` keyword inside classes
(super_expression) @identifier.builtin
(enum_entry
(simple_identifier) @constant)
@ -100,7 +101,6 @@
(#match? @type.builtin "^(Byte|Short|Int|Long|UByte|UShort|UInt|ULong|Float|Double|Boolean|Char|String|Array|ByteArray|ShortArray|IntArray|LongArray|UByteArray|UShortArray|UIntArray|ULongArray|FloatArray|DoubleArray|BooleanArray|CharArray|Map|Set|List|EmptyMap|EmptySet|EmptyList|MutableMap|MutableSet|MutableList)$"
))
(type_identifier) @identifier.type
;;; Keywords
@ -165,18 +165,12 @@
(unsigned_literal)
] @number
(boolean_literal) @boolean
"null" @constant.null
(string_literal) @string
(string_literal
["$" "${" "}"] @string.escape
)
(character_literal) @character
(character_literal (character_escape_seq) @string.escape)
;;; Operators and Punctuation
[
"(" ")"
"[" "]"
"{" "}"
] @punctuation.bracket
[
"!"
@ -219,12 +213,6 @@
; '?' operator, replacement for Java @Nullable
(nullable_type) @punctuation
[
"(" ")"
"[" "]"
"{" "}"
] @punctuation.bracket
[
"."
","
@ -232,3 +220,13 @@
":"
"::"
] @punctuation.delimiter
(boolean_literal) @boolean
"null" @constant.null
(string_literal) @string
(string_literal
["$" "${" "}"] @string.escape)
(character_literal) @character
(character_literal (character_escape_seq) @string.escape)

View File

@ -1,5 +1,47 @@
; Based on https://github.com/krn-robin/tree-sitter-magik/blob/main/queries/highlights.scm
[
(self)
(super)
(clone)
] @variable.builtin
[
(variable)
(dynamic_variable)
(global_variable)
(global_reference)
(identifier)
(slot_accessor)
(label)
] @variable
(regex_literal) @string.special
; NOTE(issues: https://github.com/krn-robin/tree-sitter-magik/issues/49): Grammar does not support traversing to the children in the pragma
(pragma) @identifier.attribute
(argument) @identifier.parameter
; Literals
(number) @number
[
(string_literal)
(symbol)
] @string
(character_literal) @character
[
(true)
(false)
] @boolean
(maybe) @constant.builtin
(unset) @constant.null
; Methods
(method
exemplarname: (identifier) @type)
@ -65,6 +107,9 @@
(unary_operator
operator: _ @operator)
(invoke
receiver: (_) @function)
(invoke
receiver: (variable) @function.builtin
(#eq? @function.builtin "def_slotted_exemplar"))
@ -73,8 +118,6 @@
receiver: (variable) @function.builtin
(#eq? @function.builtin "def_mixin"))
(invoke
receiver: (_) @function)
(call
operator: "." @operator)
(call
@ -135,46 +178,3 @@
"_while"
"_with"
] @keyword
(regex_literal) @string.special
; NOTE(issues: https://github.com/krn-robin/tree-sitter-magik/issues/49): Grammar does not support traversing to the children in the pragma
(pragma) @identifier.attribute
(argument) @identifier.parameter
; Literals
(number) @number
[
(string_literal)
(symbol)
] @string
(character_literal) @character
[
(true)
(false)
] @boolean
(maybe) @constant.builtin
(unset) @constant.null
[
(self)
(super)
(clone)
] @variable.builtin
[
(variable)
(dynamic_variable)
(global_variable)
(global_reference)
(identifier)
(slot_accessor)
(label)
] @variable

View File

@ -8,7 +8,11 @@
"default"
"doc"
"rec"
@keyword]
"optional"
"priority"
"force"
"not_exported"
] @keyword
"fun" @keyword.function
@ -40,7 +44,7 @@
"{" "}"
"(" ")"
"[|" "|]"
@punctuation.bracket]
] @punctuation.bracket
[
","
@ -52,7 +56,7 @@
"+"
"-"
"*"
@punctuation.delimiter]
] @punctuation.delimiter
(multstr_start) @punctuation.bracket
(multstr_end) @punctuation.bracket
@ -64,17 +68,17 @@
(builtin) @function.builtin
(fun_expr pats:
(pattern id:
(ident) @parameter))
(pattern_fun
(ident) @parameter
)
)
; application where the head terms is an identifier: function arg1 arg2 arg3
(applicative t1:
(applicative (record_operand (atom (ident))) @function))
(applicative (record_operand (atom (ident))) @function)
)
; application where the head terms is a record field path: foo.bar.function arg1 arg2 arg3
(applicative t1:
(applicative (record_operand (record_operation_chain)) @function))
(applicative (record_operand (record_operation_chain)) @function)
)

View File

@ -1,3 +1,6 @@
;; TODO: This may not be the best way to do it.
(bareword) @keyword
[
; Our keywords
"return"
@ -36,8 +39,6 @@
(relational_expression operator: (_) @operator)
"=>" @operator
(comment) @comment
(number) @number
(version) @number
@ -76,9 +77,7 @@
(func0op_call_expression function: _ @function.builtin)
(func1op_call_expression function: _ @function.builtin)
;; TODO: This may not be the best way to do it.
(bareword) @keyword
(comment) @comment
(data_section) @comment
; (attrlist (attribute) @decorator)

View File

@ -17,32 +17,22 @@
; Types
(identifier) @variable
(clazz (identifier) @type)
(typeAlias (identifier) @type)
(annotation ("@" @identifier.attribute) (qualifiedIdentifier (identifier) @identifier.attribute))
((identifier) @constant.builtin
(#eq? @constant.builtin "Infinity"))
((identifier) @constant.builtin
(#eq? @constant.builtin "NaN"))
((identifier) @type
(#match? @type "^[A-Z]"))
(typeArgumentList
"<" @punctuation.bracket
">" @punctuation.bracket)
; Method calls
(methodCallExpr
(identifier) @function.method)
((identifier) @type
(#match? @type "^[A-Z]"))
((identifier) @constant.builtin
(#eq? @constant.builtin "NaN"))
((identifier) @constant.builtin
(#eq? @constant.builtin "Infinity"))
; Method definitions
(classMethod (methodHeader (identifier)) @function.method)
@ -57,8 +47,6 @@
(parameterList (typedIdentifier (identifier) @variable.parameter))
(objectBodyParameters (typedIdentifier (identifier) @variable.parameter))
(identifier) @variable
; Literals
(stringConstant) @string
@ -168,3 +156,9 @@
"typealias" @keyword
"unknown" @type.builtin
"when" @keyword
(typeArgumentList
"<" @punctuation.bracket
">" @punctuation.bracket)
(annotation ("@" @identifier.attribute) (qualifiedIdentifier (identifier) @identifier.attribute))

View File

@ -1,7 +1,11 @@
(identifier) @variable
(type (identifier) @identifier.type)
(attribute attribute: (identifier) @identifier.attribute)
; Function calls
(decorator) @identifier.function
(call
function: (attribute attribute: (identifier) @identifier.function))
(call
@ -12,12 +16,8 @@
(function_definition
name: (identifier) @identifier.function)
(identifier) @variable
(attribute attribute: (identifier) @identifier.attribute)
(type (identifier) @identifier.type)
; Literals
;
[
(none)
(true)

View File

@ -1,3 +1,10 @@
; Identifiers
(global_variable) @identifier ;; Should SCIP SyntaxKind support global variables?
(identifier) @identifier
(constant) @identifier
; Keywords
[
@ -44,11 +51,11 @@
"defined?" @identifier.builtin
(call
method: [(identifier) @type.builtin (block)]
(#eq? @type.builtin "sig"))
method: [(identifier) (constant)] @identifier.function)
(call
method: [(identifier) (constant)] @identifier.function)
method: [(identifier) @type.builtin (block)]
(#eq? @type.builtin "sig"))
; Function definitions
@ -57,12 +64,6 @@
(method name: [(identifier) (constant)] @identifier.function)
(singleton_method name: [(identifier) (constant)] @identifier.function)
; Identifiers
(constant) @identifier ;; TODO: Figure out why ruby grammar uses "constant" for identifiers
(global_variable) @identifier ;; Should SCIP SyntaxKind support global variables?
[
(class_variable)
(instance_variable)]
@ -79,11 +80,6 @@
"**" @operator)
@constant.builtin
((constant) @constant
(#match? @constant "^[A-Z\\d_]+$"))
(constant) @constructor
(self) @identifier.builtin
(super) @identifier.builtin
@ -98,10 +94,6 @@
(keyword_parameter name: (identifier) @identifier.parameter)
(optional_parameter name: (identifier) @identifier.parameter)
;; ((identifier) @identifier.function
;; (#is-not? local)) ; TODO: support locals
(identifier) @identifier
; Literals
[
@ -151,4 +143,3 @@
"=>"
"->"]
@operator

View File

@ -1,9 +1,18 @@
(identifier) @identifier
(type_identifier) @type
(primitive_type) @identifier.builtin
(field_identifier) @identifier.constant
; Identifier conventions
; Assume all-caps names are constants
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]+$'"))
; Assume other uppercase names are enum constructors
((identifier) @constant
(#match? @constant "^[A-Z]"))
; Assume that uppercase names in paths are types
((scoped_identifier
path: (identifier) @type)
@ -20,10 +29,6 @@
name: (identifier) @type))
(#match? @type "^[A-Z]"))
; Assume other uppercase names are enum constructors
((identifier) @constant
(#match? @constant "^[A-Z]"))
; Assume all qualified names in struct patterns are enum constructors. (They're
; either that, or struct names; highlighting both as constructors seems to be
; the less glaring choice of error, visually.)
@ -66,10 +71,6 @@
; Other identifiers
(type_identifier) @type
(primitive_type) @identifier.builtin
(field_identifier) @identifier.constant
(line_comment) @comment
(block_comment) @comment
@ -99,8 +100,6 @@
(lifetime (identifier) @identifier.attribute)
(identifier) @identifier
[
"as"
"async"

View File

@ -1,3 +1,8 @@
(identifier) @variable
((identifier) @identifier.constant (#match? @identifier.constant "^[A-Z]"))
(operator_identifier) @variable
(type_identifier) @type
(class_definition name: (identifier) @type)
(trait_definition name: (identifier) @type)
(function_definition name: (identifier) @identifier.function)
@ -8,12 +13,7 @@
(call_expression function: (field_expression field: (identifier) @identifier.function))
(call_expression function: (identifier) @identifier.function)
(type_parameters name: (identifier) @identifier.type)
((identifier) @identifier.constant
(#match? @identifier.constant "^[A-Z]"))
(identifier) @variable
(case_class_pattern type: (type_identifier) @variable)
(operator_identifier) @variable
(type_identifier) @type
"this" @constant.builtin
(interpolated_string) @string
(string) @string

View File

@ -1,101 +1,449 @@
(string) @string
(number) @number
(comment) @comment
;; Based on the upstream highlight query: https://github.com/DerekStride/tree-sitter-sql/blob/b65df7f27d461ca7c47446fa530ba4cb9e9b8e45/queries/highlights.scm
(function_call
function: (identifier) @function)
(object_reference
name: (identifier) @type)
(identifier) @variable
(invocation
(object_reference
name: (identifier) @function.call))
[
(NULL)
(TRUE)
(FALSE)]
@constant.builtin
(keyword_gist)
(keyword_btree)
(keyword_hash)
(keyword_spgist)
(keyword_gin)
(keyword_brin)
(keyword_array)
] @function.call
([
(type_cast
(type) @type.builtin)
(create_function_statement
(type) @type.builtin)
(create_function_statement
(create_function_parameters
(create_function_parameter (type) @type.builtin)))
(create_type_statement
(parameters
(parameter (type) @type.builtin)))
(create_table_statement
(create_table_parameters
(create_table_column_parameter (type) @type.builtin)))]
(relation
alias: (identifier) @variable)
(#match?
@type.builtin
"^(bigint|BIGINT|int8|INT8|bigserial|BIGSERIAL|serial8|SERIAL8|bit|BIT|varbit|VARBIT|boolean|BOOLEAN|bool|BOOL|box|BOX|bytea|BYTEA|character|CHARACTER|char|CHAR|varchar|VARCHAR|cidr|CIDR|circle|CIRCLE|date|DATE|float8|FLOAT8|inet|INET|integer|INTEGER|int|INT|int4|INT4|interval|INTERVAL|json|JSON|jsonb|JSONB|line|LINE|lseg|LSEG|macaddr|MACADDR|money|MONEY|numeric|NUMERIC|decimal|DECIMAL|path|PATH|pg_lsn|PG_LSN|point|POINT|polygon|POLYGON|real|REAL|float4|FLOAT4|smallint|SMALLINT|int2|INT2|smallserial|SMALLSERIAL|serial2|SERIAL2|serial|SERIAL|serial4|SERIAL4|text|TEXT|time|TIME|time|TIME|timestamp|TIMESTAMP|tsquery|TSQUERY|tsvector|TSVECTOR|txid_snapshot|TXID_SNAPSHOT)$"))
(field
name: (identifier) @field)
(term
alias: (identifier) @variable)
((term
value: (cast
name: (keyword_cast) @function.call
parameter: [(literal)]?)))
(literal) @string
(comment) @comment @spell
(marginalia) @comment
((literal) @number
(#match? @number "^[-+]?%d+$"))
((literal) @float
(#match? @float "^[-+]?%d*\.%d*$"))
(parameter) @parameter
[
"::"
(keyword_true)
(keyword_false)
] @boolean
[
(keyword_asc)
(keyword_desc)
(keyword_terminated)
(keyword_escaped)
(keyword_unsigned)
(keyword_nulls)
(keyword_last)
(keyword_delimited)
(keyword_replication)
(keyword_auto_increment)
(keyword_default)
(keyword_collate)
(keyword_concurrently)
(keyword_engine)
(keyword_always)
(keyword_generated)
(keyword_preceding)
(keyword_following)
(keyword_first)
(keyword_current_timestamp)
(keyword_immutable)
(keyword_atomic)
(keyword_parallel)
(keyword_leakproof)
(keyword_safe)
(keyword_cost)
(keyword_strict)
] @attribute
[
(keyword_materialized)
(keyword_recursive)
(keyword_temp)
(keyword_temporary)
(keyword_unlogged)
(keyword_external)
(keyword_parquet)
(keyword_csv)
(keyword_rcfile)
(keyword_textfile)
(keyword_orc)
(keyword_avro)
(keyword_jsonfile)
(keyword_sequencefile)
(keyword_volatile)
] @storageclass
[
(keyword_case)
(keyword_when)
(keyword_then)
(keyword_else)
] @conditional
[
(keyword_select)
(keyword_from)
(keyword_where)
(keyword_index)
(keyword_join)
(keyword_primary)
(keyword_delete)
(keyword_create)
(keyword_insert)
(keyword_merge)
(keyword_distinct)
(keyword_replace)
(keyword_update)
(keyword_into)
(keyword_overwrite)
(keyword_matched)
(keyword_values)
(keyword_value)
(keyword_attribute)
(keyword_set)
(keyword_left)
(keyword_right)
(keyword_outer)
(keyword_inner)
(keyword_full)
(keyword_order)
(keyword_partition)
(keyword_group)
(keyword_with)
(keyword_without)
(keyword_as)
(keyword_having)
(keyword_limit)
(keyword_offset)
(keyword_table)
(keyword_tables)
(keyword_key)
(keyword_references)
(keyword_foreign)
(keyword_constraint)
(keyword_force)
(keyword_use)
(keyword_for)
(keyword_if)
(keyword_exists)
(keyword_max)
(keyword_min)
(keyword_avg)
(keyword_column)
(keyword_columns)
(keyword_cross)
(keyword_lateral)
(keyword_natural)
(keyword_alter)
(keyword_drop)
(keyword_add)
(keyword_view)
(keyword_end)
(keyword_is)
(keyword_using)
(keyword_between)
(keyword_window)
(keyword_no)
(keyword_data)
(keyword_type)
(keyword_rename)
(keyword_to)
(keyword_schema)
(keyword_owner)
(keyword_authorization)
(keyword_all)
(keyword_any)
(keyword_some)
(keyword_returning)
(keyword_begin)
(keyword_commit)
(keyword_rollback)
(keyword_transaction)
(keyword_only)
(keyword_like)
(keyword_similar)
(keyword_over)
(keyword_change)
(keyword_modify)
(keyword_after)
(keyword_before)
(keyword_range)
(keyword_rows)
(keyword_groups)
(keyword_exclude)
(keyword_current)
(keyword_ties)
(keyword_others)
(keyword_preserve)
(keyword_zerofill)
(keyword_format)
(keyword_fields)
(keyword_row)
(keyword_sort)
(keyword_compute)
(keyword_comment)
(keyword_location)
(keyword_cached)
(keyword_uncached)
(keyword_lines)
(keyword_stored)
(keyword_virtual)
(keyword_partitioned)
(keyword_analyze)
(keyword_explain)
(keyword_verbose)
(keyword_truncate)
(keyword_rewrite)
(keyword_optimize)
(keyword_vacuum)
(keyword_cache)
(keyword_language)
(keyword_sql)
(keyword_called)
(keyword_conflict)
(keyword_declare)
(keyword_filter)
(keyword_function)
(keyword_input)
(keyword_name)
(keyword_oid)
(keyword_oids)
(keyword_options)
(keyword_plpgsql)
(keyword_precision)
(keyword_regclass)
(keyword_regnamespace)
(keyword_regproc)
(keyword_regtype)
(keyword_restricted)
(keyword_return)
(keyword_returns)
(keyword_separator)
(keyword_setof)
(keyword_stable)
(keyword_support)
(keyword_tblproperties)
(keyword_trigger)
(keyword_unsafe)
(keyword_admin)
(keyword_connection)
(keyword_cycle)
(keyword_database)
(keyword_encrypted)
(keyword_increment)
(keyword_logged)
(keyword_none)
(keyword_owned)
(keyword_password)
(keyword_reset)
(keyword_role)
(keyword_sequence)
(keyword_start)
(keyword_restart)
(keyword_tablespace)
(keyword_until)
(keyword_user)
(keyword_valid)
(keyword_action)
(keyword_definer)
(keyword_invoker)
(keyword_security)
(keyword_extension)
(keyword_version)
(keyword_out)
(keyword_inout)
(keyword_variadic)
(keyword_session)
(keyword_isolation)
(keyword_level)
(keyword_serializable)
(keyword_repeatable)
(keyword_read)
(keyword_write)
(keyword_committed)
(keyword_uncommitted)
(keyword_deferrable)
(keyword_names)
(keyword_zone)
(keyword_immediate)
(keyword_deferred)
(keyword_constraints)
(keyword_snapshot)
(keyword_characteristics)
(keyword_off)
(keyword_follows)
(keyword_precedes)
(keyword_each)
(keyword_instead)
(keyword_of)
(keyword_initially)
(keyword_old)
(keyword_new)
(keyword_referencing)
(keyword_statement)
(keyword_execute)
(keyword_procedure)
(keyword_copy)
(keyword_delimiter)
(keyword_encoding)
(keyword_escape)
(keyword_force_not_null)
(keyword_force_null)
(keyword_force_quote)
(keyword_freeze)
(keyword_header)
(keyword_match)
(keyword_program)
(keyword_quote)
(keyword_stdin)
(keyword_extended)
(keyword_main)
(keyword_plain)
(keyword_storage)
(keyword_compression)
] @keyword
[
(keyword_restrict)
(keyword_unbounded)
(keyword_unique)
(keyword_cascade)
(keyword_delayed)
(keyword_high_priority)
(keyword_low_priority)
(keyword_ignore)
(keyword_nothing)
(keyword_check)
(keyword_option)
(keyword_local)
(keyword_cascaded)
(keyword_wait)
(keyword_nowait)
(keyword_metadata)
(keyword_incremental)
(keyword_bin_pack)
(keyword_noscan)
(keyword_stats)
(keyword_statistics)
(keyword_maxvalue)
(keyword_minvalue)
] @type.qualifier
[
(keyword_int)
(keyword_null)
(keyword_boolean)
(keyword_binary)
(keyword_varbinary)
(keyword_image)
(keyword_bit)
(keyword_inet)
(keyword_character)
(keyword_smallserial)
(keyword_serial)
(keyword_bigserial)
(keyword_smallint)
(keyword_mediumint)
(keyword_bigint)
(keyword_tinyint)
(keyword_decimal)
(keyword_float)
(keyword_double)
(keyword_numeric)
(keyword_real)
(double)
(keyword_money)
(keyword_smallmoney)
(keyword_char)
(keyword_nchar)
(keyword_varchar)
(keyword_nvarchar)
(keyword_varying)
(keyword_text)
(keyword_string)
(keyword_uuid)
(keyword_json)
(keyword_jsonb)
(keyword_xml)
(keyword_bytea)
(keyword_enum)
(keyword_date)
(keyword_datetime)
(keyword_time)
(keyword_datetime2)
(keyword_datetimeoffset)
(keyword_smalldatetime)
(keyword_timestamp)
(keyword_timestamptz)
(keyword_geometry)
(keyword_geography)
(keyword_box2d)
(keyword_box3d)
(keyword_interval)
] @type.builtin
[
(keyword_in)
(keyword_and)
(keyword_or)
(keyword_not)
(keyword_by)
(keyword_on)
(keyword_do)
(keyword_union)
(keyword_except)
(keyword_intersect)
] @keyword.operator
[
"+"
"-"
"*"
"/"
"%"
"^"
":="
"="
"<"
"<="
"<>"
"="
"!="
">="
">"
">="]
@operator
"<>"
(op_other)
(op_unary_other)
] @operator
[
"("
")"
"["
"]"]
@punctuation.bracket
] @punctuation.bracket
[
(type)
(array_type)]
@type
[
(primary_key_constraint)
(unique_constraint)
(null_constraint)]
@keyword
[
"AS"
"CREATE"
"CREATE_DOMAIN"
"CREATE_OR_REPLACE_FUNCTION"
"CREATE_SCHEMA"
"CREATE_TABLE"
"CREATE_TYPE"
"DATABASE"
"FROM"
"GRANT"
"GROUP_BY"
"IF_NOT_EXISTS"
"INDEX"
"INNER"
"INSERT"
"INTO"
"JOIN"
"LANGUAGE"
"LEFT"
"ON"
"ORDER_BY"
"OUTER"
"PRIMARY_KEY"
"PUBLIC"
"RETURNS"
"SCHEMA"
"SELECT"
"SET"
"LOCAL"
"SESSION"
"TABLE"
"TO"
"UNIQUE"
"UPDATE"
"USAGE"
"VALUES"
"WHERE"]
@keyword
";"
","
"."
] @punctuation.delimiter

View File

@ -1,20 +1,11 @@
;; This file inherits from typescript/highlights.scm
;; This file inherits from typescript/highlights.scm
;; This file should be kept in sync with javascript/highlights-jsx.scm
(jsx_opening_element
"<" @tag.delimiter
name: (identifier) @tag
">" @tag.delimiter)
; We need to match the tag characters individually since the version of the grammar we are using (v0.20.2) defines them that way
; when we update to the newest version we can remove this
(jsx_closing_element
["<" "/"] @tag.delimiter
name: (identifier) @tag
">" @tag.delimiter)
(jsx_self_closing_element
"<" @tag.delimiter
name: (identifier) @tag
["/" ">"] @tag.delimiter)
(jsx_attribute (property_identifier) @tag.attribute)
(jsx_opening_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
(jsx_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
(jsx_self_closing_element (identifier) @tag (#match? @tag "^[a-z][^.]*$"))
(jsx_attribute (property_identifier) @tag.attribute)
(jsx_opening_element (["<" ">"]) @tag.delimiter)
(jsx_closing_element (["</" ">"]) @tag.delimiter)
(jsx_self_closing_element (["<" "/>"]) @tag.delimiter)

View File

@ -4,7 +4,7 @@
(interface_declaration name: (_) @descriptor.type @kind.interface body: (_) @scope)
(interface_declaration
(object_type
(interface_body
[
(method_signature (property_identifier) @descriptor.method @kind.method)
(property_signature (property_identifier) @descriptor.term @kind.property)]))

View File

@ -115,11 +115,11 @@ field_constant: (IDENTIFIER) @constant
; Functions and builtins
(BUILTINIDENTIFIER) @function.builtin
((BUILTINIDENTIFIER) @include
(#any-of? @include "@import" "@cImport"))
(BUILTINIDENTIFIER) @function.builtin
parameter: (IDENTIFIER) @variable.parameter
[

View File

@ -176,7 +176,7 @@ pub fn parse_tree<'a>(
let mut kind = None;
for capture in m.captures {
let capture_name = capture_names
let capture_name = *capture_names
.get(capture.index as usize)
.context("capture indexes should always work")?;
@ -341,8 +341,6 @@ pub mod test {
let config = crate::languages::get_tag_configuration(ParserId::Go).expect("to have parser");
let source_code = include_str!("../testdata/scopes_of_go.go");
let doc = parse_file_for_lang(config, source_code);
// let dumped = dump_document(&doc, source_code)?;
let dumped = dump_document_with_config(
&doc,
source_code,

View File

@ -189,6 +189,7 @@ impl SublimeLanguageName {
}
// Somewhat ad-hoc set of names based on existing Tree-sitter grammars.
#[derive(Debug)]
pub struct TreeSitterLanguageName {
raw: String,
}

View File

@ -0,0 +1,77 @@
// Example file with all(?) possible components from the syntax
local object = {
'null': null,
'true': true,
'false': false,
string: 'string',
number: 5,
array: [
null,
true,
false,
'string',
1.5,
],
forloop: [
i
for i in std.range(0, 9)
],
objforloop: {
['index' + i]: i
for i in std.range(0, 9)
if (i % 2) == 0 // binaryop: multiplicative and equality
},
fieldaccess: self.string,
indexing: self.forloop[self.number],
indexing_obj: self.objforloop['index' + '0'],
indexing_slice: self.forloop[2:8:2],
binaryop_equality: self.string == 'string',
conditional_in_parenthesis:
(if self.binaryop_equality && true // binaryop: AND
then 'condition true'
else 'condition false'),
local objlocal = false || true, // binaryop: OR
unaryop: !objlocal,
anonymous_function:: function(arg, default='v') arg + default,
regular_func(arg):: $.string + ' ' + arg,
assert true : 'assert instide object',
'import':: import 'file.json',
'importstr':: import 'file.txt',
err:: error 'message',
};
assert true : 'assert outside object';
object + {
fieldaccess_super: super.number,
indexing_super: super.array[2 * 2], // binaryop: multiplicative
functioncall_1: super.anonymous_function('echo 1'),
functioncall_2: self.regular_func(arg='echo 2') tailstrict,
local localfunc(arg) = {
local notarg = 'value',
a: notarg, // not a parameter reference
b: arg, // parameter reference
[arg]: arg, // parameter reference in fieldname
},
functioncall_3: localfunc('echo 3'), // function reference
in_super: 'keynotfound' in super,
array+: ['another item'],
objforloop+: { another: 'item' },
['fieldname_expr' + (5 - object.objforloop.index2)]: 'value',
[if object.string == 'string' then 'conditional_key']: 'value',
}

View File

@ -32,9 +32,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
Name = "name";
// ^^^^ IdentifierAttribute
// ^ IdentifierOperator
// ^ StringLiteral
// ^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ PunctuationDelimiter
Console.log(something);
// ^^^^^^^ Identifier
@ -153,22 +151,20 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
}
void SunsetRestrictedTypes()
// ^^^^ IdentifierBuiltin
// ^^^^ IdentifierBuiltinType
// ^^^^^^^^^^^^^^^^^^^^^ IdentifierFunction
{
var g = "";
// ^^^ Keyword
// ^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^ StringLiteral
// ^^ StringLiteral
// ^ PunctuationDelimiter
var g = "";
// ^^^ Keyword
// ^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^ StringLiteral
// ^^ StringLiteral
// ^ PunctuationDelimiter
var reference = __makeref(g);
// ^^^ Keyword
@ -236,27 +232,21 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ PunctuationDelimiter
return $"a={a} b={b:0.00} c={c,24} d={d:g}";
// ^^^^^^ Keyword
// ^^ StringLiteral
// ^^ StringLiteral
// ^ StringLiteralEscape
// ^ StringLiteral
// ^^^ StringLiteral
// ^ Identifier
// ^ StringLiteralEscape
// ^^^ StringLiteral
// ^ StringLiteralEscape
// ^ Identifier
// ^ IdentifierOperator
// ^ StringLiteralEscape
// ^^^^ StringLiteral
// ^^^ StringLiteral
// ^ StringLiteralEscape
// ^ Identifier
// ^ PunctuationDelimiter
// ^^ NumericLiteral
// ^ StringLiteralEscape
// ^^^ StringLiteral
// ^ StringLiteralEscape
// ^ Identifier
// ^ IdentifierOperator
// ^ StringLiteralEscape
// ^ StringLiteral
// ^ StringLiteral
// ^ PunctuationDelimiter
}
@ -395,46 +385,36 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^ IdentifierFunction
{
#if WIN32
// ^^ Keyword
// ^ Keyword
// ^^^^^ IdentifierConstant
string os = "Win32";
// ^^^^^^ IdentifierBuiltinType
// ^^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
#warning This class is bad.
// ^^^^^^^ Keyword
// ^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^^^^ IdentifierType
// ^^^^^ Identifier
// ^^ Keyword
// ^ PunctuationDelimiter
#error Okay, just stop.
// ^^^^^ Keyword
// ^^^^^^^^^^^^^^^^^ StringLiteral
// ^^^^^^^^^^^^^^^^ StringLiteral
#elif MACOS
// ^^^^^ Keyword
// ^^^^^ IdentifierConstant
string os = "MacOS";
// ^^^^^^ IdentifierBuiltinType
// ^^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
#else
// ^^^^ Keyword
string os = "Unknown";
// ^^^^^^ IdentifierBuiltinType
// ^^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
#endif
// ^^^^^ Keyword
return os;
// ^^^^^^ Keyword
// ^^ Identifier
@ -443,7 +423,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
}
void Linq()
// ^^^^ IdentifierBuiltin
// ^^^^ IdentifierBuiltinType
// ^^^^ IdentifierFunction
{
var x = from a in sourceA

View File

@ -76,7 +76,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
public class DataGridTests
// ^^^^^^ Keyword
// ^^^^^ Keyword
// ^^^^^^^^^^^^^ IdentifierType
// ^^^^^^^^^^^^^ Identifier
{
public event EventHandler<int> Event1
@ -113,11 +113,9 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
[Required(ErrorMessage = "Message")]
// ^^^^^^^^ IdentifierType
// ^^^^^^^^^^^^ IdentifierAttribute
// ^^^^^^^^^^^^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^ StringLiteral
public string RequiredProperty { get; set; }
// ^^^^^^ Keyword
// ^^^^^^ IdentifierBuiltinType
@ -140,8 +138,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ IdentifierType
public void DataGrid_Renders_CssClass()
// ^^^^^^ Keyword
// ^^^^ IdentifierBuiltin
// ^^^^^^^^^^^^^^^^^^^^^^^^^ IdentifierFunction
// ^^^^ IdentifierBuiltinType
// ^^^^^^^^^^^^^^^^^^^^^^^^^ Identifier
{
using var ctx = new TestContext();
// ^^^^^ Keyword
@ -179,9 +177,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^^^^ IdentifierAttribute
// ^ PunctuationDelimiter
// ^^^^^^^^^^^ IdentifierFunction
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
var component = ctx.RenderComponent<RadzenGrid<dynamic>>(parameterBuilder =>
// ^^^ Keyword
@ -189,15 +185,14 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ IdentifierOperator
// ^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^^^^^^^^ IdentifierFunction
// ^^^^^^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^ IdentifierOperator
// ^^^^^^^^^^^^^^^^ Identifier
// ^ Identifier
// ^^^^^^^^^^^^^^^^^ Identifier
// ^^ IdentifierOperator
// Identifier 41:88..42:12
{
@ -205,15 +200,14 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
parameterBuilder.Add<IEnumerable<dynamic>>(p => p.Data, new[] { new { Id = 1 }, new { Id = 2 }, new { Id = 3 } });
// ^^^^^^^^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^ IdentifierOperator
// ^ Identifier
// ^ Identifier
// ^^ Identifier
// ^^ IdentifierOperator
// ^ Identifier
// ^ Identifier
@ -261,12 +255,11 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
parameterBuilder.Add<RenderFragment>(p => p.Columns, builder =>
// ^^^^^^^^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^ Identifier
// ^ Identifier
// ^^ Identifier
// ^^ IdentifierOperator
// ^ Identifier
// ^ Identifier
@ -274,8 +267,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^^ IdentifierAttribute
// ^ PunctuationDelimiter
// ^ Identifier
// ^^^^^^^ Identifier
// ^ Identifier
// ^^^^^^^^ Identifier
// ^^ IdentifierOperator
// Identifier 44:79..45:16
{
@ -301,14 +293,10 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ NumericLiteral
// ^ PunctuationDelimiter
// ^ Identifier
// ^ StringLiteral
// ^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
// ^ Identifier
// ^ StringLiteral
// ^^ StringLiteral
// ^ StringLiteral
// ^^^^ StringLiteral
// ^ PunctuationDelimiter
// Identifier 47:62..48:20
builder.CloseComponent();
@ -329,9 +317,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
// ^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
@ -341,9 +328,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
// ^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
@ -356,15 +342,14 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ IdentifierOperator
// ^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^^^^^^^^ IdentifierFunction
// ^^^^^^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^ IdentifierOperator
// ^^^^^^^^^^^^^^^^ Identifier
// ^ Identifier
// ^^^^^^^^^^^^^^^^^ Identifier
// ^^ IdentifierOperator
// Identifier 56:88..57:12
{
@ -372,15 +357,14 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
parameterBuilder.Add<IEnumerable<dynamic>>(p => p.Data, new[] { new { Id = 1 }, new { Id = 2 }, new { Id = 3 } });
// ^^^^^^^^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^ IdentifierOperator
// ^ Identifier
// ^ Identifier
// ^^ Identifier
// ^^ IdentifierOperator
// ^ Identifier
// ^ Identifier
@ -428,12 +412,11 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
parameterBuilder.Add<RenderFragment>(p => p.Columns, builder =>
// ^^^^^^^^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^^ IdentifierType
// ^ IdentifierOperator
// ^^^^^^^^^^^^^^ IdentifierType
// ^ IdentifierOperator
// ^ Identifier
// ^ Identifier
// ^^ Identifier
// ^^ IdentifierOperator
// ^ Identifier
// ^ Identifier
@ -441,8 +424,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^^ IdentifierAttribute
// ^ PunctuationDelimiter
// ^ Identifier
// ^^^^^^^ Identifier
// ^ Identifier
// ^^^^^^^^ Identifier
// ^^ IdentifierOperator
// Identifier 59:79..60:16
{
@ -468,14 +450,10 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ NumericLiteral
// ^ PunctuationDelimiter
// ^ Identifier
// ^ StringLiteral
// ^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^ StringLiteral
// ^ PunctuationDelimiter
// ^ Identifier
// ^ StringLiteral
// ^^ StringLiteral
// ^ StringLiteral
// ^^^^ StringLiteral
// ^ PunctuationDelimiter
// Identifier 62:62..63:20
builder.CloseComponent();
@ -503,8 +481,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierAttribute
// ^ PunctuationDelimiter
// ^ StringLiteral
// ^ StringLiteral
// ^^ StringLiteral
// ^ PunctuationDelimiter
// ^^^^ IdentifierFunction
// ^ PunctuationDelimiter
@ -512,71 +489,39 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ StringLiteral
// ^^ StringLiteral
// ^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteral
// ^^ StringLiteral
// ^ StringLiteral
// ^ PunctuationDelimiter
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^ StringLiteral
// ^^^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral 68:33..69:30
Assert.Contains(@$"""rz-cell-data"">2", markup);
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ StringLiteral
// ^^ StringLiteral
// ^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteral
// ^^ StringLiteral
// ^ StringLiteral
// ^^^ StringLiteral
// ^ IdentifierOperator
// ^^^^ Identifier
// ^ IdentifierOperator
// ^^^^ StringLiteral
// ^ PunctuationDelimiter
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
Assert.Contains(@$"""rz-cell-data"">3", markup);
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ StringLiteral
// ^^ StringLiteral
// ^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteral
// ^^ StringLiteral
// ^ StringLiteral
// ^ PunctuationDelimiter
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierAttribute
// ^^ StringLiteral
// ^^^ StringLiteral
Assert.Contains(@"
// ^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^ StringLiteral 71:28..73:1
Lorem Ipsum
", component.Markup);
// ^ PunctuationDelimiter
// ^^^^^^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierAttribute
// ^ PunctuationDelimiter
var productTempateProductAttribute = new ProductTemplateProductAttribute
// ^^^ Keyword
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Identifier
// ^ IdentifierOperator
// ^^^ Keyword
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ IdentifierType
{
ProductTemplate = this,
// ^^^^^^^^^^^^^^^ IdentifierAttribute
// ^^^^^^^^^^^^^^^ Identifier
// ^ IdentifierOperator
// ^^^^ Keyword
// ^ PunctuationDelimiter
ProductAttributeId = attributeId
// ^^^^^^^^^^^^^^^^^^ IdentifierAttribute
// ^^^^^^^^^^^^^^^^^^ Identifier
// ^ IdentifierOperator
// ^^^^^^^^^^^ Identifier
};
// ^ PunctuationDelimiter
}
}
}

View File

@ -244,7 +244,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^ StringLiteralEscape
// ^^^ Identifier
// ^ StringLiteralEscape
// ^^^^^^^^^^^^ StringLiteral
// ^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
} else {
// ^^^^ Keyword
console.log(`${name} is a baby.`);
@ -254,7 +255,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^ StringLiteralEscape
// ^^^^ Identifier
// ^ StringLiteralEscape
// ^^^^^^^^^^^^ StringLiteral
// ^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
}
//4. Loop
@ -283,11 +285,13 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
return `Hello, ${name}!`;
// ^^^^^^ Keyword
// ^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^ StringLiteral
// ^^ StringLiteralEscape
// ^^^^ Identifier
// ^ StringLiteralEscape
// ^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
}
console.log(greet(name));
//^^^^^^^ Identifier
@ -329,13 +333,15 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
console.log(`Hello, my name is ${this.name}.`);
// ^^^^^^^ Identifier
// ^^^ IdentifierFunction
// ^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteralEscape
// ^^^^ IdentifierBuiltin
// ^ StringLiteral
// ^^^^ Identifier
// ^ StringLiteralEscape
// ^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
}
};
person.sayHello();
@ -427,7 +433,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
console.log(`Hello, I am ${this.name} and I am a ${this.type}.`);
// ^^^^^^^ Identifier
// ^^^ IdentifierFunction
// ^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteralEscape
// ^^^^ IdentifierBuiltin
// ^ StringLiteral
@ -439,7 +446,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ StringLiteral
// ^^^^ Identifier
// ^ StringLiteralEscape
// ^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
}
}
const cat = new Animal("Tom", "cat");
@ -484,7 +492,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
console.log(`Hello, I am ${this.name} and I am a ${this.breed} breed ${this.type}.`);
// ^^^^^^^ Identifier
// ^^^ IdentifierFunction
// ^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteralEscape
// ^^^^ IdentifierBuiltin
// ^ StringLiteral
@ -502,7 +511,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ StringLiteral
// ^^^^ Identifier
// ^ StringLiteralEscape
// ^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
}
}
const dog = new Dog("Max", "Labrador");
@ -540,7 +550,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ NumericLiteral
// ^ StringLiteral
// ^ StringLiteralEscape
// ^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
console.log(message);
//^^^^^^^ Identifier
// ^^^ IdentifierFunction

View File

@ -0,0 +1,349 @@
---
source: crates/syntax-analysis/src/highlighting/tree_sitter.rs
expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
---
// Example file with all(?) possible components from the syntax
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Comment
local object = {
//^^^^^ Keyword
// ^^^^^^ Identifier
'null': null,
// ^ StringLiteral
// ^^^^ StringLiteral
// ^ StringLiteral
'true': true,
// ^ StringLiteral
// ^^^^ StringLiteral
// ^ StringLiteral
// ^^^^ BooleanLiteral
'false': false,
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^ BooleanLiteral
string: 'string',
// ^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
number: 5,
// ^^^^^^ Identifier
// ^ NumericLiteral
array: [
// ^^^^^ Identifier
null,
true,
// ^^^^ BooleanLiteral
false,
// ^^^^^ BooleanLiteral
'string',
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
1.5,
// ^^^ NumericLiteral
],
forloop: [
// ^^^^^^^ Identifier
i
// ^ Identifier
for i in std.range(0, 9)
// ^^^ Keyword
// ^ Identifier
// ^^ Keyword
// ^^^ Identifier
// ^^^^^ Identifier
// ^ NumericLiteral
// ^ NumericLiteral
],
objforloop: {
// ^^^^^^^^^^ Identifier
['index' + i]: i
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^ IdentifierOperator
// ^ StringLiteral
// ^ Identifier
// ^ Identifier
for i in std.range(0, 9)
// ^^^ Keyword
// ^ Identifier
// ^^ Keyword
// ^^^ Identifier
// ^^^^^ Identifier
// ^ NumericLiteral
// ^ NumericLiteral
if (i % 2) == 0 // binaryop: multiplicative and equality
// ^^ Keyword
// ^ Identifier
// ^ IdentifierOperator
// ^ NumericLiteral
// ^^ IdentifierOperator
// ^ NumericLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Comment
},
fieldaccess: self.string,
// ^^^^^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^ Identifier
indexing: self.forloop[self.number],
// ^^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^ Identifier
indexing_obj: self.objforloop['index' + '0'],
// ^^^^^^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
// ^ IdentifierOperator
// ^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
indexing_slice: self.forloop[2:8:2],
// ^^^^^^^^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^^ Identifier
// ^ NumericLiteral
// ^ NumericLiteral
// ^ NumericLiteral
binaryop_equality: self.string == 'string',
// ^^^^^^^^^^^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^ Identifier
// ^^ IdentifierOperator
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
conditional_in_parenthesis:
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ Identifier
(if self.binaryop_equality && true // binaryop: AND
// ^^ Keyword
// ^^^^ IdentifierBuiltin
// ^^^^^^^^^^^^^^^^^ Identifier
// ^^ IdentifierOperator
// ^^^^ BooleanLiteral
// ^^^^^^^^^^^^^^^^ Comment
then 'condition true'
// ^^^^ Keyword
// ^ StringLiteral
// ^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
else 'condition false'),
// ^^^^ Keyword
// ^ StringLiteral
// ^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
local objlocal = false || true, // binaryop: OR
// ^^^^^ Keyword
// ^^^^^^^^ Identifier
// ^^^^^ BooleanLiteral
// ^^ IdentifierOperator
// ^^^^ BooleanLiteral
// ^^^^^^^^^^^^^^^ Comment
unaryop: !objlocal,
// ^^^^^^^ Identifier
// ^ IdentifierOperator
// ^^^^^^^^ Identifier
anonymous_function:: function(arg, default='v') arg + default,
// ^^^^^^^^^^^^^^^^^^ Identifier
// ^^^^^^^^ Keyword
// ^^^ IdentifierParameter
// ^^^^^^^ IdentifierParameter
// ^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^^^ Identifier
// ^ IdentifierOperator
// ^^^^^^^ Identifier
regular_func(arg):: $.string + ' ' + arg,
// ^^^^^^^^^^^^ Identifier
// ^^^ IdentifierParameter
// ^ IdentifierBuiltin
// ^^^^^^ Identifier
// ^ IdentifierOperator
// ^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^ IdentifierOperator
// ^^^ Identifier
assert true : 'assert instide object',
// ^^^^^^ IdentifierFunction
// ^^^^ BooleanLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
'import':: import 'file.json',
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^ Keyword
// ^ IdentifierNamespace
// ^ StringLiteral
// ^^^^^^^^^ StringLiteral
// ^ StringLiteral
'importstr':: import 'file.txt',
// ^ StringLiteral
// ^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^ Keyword
// ^ IdentifierNamespace
// ^ StringLiteral
// ^^^^^^^^ StringLiteral
// ^ StringLiteral
err:: error 'message',
// ^^^ Identifier
// ^^^^^ IdentifierFunction
// ^ StringLiteral
// ^^^^^^^ StringLiteral
// ^ StringLiteral
};
assert true : 'assert outside object';
//^^^^^^ IdentifierFunction
// ^^^^ BooleanLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
object + {
//^^^^^^ Identifier
// ^ IdentifierOperator
fieldaccess_super: super.number,
// ^^^^^^^^^^^^^^^^^ Identifier
// ^^^^^ Keyword
// ^^^^^^ Identifier
indexing_super: super.array[2 * 2], // binaryop: multiplicative
// ^^^^^^^^^^^^^^ Identifier
// ^^^^^ Keyword
// ^^^^^ Identifier
// ^ NumericLiteral
// ^ IdentifierOperator
// ^ NumericLiteral
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Comment
functioncall_1: super.anonymous_function('echo 1'),
// ^^^^^^^^^^^^^^ Identifier
// ^^^^^ Keyword
// ^^^^^^^^^^^^^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
functioncall_2: self.regular_func(arg='echo 2') tailstrict,
// ^^^^^^^^^^^^^^ Identifier
// ^^^^ IdentifierBuiltin
// ^^^^^^^^^^^^ Identifier
// ^^^ Identifier
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
local localfunc(arg) = {
// ^^^^^ Keyword
// ^^^^^^^^^ IdentifierFunction
// ^^^ IdentifierParameter
local notarg = 'value',
// ^^^^^ Keyword
// ^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
a: notarg, // not a parameter reference
// ^ Identifier
// ^^^^^^ Identifier
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Comment
b: arg, // parameter reference
// ^ Identifier
// ^^^ Identifier
// ^^^^^^^^^^^^^^^^^^^^^^ Comment
[arg]: arg, // parameter reference in fieldname
// ^^^ Identifier
// ^^^ Identifier
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Comment
},
functioncall_3: localfunc('echo 3'), // function reference
// ^^^^^^^^^^^^^^ Identifier
// ^^^^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^^^ Comment
in_super: 'keynotfound' in super,
// ^^^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^ Keyword
// ^^^^^ Keyword
array+: ['another item'],
// ^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
objforloop+: { another: 'item' },
// ^^^^^^^^^^ Identifier
// ^^^^^^^ Identifier
// ^ StringLiteral
// ^^^^ StringLiteral
// ^ StringLiteral
['fieldname_expr' + (5 - object.objforloop.index2)]: 'value',
// ^ StringLiteral
// ^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^ IdentifierOperator
// ^^ StringLiteral
// ^ NumericLiteral
// ^ StringLiteral
// ^ IdentifierOperator
// ^ StringLiteral
// ^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^ Identifier
// ^ StringLiteral
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
[if object.string == 'string' then 'conditional_key']: 'value',
// ^^ Keyword
// ^ StringLiteral
// ^^^^^^ Identifier
// ^ StringLiteral
// ^^^^^^ Identifier
// ^ StringLiteral
// ^^ IdentifierOperator
// ^ StringLiteral
// ^ StringLiteral
// ^^^^^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^^^^ Keyword
// ^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^^^^^ StringLiteral
// ^ StringLiteral
}

View File

@ -20,6 +20,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
// ^ PunctuationDelimiter
// ^^^^ Identifier
// ^ PunctuationDelimiter
import java.nio.channels.FileChannel
//^^^^^^ Keyword

View File

@ -3,13 +3,26 @@ source: crates/syntax-analysis/src/highlighting/tree_sitter.rs
expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
---
let range
//^^^ Keyword
| doc "Generate an array of integers in the range [`start`, `end`)."
// ^ PunctuationDelimiter
// ^^^ Keyword
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
| Number -> Number -> Array Number
// ^^^^^^^^^^^^^^^^^^^^ IdentifierType
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierType
// ^ IdentifierType
// ^^ PunctuationDelimiter
// ^ IdentifierType
// ^^^^^^ IdentifierType
// ^ IdentifierType
// ^^ PunctuationDelimiter
// ^ IdentifierType
// ^^^^^ IdentifierBuiltinType
// ^^^^^^^ IdentifierType
// ^ IdentifierType
// ^^^^^^ IdentifierType
= fun start end =>
// ^ PunctuationDelimiter
// ^^^ Keyword
if end <= start then
// ^^ Keyword
@ -18,62 +31,111 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
else
// ^^^^ Keyword
array.generate (fun x => x + start) (end - start)
// ^^^^^^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ Keyword
// ^ PunctuationDelimiter
// ^ PunctuationDelimiter
in
//^^ Keyword
let is_prime
//^^^ Keyword
| doc "Returns true if the argument is a prime number."
// ^ PunctuationDelimiter
// ^^^ Keyword
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
= fun x => x > 1 && array.all (fun d => x % d != 0) (range 2 (x - 1))
// ^ PunctuationDelimiter
// ^^^ Keyword
// ^ NumericLiteral
// ^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^^ Keyword
// ^ NumericLiteral
// ^^^^^ IdentifierFunction
// ^ NumericLiteral
// ^ PunctuationDelimiter
// ^ NumericLiteral
in
//^^ Keyword
let Prime = contract.from_predicate is_prime in
// ^^^^^^^^^^^^^^^^^^^^^^^ IdentifierFunction
//^^^ Keyword
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^^^^^^^^^^^^ IdentifierFunction
// ^^ Keyword
let primes
//^^^ Keyword
| doc "Generate `max` primes using Sieve of Eratosthenes."
// ^ PunctuationDelimiter
// ^^^ Keyword
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ StringLiteral
| Number -> Array Prime
// ^^^^^^^^^^ IdentifierType
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierType
// ^ IdentifierType
// ^^ PunctuationDelimiter
// ^ IdentifierType
// ^^^^^ IdentifierBuiltinType
// ^^^^^^ IdentifierType
= fun max =>
// ^ PunctuationDelimiter
// ^^^ Keyword
let limit = number.pow max (1 / 2) in # sqrt(max)
// ^^^^^^^^^^ IdentifierFunction
// ^^^ Keyword
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^^ IdentifierFunction
// ^ NumericLiteral
// ^ NumericLiteral
// ^^^^^^^^^^^ Comment
// ^^ Keyword
let drop_multiples = fun x xs =>
// ^^^ Keyword
// ^ PunctuationDelimiter
// ^^^ Keyword
let to_drop = max
// ^^^ Keyword
// ^ PunctuationDelimiter
|> array.generate (fun y => (y + 2) * x)
// ^^^^^^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^^^^^^ IdentifierFunction
// ^^^ Keyword
// ^ PunctuationDelimiter
// ^ NumericLiteral
// ^ PunctuationDelimiter
|> array.filter (fun y => y <= max) in
// ^^^^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierFunction
// ^^^ Keyword
// ^^ Keyword
|> array.flatten
// ^^^^^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^^^^^ IdentifierFunction
array.filter (fun y => array.all ((!=) y) to_drop) xs in
// ^^^^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^^^^ IdentifierFunction
// ^^^ Keyword
// ^^^^^^^^^ IdentifierFunction
// ^^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^^^ IdentifierFunction
// ^^ IdentifierOperator
// ^^ Keyword
let rec loop = fun x xs =>
// ^^^ Keyword
// ^^^ Keyword
// ^ PunctuationDelimiter
// ^^^ Keyword
if x > limit then
// ^^ Keyword
@ -83,16 +145,20 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Keyword
loop (x + 1) (drop_multiples x xs) in
// ^^^^ IdentifierFunction
// ^ PunctuationDelimiter
// ^ NumericLiteral
// ^^^^^^^^^^^^^^ IdentifierFunction
// ^ IdentifierFunction
// ^^ Keyword
loop 2 (range 2 max) in
// ^^^^ IdentifierFunction
// ^ NumericLiteral
// ^^^^^ IdentifierFunction
// ^ NumericLiteral
// ^^ Keyword
{
run = primes
// ^ PunctuationDelimiter
}

View File

@ -145,7 +145,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
self.name = name
// ^^^^ Identifier
// ^^^^ Identifier
// ^^^^ IdentifierAttribute
// ^ IdentifierOperator
// ^^^^ Identifier
@ -162,7 +162,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
self.name = name
// ^^^^ Identifier
// ^^^^ Identifier
// ^^^^ IdentifierAttribute
// ^ IdentifierOperator
// ^^^^ Identifier
def eat(self):
@ -175,7 +175,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ StringLiteralEscape
// ^^^^ Identifier
// ^ StringLiteral
// ^^^^ Identifier
// ^^^^ IdentifierAttribute
// ^ StringLiteralEscape
// ^^^^^^^^^^^^ StringLiteral
class Dog(Animal):
@ -192,7 +192,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ StringLiteralEscape
// ^^^^ Identifier
// ^ StringLiteral
// ^^^^ Identifier
// ^^^^ IdentifierAttribute
// ^ StringLiteralEscape
// ^^^^^^^^^^^^ StringLiteral
dog = Dog("Rover")
@ -394,12 +394,12 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
self.firstname = first
// ^^^^ Identifier
// ^^^^^^^^^ Identifier
// ^^^^^^^^^ IdentifierAttribute
// ^ IdentifierOperator
// ^^^^^ Identifier
self.lastname = last
// ^^^^ Identifier
// ^^^^^^^^ Identifier
// ^^^^^^^^ IdentifierAttribute
// ^ IdentifierOperator
// ^^^^ Identifier
@property
@ -415,13 +415,13 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ StringLiteralEscape
// ^^^^ Identifier
// ^ StringLiteral
// ^^^^^^^^^ Identifier
// ^^^^^^^^^ IdentifierAttribute
// ^ StringLiteralEscape
// ^ StringLiteral
// ^ StringLiteralEscape
// ^^^^ Identifier
// ^ StringLiteral
// ^^^^^^^^ Identifier
// ^^^^^^^^ IdentifierAttribute
// ^ StringLiteralEscape
// ^ StringLiteral
@ -433,7 +433,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^ StringLiteral
p.name # Calls the getter
//^ Identifier
// ^^^^ Identifier
// ^^^^ IdentifierAttribute
// ^^^^^^^^^^^^^^^^^^ Comment
# Magic methods:
//^^^^^^^^^^^^^^^^ Comment
@ -447,7 +447,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ Identifier
self.n = n
// ^^^^ Identifier
// ^ Identifier
// ^ IdentifierAttribute
// ^ IdentifierOperator
// ^ Identifier
def __add__(self, other):
@ -458,10 +458,10 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
return self.n + other.n
// ^^^^^^ Keyword
// ^^^^ Identifier
// ^ Identifier
// ^ IdentifierAttribute
// ^ IdentifierOperator
// ^^^^^ Identifier
// ^ Identifier
// ^ IdentifierAttribute
a = Adder(10)
//^ Identifier
// ^ IdentifierOperator

View File

@ -17,19 +17,17 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ TagDelimiter
// ^^^ Tag
// ^ TagDelimiter
// TagDelimiter 3:13..4:13
<p />
// ^ TagDelimiter
// ^ Tag
// ^ TagDelimiter
// ^ TagDelimiter
// ^^ TagDelimiter
// TagDelimiter 4:17..5:13
<h1 id={name}>My Component</h1>
// ^ TagDelimiter
// ^^ Tag
// ^^ TagAttribute
// ^^^^ Identifier
// ^ TagDelimiter
// ^ TagDelimiter
// ^ TagDelimiter
// ^^ TagDelimiter
// ^^ Tag
// ^ TagDelimiter
{[1, 2, 3].map(item => (
@ -45,15 +43,14 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
// ^ TagDelimiter
// ^^^^ Identifier
// ^ TagDelimiter
// ^ TagDelimiter
// ^^ TagDelimiter
// ^ Tag
// ^ TagDelimiter
))}
// TagDelimiter 8:15..9:10
</div>
// ^ TagDelimiter
// ^ TagDelimiter
// ^^^ Tag
// ^ TagDelimiter
)
}

View File

@ -19,19 +19,17 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^ TagDelimiter
// ^^^ Tag
// ^ TagDelimiter
// TagDelimiter 3:13..4:13
<p />
// ^ TagDelimiter
// ^ Tag
// ^ TagDelimiter
// ^ TagDelimiter
// ^^ TagDelimiter
// TagDelimiter 4:17..5:13
<h1 id={name}>My Component</h1>
// ^ TagDelimiter
// ^^ Tag
// ^^ TagAttribute
// ^^^^ Identifier
// ^ TagDelimiter
// ^ TagDelimiter
// ^ TagDelimiter
// ^^ TagDelimiter
// ^^ Tag
// ^ TagDelimiter
{[1, 2, 3].map(item => (
@ -47,15 +45,14 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ Identifier
// ^ TagDelimiter
// ^^^^ Identifier
// ^ TagDelimiter
// ^ TagDelimiter
// ^^ TagDelimiter
// ^ Tag
// ^ TagDelimiter
))}
// TagDelimiter 8:15..9:10
</div>
// ^ TagDelimiter
// ^ TagDelimiter
// ^^^ Tag
// ^ TagDelimiter
)
}

View File

@ -3,6 +3,8 @@ source: crates/syntax-analysis/src/highlighting/tree_sitter.rs
expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
---
#![allow(all)]
// ^^^^^ Identifier
// ^^^ Identifier
#![allow(unreachable_patterns)]
// ^^^^^ Identifier
// ^^^^^^^^^^^^^^^^^^^^ Identifier
@ -32,7 +34,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
let option = Some(5);
// ^^^ Keyword
// ^^^^^^ Identifier
// ^^^^ IdentifierConstant
// ^^^^ IdentifierFunction
// ^ NumericLiteral
// Match arm
// ^^^^^^^^^^^^ Comment
@ -307,7 +309,7 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^ Keyword
// ^^^^^^ Identifier
// ^^^^^^^ IdentifierType
// ^^^^^^ IdentifierConstant
// ^^^^^^ IdentifierFunction
// ^^^^^^^^ StringLiteral
// ^^^^^^^^^ IdentifierFunction
// ^ NumericLiteral

View File

@ -128,7 +128,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^ IdentifierBuiltin
key3: `abc${d1.e2}`,
// ^^^^ IdentifierAttribute
// ^^^^ StringLiteral
// ^ StringLiteral
// ^^^ StringLiteral
// ^^ StringLiteralEscape
// ^^ Identifier
// ^ StringLiteral
@ -264,7 +265,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
// ^^^^^^ Identifier
// ^^^ Keyword
// ^^^^^^ Identifier
// ^^ StringLiteral
// ^ StringLiteral
// ^ StringLiteral
// ^^ StringLiteralEscape
// ^^^^^^ Identifier
// ^ StringLiteral
@ -482,7 +484,8 @@ expression: "snapshot_treesitter_syntax_kinds(&document, &contents)"
console.log(`Value is a string: ${unionExample}`);
// ^^^^^^^ Identifier
// ^^^ IdentifierFunction
// ^^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^ StringLiteral
// ^^^^^^^^^^^^^^^^^^^ StringLiteral
// ^^ StringLiteralEscape
// ^^^^^^^^^^^^ Identifier
// ^ StringLiteralEscape

View File

@ -1,6 +1,5 @@
use std::collections::HashMap;
use paste::paste;
use scip::types::{Document, Occurrence, SyntaxKind};
use tree_sitter_all_languages::ParserId;
use tree_sitter_highlight::{
@ -102,7 +101,8 @@ macro_rules! create_configurations {
{
// Create HighlightConfiguration language
let mut lang = HighlightConfiguration::new(
paste! { ParserId::$name.language() },
ParserId::$name.language(),
stringify!("{}", $name),
include_scip_query!($dirname, "highlights"),
include_scip_query!($dirname, "injections"),
include_scip_query!($dirname, "locals"),
@ -123,6 +123,7 @@ macro_rules! create_configurations {
];
let mut lang = HighlightConfiguration::new(
ParserId::Typescript.language(),
"typescript",
&highlights.join("\n"),
include_scip_query!("typescript", "injections"),
include_scip_query!("typescript", "locals"),
@ -132,12 +133,13 @@ macro_rules! create_configurations {
}
{
let highlights = vec![
include_scip_query!("tsx", "highlights"),
include_scip_query!("typescript", "highlights"),
include_scip_query!("javascript", "highlights"),
include_scip_query!("typescript", "highlights"),
include_scip_query!("tsx", "highlights"),
];
let mut lang = HighlightConfiguration::new(
ParserId::Tsx.language(),
"tsx",
&highlights.join("\n"),
include_scip_query!("tsx", "injections"),
include_scip_query!("tsx", "locals"),
@ -151,11 +153,12 @@ macro_rules! create_configurations {
// We have a separate file for jsx since TypeScript inherits the base javascript highlights
// and if we include the query for jsx attributes it would fail since it is not in the tree-sitter
// grammar for TypeScript.
include_scip_query!("javascript", "highlights-jsx"),
include_scip_query!("javascript", "highlights"),
include_scip_query!("javascript", "highlights-jsx"),
];
let mut lang = HighlightConfiguration::new(
ParserId::Javascript.language(),
"javascript",
&highlights.join("\n"),
include_scip_query!("javascript", "injections"),
include_scip_query!("javascript", "locals"),
@ -466,13 +469,16 @@ mod test {
.expect("dump document")
}
fn get_language_for_test(filepath: &std::path::Path, contents: &str) -> TreeSitterLanguageName {
fn get_language_for_test(
filepath: &std::path::Path,
contents: &str,
) -> Option<TreeSitterLanguageName> {
let language_from_syntect = crate::highlighting::test::SYNTAX_SET
.with(|syntax_set| {
FileInfo::new(filepath.to_string_lossy().as_ref(), contents, None)
.determine_language(syntax_set)
})
.unwrap();
.ok()?;
// If we can't determine language from Syntect, determine from path just for the test
// This is only needed for test, since when running in production, we
@ -486,11 +492,11 @@ mod test {
if let Some(extension) = filepath.extension();
if let Some(parser_id) = ParserId::from_file_extension(extension.to_str().unwrap());
then {
return TreeSitterLanguageName::new(parser_id.name());
return Some(TreeSitterLanguageName::new(parser_id.name()));
}
}
language_from_syntect
Some(language_from_syntect)
}
#[test]
@ -546,9 +552,13 @@ SELECT * FROM my_table
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let language = get_language_for_test(&filepath, &contents);
let Some(language) = get_language_for_test(&filepath, &contents) else {
continue;
};
let document = language.highlight_document(&contents, true).unwrap();
let Ok(document) = language.highlight_document(&contents, true) else {
continue;
};
// TODO: I'm not sure if there's a better way to run the snapshots without
// panicing and then catching, but this will do for now.
let panic_or_value = std::panic::catch_unwind(|| {
@ -594,9 +604,13 @@ SELECT * FROM my_table
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let language = get_language_for_test(&filepath, &contents);
let Some(language) = get_language_for_test(&filepath, &contents) else {
continue;
};
let document = language.highlight_document(&contents, true).unwrap();
let Ok(document) = language.highlight_document(&contents, true) else {
continue;
};
// TODO: I'm not sure if there's a better way to run the snapshots without
// panicing and then catching, but this will do for now.

View File

@ -49,7 +49,7 @@ impl TagConfiguration {
_ => query_text.to_string(),
};
let query = Query::new(language, &query_text).expect("to parse query");
let query = Query::new(&language, &query_text).expect("to parse query");
let mut transforms = HashMap::new();
let mut filters = HashMap::new();
@ -142,7 +142,9 @@ impl TagConfiguration {
pub fn get_parser(&self) -> Parser {
let mut parser = Parser::new();
parser.set_language(self.language).expect("to get a parser");
parser
.set_language(&self.language)
.expect("to get a parser");
parser
}
@ -185,7 +187,9 @@ pub struct LocalConfiguration {
impl LocalConfiguration {
pub fn get_parser(&self) -> Parser {
let mut parser = Parser::new();
parser.set_language(self.language).expect("to get a parser");
parser
.set_language(&self.language)
.expect("to get a parser");
parser
}
}
@ -258,8 +262,8 @@ mod locals {
let query = include_scip_query!($file, "scip-locals");
LocalConfiguration {
query: Query::new(&language, query).unwrap(),
language,
query: Query::new(language, query).unwrap(),
}
})
}

View File

@ -593,6 +593,7 @@ impl<'a> LocalResolver<'a> {
let Some(capture_name) = capture_names.get(capture.index as usize) else {
continue;
};
let capture_name = *capture_name;
if capture_name.starts_with("scope") {
let kind = capture_name.strip_prefix("scope.").unwrap_or(capture_name);
scopes.push(ScopeCapture {

View File

@ -34,9 +34,7 @@ expression: dumped
// ^^^^ definition scip-ctags MyEnum.decl.
a,
// ^ definition scip-ctags MyEnum.a.
b,
// ^ definition scip-ctags MyEnum.b.
pub fn init() void {};
// ^^^^ definition scip-ctags MyEnum.init().

View File

@ -17,10 +17,10 @@ pub fn capture_name_to_descriptor(capture: &str, name: String) -> Descriptor {
}
}
pub fn captures_to_kind(kind: &Option<&String>) -> symbol_information::Kind {
pub fn captures_to_kind(kind: &Option<&str>) -> symbol_information::Kind {
use symbol_information::Kind::*;
kind.map_or(UnspecifiedKind, |kind| match kind.as_str() {
kind.map_or(UnspecifiedKind, |kind| match kind {
"kind.accessor" => Accessor,
"kind.class" => Class,
"kind.constant" => Constant,

View File

@ -8,32 +8,34 @@ edition = "2021"
[dependencies]
tree-sitter.workspace = true
tree-sitter-c = "0.20.2"
tree-sitter-c-sharp = "0.20.0"
tree-sitter-cpp = "0.20.3"
tree-sitter-go = "0.20.0"
tree-sitter-java = "0.20.2"
tree-sitter-javascript = "0.20.0"
tree-sitter-scala = "0.20.1"
tree-sitter-python = "0.20.2"
tree-sitter-ruby = "0.20.0"
tree-sitter-rust = "0.20.3"
tree-sitter-typescript = "0.20.2"
tree-sitter-c = "0.21.4"
tree-sitter-c-sharp = "0.21.3"
tree-sitter-cpp = "0.22.3"
tree-sitter-go = "0.21.0"
tree-sitter-java = "0.21.0"
tree-sitter-javascript = "0.21.4"
tree-sitter-scala = "0.22.1"
tree-sitter-python = "0.21.0"
tree-sitter-ruby = "0.21.0"
tree-sitter-rust = "0.21.2"
tree-sitter-typescript = "0.21.2"
tree-sitter-dart = { git = "https://github.com/UserNobody14/tree-sitter-dart", rev = "923fbe0d3e62340ea78422551166ce946bc05222" }
tree-sitter-jsonnet = { git = "https://github.com/sourcegraph/tree-sitter-jsonnet", rev = "009e6f06266f46ae07077dd6c8026ded56ab7dd8" }
tree-sitter-kotlin = { git = "https://github.com/fwcd/tree-sitter-kotlin", rev = "100d79fd96b56a1b99099a8d2f3c114b8687acfb" }
tree-sitter-magik = { git = "https://github.com/sourcegraph/tree-sitter-magik", rev = "dfabbd4e70ff311939cf48fdf90d340f07758d37" }
tree-sitter-matlab = { git = "https://github.com/acristoffers/tree-sitter-matlab", rev = "6071891a8c39600203eba20513666cf93b4d650a" }
tree-sitter-nickel = { git = "https://github.com/nickel-lang/tree-sitter-nickel", rev = "d6c7eeb751038f934b5b1aa7ff236376d0235c56" }
tree-sitter-perl = { git = "https://github.com/sourcegraph/tree-sitter-perl", rev = "e1b4844afd17b7dc019a436b1ac890568d79a1f2" }
tree-sitter-pkl = { git = "https://github.com/apple/tree-sitter-pkl", rev = "b79c8c4d2419e82324d9aca31e9de47ed8304f1f" }
tree-sitter-pod = { git = "https://github.com/sourcegraph/tree-sitter-pod", rev = "f422a0dca6847c692e811f06fd92c6a75d647222" }
tree-sitter-xlsg = { git = "https://github.com/sourcegraph/tree-sitter-xlsg", rev = "d956b54ea151b12f19c945f7be421c3dcd3a77ba" }
tree-sitter-zig = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "2c7b6308d906d7aec4b3e1fafaaeca447a8a2c2f" }
# https://github.com/fwcd/tree-sitter-kotlin
tree-sitter-kotlin = "0.3.8"
# https://github.com/DerekStride/tree-sitter-sql
tree-sitter-sequel = "0.3.5"
# As of 2022 Apr 06, the upstream crate seems to have paused development,
# and it relies to tree-sitter 0.19.x creating a type mismatch. So depend
# on our own fork.
tree-sitter-sql = { git = "https://github.com/sourcegraph/tree-sitter-sql", rev = "6ea62b8d33c9e39f6de8a398a6885d1873ed7e91" }
tree-sitter-hack = { git = "https://github.com/slackhq/tree-sitter-hack", rev = "fca1e294f6dce8ec5659233a6a21f5bd0ed5b4f2" }
tree-sitter-dart = { git = "https://github.com/UserNobody14/tree-sitter-dart", rev = "cf72df5d4a623ca705e81bf9e9d264e1fe9d5da0" }
tree-sitter-jsonnet = { git = "https://github.com/kritzcreek/tree-sitter-jsonnet", rev = "bc147652f72a14c9627deae5c9c33a81e452d391" }
tree-sitter-magik = { git = "https://github.com/kritzcreek/tree-sitter-magik", rev = "d7614f9820563598b0e1e009b3e4707f60af405f" }
tree-sitter-matlab = { git = "https://github.com/kritzcreek/tree-sitter-matlab", rev = "762d3ac3daf68cff04c376a42fd793b0f81ab9c1" }
tree-sitter-nickel = { git = "https://github.com/kritzcreek/tree-sitter-nickel", rev = "46a808abaa3d0f460c859af3c3b9467641f13063" }
tree-sitter-perl = { git = "https://github.com/sourcegraph/tree-sitter-perl", rev = "fa0118e558b788c7ebd8646d3d1eea42dcf321ee" }
tree-sitter-pod = { git = "https://github.com/sourcegraph/tree-sitter-pod", rev = "b99354aaa6b11c6d9edda3285567d94ed02c0e34" }
# Not PR-ed, as there is a more comprehensive PR in the upstream repo: https://github.com/apple/tree-sitter-pkl/pull/8
# My personal fork contains the minimal changes to make things build with the latest tree-sitter.
tree-sitter-pkl = { git = "https://github.com/kritzcreek/tree-sitter-pkl", rev = "372ce76dfae3395fcf083df23328c4eb67cc0119" }
tree-sitter-xlsg = { git = "https://github.com/sourcegraph/tree-sitter-xlsg", rev = "deb2a12e617ad5e3720a1464848949cc46b375be" }
tree-sitter-zig = { git = "https://github.com/maxxnino/tree-sitter-zig", rev = "2bac4cc6c697d46a193905fef6d003bfa0bfabfd" }
tree-sitter-hack = { git = "https://github.com/kritzcreek/tree-sitter-hack", rev = "2a1f331c3b43a2262823f788a222e15a264d1062" }

View File

@ -58,7 +58,7 @@ impl ParserId {
ParserId::Ruby => tree_sitter_ruby::language(),
ParserId::Rust => tree_sitter_rust::language(),
ParserId::Scala => tree_sitter_scala::language(),
ParserId::Sql => tree_sitter_sql::language(),
ParserId::Sql => tree_sitter_sequel::language(),
ParserId::Typescript => tree_sitter_typescript::language_typescript(),
ParserId::Tsx => tree_sitter_typescript::language_tsx(),
ParserId::Xlsg => tree_sitter_xlsg::language(),
@ -68,7 +68,7 @@ impl ParserId {
pub fn get_parser(self) -> tree_sitter::Parser {
let mut parser = tree_sitter::Parser::new();
parser.set_language(self.language()).expect("Error assigning language to parser, likely a version mismatch between compiled grammar and tree-sitter library.");
parser.set_language(&self.language()).expect("Error assigning language to parser, likely a version mismatch between compiled grammar and tree-sitter library.");
parser
}