Unnamed repository; edit this file 'description' to name the repository.
language support: CodeQL (#12470)
Evan Richter 2025-01-10
parent a83c23b · commit 9721144
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml16
-rw-r--r--runtime/queries/codeql/highlights.scm104
-rw-r--r--runtime/queries/codeql/textobjects.scm16
4 files changed, 137 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 45f69a54..7ec7ec5a 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -23,6 +23,7 @@
| circom | ✓ | | | `circom-lsp` |
| clojure | ✓ | | | `clojure-lsp` |
| cmake | ✓ | ✓ | ✓ | `cmake-language-server` |
+| codeql | ✓ | ✓ | | `codeql` |
| comment | ✓ | | | |
| common-lisp | ✓ | | ✓ | `cl-lsp` |
| cpon | ✓ | | ✓ | |
diff --git a/languages.toml b/languages.toml
index 50e7d823..504613a1 100644
--- a/languages.toml
+++ b/languages.toml
@@ -21,6 +21,7 @@ cl-lsp = { command = "cl-lsp", args = [ "stdio" ] }
clangd = { command = "clangd" }
clojure-lsp = { command = "clojure-lsp" }
cmake-language-server = { command = "cmake-language-server" }
+codeql = { command = "codeql", args = ["execute", "language-server", "--check-errors=ON_CHANGE"] }
crystalline = { command = "crystalline", args = ["--stdio"] }
cs = { command = "cs", args = ["launch", "--contrib", "smithy-language-server", "--", "0"] }
csharp-ls = { command = "csharp-ls" }
@@ -4033,3 +4034,18 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "nginx"
source = { git = "https://gitlab.com/joncoole/tree-sitter-nginx", rev = "b4b61db443602b69410ab469c122c01b1e685aa0" }
+
+[[language]]
+name = "codeql"
+scope = "source.ql"
+file-types = ["ql", "qll"]
+comment-token = "//"
+block-comment-tokens = { start = "/*", end = "*/" }
+indent = { tab-width = 2, unit = " " }
+injection-regex = "codeql"
+grammar = "ql"
+language-servers = ["codeql"]
+
+[[grammar]]
+name = "ql"
+source = { git = "https://github.com/tree-sitter/tree-sitter-ql", rev = "1fd627a4e8bff8c24c11987474bd33112bead857" }
diff --git a/runtime/queries/codeql/highlights.scm b/runtime/queries/codeql/highlights.scm
new file mode 100644
index 00000000..aed7b538
--- /dev/null
+++ b/runtime/queries/codeql/highlights.scm
@@ -0,0 +1,104 @@
+[
+ "and"
+ "any"
+ "as"
+ "asc"
+ "avg"
+ "by"
+ "class"
+ "concat"
+ "count"
+ "desc"
+ "else"
+ "exists"
+ "extends"
+ "forall"
+ "forex"
+ "from"
+ "if"
+ "implements"
+ "implies"
+ "import"
+ "in"
+ "instanceof"
+ "max"
+ "min"
+ "module"
+ "newtype"
+ "not"
+ "or"
+ "order"
+ "rank"
+ "select"
+ "strictconcat"
+ "strictcount"
+ "strictsum"
+ "sum"
+ "then"
+ "where"
+
+ (false)
+ (predicate)
+ (result)
+ (specialId)
+ (super)
+ (this)
+ (true)
+] @keyword
+
+[
+ "boolean"
+ "float"
+ "int"
+ "date"
+ "string"
+] @type.builtin
+
+(annotName) @attribute
+
+[
+ "<"
+ "<="
+ "="
+ ">"
+ ">="
+ "-"
+ "!="
+ "/"
+ "*"
+ "%"
+ "+"
+ "::"
+] @operator
+
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+] @punctuation.bracket
+
+[
+ ","
+ "|"
+] @punctuation.delimiter
+
+(className) @type
+
+(varName) @variable
+
+(integer) @constant.numeric.integer
+(float) @constant.numeric.float
+
+(string) @string
+
+(aritylessPredicateExpr (literalId) @function)
+(predicateName) @function
+
+[
+ (line_comment)
+ (block_comment)
+ (qldoc)
+] @comment
diff --git a/runtime/queries/codeql/textobjects.scm b/runtime/queries/codeql/textobjects.scm
new file mode 100644
index 00000000..8ca02e3c
--- /dev/null
+++ b/runtime/queries/codeql/textobjects.scm
@@ -0,0 +1,16 @@
+(qldoc) @comment.around
+(block_comment) @comment.around
+(line_comment) @comment.inside
+(line_comment)+ @comment.around
+
+(classlessPredicate
+ ((varDecl) @parameter.inside . ","?) @parameter.around
+ (body "{" (_)* @function.inside "}")) @function.around
+(memberPredicate
+ ((varDecl) @parameter.inside . ","?) @parameter.around
+ (body "{" (_)* @function.inside "}")) @function.around
+
+(dataclass
+ ("{" (_)* @class.inside "}")?) @class.around
+(datatype) @class.around
+(datatypeBranch) @class.around