Hi djasper, Allow predefined styles to define different options for different languages so that one can run: clang-format -style=google file1.cpp file2.js
or use a single .clang-format file with "BasedOnStyle: Google" for both c++ and JS files. Added Google style for JavaScript with "BreakBeforeTernaryOperators" set to false. http://llvm-reviews.chandlerc.com/D2364 Files: include/clang/Format/Format.h lib/Format/Format.cpp unittests/Format/FormatTest.cpp unittests/Format/FormatTestJS.cpp
Index: include/clang/Format/Format.h =================================================================== --- include/clang/Format/Format.h +++ include/clang/Format/Format.h @@ -330,6 +330,11 @@ /// http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml. FormatStyle getGoogleStyle(); +/// \brief Returns a format style complying with Google's JavaScript style +/// guide: +/// http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml. +FormatStyle getGoogleJSStyle(); + /// \brief Returns a format style complying with Chromium's style guide: /// http://www.chromium.org/developers/coding-style. FormatStyle getChromiumStyle(); @@ -342,15 +347,22 @@ /// http://www.webkit.org/coding/coding-style.html FormatStyle getWebKitStyle(); -/// \brief Gets a predefined style by name. +/// \brief Gets a predefined style for the specified language by name. /// /// Currently supported names: LLVM, Google, Chromium, Mozilla. Names are /// compared case-insensitively. /// /// Returns \c true if the Style has been set. -bool getPredefinedStyle(StringRef Name, FormatStyle *Style); +bool getPredefinedStyle(FormatStyle::LanguageKind Language, StringRef Name, + FormatStyle *Style); /// \brief Parse configuration from YAML-formatted text. +/// +/// Style->Language is used to get the base style, if the \c BasedOnStyle +/// option is present. +/// +/// When \c BasedOnStyle is not present, options not present in the YAML +/// document, are retained in \p Style. llvm::error_code parseConfiguration(StringRef Text, FormatStyle *Style); /// \brief Gets configuration in a YAML string. Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -31,75 +31,69 @@ #include <queue> #include <string> +using clang::format::FormatStyle; + namespace llvm { namespace yaml { -template <> -struct ScalarEnumerationTraits<clang::format::FormatStyle::LanguageKind> { - static void enumeration(IO &IO, - clang::format::FormatStyle::LanguageKind &Value) { - IO.enumCase(Value, "Cpp", clang::format::FormatStyle::LK_Cpp); - IO.enumCase(Value, "JavaScript", clang::format::FormatStyle::LK_JavaScript); +template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> { + static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) { + IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp); + IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript); } }; -template <> -struct ScalarEnumerationTraits<clang::format::FormatStyle::LanguageStandard> { - static void enumeration(IO &IO, - clang::format::FormatStyle::LanguageStandard &Value) { - IO.enumCase(Value, "Cpp03", clang::format::FormatStyle::LS_Cpp03); - IO.enumCase(Value, "C++03", clang::format::FormatStyle::LS_Cpp03); - IO.enumCase(Value, "Cpp11", clang::format::FormatStyle::LS_Cpp11); - IO.enumCase(Value, "C++11", clang::format::FormatStyle::LS_Cpp11); - IO.enumCase(Value, "Auto", clang::format::FormatStyle::LS_Auto); +template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> { + static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) { + IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); + IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); + IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11); + IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); + IO.enumCase(Value, "Auto", FormatStyle::LS_Auto); } }; -template <> -struct ScalarEnumerationTraits<clang::format::FormatStyle::UseTabStyle> { - static void enumeration(IO &IO, - clang::format::FormatStyle::UseTabStyle &Value) { - IO.enumCase(Value, "Never", clang::format::FormatStyle::UT_Never); - IO.enumCase(Value, "false", clang::format::FormatStyle::UT_Never); - IO.enumCase(Value, "Always", clang::format::FormatStyle::UT_Always); - IO.enumCase(Value, "true", clang::format::FormatStyle::UT_Always); - IO.enumCase(Value, "ForIndentation", - clang::format::FormatStyle::UT_ForIndentation); +template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> { + static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) { + IO.enumCase(Value, "Never", FormatStyle::UT_Never); + IO.enumCase(Value, "false", FormatStyle::UT_Never); + IO.enumCase(Value, "Always", FormatStyle::UT_Always); + IO.enumCase(Value, "true", FormatStyle::UT_Always); + IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation); } }; -template <> -struct ScalarEnumerationTraits<clang::format::FormatStyle::BraceBreakingStyle> { - static void - enumeration(IO &IO, clang::format::FormatStyle::BraceBreakingStyle &Value) { - IO.enumCase(Value, "Attach", clang::format::FormatStyle::BS_Attach); - IO.enumCase(Value, "Linux", clang::format::FormatStyle::BS_Linux); - IO.enumCase(Value, "Stroustrup", clang::format::FormatStyle::BS_Stroustrup); - IO.enumCase(Value, "Allman", clang::format::FormatStyle::BS_Allman); +template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> { + static void enumeration(IO &IO, FormatStyle::BraceBreakingStyle &Value) { + IO.enumCase(Value, "Attach", FormatStyle::BS_Attach); + IO.enumCase(Value, "Linux", FormatStyle::BS_Linux); + IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup); + IO.enumCase(Value, "Allman", FormatStyle::BS_Allman); } }; template <> -struct ScalarEnumerationTraits< - clang::format::FormatStyle::NamespaceIndentationKind> { - static void - enumeration(IO &IO, - clang::format::FormatStyle::NamespaceIndentationKind &Value) { - IO.enumCase(Value, "None", clang::format::FormatStyle::NI_None); - IO.enumCase(Value, "Inner", clang::format::FormatStyle::NI_Inner); - IO.enumCase(Value, "All", clang::format::FormatStyle::NI_All); +struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> { + static void enumeration(IO &IO, + FormatStyle::NamespaceIndentationKind &Value) { + IO.enumCase(Value, "None", FormatStyle::NI_None); + IO.enumCase(Value, "Inner", FormatStyle::NI_Inner); + IO.enumCase(Value, "All", FormatStyle::NI_All); } }; -template <> struct MappingTraits<clang::format::FormatStyle> { - static void mapping(llvm::yaml::IO &IO, clang::format::FormatStyle &Style) { +template <> struct MappingTraits<FormatStyle> { + static void mapping(IO &IO, FormatStyle &Style) { + // When reading, read the language first, we need it for getPredefinedStyle. + IO.mapOptional("Language", Style.Language); + if (IO.outputting()) { StringRef StylesArray[] = { "LLVM", "Google", "Chromium", "Mozilla", "WebKit" }; ArrayRef<StringRef> Styles(StylesArray); for (size_t i = 0, e = Styles.size(); i < e; ++i) { StringRef StyleName(Styles[i]); - clang::format::FormatStyle PredefinedStyle; - if (clang::format::getPredefinedStyle(StyleName, &PredefinedStyle) && + FormatStyle PredefinedStyle; + if (getPredefinedStyle(Style.Language, StyleName, &PredefinedStyle) && Style == PredefinedStyle) { IO.mapOptional("# BasedOnStyle", StyleName); break; @@ -109,16 +103,17 @@ StringRef BasedOnStyle; IO.mapOptional("BasedOnStyle", BasedOnStyle); if (!BasedOnStyle.empty()) { - clang::format::FormatStyle::LanguageKind Language = Style.Language; - if (!clang::format::getPredefinedStyle(BasedOnStyle, &Style)) { + FormatStyle::LanguageKind OldLanguage = Style.Language; + FormatStyle::LanguageKind Language = + ((FormatStyle *)IO.getContext())->Language; + if (!getPredefinedStyle(Language, BasedOnStyle, &Style)) { IO.setError(Twine("Unknown value for BasedOnStyle: ", BasedOnStyle)); return; } - Style.Language = Language; + Style.Language = OldLanguage; } } - IO.mapOptional("Language", Style.Language); IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset); IO.mapOptional("ConstructorInitializerIndentWidth", Style.ConstructorInitializerIndentWidth); @@ -188,32 +183,28 @@ }; // Allows to read vector<FormatStyle> while keeping default values. -// Elements will be written or read starting from the 1st element. -// When writing, the 0th element is ignored. -// When reading, keys that are not present in the serialized form will be -// copied from the 0th element of the vector. If the first element had no -// Language specified, it will be treated as the default one for the following -// elements. -template <> -struct DocumentListTraits<std::vector<clang::format::FormatStyle> > { - static size_t size(IO &io, std::vector<clang::format::FormatStyle> &Seq) { - return Seq.size() - 1; - } - static clang::format::FormatStyle & - element(IO &io, std::vector<clang::format::FormatStyle> &Seq, size_t Index) { - if (Index + 2 > Seq.size()) { - assert(Index + 2 == Seq.size() + 1); - clang::format::FormatStyle Template; - if (Seq.size() > 1 && - Seq[1].Language == clang::format::FormatStyle::LK_None) { - Template = Seq[1]; - } else { +// IO.getContext() should contain a pointer to the FormatStyle structure, that +// will be used to get default values for missing keys. +// If the first element has no Language specified, it will be treated as the +// default one for the following elements. +template <> struct DocumentListTraits<std::vector<FormatStyle> > { + static size_t size(IO &IO, std::vector<FormatStyle> &Seq) { + return Seq.size(); + } + static FormatStyle &element(IO &IO, std::vector<FormatStyle> &Seq, + size_t Index) { + if (Index >= Seq.size()) { + assert(Index == Seq.size()); + FormatStyle Template; + if (Seq.size() > 0 && Seq[0].Language == FormatStyle::LK_None) { Template = Seq[0]; - Template.Language = clang::format::FormatStyle::LK_None; + } else { + Template = *((const FormatStyle*)IO.getContext()); + Template.Language = FormatStyle::LK_None; } - Seq.resize(Index + 2, Template); + Seq.resize(Index + 1, Template); } - return Seq[Index + 1]; + return Seq[Index]; } }; } @@ -327,6 +318,16 @@ return GoogleStyle; } +FormatStyle getGoogleJSStyle() { + FormatStyle GoogleJSStyle = getGoogleStyle(); + GoogleJSStyle.Language = FormatStyle::LK_JavaScript; + GoogleJSStyle.BreakBeforeTernaryOperators = false; + // FIXME: Currently unimplemented: + // var arr = [1, 2, 3]; // No space after [ or before ]. + // var obj = {a: 1, b: 2, c: 3}; // No space after ':'. + return GoogleJSStyle; +} + FormatStyle getChromiumStyle() { FormatStyle ChromiumStyle = getGoogleStyle(); ChromiumStyle.AllowAllParametersOfDeclarationOnNextLine = false; @@ -364,56 +365,67 @@ return Style; } -bool getPredefinedStyle(StringRef Name, FormatStyle *Style) { - if (Name.equals_lower("llvm")) +bool getPredefinedStyle(FormatStyle::LanguageKind Language, StringRef Name, + FormatStyle *Style) { + if (Name.equals_lower("llvm")) { *Style = getLLVMStyle(); - else if (Name.equals_lower("chromium")) + } else if (Name.equals_lower("chromium")) { *Style = getChromiumStyle(); - else if (Name.equals_lower("mozilla")) + } else if (Name.equals_lower("mozilla")) { *Style = getMozillaStyle(); - else if (Name.equals_lower("google")) - *Style = getGoogleStyle(); - else if (Name.equals_lower("webkit")) + } else if (Name.equals_lower("google")) { + *Style = Language == FormatStyle::LK_JavaScript ? getGoogleJSStyle() + : getGoogleStyle(); + } else if (Name.equals_lower("webkit")) { *Style = getWebKitStyle(); - else + } else { return false; + } + Style->Language = Language; return true; } llvm::error_code parseConfiguration(StringRef Text, FormatStyle *Style) { assert(Style); - assert(Style->Language != FormatStyle::LK_None); + FormatStyle::LanguageKind Language = Style->Language; + assert(Language != FormatStyle::LK_None); if (Text.trim().empty()) return llvm::make_error_code(llvm::errc::invalid_argument); std::vector<FormatStyle> Styles; - // DocumentListTraits<vector<FormatStyle>> uses 0th element as the default one - // for the fields, keys for which are missing from the configuration. - Styles.push_back(*Style); llvm::yaml::Input Input(Text); + // DocumentListTraits<vector<FormatStyle>> uses the context to get default + // values for the fields, keys for which are missing from the configuration. + // Mapping also uses the context to get the language to find the correct + // base style. + Input.setContext(Style); Input >> Styles; if (Input.error()) return Input.error(); - for (unsigned i = 1; i < Styles.size(); ++i) { + for (unsigned i = 0; i < Styles.size(); ++i) { // Ensures that only the first configuration can skip the Language option. - if (Styles[i].Language == FormatStyle::LK_None && i != 1) + if (Styles[i].Language == FormatStyle::LK_None && i != 0) return llvm::make_error_code(llvm::errc::invalid_argument); // Ensure that each language is configured at most once. - for (unsigned j = 1; j < i; ++j) { - if (Styles[i].Language == Styles[j].Language) + for (unsigned j = 0; j < i; ++j) { + if (Styles[i].Language == Styles[j].Language) { + DEBUG(llvm::dbgs() + << "Duplicate languages in the config file on positions " << j + << " and " << i << "\n"); return llvm::make_error_code(llvm::errc::invalid_argument); + } } } // Look for a suitable configuration starting from the end, so we can // find the configuration for the specific language first, and the default - // configuration (which can only be at slot 1) after it. - for (unsigned i = Styles.size() - 1; i > 0; --i) { - if (Styles[i].Language == Styles[0].Language || + // configuration (which can only be at slot 0) after it. + for (int i = Styles.size() - 1; i >= 0; --i) { + if (Styles[i].Language == Language || Styles[i].Language == FormatStyle::LK_None) { *Style = Styles[i]; - Style->Language = Styles[0].Language; + Style->Language = Language; return llvm::make_error_code(llvm::errc::success); } } @@ -489,7 +501,7 @@ : 0; } if (TheLine->Last->is(tok::l_brace)) { - return Style.BreakBeforeBraces == clang::format::FormatStyle::BS_Attach + return Style.BreakBeforeBraces == FormatStyle::BS_Attach ? tryMergeSimpleBlock(I, E, Limit) : 0; } @@ -1658,28 +1670,22 @@ "parameters, e.g.:\n" " -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\""; -static void fillLanguageByFileName(StringRef FileName, FormatStyle *Style) { - if (FileName.endswith_lower(".c") || FileName.endswith_lower(".h") || - FileName.endswith_lower(".cpp") || FileName.endswith_lower(".hpp") || - FileName.endswith_lower(".cc") || FileName.endswith_lower(".hh") || - FileName.endswith_lower(".cxx") || FileName.endswith_lower(".hxx") || - FileName.endswith_lower(".m") || FileName.endswith_lower(".mm")) { - Style->Language = FormatStyle::LK_Cpp; - } +static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { if (FileName.endswith_lower(".js")) { - Style->Language = FormatStyle::LK_JavaScript; + return FormatStyle::LK_JavaScript; } + return FormatStyle::LK_Cpp; } FormatStyle getStyle(StringRef StyleName, StringRef FileName, StringRef FallbackStyle) { - FormatStyle Style; - if (!getPredefinedStyle(FallbackStyle, &Style)) { + FormatStyle Style = getLLVMStyle(); + Style.Language = getLanguageByFileName(FileName); + if (!getPredefinedStyle(Style.Language, FallbackStyle, &Style)) { llvm::errs() << "Invalid fallback style \"" << FallbackStyle << "\" using LLVM style\n"; - return getLLVMStyle(); + return Style; } - fillLanguageByFileName(FileName, &Style); if (StyleName.startswith("{")) { // Parse YAML/JSON style from the command line. @@ -1691,13 +1697,13 @@ } if (!StyleName.equals_lower("file")) { - if (!getPredefinedStyle(StyleName, &Style)) + if (!getPredefinedStyle(Style.Language, StyleName, &Style)) llvm::errs() << "Invalid value for -style, using " << FallbackStyle << " style\n"; - fillLanguageByFileName(FileName, &Style); return Style; } + // Look for .clang-format/_clang-format file in the file's parent directories. SmallString<128> UnsuitableConfigFiles; SmallString<128> Path(FileName); llvm::sys::fs::make_absolute(Path); Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -6913,31 +6913,53 @@ FormatStyle Styles[3]; Styles[0] = getLLVMStyle(); - EXPECT_TRUE(getPredefinedStyle("LLVM", &Styles[1])); - EXPECT_TRUE(getPredefinedStyle("lLvM", &Styles[2])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "LLVM", &Styles[1])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "lLvM", &Styles[2])); EXPECT_TRUE(allStylesEqual(Styles)); Styles[0] = getGoogleStyle(); - EXPECT_TRUE(getPredefinedStyle("Google", &Styles[1])); - EXPECT_TRUE(getPredefinedStyle("gOOgle", &Styles[2])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "Google", &Styles[1])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "gOOgle", &Styles[2])); + EXPECT_TRUE(allStylesEqual(Styles)); + + Styles[0] = getGoogleJSStyle(); + EXPECT_TRUE( + getPredefinedStyle(FormatStyle::LK_JavaScript, "Google", &Styles[1])); + EXPECT_TRUE( + getPredefinedStyle(FormatStyle::LK_JavaScript, "gOOgle", &Styles[2])); EXPECT_TRUE(allStylesEqual(Styles)); Styles[0] = getChromiumStyle(); - EXPECT_TRUE(getPredefinedStyle("Chromium", &Styles[1])); - EXPECT_TRUE(getPredefinedStyle("cHRoMiUM", &Styles[2])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "Chromium", &Styles[1])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "cHRoMiUM", &Styles[2])); EXPECT_TRUE(allStylesEqual(Styles)); Styles[0] = getMozillaStyle(); - EXPECT_TRUE(getPredefinedStyle("Mozilla", &Styles[1])); - EXPECT_TRUE(getPredefinedStyle("moZILla", &Styles[2])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "Mozilla", &Styles[1])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "moZILla", &Styles[2])); EXPECT_TRUE(allStylesEqual(Styles)); Styles[0] = getWebKitStyle(); - EXPECT_TRUE(getPredefinedStyle("WebKit", &Styles[1])); - EXPECT_TRUE(getPredefinedStyle("wEbKit", &Styles[2])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "WebKit", &Styles[1])); + EXPECT_TRUE(getPredefinedStyle(FormatStyle::LK_Cpp, "wEbKit", &Styles[2])); EXPECT_TRUE(allStylesEqual(Styles)); - EXPECT_FALSE(getPredefinedStyle("qwerty", &Styles[0])); + EXPECT_FALSE(getPredefinedStyle(FormatStyle::LK_Cpp, "qwerty", &Styles[0])); +} + +TEST_F(FormatTest, GetsCorrectBasedOnStyle) { + FormatStyle Styles[2]; + + Styles[0] = getGoogleStyle(); + Styles[1] = getLLVMStyle(); + EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value()); + EXPECT_TRUE(allStylesEqual(Styles)); + + Styles[0] = getGoogleJSStyle(); + Styles[1] = getLLVMStyle(); + Styles[1].Language = FormatStyle::LK_JavaScript; + EXPECT_EQ(0, parseConfiguration("BasedOnStyle: Google", &Styles[1]).value()); + EXPECT_TRUE(allStylesEqual(Styles)); } #define CHECK_PARSE(TEXT, FIELD, VALUE) \ @@ -7132,6 +7154,23 @@ EXPECT_EQ(FormatStyle::LK_Cpp, Style.Language); } +TEST_F(FormatTest, UsesLanguageForBasedOnStyle) { + FormatStyle Style = {}; + Style.Language = FormatStyle::LK_JavaScript; + Style.BreakBeforeTernaryOperators = true; + CHECK_PARSE("BasedOnStyle: Google", BreakBeforeTernaryOperators, false); + Style.BreakBeforeTernaryOperators = true; + CHECK_PARSE("---\n" + "BasedOnStyle: Google\n" + "---\n" + "Language: JavaScript\n" + "IndentWidth: 76\n" + "...\n", + BreakBeforeTernaryOperators, false); + EXPECT_EQ(76u, Style.IndentWidth); + EXPECT_EQ(FormatStyle::LK_JavaScript, Style.Language); +} + #undef CHECK_PARSE #undef CHECK_PARSE_BOOL Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -33,24 +33,18 @@ } static std::string format(llvm::StringRef Code, - const FormatStyle &Style = getJSStyle()) { + const FormatStyle &Style = getGoogleJSStyle()) { return format(Code, 0, Code.size(), Style); } - static FormatStyle getJSStyle() { - FormatStyle Style = getLLVMStyle(); - Style.Language = FormatStyle::LK_JavaScript; - return Style; - } - - static FormatStyle getJSStyleWithColumns(unsigned ColumnLimit) { - FormatStyle Style = getJSStyle(); + static FormatStyle getGoogleJSStyleWithColumns(unsigned ColumnLimit) { + FormatStyle Style = getGoogleJSStyle(); Style.ColumnLimit = ColumnLimit; return Style; } static void verifyFormat(llvm::StringRef Code, - const FormatStyle &Style = getJSStyle()) { + const FormatStyle &Style = getGoogleJSStyle()) { EXPECT_EQ(Code.str(), format(test::messUp(Code), Style)); } }; @@ -60,26 +54,30 @@ verifyFormat("a != = b;"); verifyFormat("a === b;"); - verifyFormat("aaaaaaa ===\n b;", getJSStyleWithColumns(10)); + verifyFormat("aaaaaaa ===\n b;", getGoogleJSStyleWithColumns(10)); verifyFormat("a !== b;"); - verifyFormat("aaaaaaa !==\n b;", getJSStyleWithColumns(10)); + verifyFormat("aaaaaaa !==\n b;", getGoogleJSStyleWithColumns(10)); verifyFormat("if (a + b + c +\n" " d !==\n" " e + f + g)\n" " q();", - getJSStyleWithColumns(20)); + getGoogleJSStyleWithColumns(20)); verifyFormat("a >> >= b;"); verifyFormat("a >>> b;"); - verifyFormat("aaaaaaa >>>\n b;", getJSStyleWithColumns(10)); + verifyFormat("aaaaaaa >>>\n b;", getGoogleJSStyleWithColumns(10)); verifyFormat("a >>>= b;"); - verifyFormat("aaaaaaa >>>=\n b;", getJSStyleWithColumns(10)); + verifyFormat("aaaaaaa >>>=\n b;", getGoogleJSStyleWithColumns(10)); verifyFormat("if (a + b + c +\n" " d >>>\n" " e + f + g)\n" " q();", - getJSStyleWithColumns(20)); + getGoogleJSStyleWithColumns(20)); + verifyFormat("var x = aaaaaaaaaa ?\n" + " bbbbbb :\n" + " ccc;", + getGoogleJSStyleWithColumns(20)); } } // end namespace tooling
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
