<?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>netCUBED Blog &#187; completion</title>
	<atom:link href="http://blog.netcubed.de/tag/completion/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.netcubed.de</link>
	<description>Just another web developer's weblog</description>
	<lastBuildDate>Mon, 29 Jun 2009 20:58:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Perl autocompletion of methods for TextMate</title>
		<link>http://blog.netcubed.de/2009/06/perl-autocompletion-of-methods-for-textmate/</link>
		<comments>http://blog.netcubed.de/2009/06/perl-autocompletion-of-methods-for-textmate/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 08:26:01 +0000</pubDate>
		<dc:creator>Moritz Onken</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[auto completion]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[completion]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://blog.netcubed.de/?p=120</guid>
		<description><![CDATA[It is pretty hard to write a code completion script for perl since it&#8217;s hard to find out of which type a variable is. I use simple regexes and a comment to achieve this. Here is how it looks like:
It consists of a perl script which reads the current file from STDIN and gets the [...]]]></description>
			<content:encoded><![CDATA[<span class='flash'><span id='flash-perl-autocompletion-of-methods-for-textmate1.58507612528E+37'></span></span>
<script type='text/javascript'>
var params = {
allowfullscreen: 'true'
};var flashvars = null
swfobject.embedSWF('http://blog.netcubed.de/wp-content/uploads/2009/06/2009-06-10_1002.swf', 'flash-perl-autocompletion-of-methods-for-textmate1.58507612528E+37', '574', '474', '9.0.0', '', flashvars, params, '');
</script>
<p>It is pretty hard to write a code completion script for perl since it&#8217;s hard to find out of which type a variable is. I use simple regexes and a comment to achieve this. Here is how it looks like:</p>
<p>It consists of a perl script which reads the current file from STDIN and gets the current line number as well as the cursor position in that line. The script is run if the cursor is behind a <code>-&gt;</code> and the string before that looks like a class or a variable. If it&#8217;s a variable the script travels the lines up until it finds something like <code>$var = Class->new</code>, <code>$var = new Class</code> or <code> # $var isa Class</code>.</p>
<p><code>Class::MOP::Class</code> loads that class and retrieves all method names. It also evaluates the prefix which has been entered behind the <code>-></code> and displays those methods only which have the same prefix. Private methods are moved to the buttom as well as capitalized method names.</p>
<p>The second part of this script is embedded in TextMate. TextMate allows to define custom commands. You can define how the data shoud be rendered depending on the return value of the script. In this case STDERR is printed directly into the editor (if there is only one method left) and STDOUT is printed as tool tip.</p>
<p>I&#8217;d like to hear what you think about it and whether there are better / other approaches. I should probably use PPI instead of regexes to parse the document. This is one of the reasons why I did not release any code yet. Another shortcoming is speed. Especially for large classes like Catalyst or DateTime it takes a noticeable time until you get the results.</p>
<p>So long&#8230; I&#8217;ll keep you posted.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.netcubed.de/2009/06/perl-autocompletion-of-methods-for-textmate/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
