File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ pub fn language_by_filename(path: &Path) -> Option<Arc<Language>> {
152152 "tsx" => language_by_name ( "tsx" ) ,
153153 "ts" | "cts" | "mts" => language_by_name ( "typescript" ) ,
154154 "java" | "groovy" | "gvy" | "gy" | "gsh" => language_by_name ( "java" ) ,
155- "cpp" | "cxx" | "cc" | "h" | "hh" => language_by_name ( "cpp" ) ,
155+ "cpp" | "cxx" | "cc" | "h" | "hh" | "hpp" | "hxx" | "h++" => language_by_name ( "cpp" ) ,
156156 "sh" | "zsh" | "bash" => language_by_name ( "shell" ) ,
157157 "cs" => language_by_name ( "csharp" ) ,
158158 "html" => language_by_name ( "html" ) ,
Original file line number Diff line number Diff line change 1- use crate :: { load_language, SUPPORTED_LANGUAGES } ;
1+ use std:: path:: Path ;
2+
3+ use crate :: { language_by_filename, load_language, SUPPORTED_LANGUAGES } ;
24
35/// Validate that every supported language can be loaded successfully.
46/// This catches invalid node types, syntax errors, and other issues in .scm query files
@@ -20,3 +22,15 @@ fn all_supported_languages_load_successfully() {
2022 . join( "\n " )
2123 ) ;
2224}
25+
26+ /// Modern C++ codebases (Boost, Qt, etc.) use `.hpp` (and less often
27+ /// `.hxx` / `.h++`) for headers to distinguish them from plain C.
28+ /// Make sure each variant resolves to the C++ language.
29+ #[ test]
30+ fn cpp_header_extensions_resolve_to_cpp ( ) {
31+ for name in [ "foo.hpp" , "foo.hxx" , "foo.h++" ] {
32+ let language = language_by_filename ( Path :: new ( name) )
33+ . unwrap_or_else ( || panic ! ( "`{name}` should resolve to a language" ) ) ;
34+ assert_eq ! ( language. display_name, "C++" , "{name} should map to C++" ) ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments