<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>hasseg.org &#187; jEdit</title>
	<atom:link href="http://hasseg.org/blog/post/category/jedit/feed/" rel="self" type="application/rss+xml" />
	<link>http://hasseg.org/blog</link>
	<description></description>
	<lastBuildDate>Mon, 15 Aug 2011 22:38:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jEdit Syntax Highlighting Mode for the Peg/Leg Parser Generator &#8216;Leg&#8217; Syntax</title>
		<link>http://hasseg.org/blog/post/651/jedit-syntax-highlighting-mode-for-the-pegleg-parser-generator-leg-syntax/</link>
		<comments>http://hasseg.org/blog/post/651/jedit-syntax-highlighting-mode-for-the-pegleg-parser-generator-leg-syntax/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 12:38:26 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=651</guid>
		<description><![CDATA[I&#8217;ve been working on a fast and embeddable Markdown parser that can be used for syntax highlighting in editors, based on the PEG grammar from John MacFarlane&#8217;s peg-markdown compiler project. The grammar is written in leg, a syntax for the peg/leg parser generator by Ian Piumarta, and to make my work with this new syntax [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://hasseg.org/blog/wp-content/uploaded/2007/09/jediticon.jpeg" align="right" alt="jedit icon" width="53" height="53" /> I&#8217;ve been working on a fast and embeddable Markdown parser that can be used for syntax highlighting in editors, based on the <a href="http://en.wikipedia.org/wiki/Parsing_expression_grammar">PEG</a> grammar from John MacFarlane&#8217;s <a href="https://github.com/jgm/peg-markdown">peg-markdown</a> compiler project. The grammar is written in <strong><em>leg</em>, a syntax for the <a href="http://piumarta.com/software/peg/">peg/leg</a> parser generator</strong> by Ian Piumarta, and to make my work with this new syntax a bit more pleasant I implemented <strong>a jEdit mode for it</strong>.
</p>
<p><span id="more-651"></span></p>
<p>
<strong>Download the mode here:</strong> <a href="/stuff/jedit-modes/leg.xml">leg.xml</a>
</p>
<p>
Note that since the <em>leg</em> syntax uses curly brackets (<span style="font-family:monospace;">{}</span>) to delimit <a href="http://en.wikipedia.org/wiki/Syntax-directed_translation">actions</a> in the grammar, and those actions are written in C (which also uses curly brackets a lot), the mode has to somehow be able to match a certain number of balanced pairs of these brackets. As far as I know this is not directly supported in the jEdit syntax highlighting mode system but I was able to use the &#8220;delegates&#8221; mechanism to implement support for two levels of matched brackets, which should be enough for any reasonable use (in any case, it&#8217;s easy to add further levels of such support to the mode).
</p>
<p>
<strong>To install this mode</strong>, add the following to the <span style="font-family:monospace;">modes/catalog</span> file in your jEdit user settings directory (select <em>Utilities &rarr; Settings Directory</em> in jEdit to find this):
</p>
<div class="codecolorer-container xml mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;MODE</span> <span style="color: #000066;">NAME</span>=<span style="color: #ff0000;">&quot;leg&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; <span style="color: #000066;">FILE</span>=<span style="color: #ff0000;">&quot;leg.xml&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; <span style="color: #000066;">FILE_NAME_GLOB</span>=<span style="color: #ff0000;">&quot;*.leg&quot;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></div>
<p>
Then copy the <span style="font-family:monospace;">leg.xml</span> file into the same directory with this file. See <a href="http://www.jedit.org/users-guide/installing-modes.html">the Installing Modes section</a> of the jEdit users&#8217; guide for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/651/jedit-syntax-highlighting-mode-for-the-pegleg-parser-generator-leg-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jEdit Macro for Opening the File Browser at Current Buffer&#8217;s &#8220;Project Root&#8221; Directory</title>
		<link>http://hasseg.org/blog/post/619/jedit-macro-for-opening-the-file-browser-at-current-buffers-project-root-directory/</link>
		<comments>http://hasseg.org/blog/post/619/jedit-macro-for-opening-the-file-browser-at-current-buffers-project-root-directory/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 15:26:01 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=619</guid>
		<description><![CDATA[When I&#8217;m working with code in jEdit, my editor of choice, I like to keep the file browser open and docked to the left side of my editor window. When I&#8217;m switching between files &#8212; often belonging to different projects &#8212; I find myself reaching for the mouse in order to manually navigate the file [...]]]></description>
			<content:encoded><![CDATA[<p>
<img align="right" src="http://hasseg.org/blog/wp-content/uploaded/2007/09/jediticon.jpeg" alt="" width="53" height="53" /> When I&#8217;m working with code in jEdit, my editor of choice, I like to keep the file browser open and docked to the left side of my editor window. When I&#8217;m switching between files &#8212; often belonging to different projects &#8212; I find myself <strong>reaching for the mouse</strong> in order to manually navigate the file browser to the root folder of the project the currently open file belongs to. I started doing this so often that I decided to <strong>whip up a small macro to do it for me</strong>.
</p>
<div class="note">
<strong>Update (April 4, 2011):</strong> Set file browser to directory of current buffer if version control root cannot be found.
</div>
<p><span id="more-619"></span></p>
<p>
Since I don&#8217;t use the <a href="http://plugins.jedit.org/plugins/?ProjectViewer">ProjectViewer</a> plugin this macro has to have its own logic for determining where the &#8220;project root&#8221; is. The way it works is that it tries to <strong>find the root folder</strong> of the current project by way of <strong>searching for version control system folders</strong> (i.e. <span style="font-family:monospace">.git</span>, <span style="font-family:monospace">.hg</span>, <span style="font-family:monospace">.bzr</span>, <span style="font-family:monospace">_darcs</span>, <span style="font-family:monospace">.svn</span> or <span style="font-family:monospace">CVS</span>). The assumption is that as the script traverses the file system folder structure from the buffer&#8217;s location towards the root the <em>first</em> folder that has a Git, Mercurial, Bazaar or Darcs folder (or the <em>last</em> to have a Subversion or CVS folder) is the root. When the script finds the project root it switches the file browser to display it while keeping the UI focus in the editor field. If no project root can be found in this manner, the script sets the file browser to the directory that contains the currently open file.
</p>
<p>
<strong>Download</strong> the macro script itself here: <a href="/stuff/jEditMacros/Open_Root_of_Current_Project_in_File_Browser.bsh">Open_Root_of_Current_Project_in_File_Browser.bsh</a>
</p>
<p>
You install it by dropping it into your jEdit user settings directory&#8217;s <span style="font-family:monospace">/macros</span> folder (select <em>Utilities &rarr; Settings Directory</em> from the jEdit menu to find this location) and then running <em>Macros &rarr; Rescan Macros</em>. You can set a keyboard shortcut for this via the <em>Shortcuts</em> section of jEdit&#8217;s preferences and/or add a toolbar button via the <em>Tool Bar</em> section.
</p>
<p>Here is the macro source:</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp;* Tries to find the root of the 'current project', assuming<br />
&nbsp;* all project files live under the same directory structure<br />
&nbsp;* and that they are all under the same version control<br />
&nbsp;* repository.<br />
&nbsp;* <br />
&nbsp;* For Git, Mercurial and Bazaar (and it seems Darcs?) this is<br />
&nbsp;* easy since they only have their 'dot-directory' at the root<br />
&nbsp;* of the structure but Subversion (and I assume CVS) put them<br />
&nbsp;* everywhere so we have to find the _last_ directory to have<br />
&nbsp;* one.<br />
&nbsp;* <br />
&nbsp;*/</span><br />
<span style="color: #003399;">String</span> findProjectRoot<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; dir <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>buffer.<span style="color: #006633;">getDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; previousDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> previousDirHasSvnDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> previousDirHasCvsDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>dir <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> hasSvnDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> hasCvsDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; list <span style="color: #339933;">=</span> dir.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>childName <span style="color: #339933;">:</span> list<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>hasSvnDir <span style="color: #339933;">&amp;&amp;</span> childName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.svn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hasSvnDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>hasCvsDir <span style="color: #339933;">&amp;&amp;</span> childName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;CVS&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hasCvsDir <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>childName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.git&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> childName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.hg&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> childName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.bzr&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> childName.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;_darcs&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> dir.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>previousDir <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>previousDirHasSvnDir <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>hasSvnDir<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>previousDirHasCvsDir <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>hasCvsDir<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> previousDir.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; previousDirHasSvnDir <span style="color: #339933;">=</span> hasSvnDir<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; previousDirHasCvsDir <span style="color: #339933;">=</span> hasCvsDir<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; previousDir <span style="color: #339933;">=</span> dir<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dir <span style="color: #339933;">=</span> dir.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
root <span style="color: #339933;">=</span> findProjectRoot<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>root <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; VFSBrowser.<span style="color: #006633;">browseDirectory</span><span style="color: #009900;">&#40;</span>view, buffer.<span style="color: #006633;">getDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; view.<span style="color: #006633;">getEditPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">focusOnTextArea</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; view.<span style="color: #006633;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setMessageAndClear</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Browser directory set to current buffer's location (cannot find project root.).&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">else</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; VFSBrowser.<span style="color: #006633;">browseDirectory</span><span style="color: #009900;">&#40;</span>view, root<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; view.<span style="color: #006633;">getEditPane</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">focusOnTextArea</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; view.<span style="color: #006633;">getStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setMessageAndClear</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Project root guessed; browser directory set to it.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/619/jedit-macro-for-opening-the-file-browser-at-current-buffers-project-root-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick, Declarative UML Sequence Diagrams</title>
		<link>http://hasseg.org/blog/post/329/quick-declarative-uml-sequence-diagrams/</link>
		<comments>http://hasseg.org/blog/post/329/quick-declarative-uml-sequence-diagrams/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 13:34:55 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=329</guid>
		<description><![CDATA[I recently had to create a few UML sequence diagrams, and I decided that I didn&#8217;t want to spend too much time manually tweaking and fixing the diagrams themselves (which is what I probably would&#8217;ve done, had I used OmniGraffle or something similar), but instead focus on the content &#8212; the depicted workflow itself. This [...]]]></description>
			<content:encoded><![CDATA[<p>
<img align="right" src="http://hasseg.org/blog/wp-content/uploaded/2009/06/wsd-example-diagram-small.png" alt="wsd-example-diagram-small" width="113" height="86" /> I recently had to create a few UML sequence diagrams, and I decided that I didn&#8217;t want to spend too much time manually tweaking and fixing the diagrams themselves (which is what I probably would&#8217;ve done, had I used <em>OmniGraffle</em> or something similar), but instead <strong>focus on the <em>content</em></strong> &mdash; the depicted workflow itself. This is when I remembered the bookmark I had in my browser for the <strong><a href="http://www.websequencediagrams.com">Web Sequence Diagrams</a> online service</strong>.
</p>
<p><span id="more-329"></span></p>
<h2>Benefits of Declarative Diagramming</h2>
<p><em>Web Sequence Diagrams</em> is great. It uses <strong><a href="http://www.websequencediagrams.com/examples.html">a simple, readable syntax</a></strong> you can use to type in descriptions of sequential workflows and based on that it will <strong>generate the corresponding UML sequence diagrams</strong> for you.</p>
<p>
Working with these diagrams in this way has a couple of <strong>nice benefits</strong> over more intricate/professional methods:
</p>
<ul>
<li>They&#8217;re quick to create and quick to modify</li>
<li>The syntax is pretty easy to read as-is</li>
<li>The source is plain text, so all the benefits of using plain text apply (e.g. <em>can put under source control</em>, <em>can use simple diff tools</em>, <em>file sizes are small</em> etc.)</li>
</ul>
<h2>Helper Script and Syntax Highlighting</h2>
<p>
When I was sure I wanted to use this method again in the future, I hacked up a few quick and simple tools for this:
</p>
<h3>Script for generating the diagram images from source files</h3>
<p>At the time of this writing, there&#8217;s <a href="http://websequencediagrams.uservoice.com/pages/9445-general/suggestions/101931-create-a-command-line-version-of-this-application-">a suggestion called &#8220;Create a command-line version of this application&#8221;</a> on the service&#8217;s <em>UserVoice</em> site that&#8217;s labeled <em>&#8220;started&#8221;</em>, so hopefully in the future we&#8217;ll have a command-line sequence diagram generator from the author of the online service. In the meantime, though, here&#8217;s my solution. This is <strong>a Python script</strong> that can be used for generating the diagram images (using this service) from &#8220;source files&#8221; that contain the declarative workflow syntax. You just need to:</p>
<ol>
<li>type up your diagram description in a text editor and save it into a file</li>
<li>begin the first line in the file with <span style="font-family:monospace;">#wsd</span> (so that the script knows this is a websequencediagrams.com syntax file)</li>
<li><em>(optional:)</em> specify the <a href="http://www.websequencediagrams.com/embedding.html">diagram style</a> you&#8217;d like to use on the first line with the syntax <span style="font-family:monospace;">#wsd:style=modern-blue</span></li>
<li>call the script with the path to this file as an argument to generate the diagram image</li>
</ol>
<p>
The script uses a temporary <a href="http://www.sqlite.org/">SQLite</a> database to <strong>save hashes of file contents</strong> so that even if you call it repeatedly for the same file, it&#8217;ll notice if the file contents haven&#8217;t changed and decide not to send a request over to the server. I did this in order to reduce unnecessary load on the server. I tested the script on <strong>Mac OS 10.5.7, Windows XP SP3 and Ubuntu 9.04</strong> and it seems to work just fine on all of those (of course, on Windows you&#8217;ll first have to install <a href="http://www.python.org/download/">Python</a> manually).
</p>
<p><strong>Download</strong> the script here: <a href="/stuff/wsd/wsd.py">wsd.py</a></p>
<p>
Here&#8217;s an example on how to use it (to see the script&#8217;s <em>usage</em> info, run it without any arguments):
</p>
<p>Save this into a file called <em>ax-diagram</em>:</p>
<pre class="prettyprint">
#wsd

participant "Component A" as A
participant "Component X" as X

X -> A: what up
A -> A: processWhatUp()
note over A: A is confused
A -> X: go away
destroy X
</pre>
<p>Then run the script:</p>
<pre class="prettyprint">
wsd.py ax-diagram
</pre>
<p>
&#8230;and the file <em>ax-diagram.png</em> is created:
</p>
<p><img src="http://hasseg.org/blog/wp-content/uploaded/2009/06/wsd-example-diagram.png" alt="example diagram" width="323" height="247" /></p>
<h3>jEdit syntax highlighting mode</h3>
<p>This is a simple jEdit syntax highlighting mode for the Web Sequence Diagrams syntax. You can <strong>download</strong> the file here: <a href="/stuff/wsd/websequencediagrams.xml">websequencediagrams.xml</a>. Refer to <a href="?p=302">this other blog post of mine</a> for instructions on how to install modes for jEdit.</p>
<p>
Here&#8217;s a screenshot of the highlighted syntax on my machine:
</p>
<p><img src="http://hasseg.org/blog/wp-content/uploaded/2009/06/wsd-syntax.png" alt="websequencediagram.com syntax highlighting screenshot" width="249" height="166" /></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/329/quick-declarative-uml-sequence-diagrams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Markdown and POD Syntax Highlighting Modes for jEdit</title>
		<link>http://hasseg.org/blog/post/302/markdown-and-pod-syntax-highlighting-modes-for-jedit/</link>
		<comments>http://hasseg.org/blog/post/302/markdown-and-pod-syntax-highlighting-modes-for-jedit/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 13:44:45 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[jEdit]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=302</guid>
		<description><![CDATA[In The Pragmatic Programmer&#185;, the authors Andrew Hunt and David Thomas empasize the power of plain text, as well as &#8220;generators&#8221; that take the canonical form of some document and generate different representations of it. This is very much in line with the way I like to work with a lot of documents, which is [...]]]></description>
			<content:encoded><![CDATA[<p>
In <em>The Pragmatic Programmer</em><a href="#fn1">&sup1;</a>, the authors Andrew Hunt and David Thomas empasize the power of plain text, as well as &#8220;generators&#8221; that take the canonical form of some document and generate different representations of it. This is very much in line with the way I like to work with a lot of documents, which is why I&#8217;ve been using the <strong>Markdown</strong> and <strong>POD (Plain Old Documentation)</strong> syntaxes for a couple of things. As jEdit is the editor I prefer to use for working with most plain-text formats, I wrote highlighting modes for it for these two syntaxes.
</p>
<div style="padding:4px;background:#eee;border:1px solid #ddd;">
<em><strong>Update (April 23, 09):</strong> Updated the Markdown mode with slightly better handling of code blocks and list item paragraphs as well as some comments about problems therein (see below in the post for more info on this).</em>
</div>
<p><span id="more-302"></span></p>
<h2>The Markdown jEdit mode</h2>
<p><img src="http://hasseg.org/blog/wp-content/uploaded/2009/04/markdown-highlighting.png" alt="Markdown jEdit mode screenshot" title="markdown-highlighting" width="419" height="256" class="size-full wp-image-310" /></p>
<p>
<a href="http://daringfireball.net/projects/markdown/">Markdown</a> is my favourite markup language. Its primary design principle, that the markup written in it should be <strong>as readable as possible</strong> even by itself, is something my plain text -loving mind can easily agree with. If I&#8217;m writing a document that needs to be represented as HTML later on, Markdown is my first choice (too bad <a href="http://michelf.com/weblog/2005/wordpress-text-flow-vs-markdown/">it doesn&#8217;t work very well with WordPress</a>).
</p>
<p>
<strong>Here&#8217;s my jEdit mode file for Markdown:</strong> <a href="/stuff/jedit-modes/markdown.xml">markdown.xml</a>.
</p>
<p>
To install this mode, add the following to the <span style="font-family:monospace;">modes/catalog</span> file in your jEdit user settings directory (select <em>Utilities &rarr; Settings Directory</em> in jEdit to find this):
</p>
<pre class="prettyprint">
<div class="codecolorer-container text mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;MODE &nbsp; NAME=&quot;markdown&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE=&quot;markdown.xml&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; FILE_NAME_GLOB=&quot;*.markdown&quot;<br />
/&gt;</div></div>
</pre>
<p>
Then copy the <span style="font-family:monospace;">markdown.xml</span> file into the same directory with this file. See <a href="http://www.jedit.org/users-guide/installing-modes.html">the Installing Modes section</a> of the jEdit users&#8217; guide for more information.
</p>
<p>
This mode is not perfect; I could not figure out how to properly differentiate between <em>code blocks</em> and <em>list item paragraphs</em> (both are indented by 4+ spaces or 1+ tabs). Here&#8217;s what I wrote into the mode file related to these:
</p>
<pre class="prettyprint">
<div class="codecolorer-container text mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;!-- PROBLEM: code blocks<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;Both code blocks and list paragraphs are specified by indenting<br />
&nbsp; &nbsp; &nbsp;(4+ spaces or 1+ tab) - how to differentiate between them? We<br />
&nbsp; &nbsp; &nbsp;don't want markdown syntax coloring to apply within code blocks<br />
&nbsp; &nbsp; &nbsp;but we _do_ want it to apply within list paragraphs. As it stands,<br />
&nbsp; &nbsp; &nbsp;we can't have both (or at least I don't know how to do that with<br />
&nbsp; &nbsp; &nbsp;jEdit's current mode syntax implementation.)<br />
&nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp;The next line applies one syntax color type for all lines that<br />
&nbsp; &nbsp; &nbsp;begin with at least 4 spaces or 1 tab, which means that all such<br />
&nbsp; &nbsp; &nbsp;lines are treated as code blocks (this disables markdown syntax<br />
&nbsp; &nbsp; &nbsp;coloring for indented list paragraphs). Comment or uncomment it<br />
&nbsp; &nbsp; &nbsp;according to your preferences.<br />
--&gt;<br />
&lt;EOL_SPAN_REGEXP TYPE=&quot;LITERAL2&quot; AT_LINE_START=&quot;TRUE&quot; HASH_CHARS=&quot; &amp;#09;&quot;&gt;(\s{4,}|\t+)&lt;/EOL_SPAN_REGEXP&gt;<br />
&lt;!-- The next line applies one syntax color type for all lines that<br />
&nbsp; &nbsp; &nbsp;are indented &quot;twice&quot; (i.e. begin with at least 8 spaces or 2 tabs).<br />
&nbsp; &nbsp; &nbsp;This should safely match only code blocks (no list paragraphs can<br />
&nbsp; &nbsp; &nbsp;be indented twice like this, if I understand the spec correctly.)<br />
--&gt;<br />
&lt;EOL_SPAN_REGEXP TYPE=&quot;LITERAL2&quot; AT_LINE_START=&quot;TRUE&quot; HASH_CHARS=&quot; &amp;#09;&quot;&gt;(\s{4,}|\t+){2,}&lt;/EOL_SPAN_REGEXP&gt;</div></div>
</pre>
<p>Here&#8217;s how you&#8217;d generate a HTML file from a Markdown file:</p>
<pre class="prettyprint">
<div class="codecolorer-container text mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">perl Markdown.pl myDocument.markdown &gt; myDocument.html</div></div>
</pre>
<h2>The POD jEdit mode</h2>
<p><img src="http://hasseg.org/blog/wp-content/uploaded/2009/04/pod-highlighting.png" alt="POD jEdit mode screenshot" title="pod-highlighting" width="377" height="220" class="size-full wp-image-311" /></p>
<p>
When writing documentation for <a href="/icalBuddy">icalBuddy</a>, I had to enter the wonderful world of creating <a href="http://en.wikipedia.org/wiki/Manual_page_(Unix)">man pages</a> for the first time. The raw syntax for writing these things is, to say the least, awful. Just awful. Unfortunately I can&#8217;t use Markdown for writing them, but a pretty nice alternative I found was <a href="http://en.wikipedia.org/wiki/Plain_Old_Documentation">POD</a> (or <em>&#8220;Plain Old Documentation&#8221;</em>), which is mainly used to document Perl code. Now, the important thing to note about this mode is that I don&#8217;t know any Perl, I don&#8217;t code in Perl and I have no idea how POD is used with Perl, so <strong>this mode is not suitable for simultaneous use of Perl and POD</strong> &mdash; I just wrote it for syntax highlighting in the pure POD documents I use to write man pages. Adjusting it to work for the purposes of documenting Perl code might just be trivial for someone who does know Perl and how POD is used with it, but I can&#8217;t do it.
</p>
<p>
<strong>Here&#8217;s my jEdit mode file for POD:</strong> <a href="/stuff/jedit-modes/pod.xml">pod.xml</a>. Refer to the installation instructions for the Markdown mode above to see how this should be taken into use &mdash; the process is similar.
</p>
<p>Here&#8217;s how you&#8217;d generate a man page from a POD file:</p>
<pre class="prettyprint">
pod2man --section=1 --release=1.0 --center="manpage_title" --date="2009-04-21" myManPage.pod > myManPage.1
</pre>
<h3 style="margin-top:50px;">Footnotes</h3>
<ol>
<li id="fn1"><a href="http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X">The Pragmatic Programmer</a> (ISBN 0-201-61622-X): Chapter 3 (<em>&#8220;The Basic Tools&#8221;</em>), Sections <em>&#8220;The Power of Plain Text&#8221;</em> (pages 73-77) and <em>&#8220;Code Generators&#8221;</em> (pages 102-106). </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/302/markdown-and-pod-syntax-highlighting-modes-for-jedit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>fcshctl: the Flex Compiler Shell Controller</title>
		<link>http://hasseg.org/blog/post/194/fcshctl-the-flex-compiler-shell-controller/</link>
		<comments>http://hasseg.org/blog/post/194/fcshctl-the-flex-compiler-shell-controller/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 17:32:35 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=194</guid>
		<description><![CDATA[Introduction Like I&#8217;ve mentioned before in this blog, I develop Flex applications using the Flex SDK and jEdit instead of Adobe&#8217;s Flex Builder IDE. This setup has worked very well for me but one annoying issue I&#8217;ve had to deal with because of this is the slow compilation speed: every time I make a small [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>
Like I&#8217;ve mentioned before in this blog, I develop Flex applications using the Flex SDK and jEdit instead of Adobe&#8217;s Flex Builder IDE. This setup has worked very well for me but one annoying issue I&#8217;ve had to deal with because of this is <strong>the slow compilation speed</strong>: every time I make a small change into one of my projects and recompile it, the mxmlc compiler (that my build scripts are calling) has to load the JVM into memory and recompile my whole project from scratch, which obviously takes a while. Compiling things in Flex Builder is a lot faster, and the reason for that is <em><a href="http://labs.adobe.com/wiki/index.php/Flex_Compiler_Shell">the Flex Compiler Shell</a></em>, which it uses for compilation instead of mxmlc.
</p>
<div style="padding:4px;background:#eee;border:1px solid #ddd;">
<em><strong>Update (Version 0.5.1, Mar 17, 09):</strong></p>
<ul>
<li>Display a &#8220;compiling&#8230;&#8221; message before sending fcsh a compilation command in order to let the user know that something is going on and that they should wait instead of just killing the process.</li>
<li>If the log file exists when fcshctl runs, check if there are any other fcshctl instances running, and if not, assume that the log file has been orphaned, delete it and continue.</li>
<li>Exit with status code 0 (&#8220;ok&#8221;) if fcsh output ends in the <em>&#8220;Nothing has changed since the last compile&#8221;</em> message.</li>
</ul>
<p></em>
</div>
<p><span id="more-194"></span></p>
<div style="padding:4px;background:#eee;border:1px solid #ddd;">
<em><br />
<strong>Update (Version 0.5, Dec 10, 08):</strong></p>
<ul>
<li>Made it possible to specify a filename as the argument to the &#8220;clear&#8221; command &#8212; fcshctl will then try to find the first compile target id matching the specified filename and clear the corresponding id (example: &#8220;fcshctl clear MyApp.mxml&#8221;)</li>
<li>Made fcshctl find compile target ids corresponding to specific filenames or paths by asking fcsh directly via the &#8220;info&#8221; command instead of retaining them on its own in a temporary file (this is in order to avoid problems that could arise if this temp file and fcsh&#8217;s own list of retained compile target ids would get out of sync.)</li>
<li>Added command &#8220;id&#8221; which can be used to find the first compile target id matching a specified string (example: &#8220;fcshctl id MyApp.mxml&#8221;)</li>
</ul>
<p><strong>Update (Version 0.4, Nov 4, 08):</strong></p>
<ul>
<li>Made the script use only one logfile (i.e. one with a static path) and check its existence (and if it does exist, wait for it to be deleted) before continuing, so as to make sure no two fcshctl instances can try to send commands to fcsh at the same time, or before an already running command has finished executing and returned control to the prompt.</li>
</ul>
<p></em>
</div>
<p></p>
<p>
The basic idea behind the Flex Compiler Shell is that it would stay in memory between compilations (thus avoiding the cost of loading up the JVM every time you want to compile something) and use a technique called <strong>incremental compilation</strong> that, as the name suggests, is based on the idea of only compiling the parts of your project that have changed since the last compilation (thus making the process a lot faster). When you run the Flex Compiler Shell executable (called <em>fcsh</em>), you&#8217;re thrown into an interactive shell where you can run commands in order to compile your projects and control the operation of fcsh itself.
</p>
<h2>The Problem</h2>
<p>
When I found out about fcsh, tried it out and saw how much faster it was than mxmlc, of course I wanted to immediately start using it instead in my build scripts. The biggest problem with doing this, though, is the fact that <strong>the basic operation of these two programs is fundamentally different</strong>: when you run mxmlc, it compiles the project, prints some messages to standard output and then exits (with the exit status 0 if the compilation was successful or 1 if it wasn&#8217;t), which is perfect for integrating it into build scripts. Fcsh, on the other hand, throws you into a shell of its own and expects you to essentially operate it from within itself (instead of simply calling it with some arguments and then having it return with some standard output and an exit status like mxmlc).
</p>
<p>
The other issue that makes fcsh more difficult to use in general is that in order to use the incremental compilation feature, you have to first compile your project like you normally would (using the &#8220;mxmlc&#8221; command), then make note of the <em>&#8220;compile target id&#8221;</em> number that fcsh then assigns to this project and specifies in its output, and for future compilations use the &#8220;compile N&#8221; (where N is the compile target id) command.
</p>
<h2>The Solution</h2>
<p>
I tried to search for a solution to this problem that somebody else might have come up with but didn&#8217;t find an adequate one (a list of the ones that I could find is further down), so I decided to give it a shot myself. My approach, called <strong>fcshctl</strong> (short for &#8220;fcsh controller&#8221;), is basically a simple bash script that:</p>
<ol>
<li>starts the fcsh process if it isn&#8217;t already running</li>
<li>forwards its arguments to fcsh as commands</li>
<li>reads the output of that command from the fcsh interactive shell and prints it to the standard output</li>
<li>exits with status 0 (success) or >0 (failure)</li>
</ol>
<p>
In addition to this, I also made the script <strong>automatically and transparently invoke the incremental compilation feature</strong> whenever applicable so that I wouldn&#8217;t have to worry about keeping track of the compile target ids and using a different command for the compilation whenever one had already been assigned.
</p>
<p>
Below is a summarization of the pros and cons of this solution:
</p>
<h3>Pros:</h3>
<ul>
<li>It&#8217;s quite simple &#8212; just one shell script (a few others are included in the .zip that are only for convenience and not required)</li>
<li>It runs the fcsh instance in a <a href="http://www.gnu.org/software/screen/">GNU screen</a> session, which means that:</li>
<ul>
<li>The running fcsh instance is accessible to all user processes (i.e. not just within a single shell session, for example)</li>
<li>It is possible for the user to enter the running fcsh interactive shell at any time (by attaching to the screen session via the command <span style="font-family:monospace;">screen -r -S fcsh</span>) and manually interact with it</li>
</ul>
<li>It automatically checks whether you&#8217;ve compiled a specific file before and keeps track of the compile target ids that fcsh assigns so that it can automatically and transparently invoke the incremental compilation feature and let you access the speed gains that are fcsh&#8217;s main offering without any additional work. This feature can also be turned off by setting an environment variable.</li>
<li>A proxy script (called <span style="font-family:monospace;">fcshctl-mxmlc</span>) that can be used in place of mxmlc is provided. It simply calls fcshctl with <span style="font-family:monospace;">&#8220;mxmlc&#8221;</span> as the first argument, followed by all the other arguments you specify, so that you can simply use this script as a stand-in for mxmlc in any build scripts that you may be using without having to modify them any further.</li>
</ul>
<h3>Cons:</h3>
<ul>
<li>It uses the GNU screen logging mechanism and polling for changes in the log file in order to catch the output of commands sent to fcsh, which is not very elegant and causes a slowdown of maybe about a couple hundred milliseconds before the output is printed to stdout.</li>
<li>The output of the executed fcsh command is not printed to the standard output as it comes, but instead all at once when the command finishes (this is not a problem for me personally, but others might want to fix this).</li>
<li>It&#8217;s implemented as a bash script, which means that it&#8217;s not the fastest monster out there (we&#8217;re talking about milliseconds here, though, so it doesn&#8217;t bother me at all).</li>
</ul>
<h2>Download</h2>
<p>
You can download fcshctl here:</p>
<ul>
<li><strong><a href="/stuff/fcshctl/fcshctl-v0.5.1.zip">fcshctl-v0.5.1.zip</a> (latest)</strong></li>
<li><a href="/stuff/fcshctl/fcshctl-v0.5.zip">fcshctl-v0.5.zip</a></li>
<li><a href="/stuff/fcshctl/fcshctl-v0.4.zip">fcshctl-v0.4.zip</a></li>
<li><a href="/stuff/fcshctl/fcshctl-v0.3.zip">fcshctl-v0.3.zip</a></li>
</ul>
<p>
fcshctl has been tested with fcsh versions <em>3.0.0 build 477</em> and <em>3.1.0 build 2710</em> on Mac OS 10.5.5. It is licensed under <a href="http://hasseg.org/stuff/license/MIT_License.txt">the MIT License</a>.
</p>
<p>
The script requires the following to be in your <span style="font-family:monospace;">$PATH</span>: rm, mv, cat, ps, sleep, tail, head, grep, awk, screen, xargs and basename. <strong>You also need to have the <span style="font-family:monospace;">FLEX_HOME</span> environment variable set to point to the Flex SDK root path.</strong>
</p>
<h2>Example of use</h2>
<p><pre>
fcshctl $ export FLEX_HOME=/Users/username/code/SDKs/flex_sdk_3.1
fcshctl $
fcshctl $ ./fcshctl
<span style="color:blue;">
Usage: fcshctl &lt;commands&gt;

&nbsp;&nbsp;Substitute &lt;commands&gt; with any commands you
&nbsp;&nbsp;would like to send fcsh, just like you would
&nbsp;&nbsp;enter them in the interactive fcsh shell
&nbsp;&nbsp;session.

&nbsp;&nbsp;To get a list of the available commands, run:

&nbsp;&nbsp;&nbsp;&nbsp;fcshctl help
</span>
fcshctl $
fcshctl $ ./fcshctl help
<span style="color:blue;">List of fcsh commands:
mxmlc arg1 arg2 ...      full compilation and optimization; return a target id
compc arg1 arg2 ...      full SWC compilation
compile id               incremental compilation
clear [id]               clear target(s)
info [id]                display compile target info
quit                     quit</span>
fcshctl $
fcshctl $ ./fcshctl mxmlc ~/code/Flex/projects/testbed/testbed.mxml
<span style="color:blue;">Loading configuration file /Users/username/code/SDKs/flex_sdk_3.1/frameworks/flex-config.xml
Recompile: /Users/username/code/Flex/projects/testbed/testbed.mxml
Reason: The source file wasn't fully compiled.
Files changed: 0 Files affected: 1
/Users/username/code/Flex/projects/testbed/testbed.mxml(28):  Error: Incorrect number of arguments.  Expected 2.

&nbsp;&nbsp;&nbsp;&nbsp;func1("toka");
</span>
fcshctl $ echo $?
1
fcshctl $
fcshctl $
</pre>
</p>
<h2>Other similar solutions</h2>
<p>
Below is a list of other approaches to the problem of integrating fcsh to non-standard (i.e. non-Flex Builder) workflows (roughly in order from most promising to least promising), and short lists of reasons why I personally didn&#8217;t want to use them. If my solution doesn&#8217;t seem good to you, you should maybe check some of these out.
</p>
<p>
<a href="http://www.vim.org/scripts/script.php?script_id=1793">fcsh tools</a> by <em>Mike Rowe</em></p>
<ul>
<li>Runs fcsh in a daemonized process, which means you won&#8217;t be able to enter the interactive shell of a running fcsh process and manually interact with it</li>
<li>You can only specify the filename to compile; has no support for additional mxmlc arguments</li>
<li>For GNU/Linux (but seems to work just fine on OS X as well)</li>
</ul>
<p><a href="http://code.google.com/p/flex-compiler-shell-daemon/">flex-compiler-shell-daemon</a> by <em>Leonardo Soto Muños</em> (also see <a href="http://blog.leosoto.com/2008/10/flex-compiler-shell-daemon.html">his blog post about it</a>)</p>
<ul>
<li>I couldn&#8217;t get it to work out of the box on OS X</li>
<li>Runs fcsh in a daemonized process, which means you won&#8217;t be able to enter the interactive shell of a running fcsh process and manually interact with it</li>
</ul>
<p><a href="http://fcshwrapper.blogspot.com/">FCSH Wrapper</a> by <em>Mihai Vasilache</em></p>
<ul>
<li>For Windows</li>
<li>Designed to be used with Ant</li>
<li><a href="http://mihai.vasilache.googlepages.com/classDiagram.jpg">A bit complicated</a></li>
</ul>
<p><a href="http://code.google.com/p/fsch/">http://code.google.com/p/fsch/</a> by <em>nimrod97</em></p>
<ul>
<li>For Windows</li>
</ul>
<p><a href="http://zarkov.bigsource.de/front_content.php">BigSource Zarkov</a> by <em>BigSource GbR</em></p>
<ul>
<li>For Eclipse &#038; Ant</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/194/fcshctl-the-flex-compiler-shell-controller/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 Support for jEdit&#8217;s SideKick Plugin Through Exuberant Ctags</title>
		<link>http://hasseg.org/blog/post/101/actionscript-3-support-for-jedits-sidekick-plugin-through-exuberant-ctags/</link>
		<comments>http://hasseg.org/blog/post/101/actionscript-3-support-for-jedits-sidekick-plugin-through-exuberant-ctags/#comments</comments>
		<pubDate>Tue, 09 Oct 2007 12:49:04 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=101</guid>
		<description><![CDATA[Today VeryVito made a post on his blog that I had been waiting for a while now: he had just written ActionScript 3 support for Exuberant Ctags, which means proper SideKick plugin support for jEdit when editing AS3 with it. He also made nicer icons for use with the CtagsSideKick, so you should definitely check [...]]]></description>
			<content:encoded><![CDATA[<p>
Today VeryVito made a post on his blog that I had been waiting for a while now: he had just written <a href="http://www.turdhead.com/2007/10/09/almost-perfect-actionscript-code-browsing-with-jedits-sidekick-panel/">ActionScript 3 support</a> for <a href="http://ctags.sourceforge.net/">Exuberant Ctags</a>, which means proper SideKick plugin support for jEdit when editing AS3 with it. He also made nicer icons for use with the CtagsSideKick, so you should definitely <a href="http://www.turdhead.com/2007/10/09/almost-perfect-actionscript-code-browsing-with-jedits-sidekick-panel/">check his stuff out</a> if you use (or plan to use) jEdit for editing AS3.
</p>
<p>
However, after starting to use the SideKick plugin with the modified, AS3-supported version of Ctags while doing my work, I found a few small rough edges in the ActionScript support he had made:
</p>
<p><span id="more-101"></span></p>
<ul>
<li>Package names were not properly catched &#8211; only the first level was shown (e.g. &#8220;<em>org</em>&#8221; instead of &#8220;<em>org.hasseg.thingamabob</em>&#8220;)</li>
<li>Todo and note names were not properly catched &#8211; it just showed &#8220;<em>todo</em>&#8221; or &#8220;<em>note</em>&#8221; instead of what comes after</li>
<li>My &#8220;<em>todo:</em>&#8221; notes were not catched &#8211; it only supported uppercase (i.e. &#8220;<em>TODO:</em>&#8220;)</li>
<li>Some attribute keywords (<em>override</em>, <em>final</em>, <em>internal</em> etc&#8230;) were not allowed on classes, functions/methods and properties, so I was missing some of these in my SideKick listings</li>
</ul>
<p>Not big problems by any means, but for me these meant that SideKick wouldn&#8217;t display some of the stuff in my code, and if it did, not properly, so I fixed them.
</p>
<p>
Get my modified version of the AS3-supported Ctags here:
</p>
<p>
<a href="/stuff/AS3Ctags/ctags.zip">The ctags binary (zipped)</a> (<em>note: compiled on a rev.B MacBook (Core 2 Duo processor) with Mac OS 10.4.10</em>)
</p>
<p>
<a href="/stuff/AS3Ctags/actionscript.c">The source code (actionscript.c)</a>
</p>
<p>
You should refer to <a href="http://www.turdhead.com/2007/10/09/almost-perfect-actionscript-code-browsing-with-jedits-sidekick-panel/">VeryVito&#8217;s post</a> for more info this issue.
</p>
<p>
<em>Update (same day as original post): Improved this a bit. Find below a complete list of changes I&#8217;ve made (taken from the source code):</p>
<div class="codecolorer-container c mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">/*<br />
* - Added more allowed AS3 attribute keywords (override, final, internal <br />
* &nbsp; etc...) for classes, getters &amp; setters, variables<br />
* - Allowed varying versions of &quot;note&quot; and &quot;todo&quot; spellings<br />
* - Allowed points (.) in package names so that they would display the<br />
* &nbsp; whole package name instead of just the first level<br />
* - Added interfaces matching support<br />
* - Reformatted some name parameters:<br />
* - Getters and setters: display either &quot;get&quot; or &quot;set&quot; in front<br />
* &nbsp; of the property name<br />
* - Todos &amp; notes: made the name be the text that comes after the<br />
* &nbsp; &quot;todo&quot; or &quot;note&quot; text<br />
* - Variables: Moved the variable type after the name and separated<br />
* &nbsp; them with &quot; : &quot; according to ActionScript syntax<br />
*/</span></div></div>
<p></em></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/101/actionscript-3-support-for-jedits-sidekick-plugin-through-exuberant-ctags/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flex SDK Language Reference Helper Macro for jEdit</title>
		<link>http://hasseg.org/blog/post/98/flex-sdk-language-reference-helper-macro-for-jedit/</link>
		<comments>http://hasseg.org/blog/post/98/flex-sdk-language-reference-helper-macro-for-jedit/#comments</comments>
		<pubDate>Mon, 01 Oct 2007 15:12:07 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=98</guid>
		<description><![CDATA[VeryVito at turdhead.com has been writing lately about customizing jEdit for writing ActionScript, which is exactly what I&#8217;ve also been doing. A While ago he posted macros for referencing the help files that came with Flash CS3. Well, I don&#8217;t have Flash CS3, and I use the Flex SDK to do my ActionScripting, so I [...]]]></description>
			<content:encoded><![CDATA[<p>
VeryVito at <a href="http://www.turdhead.com">turdhead.com</a> has been writing lately about <a href="http://www.turdhead.com/jedit-and-actionscript-the-collected-files/">customizing jEdit for writing ActionScript</a>, which is exactly what I&#8217;ve also been doing. A While ago he posted <a href="http://www.turdhead.com/2007/09/30/more-actionscript-magic-for-jedit-context-sensitive-reference-material/">macros for referencing the help files</a> that came with Flash CS3. Well, I don&#8217;t have Flash CS3, and I use the Flex SDK to do my ActionScripting, so I took the macro he posted and modified it so that it can be used with the Flex language reference.
</p>
<p>
<em><b>Update (Oct 5, 07)</b>: Now it can search from any number of AsDoc sources</em><br />
<em><b>Update (Oct 8, 07)</b>: Also finds documentation for methods, changing the command for opening a file in a web browser is easier</em><br />
<em><b>Update (Oct 10, 07)</b>: now the script searches through files, not buffers, so you needn&#8217;t have all of your project&#8217;s files open for it to be able to search through them</em>
</p>
<p><span id="more-98"></span></p>
<p>
The way my version works is that it gets the selection from the current buffer (or if there&#8217;s no selection made, it selects the word that the caret is on top of) and searches the Flex SDK language reference for it. The files it goes through and the regular expressions + other logic that is used to do the pattern matching are designed so that it would work for class, package and method names.
</p>
<p>
Here&#8217;s the macro code (with some unnecessary whitespace removed):</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/*<br />
* Copyright (c) 2007 Ali Rantakari<br />
* <br />
* fromjeditflexlangrefmacro.20.hasseg@spamgourmet.com<br />
* http://hasseg.org<br />
* <br />
* Based on macros by VeryVito from turdhead.com :<br />
* http://www.turdhead.com/2007/09/30/more-actionscript-magic-for-jedit-context-sensitive-reference-material/<br />
* <br />
* thanks!<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* DESCRIPTION:<br />
* <br />
* A jEdit macro for displaying Flex SDK language reference documentation<br />
* for a selected class, package or method.<br />
* <br />
* Developed and tested only on OS X, no guarantee of this working on <br />
* other platforms.<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* REQUIRES:<br />
* <br />
* - jEdit<br />
* <br />
* - OPTIONAL: InfoViewer plugin for jEdit<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* USAGE:<br />
* <br />
* 1) Change the settings below to correspond to your system<br />
* <br />
* 2) Add this to your macros folder ( ~/.jedit/macros )<br />
* <br />
* 3) Bind it to a keyboard shortcut ( utilities -&gt; global options -&gt;<br />
* &nbsp; &nbsp;shortcuts -&gt; macros )<br />
* <br />
* 4) Place your pointer on the search term or select the search<br />
* &nbsp; &nbsp;term (an AS3/Flex class, package or method name)<br />
* <br />
* 5) Run the macro by pressing the shortcut you assigned (or from<br />
* &nbsp; &nbsp;the macros menu)<br />
* <br />
* ---------------------------------------------------------------------------<br />
* <br />
* Licensed under the MIT License:<br />
* <br />
* Permission is hereby granted, free of charge, to any person obtaining a copy<br />
* of this software and associated documentation files (the &quot;Software&quot;), to deal<br />
* in the Software without restriction, including without limitation the rights<br />
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br />
* copies of the Software, and to permit persons to whom the Software is<br />
* furnished to do so, subject to the following conditions:<br />
* <br />
* The above copyright notice and this permission notice shall be included in<br />
* all copies or substantial portions of the Software.<br />
* <br />
* THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br />
* THE SOFTWARE.<br />
*/</span><br />
<br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.regex.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.MessageFormat</span><span style="color: #339933;">;</span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// SETTINGS: --------------------------------------</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * Paths to AsDoc folders to search (in this order)<br />
&nbsp; &nbsp; * (with trailing slashes)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> foldersToCheck <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>&nbsp; &nbsp; <span style="color: #0000ff;">&quot;/Flex/flex201_documentation/langref/&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/Flex/SVN_working_copies/SSGUI-Flex/asdoc-output/&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * The files in the AsDoc folders to check (in this order)<br />
&nbsp; &nbsp; * (if they don't exist in all of the folders, no worries)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> filesToCheck <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>&nbsp; <span style="color: #0000ff;">&quot;all-classes.html&quot;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;class-list.html&quot;</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;package-summary.html&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * Whether to display the found documentation page<br />
&nbsp; &nbsp; * in the InfoViewer plugin or not (if not, the<br />
&nbsp; &nbsp; * openCommand (below) will be run in the console)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; displayInInfoViewer <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * The command to run in the console for opening<br />
&nbsp; &nbsp; * the found documentation file in, for example,<br />
&nbsp; &nbsp; * a web browser<br />
&nbsp; &nbsp; * <br />
&nbsp; &nbsp; * {0} will be substituted with the filename to open,<br />
&nbsp; &nbsp; * &nbsp; &nbsp; surrounded by double quotes (so don't add the<br />
&nbsp; &nbsp; * &nbsp; &nbsp; double quotes here)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; openCommand <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;open -a Safari {0}&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
<span style="color: #666666; font-style: italic;">// /settings - - - - - - - - - - - - - - - - - - - </span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// Macro implementation begins here: &nbsp;------------</span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// functions -------------------------------------</span><br />
<br />
<br />
<span style="color: #003399;">Vector</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> aDirectory, <span style="color: #003399;">String</span> aRegEx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">Vector</span> retVal <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Vector</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aDirectory <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aDirectory.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aDirectory.<span style="color: #006633;">isDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> files <span style="color: #339933;">=</span> aDirectory.<span style="color: #006633;">listFiles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> files.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">isFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">isHidden</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span>aRegEx<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>files<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aDirectory.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> is not a directory&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aDirectory.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> does not exist!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* Returns a Vector of HashMaps. Each HashMap contains a match, where<br />
* the keys are the specified group numbers and the values are the<br />
* corresponding strings.<br />
* <br />
* Returns null if no matches.<br />
*/</span><br />
<span style="color: #003399;">Vector</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aRegEx, <span style="color: #003399;">String</span> aFilePath, <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> aGroupsToReturn<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">Vector</span> retVal <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Vector</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Pattern regPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span>aRegEx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Matcher matcher<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">BufferedReader</span> bufr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>aFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bufr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span> <span style="color: #009900;">&#40;</span>aFilePath<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>record <span style="color: #339933;">=</span> bufr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matcher <span style="color: #339933;">=</span> regPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>matcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">HashMap</span> thisRetEntry <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> aGroupsToReturn.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; thisRetEntry.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>aGroupsToReturn<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>, matcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span>aGroupsToReturn<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>thisRetEntry<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">io</span>.<span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;An error occurred while trying to parse <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* Searches for the specified class or package name (aWordToFind) in<br />
* the AsDoc folders and files specified in the settings.<br />
* <br />
* Returns the documentation file path or null if not found.<br />
*/</span><br />
<span style="color: #003399;">String</span> searchForDocs<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aWordToFind<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> retVal <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> regEx <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;a.*href<span style="color: #000099; font-weight: bold;">\\</span>s*=<span style="color: #000099; font-weight: bold;">\\</span>s*<span style="color: #000099; font-weight: bold;">\&quot;</span>(.*?)<span style="color: #000099; font-weight: bold;">\&quot;</span>.*&gt;(&quot;</span><span style="color: #339933;">+</span>aWordToFind<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;)&lt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Pattern regPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span>regEx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Matcher matcher<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">BufferedReader</span> bufr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&lt;</span> foldersToCheck.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">&lt;</span> filesToCheck.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> thisFile <span style="color: #339933;">=</span> foldersToCheck<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>filesToCheck<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>thisFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bufr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span> <span style="color: #009900;">&#40;</span>thisFile<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>record <span style="color: #339933;">=</span> bufr.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; matcher <span style="color: #339933;">=</span> regPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>record<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>matcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> foldersToCheck<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> matcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>java.<span style="color: #006633;">io</span>.<span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;An error occurred while trying to parse <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>thisFile<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; j<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
* Give this a variable name and the path to the file where<br />
* it appears, and get the class name of the type<br />
* of the variable, or null if not found.<br />
*/</span><br />
<span style="color: #003399;">String</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> aVarName, <span style="color: #003399;">String</span> aFilePath<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> retVal <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>aFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">isFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnCurrentClassName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aVarName <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> returnCurrentClassName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>aVarName <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;this&quot;</span> <span style="color: #339933;">||</span> aVarName.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> returnCurrentClassName <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>returnCurrentClassName <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find first class name from specified file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> results <span style="color: #339933;">=</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>b(class)<span style="color: #000099; font-weight: bold;">\\</span>s+<span style="color: #000099; font-weight: bold;">\\</span>b(<span style="color: #000099; font-weight: bold;">\\</span>w+)<span style="color: #000099; font-weight: bold;">\\</span>b&quot;</span>, aFilePath, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>results.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> results.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find definition of specified variable from specified file</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> results <span style="color: #339933;">=</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.*(&quot;</span><span style="color: #339933;">+</span>aVarName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;)<span style="color: #000099; font-weight: bold;">\\</span>s*:<span style="color: #000099; font-weight: bold;">\\</span>s*(.*?)[;,=<span style="color: #000099; font-weight: bold;">\\</span>s<span style="color: #000099; font-weight: bold;">\\</span>)]+&quot;</span><span style="color: #009900;">&#41;</span>, aFilePath, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>results.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> results.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if file classname+&quot;class.as&quot; exists, prefer that class name</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> codeBehindMatches <span style="color: #339933;">=</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">+</span>retVal<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;Class<span style="color: #000099; font-weight: bold;">\\</span>.as$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>codeBehindMatches.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> retVal<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;Class&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if nothing found...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find superclass name (if there is one)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> results <span style="color: #339933;">=</span> regExSearchFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;class<span style="color: #000099; font-weight: bold;">\\</span>s+(.*?)<span style="color: #000099; font-weight: bold;">\\</span>s+extends<span style="color: #000099; font-weight: bold;">\\</span>s+(.*?)[;<span style="color: #000099; font-weight: bold;">\\</span>s]+&quot;</span><span style="color: #009900;">&#41;</span>, aFilePath, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>results.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> superClassName <span style="color: #339933;">=</span> results.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find source file for superclass (in the same dir)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span> superClassFile <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> straightMatches <span style="color: #339933;">=</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">+</span>superClassName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>.as$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Vector</span> codeBehindMatches <span style="color: #339933;">=</span> searchDirForFilesMatching<span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getParentFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;^&quot;</span><span style="color: #339933;">+</span>superClassName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;Class<span style="color: #000099; font-weight: bold;">\\</span>.as$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>codeBehindMatches.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> superClassFile <span style="color: #339933;">=</span> codeBehindMatches.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>straightMatches.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> superClassFile <span style="color: #339933;">=</span> straightMatches.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>superClassFile <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span>aVarName, superClassFile.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> is not a file!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;File <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>aFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> does not exist!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #003399;">String</span> getMethodOwner<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> functionName, <span style="color: #003399;">String</span> lineWhereItAppears<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> retVal <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> methodRegEx <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;((.+)<span style="color: #000099; font-weight: bold;">\\</span>s*<span style="color: #000099; font-weight: bold;">\\</span>.<span style="color: #000099; font-weight: bold;">\\</span>s*)?(&quot;</span><span style="color: #339933;">+</span>functionName<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;)<span style="color: #000099; font-weight: bold;">\\</span>s*<span style="color: #000099; font-weight: bold;">\\</span>((.*?)<span style="color: #000099; font-weight: bold;">\\</span>)&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Pattern methodRegPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span>methodRegEx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Matcher methodMatcher <span style="color: #339933;">=</span> methodRegPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>lineWhereItAppears<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodMatcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> methodMatcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> retVal.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if using a cast (e.g. &quot;MyClass(event.target).methodToSearchFor();&quot;)...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>retVal.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>retVal.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.*<span style="color: #000099; font-weight: bold;">\\</span>(.*<span style="color: #000099; font-weight: bold;">\\</span>)$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retVal <span style="color: #339933;">=</span> retVal.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #009900;">&#40;</span>retVal.<span style="color: #006633;">lastIndexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;(&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if 'inline'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; methodRegPat <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.+<span style="color: #000099; font-weight: bold;">\\</span>b(<span style="color: #000099; font-weight: bold;">\\</span>w+)$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; methodMatcher <span style="color: #339933;">=</span> methodRegPat.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>retVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodMatcher.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> methodMatcher.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retVal <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> retVal <span style="color: #339933;">=</span> retVal.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Macros.message(view, &quot;method owner variable is '&quot;+retVal+&quot;'&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> retVal<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// /functions - - - - - - - - - - - - - - - - - - - - -</span><br />
<br />
<br />
<br />
<span style="color: #003399;">String</span> foundDocFilePath <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the path to the documentation html file to display</span><br />
<br />
<span style="color: #666666; font-style: italic;">// run search on the word under cursor or the selected text</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>textArea.<span style="color: #006633;">selectedText</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; textArea.<span style="color: #006633;">goToPrevCharacter</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; textArea.<span style="color: #006633;">selectWord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #003399;">String</span> wordToFind <span style="color: #339933;">=</span> textArea.<span style="color: #006633;">selectedText</span><span style="color: #339933;">;</span><br />
foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>wordToFind<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// if nothing found, see if the selection is defined as a variable. </span><br />
<span style="color: #666666; font-style: italic;">// If it is, take variable's type and run a search on that</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> typeOfVar <span style="color: #339933;">=</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span>wordToFind, buffer.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>typeOfVar <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>typeOfVar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// if still nothing found...</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if selection is a function/method name, get its owner variable</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> methodOwnerVar <span style="color: #339933;">=</span> getMethodOwner<span style="color: #009900;">&#40;</span>wordToFind, textArea.<span style="color: #006633;">getLineText</span><span style="color: #009900;">&#40;</span>textArea.<span style="color: #006633;">getCaretLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodOwnerVar <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// if starts with an uppercase letter, probably a class name -&gt; try that</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodOwnerVar.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[A-Z]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>methodOwnerVar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>methodOwnerVar <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> methodOwnerVar <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;this&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// find type of this owner var and if found, search for that class</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> typeOfOwnerVar <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; typeOfOwnerVar <span style="color: #339933;">=</span> findTypeOfVarFromFile<span style="color: #009900;">&#40;</span>methodOwnerVar, buffer.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Macros.message(view, &quot;method owner type is '&quot;+typeOfOwnerVar+&quot;'&quot;);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>typeOfOwnerVar <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> searchForDocs<span style="color: #009900;">&#40;</span>typeOfOwnerVar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> foundDocFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">+</span>wordToFind<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>(<span style="color: #000099; font-weight: bold;">\\</span><span style="color: #000099; font-weight: bold;">\\</span>)&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// if found a doc URL, display it</span><br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>foundDocFilePath <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> &nbsp; &nbsp;<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>foundDocFilePath.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;file://&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> foundDocFilePath <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;file://&quot;</span><span style="color: #339933;">+</span>foundDocFilePath<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>displayInInfoViewer<span style="color: #009900;">&#41;</span> infoviewer.<span style="color: #006633;">InfoViewerPlugin</span>.<span style="color: #006633;">openURL</span><span style="color: #009900;">&#40;</span>view, foundDocFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> mfArgs <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>foundDocFilePath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; commandToRun <span style="color: #339933;">=</span> <span style="color: #003399;">MessageFormat</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>openCommand, mfArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; runInSystemShell<span style="color: #009900;">&#40;</span>view, commandToRun<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowDocked</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowVisible</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">removeDockableWindow</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;Sorry. No Flex documentation found for <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>wordToFind<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
<br />
Macro index data (in DocBook format)<br />
<br />
&nbsp; &lt;listitem&gt;<br />
&nbsp; &nbsp; &lt;para&gt;&lt;filename&gt;Display_Flex_documentation.bsh&lt;/filename&gt;&lt;/para&gt;<br />
&nbsp; &nbsp; &lt;abstract&gt;&lt;para&gt;<br />
&nbsp; &nbsp; &nbsp; Displays documentation about selected class, package or method from Flex language reference<br />
&nbsp; &nbsp; &nbsp; and optionally also other AsDoc sources<br />
&nbsp; &nbsp; &lt;/para&gt;&lt;/abstract&gt;<br />
&nbsp; &lt;/listitem&gt;<br />
<br />
*/</span><br />
<br />
<span style="color: #666666; font-style: italic;">// end Display_Flex_documentation.bsh</span></div></div>
</p>
<p>
As you can see from the settings, the macro can be set to open the documentation html page in either the InfoViewer plugin in jEdit or an external web browser. I prefer to have it open up in the browser, since the formatting and styling of the Flex language reference contribute to the fact that the pages don&#8217;t really work very well in the InfoViewer plugin. <del>The OS X <em>open</em> command is used to make the external browser open up the documentation, which means that if someone would want to use this in Windows or Linux, that part would have to be re-implemented.</del> <em>Update: Now you can simply edit the openCommand variable in the &#8220;settings&#8221; area to change the command that is run in the system shell to open up docs in the browser.</em>
</p>
<p>
Get the script here:
</p>
<p>
<a href="/stuff/jEditMacros/Display_Flex_documentation.bsh">Display_Flex_documentation.bsh</a>
</p>
<p>
<em>Update (October 5, 07): Modified the script so that it can search from any number of different AsDoc sources (which the official Flex language reference is one of)</em>
</p>
<p>
<em>Update (October 8, 07): Modified the script to also find documentation for methods. Made it easier to modify the command that is run in the system shell to open up documentation .html pages in an external browser.</em>
</p>
<p>
<em>Update (October 10, 07): Modified the script to operate on files instead of buffers so that it can also search files that are not currently open.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/98/flex-sdk-language-reference-helper-macro-for-jedit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jEdit Macros for Running Compilers</title>
		<link>http://hasseg.org/blog/post/96/jedit-macros-for-running-compilers/</link>
		<comments>http://hasseg.org/blog/post/96/jedit-macros-for-running-compilers/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 18:18:17 +0000</pubDate>
		<dc:creator>Ali Rantakari</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[jEdit]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://hasseg.org/blog/?p=96</guid>
		<description><![CDATA[I&#8217;ve been using jEdit as my ActionScript 3 editor for a while now. I Like the extension and customization possibilities it gives me, and I&#8217;ve used them to create macros for compiling my Flex applications and then bound them to specific keyboard shortcuts to enable quick access to running the compiler. For a while, I [...]]]></description>
			<content:encoded><![CDATA[<p>
<img align="right" style="padding-left: 5px;" src='http://hasseg.org/blog/wp-content/uploaded/2007/09/compilescriptgrowl.png' alt='compileMxml shell script displays Growl notifications' /> I&#8217;ve been using jEdit as my ActionScript 3 editor for a while now. I Like the extension and customization possibilities it gives me, and I&#8217;ve used them to create macros for compiling my Flex applications and then bound them to specific keyboard shortcuts to enable quick access to running the compiler.
</p>
<p><span id="more-96"></span></p>
<p>
For a while, I had the compiler command and the parameters (i.e. the file to compile) hardcoded in my macro, but recently I changed this to a more reusable solution where you have one macro for selecting the file (&#8220;buffer&#8221; in jEdit lingo) to be compiled and another for actually running the compiler on that file. Then I simply bind keystrokes for both of them. This enables me to easily and quickly run the compiler whenever I want to, and also change the file to be compiled (and, of course, also the compiler used – automatically based on the file extension) if I switch projects.
</p>
<p><h3>Select_file_to_compile.bsh</h3>
<p>First, let&#8217;s take a look at <em>Select_file_to_compile.bsh</em>, which is used to select the file (as you can see, it saves the file path into a jEdit property which the other script will later read):</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// SETTINGS: --------------------------------------</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* <br />
&nbsp; &nbsp; * set allowed file extensions here: (include leading point)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; allowedExtensions <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;.mxml&quot;</span>, <span style="color: #0000ff;">&quot;.java&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #666666; font-style: italic;">// /settings - - - - - - - - - - - - - - - - - - - </span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// Macro implementation begins here: &nbsp;------------</span><br />
<br />
currentBufferPath <span style="color: #339933;">=</span> jEdit.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;macro.compile_specific_buffer.buffer_path&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
allBuffers <span style="color: #339933;">=</span> jEdit.<span style="color: #006633;">getBuffers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
mxmlBuffers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span>allBuffers.<span style="color: #006633;">length</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">int</span> currentlySelectedIndex <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> allBuffers.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">Boolean</span> extensionMatch <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> k <span style="color: #339933;">&lt;</span> allowedExtensions.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> k<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>allBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span>allowedExtensions<span style="color: #009900;">&#91;</span>k<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> extensionMatch <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>extensionMatch <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentBufferPath.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>allBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> currentlySelectedIndex <span style="color: #339933;">=</span> j<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mxmlBuffers<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> allBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;Can not find any open buffers with the specified extensions!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; listItems <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> j<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> listItems<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> mxmlBuffers<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; result <span style="color: #339933;">=</span> <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">showInputDialog</span><span style="color: #009900;">&#40;</span>view,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;Choose which file to pass to the compiler the next time you run the compile macro:&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;Select file to compile&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">QUESTION_MESSAGE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">null</span>, listItems, listItems<span style="color: #009900;">&#91;</span>currentlySelectedIndex<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>result <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> jEdit.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;macro.compile_specific_buffer.buffer_path&quot;</span>, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></div>
</p>
<p><h3>Compile_previously_selected_file.bsh</h3>
<p>Then there&#8217;s <em>Compile_previously_selected_file.bsh</em> which invokes the compiling process. Notice the <em>displayDockedConsole</em> parameter in the settings – a <em>false</em> value will make sure that the Console plugin will not open up whenever the compiling starts. I Want to keep it closed because I don&#8217;t make this macro call the mxml compiler directly, but instead through a bash shell script (<em>compileMxml.bash</em> – link below) that displays a <a href="http://growl.info/">Growl</a> notification whenever the compiling finishes, telling me whether or not the application was compiled successfully. In case of errors, the notification will be sticky, so that if I leave my computer to compile and then come back later, I&#8217;ll still be able to see it.</p>
<div class="codecolorer-container java mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// SETTINGS: --------------------------------------</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* <br />
&nbsp; &nbsp; * match file extensions and compilers here (no <br />
&nbsp; &nbsp; * trailing space after compiler command):<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; compilers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">HashMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; compilers.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.mxml&quot;</span>, <span style="color: #0000ff;">&quot;/path/to/flex/sdk/bin/mxmlc --file-specs&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; compilers.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.java&quot;</span>, <span style="color: #0000ff;">&quot;/path/to/java/sdk/bin/javac &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; * whether or not to display the console when compiling<br />
&nbsp; &nbsp; * (only works if the console is docked)<br />
&nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; displayDockedConsole <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #666666; font-style: italic;">// /settings - - - - - - - - - - - - - - - - - - - </span><br />
<br />
<br />
<br />
<span style="color: #666666; font-style: italic;">// Macro implementation begins here: &nbsp;------------</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>compilers.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;No compilers specified!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; theBufferPath <span style="color: #339933;">=</span> jEdit.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;macro.compile_specific_buffer.buffer_path&quot;</span>,<span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; compilerCommand <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; extensions <span style="color: #339933;">=</span> compilers.<span style="color: #006633;">keySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> extensions.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>theBufferPath.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span>extensions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> compilerCommand <span style="color: #339933;">=</span> compilers.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>extensions<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>theBufferPath.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;No file has been specified to be compiled! Use the <span style="color: #000099; font-weight: bold;">\&quot;</span>Select_file_to_compile<span style="color: #000099; font-weight: bold;">\&quot;</span> macro to specify it.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>compilerCommand.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Macros.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span>view, <span style="color: #0000ff;">&quot;No compiler set for this file extension! <span style="color: #000099; font-weight: bold;">\n</span>(file path: <span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>theBufferPath<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; os <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;os.name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>os.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Windows&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> path <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">+</span> path <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; clearConsole<span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; runInSystemShell<span style="color: #009900;">&#40;</span>view, compilerCommand <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> theBufferPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>displayDockedConsole <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowDocked</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDockableWindowVisible</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; view.<span style="color: #006633;">getDockableWindowManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">removeDockableWindow</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;console&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span></div></div>
</p>
<p><h3>Download scripts</h3>
<ul>
<li>Get the jEdit macros here: <a href="/stuff/jEditMacros/jEditCompileMacros.zip">jEditCompileMacros.zip</a></li>
<p>Install them by saving them to jEdit&#8217;s macros directory. Then you can go to &#8220;utilities&#8221; -> &#8220;global options&#8221; -> &#8220;shortcuts&#8221; -> &#8220;macros&#8221; to set the keyboard shortcuts. In Mac OS X, the jEdit macros folder can be found here:</p>
<div class="codecolorer-container text mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">~/.jEdit/macros/</div></div>
<p>Please also note that you need the Console plugin for jEdit for this to work. Go to &#8220;plugins&#8221; -> &#8220;plugin manager&#8221; -> &#8220;install&#8221; to get it.</p>
<li>Get the mxml compiler shell script (+ the icon images used in the Growl notifications it displays) here: <a href="/stuff/compileMxmlScript/compileMxml.zip">compileMxml.zip</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://hasseg.org/blog/post/96/jedit-macros-for-running-compilers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

