Lines Matching refs:FormatStyle
44 using clang::format::FormatStyle;
47 LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::IncludeCategory)
51 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
52 static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) { in enumeration()
53 IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp); in enumeration()
54 IO.enumCase(Value, "Java", FormatStyle::LK_Java); in enumeration()
55 IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript); in enumeration()
56 IO.enumCase(Value, "Proto", FormatStyle::LK_Proto); in enumeration()
57 IO.enumCase(Value, "TableGen", FormatStyle::LK_TableGen); in enumeration()
61 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> {
62 static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) { in enumeration()
63 IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); in enumeration()
64 IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); in enumeration()
65 IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11); in enumeration()
66 IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); in enumeration()
67 IO.enumCase(Value, "Auto", FormatStyle::LS_Auto); in enumeration()
71 template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> {
72 static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) { in enumeration()
73 IO.enumCase(Value, "Never", FormatStyle::UT_Never); in enumeration()
74 IO.enumCase(Value, "false", FormatStyle::UT_Never); in enumeration()
75 IO.enumCase(Value, "Always", FormatStyle::UT_Always); in enumeration()
76 IO.enumCase(Value, "true", FormatStyle::UT_Always); in enumeration()
77 IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation); in enumeration()
79 FormatStyle::UT_ForContinuationAndIndentation); in enumeration()
83 template <> struct ScalarEnumerationTraits<FormatStyle::JavaScriptQuoteStyle> {
84 static void enumeration(IO &IO, FormatStyle::JavaScriptQuoteStyle &Value) { in enumeration()
85 IO.enumCase(Value, "Leave", FormatStyle::JSQS_Leave); in enumeration()
86 IO.enumCase(Value, "Single", FormatStyle::JSQS_Single); in enumeration()
87 IO.enumCase(Value, "Double", FormatStyle::JSQS_Double); in enumeration()
91 template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
92 static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) { in enumeration()
93 IO.enumCase(Value, "None", FormatStyle::SFS_None); in enumeration()
94 IO.enumCase(Value, "false", FormatStyle::SFS_None); in enumeration()
95 IO.enumCase(Value, "All", FormatStyle::SFS_All); in enumeration()
96 IO.enumCase(Value, "true", FormatStyle::SFS_All); in enumeration()
97 IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline); in enumeration()
98 IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty); in enumeration()
102 template <> struct ScalarEnumerationTraits<FormatStyle::BinaryOperatorStyle> {
103 static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) { in enumeration()
104 IO.enumCase(Value, "All", FormatStyle::BOS_All); in enumeration()
105 IO.enumCase(Value, "true", FormatStyle::BOS_All); in enumeration()
106 IO.enumCase(Value, "None", FormatStyle::BOS_None); in enumeration()
107 IO.enumCase(Value, "false", FormatStyle::BOS_None); in enumeration()
108 IO.enumCase(Value, "NonAssignment", FormatStyle::BOS_NonAssignment); in enumeration()
112 template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> {
113 static void enumeration(IO &IO, FormatStyle::BraceBreakingStyle &Value) { in enumeration()
114 IO.enumCase(Value, "Attach", FormatStyle::BS_Attach); in enumeration()
115 IO.enumCase(Value, "Linux", FormatStyle::BS_Linux); in enumeration()
116 IO.enumCase(Value, "Mozilla", FormatStyle::BS_Mozilla); in enumeration()
117 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup); in enumeration()
118 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman); in enumeration()
119 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU); in enumeration()
120 IO.enumCase(Value, "WebKit", FormatStyle::BS_WebKit); in enumeration()
121 IO.enumCase(Value, "Custom", FormatStyle::BS_Custom); in enumeration()
126 struct ScalarEnumerationTraits<FormatStyle::ReturnTypeBreakingStyle> {
127 static void enumeration(IO &IO, FormatStyle::ReturnTypeBreakingStyle &Value) { in enumeration()
128 IO.enumCase(Value, "None", FormatStyle::RTBS_None); in enumeration()
129 IO.enumCase(Value, "All", FormatStyle::RTBS_All); in enumeration()
130 IO.enumCase(Value, "TopLevel", FormatStyle::RTBS_TopLevel); in enumeration()
132 FormatStyle::RTBS_TopLevelDefinitions); in enumeration()
133 IO.enumCase(Value, "AllDefinitions", FormatStyle::RTBS_AllDefinitions); in enumeration()
138 struct ScalarEnumerationTraits<FormatStyle::DefinitionReturnTypeBreakingStyle> {
140 enumeration(IO &IO, FormatStyle::DefinitionReturnTypeBreakingStyle &Value) { in enumeration()
141 IO.enumCase(Value, "None", FormatStyle::DRTBS_None); in enumeration()
142 IO.enumCase(Value, "All", FormatStyle::DRTBS_All); in enumeration()
143 IO.enumCase(Value, "TopLevel", FormatStyle::DRTBS_TopLevel); in enumeration()
146 IO.enumCase(Value, "false", FormatStyle::DRTBS_None); in enumeration()
147 IO.enumCase(Value, "true", FormatStyle::DRTBS_All); in enumeration()
152 struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> {
154 FormatStyle::NamespaceIndentationKind &Value) { in enumeration()
155 IO.enumCase(Value, "None", FormatStyle::NI_None); in enumeration()
156 IO.enumCase(Value, "Inner", FormatStyle::NI_Inner); in enumeration()
157 IO.enumCase(Value, "All", FormatStyle::NI_All); in enumeration()
161 template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
162 static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) { in enumeration()
163 IO.enumCase(Value, "Align", FormatStyle::BAS_Align); in enumeration()
164 IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign); in enumeration()
165 IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak); in enumeration()
168 IO.enumCase(Value, "true", FormatStyle::BAS_Align); in enumeration()
169 IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign); in enumeration()
173 template <> struct ScalarEnumerationTraits<FormatStyle::PointerAlignmentStyle> {
174 static void enumeration(IO &IO, FormatStyle::PointerAlignmentStyle &Value) { in enumeration()
175 IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle); in enumeration()
176 IO.enumCase(Value, "Left", FormatStyle::PAS_Left); in enumeration()
177 IO.enumCase(Value, "Right", FormatStyle::PAS_Right); in enumeration()
180 IO.enumCase(Value, "true", FormatStyle::PAS_Left); in enumeration()
181 IO.enumCase(Value, "false", FormatStyle::PAS_Right); in enumeration()
186 struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensOptions> {
188 FormatStyle::SpaceBeforeParensOptions &Value) { in enumeration()
189 IO.enumCase(Value, "Never", FormatStyle::SBPO_Never); in enumeration()
191 FormatStyle::SBPO_ControlStatements); in enumeration()
192 IO.enumCase(Value, "Always", FormatStyle::SBPO_Always); in enumeration()
195 IO.enumCase(Value, "false", FormatStyle::SBPO_Never); in enumeration()
196 IO.enumCase(Value, "true", FormatStyle::SBPO_ControlStatements); in enumeration()
200 template <> struct MappingTraits<FormatStyle> {
201 static void mapping(IO &IO, FormatStyle &Style) { in mapping()
211 FormatStyle PredefinedStyle; in mapping()
222 FormatStyle::LanguageKind OldLanguage = Style.Language; in mapping()
223 FormatStyle::LanguageKind Language = in mapping()
224 ((FormatStyle *)IO.getContext())->Language; in mapping()
271 if (Style.AlwaysBreakAfterDefinitionReturnType != FormatStyle::DRTBS_None && in mapping()
272 Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None) { in mapping()
273 if (Style.AlwaysBreakAfterDefinitionReturnType == FormatStyle::DRTBS_All) in mapping()
274 Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions; in mapping()
276 FormatStyle::DRTBS_TopLevel) in mapping()
278 FormatStyle::RTBS_TopLevelDefinitions; in mapping()
361 template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
362 static void mapping(IO &IO, FormatStyle::BraceWrappingFlags &Wrapping) { in mapping()
377 template <> struct MappingTraits<FormatStyle::IncludeCategory> {
378 static void mapping(IO &IO, FormatStyle::IncludeCategory &Category) { in mapping()
389 template <> struct DocumentListTraits<std::vector<FormatStyle>> {
390 static size_t size(IO &IO, std::vector<FormatStyle> &Seq) { in size()
393 static FormatStyle &element(IO &IO, std::vector<FormatStyle> &Seq, in element()
397 FormatStyle Template; in element()
398 if (Seq.size() > 0 && Seq[0].Language == FormatStyle::LK_None) { in element()
401 Template = *((const FormatStyle *)IO.getContext()); in element()
402 Template.Language = FormatStyle::LK_None; in element()
439 static FormatStyle expandPresets(const FormatStyle &Style) { in expandPresets()
440 if (Style.BreakBeforeBraces == FormatStyle::BS_Custom) in expandPresets()
442 FormatStyle Expanded = Style; in expandPresets()
446 case FormatStyle::BS_Linux: in expandPresets()
451 case FormatStyle::BS_Mozilla: in expandPresets()
458 case FormatStyle::BS_Stroustrup: in expandPresets()
463 case FormatStyle::BS_Allman: in expandPresets()
474 case FormatStyle::BS_GNU: in expandPresets()
478 case FormatStyle::BS_WebKit: in expandPresets()
487 FormatStyle getLLVMStyle() { in getLLVMStyle()
488 FormatStyle LLVMStyle; in getLLVMStyle()
489 LLVMStyle.Language = FormatStyle::LK_Cpp; in getLLVMStyle()
492 LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align; in getLLVMStyle()
498 LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; in getLLVMStyle()
503 LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None; in getLLVMStyle()
504 LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None; in getLLVMStyle()
509 LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None; in getLLVMStyle()
511 LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach; in getLLVMStyle()
535 LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave; in getLLVMStyle()
540 LLVMStyle.NamespaceIndentation = FormatStyle::NI_None; in getLLVMStyle()
544 LLVMStyle.PointerAlignment = FormatStyle::PAS_Right; in getLLVMStyle()
546 LLVMStyle.Standard = FormatStyle::LS_Cpp11; in getLLVMStyle()
547 LLVMStyle.UseTab = FormatStyle::UT_Never; in getLLVMStyle()
548 LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave; in getLLVMStyle()
556 LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements; in getLLVMStyle()
573 FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { in getGoogleStyle()
574 FormatStyle GoogleStyle = getLLVMStyle(); in getGoogleStyle()
591 GoogleStyle.PointerAlignment = FormatStyle::PAS_Left; in getGoogleStyle()
593 GoogleStyle.Standard = FormatStyle::LS_Auto; in getGoogleStyle()
598 if (Language == FormatStyle::LK_Java) { in getGoogleStyle()
599 GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; in getGoogleStyle()
602 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty; in getGoogleStyle()
605 GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment; in getGoogleStyle()
609 } else if (Language == FormatStyle::LK_JavaScript) { in getGoogleStyle()
610 GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; in getGoogleStyle()
612 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; in getGoogleStyle()
617 GoogleStyle.NamespaceIndentation = FormatStyle::NI_All; in getGoogleStyle()
619 GoogleStyle.JavaScriptQuotes = FormatStyle::JSQS_Single; in getGoogleStyle()
621 } else if (Language == FormatStyle::LK_Proto) { in getGoogleStyle()
622 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None; in getGoogleStyle()
629 FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) { in getChromiumStyle()
630 FormatStyle ChromiumStyle = getGoogleStyle(Language); in getChromiumStyle()
631 if (Language == FormatStyle::LK_Java) { in getChromiumStyle()
638 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; in getChromiumStyle()
648 FormatStyle getMozillaStyle() { in getMozillaStyle()
649 FormatStyle MozillaStyle = getLLVMStyle(); in getMozillaStyle()
651 MozillaStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; in getMozillaStyle()
653 FormatStyle::RTBS_TopLevelDefinitions; in getMozillaStyle()
655 FormatStyle::DRTBS_TopLevel; in getMozillaStyle()
657 MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla; in getMozillaStyle()
666 MozillaStyle.PointerAlignment = FormatStyle::PAS_Left; in getMozillaStyle()
670 FormatStyle getWebKitStyle() { in getWebKitStyle()
671 FormatStyle Style = getLLVMStyle(); in getWebKitStyle()
673 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; in getWebKitStyle()
676 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All; in getWebKitStyle()
677 Style.BreakBeforeBraces = FormatStyle::BS_WebKit; in getWebKitStyle()
682 Style.NamespaceIndentation = FormatStyle::NI_Inner; in getWebKitStyle()
685 Style.PointerAlignment = FormatStyle::PAS_Left; in getWebKitStyle()
686 Style.Standard = FormatStyle::LS_Cpp03; in getWebKitStyle()
690 FormatStyle getGNUStyle() { in getGNUStyle()
691 FormatStyle Style = getLLVMStyle(); in getGNUStyle()
692 Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All; in getGNUStyle()
693 Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions; in getGNUStyle()
694 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All; in getGNUStyle()
695 Style.BreakBeforeBraces = FormatStyle::BS_GNU; in getGNUStyle()
699 Style.SpaceBeforeParens = FormatStyle::SBPO_Always; in getGNUStyle()
700 Style.Standard = FormatStyle::LS_Cpp03; in getGNUStyle()
704 FormatStyle getNoStyle() { in getNoStyle()
705 FormatStyle NoStyle = getLLVMStyle(); in getNoStyle()
711 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, in getPredefinedStyle()
712 FormatStyle *Style) { in getPredefinedStyle()
735 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) { in parseConfiguration()
737 FormatStyle::LanguageKind Language = Style->Language; in parseConfiguration()
738 assert(Language != FormatStyle::LK_None); in parseConfiguration()
742 std::vector<FormatStyle> Styles; in parseConfiguration()
755 if (Styles[i].Language == FormatStyle::LK_None && i != 0) in parseConfiguration()
772 Styles[i].Language == FormatStyle::LK_None) { in parseConfiguration()
781 std::string configurationAsText(const FormatStyle &Style) { in configurationAsText()
787 FormatStyle NonConstStyle = expandPresets(Style); in configurationAsText()
796 Formatter(const Environment &Env, const FormatStyle &Style, in Formatter()
808 if (Style.Language == FormatStyle::LK_JavaScript && in analyze()
809 Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) in analyze()
847 (Style.JavaScriptQuotes == FormatStyle::JSQS_Single && in requoteJSStringLiteral()
849 (Style.JavaScriptQuotes == FormatStyle::JSQS_Double && in requoteJSStringLiteral()
854 bool IsSingle = Style.JavaScriptQuotes == FormatStyle::JSQS_Single; in requoteJSStringLiteral()
968 ? FormatStyle::PAS_Left in deriveLocalStyle()
969 : FormatStyle::PAS_Right; in deriveLocalStyle()
970 if (Style.Standard == FormatStyle::LS_Auto) in deriveLocalStyle()
972 ? FormatStyle::LS_Cpp11 in deriveLocalStyle()
973 : FormatStyle::LS_Cpp03; in deriveLocalStyle()
986 Cleaner(const Environment &Env, const FormatStyle &Style) in Cleaner()
1216 static void sortCppIncludes(const FormatStyle &Style, in sortCppIncludes()
1270 IncludeCategoryManager(const FormatStyle &Style, StringRef FileName) in IncludeCategoryManager()
1311 const FormatStyle &Style;
1323 tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code, in sortCppIncludes()
1383 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code, in sortIncludes()
1389 if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript) in sortIncludes()
1399 const FormatStyle &Style) { in processReplacements()
1418 const FormatStyle &Style) { in formatReplacements()
1421 auto SortIncludes = [](const FormatStyle &Style, StringRef Code, in formatReplacements()
1433 auto Reformat = [](const FormatStyle &Style, StringRef Code, in formatReplacements()
1469 const FormatStyle &Style) { in getOffsetAfterHeaderGuardsAndComments()
1496 const FormatStyle &Style) { in fixCppIncludeInsertions()
1497 if (Style.Language != FormatStyle::LanguageKind::LK_Cpp) in fixCppIncludeInsertions()
1600 const FormatStyle &Style) { in cleanupAroundReplacements()
1603 auto Cleanup = [](const FormatStyle &Style, StringRef Code, in cleanupAroundReplacements()
1614 tooling::Replacements reformat(const FormatStyle &Style, SourceManager &SM, in reformat()
1617 FormatStyle Expanded = expandPresets(Style); in reformat()
1626 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, in reformat()
1629 FormatStyle Expanded = expandPresets(Style); in reformat()
1639 tooling::Replacements cleanup(const FormatStyle &Style, SourceManager &SM, in cleanup()
1646 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code, in cleanup()
1655 LangOptions getFormattingLangOpts(const FormatStyle &Style) { in getFormattingLangOpts()
1658 LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; in getFormattingLangOpts()
1659 LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; in getFormattingLangOpts()
1661 bool AlternativeOperators = Style.Language == FormatStyle::LK_Cpp; in getFormattingLangOpts()
1682 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { in getLanguageByFileName()
1684 return FormatStyle::LK_Java; in getLanguageByFileName()
1686 return FormatStyle::LK_JavaScript; // JavaScript or TypeScript. in getLanguageByFileName()
1689 return FormatStyle::LK_Proto; in getLanguageByFileName()
1691 return FormatStyle::LK_TableGen; in getLanguageByFileName()
1692 return FormatStyle::LK_Cpp; in getLanguageByFileName()
1695 FormatStyle getStyle(StringRef StyleName, StringRef FileName, in getStyle()
1700 FormatStyle Style = getLLVMStyle(); in getStyle()