* Heuristic: does a .h file contain C++ constructs? * Checks the first ~8KB for patterns that are unique to C++ and never valid C.
(source: string)
| 301 | * Checks the first ~8KB for patterns that are unique to C++ and never valid C. |
| 302 | */ |
| 303 | function looksLikeCpp(source: string): boolean { |
| 304 | const sample = source.substring(0, 8192); |
| 305 | return /\bnamespace\b|\bclass\s+\w+\s*[:{]|\btemplate\s*<|\b(?:public|private|protected)\s*:|\bvirtual\b|\busing\s+(?:namespace\b|\w+\s*=)/.test(sample); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * Heuristic: does a .h file contain Objective-C constructs? |