<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Formatter Callback Functions	</title>
	<atom:link href="https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/</link>
	<description>Database-centric development</description>
	<lastBuildDate>Sun, 12 Nov 2023 12:59:39 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/>
<atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/>
<atom:link rel="hub" href="https://websubhub.com/hub"/>
<atom:link rel="self" href="https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/feed/"/>
	<item>
		<title>
		By: Philipp Salvisberg		</title>
		<link>https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/#comment-37314</link>

		<dc:creator><![CDATA[Philipp Salvisberg]]></dc:creator>
		<pubDate>Thu, 19 Nov 2020 12:08:01 +0000</pubDate>
		<guid isPermaLink="false">https://www.salvis.com/blog/?p=10859#comment-37314</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/#comment-36483&quot;&gt;Vadim Tropashko&lt;/a&gt;.

Agreed, the formatter could be implemented in JS, e.g. using SQLDev as a library. However, AFAIK it is not possible to configure an alternative formatter in SQLDev 20.2. You need to provide it as an additional SQLDev extension with a new action which lives beside the existing action &quot;Format&quot; and call it &quot;Beautify&quot; or something similar. Please let me know if I&#039;m missing something here.

It&#039;s interesting to hear that you are thinking about changing the way how the code is formatted using approaches from graphics libraries. I was working on a formatter for PL/SQL myself. It was based on our Trivadis parser produced by Xtext. The formatter used the &quot;old&quot; formatter API and produced only satisfying results for some chosen use cases. In other words, the formatter was never complete. I did not found the time to move it to the &lt;a href=&quot;https://www.slideshare.net/meysholdt/xtexts-new-formatter-api&quot; rel=&quot;nofollow ugc&quot;&gt;new formatter API&lt;/a&gt; which contains very interesting concepts: autowrap with handler, conditional formatting, pattern-aware formatting and table-based formatting. However, I stopped working on this project as SQLDev 4.2 came out and it was clear the SQLDev team has taken actions to improve the formatter significantly.

While I very much like the formatter capabilities that come with the exposure of the Arbori program, I do not think it is something a typical SQL Developer (person) should care about. I think the &quot;Advanced Settings&quot; should be enough to get the desired result or a result that is similar to the desired one and therefore good enough. Changing or better extending the provided Arbori program should be the last resort. It&#039;s worth to look at the formatter settings of other PL/SQL IDEs in that context. Here are two screenshots. One of Allround Automations PL/SQL Developer and the other of Quest TOAD:

&lt;a href=&quot;https://www.salvis.com/blog/wp-content/uploads/2020/11/plsql_developer_preferences_beautifier_14.0.png&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-10981&quot; src=&quot;https://www.salvis.com/blog/wp-content/uploads/2020/11/plsql_developer_preferences_beautifier_14.0.png&quot; alt=&quot;&quot; width=&quot;439&quot; height=&quot;208&quot; /&gt;&lt;/a&gt;

&lt;a href=&quot;https://www.salvis.com/blog/wp-content/uploads/2020/11/toad_options_formatter_13.3.png&quot;&gt;&lt;img class=&quot;alignnone size-full wp-image-10982&quot; src=&quot;https://www.salvis.com/blog/wp-content/uploads/2020/11/toad_options_formatter_13.3.png&quot; alt=&quot;&quot; width=&quot;661&quot; height=&quot;777&quot; /&gt;&lt;/a&gt;

The screenshots show two things.
&lt;ul&gt;
 	&lt;li&gt;There are a lot of formatter options. It&#039;s clear for TOAD. For PL/SQL Developer it is not that obvious, but considering all options, it is more than what SQLDev provides under &quot;Advanced Format&quot; settings.&lt;/li&gt;
 	&lt;li&gt;For parameter list, there is a variant for code fitting on a single line. Additionally there are several multi-line variants. TOAD visualises the typical design variants and you may configure them further by specifying the number of parameters per line. PL/SQL Developer uses a similar concept but is less sophisticated in that area. However, both products allow similar settings for various lists.&lt;/li&gt;
