]> granicus.if.org Git - clang/commitdiff
clang-format: Recognize the .ts (TypeScript) extension as JavaScript.
authorDaniel Jasper <djasper@google.com>
Wed, 11 Mar 2015 14:58:38 +0000 (14:58 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 11 Mar 2015 14:58:38 +0000 (14:58 +0000)
Patch by Martin Probst. Thank you.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231926 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
tools/clang-format/clang-format-diff.py

index d312e8d86e9a06d5648e922497d4832879b26e93..a243a1f3157355d580bb56fce06ac99b4e1db4aa 100644 (file)
@@ -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")) {
index 23adb077c95342454248e8705d417144451e89f0..64efb83a8c19eab5d0b5d50a101440a927aa934a 100755 (executable)
@@ -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)')