diff options
| author | Fangrui Song <maskray@google.com> | 2019-08-23 04:46:01 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-08-23 04:46:01 +0000 |
| commit | 8798c8de9a8a4abf597cd370da57ebefaa4d951d (patch) | |
| tree | 0c973efd715b7f4045a88d2a0c4e55b9cc4664f7 /clang/lib | |
| parent | 6c9dc12caaffc4bb2d9d836b890dc27b7a8c167a (diff) | |
| download | bcm5719-llvm-8798c8de9a8a4abf597cd370da57ebefaa4d951d.tar.gz bcm5719-llvm-8798c8de9a8a4abf597cd370da57ebefaa4d951d.zip | |
[clang-format] Recognize ECMAScript module .mjs as JavaScript
PR43085.
Recognize .mjs files as JavaScript. .mjs is the extension for ECMAScript modules.
A specific extension (and associated content type javascript/esm) is
introduced to differentiate it from CommonJS modules and solve some
interoperability problems.
Differential Revision: https://reviews.llvm.org/D66584
Patch by Fergal Daly
llvm-svn: 369732
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 4fbaee470fa..175807edfb4 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -2411,8 +2411,9 @@ const char *StyleOptionHelpDescription = static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { if (FileName.endswith(".java")) return FormatStyle::LK_Java; - if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts")) - return FormatStyle::LK_JavaScript; // JavaScript or TypeScript. + if (FileName.endswith_lower(".js") || FileName.endswith_lower(".mjs") || + FileName.endswith_lower(".ts")) + return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript. if (FileName.endswith(".m") || FileName.endswith(".mm")) return FormatStyle::LK_ObjC; if (FileName.endswith_lower(".proto") || |