&lt;/ul&gt;
By exposing the Arbori program and allowing to change it, SQLDev provides far more options than any other IDE. However, it is not that easy to master and to maintain it (thinking about merging my Arbori program with the one provided by a new SQLDev version). And therefore providing more options outside of the Arbori program to configure the formatter would be very much appreciated. This should work with the current model and also with a future model which might be based on blocks and substitutions.

Thank you for taking the time to comment on this blog post and I look forward to the improvements of future versions of SQLDev, especially in the area of code formatting.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/#comment-36483">Vadim Tropashko</a>.</p>
<p>Agreed, the formatter could be implemented in JS, e.g. using SQLDev as a library. However, AFAIK it is not possible to configure an alternative formatter in SQLDev 20.2. You need to provide it as an additional SQLDev extension with a new action which lives beside the existing action &#8220;Format&#8221; and call it &#8220;Beautify&#8221; or something similar. Please let me know if I&#8217;m missing something here.</p>
<p>It&#8217;s interesting to hear that you are thinking about changing the way how the code is formatted using approaches from graphics libraries. I was working on a formatter for PL/SQL myself. It was based on our Trivadis parser produced by Xtext. The formatter used the &#8220;old&#8221; formatter API and produced only satisfying results for some chosen use cases. In other words, the formatter was never complete. I did not found the time to move it to the <a href="https://www.slideshare.net/meysholdt/xtexts-new-formatter-api" rel="nofollow ugc">new formatter API</a> which contains very interesting concepts: autowrap with handler, conditional formatting, pattern-aware formatting and table-based formatting. However, I stopped working on this project as SQLDev 4.2 came out and it was clear the SQLDev team has taken actions to improve the formatter significantly.</p>
<p>While I very much like the formatter capabilities that come with the exposure of the Arbori program, I do not think it is something a typical SQL Developer (person) should care about. I think the &#8220;Advanced Settings&#8221; should be enough to get the desired result or a result that is similar to the desired one and therefore good enough. Changing or better extending the provided Arbori program should be the last resort. It&#8217;s worth to look at the formatter settings of other PL/SQL IDEs in that context. Here are two screenshots. One of Allround Automations PL/SQL Developer and the other of Quest TOAD:</p>
<p><a href="https://www.salvis.com/blog/wp-content/uploads/2020/11/plsql_developer_preferences_beautifier_14.0.png"><img class="alignnone size-full wp-image-10981" src="https://www.salvis.com/blog/wp-content/uploads/2020/11/plsql_developer_preferences_beautifier_14.0.png" alt="" width="439" height="208" /></a></p>
<p><a href="https://www.salvis.com/blog/wp-content/uploads/2020/11/toad_options_formatter_13.3.png"><img class="alignnone size-full wp-image-10982" src="https://www.salvis.com/blog/wp-content/uploads/2020/11/toad_options_formatter_13.3.png" alt="" width="661" height="777" /></a></p>
<p>The screenshots show two things.</p>
<ul>
<li>There are a lot of formatter options. It&#8217;s clear for TOAD. For PL/SQL Developer it is not that obvious, but considering all options, it is more than what SQLDev provides under &#8220;Advanced Format&#8221; settings.</li>
<li>For parameter list, there is a variant for code fitting on a single line. Additionally there are several multi-line variants. TOAD visualises the typical design variants and you may configure them further by specifying the number of parameters per line. PL/SQL Developer uses a similar concept but is less sophisticated in that area. However, both products allow similar settings for various lists.</li>
</ul>
<p>By exposing the Arbori program and allowing to change it, SQLDev provides far more options than any other IDE. However, it is not that easy to master and to maintain it (thinking about merging my Arbori program with the one provided by a new SQLDev version). And therefore providing more options outside of the Arbori program to configure the formatter would be very much appreciated. This should work with the current model and also with a future model which might be based on blocks and substitutions.</p>
<p>Thank you for taking the time to comment on this blog post and I look forward to the improvements of future versions of SQLDev, especially in the area of code formatting.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vadim Tropashko		</title>
		<link>https://www.salvis.com/blog/2020/11/12/formatter-callback-functions/#comment-36483</link>

		<dc:creator><![CDATA[Vadim Tropashko]]></dc:creator>
		<pubDate>Mon, 16 Nov 2020 22:58:37 +0000</pubDate>
		<guid isPermaLink="false">https://www.salvis.com/blog/?p=10859#comment-36483</guid>

					<description><![CDATA[It is remarkable that you had the patience to reverse engineer all the formatting rules. Initially, I naively thought that just one rule -- simple indentations -- would be good enough. Then, more and more rules become piling in in somewhat haphazard fashion.

I&#039;m still convinced there don&#039;t have to be that many rules. However, the formatter design should be revised. The key design element must be a rectangular block, and its relative position to the other block, corresponding to the node&#039;s parent, or predecessor in the parse tree. For example, the space before a word or symbol is just a block offset by one character, relative to the predecessor. Vertically aligned piece of code is just a block shifted one line down. The idea of visual elements organized into a tree with spacial transformations relating nodes to their parents is an old one, and it&#039;s leveraged in virtually any 3D and 2D graphics library.

Keep in mind that the formatter can be implemented entirely in JS. The fact that there is the central sequential token processor java function is just a historical artifact. The java callback methods also date to the time when Arbori didn&#039;t support JS callbacks yet.

This is hand waving, of course, because it&#039;s not quite clear what is the mechanism of rendering those code blocks without reliance onto the central sequential token processor. I&#039;d suggest that formatting should be viewed as a translator. Technically, translator is a program which analyses an input text and produces a&lt;a href=&quot;https://community.oracle.com/tech/developers/discussion/4336648/formatting-pl-sql-in-sqldev-20-2-0-unwanted-indentation-after-comment-solution&quot; rel=&quot;nofollow ugc&quot;&gt; set of Substitutions&lt;/a&gt;. Again, it is immature idea until we figure out how to convert those blocks into Substitutions...

&#160;

&#160;]]></description>
			<content:encoded><![CDATA[<p>It is remarkable that you had the patience to reverse engineer all the formatting rules. Initially, I naively thought that just one rule &#8212; simple indentations &#8212; would be good enough. Then, more and more rules become piling in in somewhat haphazard fashion.</p>
<p>I&#8217;m still convinced there don&#8217;t have to be that many rules. However, the formatter design should be revised. The key design element must be a rectangular block, and its relative position to the other block, corresponding to the node&#8217;s parent, or predecessor in the parse tree. For example, the space before a word or symbol is just a block offset by one character, relative to the predecessor. Vertically aligned piece of code is just a block shifted one line down. The idea of visual elements organized into a tree with spacial transformations relating nodes to their parents is an old one, and it&#8217;s leveraged in virtually any 3D and 2D graphics library.</p>
<p>Keep in mind that the formatter can be implemented entirely in JS. The fact that there is the central sequential token processor java function is just a historical artifact. The java callback methods also date to the time when Arbori didn&#8217;t support JS callbacks yet.</p>
<p>This is hand waving, of course, because it&#8217;s not quite clear what is the mechanism of rendering those code blocks without reliance onto the central sequential token processor. I&#8217;d suggest that formatting should be viewed as a translator. Technically, translator is a program which analyses an input text and produces a<a href="https://community.oracle.com/tech/developers/discussion/4336648/formatting-pl-sql-in-sqldev-20-2-0-unwanted-indentation-after-comment-solution" rel="nofollow ugc"> set of Substitutions</a>. Again, it is immature idea until we figure out how to convert those blocks into Substitutions&#8230;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
