Lines Matching defs:Style
809 static void mapping(IO &IO, FormatStyle &Style) {
811 IO.mapOptional("Language", Style.Language);
819 if (getPredefinedStyle(StyleName, Style.Language, &PredefinedStyle) &&
820 Style == PredefinedStyle) {
828 FormatStyle::LanguageKind OldLanguage = Style.Language;
831 if (!getPredefinedStyle(BasedOnStyle, Language, &Style)) {
835 Style.Language = OldLanguage;
868 IO.mapOptional("AlignEscapedNewlinesLeft", Style.AlignEscapedNewlines);
870 IO.mapOptional("AlwaysBreakAfterReturnType", Style.BreakAfterReturnType);
872 Style.BreakTemplateDeclarations);
880 IO.mapOptional("DerivePointerBinding", Style.DerivePointerAlignment);
881 IO.mapOptional("KeepEmptyLinesAtEOF", Style.KeepEmptyLines.AtEndOfFile);
883 Style.KeepEmptyLines.AtStartOfBlock);
885 Style.IndentWrappedFunctionNames);
886 IO.mapOptional("IndentRequires", Style.IndentRequiresClause);
887 IO.mapOptional("PointerBindsToType", Style.PointerAlignment);
889 Style.SpaceBeforeParens);
899 IO.mapOptional("AccessModifierOffset", Style.AccessModifierOffset);
900 IO.mapOptional("AlignAfterOpenBracket", Style.AlignAfterOpenBracket);
901 IO.mapOptional("AlignArrayOfStructures", Style.AlignArrayOfStructures);
903 Style.AlignConsecutiveAssignments);
905 Style.AlignConsecutiveBitFields);
907 Style.AlignConsecutiveDeclarations);
908 IO.mapOptional("AlignConsecutiveMacros", Style.AlignConsecutiveMacros);
910 Style.AlignConsecutiveShortCaseStatements);
912 Style.AlignConsecutiveTableGenBreakingDAGArgColons);
914 Style.AlignConsecutiveTableGenCondOperatorColons);
916 Style.AlignConsecutiveTableGenDefinitionColons);
917 IO.mapOptional("AlignEscapedNewlines", Style.AlignEscapedNewlines);
918 IO.mapOptional("AlignOperands", Style.AlignOperands);
919 IO.mapOptional("AlignTrailingComments", Style.AlignTrailingComments);
921 Style.AllowAllArgumentsOnNextLine);
923 Style.AllowAllParametersOfDeclarationOnNextLine);
925 Style.AllowBreakBeforeNoexceptSpecifier);
927 Style.AllowShortBlocksOnASingleLine);
929 Style.AllowShortCaseExpressionOnASingleLine);
931 Style.AllowShortCaseLabelsOnASingleLine);
933 Style.AllowShortCompoundRequirementOnASingleLine);
935 Style.AllowShortEnumsOnASingleLine);
937 Style.AllowShortFunctionsOnASingleLine);
939 Style.AllowShortIfStatementsOnASingleLine);
941 Style.AllowShortLambdasOnASingleLine);
943 Style.AllowShortLoopsOnASingleLine);
945 Style.AlwaysBreakAfterDefinitionReturnType);
947 Style.AlwaysBreakBeforeMultilineStrings);
948 IO.mapOptional("AttributeMacros", Style.AttributeMacros);
949 IO.mapOptional("BinPackArguments", Style.BinPackArguments);
950 IO.mapOptional("BinPackParameters", Style.BinPackParameters);
951 IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing);
953 Style.BracedInitializerIndentWidth);
954 IO.mapOptional("BraceWrapping", Style.BraceWrapping);
956 Style.BreakAdjacentStringLiterals);
957 IO.mapOptional("BreakAfterAttributes", Style.BreakAfterAttributes);
959 Style.BreakAfterJavaFieldAnnotations);
960 IO.mapOptional("BreakAfterReturnType", Style.BreakAfterReturnType);
961 IO.mapOptional("BreakArrays", Style.BreakArrays);
963 Style.BreakBeforeBinaryOperators);
965 Style.BreakBeforeConceptDeclarations);
966 IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);
968 Style.BreakBeforeInlineASMColon);
970 Style.BreakBeforeTernaryOperators);
972 Style.BreakConstructorInitializers);
974 Style.BreakFunctionDefinitionParameters);
975 IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList);
976 IO.mapOptional("BreakStringLiterals", Style.BreakStringLiterals);
978 Style.BreakTemplateDeclarations);
979 IO.mapOptional("ColumnLimit", Style.ColumnLimit);
980 IO.mapOptional("CommentPragmas", Style.CommentPragmas);
981 IO.mapOptional("CompactNamespaces", Style.CompactNamespaces);
983 Style.ConstructorInitializerIndentWidth);
984 IO.mapOptional("ContinuationIndentWidth", Style.ContinuationIndentWidth);
985 IO.mapOptional("Cpp11BracedListStyle", Style.Cpp11BracedListStyle);
986 IO.mapOptional("DerivePointerAlignment", Style.DerivePointerAlignment);
987 IO.mapOptional("DisableFormat", Style.DisableFormat);
989 Style.EmptyLineAfterAccessModifier);
991 Style.EmptyLineBeforeAccessModifier);
993 Style.ExperimentalAutoDetectBinPacking);
994 IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
995 IO.mapOptional("ForEachMacros", Style.ForEachMacros);
996 IO.mapOptional("IfMacros", Style.IfMacros);
997 IO.mapOptional("IncludeBlocks", Style.IncludeStyle.IncludeBlocks);
998 IO.mapOptional("IncludeCategories", Style.IncludeStyle.IncludeCategories);
999 IO.mapOptional("IncludeIsMainRegex", Style.IncludeStyle.IncludeIsMainRegex);
1001 Style.IncludeStyle.IncludeIsMainSourceRegex);
1002 IO.mapOptional("IndentAccessModifiers", Style.IndentAccessModifiers);
1003 IO.mapOptional("IndentCaseBlocks", Style.IndentCaseBlocks);
1004 IO.mapOptional("IndentCaseLabels", Style.IndentCaseLabels);
1005 IO.mapOptional("IndentExternBlock", Style.IndentExternBlock);
1006 IO.mapOptional("IndentGotoLabels", Style.IndentGotoLabels);
1007 IO.mapOptional("IndentPPDirectives", Style.IndentPPDirectives);
1008 IO.mapOptional("IndentRequiresClause", Style.IndentRequiresClause);
1009 IO.mapOptional("IndentWidth", Style.IndentWidth);
1011 Style.IndentWrappedFunctionNames);
1012 IO.mapOptional("InsertBraces", Style.InsertBraces);
1013 IO.mapOptional("InsertNewlineAtEOF", Style.InsertNewlineAtEOF);
1014 IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
1015 IO.mapOptional("IntegerLiteralSeparator", Style.IntegerLiteralSeparator);
1016 IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
1017 IO.mapOptional("JavaScriptQuotes", Style.JavaScriptQuotes);
1018 IO.mapOptional("JavaScriptWrapImports", Style.JavaScriptWrapImports);
1019 IO.mapOptional("KeepEmptyLines", Style.KeepEmptyLines);
1020 IO.mapOptional("LambdaBodyIndentation", Style.LambdaBodyIndentation);
1021 IO.mapOptional("LineEnding", Style.LineEnding);
1022 IO.mapOptional("MacroBlockBegin", Style.MacroBlockBegin);
1023 IO.mapOptional("MacroBlockEnd", Style.MacroBlockEnd);
1024 IO.mapOptional("Macros", Style.Macros);
1025 IO.mapOptional("MainIncludeChar", Style.IncludeStyle.MainIncludeChar);
1026 IO.mapOptional("MaxEmptyLinesToKeep", Style.MaxEmptyLinesToKeep);
1027 IO.mapOptional("NamespaceIndentation", Style.NamespaceIndentation);
1028 IO.mapOptional("NamespaceMacros", Style.NamespaceMacros);
1029 IO.mapOptional("ObjCBinPackProtocolList", Style.ObjCBinPackProtocolList);
1030 IO.mapOptional("ObjCBlockIndentWidth", Style.ObjCBlockIndentWidth);
1032 Style.ObjCBreakBeforeNestedBlockParam);
1034 Style.ObjCPropertyAttributeOrder);
1035 IO.mapOptional("ObjCSpaceAfterProperty", Style.ObjCSpaceAfterProperty);
1037 Style.ObjCSpaceBeforeProtocolList);
1039 Style.PackConstructorInitializers);
1040 IO.mapOptional("PenaltyBreakAssignment", Style.PenaltyBreakAssignment);
1042 Style.PenaltyBreakBeforeFirstCallParameter);
1043 IO.mapOptional("PenaltyBreakComment", Style.PenaltyBreakComment);
1045 Style.PenaltyBreakFirstLessLess);
1047 Style.PenaltyBreakOpenParenthesis);
1049 Style.PenaltyBreakScopeResolution);
1050 IO.mapOptional("PenaltyBreakString", Style.PenaltyBreakString);
1052 Style.PenaltyBreakTemplateDeclaration);
1053 IO.mapOptional("PenaltyExcessCharacter", Style.PenaltyExcessCharacter);
1055 Style.PenaltyIndentedWhitespace);
1057 Style.PenaltyReturnTypeOnItsOwnLine);
1058 IO.mapOptional("PointerAlignment", Style.PointerAlignment);
1059 IO.mapOptional("PPIndentWidth", Style.PPIndentWidth);
1060 IO.mapOptional("QualifierAlignment", Style.QualifierAlignment);
1062 if (Style.QualifierAlignment == FormatStyle::QAS_Right)
1063 Style.QualifierOrder = {"type", "const", "volatile"};
1064 else if (Style.QualifierAlignment == FormatStyle::QAS_Left)
1065 Style.QualifierOrder = {"const", "volatile", "type"};
1066 else if (Style.QualifierAlignment == FormatStyle::QAS_Custom)
1067 IO.mapOptional("QualifierOrder", Style.QualifierOrder);
1068 IO.mapOptional("RawStringFormats", Style.RawStringFormats);
1069 IO.mapOptional("ReferenceAlignment", Style.ReferenceAlignment);
1070 IO.mapOptional("ReflowComments", Style.ReflowComments);
1071 IO.mapOptional("RemoveBracesLLVM", Style.RemoveBracesLLVM);
1072 IO.mapOptional("RemoveParentheses", Style.RemoveParentheses);
1073 IO.mapOptional("RemoveSemicolon", Style.RemoveSemicolon);
1074 IO.mapOptional("RequiresClausePosition", Style.RequiresClausePosition);
1076 Style.RequiresExpressionIndentation);
1077 IO.mapOptional("SeparateDefinitionBlocks", Style.SeparateDefinitionBlocks);
1078 IO.mapOptional("ShortNamespaceLines", Style.ShortNamespaceLines);
1079 IO.mapOptional("SkipMacroDefinitionBody", Style.SkipMacroDefinitionBody);
1080 IO.mapOptional("SortIncludes", Style.SortIncludes);
1081 IO.mapOptional("SortJavaStaticImport", Style.SortJavaStaticImport);
1082 IO.mapOptional("SortUsingDeclarations", Style.SortUsingDeclarations);
1083 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
1084 IO.mapOptional("SpaceAfterLogicalNot", Style.SpaceAfterLogicalNot);
1086 Style.SpaceAfterTemplateKeyword);
1088 Style.SpaceAroundPointerQualifiers);
1090 Style.SpaceBeforeAssignmentOperators);
1091 IO.mapOptional("SpaceBeforeCaseColon", Style.SpaceBeforeCaseColon);
1093 Style.SpaceBeforeCpp11BracedList);
1095 Style.SpaceBeforeCtorInitializerColon);
1097 Style.SpaceBeforeInheritanceColon);
1098 IO.mapOptional("SpaceBeforeJsonColon", Style.SpaceBeforeJsonColon);
1099 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
1100 IO.mapOptional("SpaceBeforeParensOptions", Style.SpaceBeforeParensOptions);
1102 Style.SpaceBeforeRangeBasedForLoopColon);
1104 Style.SpaceBeforeSquareBrackets);
1105 IO.mapOptional("SpaceInEmptyBlock", Style.SpaceInEmptyBlock);
1107 Style.SpacesBeforeTrailingComments);
1108 IO.mapOptional("SpacesInAngles", Style.SpacesInAngles);
1110 Style.SpacesInContainerLiterals);
1112 Style.SpacesInLineCommentPrefix);
1113 IO.mapOptional("SpacesInParens", Style.SpacesInParens);
1114 IO.mapOptional("SpacesInParensOptions", Style.SpacesInParensOptions);
1115 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
1116 IO.mapOptional("Standard", Style.Standard);
1118 Style.StatementAttributeLikeMacros);
1119 IO.mapOptional("StatementMacros", Style.StatementMacros);
1121 Style.TableGenBreakingDAGArgOperators);
1123 Style.TableGenBreakInsideDAGArg);
1124 IO.mapOptional("TabWidth", Style.TabWidth);
1125 IO.mapOptional("TypeNames", Style.TypeNames);
1126 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
1127 IO.mapOptional("UseTab", Style.UseTab);
1129 Style.VerilogBreakBetweenInstancePorts);
1131 Style.WhitespaceSensitiveMacros);
1136 if (Style.AlwaysBreakAfterDefinitionReturnType != FormatStyle::DRTBS_None &&
1137 Style.BreakAfterReturnType == FormatStyle::RTBS_None) {
1138 if (Style.AlwaysBreakAfterDefinitionReturnType ==
1140 Style.BreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
1141 } else if (Style.AlwaysBreakAfterDefinitionReturnType ==
1143 Style.BreakAfterReturnType = FormatStyle::RTBS_TopLevelDefinitions;
1150 Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon) {
1151 Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
1158 Style.BreakConstructorInitializers == FormatStyle::BCIS_BeforeColon) {
1159 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
1163 if (Style.PackConstructorInitializers == FormatStyle::PCIS_BinPack &&
1165 Style.PackConstructorInitializers = OnNextLine
1169 } else if (Style.PackConstructorInitializers ==
1172 Style.PackConstructorInitializers = FormatStyle::PCIS_BinPack;
1174 Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
1177 if (Style.LineEnding == FormatStyle::LE_DeriveLF) {
1179 Style.LineEnding = UseCRLF ? FormatStyle::LE_CRLF : FormatStyle::LE_LF;
1181 Style.LineEnding = FormatStyle::LE_DeriveCRLF;
1184 if (Style.SpacesInParens != FormatStyle::SIPO_Custom &&
1189 Style.SpacesInParensOptions.ExceptDoubleParentheses = false;
1190 Style.SpacesInParensOptions.InConditionalStatements = true;
1191 Style.SpacesInParensOptions.InCStyleCasts =
1193 Style.SpacesInParensOptions.InEmptyParentheses =
1195 Style.SpacesInParensOptions.Other = true;
1197 Style.SpacesInParensOptions = {};
1198 Style.SpacesInParensOptions.InConditionalStatements =
1200 Style.SpacesInParensOptions.InCStyleCasts =
1202 Style.SpacesInParensOptions.InEmptyParentheses =
1205 Style.SpacesInParens = FormatStyle::SIPO_Custom;
1861 FormatStyle Style = getLLVMStyle();
1862 Style.AccessModifierOffset = -4;
1863 Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
1864 Style.AlignOperands = FormatStyle::OAS_DontAlign;
1865 Style.AlignTrailingComments = {};
1866 Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
1867 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
1868 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
1869 Style.BreakBeforeBraces = FormatStyle::BS_WebKit;
1870 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
1871 Style.ColumnLimit = 0;
1872 Style.Cpp11BracedListStyle = false;
1873 Style.FixNamespaceComments = false;
1874 Style.IndentWidth = 4;
1875 Style.NamespaceIndentation = FormatStyle::NI_Inner;
1876 Style.ObjCBlockIndentWidth = 4;
1877 Style.ObjCSpaceAfterProperty = true;
1878 Style.PointerAlignment = FormatStyle::PAS_Left;
1879 Style.SpaceBeforeCpp11BracedList = true;
1880 Style.SpaceInEmptyBlock = true;
1881 return Style;
1885 FormatStyle Style = getLLVMStyle();
1886 Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
1887 Style.BreakAfterReturnType = FormatStyle::RTBS_AllDefinitions;
1888 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
1889 Style.BreakBeforeBraces = FormatStyle::BS_GNU;
1890 Style.BreakBeforeTernaryOperators = true;
1891 Style.ColumnLimit = 79;
1892 Style.Cpp11BracedListStyle = false;
1893 Style.FixNamespaceComments = false;
1894 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
1895 Style.Standard = FormatStyle::LS_Cpp03;
1896 return Style;
1900 FormatStyle Style = getLLVMStyle(Language);
1901 Style.ColumnLimit = 120;
1902 Style.TabWidth = 4;
1903 Style.IndentWidth = 4;
1904 Style.UseTab = FormatStyle::UT_Never;
1905 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
1906 Style.BraceWrapping.AfterClass = true;
1907 Style.BraceWrapping.AfterControlStatement = FormatStyle::BWACS_Always;
1908 Style.BraceWrapping.AfterEnum = true;
1909 Style.BraceWrapping.AfterFunction = true;
1910 Style.BraceWrapping.AfterNamespace = true;
1911 Style.BraceWrapping.AfterObjCDeclaration = true;
1912 Style.BraceWrapping.AfterStruct = true;
1913 Style.BraceWrapping.AfterExternBlock = true;
1914 Style.BraceWrapping.BeforeCatch = true;
1915 Style.BraceWrapping.BeforeElse = true;
1916 Style.BraceWrapping.BeforeWhile = false;
1917 Style.PenaltyReturnTypeOnItsOwnLine = 1000;
1918 Style.AllowShortEnumsOnASingleLine = false;
1919 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
1920 Style.AllowShortCaseLabelsOnASingleLine = false;
1921 Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
1922 Style.AllowShortLoopsOnASingleLine = false;
1923 Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
1924 Style.BreakAfterReturnType = FormatStyle::RTBS_None;
1925 return Style;
1929 FormatStyle Style = getLLVMStyle();
1930 Style.InsertBraces = true;
1931 Style.InsertNewlineAtEOF = true;
1932 Style.IntegerLiteralSeparator.Decimal = 3;
1933 Style.IntegerLiteralSeparator.DecimalMinDigits = 5;
1934 Style.LineEnding = FormatStyle::LE_LF;
1935 Style.RemoveBracesLLVM = true;
1936 Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
1937 Style.RemoveSemicolon = true;
1938 return Style;
1950 FormatStyle *Style) {
1952 *Style = getLLVMStyle(Language);
1954 *Style = getChromiumStyle(Language);
1956 *Style = getMozillaStyle();
1958 *Style = getGoogleStyle(Language);
1960 *Style = getWebKitStyle();
1962 *Style = getGNUStyle();
1964 *Style = getMicrosoftStyle(Language);
1966 *Style = getClangFormatStyle();
1968 *Style = getNoStyle();
1970 Style->InheritsParentConfig = true;
1974 Style->Language = Language;
1978 ParseError validateQualifierOrder(FormatStyle *Style) {
1980 if (Style->QualifierOrder.empty())
1984 for (const auto &Qualifier : Style->QualifierOrder) {
1994 std::set<std::string> UniqueQualifiers(Style->QualifierOrder.begin(),
1995 Style->QualifierOrder.end());
1996 if (Style->QualifierOrder.size() != UniqueQualifiers.size()) {
1998 << "Duplicate Qualifiers " << Style->QualifierOrder.size()
2004 if (!llvm::is_contained(Style->QualifierOrder, "type"))
2011 FormatStyle *Style, bool AllowUnknownOptions,
2014 assert(Style);
2015 FormatStyle::LanguageKind Language = Style->Language;
2019 Style->StyleSet.Clear();
2027 Input.setContext(Style);
2052 for (const FormatStyle &Style : llvm::reverse(Styles)) {
2053 if (Style.Language != FormatStyle::LK_None)
2054 StyleSet.Add(Style);
2055 if (Style.Language == Language)
2065 *Style = *StyleSet.Get(Language);
2066 if (Style->InsertTrailingCommas != FormatStyle::TCS_None &&
2067 Style->BinPackArguments) {
2071 if (Style->QualifierAlignment != FormatStyle::QAS_Leave)
2072 return make_error_code(validateQualifierOrder(Style));
2076 std::string configurationAsText(const FormatStyle &Style) {
2082 FormatStyle NonConstStyle = Style;
2098 FormatStyle Style = It->second;
2099 Style.StyleSet = *this;
2100 return Style;
2103 void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
2104 assert(Style.Language != LK_None &&
2107 !Style.StyleSet.Styles &&
2111 (*Styles)[Style.Language] = std::move(Style);
2125 ParensRemover(const Environment &Env, const FormatStyle &Style)
2126 : TokenAnalyzer(Env, Style) {}
2169 BracesInserter(const Environment &Env, const FormatStyle &Style)
2170 : TokenAnalyzer(Env, Style) {}
2222 BracesRemover(const Environment &Env, const FormatStyle &Style)
2223 : TokenAnalyzer(Env, Style) {}
2273 SemiRemover(const Environment &Env, const FormatStyle &Style)
2274 : TokenAnalyzer(Env, Style) {}
2333 JavaScriptRequoter(const Environment &Env, const FormatStyle &Style)
2334 : TokenAnalyzer(Env, Style) {}
2361 (Style.JavaScriptQuotes == FormatStyle::JSQS_Single &&
2363 (Style.JavaScriptQuotes == FormatStyle::JSQS_Double &&
2369 bool IsSingle = Style.JavaScriptQuotes == FormatStyle::JSQS_Single;
2421 Formatter(const Environment &Env, const FormatStyle &Style,
2423 : TokenAnalyzer(Env, Style), Status(Status) {}
2437 Env.getSourceManager(), Style,
2438 Style.LineEnding > FormatStyle::LE_CRLF
2441 Style.LineEnding == FormatStyle::LE_DeriveCRLF)
2442 : Style.LineEnding == FormatStyle::LE_CRLF);
2443 ContinuationIndenter Indenter(Style, Tokens.getKeywords(),
2447 UnwrappedLineFormatter(&Indenter, &Whitespaces, Style,
2529 if (Style.DerivePointerAlignment) {
2532 Style.PointerAlignment = FormatStyle::PAS_Right;
2534 Style.PointerAlignment = FormatStyle::PAS_Left;
2535 Style.ReferenceAlignment = FormatStyle::RAS_Pointer;
2537 if (Style.Standard == FormatStyle::LS_Auto) {
2538 Style.Standard = hasCpp03IncompatibleFormat(AnnotatedLines)
2563 TrailingCommaInserter(const Environment &Env, const FormatStyle &Style)
2564 : TokenAnalyzer(Env, Style) {}
2609 if (ColumnNumber > Style.ColumnLimit)
2624 Cleaner(const Environment &Env, const FormatStyle &Style)
2625 : TokenAnalyzer(Env, Style),
2699 if (Style.BraceWrapping.AfterNamespace) {
2847 ObjCHeaderStyleGuesser(const Environment &Env, const FormatStyle &Style)
2848 : TokenAnalyzer(Env, Style), IsObjC(false) {}
2854 assert(Style.Language == FormatStyle::LK_Cpp);
3075 static void sortCppIncludes(const FormatStyle &Style,
3080 tooling::IncludeCategoryManager Categories(Style.IncludeStyle, FileName);
3090 if (Style.SortIncludes == FormatStyle::SI_CaseInsensitive) {
3128 // In case Style.IncldueStyle.IncludeBlocks != IBS_Preserve, this check is not
3133 Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Preserve) {
3142 if (Style.IncludeStyle.IncludeBlocks ==
3176 tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
3195 tooling::IncludeCategoryManager Categories(Style.IncludeStyle, FileName);
3238 (Style.IncludeStyle.IncludeBlocks == tooling::IncludeStyle::IBS_Merge ||
3239 Style.IncludeStyle.IncludeBlocks ==
3266 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
3283 sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code, Replaces,
3291 static unsigned findJavaImportGroup(const FormatStyle &Style,
3295 for (unsigned I = 0; I < Style.JavaImportGroups.size(); I++) {
3296 const std::string &GroupPrefix = Style.JavaImportGroups[I];
3311 static void sortJavaImports(const FormatStyle &Style,
3327 JavaImportGroups.push_back(findJavaImportGroup(Style, Import.Identifier));
3330 Style.SortJavaStaticImport == FormatStyle::SJSIO_After;
3393 tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code,
3441 sortJavaImports(Style, ImportsInBlock, Ranges, FileName, Code, Replaces);
3454 tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
3458 if (!Style.SortIncludes || Style.DisableFormat)
3462 if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript &&
3466 if (Style.Language == FormatStyle::LanguageKind::LK_JavaScript)
3467 return sortJavaScriptImports(Style, Code, Ranges, FileName);
3468 if (Style.Language == FormatStyle::LanguageKind::LK_Java)
3469 return sortJavaImports(Style, Code, Ranges, FileName, Replaces);
3470 sortCppIncludes(Style, Code, Ranges, FileName, Replaces, Cursor);
3478 const FormatStyle &Style) {
3489 ProcessFunc(Style, *NewCode, ChangedRanges, FileName);
3496 const FormatStyle &Style) {
3499 auto SortIncludes = [](const FormatStyle &Style, StringRef Code,
3502 return sortIncludes(Style, Code, Ranges, FileName);
3505 processReplacements(SortIncludes, Code, Replaces, Style);
3511 auto Reformat = [](const FormatStyle &Style, StringRef Code,
3514 return reformat(Style, Code, Ranges, FileName);
3516 return processReplacements(Reformat, Code, *SortedReplaces, Style);
3534 const FormatStyle &Style) {
3535 if (!Style.isCpp())
3560 tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle);
3606 const FormatStyle &Style) {
3609 auto Cleanup = [](const FormatStyle &Style, StringRef Code,
3612 return cleanup(Style, Code, Ranges, FileName);
3616 fixCppIncludeInsertions(Code, Replaces, Style);
3617 return cantFail(processReplacements(Cleanup, Code, NewReplaces, Style));
3622 reformat(const FormatStyle &Style, StringRef Code,
3626 FormatStyle Expanded = Style;
3651 if (Style.isJson()) {
3659 Formatter(*Env, Style, Status).process().first;
3684 if (Style.isCpp()) {
3685 if (Style.QualifierAlignment != FormatStyle::QAS_Leave)
3688 if (Style.RemoveParentheses != FormatStyle::RPS_Leave) {
3690 S.RemoveParentheses = Style.RemoveParentheses;
3696 if (Style.InsertBraces) {
3704 if (Style.RemoveBracesLLVM) {
3712 if (Style.RemoveSemicolon) {
3720 if (Style.FixNamespaceComments) {
3726 if (Style.SortUsingDeclarations != FormatStyle::SUD_Never) {
3733 if (Style.SeparateDefinitionBlocks != FormatStyle::SDS_Leave) {
3739 if (Style.Language == FormatStyle::LK_ObjC &&
3740 !Style.ObjCPropertyAttributeOrder.empty()) {
3746 if (Style.isJavaScript() &&
3747 Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) {
3757 if (Style.isJavaScript() &&
3758 Style.InsertTrailingCommas == FormatStyle::TCS_Wrapped) {
3786 if (Style.QualifierAlignment != FormatStyle::QAS_Leave) {
3808 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
3812 return internal::reformat(Style, Code, Ranges,
3819 tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
3823 if (Style.Language != FormatStyle::LK_Cpp)
3828 return Cleaner(*Env, Style).process().first;
3831 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
3835 auto Result = reformat(Style, Code, Ranges, FileName, &Status);
3841 tooling::Replacements fixNamespaceEndComments(const FormatStyle &Style,
3848 return NamespaceEndCommentsFixer(*Env, Style).process().first;
3851 tooling::Replacements sortUsingDeclarations(const FormatStyle &Style,
3858 return UsingDeclarationsSorter(*Env, Style).process().first;
3861 LangOptions getFormattingLangOpts(const FormatStyle &Style) {
3864 FormatStyle::LanguageStandard LexingStd = Style.Standard;
3881 LangOpts.CXXOperatorNames = Style.isCpp();
3969 FormatStyle *Style, bool AllowUnknownOptions,
3975 if (auto EC = parseConfiguration(*Text.get(), Style, AllowUnknownOptions,
3987 FormatStyle Style = getLLVMStyle(guessLanguage(FileName, Code));
3989 if (!getPredefinedStyle(FallbackStyleName, Style.Language, &FallbackStyle))
3998 parseConfiguration(llvm::MemoryBufferRef(StyleName, Source), &Style,
4003 if (!Style.InheritsParentConfig)
4004 return Style;
4015 if (!Style.InheritsParentConfig &&
4019 loadAndParseConfigFile(ConfigFile, FS, &Style, AllowUnknownOptions,
4029 if (!Style.InheritsParentConfig)
4030 return Style;
4041 if (!Style.InheritsParentConfig && !StyleName.equals_insensitive("file")) {
4042 if (!getPredefinedStyle(StyleName, Style.Language, &Style))
4044 if (!Style.InheritsParentConfig)
4045 return Style;
4053 Style.InheritsParentConfig = false;
4057 auto applyChildFormatTexts = [&](FormatStyle *Style) {
4060 parseConfiguration(*MemBuf, Style, AllowUnknownOptions,
4095 loadAndParseConfigFile(ConfigFile, FS, &Style, AllowUnknownOptions,
4111 if (!Style.InheritsParentConfig) {
4114 applyChildFormatTexts(&Style);
4116 return Style;
4122 Style.InheritsParentConfig = false;
4136 getLanguageName(Style.Language) + ": " +