Home | History | Annotate | Download | only in Format

Lines Matching refs:FormatStyle

36 using clang::format::FormatStyle;
42 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
43 static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) {
44 IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp);
45 IO.enumCase(Value, "Java", FormatStyle::LK_Java);
46 IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript);
47 IO.enumCase(Value, "Proto", FormatStyle::LK_Proto);
51 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> {
52 static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) {
53 IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03);
54 IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03);
55 IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11);
56 IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11);
57 IO.enumCase(Value, "Auto", FormatStyle::LS_Auto);
61 template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> {
62 static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) {
63 IO.enumCase(Value, "Never", FormatStyle::UT_Never);
64 IO.enumCase(Value, "false", FormatStyle::UT_Never);
65 IO.enumCase(Value, "Always", FormatStyle::UT_Always);
66 IO.enumCase(Value, "true", FormatStyle::UT_Always);
67 IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation);
71 template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
72 static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
73 IO.enumCase(Value, "None", FormatStyle::SFS_None);
74 IO.enumCase(Value, "false", FormatStyle::SFS_None);
75 IO.enumCase(Value, "All", FormatStyle::SFS_All);
76 IO.enumCase(Value, "true", FormatStyle::SFS_All);
77 IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline);
78 IO.enumCase(Value, "Empty", FormatStyle::SFS_Empty);
82 template <> struct ScalarEnumerationTraits<FormatStyle::BinaryOperatorStyle> {
83 static void enumeration(IO &IO, FormatStyle::BinaryOperatorStyle &Value) {
84 IO.enumCase(Value, "All", FormatStyle::BOS_All);
85 IO.enumCase(Value, "true", FormatStyle::BOS_All);
86 IO.enumCase(Value, "None", FormatStyle::BOS_None);
87 IO.enumCase(Value, "false", FormatStyle::BOS_None);
88 IO.enumCase(Value, "NonAssignment", FormatStyle::BOS_NonAssignment);
92 template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> {
93 static void enumeration(IO &IO, FormatStyle::BraceBreakingStyle &Value) {
94 IO.enumCase(Value, "Attach", FormatStyle::BS_Attach);
95 IO.enumCase(Value, "Linux", FormatStyle::BS_Linux);
96 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup);
97 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman);
98 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU);
103 struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> {
105 FormatStyle::NamespaceIndentationKind &Value) {
106 IO.enumCase(Value, "None", FormatStyle::NI_None);
107 IO.enumCase(Value, "Inner", FormatStyle::NI_Inner);
108 IO.enumCase(Value, "All", FormatStyle::NI_All);
112 template <> struct ScalarEnumerationTraits<FormatStyle::PointerAlignmentStyle> {
113 static void enumeration(IO &IO, FormatStyle::PointerAlignmentStyle &Value) {
114 IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle);
115 IO.enumCase(Value, "Left", FormatStyle::PAS_Left);
116 IO.enumCase(Value, "Right", FormatStyle::PAS_Right);
119 IO.enumCase(Value, "true", FormatStyle::PAS_Left);
120 IO.enumCase(Value, "false", FormatStyle::PAS_Right);
125 struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensOptions> {
127 FormatStyle::SpaceBeforeParensOptions &Value) {
128 IO.enumCase(Value, "Never", FormatStyle::SBPO_Never);
130 FormatStyle::SBPO_ControlStatements);
131 IO.enumCase(Value, "Always", FormatStyle::SBPO_Always);
134 IO.enumCase(Value, "false", FormatStyle::SBPO_Never);
135 IO.enumCase(Value, "true", FormatStyle::SBPO_ControlStatements);
139 template <> struct MappingTraits<FormatStyle> {
140 static void mapping(IO &IO, FormatStyle &Style) {
150 FormatStyle PredefinedStyle;
161 FormatStyle::LanguageKind OldLanguage = Style.Language;
162 FormatStyle::LanguageKind Language =
163 ((FormatStyle *)IO.getContext())->Language;
269 // Allows to read vector<FormatStyle> while keeping default values.
270 // IO.getContext() should contain a pointer to the FormatStyle structure, that
274 template <> struct DocumentListTraits<std::vector<FormatStyle>> {
275 static size_t size(IO &IO, std::vector<FormatStyle> &Seq) {
278 static FormatStyle &element(IO &IO, std::vector<FormatStyle> &Seq,
282 FormatStyle Template;
283 if (Seq.size() > 0 && Seq[0].Language == FormatStyle::LK_None) {
286 Template = *((const FormatStyle *)IO.getContext());
287 Template.Language = FormatStyle::LK_None;
324 FormatStyle getLLVMStyle() {
325 FormatStyle LLVMStyle;
326 LLVMStyle.Language = FormatStyle::LK_Cpp;
333 LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
343 LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
345 LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
364 LLVMStyle.NamespaceIndentation = FormatStyle::NI_None;
368 LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
370 LLVMStyle.Standard = FormatStyle::LS_Cpp11;
371 LLVMStyle.UseTab = FormatStyle::UT_Never;
378 FormatStyle::SBPO_ControlStatements;
394 FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
395 FormatStyle GoogleStyle = getLLVMStyle();
410 GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
412 GoogleStyle.Standard = FormatStyle::LS_Auto;
417 if (Language == FormatStyle::LK_Java) {
421 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
424 GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
428 } else if (Language == FormatStyle::LK_JavaScript) {
432 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
434 } else if (Language == FormatStyle::LK_Proto) {
435 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
442 FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
443 FormatStyle ChromiumStyle = getGoogleStyle(Language);
444 if (Language == FormatStyle::LK_Java) {
450 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
459 FormatStyle getMozillaStyle() {
460 FormatStyle MozillaStyle = getLLVMStyle();
469 MozillaStyle.PointerAlignment = FormatStyle::PAS_Left;
470 MozillaStyle.Standard = FormatStyle::LS_Cpp03;
474 FormatStyle getWebKitStyle() {
475 FormatStyle Style = getLLVMStyle();
480 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
481 Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
486 Style.NamespaceIndentation = FormatStyle::NI_Inner;
489 Style.PointerAlignment = FormatStyle::PAS_Left;
490 Style.Standard = FormatStyle::LS_Cpp03;
494 FormatStyle getGNUStyle() {
495 FormatStyle Style = getLLVMStyle();
497 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
498 Style.BreakBeforeBraces = FormatStyle::BS_GNU;
502 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
503 Style.Standard = FormatStyle::LS_Cpp03;
507 FormatStyle getNoStyle() {
508 FormatStyle NoStyle = getLLVMStyle();
513 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
514 FormatStyle *Style) {
537 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
539 FormatStyle::LanguageKind Language = Style->Language;
540 assert(Language != FormatStyle::LK_None);
544 std::vector<FormatStyle> Styles;
546 // DocumentListTraits<vector<FormatStyle>> uses the context to get default
557 if (Styles[i].Language == FormatStyle::LK_None && i != 0)
574 Styles[i].Language == FormatStyle::LK_None) {
583 std::string configurationAsText(const FormatStyle &Style) {
589 FormatStyle NonConstStyle = Style;
598 FormatTokenLexer(SourceManager &SourceMgr, FileID ID, FormatStyle &Style,
637 if (Style.Language == FormatStyle::LK_JavaScript) {
1066 if (Style.Language == FormatStyle::LK_Java &&
1121 FormatStyle &Style;
1143 } else if (Style.Language == FormatStyle::LK_JavaScript &&
1171 static StringRef getLanguageName(FormatStyle::LanguageKind Language) {
1173 case FormatStyle::LK_Cpp:
1175 case FormatStyle::LK_Java:
1177 case FormatStyle::LK_JavaScript:
1179 case FormatStyle::LK_Proto:
1188 Formatter(const FormatStyle &Style, SourceManager &SourceMgr, FileID ID,
1438 Style.PointerAlignment = FormatStyle::PAS_Left;
1440 Style.PointerAlignment = FormatStyle::PAS_Right;
1442 if (Style.Standard == FormatStyle::LS_Auto) {
1443 Style.Standard = HasCpp03IncompatibleFormat ? FormatStyle::LS_Cpp11
1444 : FormatStyle::LS_Cpp03;
1459 FormatStyle Style;
1472 tooling::Replacements reformat(const FormatStyle &Style, Lexer &Lex,
1481 tooling::Replacements reformat(const FormatStyle &Style,
1490 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
1518 LangOptions getFormattingLangOpts(const FormatStyle &Style) {
1521 LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
1522 LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
1524 bool AlternativeOperators = Style.Language == FormatStyle::LK_Cpp;
1544 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
1546 return FormatStyle::LK_Java;
1549 return FormatStyle::LK_JavaScript;
1552 return FormatStyle::LK_Proto;
1554 return FormatStyle::LK_Cpp;
1557 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
1559 FormatStyle Style = getLLVMStyle();