[PATCH] Refactor the formatter of clang-format.
Manuel Klimek
klimek at google.com
Fri May 8 07:58:02 PDT 2015
================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:448
@@ +447,3 @@
+/// \brief Formatter that puts all tokens into a single line without breaks.
+class FitInOneLineFormatter : public LineFormatter {
+public:
----------------
djasper wrote:
> I think this is a NoLineBreakFormatter. The fact that it is used if something fits into a line is not really a description of its function.
Done. Good name.
================
Comment at: lib/Format/UnwrappedLineFormatter.h:42-45
@@ -32,11 +41,6 @@
public:
- UnwrappedLineFormatter(ContinuationIndenter *Indenter,
- WhitespaceManager *Whitespaces,
- const FormatStyle &Style,
- const AdditionalKeywords &Keywords,
- bool *IncompleteFormat)
- : Indenter(Indenter), Whitespaces(Whitespaces), Style(Style),
- Keywords(Keywords), IncompleteFormat(IncompleteFormat) {}
-
- unsigned format(const SmallVectorImpl<AnnotatedLine *> &Lines, bool DryRun,
- int AdditionalIndent = 0, bool FixBadIndentation = false);
+ UnwrappedLineFormatter(const SmallVectorImpl<AnnotatedLine *> &Lines,
+ FormattingContext Context, bool DryRun = false,
+ int AdditionalIndent = 0,
+ bool FixBadIndentation = false)
+ : Lines(Lines), Context(Context), AdditionalIndent(AdditionalIndent),
----------------
djasper wrote:
> I am not sure what the long term solution for UnwrappedLineFormatter/BlockFormatter is. I think we will probably want to try to separate the individual concepts into different classes (indent level tracking, deciding which line to format and how, deciding which formatter to use).
>
> Until we have that, I'd like it to remain a container for the formatting configuration and pass it to the different LineFormatters (so that LineFormatter::formatChildren() can just call format).
Done.
http://reviews.llvm.org/D9597
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list