diff --git a/README.md b/README.md index 3c64944c..c324f054 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/scoping/langs/csharp.rs b/src/scoping/langs/csharp.rs index fb92e48d..36cc424d 100644 --- a/src/scoping/langs/csharp.rs +++ b/src/scoping/langs/csharp.rs @@ -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. @@ -72,6 +74,7 @@ impl From 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", }, diff --git a/tests/langs/mod.rs b/tests/langs/mod.rs index f7f6a2bd..60de2650 100644 --- a/tests/langs/mod.rs +++ b/tests/langs/mod.rs @@ -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, diff --git a/tests/langs/snapshots/r#mod__langs__base.cs_destructor.snap b/tests/langs/snapshots/r#mod__langs__base.cs_destructor.snap new file mode 100644 index 00000000..bb20edd3 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cs_destructor.snap @@ -0,0 +1,7 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 50 + l: " ~TestBase() => Console.WriteLine(\"Test finalized.\");\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "