@@ -908,8 +908,8 @@ class JavaScriptRequoter : public TokenAnalyzer {
908
908
class Formatter : public TokenAnalyzer {
909
909
public:
910
910
Formatter (const Environment &Env, const FormatStyle &Style ,
911
- bool *IncompleteFormat )
912
- : TokenAnalyzer(Env, Style ), IncompleteFormat(IncompleteFormat ) {}
911
+ FormattingAttemptStatus *Status )
912
+ : TokenAnalyzer(Env, Style ), Status(Status ) {}
913
913
914
914
tooling::Replacements
915
915
analyze (TokenAnnotator &Annotator,
@@ -931,7 +931,7 @@ class Formatter : public TokenAnalyzer {
931
931
Env.getSourceManager (), Whitespaces, Encoding,
932
932
BinPackInconclusiveFunctions);
933
933
UnwrappedLineFormatter (&Indenter, &Whitespaces, Style , Tokens.getKeywords (),
934
- IncompleteFormat )
934
+ Env. getSourceManager (), Status )
935
935
.format (AnnotatedLines);
936
936
for (const auto &R : Whitespaces.generateReplacements ())
937
937
if (Result.add (R))
@@ -1013,7 +1013,7 @@ class Formatter : public TokenAnalyzer {
1013
1013
}
1014
1014
1015
1015
bool BinPackInconclusiveFunctions;
1016
- bool *IncompleteFormat ;
1016
+ FormattingAttemptStatus *Status ;
1017
1017
};
1018
1018
1019
1019
// This class clean up the erroneous/redundant code around the given ranges in
@@ -1830,7 +1830,8 @@ cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
1830
1830
1831
1831
tooling::Replacements reformat (const FormatStyle &Style , StringRef Code,
1832
1832
ArrayRef<tooling::Range> Ranges,
1833
- StringRef FileName, bool *IncompleteFormat) {
1833
+ StringRef FileName,
1834
+ FormattingAttemptStatus *Status) {
1834
1835
FormatStyle Expanded = expandPresets (Style );
1835
1836
if (Expanded.DisableFormat )
1836
1837
return tooling::Replacements ();
@@ -1846,11 +1847,11 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
1846
1847
auto NewEnv = Environment::CreateVirtualEnvironment (
1847
1848
*NewCode, FileName,
1848
1849
tooling::calculateRangesAfterReplacements (Fixes, Ranges));
1849
- Formatter Format (*NewEnv, Expanded, IncompleteFormat );
1850
+ Formatter Format (*NewEnv, Expanded, Status );
1850
1851
return Fixes.merge (Format.process ());
1851
1852
}
1852
1853
}
1853
- Formatter Format (*Env, Expanded, IncompleteFormat );
1854
+ Formatter Format (*Env, Expanded, Status );
1854
1855
return Format.process ();
1855
1856
};
1856
1857
@@ -1866,7 +1867,7 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
1866
1867
return reformatAfterApplying (Requoter);
1867
1868
}
1868
1869
1869
- Formatter Format (*Env, Expanded, IncompleteFormat );
1870
+ Formatter Format (*Env, Expanded, Status );
1870
1871
return Format.process ();
1871
1872
}
1872
1873
@@ -1879,6 +1880,16 @@ tooling::Replacements cleanup(const FormatStyle &Style, StringRef Code,
1879
1880
return Clean.process ();
1880
1881
}
1881
1882
1883
+ tooling::Replacements reformat (const FormatStyle &Style , StringRef Code,
1884
+ ArrayRef<tooling::Range> Ranges,
1885
+ StringRef FileName, bool *IncompleteFormat) {
1886
+ FormattingAttemptStatus Status;
1887
+ auto Result = reformat (Style , Code, Ranges, FileName, &Status);
1888
+ if (!Status.FormatComplete )
1889
+ *IncompleteFormat = true ;
1890
+ return Result;
1891
+ }
1892
+
1882
1893
tooling::Replacements fixNamespaceEndComments (const FormatStyle &Style ,
1883
1894
StringRef Code,
1884
1895
ArrayRef<tooling::Range> Ranges,
0 commit comments