|
@@ -149,8 +149,8 @@ struct ScalarEnumerationTraits<FormatStyle::BreakConstructorInitializersStyle> {
|
|
|
|
|
|
template <>
|
|
template <>
|
|
struct ScalarEnumerationTraits<FormatStyle::BreakInheritanceListStyle> {
|
|
struct ScalarEnumerationTraits<FormatStyle::BreakInheritanceListStyle> {
|
|
- static void
|
|
|
|
- enumeration(IO &IO, FormatStyle::BreakInheritanceListStyle &Value) {
|
|
|
|
|
|
+ static void enumeration(IO &IO,
|
|
|
|
+ FormatStyle::BreakInheritanceListStyle &Value) {
|
|
IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);
|
|
IO.enumCase(Value, "BeforeColon", FormatStyle::BILS_BeforeColon);
|
|
IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);
|
|
IO.enumCase(Value, "BeforeComma", FormatStyle::BILS_BeforeComma);
|
|
IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);
|
|
IO.enumCase(Value, "AfterColon", FormatStyle::BILS_AfterColon);
|
|
@@ -179,7 +179,8 @@ struct ScalarEnumerationTraits<FormatStyle::ReturnTypeBreakingStyle> {
|
|
|
|
|
|
template <>
|
|
template <>
|
|
struct ScalarEnumerationTraits<FormatStyle::BreakTemplateDeclarationsStyle> {
|
|
struct ScalarEnumerationTraits<FormatStyle::BreakTemplateDeclarationsStyle> {
|
|
- static void enumeration(IO &IO, FormatStyle::BreakTemplateDeclarationsStyle &Value) {
|
|
|
|
|
|
+ static void enumeration(IO &IO,
|
|
|
|
+ FormatStyle::BreakTemplateDeclarationsStyle &Value) {
|
|
IO.enumCase(Value, "No", FormatStyle::BTDS_No);
|
|
IO.enumCase(Value, "No", FormatStyle::BTDS_No);
|
|
IO.enumCase(Value, "MultiLine", FormatStyle::BTDS_MultiLine);
|
|
IO.enumCase(Value, "MultiLine", FormatStyle::BTDS_MultiLine);
|
|
IO.enumCase(Value, "Yes", FormatStyle::BTDS_Yes);
|
|
IO.enumCase(Value, "Yes", FormatStyle::BTDS_Yes);
|
|
@@ -361,10 +362,8 @@ template <> struct MappingTraits<FormatStyle> {
|
|
IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);
|
|
IO.mapOptional("BreakBeforeBraces", Style.BreakBeforeBraces);
|
|
|
|
|
|
bool BreakBeforeInheritanceComma = false;
|
|
bool BreakBeforeInheritanceComma = false;
|
|
- IO.mapOptional("BreakBeforeInheritanceComma",
|
|
|
|
- BreakBeforeInheritanceComma);
|
|
|
|
- IO.mapOptional("BreakInheritanceList",
|
|
|
|
- Style.BreakInheritanceList);
|
|
|
|
|
|
+ IO.mapOptional("BreakBeforeInheritanceComma", BreakBeforeInheritanceComma);
|
|
|
|
+ IO.mapOptional("BreakInheritanceList", Style.BreakInheritanceList);
|
|
// If BreakBeforeInheritanceComma was specified but
|
|
// If BreakBeforeInheritanceComma was specified but
|
|
// BreakInheritance was not, initialize the latter from the
|
|
// BreakInheritance was not, initialize the latter from the
|
|
// former for backwards compatibility.
|
|
// former for backwards compatibility.
|
|
@@ -854,15 +853,9 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
|
|
// See styleguide for import groups:
|
|
// See styleguide for import groups:
|
|
// https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
|
|
// https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
|
|
ChromiumStyle.JavaImportGroups = {
|
|
ChromiumStyle.JavaImportGroups = {
|
|
- "android",
|
|
|
|
- "com",
|
|
|
|
- "dalvik",
|
|
|
|
- "junit",
|
|
|
|
- "org",
|
|
|
|
- "com.google.android.apps.chrome",
|
|
|
|
- "org.chromium",
|
|
|
|
- "java",
|
|
|
|
- "javax",
|
|
|
|
|
|
+ "android", "com", "dalvik",
|
|
|
|
+ "junit", "org", "com.google.android.apps.chrome",
|
|
|
|
+ "org.chromium", "java", "javax",
|
|
};
|
|
};
|
|
ChromiumStyle.SortIncludes = true;
|
|
ChromiumStyle.SortIncludes = true;
|
|
} else if (Language == FormatStyle::LK_JavaScript) {
|
|
} else if (Language == FormatStyle::LK_JavaScript) {
|
|
@@ -1063,9 +1056,7 @@ void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
|
|
(*Styles)[Style.Language] = std::move(Style);
|
|
(*Styles)[Style.Language] = std::move(Style);
|
|
}
|
|
}
|
|
|
|
|
|
-void FormatStyle::FormatStyleSet::Clear() {
|
|
|
|
- Styles.reset();
|
|
|
|
-}
|
|
|
|
|
|
+void FormatStyle::FormatStyleSet::Clear() { Styles.reset(); }
|
|
|
|
|
|
llvm::Optional<FormatStyle>
|
|
llvm::Optional<FormatStyle>
|
|
FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
|
|
FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
|
|
@@ -1857,8 +1848,7 @@ static unsigned findJavaImportGroup(const FormatStyle &Style,
|
|
static void sortJavaImports(const FormatStyle &Style,
|
|
static void sortJavaImports(const FormatStyle &Style,
|
|
const SmallVectorImpl<JavaImportDirective> &Imports,
|
|
const SmallVectorImpl<JavaImportDirective> &Imports,
|
|
ArrayRef<tooling::Range> Ranges, StringRef FileName,
|
|
ArrayRef<tooling::Range> Ranges, StringRef FileName,
|
|
- StringRef Code,
|
|
|
|
- tooling::Replacements &Replaces) {
|
|
|
|
|
|
+ StringRef Code, tooling::Replacements &Replaces) {
|
|
unsigned ImportsBeginOffset = Imports.front().Offset;
|
|
unsigned ImportsBeginOffset = Imports.front().Offset;
|
|
unsigned ImportsEndOffset =
|
|
unsigned ImportsEndOffset =
|
|
Imports.back().Offset + Imports.back().Text.size();
|
|
Imports.back().Offset + Imports.back().Text.size();
|
|
@@ -1965,7 +1955,8 @@ tooling::Replacements sortJavaImports(const FormatStyle &Style, StringRef Code,
|
|
if (Static.contains("static")) {
|
|
if (Static.contains("static")) {
|
|
IsStatic = true;
|
|
IsStatic = true;
|
|
}
|
|
}
|
|
- ImportsInBlock.push_back({Identifier, Line, Prev, AssociatedCommentLines, IsStatic});
|
|
|
|
|
|
+ ImportsInBlock.push_back(
|
|
|
|
+ {Identifier, Line, Prev, AssociatedCommentLines, IsStatic});
|
|
AssociatedCommentLines.clear();
|
|
AssociatedCommentLines.clear();
|
|
} else if (Trimmed.size() > 0 && !ImportsInBlock.empty()) {
|
|
} else if (Trimmed.size() > 0 && !ImportsInBlock.empty()) {
|
|
// Associating comments within the imports with the nearest import below
|
|
// Associating comments within the imports with the nearest import below
|
|
@@ -2094,7 +2085,6 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
|
if (HeaderInsertions.empty() && HeadersToDelete.empty())
|
|
if (HeaderInsertions.empty() && HeadersToDelete.empty())
|
|
return Replaces;
|
|
return Replaces;
|
|
|
|
|
|
-
|
|
|
|
StringRef FileName = Replaces.begin()->getFilePath();
|
|
StringRef FileName = Replaces.begin()->getFilePath();
|
|
tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle);
|
|
tooling::HeaderIncludes Includes(FileName, Code, Style.IncludeStyle);
|
|
|
|
|
|
@@ -2127,7 +2117,8 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
|
|
auto Err = Result.add(*Replace);
|
|
auto Err = Result.add(*Replace);
|
|
if (Err) {
|
|
if (Err) {
|
|
llvm::consumeError(std::move(Err));
|
|
llvm::consumeError(std::move(Err));
|
|
- unsigned NewOffset = Result.getShiftedCodePosition(Replace->getOffset());
|
|
|
|
|
|
+ unsigned NewOffset =
|
|
|
|
+ Result.getShiftedCodePosition(Replace->getOffset());
|
|
auto Shifted = tooling::Replacement(FileName, NewOffset, 0,
|
|
auto Shifted = tooling::Replacement(FileName, NewOffset, 0,
|
|
Replace->getReplacementText());
|
|
Replace->getReplacementText());
|
|
Result = Result.merge(tooling::Replacements(Shifted));
|
|
Result = Result.merge(tooling::Replacements(Shifted));
|