[PATCH] [clang-format] Added: FormatStyle::IndentNamespaces to indent the content of namespaces
Daniel Jasper
djasper at google.com
Mon Jul 29 01:41:26 PDT 2013
Please attach patches as plain text, not as zip-files. Or alternatively,
use phabricator (http://llvm-reviews.chandlerc.com/).
Comments inline.
+ /// \brief Indent the content of namespaces by one level.
> + ///
> + /// When false, use the same indentation level as outside block (file
> or namespace).
>
Please adhere to the 80 column limit. Or ideally, just use clang-format ;-).
> + bool IndentNamespaces;
>
IndentInNamespaces might be slightly more precise, but I am not sure.
> - parseBlock(/*MustBeDeclaration=*/true, 0);
> + parseBlock(/*MustBeDeclaration=*/true,
> /*AddLevels=*/Style.IndentNamespaces);
>
Please adhere to the 80 column limit.
> + FormatStyle getLLVMStyleWithIndentNamespaces(bool IndentNamespaces =
> true) {
> + FormatStyle Style = getLLVMStyle();
> + Style.IndentNamespaces = IndentNamespaces;
> + return Style;
> + }
> +
> + FormatStyle getGoogleStyleWithIndentNamespaces(bool IndentNamespaces =
> true) {
> + FormatStyle Style = getGoogleStyle();
> + Style.IndentNamespaces = IndentNamespaces;
> + return Style;
> + }
>
I don't think it is worth adding these methods. Just define a local style
in your test:
TEST_F(..., ...) {
FormatStyle Style = getLLVMStyle();
Style.IndentNamespace = true;
...
}
> On Fri, Jul 26, 2013 at 2:17 PM, Curdeius Curdeius <curdeius at gmail.com>wrote:
> Hi,
> Clang-format was lacking an option to add indentation within namespaces.
> I've created a patch that adds this option to clang::Format::FormatStyle.
> There is also a basic test.
> You'll find it in the attachment.
> I think it will be nice to have a possibility to indent only the content
> of namespaces, but excluding the inner namespaces, i.e. to have something
> like:
>
> class Indented1;
> namespace inner1 {
> class Indented2;
> } // namespace inner1
> namespace inner2 {
> } // namespace inner2
> } // namespace outer
> instead of:
>
> class Indented1;
> namespace inner1 {
> class Indented2;
> } // namespace inner1
> namespace inner2 {
> } // namespace inner2
> } // namespace outer
>
Really? I have never seen the latter before and it would confuse me quite a
bit.
Cheers,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130729/66583a73/attachment.html>
More information about the cfe-commits
mailing list