From 12accc08b7192bc8ab78bdc44471597f8449f716 Mon Sep 17 00:00:00 2001 From: Maxim Zhukov Date: Sun, 22 Sep 2024 12:56:31 +0300 Subject: [PATCH] feat(cpp): introduce C++ parser --- Cargo.lock | 11 ++ Cargo.toml | 1 + README.md | 69 +++++++ src/main.rs | 17 ++ src/scoping/langs/cpp.rs | 151 +++++++++++++++ src/scoping/langs/mod.rs | 2 + tests/langs/cpp/base.cpp | 102 ++++++++++ tests/langs/mod.rs | 131 +++++++++++++ .../r#mod__langs__base.cpp_call_expr.snap | 19 ++ .../r#mod__langs__base.cpp_class.snap | 46 +++++ .../r#mod__langs__base.cpp_comments.snap | 19 ++ .../r#mod__langs__base.cpp_declaration.snap | 31 ++++ .../snapshots/r#mod__langs__base.cpp_do.snap | 10 + .../r#mod__langs__base.cpp_enum.snap | 19 ++ ...od__langs__base.cpp_field_declaration.snap | 28 +++ .../snapshots/r#mod__langs__base.cpp_for.snap | 16 ++ .../r#mod__langs__base.cpp_function.snap | 16 ++ ..._langs__base.cpp_function_declaration.snap | 25 +++ ...__langs__base.cpp_function_definition.snap | 175 ++++++++++++++++++ .../r#mod__langs__base.cpp_ident.snap | 82 ++++++++ .../snapshots/r#mod__langs__base.cpp_if.snap | 10 + .../r#mod__langs__base.cpp_includes.snap | 10 + .../r#mod__langs__base.cpp_lambda.snap | 13 ++ .../r#mod__langs__base.cpp_namespace.snap | 10 + .../r#mod__langs__base.cpp_strings.snap | 16 ++ .../r#mod__langs__base.cpp_struct.snap | 25 +++ .../r#mod__langs__base.cpp_switch.snap | 25 +++ .../r#mod__langs__base.cpp_template.snap | 13 ++ .../snapshots/r#mod__langs__base.cpp_try.snap | 28 +++ .../r#mod__langs__base.cpp_typedef.snap | 7 + .../r#mod__langs__base.cpp_union.snap | 16 ++ ...#mod__langs__base.cpp_using_namespace.snap | 7 + .../r#mod__langs__base.cpp_variable.snap | 31 ++++ .../r#mod__langs__base.cpp_while.snap | 10 + 34 files changed, 1191 insertions(+) create mode 100644 src/scoping/langs/cpp.rs create mode 100644 tests/langs/cpp/base.cpp create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_call_expr.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_class.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_comments.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_declaration.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_do.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_enum.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_field_declaration.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_for.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_function.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_function_declaration.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_function_definition.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_ident.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_if.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_includes.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_lambda.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_namespace.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_strings.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_struct.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_switch.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_template.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_try.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_typedef.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_union.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_using_namespace.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_variable.snap create mode 100644 tests/langs/snapshots/r#mod__langs__base.cpp_while.snap diff --git a/Cargo.lock b/Cargo.lock index 1b2b24d3..f584edec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1161,6 +1161,7 @@ dependencies = [ "titlecase", "tree-sitter", "tree-sitter-c-sharp", + "tree-sitter-cpp", "tree-sitter-go", "tree-sitter-python", "tree-sitter-rust", @@ -1292,6 +1293,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-cpp" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0a588a816017469b69f2e3544742e34a5a59dddfb4b9457b657a6052e2ea39c" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-go" version = "0.23.1" diff --git a/Cargo.toml b/Cargo.toml index 9a0a79d7..eb841bae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,6 +55,7 @@ tempfile = "3.12.0" titlecase = "3.3.0" tree-sitter = "0.23.0" tree-sitter-c-sharp = "0.23.0" +tree-sitter-cpp = "0.23.0" tree-sitter-go = "0.23.1" tree-sitter-python = "0.23.2" tree-sitter-rust = "0.23.0" diff --git a/README.md b/README.md index 03b86b26..c7e23302 100644 --- a/README.md +++ b/README.md @@ -1061,6 +1061,36 @@ resource "aws_instance" "main" { } ``` +###### Rename class. + +Try to rename a class: + +```cpp file=example.cpp +class OldClass { +} + +int main() { + class OldClass newClass; +} +``` + +with + +```bash +cat example.cpp | srgn --cpp 'class' 'OldClass' 'NewClass' +``` + +will give + +```cpp file=output-example.cpp +class NewClass { +} + +int main() { + class NewClass newClass; +} +``` + ##### Custom queries Custom queries allow you to create ad-hoc scopes. These might be useful, for example, to @@ -1441,6 +1471,45 @@ Options (global): of times this flag is given, maxing out at 'trace' verbosity. Language scopes: + --cpp + Scope C++ code using a prepared query. + + [env: CPP=] + [aliases: cpp] + + Possible values: + - comments: Comments (single- and multi-line) + - strings: Strings + - includes: Includes + - type-def: Type definitions + - enum: `enum` definitions + - struct: `struct` type definitions + - class: `class` definitions + - namespace: `namespace` definitions + - using-namespace: `using` namespace declarations + - template: `template` declarations + - field-decl: Field declarations + - variable: Variable definitions + - function: All functions usages (declarations and calls) + - function-def: Function definitions + - function-decl: Function declaration + - lambda: Lambda + - switch: `switch` blocks + - if: `if` blocks + - for: `for` blocks + - while: `while` blocks + - do: `do` blocks + - union: `union` blocks + - try: `try` blocks + - identifier: Identifier + - declaration: Declaration + - call-expression: Call expression + + --cpp-query + Scope C++ code using a custom tree-sitter query. + + [env: CPP_QUERY=] + --csharp Scope C# code using a prepared query. diff --git a/src/main.rs b/src/main.rs index ad1cfc49..d3e543c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use srgn::actions::{ }; #[cfg(feature = "symbols")] use srgn::actions::{Symbols, SymbolsInversion}; +use srgn::scoping::langs::cpp::{Cpp, CppQuery}; use srgn::scoping::langs::csharp::{CSharp, CSharpQuery}; use srgn::scoping::langs::go::{Go, GoQuery}; use srgn::scoping::langs::hcl::{Hcl, HclQuery}; @@ -830,6 +831,7 @@ fn get_language_scopers(args: &cli::Cli) -> Vec> { }; } + handle_language_scope!(cpp, cpp_query, CppQuery, Cpp); handle_language_scope!(csharp, csharp_query, CSharpQuery, CSharp); handle_language_scope!(hcl, hcl_query, HclQuery, Hcl); handle_language_scope!(go, go_query, GoQuery, Go); @@ -936,6 +938,7 @@ mod cli { use clap::builder::ArgPredicate; use clap::{ArgAction, Command, CommandFactory, Parser}; use clap_complete::{generate, Generator, Shell}; + use srgn::scoping::langs::cpp::{CustomCppQuery, PreparedCppQuery}; use srgn::scoping::langs::csharp::{CustomCSharpQuery, PreparedCSharpQuery}; use srgn::scoping::langs::go::{CustomGoQuery, PreparedGoQuery}; use srgn::scoping::langs::hcl::{CustomHclQuery, PreparedHclQuery}; @@ -1224,6 +1227,8 @@ mod cli { #[group(required = false, multiple = false)] #[command(next_help_heading = "Language scopes")] pub struct LanguageScopes { + #[command(flatten)] + pub cpp: Option, #[command(flatten)] pub csharp: Option, #[command(flatten)] @@ -1238,6 +1243,18 @@ mod cli { pub typescript: Option, } + #[derive(Parser, Debug, Clone)] + #[group(required = false, multiple = false)] + pub struct CppScope { + /// Scope C++ code using a prepared query. + #[arg(long, env, verbatim_doc_comment, visible_alias = "cpp")] + pub cpp: Vec, + + /// Scope C++ code using a custom tree-sitter query. + #[arg(long, env, verbatim_doc_comment, value_name = TREE_SITTER_QUERY_VALUE_NAME)] + pub cpp_query: Vec, + } + #[derive(Parser, Debug, Clone)] #[group(required = false, multiple = false)] pub struct CSharpScope { diff --git a/src/scoping/langs/cpp.rs b/src/scoping/langs/cpp.rs new file mode 100644 index 00000000..9e833e95 --- /dev/null +++ b/src/scoping/langs/cpp.rs @@ -0,0 +1,151 @@ +use std::fmt::Debug; +use std::str::FromStr; + +use clap::ValueEnum; +use tree_sitter::QueryError; + +use super::{CodeQuery, Language, LanguageScoper, TSLanguage, TSQuery}; +use crate::find::Find; + +/// The C++ language. +pub type Cpp = Language; +/// A query for C++. +pub type CppQuery = CodeQuery; + +/// Prepared tree-sitter queries for C++. +#[derive(Debug, Clone, Copy, ValueEnum)] +pub enum PreparedCppQuery { + /// Comments (single- and multi-line). + Comments, + /// Strings. + Strings, + /// Includes. + Includes, + /// Type definitions. + TypeDef, + /// `enum` definitions. + Enum, + /// `struct` type definitions. + Struct, + /// `class` definitions. + Class, + /// `namespace` definitions. + Namespace, + /// `using` namespace declarations. + UsingNamespace, + /// `template` declarations. + Template, + /// Field declarations. + FieldDecl, + /// Variable definitions. + Variable, + /// All functions usages (declarations and calls). + Function, + /// Function definitions. + FunctionDef, + /// Function declaration. + FunctionDecl, + /// Lambda + Lambda, + /// `switch` blocks. + Switch, + /// `if` blocks. + If, + /// `for` blocks. + For, + /// `while` blocks. + While, + /// `do` blocks. + Do, + /// `union` blocks. + Union, + /// `try` blocks. + Try, + /// Identifier. + Identifier, + /// Declaration. + Declaration, + /// Call expression. + CallExpression, +} + +impl From for TSQuery { + fn from(value: PreparedCppQuery) -> Self { + Self::new( + &Cpp::lang(), + match value { + PreparedCppQuery::Comments => "(comment) @comment", + PreparedCppQuery::Strings => "[(string_literal) (system_lib_string)] @string", + PreparedCppQuery::Includes => "(preproc_include) @include", + PreparedCppQuery::TypeDef => "(type_definition) @typedef", + PreparedCppQuery::Enum => "(enum_specifier) @enum", + PreparedCppQuery::Struct => "(struct_specifier) @struct", + PreparedCppQuery::Class => "(class_specifier) @class", + PreparedCppQuery::Namespace => "(namespace_definition) @namespace", + PreparedCppQuery::UsingNamespace => "(using_declaration) @using", + PreparedCppQuery::Template => "(template_declaration) @template", + PreparedCppQuery::FieldDecl => "(field_declaration) @field_decl", + PreparedCppQuery::Variable => "(declaration) @var", + PreparedCppQuery::Function => { + "[(function_declarator (identifier)) (call_expression (identifier))] @function" + } + PreparedCppQuery::FunctionDef => "(function_definition) @function_definition", + PreparedCppQuery::FunctionDecl => "(function_declarator) @function_decl", + PreparedCppQuery::Lambda => "(lambda_expression) @lambda", + PreparedCppQuery::Switch => "(switch_statement) @switch", + PreparedCppQuery::If => "(if_statement) @if", + PreparedCppQuery::For => "[(for_statement) (for_range_loop)] @for", + PreparedCppQuery::While => "(while_statement) @while", + PreparedCppQuery::Union => "(union_specifier) @union", + PreparedCppQuery::Try => "(try_statement) @try", + PreparedCppQuery::Do => "(do_statement) @do", + PreparedCppQuery::Identifier => "(identifier) @ident", + PreparedCppQuery::Declaration => "(declaration) @decl", + PreparedCppQuery::CallExpression => "(call_expression) @call", + }, + ) + .expect("Prepared queries to be valid") + } +} + +/// A custom tree-sitter query for C++. +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct CustomCppQuery(String); + +impl FromStr for CustomCppQuery { + type Err = QueryError; + + fn from_str(s: &str) -> Result { + match TSQuery::new(&Cpp::lang(), s) { + Ok(_) => Ok(Self(s.to_string())), + Err(e) => Err(e), + } + } +} + +impl From for TSQuery { + fn from(value: CustomCppQuery) -> Self { + Self::new(&Cpp::lang(), &value.0) + .expect("Valid query, as object cannot be constructed otherwise") + } +} + +impl LanguageScoper for Cpp { + fn lang() -> TSLanguage { + tree_sitter_cpp::LANGUAGE.into() + } + + fn pos_query(&self) -> &TSQuery { + &self.positive_query + } + + fn neg_query(&self) -> Option<&TSQuery> { + self.negative_query.as_ref() + } +} + +impl Find for Cpp { + fn extensions(&self) -> &'static [&'static str] { + &["cpp", "hpp"] + } +} diff --git a/src/scoping/langs/mod.rs b/src/scoping/langs/mod.rs index d98a923d..125eb885 100644 --- a/src/scoping/langs/mod.rs +++ b/src/scoping/langs/mod.rs @@ -16,6 +16,8 @@ use crate::scoping::{ view::ScopedViewBuilder, }; +/// C++. +pub mod cpp; /// C#. pub mod csharp; /// Go. diff --git a/tests/langs/cpp/base.cpp b/tests/langs/cpp/base.cpp new file mode 100644 index 00000000..85750c60 --- /dev/null +++ b/tests/langs/cpp/base.cpp @@ -0,0 +1,102 @@ +#include +#include + +// comment +/* + multiline comment + */ +namespace foo { +} + +using namespace foo; + +template +void bar(T t) { +} + +typedef unsigned int uint; + +union U { + int union_a; + long long union_l; +}; + +struct S { + int struct_a; + + int struct_method() { + return this->struct_a; + } +}; + + +enum E: int { + EA, + EB, + EC, +}; + +class C { + public: + int class_pub_a; + void class_method() { + this->class_virt_method(); + }; + virtual void class_virt_method(); + static void class_static_method(); + private: + std::string class_piv_b; + protected: + char class_prot_c; +}; + +constexpr auto fn(void) { + return 0; +} + +int main() { + auto v = 1; + class C c; + const char *cs = "test"; + std::string s("test"); + + auto j = {1, 2, 3, 4}; + + for (auto i : j) { + } + for (int i; ; i++) { + } + + auto lambda = [](std::vector v) { + // ... + }; + + switch (v) { + case 1: + break; + + case 2: + break; + } + + if (v > 0) { + } + + while (v++) { + } + + do { + } while (0); + + try { + throw new Error(); + } catch (e) { + bar(1); + bar(4); + c.class_method(); + C::class_static_method(); + } + + + return 0; +} diff --git a/tests/langs/mod.rs b/tests/langs/mod.rs index b466afeb..f4ca1e38 100644 --- a/tests/langs/mod.rs +++ b/tests/langs/mod.rs @@ -2,6 +2,7 @@ use std::ops::Range; use rstest::rstest; use serde::{Deserialize, Serialize}; +use srgn::scoping::langs::cpp::{Cpp, PreparedCppQuery}; use srgn::scoping::langs::csharp::{CSharp, PreparedCSharpQuery}; use srgn::scoping::langs::go::{Go, PreparedGoQuery}; use srgn::scoping::langs::hcl::{Hcl, PreparedHclQuery}; @@ -719,6 +720,136 @@ impl InScopeLinePart { include_str!("csharp/base.cs"), CSharp::new(CodeQuery::Prepared(PreparedCSharpQuery::Identifier)), )] +#[case( + "base.cpp_comments", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Comments)), +)] +#[case( + "base.cpp_strings", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Strings)), +)] +#[case( + "base.cpp_includes", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Includes)), +)] +#[case( + "base.cpp_typedef", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::TypeDef)), +)] +#[case( + "base.cpp_enum", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Enum)), +)] +#[case( + "base.cpp_struct", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Struct)), +)] +#[case( + "base.cpp_class", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Class)), +)] +#[case( + "base.cpp_namespace", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Namespace)), +)] +#[case( + "base.cpp_using_namespace", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::UsingNamespace)), +)] +#[case( + "base.cpp_template", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Template)), +)] +#[case( + "base.cpp_field_declaration", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::FieldDecl)), +)] +#[case( + "base.cpp_variable", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Variable)), +)] +#[case( + "base.cpp_function", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Function)), +)] +#[case( + "base.cpp_function_definition", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::FunctionDef)), +)] +#[case( + "base.cpp_function_declaration", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::FunctionDecl)), +)] +#[case( + "base.cpp_lambda", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Lambda)), +)] +#[case( + "base.cpp_switch", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Switch)), +)] +#[case( + "base.cpp_if", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::If)), +)] +#[case( + "base.cpp_for", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::For)), +)] +#[case( + "base.cpp_while", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::While)), +)] +#[case( + "base.cpp_do", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Do)), +)] +#[case( + "base.cpp_union", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Union)), +)] +#[case( + "base.cpp_try", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Try)), +)] +#[case( + "base.cpp_ident", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Identifier)), +)] +#[case( + "base.cpp_declaration", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::Declaration)), +)] +#[case( + "base.cpp_call_expr", + include_str!("cpp/base.cpp"), + Cpp::new(CodeQuery::Prepared(PreparedCppQuery::CallExpression)), +)] fn test_language_scopers( #[case] snapshot_name: &str, #[case] contents: &str, diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_call_expr.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_call_expr.snap new file mode 100644 index 00000000..3e5291e7 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_call_expr.snap @@ -0,0 +1,19 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 43 + l: " this->class_virt_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 94 + l: " bar(1);\n" + m: " ^^^^^^ " +- n: 95 + l: " bar(4);\n" + m: " ^^^^^^^^^^^ " +- n: 96 + l: " c.class_method();\n" + m: " ^^^^^^^^^^^^^^^^ " +- n: 97 + l: " C::class_static_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_class.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_class.snap new file mode 100644 index 00000000..50bcb002 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_class.snap @@ -0,0 +1,46 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 39 + l: "class C {\n" + m: ^^^^^^^^^^^ +- n: 40 + l: " public:\n" + m: ^^^^^^^^^^^^^ +- n: 41 + l: " int class_pub_a;\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 42 + l: " void class_method() {\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 43 + l: " this->class_virt_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 44 + l: " };\n" + m: ^^^^^^^^^^^^ +- n: 45 + l: " virtual void class_virt_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 46 + l: " static void class_static_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 47 + l: " private:\n" + m: ^^^^^^^^^^^^^^ +- n: 48 + l: " std::string class_piv_b;\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 49 + l: " protected:\n" + m: ^^^^^^^^^^^^^^^^ +- n: 50 + l: " char class_prot_c;\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 51 + l: "};\n" + m: "^ " +- n: 59 + l: " class C c;\n" + m: " ^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_comments.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_comments.snap new file mode 100644 index 00000000..f5de85be --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_comments.snap @@ -0,0 +1,19 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 4 + l: "// comment\n" + m: "^^^^^^^^^^ " +- n: 5 + l: "/*\n" + m: ^^^^ +- n: 6 + l: " multiline comment\n" + m: ^^^^^^^^^^^^^^^^^^^^^^ +- n: 7 + l: " */\n" + m: "^^^ " +- n: 71 + l: " // ...\n" + m: " ^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_declaration.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_declaration.snap new file mode 100644 index 00000000..f6d12730 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_declaration.snap @@ -0,0 +1,31 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 58 + l: " auto v = 1;\n" + m: " ^^^^^^^^^^^ " +- n: 59 + l: " class C c;\n" + m: " ^^^^^^^^^^ " +- n: 60 + l: " const char *cs = \"test\";\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 61 + l: " std::string s(\"test\");\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 63 + l: " auto j = {1, 2, 3, 4};\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^ " +- n: 67 + l: " for (int i; ; i++) {\n" + m: " ^^^^^^ " +- n: 70 + l: " auto lambda = [](std::vector v) {\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" +- n: 71 + l: " // ...\n" + m: ^^^^^^^^^^^^^^^^ +- n: 72 + l: " };\n" + m: "^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_do.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_do.snap new file mode 100644 index 00000000..7843e3b3 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_do.snap @@ -0,0 +1,10 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 88 + l: " do {\n" + m: " ^^^^^^" +- n: 89 + l: " } while (0);\n" + m: "^^^^^^^^^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_enum.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_enum.snap new file mode 100644 index 00000000..1032f8eb --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_enum.snap @@ -0,0 +1,19 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 33 + l: "enum E: int {\n" + m: ^^^^^^^^^^^^^^^ +- n: 34 + l: " EA,\n" + m: ^^^^^^^^^ +- n: 35 + l: " EB,\n" + m: ^^^^^^^^^ +- n: 36 + l: " EC,\n" + m: ^^^^^^^^^ +- n: 37 + l: "};\n" + m: "^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_field_declaration.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_field_declaration.snap new file mode 100644 index 00000000..c08f3e69 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_field_declaration.snap @@ -0,0 +1,28 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 20 + l: " int union_a;\n" + m: " ^^^^^^^^^^^^ " +- n: 21 + l: " long long union_l;\n" + m: " ^^^^^^^^^^^^^^^^^^ " +- n: 25 + l: " int struct_a;\n" + m: " ^^^^^^^^^^^^^ " +- n: 41 + l: " int class_pub_a;\n" + m: " ^^^^^^^^^^^^^^^^ " +- n: 45 + l: " virtual void class_virt_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 46 + l: " static void class_static_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 48 + l: " std::string class_piv_b;\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 50 + l: " char class_prot_c;\n" + m: " ^^^^^^^^^^^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_for.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_for.snap new file mode 100644 index 00000000..fc23c5b6 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_for.snap @@ -0,0 +1,16 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 65 + l: " for (auto i : j) {\n" + m: " ^^^^^^^^^^^^^^^^^^^^" +- n: 66 + l: " }\n" + m: "^^^^^ " +- n: 67 + l: " for (int i; ; i++) {\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^" +- n: 68 + l: " }\n" + m: "^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_function.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_function.snap new file mode 100644 index 00000000..20351360 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_function.snap @@ -0,0 +1,16 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 14 + l: "void bar(T t) {\n" + m: " ^^^^^^^^ " +- n: 53 + l: "constexpr auto fn(void) {\n" + m: " ^^^^^^^^ " +- n: 57 + l: "int main() {\n" + m: " ^^^^^^ " +- n: 94 + l: " bar(1);\n" + m: " ^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_function_declaration.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_function_declaration.snap new file mode 100644 index 00000000..70e51b37 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_function_declaration.snap @@ -0,0 +1,25 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 14 + l: "void bar(T t) {\n" + m: " ^^^^^^^^ " +- n: 27 + l: " int struct_method() {\n" + m: " ^^^^^^^^^^^^^^^ " +- n: 42 + l: " void class_method() {\n" + m: " ^^^^^^^^^^^^^^ " +- n: 45 + l: " virtual void class_virt_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^ " +- n: 46 + l: " static void class_static_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^^^ " +- n: 53 + l: "constexpr auto fn(void) {\n" + m: " ^^^^^^^^ " +- n: 57 + l: "int main() {\n" + m: " ^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_function_definition.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_function_definition.snap new file mode 100644 index 00000000..2f3a76e9 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_function_definition.snap @@ -0,0 +1,175 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 14 + l: "void bar(T t) {\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 15 + l: "}\n" + m: "^ " +- n: 27 + l: " int struct_method() {\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^" +- n: 28 + l: " return this->struct_a;\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 29 + l: " }\n" + m: "^^^^^ " +- n: 42 + l: " void class_method() {\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^" +- n: 43 + l: " this->class_virt_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 44 + l: " };\n" + m: "^^^^^^^^^ " +- n: 53 + l: "constexpr auto fn(void) {\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 54 + l: " return 0;\n" + m: ^^^^^^^^^^^^^^^ +- n: 55 + l: "}\n" + m: "^ " +- n: 57 + l: "int main() {\n" + m: ^^^^^^^^^^^^^^ +- n: 58 + l: " auto v = 1;\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 59 + l: " class C c;\n" + m: ^^^^^^^^^^^^^^^^ +- n: 60 + l: " const char *cs = \"test\";\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 61 + l: " std::string s(\"test\");\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 62 + l: "\n" + m: ^^ +- n: 63 + l: " auto j = {1, 2, 3, 4};\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 64 + l: "\n" + m: ^^ +- n: 65 + l: " for (auto i : j) {\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 66 + l: " }\n" + m: ^^^^^^^ +- n: 67 + l: " for (int i; ; i++) {\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 68 + l: " }\n" + m: ^^^^^^^ +- n: 69 + l: "\n" + m: ^^ +- n: 70 + l: " auto lambda = [](std::vector v) {\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 71 + l: " // ...\n" + m: ^^^^^^^^^^^^^^^^ +- n: 72 + l: " };\n" + m: ^^^^^^^^ +- n: 73 + l: "\n" + m: ^^ +- n: 74 + l: " switch (v) {\n" + m: ^^^^^^^^^^^^^^^^^^ +- n: 75 + l: " case 1:\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 76 + l: " break;\n" + m: ^^^^^^^^^^^^^^^^^^^^ +- n: 77 + l: "\n" + m: ^^ +- n: 78 + l: " case 2:\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 79 + l: " break;\n" + m: ^^^^^^^^^^^^^^^^^^^^ +- n: 80 + l: " }\n" + m: ^^^^^^^ +- n: 81 + l: "\n" + m: ^^ +- n: 82 + l: " if (v > 0) {\n" + m: ^^^^^^^^^^^^^^^^^^ +- n: 83 + l: " }\n" + m: ^^^^^^^ +- n: 84 + l: "\n" + m: ^^ +- n: 85 + l: " while (v++) {\n" + m: ^^^^^^^^^^^^^^^^^^^ +- n: 86 + l: " }\n" + m: ^^^^^^^ +- n: 87 + l: "\n" + m: ^^ +- n: 88 + l: " do {\n" + m: ^^^^^^^^^^ +- n: 89 + l: " } while (0);\n" + m: ^^^^^^^^^^^^^^^^^^ +- n: 90 + l: "\n" + m: ^^ +- n: 91 + l: " try {\n" + m: ^^^^^^^^^^^ +- n: 92 + l: " throw new Error();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 93 + l: " } catch (e) {\n" + m: ^^^^^^^^^^^^^^^^^^^ +- n: 94 + l: " bar(1);\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 95 + l: " bar(4);\n" + m: ^^^^^^^^^^^^^^^^^^^^^^ +- n: 96 + l: " c.class_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 97 + l: " C::class_static_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 98 + l: " }\n" + m: ^^^^^^^ +- n: 99 + l: "\n" + m: ^^ +- n: 100 + l: "\n" + m: ^^ +- n: 101 + l: " return 0;\n" + m: ^^^^^^^^^^^^^^^ +- n: 102 + l: "}\n" + m: "^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_ident.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_ident.snap new file mode 100644 index 00000000..7a4c0edd --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_ident.snap @@ -0,0 +1,82 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 11 + l: "using namespace foo;\n" + m: " ^^^ " +- n: 14 + l: "void bar(T t) {\n" + m: " ^^^ " +- n: 14 + l: "void bar(T t) {\n" + m: " ^ " +- n: 34 + l: " EA,\n" + m: " ^^ " +- n: 35 + l: " EB,\n" + m: " ^^ " +- n: 36 + l: " EC,\n" + m: " ^^ " +- n: 53 + l: "constexpr auto fn(void) {\n" + m: " ^^ " +- n: 57 + l: "int main() {\n" + m: " ^^^^ " +- n: 58 + l: " auto v = 1;\n" + m: " ^ " +- n: 59 + l: " class C c;\n" + m: " ^ " +- n: 60 + l: " const char *cs = \"test\";\n" + m: " ^^ " +- n: 61 + l: " std::string s(\"test\");\n" + m: " ^ " +- n: 63 + l: " auto j = {1, 2, 3, 4};\n" + m: " ^ " +- n: 65 + l: " for (auto i : j) {\n" + m: " ^ " +- n: 65 + l: " for (auto i : j) {\n" + m: " ^ " +- n: 67 + l: " for (int i; ; i++) {\n" + m: " ^ " +- n: 67 + l: " for (int i; ; i++) {\n" + m: " ^ " +- n: 70 + l: " auto lambda = [](std::vector v) {\n" + m: " ^^^^^^ " +- n: 70 + l: " auto lambda = [](std::vector v) {\n" + m: " ^ " +- n: 74 + l: " switch (v) {\n" + m: " ^ " +- n: 82 + l: " if (v > 0) {\n" + m: " ^ " +- n: 85 + l: " while (v++) {\n" + m: " ^ " +- n: 94 + l: " bar(1);\n" + m: " ^^^ " +- n: 95 + l: " bar(4);\n" + m: " ^^^ " +- n: 96 + l: " c.class_method();\n" + m: " ^ " +- n: 97 + l: " C::class_static_method();\n" + m: " ^^^^^^^^^^^^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_if.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_if.snap new file mode 100644 index 00000000..58507a56 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_if.snap @@ -0,0 +1,10 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 82 + l: " if (v > 0) {\n" + m: " ^^^^^^^^^^^^^^" +- n: 83 + l: " }\n" + m: "^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_includes.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_includes.snap new file mode 100644 index 00000000..cfae9053 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_includes.snap @@ -0,0 +1,10 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 1 + l: "#include \n" + m: ^^^^^^^^^^^^^^^^^^^ +- n: 2 + l: "#include \n" + m: ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_lambda.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_lambda.snap new file mode 100644 index 00000000..78be00a3 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_lambda.snap @@ -0,0 +1,13 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 70 + l: " auto lambda = [](std::vector v) {\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" +- n: 71 + l: " // ...\n" + m: ^^^^^^^^^^^^^^^^ +- n: 72 + l: " };\n" + m: "^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_namespace.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_namespace.snap new file mode 100644 index 00000000..d8d5194a --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_namespace.snap @@ -0,0 +1,10 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 8 + l: "namespace foo {\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 9 + l: "}\n" + m: "^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_strings.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_strings.snap new file mode 100644 index 00000000..2ee3b0b2 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_strings.snap @@ -0,0 +1,16 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 1 + l: "#include \n" + m: " ^^^^^^^^ " +- n: 2 + l: "#include \n" + m: " ^^^^^^^^ " +- n: 60 + l: " const char *cs = \"test\";\n" + m: " ^^^^^^^^ " +- n: 61 + l: " std::string s(\"test\");\n" + m: " ^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_struct.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_struct.snap new file mode 100644 index 00000000..e27dd162 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_struct.snap @@ -0,0 +1,25 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 24 + l: "struct S {\n" + m: ^^^^^^^^^^^^ +- n: 25 + l: " int struct_a;\n" + m: ^^^^^^^^^^^^^^^^^^^ +- n: 26 + l: "\n" + m: ^^ +- n: 27 + l: " int struct_method() {\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 28 + l: " return this->struct_a;\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 29 + l: " }\n" + m: ^^^^^^^ +- n: 30 + l: "};\n" + m: "^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_switch.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_switch.snap new file mode 100644 index 00000000..a7d46cce --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_switch.snap @@ -0,0 +1,25 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 74 + l: " switch (v) {\n" + m: " ^^^^^^^^^^^^^^" +- n: 75 + l: " case 1:\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 76 + l: " break;\n" + m: ^^^^^^^^^^^^^^^^^^^^ +- n: 77 + l: "\n" + m: ^^ +- n: 78 + l: " case 2:\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 79 + l: " break;\n" + m: ^^^^^^^^^^^^^^^^^^^^ +- n: 80 + l: " }\n" + m: "^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_template.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_template.snap new file mode 100644 index 00000000..fef0493c --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_template.snap @@ -0,0 +1,13 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 13 + l: "template \n" + m: ^^^^^^^^^^^^^^^^^^^^^^^ +- n: 14 + l: "void bar(T t) {\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 15 + l: "}\n" + m: "^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_try.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_try.snap new file mode 100644 index 00000000..b0b1f79e --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_try.snap @@ -0,0 +1,28 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 91 + l: " try {\n" + m: " ^^^^^^^" +- n: 92 + l: " throw new Error();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 93 + l: " } catch (e) {\n" + m: ^^^^^^^^^^^^^^^^^^^ +- n: 94 + l: " bar(1);\n" + m: ^^^^^^^^^^^^^^^^^ +- n: 95 + l: " bar(4);\n" + m: ^^^^^^^^^^^^^^^^^^^^^^ +- n: 96 + l: " c.class_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 97 + l: " C::class_static_method();\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 98 + l: " }\n" + m: "^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_typedef.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_typedef.snap new file mode 100644 index 00000000..3978f5b2 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_typedef.snap @@ -0,0 +1,7 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 17 + l: "typedef unsigned int uint;\n" + m: "^^^^^^^^^^^^^^^^^^^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_union.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_union.snap new file mode 100644 index 00000000..484b21e8 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_union.snap @@ -0,0 +1,16 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 19 + l: "union U {\n" + m: ^^^^^^^^^^^ +- n: 20 + l: " int union_a;\n" + m: ^^^^^^^^^^^^^^^^^^ +- n: 21 + l: " long long union_l;\n" + m: ^^^^^^^^^^^^^^^^^^^^^^^^ +- n: 22 + l: "};\n" + m: "^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_using_namespace.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_using_namespace.snap new file mode 100644 index 00000000..f252410b --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_using_namespace.snap @@ -0,0 +1,7 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 11 + l: "using namespace foo;\n" + m: "^^^^^^^^^^^^^^^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_variable.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_variable.snap new file mode 100644 index 00000000..f6d12730 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_variable.snap @@ -0,0 +1,31 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 58 + l: " auto v = 1;\n" + m: " ^^^^^^^^^^^ " +- n: 59 + l: " class C c;\n" + m: " ^^^^^^^^^^ " +- n: 60 + l: " const char *cs = \"test\";\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 61 + l: " std::string s(\"test\");\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^ " +- n: 63 + l: " auto j = {1, 2, 3, 4};\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^ " +- n: 67 + l: " for (int i; ; i++) {\n" + m: " ^^^^^^ " +- n: 70 + l: " auto lambda = [](std::vector v) {\n" + m: " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" +- n: 71 + l: " // ...\n" + m: ^^^^^^^^^^^^^^^^ +- n: 72 + l: " };\n" + m: "^^^^^^ " diff --git a/tests/langs/snapshots/r#mod__langs__base.cpp_while.snap b/tests/langs/snapshots/r#mod__langs__base.cpp_while.snap new file mode 100644 index 00000000..b6cca369 --- /dev/null +++ b/tests/langs/snapshots/r#mod__langs__base.cpp_while.snap @@ -0,0 +1,10 @@ +--- +source: tests/langs/mod.rs +expression: inscope_parts +--- +- n: 85 + l: " while (v++) {\n" + m: " ^^^^^^^^^^^^^^^" +- n: 86 + l: " }\n" + m: "^^^^^ "