From: Daniel Jasper Date: Wed, 11 Mar 2015 14:58:38 +0000 (+0000) Subject: clang-format: Recognize the .ts (TypeScript) extension as JavaScript. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a47fa0bab4258a7c762e394f00cbadfa73de47ec;p=clang clang-format: Recognize the .ts (TypeScript) extension as JavaScript. Patch by Martin Probst. Thank you. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231926 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index d312e8d86e..a243a1f315 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1528,7 +1528,8 @@ const char *StyleOptionHelpDescription = static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { if (FileName.endswith(".java")) { return FormatStyle::LK_Java; - } else if (FileName.endswith_lower(".js")) { + } else if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts")) { + // JavaScript or TypeScript. return FormatStyle::LK_JavaScript; } else if (FileName.endswith_lower(".proto") || FileName.endswith_lower(".protodevel")) { diff --git a/tools/clang-format/clang-format-diff.py b/tools/clang-format/clang-format-diff.py index 23adb077c9..64efb83a8c 100755 --- a/tools/clang-format/clang-format-diff.py +++ b/tools/clang-format/clang-format-diff.py @@ -48,7 +48,7 @@ def main(): help='custom pattern selecting file paths to reformat ' '(case sensitive, overrides -iregex)') parser.add_argument('-iregex', metavar='PATTERN', default= - r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc|js|proto' + r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc|js|ts|proto' r'|protodevel|java)', help='custom pattern selecting file paths to reformat ' '(case insensitive, overridden by -regex)')