{"id":2193,"date":"2019-07-27T13:37:18","date_gmt":"2019-07-27T17:37:18","guid":{"rendered":"http:\/\/codinggorilla.com\/?p=2193"},"modified":"2019-08-14T21:14:44","modified_gmt":"2019-08-15T01:14:44","slug":"antlrvsix-v2-0","status":"publish","type":"post","link":"http:\/\/165.227.223.229\/index.php\/2019\/07\/27\/antlrvsix-v2-0\/","title":{"rendered":"AntlrVSIX v2.0"},"content":{"rendered":"\n<p>Due to my work on <a rel=\"noreferrer noopener\" aria-label=\"Piggy (opens in a new tab)\" href=\"https:\/\/github.com\/kaby76\/Piggy\" target=\"_blank\">Piggy<\/a> and <a rel=\"noreferrer noopener\" aria-label=\"Campy (opens in a new tab)\" href=\"https:\/\/github.com\/kaby76\/Campy\" target=\"_blank\">Campy<\/a>, I&#8217;m extending <a rel=\"noreferrer noopener\" aria-label=\"my Antlr4 extension (opens in a new tab)\" href=\"https:\/\/github.com\/kaby76\/AntlrVSIX\" target=\"_blank\">my Antlr4 extension<\/a> for Visual Studio in a number of ways. The plug-in hasn&#8217;t been updated for two years, and there are no extensions for Antlr that work with Visual Studio 2019, so it is due for an update. In fact, there isn&#8217;t a single extension for Antlr for Visual Studio 2019, and Antlr.org removed  Visual  Studio from the list of developer tools for Antlr.<\/p>\n\n\n\n<h2>Changes<\/h2>\n\n\n\n<h4>Targeting Visual Studio 2019 and 2017<\/h4>\n\n\n\n<p>I&#8217;m not sure where I read it, but &#8220;good practice&#8221; says I should only support the current version and one version previous.<\/p>\n\n\n\n<h4>Improved Tagging<\/h4>\n\n\n\n<p>I&#8217;ve added new tags for channels and modes, and the whole classification and tagging routines now check if the source has changed before reparsing, which improves performance.<\/p>\n\n\n\n<h4>A menu for AntlrVSIX in Extensions<\/h4>\n\n\n\n<p>In Visual Studio 2019, the menus for extensions are where you should look&#8211;under &#8220;Extensions&#8221;. Previously, I have to admit that it was hard to figure out the UI for AntlrVSIX, hidden under various menus, or available through a right-click context menu. That&#8217;s basically bad UI design.<\/p>\n\n\n\n<p>Although the right-click context menu for AntlrVSIX is still available, it mirrors exactly what you see in the main menu under &#8220;Extensions -&gt; AntlrVSIX&#8221;.<\/p>\n\n\n\n<h4>Navigation to next and previous rules in a grammar file<\/h4>\n\n\n\n<p>I&#8217;m a big fan of the old-style Emacs and even older Vi! Back then, UI was keyboard-oriented. It was much more efficient instead of moving around this stupid mouse, pointing to something I can hardly see on the screen.<\/p>\n\n\n\n<p>I&#8217;ve added a few new ways to navigate around a grammar file with some shortcuts. &#8220;Next rule&#8221; jumps to the next rule in a grammar; &#8220;Previous rule&#8221; jumps to the previous rule in the grammar; &#8220;Go to Visitor&#8221; navigates to a visitor method for a tree node corresponding to a non-terminal.<\/p>\n\n\n\n<h4>Generation of Visitors and Listeners<\/h4>\n\n\n\n<p>Go to visitor\/listener jumps to C# code for grammar symbol. If the method doesn&#8217;t exist, then the Visitor or Listener classes and methods are generated.<\/p>\n\n\n\n<h4>Options for the extension<\/h4>\n\n\n\n<p>An options dialog box for extension-specific parameters is now included. It is needed for things like where to find the &#8220;corpus&#8221; of examples of formatted grammars that Codebuff will use to format your grammar.<\/p>\n\n\n\n<h4>Performance<\/h4>\n\n\n\n<p>While AntlrVSIX is the only extension for VS 2019, it&#8217;s rarely used compared to several other older&#8211;and in my opinion, less useful extensions. AntlrVSIX has had only one review, which says the performance sucks. (Thanks, dude for not saying *what* specifically are you trying to do that is slow. I&#8217;d never have you on my QA team&#8211;not helpful descriptions).<\/p>\n\n\n\n<p>Performance has taken a more front seat with this release. Before parsing, I check whether the code buffer has changed.<\/p>\n\n\n\n<h4>Significant cleanup and bug fix of the <a href=\"https:\/\/github.com\/kaby76\/AntlrVSIX\">source code<\/a><\/h4>\n\n\n\n<p>I spent a lot of the time cleaning up the source code. At the time when I first wrote the extension, I had no clue how to modify which feature in the UI because the documentation for Visual Studio extensions is absolutely terrible. I now have a better command of what is going on and fixed a lot of the code.<\/p>\n\n\n\n<h4>Migration from packages.config to PackageReference builds<\/h4>\n\n\n\n<p>It&#8217;s absolutely appalling that the examples for extensions Microsoft provides is out of date and are so poor. Many still use the &#8220;packages.config&#8221; file to list the NuGet dependencies of a C# project. I&#8217;ve updated AntrlVSIX to use the latest format, which required the tool to be migrated to Net 4.7.2.<\/p>\n\n\n\n<h4>Integrating builds with <a rel=\"noreferrer noopener\" aria-label=\"Antlr4BuildTasks (opens in a new tab)\" href=\"https:\/\/github.com\/kaby76\/Antlr4BuildTasks\" target=\"_blank\">Antlr4BuildTasks<\/a><\/h4>\n\n\n\n<p>You can&#8217;t really have an extension for a language like Antlr if you don&#8217;t include some way of actually *building* the project that uses the language. After first writing AntlrVSIX, I then modified Antlr4cs, a wrapper for a C# version of the Antlr tool, to just be a wrapper the standard Antlr4 Java tool. So, it now generates the parsers\/lexers in the IDE.<\/p>\n\n\n\n<p>In addition, the Antlr4BuildTasks had a bug where one couldn&#8217;t change the build mode of the .g4 file to none. This is required for multi-file grammars that use the &#8220;import&#8221; statement in Antlr.<\/p>\n\n\n\n<h4>Fixing Intellisense<\/h4>\n\n\n\n<p>I fixed the Intellisense for the extension. The tooltip now works when hovering over a single-character grammar symbol. Command completion now offers a list of grammar symbols in the grammar.<\/p>\n\n\n\n<p>*****<\/p>\n\n\n\n<p>The work on the extension has been going on for two weeks and should be finished in the next week.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Due to my work on Piggy and Campy, I&#8217;m extending my Antlr4 extension for Visual Studio in a number of ways. The plug-in hasn&#8217;t been updated for two years, and there are no extensions for Antlr that work with Visual Studio 2019, so it is due for an update. In fact, there isn&#8217;t a single &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/165.227.223.229\/index.php\/2019\/07\/27\/antlrvsix-v2-0\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;AntlrVSIX v2.0&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/2193"}],"collection":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/comments?post=2193"}],"version-history":[{"count":0,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/2193\/revisions"}],"wp:attachment":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/media?parent=2193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/categories?post=2193"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/tags?post=2193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}