Lines Matching refs:FormatStyle
37 using clang::format::FormatStyle;
40 LLVM_YAML_IS_SEQUENCE_VECTOR(clang::format::FormatStyle::IncludeCategory)
44 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
45 static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) { in enumeration()
46 IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp); in enumeration()
47 IO.enumCase(Value, "Java", FormatStyle::LK_Java); in enumeration()
48 IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript); in enumeration()
49 IO.enumCase(Value, "Proto", FormatStyle::LK_Proto); in enumeration()
53 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> {
54 static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) { in enumeration()
55 IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03); in enumeration()
56 IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03); in enumeration()
57 IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11); in enumeration()
58 IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11); in enumeration()
59 IO.enumCase(Value, "Auto", FormatStyle::LS_Auto); in enumeration()
63 template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> {
64 static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) { in enumeration()
65 IO.enumCase(Value, "Never", FormatStyle::UT_Never); in enumeration()
66 IO.enumCase(Value, "false", FormatStyle::UT_Never); in enumeration()
67 IO.enumCase(Value, "Always", FormatStyle::UT_Always); in enumeration()
68 IO.enumCase(Value, "true", FormatStyle::UT_Always); in enumeration()
69 IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation); in enumeration()
73 template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
74 static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) { in enumeration()
75 IO.enumCase(Value, "None", FormatStyle::SFS_None); in enumeration()
76 IO.enumCase(Value, "false", FormatStyle::SFS_None); in enumeration()
77 IO.enumCase(Value, "All", FormatStyle::SFS_All); in enumeration()
78 IO.enumCase(Value, "true", FormatStyle::SFS_All); in enumeration()
79 IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline); in enumeration()
80 IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty); in enumeration()
84 template <> struct ScalarEnumerationTraits<FormatStyle::BinaryOperatorStyle> {
85 static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) { in enumeration()
86 IO.enumCase(Value, "All", FormatStyle::BOS_All); in enumeration()
87 IO.enumCase(Value, "true", FormatStyle::BOS_All); in enumeration()
88 IO.enumCase(Value, "None", FormatStyle::BOS_None); in enumeration()
89 IO.enumCase(Value, "false", FormatStyle::BOS_None); in enumeration()
90 IO.enumCase(Value, "NonAssignment", FormatStyle::BOS_NonAssignment); in enumeration()
94 template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> {
95 static void enumeration(IO &IO, FormatStyle::BraceBreakingStyle &Value) { in enumeration()
96 IO.enumCase(Value, "Attach", FormatStyle::BS_Attach); in enumeration()
97 IO.enumCase(Value, "Linux", FormatStyle::BS_Linux); in enumeration()
98 IO.enumCase(Value, "Mozilla", FormatStyle::BS_Mozilla); in enumeration()
99 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup); in enumeration()
100 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman); in enumeration()
101 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU); in enumeration()
102 IO.enumCase(Value, "WebKit", FormatStyle::BS_WebKit); in enumeration()
103 IO.enumCase(Value, "Custom", FormatStyle::BS_Custom); in enumeration()
108 struct ScalarEnumerationTraits<FormatStyle::ReturnTypeBreakingStyle> {
109 static void enumeration(IO &IO, FormatStyle::ReturnTypeBreakingStyle &Value) { in enumeration()
110 IO.enumCase(Value, "None", FormatStyle::RTBS_None); in enumeration()
111 IO.enumCase(Value, "All", FormatStyle::RTBS_All); in enumeration()
112 IO.enumCase(Value, "TopLevel", FormatStyle::RTBS_TopLevel); in enumeration()
114 FormatStyle::RTBS_TopLevelDefinitions); in enumeration()
115 IO.enumCase(Value, "AllDefinitions", FormatStyle::RTBS_AllDefinitions); in enumeration()
120 struct ScalarEnumerationTraits<FormatStyle::DefinitionReturnTypeBreakingStyle> {
122 enumeration(IO &IO, FormatStyle::DefinitionReturnTypeBreakingStyle &Value) { in enumeration()
123 IO.enumCase(Value, "None", FormatStyle::DRTBS_None); in enumeration()
124 IO.enumCase(Value, "All", FormatStyle::DRTBS_All); in enumeration()
125 IO.enumCase(Value, "TopLevel", FormatStyle::DRTBS_TopLevel); in enumeration()
128 IO.enumCase(Value, "false", FormatStyle::DRTBS_None); in enumeration()
129 IO.enumCase(Value, "true", FormatStyle::DRTBS_All); in enumeration()
134 struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> {
136 FormatStyle::NamespaceIndentationKind &Value) { in enumeration()
137 IO.enumCase(Value, "None", FormatStyle::NI_None); in enumeration()
138 IO.enumCase(Value, "Inner", FormatStyle::NI_Inner); in enumeration()
139 IO.enumCase(Value, "All", FormatStyle::NI_All); in enumeration()
143 template <> struct ScalarEnumerationTraits<FormatStyle::BracketAlignmentStyle> {
144 static void enumeration(IO &IO, FormatStyle::BracketAlignmentStyle &Value) { in enumeration()
145 IO.enumCase(Value, "Align", FormatStyle::BAS_Align); in enumeration()
146 IO.enumCase(Value, "DontAlign", FormatStyle::BAS_DontAlign); in enumeration()
147 IO.enumCase(Value, "AlwaysBreak", FormatStyle::BAS_AlwaysBreak); in enumeration()
150 IO.enumCase(Value, "true", FormatStyle::BAS_Align); in enumeration()
151 IO.enumCase(Value, "false", FormatStyle::BAS_DontAlign); in enumeration()
155 template <> struct ScalarEnumerationTraits<FormatStyle::PointerAlignmentStyle> {
156 static void enumeration(IO &IO, FormatStyle::PointerAlignmentStyle &Value) { in enumeration()
157 IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle); in enumeration()
158 IO.enumCase(Value, "Left", FormatStyle::PAS_Left); in enumeration()
159 IO.enumCase(Value, "Right", FormatStyle::PAS_Right); in enumeration()
162 IO.enumCase(Value, "true", FormatStyle::PAS_Left); in enumeration()
163 IO.enumCase(Value, "false", FormatStyle::PAS_Right); in enumeration()
168 struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensOptions> {
170 FormatStyle::SpaceBeforeParensOptions &Value) { in enumeration()
171 IO.enumCase(Value, "Never", FormatStyle::SBPO_Never); in enumeration()
173 FormatStyle::SBPO_ControlStatements); in enumeration()
174 IO.enumCase(Value, "Always", FormatStyle::SBPO_Always); in enumeration()
177 IO.enumCase(Value, "false", FormatStyle::SBPO_Never); in enumeration()
178 IO.enumCase(Value, "true", FormatStyle::SBPO_ControlStatements); in enumeration()
182 template <> struct MappingTraits<FormatStyle> {
183 static void mapping(IO &IO, FormatStyle &Style) { in mapping()
193 FormatStyle PredefinedStyle; in mapping()
204 FormatStyle::LanguageKind OldLanguage = Style.Language; in mapping()
205 FormatStyle::LanguageKind Language = in mapping()
206 ((FormatStyle *)IO.getContext())->Language; in mapping()
253 if (Style.AlwaysBreakAfterDefinitionReturnType != FormatStyle::DRTBS_None && in mapping()
254 Style.AlwaysBreakAfterReturnType == FormatStyle::RTBS_None) { in mapping()
255 if (Style.AlwaysBreakAfterDefinitionReturnType == FormatStyle::DRTBS_All) in mapping()
256 Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions; in mapping()
258 FormatStyle::DRTBS_TopLevel) in mapping()
260 FormatStyle::RTBS_TopLevelDefinitions; in mapping()
337 template <> struct MappingTraits<FormatStyle::BraceWrappingFlags> {
338 static void mapping(IO &IO, FormatStyle::BraceWrappingFlags &Wrapping) { in mapping()
353 template <> struct MappingTraits<FormatStyle::IncludeCategory> {
354 static void mapping(IO &IO, FormatStyle::IncludeCategory &Category) { in mapping()
365 template <> struct DocumentListTraits<std::vector<FormatStyle>> {
366 static size_t size(IO &IO, std::vector<FormatStyle> &Seq) { in size()
369 static FormatStyle &element(IO &IO, std::vector<FormatStyle> &Seq, in element()
373 FormatStyle Template; in element()
374 if (Seq.size() > 0 && Seq[0].Language == FormatStyle::LK_None) { in element()
377 Template = *((const FormatStyle *)IO.getContext()); in element()
378 Template.Language = FormatStyle::LK_None; in element()
415 static FormatStyle expandPresets(const FormatStyle &Style) { in expandPresets()
416 if (Style.BreakBeforeBraces == FormatStyle::BS_Custom) in expandPresets()
418 FormatStyle Expanded = Style; in expandPresets()
422 case FormatStyle::BS_Linux: in expandPresets()
427 case FormatStyle::BS_Mozilla: in expandPresets()
434 case FormatStyle::BS_Stroustrup: in expandPresets()
439 case FormatStyle::BS_Allman: in expandPresets()
450 case FormatStyle::BS_GNU: in expandPresets()
454 case FormatStyle::BS_WebKit: in expandPresets()
463 FormatStyle getLLVMStyle() { in getLLVMStyle()
464 FormatStyle LLVMStyle; in getLLVMStyle()
465 LLVMStyle.Language = FormatStyle::LK_Cpp; in getLLVMStyle()
468 LLVMStyle.AlignAfterOpenBracket = FormatStyle::BAS_Align; in getLLVMStyle()
474 LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All; in getLLVMStyle()
479 LLVMStyle.AlwaysBreakAfterReturnType = FormatStyle::RTBS_None; in getLLVMStyle()
480 LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None; in getLLVMStyle()
485 LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None; in getLLVMStyle()
487 LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach; in getLLVMStyle()
512 LLVMStyle.NamespaceIndentation = FormatStyle::NI_None; in getLLVMStyle()
516 LLVMStyle.PointerAlignment = FormatStyle::PAS_Right; in getLLVMStyle()
518 LLVMStyle.Standard = FormatStyle::LS_Cpp11; in getLLVMStyle()
519 LLVMStyle.UseTab = FormatStyle::UT_Never; in getLLVMStyle()
527 LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements; in getLLVMStyle()
544 FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) { in getGoogleStyle()
545 FormatStyle GoogleStyle = getLLVMStyle(); in getGoogleStyle()
561 GoogleStyle.PointerAlignment = FormatStyle::PAS_Left; in getGoogleStyle()
563 GoogleStyle.Standard = FormatStyle::LS_Auto; in getGoogleStyle()
568 if (Language == FormatStyle::LK_Java) { in getGoogleStyle()
569 GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; in getGoogleStyle()
572 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty; in getGoogleStyle()
575 GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment; in getGoogleStyle()
579 } else if (Language == FormatStyle::LK_JavaScript) { in getGoogleStyle()
580 GoogleStyle.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak; in getGoogleStyle()
582 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; in getGoogleStyle()
587 } else if (Language == FormatStyle::LK_Proto) { in getGoogleStyle()
588 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None; in getGoogleStyle()
595 FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) { in getChromiumStyle()
596 FormatStyle ChromiumStyle = getGoogleStyle(Language); in getChromiumStyle()
597 if (Language == FormatStyle::LK_Java) { in getChromiumStyle()
604 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; in getChromiumStyle()
613 FormatStyle getMozillaStyle() { in getMozillaStyle()
614 FormatStyle MozillaStyle = getLLVMStyle(); in getMozillaStyle()
616 MozillaStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline; in getMozillaStyle()
618 FormatStyle::RTBS_TopLevelDefinitions; in getMozillaStyle()
620 FormatStyle::DRTBS_TopLevel; in getMozillaStyle()
622 MozillaStyle.BreakBeforeBraces = FormatStyle::BS_Mozilla; in getMozillaStyle()
631 MozillaStyle.PointerAlignment = FormatStyle::PAS_Left; in getMozillaStyle()
635 FormatStyle getWebKitStyle() { in getWebKitStyle()
636 FormatStyle Style = getLLVMStyle(); in getWebKitStyle()
638 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; in getWebKitStyle()
641 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All; in getWebKitStyle()
642 Style.BreakBeforeBraces = FormatStyle::BS_WebKit; in getWebKitStyle()
647 Style.NamespaceIndentation = FormatStyle::NI_Inner; in getWebKitStyle()
650 Style.PointerAlignment = FormatStyle::PAS_Left; in getWebKitStyle()
651 Style.Standard = FormatStyle::LS_Cpp03; in getWebKitStyle()
655 FormatStyle getGNUStyle() { in getGNUStyle()
656 FormatStyle Style = getLLVMStyle(); in getGNUStyle()
657 Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All; in getGNUStyle()
658 Style.AlwaysBreakAfterReturnType = FormatStyle::RTBS_AllDefinitions; in getGNUStyle()
659 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All; in getGNUStyle()
660 Style.BreakBeforeBraces = FormatStyle::BS_GNU; in getGNUStyle()
664 Style.SpaceBeforeParens = FormatStyle::SBPO_Always; in getGNUStyle()
665 Style.Standard = FormatStyle::LS_Cpp03; in getGNUStyle()
669 FormatStyle getNoStyle() { in getNoStyle()
670 FormatStyle NoStyle = getLLVMStyle(); in getNoStyle()
676 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language, in getPredefinedStyle()
677 FormatStyle *Style) { in getPredefinedStyle()
700 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) { in parseConfiguration()
702 FormatStyle::LanguageKind Language = Style->Language; in parseConfiguration()
703 assert(Language != FormatStyle::LK_None); in parseConfiguration()
707 std::vector<FormatStyle> Styles; in parseConfiguration()
720 if (Styles[i].Language == FormatStyle::LK_None && i != 0) in parseConfiguration()
737 Styles[i].Language == FormatStyle::LK_None) { in parseConfiguration()
746 std::string configurationAsText(const FormatStyle &Style) { in configurationAsText()
752 FormatStyle NonConstStyle = expandPresets(Style); in configurationAsText()
761 FormatTokenLexer(SourceManager &SourceMgr, FileID ID, FormatStyle &Style, in FormatTokenLexer()
784 if (Style.Language == FormatStyle::LK_JavaScript) in lex()
804 if (Style.Language == FormatStyle::LK_JavaScript) { in tryMergePreviousTokens()
1276 if (Style.Language == FormatStyle::LK_Java && in getNextToken()
1280 } else if (Style.Language == FormatStyle::LK_JavaScript && in getNextToken()
1320 if (Style.Language == FormatStyle::LK_Cpp) { in getNextToken()
1347 FormatStyle &Style;
1372 } else if (Style.Language == FormatStyle::LK_JavaScript && in readRawToken()
1401 static StringRef getLanguageName(FormatStyle::LanguageKind Language) { in getLanguageName()
1403 case FormatStyle::LK_Cpp: in getLanguageName()
1405 case FormatStyle::LK_Java: in getLanguageName()
1407 case FormatStyle::LK_JavaScript: in getLanguageName()
1409 case FormatStyle::LK_Proto: in getLanguageName()
1418 Formatter(const FormatStyle &Style, SourceManager &SourceMgr, FileID ID, in Formatter()
1685 ? FormatStyle::PAS_Left in deriveLocalStyle()
1686 : FormatStyle::PAS_Right; in deriveLocalStyle()
1687 if (Style.Standard == FormatStyle::LS_Auto) in deriveLocalStyle()
1689 ? FormatStyle::LS_Cpp11 in deriveLocalStyle()
1690 : FormatStyle::LS_Cpp03; in deriveLocalStyle()
1704 FormatStyle Style;
1738 static void sortIncludes(const FormatStyle &Style, in sortIncludes()
1792 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code, in sortIncludes()
1876 tooling::Replacements reformat(const FormatStyle &Style, in reformat()
1880 FormatStyle Expanded = expandPresets(Style); in reformat()
1887 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, in reformat()
1914 LangOptions getFormattingLangOpts(const FormatStyle &Style) { in getFormattingLangOpts()
1917 LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; in getFormattingLangOpts()
1918 LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; in getFormattingLangOpts()
1920 bool AlternativeOperators = Style.Language == FormatStyle::LK_Cpp; in getFormattingLangOpts()
1941 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { in getLanguageByFileName()
1943 return FormatStyle::LK_Java; in getLanguageByFileName()
1946 return FormatStyle::LK_JavaScript; in getLanguageByFileName()
1949 return FormatStyle::LK_Proto; in getLanguageByFileName()
1951 return FormatStyle::LK_Cpp; in getLanguageByFileName()
1954 FormatStyle getStyle(StringRef StyleName, StringRef FileName, in getStyle()
1956 FormatStyle Style = getLLVMStyle(); in getStyle()