]> granicus.if.org Git - clang/commitdiff
clang-format: [Java] No altnerative operator names in Java.
authorDaniel Jasper <djasper@google.com>
Fri, 14 Nov 2014 09:02:28 +0000 (09:02 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 14 Nov 2014 09:02:28 +0000 (09:02 +0000)
Before:
  someObject.and ();

After:
  someObject.and();

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

lib/Format/Format.cpp
unittests/Format/FormatTestJava.cpp

index 740adb2b1263acb29b9f194335b19fba8e75c749..52a88e0a788dfdaa26b7fc6a9a05897c7f32659e 100644 (file)
@@ -2133,8 +2133,9 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) {
   LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
   LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
   LangOpts.LineComment = 1;
-  LangOpts.CXXOperatorNames =
-      Style.Language != FormatStyle::LK_JavaScript ? 1 : 0;
+  bool AlternativeOperators = Style.Language != FormatStyle::LK_JavaScript &&
+                              Style.Language != FormatStyle::LK_Java;
+  LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0;
   LangOpts.Bool = 1;
   LangOpts.ObjC1 = 1;
   LangOpts.ObjC2 = 1;
index 650c0af0cbb6c3399214b9e78e701ff636ecf1f4..e8e35c85ef74c9e205b9259538e3688a40669178 100644 (file)
@@ -50,6 +50,10 @@ protected:
   }
 };
 
+TEST_F(FormatTestJava, NoAlternativeOperatorNames) {
+  verifyFormat("someObject.and();");
+}
+
 TEST_F(FormatTestJava, ClassDeclarations) {
   verifyFormat("public class SomeClass {\n"
                "  private int a;\n"