<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi Jonas,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Lexer returns only the indentation which is already in the source code but not the calculated according to the .clang-format file.</p>
<p style="margin-top:0;margin-bottom:0">So far I've found the WhitespaceManager in libFormat but it seems to work only together with other formatting.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Ivan</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Jonas Toth <development@jonas-toth.eu><br>
<b>Sent:</b> Friday, October 5, 2018 3:16:51 PM<br>
<b>To:</b> Ivan Donchevskii; cfe-dev<br>
<b>Subject:</b> Re: [cfe-dev] [clang-format] Trying to use libFormat for code indentation</font>
<div> </div>
</div>
<meta content="text/html; charset=Windows-1252">
<div style="background-color:#FFFFFF">
<p>Hi Ivan,</p>
<p><br>
</p>
<p>take a look at this one: <a class="x_moz-txt-link-freetext" href="https://clang.llvm.org/doxygen/classclang_1_1Lexer.html#a9102a4b3ccbed3505f6d002502193793">
https://clang.llvm.org/doxygen/classclang_1_1Lexer.html#a9102a4b3ccbed3505f6d002502193793</a></p>
<p>The Lexer provides a function that gives the indendation for a line, given that you seem to know the line of interest you can probably query the Lexer there.</p>
<p><br>
</p>
<p>Best Jonas<br>
</p>
<br>
<div class="x_moz-cite-prefix">Am 05.10.2018 um 13:31 schrieb Ivan Donchevskii via cfe-dev:<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div id="x_divtagdefaultwrapper" dir="ltr" style="">
<p style="">Hi,</p>
<p style=""><br>
</p>
<p style="">libFormat and clang-format are great for formatting but I want to use libFormat a bit differently - to provide the indentation for the next line (inside IDE, when you press CR in code editor).</p>
<p style=""><br>
</p>
<p style="">Probably I miss some handy flag which helps with that but so far I've found only workarounds to do what I need:</p>
<p style=""><span style="font-size:12pt"> - add some stupid expression to the new line<span style=""> (something like "</span><span style="">a;")</span> to force libFormat indent it</span><br>
</p>
<p style=""><span style="font-size:12pt"> - play with clang-format flags to prevent it from shrinking the new line into the previous one</span></p>
<p style=""><span style="font-size:12pt"> - set ColumnLimit to the length of the previous line also to prevent shrinking</span></p>
<p style=""><span style="font-size:12pt"><br>
</span></p>
<p style=""><span style="font-size:12pt">All of them work completely unreliably. Also it's often some incomplete code in the middle of typing so it might have unfinished expressions.</span></p>
<p style=""><span style="font-size:12pt"><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">So I want to ask if somebody has/had similar
</span>use cases<span style="font-size:12pt"> and knows how to deal with them before adding some special flag to clang-format and trying to solve my issues there.</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt"><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">Kind regards,</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">Ivan</span></p>
</div>
<br>
<fieldset class="x_mimeAttachmentHeader"></fieldset> <br>
<pre>_______________________________________________
cfe-dev mailing list
<a class="x_moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="x_moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</div>
</body>
</html>