Skip to content

Commit

Permalink
Use tree-sitter-c-sharp from crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Dec 20, 2024
1 parent de6e670 commit 2bbed44
Show file tree
Hide file tree
Showing 66 changed files with 229 additions and 1,588,921 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ with YAML.

Improved language detection when one argument is a named pipe.

Updated to the latest tree-sitter parser for Haskell, Objective-C,
Updated to the latest tree-sitter parser for C#, Haskell, Objective-C,
OCaml, Ruby and Scala.

### Syntax Highlighting
Expand Down
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ tree-sitter-ruby = "0.23.1"
tree-sitter-scala = "0.23.3"
tree-sitter-objc = "3.0.2"
tree-sitter-ocaml = "0.23.2"
tree-sitter-c-sharp = "0.23.1"

[dev-dependencies]
# assert_cmd 2.0.10 requires predicates 3.
Expand Down
5 changes: 0 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ fn main() {
src_dir: "vendored_parsers/tree-sitter-cpp-src",
extra_files: vec!["scanner.c"],
},
TreeSitterParser {
name: "tree-sitter-c-sharp",
src_dir: "vendored_parsers/tree-sitter-c-sharp-src",
extra_files: vec!["scanner.c"],
},
TreeSitterParser {
name: "tree-sitter-clojure",
src_dir: "vendored_parsers/tree-sitter-clojure-src",
Expand Down
4 changes: 2 additions & 2 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ extern "C" {
fn tree_sitter_apex() -> ts::Language;
fn tree_sitter_bash() -> ts::Language;
fn tree_sitter_c() -> ts::Language;
fn tree_sitter_c_sharp() -> ts::Language;
fn tree_sitter_clojure() -> ts::Language;
fn tree_sitter_cmake() -> ts::Language;
fn tree_sitter_cpp() -> ts::Language;
Expand Down Expand Up @@ -262,7 +261,8 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
}
}
CSharp => {
let language = unsafe { tree_sitter_c_sharp() };
let language_fn = tree_sitter_c_sharp::LANGUAGE;
let language = tree_sitter::Language::new(language_fn);
TreeSitterConfig {
language: language.clone(),
atom_nodes: vec![
Expand Down
1 change: 0 additions & 1 deletion vendored_parsers/highlights/c-sharp.scm

This file was deleted.

214 changes: 214 additions & 0 deletions vendored_parsers/highlights/c-sharp.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
;; https://github.com/tree-sitter/tree-sitter-c-sharp/blob/4bf615f8d688f50d69fc5677187dc35f22e03ad6/queries/highlights.scm
;; MIT license
(identifier) @variable

;; Methods

(method_declaration name: (identifier) @function)
(local_function_statement name: (identifier) @function)

;; Types

(interface_declaration name: (identifier) @type)
(class_declaration name: (identifier) @type)
(enum_declaration name: (identifier) @type)
(struct_declaration (identifier) @type)
(record_declaration (identifier) @type)
(namespace_declaration name: (identifier) @module)

(generic_name (identifier) @type)
(type_parameter (identifier) @property.definition)
(parameter type: (identifier) @type)
(type_argument_list (identifier) @type)
(as_expression right: (identifier) @type)
(is_expression right: (identifier) @type)

(constructor_declaration name: (identifier) @constructor)
(destructor_declaration name: (identifier) @constructor)

(_ type: (identifier) @type)

(base_list (identifier) @type)

(predefined_type) @type.builtin

;; Enum
(enum_member_declaration (identifier) @property.definition)

;; Literals

[
(real_literal)
(integer_literal)
] @number

[
(character_literal)
(string_literal)
(raw_string_literal)
(verbatim_string_literal)
(interpolated_string_expression)
(interpolation_start)
(interpolation_quote)
] @string

(escape_sequence) @string.escape

[
(boolean_literal)
(null_literal)
] @constant.builtin

;; Comments

(comment) @comment

;; Tokens

[
";"
"."
","
] @punctuation.delimiter

[
"--"
"-"
"-="
"&"
"&="
"&&"
"+"
"++"
"+="
"<"
"<="
"<<"
"<<="
"="
"=="
"!"
"!="
"=>"
">"
">="
">>"
">>="
">>>"
">>>="
"|"
"|="
"||"
"?"
"??"
"??="
"^"
"^="
"~"
"*"
"*="
"/"
"/="
"%"
"%="
":"
] @operator

[
"("
")"
"["
"]"
"{"
"}"
(interpolation_brace)
] @punctuation.bracket

;; Keywords

[
(modifier)
"this"
(implicit_type)
] @keyword

[
"add"
"alias"
"as"
"base"
"break"
"case"
"catch"
"checked"
"class"
"continue"
"default"
"delegate"
"do"
"else"
"enum"
"event"
"explicit"
"extern"
"finally"
"for"
"foreach"
"global"
"goto"
"if"
"implicit"
"interface"
"is"
"lock"
"namespace"
"notnull"
"operator"
"params"
"return"
"remove"
"sizeof"
"stackalloc"
"static"
"struct"
"switch"
"throw"
"try"
"typeof"
"unchecked"
"using"
"while"
"new"
"await"
"in"
"yield"
"get"
"set"
"when"
"out"
"ref"
"from"
"where"
"select"
"record"
"init"
"with"
"let"
] @keyword

;; Attribute

(attribute name: (identifier) @attribute)

;; Parameters

(parameter
name: (identifier) @variable.parameter)

;; Type constraints

(type_parameter_constraints_clause (identifier) @property.definition)

;; Method calls

(invocation_expression (member_access_expression name: (identifier) @function))
1 change: 0 additions & 1 deletion vendored_parsers/tree-sitter-c-sharp-src

This file was deleted.

4 changes: 0 additions & 4 deletions vendored_parsers/tree-sitter-c-sharp/.gitattributes

This file was deleted.

36 changes: 0 additions & 36 deletions vendored_parsers/tree-sitter-c-sharp/.github/workflows/build.yml

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions vendored_parsers/tree-sitter-c-sharp/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions vendored_parsers/tree-sitter-c-sharp/.npmignore

This file was deleted.

Loading

0 comments on commit 2bbed44

Please sign in to comment.