Home | History | Annotate | Download | only in Format

Lines Matching refs:FormatStyle

35 using clang::format::FormatStyle;
41 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
42 static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) {
43 IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp);
44 IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript);
45 IO.enumCase(Value, "Proto", FormatStyle::LK_Proto);
49 template <> struct ScalarEnumerationTraits<FormatStyle::LanguageStandard> {
50 static void enumeration(IO &IO, FormatStyle::LanguageStandard &Value) {
51 IO.enumCase(Value, "Cpp03", FormatStyle::LS_Cpp03);
52 IO.enumCase(Value, "C++03", FormatStyle::LS_Cpp03);
53 IO.enumCase(Value, "Cpp11", FormatStyle::LS_Cpp11);
54 IO.enumCase(Value, "C++11", FormatStyle::LS_Cpp11);
55 IO.enumCase(Value, "Auto", FormatStyle::LS_Auto);
59 template <> struct ScalarEnumerationTraits<FormatStyle::UseTabStyle> {
60 static void enumeration(IO &IO, FormatStyle::UseTabStyle &Value) {
61 IO.enumCase(Value, "Never", FormatStyle::UT_Never);
62 IO.enumCase(Value, "false", FormatStyle::UT_Never);
63 IO.enumCase(Value, "Always", FormatStyle::UT_Always);
64 IO.enumCase(Value, "true", FormatStyle::UT_Always);
65 IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation);
69 template <> struct ScalarEnumerationTraits<FormatStyle::ShortFunctionStyle> {
70 static void enumeration(IO &IO, FormatStyle::ShortFunctionStyle &Value) {
71 IO.enumCase(Value, "None", FormatStyle::SFS_None);
72 IO.enumCase(Value, "false", FormatStyle::SFS_None);
73 IO.enumCase(Value, "All", FormatStyle::SFS_All);
74 IO.enumCase(Value, "true", FormatStyle::SFS_All);
75 IO.enumCase(Value, "Inline", FormatStyle::SFS_Inline);
79 template <> struct ScalarEnumerationTraits<FormatStyle::BraceBreakingStyle> {
80 static void enumeration(IO &IO, FormatStyle::BraceBreakingStyle &Value) {
81 IO.enumCase(Value, "Attach", FormatStyle::BS_Attach);
82 IO.enumCase(Value, "Linux", FormatStyle::BS_Linux);
83 IO.enumCase(Value, "Stroustrup", FormatStyle::BS_Stroustrup);
84 IO.enumCase(Value, "Allman", FormatStyle::BS_Allman);
85 IO.enumCase(Value, "GNU", FormatStyle::BS_GNU);
90 struct ScalarEnumerationTraits<FormatStyle::NamespaceIndentationKind> {
92 FormatStyle::NamespaceIndentationKind &Value) {
93 IO.enumCase(Value, "None", FormatStyle::NI_None);
94 IO.enumCase(Value, "Inner", FormatStyle::NI_Inner);
95 IO.enumCase(Value, "All", FormatStyle::NI_All);
100 struct ScalarEnumerationTraits<FormatStyle::PointerAlignmentStyle> {
102 FormatStyle::PointerAlignmentStyle &Value) {
103 IO.enumCase(Value, "Middle", FormatStyle::PAS_Middle);
104 IO.enumCase(Value, "Left", FormatStyle::PAS_Left);
105 IO.enumCase(Value, "Right", FormatStyle::PAS_Right);
108 IO.enumCase(Value, "true", FormatStyle::PAS_Left);
109 IO.enumCase(Value, "false", FormatStyle::PAS_Right);
114 struct ScalarEnumerationTraits<FormatStyle::SpaceBeforeParensOptions> {
116 FormatStyle::SpaceBeforeParensOptions &Value) {
117 IO.enumCase(Value, "Never", FormatStyle::SBPO_Never);
119 FormatStyle::SBPO_ControlStatements);
120 IO.enumCase(Value, "Always", FormatStyle::SBPO_Always);
123 IO.enumCase(Value, "false", FormatStyle::SBPO_Never);
124 IO.enumCase(Value, "true", FormatStyle::SBPO_ControlStatements);
128 template <> struct MappingTraits<FormatStyle> {
129 static void mapping(IO &IO, FormatStyle &Style) {
139 FormatStyle PredefinedStyle;
150 FormatStyle::LanguageKind OldLanguage = Style.Language;
151 FormatStyle::LanguageKind Language =
152 ((FormatStyle *)IO.getContext())->Language;
248 // Allows to read vector<FormatStyle> while keeping default values.
249 // IO.getContext() should contain a pointer to the FormatStyle structure, that
253 template <> struct DocumentListTraits<std::vector<FormatStyle> > {
254 static size_t size(IO &IO, std::vector<FormatStyle> &Seq) {
257 static FormatStyle &element(IO &IO, std::vector<FormatStyle> &Seq,
261 FormatStyle Template;
262 if (Seq.size() > 0 && Seq[0].Language == FormatStyle::LK_None) {
265 Template = *((const FormatStyle *)IO.getContext());
266 Template.Language = FormatStyle::LK_None;
303 FormatStyle getLLVMStyle() {
304 FormatStyle LLVMStyle;
305 LLVMStyle.Language = FormatStyle::LK_Cpp;
310 LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
319 LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
338 LLVMStyle.NamespaceIndentation = FormatStyle::NI_None;
341 LLVMStyle.PointerAlignment = FormatStyle::PAS_Right;
343 LLVMStyle.Standard = FormatStyle::LS_Cpp11;
344 LLVMStyle.UseTab = FormatStyle::UT_Never;
349 LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
365 FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
366 FormatStyle GoogleStyle = getLLVMStyle();
381 GoogleStyle.PointerAlignment = FormatStyle::PAS_Left;
383 GoogleStyle.Standard = FormatStyle::LS_Auto;
388 if (Language == FormatStyle::LK_JavaScript) {
392 } else if (Language == FormatStyle::LK_Proto) {
393 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
400 FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
401 FormatStyle ChromiumStyle = getGoogleStyle(Language);
403 ChromiumStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
408 ChromiumStyle.Standard = FormatStyle::LS_Cpp03;
412 FormatStyle getMozillaStyle() {
413 FormatStyle MozillaStyle = getLLVMStyle();
422 MozillaStyle.PointerAlignment = FormatStyle::PAS_Left;
423 MozillaStyle.Standard = FormatStyle::LS_Cpp03;
427 FormatStyle getWebKitStyle() {
428 FormatStyle Style = getLLVMStyle();
432 Style.BreakBeforeBraces = FormatStyle::BS_Stroustrup;
437 Style.NamespaceIndentation = FormatStyle::NI_Inner;
439 Style.PointerAlignment = FormatStyle::PAS_Left;
440 Style.Standard = FormatStyle::LS_Cpp03;
444 FormatStyle getGNUStyle() {
445 FormatStyle Style = getLLVMStyle();
447 Style.BreakBeforeBraces = FormatStyle::BS_GNU;
451 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
452 Style.Standard = FormatStyle::LS_Cpp03;
456 FormatStyle getNoStyle() {
457 FormatStyle NoStyle = getLLVMStyle();
462 bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
463 FormatStyle *Style) {
486 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
488 FormatStyle::LanguageKind Language = Style->Language;
489 assert(Language != FormatStyle::LK_None);
493 std::vector<FormatStyle> Styles;
495 // DocumentListTraits<vector<FormatStyle>> uses the context to get default
506 if (Styles[i].Language == FormatStyle::LK_None && i != 0)
523 Styles[i].Language == FormatStyle::LK_None) {
532 std::string configurationAsText(const FormatStyle &Style) {
538 FormatStyle NonConstStyle = Style;
568 LineJoiner(const FormatStyle &Style) : Style(Style) {}
597 Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All ||
598 (Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Inline &&
606 return Style.BreakBeforeBraces == FormatStyle::BS_Attach
611 Style.BreakBeforeBraces != FormatStyle::BS_Attach) {
665 if ((Style.BreakBeforeBraces == FormatStyle::BS_Allman ||
666 Style.BreakBeforeBraces == FormatStyle::BS_GNU) &&
788 const FormatStyle &Style;
795 const FormatStyle &Style)
1254 FormatStyle Style;
1268 FormatTokenLexer(Lexer &Lex, SourceManager &SourceMgr, FormatStyle &Style,
1302 if (Style.Language == FormatStyle::LK_JavaScript) {
1638 FormatStyle &Style;
1657 } else if (Style.Language == FormatStyle::LK_JavaScript &&
1665 static StringRef getLanguageName(FormatStyle::LanguageKind Language) {
1667 case FormatStyle::LK_Cpp:
1669 case FormatStyle::LK_JavaScript:
1671 case FormatStyle::LK_Proto:
1680 Formatter(const FormatStyle &Style, Lexer &Lex, SourceManager &SourceMgr,
1928 Style.PointerAlignment = FormatStyle::PAS_Left;
1930 Style.PointerAlignment = FormatStyle::PAS_Right;
1932 if (Style.Standard == FormatStyle::LS_Auto) {
1933 Style.Standard = HasCpp03IncompatibleFormat ? FormatStyle::LS_Cpp11
1934 : FormatStyle::LS_Cpp03;
1949 FormatStyle Style;
1962 tooling::Replacements reformat(const FormatStyle &Style, Lexer &Lex,
1974 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
2000 LangOptions getFormattingLangOpts(FormatStyle::LanguageStandard Standard) {
2003 LangOpts.CPlusPlus11 = Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
2004 LangOpts.CPlusPlus1y = Standard == FormatStyle::LS_Cpp03 ? 0 : 1;
2024 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
2026 return FormatStyle::LK_JavaScript;
2029 return FormatStyle::LK_Proto;
2031 return FormatStyle::LK_Cpp;
2034 FormatStyle getStyle(StringRef StyleName, StringRef FileName,
2036 FormatStyle Style = getLLVMStyle();