From 352c6cf08658d65950d6a4c618afa67875b37ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Fri, 27 Sep 2024 10:33:08 +0200 Subject: [PATCH 1/4] Add block_comment type for Rust --- src/config.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/config.rs b/src/config.rs index cda82fb..1e3b080 100644 --- a/src/config.rs +++ b/src/config.rs @@ -94,6 +94,7 @@ static PYTHON_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { static RUST_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { "doc_comment" => CodeType::Comment, "line_comment" => CodeType::Comment, + "block_comment" => CodeType::Comment, "string_content" => CodeType::StringLiteral, "char_literal" => CodeType::StringLiteral, }; From 86222cf163721801ae3ab8a181c81944541d13bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Fri, 27 Sep 2024 10:34:28 +0200 Subject: [PATCH 2/4] Organize code type mappings nicer --- src/config.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 1e3b080..33e8457 100644 --- a/src/config.rs +++ b/src/config.rs @@ -76,6 +76,7 @@ pub enum Language { static GO_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { "comment" => CodeType::Comment, + "interpreted_string_literal" => CodeType::StringLiteral, "raw_string_literal" => CodeType::StringLiteral, }; @@ -83,18 +84,21 @@ static GO_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { static JAVASCRIPT_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { "comment" => CodeType::Comment, "block_comment" => CodeType::Comment, + "string_fragment" => CodeType::StringLiteral, }; static PYTHON_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { - "string_content" => CodeType::StringLiteral, "comment" => CodeType::Comment, + + "string_content" => CodeType::StringLiteral, }; static RUST_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { "doc_comment" => CodeType::Comment, "line_comment" => CodeType::Comment, "block_comment" => CodeType::Comment, + "string_content" => CodeType::StringLiteral, "char_literal" => CodeType::StringLiteral, }; @@ -102,6 +106,7 @@ static RUST_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { static SWIFT_CODE_TYPES: phf::Map<&'static str, CodeType> = phf::phf_map! { "comment" => CodeType::Comment, "multiline_comment" => CodeType::Comment, + "line_str_text" => CodeType::StringLiteral, "multi_line_str_text" => CodeType::StringLiteral, }; From 1aa1f7330e91f12022af81b5a0cd5755fe9613da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Fri, 27 Sep 2024 10:52:35 +0200 Subject: [PATCH 3/4] Remove unused "Identifier" CodeType There were no mappings for the type anyway. And after discussing it, we did not find any concrete use case for special casing identifiers. So we decided to not support it for now. --- src/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 33e8457..851e863 100644 --- a/src/config.rs +++ b/src/config.rs @@ -61,7 +61,6 @@ fn unicode_notation_to_char(unicode_notation: &str) -> Result Date: Fri, 27 Sep 2024 10:53:24 +0200 Subject: [PATCH 4/4] Add documentation about the CodeType enum --- src/config.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/config.rs b/src/config.rs index 851e863..064ae78 100644 --- a/src/config.rs +++ b/src/config.rs @@ -56,10 +56,19 @@ fn unicode_notation_to_char(unicode_notation: &str) -> Result