<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">One thing fixed, another one broken; that's why you have tests.<br><br>I did found the ContinuationIndenter::getNewLineColumn(),<br>if I understand it right it tells you how many spaces are added in front of some symbol.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Though because this both handles the enum values and the braced lists, reducing the indent for the enums (return State.Stack.back().Indent - Style.IndentWidth;) results in all other stuff to get messed up.<br><br></div><div class="gmail_default" style><font color="#000000" face="verdana, sans-serif">This makes the following code:</font><br><font color="#000000" face="verdana, sans-serif"><br>void someLongFunction(</font></div><div class="gmail_default" style><font color="#000000" face="verdana, sans-serif">....int someLongParameter) const<br>..{<br>..}</font></div><div class="gmail_default" style><font color="#000000" face="verdana, sans-serif"><br></font></div><div class="gmail_default" style><font color="#000000" face="verdana, sans-serif">into:</font></div><div class="gmail_default" style><font color="#000000" face="verdana, sans-serif"><br></font><div class="gmail_default"><font color="#000000" face="verdana, sans-serif">void someLongFunction(</font></div><div class="gmail_default"><font color="#000000" face="verdana, sans-serif">..int someLongParameter) const<br>..{<br>..}</font><br></div><div class="gmail_default"><font color="#000000" face="verdana, sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" face="verdana, sans-serif">Is their any way to correct the indent selectively when parsing the enumeration and return it without incorrect correction in all other cases?</font></div><div class="gmail_default"><font color="#000000" face="verdana, sans-serif"><br></font></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><font face="verdana, sans-serif">JVApen<font size="1"><br><br></font></font></div></div></div></div>
<br><div class="gmail_quote">On 1 January 2015 at 21:33, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yeah. Enums are special. The reason is that we want to treat them somewhat close to other braced lists. They do not really contain individual statements or declarations and thus we parse them into a single unwrapped line. The actual wrapping/indentation is then done later in ContinuationIndenter.cpp. The logic might be a bit convoluted there, let me know if you need further help</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 1, 2015 at 4:14 PM, JVApen <span dir="ltr"><<a href="mailto:JVApen@gmail.com" target="_blank">JVApen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Hi Daniel,<br><br>Most of appears to be working with the Whitesmiths; however I still have one group of tests failing.</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">These tests contain enumerations, the scenario is the following:<br><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">enum X</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">  {</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">  Y = 0</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">  }<br><br>which gets formatted to:</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">enum X</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">{</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">  Y = 0</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">}</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br>If I call addUnwrappedLine() at the end of parseEnum() the result becomes the following:</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">enum X</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">  {</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">    Y = 0</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">  }</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">The debug information tells me the following:</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><div>Line(0): enum[47] identifier[47] </div><div>Line(1): l_brace[47] identifier[47] equal[47] numeric_constant[47] r_brace[47] </div><div>Line(0): eof[47] </div><div><br></div><div>Hower for this result I expect it to be more like:</div><div><div>Line(0): enum[47] identifier[47] </div><div>Line(1): l_brace[47]</div><div>Line(2): identifier[47] equal[47] numeric_constant[47]</div><div>Line(1): r_brace[47] </div><div>Line(0): eof[47] </div></div><div><br></div><div>However I'm guessing that I am missing something obvious;<br>I do however suspect parseBracedList() from doing something which I don't completely understand<br>OR something in the UnwrappedLineFormatter.cpp file to mess this up.<br><br>Any idea on where to look for the responsible?</div><span><font color="#888888"><div><br></div></font></span></div><div class="gmail_extra"><span><font color="#888888"><div><div><div dir="ltr"><div><font face="verdana, sans-serif"><font size="1"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0);display:inline">​JVApen​</div><br></font></font></div></div></div></div></font></span><div><div>
<br><div class="gmail_quote">On 26 December 2014 at 20:14, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Dec 26, 2014 at 7:53 PM, JVApen <span dir="ltr"><<a href="mailto:JVApen@gmail.com" target="_blank">JVApen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Hi all,<br><br>I was looking into the clang tools to experiment with; hoping to convince some colleagues that tooling can save us time.<br>Anyhow; since I was trying to take baby steps; clang format looked like a very good start.<br>Unfortunately, we would not be programmers if we wouldn't do things a bit different than the rest of the world.</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">The current code; with too many files; uses the <a href="http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style" target="_blank">Whitesmiths style</a> at most places.<br>Though this is not yet supported by clang format.<br>Going through the code, adding support for it did not look like a big thing; since Allman and GNU are very similar.<br>The thing I did not realize is that both of them indent all code by one level compared to the {,<br>which is not done by Whitesmiths style.<br></div></div></blockquote><div><br></div></span><div>That actually shouldn't matter much. The whether or not to break before the "{" is controlled by calling addUnwrappedLine() one more time whereas the indentation is controlled by changing Line->Level. Basically all you should need to do is to change the order of "addUnwrappedLine(); ++Line->Level;" for the addUnwrappedLine() call for the "{". Unfortunately, there is no nice abstraction for this and you'll need to look at how to do this for the different kinds of syntactic elements individually. I can look into it and give more help if you get stuck.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I already wrote a unit test, based on the Allman unit test; useful for test driven development<br>and experimented already with the code in lib/Format/UnwrappedLineParser.cpp<br>Though can't seem to find out how to prevent the extra indent;<br>does anyone with more codebase experience have an idea where to start?</div><span><font color="#888888"><br clear="all"><div><div><div dir="ltr"><div><font face="verdana, sans-serif">JVApen<font size="1"><br></font></font></div></div></div></div>
</font></span></div>
<br></span>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>