Skip to content

Commit

Permalink
feat(c#): Scope destructor definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Aug 11, 2024
1 parent d8b5e7a commit 6f9677b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,7 @@ Language scopes:
- variable-declaration: Variable declarations (in their entirety)
- property: Property definitions (in their entirety)
- constructor: Constructor definitions (in their entirety)
- destructor: Destructor definitions (in their entirety)
- field: Field definitions on types (in their entirety)
- attribute: Attribute names

Expand Down
3 changes: 3 additions & 0 deletions src/scoping/langs/csharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub enum PreparedCSharpQuery {
Property,
/// Constructor definitions (in their entirety).
Constructor,
/// Destructor definitions (in their entirety).
Destructor,
/// Field definitions on types (in their entirety).
Field,
/// Attribute names.
Expand Down Expand Up @@ -72,6 +74,7 @@ impl From<PreparedCSharpQuery> for TSQuery {
PreparedCSharpQuery::VariableDeclaration => "(variable_declaration) @variable",
PreparedCSharpQuery::Property => "(property_declaration) @property",
PreparedCSharpQuery::Constructor => "(constructor_declaration) @constructor",
PreparedCSharpQuery::Destructor => "(destructor_declaration) @destructor",
PreparedCSharpQuery::Field => "(field_declaration) @field",
PreparedCSharpQuery::Attribute => "(attribute) @attribute",
},
Expand Down
5 changes: 5 additions & 0 deletions tests/langs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ impl InScopeLinePart {
include_str!("csharp/base.cs"),
CSharp::new(CodeQuery::Prepared(PreparedCSharpQuery::Constructor)),
)]
#[case(
"base.cs_destructor",
include_str!("csharp/base.cs"),
CSharp::new(CodeQuery::Prepared(PreparedCSharpQuery::Destructor)),
)]
fn test_language_scopers(
#[case] snapshot_name: &str,
#[case] contents: &str,
Expand Down
7 changes: 7 additions & 0 deletions tests/langs/snapshots/r#mod__langs__base.cs_destructor.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: tests/langs/mod.rs
expression: inscope_parts
---
- n: 50
l: " ~TestBase() => Console.WriteLine(\"Test finalized.\");\n"
m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "

0 comments on commit 6f9677b

Please sign in to comment.