<?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>Orion PHP Editor</title>
	<atom:link href="http://orion.gusak.eu/feed/" rel="self" type="application/rss+xml" />
	<link>http://orion.gusak.eu</link>
	<description>GSoC 2011 Project</description>
	<lastBuildDate>Sun, 21 Aug 2011 13:14:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GSoC 2011 – general summary</title>
		<link>http://orion.gusak.eu/2011/08/gsoc-2011-%e2%80%93-general-summary/</link>
		<comments>http://orion.gusak.eu/2011/08/gsoc-2011-%e2%80%93-general-summary/#comments</comments>
		<pubDate>Sun, 21 Aug 2011 13:14:52 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[summary]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=453</guid>
		<description><![CDATA[As the Google Summer of Code 2011 is coming to an end tomorrow (22.08.2011, see the timeline), I&#8217;d like to summarize the last three months of my adventure with GSoC. I won&#8217;t come into much details of my project as I recently prepared a few posts that come into all the bits and pieces (Installing [...]]]></description>
			<content:encoded><![CDATA[<p>As the Google Summer of Code 2011 is coming to an end tomorrow (22.08.2011, see the <a href="http://socghop.appspot.com/gsoc/events/google/gsoc2011">timeline</a>), I&#8217;d like to summarize the last three months of my adventure with GSoC. I won&#8217;t come into much details of my project as I recently prepared a few posts that come into all the bits and pieces (<a href="http://orion.gusak.eu/2011/08/installing-orion-php-editor-features/">Installing Orion PHP editor features</a>, <a href="http://orion.gusak.eu/2011/08/what-to-watch-for-while-implementing-an-orion-plugin/">What to watch for while implementing an Orion plugin</a>, and <a href="http://orion.gusak.eu/2011/08/documentation-for-orion-php-editor-plugin/">Documentation for Orion PHP Editor plugin</a>). But for those of you who are new on my blog, I&#8217;d like to say just few words about the project.</p>
<p>So my project&#8217;s goal was to develop a plugin with the most important PHP editor features for Orion. To summarize in one sentence what is <a href="http://wiki.eclipse.org/Orion">Orion</a> I&#8217;d say that it&#8217;s the Eclipse Platform for the web. Of course this is still an exaggeration as Orion is a very young Eclipse project. But even on this early stage Orion has a better online source code editor than any other web IDE over there, in my opinion. And my plugin adds a support for editing PHP files into this editor.</p>
<p>Together with my mentor Jacek, yet back in the proposal stage we defined as list of features PHP editor should have and prioritized them. Then we decided that it&#8217;ll better to actually pick up few big features and work on the than to fragment my time for many small and not so important ones. And so we&#8217;ve chosen three of them: syntax highlighting, code validation, and content assist.</p>
<p>After implementing these features I think it was the right choice &#8211; the PHP editor actually seems to be pretty usable already. Of course many things are lacking, and some bugs were detected on Orion side. Many of them were fixed my Mark, and for some I even prepared patches which are now integrated with the trunk ;-). I described the problems that still exist in the blog posts linked above.</p>
<p>GSoC 2011 was a great learning experience for me. I got to know a lot about the Eclipse Foundation, and the whole ecosystem, how the open source code is being developed, what tools are used, etc. I of course got to know many things about the Orion itself. I&#8217;d like to recommend any student to participate in Google Summer of Code, especially under the wings of the Eclipse Foundation :-).</p>
<p>I&#8217;d like to thank my mentor <a href="http://jacekonthings.blogspot.com/">Jacek Pospychala</a> for being very helpful when all the GSoC coding took off and even before it. Also I&#8217;m very thankful for Orion developers for the help I received many times on orion-dev mailing list as well as on the Bugzilla (big thanks to Mark who was promptly responding to my ramblings on it and who actually turned my patches to an usable form ;-)).</p>
<p>Thank you!</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/08/gsoc-2011-%e2%80%93-general-summary/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Documentation for Orion PHP Editor plugin</title>
		<link>http://orion.gusak.eu/2011/08/documentation-for-orion-php-editor-plugin/</link>
		<comments>http://orion.gusak.eu/2011/08/documentation-for-orion-php-editor-plugin/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 14:22:43 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[Various Orion Topics]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[gsoc]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=419</guid>
		<description><![CDATA[This blog post serves as a documentation for everyone who wants to know more about the Orion PHP Editor plugin which was developed by me as a Google Summer of Code 2011 project. Please note that it&#8217;d be reasonable if you read the problems post first. If you&#8217;d like to know even more details, feel [...]]]></description>
			<content:encoded><![CDATA[<p>This blog post serves as a documentation for everyone who wants to know more about the Orion PHP Editor plugin which was developed by me as a Google Summer of Code 2011 project. Please note that it&#8217;d be reasonable if you read the <a href="http://orion.gusak.eu/2011/08/what-to-watch-for-while-implementing-an-orion-plugin/">problems post</a> first. If you&#8217;d like to know even more details, feel free to read the <a href="http://orion.gusak.eu/tag/summary/">weekly status reports</a> :-).</p>
<h2>Syntax Highlighting</h2>
<p><b>TextMate grammars</b></p>
<p>Orion uses a grammar-file based syntax highlighting. The TextMate&#8217;s syntax highlighting system is the role model for Orion&#8217;s implementation. Not the whole TextMate&#8217;s grammar file&#8217;s syntax is supported, but the most important parts are. The grammars are defined as .js files in Orion, as opposed to .plist files in TextMate, and are much more readable in general. The grammar rules are used to select some parts of the text buffer, to which a CSS style is attached afterwards. They are applied in a hierarchical manner, so for example is the style name is <em>.keyword-control-exception-php</em>, all of the <em>.keyword-control-exception</em>, <em>.keyword-control</em>, <em>.keyword</em> will be also applied. This is great as you can both define a detailed language-specific styles and reuse the preexisting, general ones too. You can read more about the TextMate grammars on it&#8217;s <a href="http://manual.macromates.com/en/language_grammars">manual</a> and <a href="http://blog.macromates.com/2005/language-grammars/">blog</a>, as most of the specification applies to Orion. If you want to see the existing grammar files, take a look at their <a href="https://github.com/textmate/">github repo</a>.</p>
<p><b>Your own grammar rules in Orion</b></p>
<p>To add syntax highlighting to your own language of choice, you need to create a grammar file. It looks like <a href="https://github.com/kgusak/orion-php-editor/blob/master/orion-client-php-plugin/org.eclipse.orion.client.editor/web/orion/editor/phpGrammar.js">this one</a>. Name it <em>[lang]Grammar.js</em> (for example <em>phpGrammar.js</em>). The rules themselves can be almost directly copied from corresponding TextMate file. Just keep in mind the differences between Oniguruma and JavaScript&#8217;s regex engine, escape the special symbols etc.</p>
<p>Another important file is your plugin.html file, which looks like <a href="https://github.com/kgusak/orion-php-editor/blob/master/orion-client-php-plugin/org.eclipse.orion.client.core/web/plugins/phpEditingPlugin.html">this one</a>. You need to register you grammar file. In my example the registration part is commented out, as in order to get the multi-mode syntax highlighting (PHP in HTML) I needed to modify HtmlGrammar to actually hande .php files. More about later.</p>
<p>This is how simple grammar rules converted from TextMate look like in <em>phpGrammar.js</em>:</p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/08/Selection_038.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/08/Selection_038.png" alt="" title="Grammar rules for PHP variables" width="587" height="260" class="aligncenter size-full wp-image-444" /></a></p>
<p><b>Bugs and multi-mode highlighting</b></p>
<p>You can read about the bugs related to syntax highlighting that are still open, on the blog post I linked in entry paragraph. I provided a patch for one important feature which is now in trunk thanks to Mark, namely multi-mode syntax highlighting. It&#8217;s about a possibility to highlight PHP mixed with HTML, JS within HTML and so on. In TextMate, to highlight one language within another, a concept of external references is used. For example, HTML grammar defines a rule for catching the PHP open / close tags, for which it then includes PHP grammar. It&#8217;s a problematic solution as HTML grammar has to &#8220;know&#8221; about all the languages it wants to include, so it&#8217;s not very plugin-friendly. This is why I had to modify HTML grammar to test this feature. But this is how it works in TextMate.</p>
<p>Look at my modified <a href="https://github.com/kgusak/orion-php-editor/blob/master/orion-client-php-plugin/org.eclipse.orion.client.editor/web/orion/editor/htmlGrammar.js">htmlGrammar.js</a> file to see how to use external references.</p>
<h2>Content Assist</h2>
<p><b>How it works in Orion</b></p>
<p>Orion has a concept of content assist proposals providers. You have to register your own proposal which has to follow pretty straightforward API. Take a look at <a href="https://github.com/kgusak/orion-php-editor/blob/master/orion-client-php-plugin/org.eclipse.orion.client.editor/web/orion/editor/phpContentAssist.js">phpContentAssist.js</a> file. Please note that this provider retrieves it&#8217;s proposals from the server side, where a <a href="http://www.eclipse.org/projects/project.php?id=tools.pdt">PDT</a> installation resides.</p>
<p>The real work is done on the server side, in <a href="https://github.com/kgusak/orion-php-editor/blob/master/orion-server-php-plugin/eu.gusak.orion.php/src/eu/gusak/orion/php/servlets/PhpServlet.java">PhpServlet</a>. Most of the work is initializing and configuring PDT, but if you look into getProposalInfo() method you may notice a specific structure which is being returned (it&#8217;s later converted to JSON). It&#8217;s for the <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346409">Linked Mode</a> feature that I provided a patch for some time ago. If the proposal is a method, and has parameters, their&#8217;s offsets and lengths are provided and Orion will set up the Linked Mode &#8211; pressing tab will switch between these parameters in a cyclic manner.</p>
<p>Please note that Orion supports many content assist providers for one file. So as long as your provider can handle multiple-languages soup, it&#8217;s not a problem at all to create for example PHP content assistance for PHP embedded code snippets, and HTML content assistance for the rest of the code, in one file.</p>
<h2>Code Validation</h2>
<p>Code Validation has similar architecture as Content Assist in Orion. You have to register your provider, and you can register many providers for one file type. The extension point is called <em>orion.edit.validator</em>. The <a href="https://github.com/kgusak/orion-php-editor/blob/master/orion-client-php-plugin/org.eclipse.orion.client.editor/web/orion/editor/phpValidator.js">phpValidator.js</a> file is very simple as the real validation is done at the server, using PDT. You can find the corresponding code in <em>PhpServlet</em> I linked above.</p>
<p>The code for registering a problem provider is very simple and looks like this:</p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/08/Selection_037.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/08/Selection_037.png" alt="" title="Registering problem provider" width="531" height="126" class="aligncenter size-full wp-image-441" /></a></p>
<h2>Other</h2>
<p>During the whole coding period I was regularly updating my test Orion installation. You can see and test the plugin features by yourself, live, for free. Check out <a href="http://orion.gusak.eu/2011/06/orion-test-installation/">this post</a> for details. :-)</p>
<p>So, this is relatively brief summary of the plugin&#8217;s internals and features, but I think it&#8217;s a good start for anyone who wants to develop a custom plugin or maybe build upon this one, etc. You can find much more details in the status report posts I was writing every week. Feel free to browse this blog and ask questions if something is not clear. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/08/documentation-for-orion-php-editor-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>What to watch for while implementing an Orion plugin</title>
		<link>http://orion.gusak.eu/2011/08/what-to-watch-for-while-implementing-an-orion-plugin/</link>
		<comments>http://orion.gusak.eu/2011/08/what-to-watch-for-while-implementing-an-orion-plugin/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 12:04:28 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[Various Orion Topics]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[problems]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=405</guid>
		<description><![CDATA[Orion is still a very new Eclipse Foundation project so if you plan to implement a plugin for it, you have to be prepared for various problems and obstacles. After three months of work on Orion PHP editor plugin, I got to experience some of them. I&#8217;d like to share my knowledge with you to [...]]]></description>
			<content:encoded><![CDATA[<p>Orion is still a very new Eclipse Foundation project so if you plan to implement a plugin for it, you have to be prepared for various problems and obstacles. After three months of work on Orion PHP editor plugin, I got to experience some of them. I&#8217;d like to share my knowledge with you to let you develop your plugin quickly and more easily :-).</p>
<p><strong>Bugs</strong></p>
<p>First things first, these are some bugs I experienced. They can be on your way too especially if you want to develop a plugin to add support for a new language. Please note that most of these problems will probably be fixed in not so far future by Orion devs. These are the ones that still exists:</p>
<ul>
<li><b>Begin/End patterns are buggy in TextMateStyler (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=345191">#345191</a>)</b> &#8211; this is a very important bug in syntax highlighting in Orion. If you use begin/end patterns in your grammar file (which is a very commonly used feature), the styler might colorize the code incorrectly on change. So, when you just load the editor, the syntax is highlighted correctly. But when you start adding and removing lines, the repairer is <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=345191#c3">getting confused</a> a little bit. Currently refreshing the page helps.</li>
<li><b>You cannot attach your own CSS style to the editor (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=347493">#347493</a>)</b> &#8211; as you may read in the bug comments on bugzilla, Orion supports multiple CSS styles but you cannot attach them yet from plugin&#8217;s perspective. So, to add your own syntax-highlighting style, you have to edit default-theme.css file directly.</li>
<li><b>Content assist proposal can be placed in a wrong place if you move the caret (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350494">#350494</a>)</b> &#8211; If you invoke CA, then move your caret (using mouse), and then choose the proposal, it&#8217;ll be placed in the new caret&#8217;s position. Instead the proposal window should disappear. This problem will be fixed when TextView will provide mouse-click event.</li>
<li><b>TextMateStyler doesn&#8217;t support a case insensitive flag (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=348347">#348347</a>)</b> &#8211; the (?i) flag is very commonly used in TextMate grammar rules. Currently TextMateStyler doesn&#8217;t support that yet.</li>
<li><b>Completion prefix is computed incorrectly in some cases (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=352756">#352756</a>)</b> &#8211; If your language uses some kind of special character, like PHP uses a dollar sign for variables, Orion may compute a completion prefix incorrectly. As a result, instead of inserting $var for example, it&#8217;ll insert $$var.</li>
<li><b>Content assist feature may behave unfamiliar on Backspace key (<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=352782">#352782</a>)</b> &#8211; When you have your completion window opened, and you tap a Backspace key, the proposals will be shown even if you move to the line above etc. The completion window should be canceled at some point.</li>
</ul>
<p><b>Various problems</b></p>
<p>Below are problems that are not strict bugs, but provided me a headache many times during development of my plugin. Please note that these are from perspective of a JavaScript as well as Eclipse newbie. If something is illogical here, please let me know :).</p>
<ul>
<li><b>Plugin not loading, blank screen, etc</b> &#8211; Sometimes when I changed something in the code and wanted to test it out, I was experiencing problems with loading the changes or Orion itself. It can be a black screen, plugin not listed in the plugins list (so not loaded), or &#8220;old&#8221; behavior even if the plugin seems to be listed. My advices are as follows. Double check all the edited files. Make sure they are in correct place and that you&#8217;re not doing something stupid ;). Invoke <strong>localStorage.clear()</strong> in your browser&#8217;s JS console. Many times, just in case ;P. If the problem persists, use all the clear-cache options your browser have (also just in case). Test if the problem occurs in another browser. Hit hard refresh many times.</li>
<li><b>Orion is not fully loading (grey sidebar and empty editor visible)</b> &#8211; This is what I experience actually every single time when I invoke <strong>localStorage.clear()</strong>. Just hit the hard refresh button (e.g. CTRL+F5) many times. Like 10 times. It&#8217;ll eventually catch on. Note that if you&#8217;ve changed just one file, and you know the webroot location for it, you may just open it in your browser and refresh so it&#8217;s redownloaded. Then just refresh the Orion window &#8211; no need to clear the local storage. However, the plugin files you include in your plugin.html file won&#8217;t refresh that way.</li>
<li><b>Orion server doesn&#8217;t work correctly even if all dependencies are satisfied</b> &#8211; if you&#8217;re experimenting with your own server-side bundles, and want to run it using Eclipse Platform as described on Orion wiki, you may need to change the run configuration to not use features but individual bundles (to include yours). If it&#8217;s the case, don&#8217;t trust the &#8220;Select required bundles&#8221; option of Eclipse. It won&#8217;t select dojox bundle for example. Check the list and select the ones that were in Orion target platform but are not selected. Also if you&#8217;re hacking on Orion bundles, make sure that you run it against the most recent target platform! If everything fails, don&#8217;t forget about the debug trace feature of Eclipse plugins (.options file), turn it on.</li>
</ul>
<p>Your problem may me known on <a href="https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&#038;bug_status=UNCONFIRMED&#038;bug_status=NEW&#038;bug_status=ASSIGNED&#038;bug_status=REOPENED&#038;product=E4&#038;component=Orion">bugzilla</a>. Check there first. If nothing helps, ask on <a href="https://dev.eclipse.org/mailman/listinfo/orion-dev">orion-dev</a> mailing list. They will know the answer, just be patient.</p>
<p>PS: if you want to browse the Orion source code online, these are valid links for <a href="http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/">client</a> and <a href="http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/">server</a>. Make sure you&#8217;re not browsing or pulling from the old repositories, from e4.</p>
<p>Good luck! :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/08/what-to-watch-for-while-implementing-an-orion-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing Orion PHP editor features</title>
		<link>http://orion.gusak.eu/2011/08/installing-orion-php-editor-features/</link>
		<comments>http://orion.gusak.eu/2011/08/installing-orion-php-editor-features/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 10:24:59 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[Various Orion Topics]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[oriondemo]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=396</guid>
		<description><![CDATA[You can always test the Orion PHP editor features on my oriondemo test installation. But if it&#8217;s not enough for you and you&#8217;d like to install Orion PHP editor features on your own machine, I&#8217;ve prepared a detailed installation instructions for you. I don&#8217;t want to repost them here as they&#8217;d quickly become obsolete. You [...]]]></description>
			<content:encoded><![CDATA[<p>You can always test the Orion PHP editor features on my <a href="http://orion.gusak.eu/2011/06/orion-test-installation/">oriondemo test installation</a>. But if it&#8217;s not enough for you and you&#8217;d like to install Orion PHP editor features on your own machine, I&#8217;ve prepared a detailed installation instructions for you. I don&#8217;t want to repost them here as they&#8217;d quickly become obsolete. You can find the always most recent instructions at <a href="https://github.com/kgusak/orion-php-editor"><strong>github repo</strong></a>. The direct link: <a href="https://github.com/kgusak/orion-php-editor/blob/master/README"><strong>README file</strong></a>.</p>
<p>Just make sure that you know how to install Orion on your own machine, how to use OSGi console and Eclipse plugins. My goal was to create as simple instructions as possible, but some problems can get complicated anyway. Also make sure that you&#8217;re using the correct version of Orion (too new is also bad as Orion is still evolving rapidly, so the plugin might be not compatible).</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/08/installing-orion-php-editor-features/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 – Status Report – August 10th</title>
		<link>http://orion.gusak.eu/2011/08/gsoc-2011-%e2%80%93-status-report-%e2%80%93-august-10th/</link>
		<comments>http://orion.gusak.eu/2011/08/gsoc-2011-%e2%80%93-status-report-%e2%80%93-august-10th/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 21:08:21 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[pdt]]></category>
		<category><![CDATA[summary]]></category>
		<category><![CDATA[syntax highlighting]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=373</guid>
		<description><![CDATA[For this week I planned to work on the multi-mode syntax highlighting feature I started previously. I changed the htmlGrammar.js to make it use (include) phpGrammar.js for anything that is inside PHP tags. Then I updated my modifications to textMateStyler.js file to make it remember the included grammars for reuse purposes. I was very surprised [...]]]></description>
			<content:encoded><![CDATA[<p>For this week I planned to work on the multi-mode syntax highlighting feature I started previously. I changed the <em>htmlGrammar.js</em> to make it use (include) <em>phpGrammar.js</em> for anything that is inside PHP tags. Then I updated my modifications to <em>textMateStyler.js</em> file to make it remember the included grammars for reuse purposes. I was very surprised that it actually started to work right away. The Orion design is very nice and modular. :)</p>
<p>After some tests I got back to the modified files to add some comments and make the code clean. I also looked into the CSS file modifications and other modifications related to the particular syntax highlighting plugin, PHP syntax highlight. These parts of the code are not required for using the multi-mode syntax highlighting feature, but I wanted to prepare a separate patch for that so anyone interested can see how to utilize this new feature.</p>
<p>Then after my mentor&#8217;s advice I&#8217;ve took a look into a content assist feature. Can it cooperate with the new mutli-mode syntax highlighting? How will it know what part of the code is relevant? Well, thanks to Orion design it&#8217;s very easy to attach multiple content assist providers to one file format. As the <em>phpContentAssist</em> is already attached to <em>.php</em> files by my plugin, it started to work right away. That was a nice surprise! :) It&#8217;s because the PDT has totally no problem with handling PHP-HTML mix. It just doesn&#8217;t suggest any proposals for non-php code.</p>
<p>I was experiencing some problems with opening PHP files in the Orion editor after applying the modifications. The browser wanted to download the file instead of showing it on the website. This happens when the editor is not configured to handle this particular file format. But I did configure it to open <em>.php</em> files, and the problem still persisted. As later came out, the problem was probably in the browser cache mechanism (I&#8217;m still not sure the <em>localStorage.clear()</em> didn&#8217;t work that time, but after cleaning some other cache options in the browser it started to work).</p>
<p>After solving this problem out, I updated my <a href="http://oriondemo.gusak.eu:8080">oriondemo</a> installation. You can test the latest changes there by yourself. I also prepared two patches &#8211; one with the language agnostic multi-mode syntax highlighting feature, and another one with php-specific modifications. The latter one was not meant to be applied to Orion trunk of course, it was more like a reference for anyone to use.</p>
<p>This is the screenshot of multi-mode syntax highlighting. Oh, and the code validation feature works too:</p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/08/Selection_036.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/08/Selection_036.png" alt="Multi-mode syntax highlighting, with code validation" title="Selection_036" width="587" height="416" class="aligncenter size-full wp-image-390" /></a></p>
<p>The nice thing about doing patches is that eventually someone will use them ;). Mark applied my last two patches, one for  better <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350351#c6">content assist panel</a>, and one for the <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=348918#c9">multi-mode syntax highlighting</a> I&#8217;ve just written about. Of course he modified them, added test cases etc, but I&#8217;m glad it came in useful :).</p>
<p>As you might have notice, this blog report is a little bit late (I used to post them on Sundays). It&#8217;s because I just moved to Sweden and I had to do (and still have) a lot of stuff to organize my life here and prepare for studies. As the Google Summer of Code 2011 is slowly coming to it&#8217;s end, for the following days I plan to write a documentation for all the modifications and new features I&#8217;ve made, a detailed installation instructions and so on. I also want to reorganize the code and make the git repo look more logical. And of course I&#8217;d like to document some problems and obstacles I experienced while implementing a plugin for Orion, so it can be easier for other people ;).</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/08/gsoc-2011-%e2%80%93-status-report-%e2%80%93-august-10th/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 – Status Report – July 31st</title>
		<link>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-31st/</link>
		<comments>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-31st/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 13:12:33 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[content assist]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[summary]]></category>
		<category><![CDATA[syntax highlighting]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=348</guid>
		<description><![CDATA[I started this week with a goal to improve the content assist panel&#8217;s look and feel. The problem of current panel is that it doesn&#8217;t show any scroll bars when there&#8217;re many proposals listed. It can easily get out of the viewport and becomes very long. Also, when the caret position is near the bottom [...]]]></description>
			<content:encoded><![CDATA[<p>I started this week with a goal to improve the content assist panel&#8217;s look and feel. The problem of current panel is that it<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350351"> doesn&#8217;t show any scroll bars</a> when there&#8217;re many proposals listed. It can easily get out of the viewport and becomes very long. Also, when the caret position is near the bottom or right edge of the viewport, invoking the content assist panel makes it displayed mostly out of the view.</p>
<p>Firstly I edited the <em>ide.css</em> file to add <em>overflow: scroll</em> property and a fixed height (150px). It was enough to make the panel display horizontal and vertical scrollbar. But a new problem occurred &#8211; the scroll position was not related to the currently selected item at all &#8211; using arrow keys to move up / down haven&#8217;t scrolled the panel, so the selection went easily out of sight.</p>
<p>I modified then <em>contentAssist.js</em> file to implement the scrolling. I used the <em>node.scrollIntoView()</em> method do the scrolling on every selection change. This method accepts a boolean parameter &#8211; when <em>true</em>, the panel will be scrolled as much as it&#8217;s needed to display the selected element at the <strong>top</strong> of the window, while providing <em>false</em> will show the element at the <strong>bottom</strong>. It&#8217;s the typical behavior you would expect in such situation.</p>
<p>To prevent the panel of being displayed out of the viewport, I added two conditional statements in panel&#8217;s initialization code. First, it checks if the bottom line of the panel is not outside of the viewport &#8211; if it is, the panel will be displayed above the caret, and not below it as usual. Second, the same thing is done for right edge of the viewport and panel. But this time, if the panel doesn&#8217;t fit, it&#8217;ll be displayed just next to the right edge (&#8220;snapped&#8221; to it). This is the behavior I observed in desktop Eclipse Platform and I think it&#8217;s the most common.</p>
<p>This simple changes allowed the panel to behave in a way that is much more convenient and useful. You can test the changes by yourself! Just go to this file on <a href="http://oriondemo.gusak.eu:8080/edit/edit.html#/file/A/do_not_save_changes/linkedmode3.php">oriondemo</a>, place the caret near the bottom and / or right edge of the editor and invoke the content assist by ctrl+space. This is how it&#8217;s displayed near the bottom / right edge of the viewport:</p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_032.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_032.png" alt="" title="Content assist panel near the bottom edge of the screen" width="493" height="269" class="aligncenter size-full wp-image-356" /></a></p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_031.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_031.png" alt="" title="Content assist panel near right and bottom edge of the screen" width="408" height="316" class="aligncenter size-full wp-image-355" /></a></p>
<p>I prepared a patch and added it to the <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350351#c2">issue</a> on bugzilla. I didn&#8217;t test the changes on many browsers (just FF4 and Chrome) but I hope it&#8217;ll be useful for the devs.</p>
<p><b>Multi-mode syntax highlighting</b></p>
<p>After the patch was ready I proceeded to the next, more important task &#8211; implementation of multi-mode syntax highlighting. Currently, only one language grammar is used for highlighting any file. So, if it&#8217;s an HTML file, only HTML syntax will be highlighted. And if it&#8217;s a PHP file, the syntax will be highlighted even outside of start and end tags. It is a major lack so I really want to change this ;).</p>
<p>I started with looking into <em>HTML.plist</em>, <em>PHP.plist</em> TextMate grammar files to get some insight how this problem is solved there. As it turned out, there is no concept of grammar inheritance as I firstly thought, but just the external reference is being used. For example, the <em>HTML.plist</em> file is defined as a grammar for <em>*.html</em> files, but also <em>*.php</em>, <em>*.js</em>, and few others. Then in the grammar body, some rules exist to &#8220;catch&#8221; the begin / end tags for particular languages, and in pattern list for body of this capture, external grammar is included. Grammars have names (for php its &#8220;<em>source.php</em>&#8220;), so just this name is given.</p>
<p>Such solution has a drawback &#8211; the &#8220;main&#8221; grammar file has to know about all the included languages. This is a problem from the perspective of pluginability, but nevertheless I wanted to try implementing support for external references in Orion&#8217;s <em>textMateStyler.js</em> (as it currently doesn&#8217;t support these of course) and check how it would work.</p>
<p>I&#8217;ve looked into the <em>textMateStyler.js</em> and <em>setup.js</em> which is instantiating the former to check how to add this feature. I came to conclusion, that in theory it should be enough to provide a list of all known grammar objects to <em>textMateStyler.js</em> (aside of providing just one grammar as it&#8217;s now), modify the <em>preprocess()</em> method to accept any grammar object and not just the &#8220;main&#8221; one (it converts the grammar rules into a more useful, preprocessed form), and, the most important part, reimplement <em>_resolve()</em> method to not throw an exception when an external reference is detected. Instead, it&#8217;s needed to go through the array of all known grammars and compare it&#8217;s name. If it matches, it should be enough to invoke the <em>preprocess()</em> method with the just recognized grammar as a parameter.</p>
<p>The theory didn&#8217;t worked as nice in practice, as usual, but all the problems were simple ones caused by my absence of mind ;). After fixing these, surprisingly, the highlighting of PHP inside of HTML just started to work!</p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_033.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_033.png" alt="" title="Multi-mode syntax highlight" width="496" height="128" class="aligncenter size-full wp-image-368" /></a></p>
<p>I&#8217;m very happy that it worked just like that, but of course it&#8217;s just a proof of concept. It&#8217;s very inefficient, no cache, no handling of corner cases etc, so I didn&#8217;t place it on oriondemo yet.</p>
<p>Next week I&#8217;ll further work on this feature to make it nice and efficient. There&#8217;s a lot stuff to do here, but I think it&#8217;s a very important feature &#8211; probably the most important I&#8217;ll do a patch for :D</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-31st/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 – Status Report – July 24th</title>
		<link>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-24th/</link>
		<comments>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-24th/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 22:23:42 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[content assist]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[linked mode]]></category>
		<category><![CDATA[oriondemo]]></category>
		<category><![CDATA[pdt]]></category>
		<category><![CDATA[summary]]></category>
		<category><![CDATA[syntax highlighting]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=336</guid>
		<description><![CDATA[This week was meant for a bug fixing, some cleaning-out and organizational work. I fixed a few important problems. I started with modifying the PhpServlet of Orion PHP Editor server-side bundle and PhpContentAssist.js on the client side to make it communicate by POST and not GET requests, as sending PHP script as a GET parameter [...]]]></description>
			<content:encoded><![CDATA[<p>This week was meant for a bug fixing, some cleaning-out and organizational work. I fixed a few important problems. I started with modifying the <em>PhpServlet</em> of Orion PHP Editor server-side bundle and<em> PhpContentAssist.js</em> on the client side to make it communicate by POST and not GET requests, as sending PHP script as a GET parameter could work for testing, but would most probably soon incur some problems with URL length for bigger scripts.</p>
<p>Then next problem I wanted to solve was related to the fact that the content assist feature from PDT returns a huge list of all available proposals (all global functions, constants, etc) if you invoke the assistance when no prefix is available (for example, right after the semicolon, or at the very beginning of the script, etc). This big list loads for too long, and isn&#8217;t also very usable. I did some analysis of PDT API and I couldn&#8217;t find any suitable solution to this problem. For example, a method <em>acceptContext()</em> of interface <em>CompletionRequestor</em> should be called before each set of proposals from particular category (for particular context) is returned, but somehow it isn&#8217;t. I don&#8217;t know if it&#8217;s PDT or DLTK fault, I didn&#8217;t dive that much to get clear view of this problem. I <a href="http://dev.eclipse.org/mhonarc/lists/pdt-dev/msg01886.html">asked</a> on pdt-dev mailing list. I received a <a href="http://dev.eclipse.org/mhonarc/lists/pdt-dev/msg01887.html">reply</a> very soon, and Roy told me that it&#8217;s pretty much not possible to make PDT not return the full proposals list in such situation, except by doing some filtering.</p>
<p>At first I tried to get flags for a proposal and check if it&#8217;s a method (declaration or reference), but again, something seems to not work here as these flags are not being set for methods. But I shouldn&#8217;t really comment on the API as all that stuff is from internal package. So I went with the simple solution. After 100 first proposals, the<br />
<em>findParameterNames()</em> is not called any more (as it&#8217;s a costly method), and after 200 first proposals I stop generating results. The proposals are sorted by relevance so I doubt it&#8217;s a big problem to get 200 of them. Thanks to this even the full list returned by PDT is assembled in fast manner, and the general performance of the PHP content assist in Orion is pretty satisfactory.</p>
<p>Another bug with content assist is a problem with a prefix passed to the proposals provider by Orion. The prefix is computed in such way that if you try to complete a dollar sign, &#8220;<em>$</em>&#8220;, which is common in PHP, the prefix variable is an empty string. This makes PDT return for example &#8220;<em>$var</em>&#8221; completion, which will be inserted into the editor and make &#8220;<em>$$var</em>&#8221; (because of the old dollar sign which wasn&#8217;t taken into account). Solving this problem is simple, and would probably require to define a list of special characters which will be treated as a part of a prefix. But the Orion devs need to take various languages into account, so I <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=352756">reported this bug</a>.</p>
<p>Yet another bug with the content assist in Orion occurs when you switch to the content assist mode (i.e. invoke the proposals window by ctrl+space), and then start to press backspace to delete the chars before the caret. The proposals window is being updated, which is OK, but if you continue deleting and remove the preceding new line etc, the window is still open. I think it&#8217;s more common to automatically cancel the content assist mode in such situations, so I <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=352782">reported a bug</a>.</p>
<p>Later I worked on some minor issues. I&#8217;ve added PHP heredoc highlighting rules for the syntax highlighter. Then I&#8217;ve checked how the new Linked Mode functionality I implemented lately works with Orion&#8217;s undo functionality, and surprisingly, it works without any problems :-). </p>
<p>In the meantime Mark <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346409#c7">took over my patch</a> with Linked Mode feature and integrated it into Orion codebase! Of course he did some modifications and improvements. But this feature is now available both in the repos and latest integration builds. I wanted yet again sync my code with the current Orion, so I needed to update both my local installation and the <a href="http://oriondemo.gusak.eu:8080">oriondemo</a>. I experienced some problems while doing this, despite the fact that I did it several times already. As it turned out, I forgot that John wrote on the list about recent repo address change. As Orion is the first-class Eclipse project now, the repo name is not <em>e4</em> anymore but just <em>orion</em>. It took me way too much time to notice this, so updated a related<a href="http://wiki.eclipse.org/Orion/Getting_the_source"> Orion wiki page</a> coincidentally.</p>
<p>For the next week I plan the bug hunting part 2. There&#8217;re a few more problems left I want to solve. When I&#8217;ll get through the problems on my side, I&#8217;d like to help Orion devs with some open bugs I reported. Hopefully I&#8217;ll produce some more patches :-).</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-24th/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 – Status Report – July 17th</title>
		<link>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-17th/</link>
		<comments>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-17th/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 17:47:56 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[code validation]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[oriondemo]]></category>
		<category><![CDATA[pdt]]></category>
		<category><![CDATA[summary]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=311</guid>
		<description><![CDATA[The task for this week was to implement PHP code validation feature, integratef with Orion &#8211; so the errors are marked on the sidebar (similar to how it&#8217;s done in the desktop Eclipse Platform). My goal was to utilize PDT for this feature. When I was doing some prototype tests (yet before the coding period [...]]]></description>
			<content:encoded><![CDATA[<p>The task for this week was to implement PHP code validation feature, integratef with Orion &#8211; so the errors are marked on the sidebar (similar to how it&#8217;s done in the desktop Eclipse Platform). My goal was to utilize PDT for this feature. When I was doing some prototype tests (yet before the coding period started) to check if this is doable or not, I failed to make the code validation work. But few weeks ago, when I encountered some unexpected problems while accessing PDT&#8217;s content assist functionality, it turned out that my previous failure could be just my mistake and not any technical problem.</p>
<p>So this time I wanted to prepare yet another quick-and-dirty demo to check if the code validation feature of PDT can be used from outside of the Eclipse Platform context. It didn&#8217;t work at first, so I&#8217;ve enabled the tracing data and started to debug the code, to check what exactly is failing (I was just receiving an empty array instead of an array of problem markers). I noticed that the markers are generated correctly in one point, but then they are removed from the array. It turned out that the array is being filtered by a problem&#8217;s type, which is passed as a parameter to <em>findMarkers()</em> method. In PDT unit tests a constant <em>DefaultProblem.MARKER_TYPE_PROBLEM</em> is being passed, so I did the same ;-). But after changing this parameter to just <em>null</em>, my markers finally started to show up. According to the source code&#8217;s comment of <em>findMarkers()</em> method, passing null makes the method to just return markers of all types. I&#8217;m not sure why it&#8217;s like that in PDT&#8217;s unit tests.</p>
<p>After ensuring that I can retrieve the problem&#8217;s list for any particular PHP script, I started to modify <em>PhpServlet</em> to handle the new functionality. From now on it had to support requests in two formats, <em>/php/contentassist/</em> for the &#8220;old&#8221; feature, and <em>/php/codevalidation/</em> for the brand new stuff. The new mode expects a <em>script</em> parameter, and optionally <em>phpversion</em>. It returns a simple JSON array, with elements of following structure:</p>
<p><code><br />
{<br />
    reason: "A problem description",<br />
    line: 3,<br />
    character: 1<br />
}<br />
</code></p>
<p>This is just a structure that <em>orion.edit.validator</em> expects (more about it in a moment). <em>Line</em> is just a number of line where the problem occurs, and <em>character</em> is a number of column in this line. However this particular value is not being used by Orion yet.</p>
<p>On the client side, I had to just connect to the mentioned <em>orion.edit.validator</em> extension point to make Orion display the problem markers. The extension points are now very nicely described <a href="http://wiki.eclipse.org/Orion/Documentation/Developer_Guide/Plugging_into_the_editor#orion.edit.validator">on wiki</a>, so it&#8217;s easier now to do everything as it should be.</p>
<p>However, while implementing the client code I&#8217;ve encountered a very weird problem. After initial versions of files <em>phpValidator.js</em> (provides markers&#8217; array to the mentioned extension point) and <em>phpEditingPlugin.html</em> (registers the object from former file) were ready, I cleared the <em>localStorage</em> as I always do and prepared to test the new feature. But then all the contents of files in my workspace disappeared, and any attempt to save any text just failed. The files were staying empty. I noticed that while invoking the <em>save</em> action (by a keyboard shortcut or by using a navigation button) an error was showing up in the console: &#8220;<em>TypeError: result is null</em>&#8220;. So I&#8217;ve looked into the code where the error occurs, and it seemed like the servers&#8217; response is invalid. But the file operations functionality which was failing has nothing to do with the parts I&#8217;ve changed! Moreover, I reverted my modifications, cleared everything I can in the browser, and even removed server-side Orion workspace files. It didn&#8217;t help, my local installation was just broken. I tried to debug the client-side and server-side code but I didn&#8217;t get any clues what&#8217;s wrong.</p>
<p>After wasting too much time on this already I came up with an idea to just test my modifications on the remote installation (<a href="oriondemo.gusak.eu:8080">oriondemo</a>) to see if the problem will also come out here. I did exactly same steps as before, and this time it just worked! Code validation is working as expected and you can <a href="http://oriondemo.gusak.eu:8080/edit/edit.html#/file/A/do_not_save_changes/codevalidation1.php">test it by yourself</a> :-). Just remember that you might need to issue <em>localStorage.clear()</em> if you&#8217;ve visited the demo recently (and it may require many subsequent F5 keystrokes ;-)). At present I still don&#8217;t know what is the problem with my local installation and why it occurred. I&#8217;ll try to investigate this issue but as my code works, I committed it to my <a href="https://github.com/kgusak/orion-php-editor">github repo</a>.</p>
<p><a href="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_027.png"><img src="http://orion.gusak.eu/wp-content/uploads/2011/07/Selection_027.png" alt="" title="PHP code validation works" width="568" height="416" class="aligncenter size-full wp-image-328" /></a></p>
<p>When you hover a mouse pointer over the marker you will see the error message (reason).</p>
<p>The next week will be a bug-fixing week for me. I plan to concentrate on some problems I postponed or ignored before. There are many various problems that need to be fixed, as the code still has very prototype-like nature in general. :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-17th/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 – Status Report – July 10th</title>
		<link>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-10th/</link>
		<comments>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-10th/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 16:08:27 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[content assist]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[linked mode]]></category>
		<category><![CDATA[oriondemo]]></category>
		<category><![CDATA[pdt]]></category>
		<category><![CDATA[summary]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=300</guid>
		<description><![CDATA[This week I planned to do some prototype implementation of the Linked Mode feature for Orion. As you can see in the last report, I was worried about the need of modifying too much of the core Orion parts to actually add this feature. I thought I&#8217;ll need to modify the textView.js file. But then [...]]]></description>
			<content:encoded><![CDATA[<p>This week I planned to do some prototype implementation of the Linked Mode feature for Orion. As you can see in the <a href="http://orion.gusak.eu/2011/07/gsoc-2011-%E2%80%93-status-report-%E2%80%93-july-3rd/">last report</a>, I was worried about the need of modifying too much of the core Orion parts to actually add this feature. I thought I&#8217;ll need to modify the <em>textView.js</em> file. But then fortunately Boris Bokowski <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346409#c4">pointed out</a> that <em>editorFeatures.js</em> file is actually the proper place. It helped me a lot as when I&#8217;ve started to read this file I began to see where exactly should I place my future code. I&#8217;m not sure why I was kind of ignoring this file in the first place.</p>
<p>I started with implementing the Linked Mode activated on key shortcut. The positions were hardcoded, so only the same part of the text were being selected over and over again. Then I added a key actions for TAB &#8211; to traverse through the positions (in cyclic manner) &#8211; and for ESC to exit the Linked Mode. After exiting the &#8220;old&#8221; bindings are reattached (i.e. inserting tab on TAB key :)). Also the position &#8220;groups&#8221; (selections) are being updated if the user inputs a text (or deletes) within the group. If it&#8217;s done outside the group, the Linked Mode is canceled.</p>
<p>As the simple version was working I started to create an API so the content assist feature could later use the Linked Mode while completing methods with parameters. After that I had to modify <em>contentAssist.js</em> of course, so it could prepare data needed to activate the mode (i.e. offsets and lengths of the position groups, as well as the escape position &#8211; a place where the caret has to be inserted after the Linked Mode is exited). Finally my phpContentAssist plugin and the responding server-side code had to be modified to provide that data (the <em>contentAssist.js</em> is language-agnostic so it cannot know what is a parameter and what not in a completion proposal).</p>
<p>After some more tinkering all started to work nicely. Almost all actually, as I experienced some problems not related to the new feature itself. First, the Linked Mode won&#8217;t be turned on if you choose the proposal from the list by mouse click (as opposed to enter key). These two events are handled in two different places in code, so <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346409#c5">I didn&#8217;t want</a> to duplicate my handling routine just yet to not unnecessarily mess up the prototype. The second problem is that the selection object doesn&#8217;t seem to be updated before calling onModelChanged, so I needed to do little hack to get the up-to-date caret position every time. And the third problem occurs when you invoke the completion proposals&#8217; window, then click somewhere else (place caret on another line), and then click enter to select the proposal &#8211; it&#8217;ll be inserted in the wrong place. But it&#8217;s a <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350494">known issue</a> reported by Mark &#8211; the <em>textView.js</em> has to expose a new event first to fix this.</p>
<p>Finally after cleaning out the code I&#8217;ve updated git repo (also new README) and the tracker <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346409">issue</a> and added the diff patch of the new feature. When updating my Orion demo installation I experienced one more problem. It turned out that the Orion target package includes a <em>built-edit.js</em> instead of <em>edit.js</em> file by default. The former one is a &#8220;precompiled&#8221; version of few files included by <em>edit.js</em> (so e.g. my modifications of <em>editorFeatures.js</em> weren&#8217;t picked up). But I changed the relevant line of code and now you can test the new Linked Mode by yourself in <a href="http://oriondemo.gusak.eu:8080">oriondemo</a>. Just please don&#8217;t save the modifications of prepared files :).</p>
<p>The task for next week is the code validation feature for PHP, which I omitted earlier to proceed with content assist. But as this time I can return to and I&#8217;m curious about the effects :).</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-10th/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>GSoC 2011 – Status Report – July 3rd</title>
		<link>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-3rd/</link>
		<comments>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-3rd/#comments</comments>
		<pubDate>Sun, 03 Jul 2011 17:35:39 +0000</pubDate>
		<dc:creator>Karol Gusak</dc:creator>
				<category><![CDATA[Google Summer of Code 2011]]></category>
		<category><![CDATA[content assist]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[summary]]></category>

		<guid isPermaLink="false">http://orion.gusak.eu/?p=286</guid>
		<description><![CDATA[I started with updating the Orion version of my test installation as I didn&#8217;t do that for few weeks and some new important changes were introduced since M8 (you can read about it on planetorion.org). Some of them (git-related) doesn&#8217;t affect my work but the performance gain is easily noticeable. Also a very important bug [...]]]></description>
			<content:encoded><![CDATA[<p>I started with updating the Orion version of my <a href="http://oriondemo.gusak.eu:8080">test installation</a> as I didn&#8217;t do that for few weeks and some new important changes were introduced since M8 (you can read about it on <a href="http://planetorion.org/news/2011/06/orion-0-2-rc1-new-and-noteworthy/">planetorion.org</a>). Some of them (git-related) doesn&#8217;t affect my work but the performance gain is easily noticeable. Also a very important <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=350350">bug</a> I reported last week was fixed by Mark, who has also made other improvements for content assist in Orion so I really had to update ;). I&#8217;ve also updated my local installation which I&#8217;m using for quick tests. It&#8217;s a little bit annoying that I have to actually do a clean installation of Orion and my modified code every time I&#8217;m updating, as my modifications cannot be yet conveniently extracted and prepacked. I need to apply them by hand. But at least I have a reason to check if my installation instructions I&#8217;ve placed in README file on <a href="https://github.com/kgusak/orion-php-editor">github</a> repo are good ;-).</p>
<p>Then I started to look into Orion code and get a little bit familiar with it. I&#8217;ve searched for the parts related to storing and using information about current selection (so also the caret position) in the editor. I got to know that the <em>textView.js</em> is mostly responsible for that, and that it also exposes some methods to read and change the caret position or selection. But there are also files like <em>editorFeatures.js</em> or <em>commands.js</em> which use this information (for incremental find and so on).</p>
<p>But the hardest problem was to actually learn how the desktop Eclipse is achieving its functionality of &#8220;controlled caret movement&#8221; when traversing through the arguments&#8217; list for a method being autocompleted. I had no idea where can I start looking for, and googling didn&#8217;t really yield any useful results. It was mainly because I really didn&#8217;t know the official name for this functionality. But then I somehow stumbled upon <a href="http://archive.eclipse.org/eclipse/downloads/drops/R-3.0-200406251208/eclipse-news-part4-R3.html">this article</a>, where the name Linked Mode occurs. It was a good anchor for me, and then finding the package responsible for Linked Mode, which is <em>org.eclipse.jface.text.link</em>, was easier. Then I checked the <em>org.eclipse.dltk.ui</em> plugin, as I thought it must be using the Linked Mode to its content assist feature, and I found <em>AbstractScriptCompletionProposal</em> class, among other where <em>LinkedModeUI</em> was used.</p>
<p>It was a very helpful finding as I could finally see how it is exactly implemented in Eclipse. But one thing wondered me &#8211; why the completion proposals I was receiving from PDT on my server, didn&#8217;t contain method&#8217;s parameters, even though they were defined in the code. Always a method name with just opening and closing bracket was returned (and it still is &#8211; you can test it in my Orion installation). I&#8217;m still not sure why it is like that as the method I&#8217;m using for retrieving the proposals &#8211; <em>getCompletion()</em> seems to be invoking <em>findParameterNames()</em> to get the parameters and place them in the returned completion. Nevertheless I&#8217;ve done a quick test of invoking this method by myself and I got nice array of parameters, so this is really not an issue.</p>
<p>And finally today I&#8217;ve updated <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=346409#c3">the bug</a> about the Linked Mode, adding some API details of this feature. The biggest problem is how to implement the Linked Mode itself. The other tasks, like modifying <em>contentAssist.js</em> to actually support the aided completion of parameters using the Linked Mode, and updating my plugin to utilize this feature are much easier to do. However the Linked Mode itself seems to be very core-related part, requiring to modify the <em>textView.js</em> file which is a heart of the Orion editor. Anyway, I plan to give it a try and experiment with this feature next week. I hope to implement some simple prototype that will actually work :). If I&#8217;ll experience some big problems, I&#8217;ll just proceed to the next part of my proposal &#8211; code validation &#8211; and maybe get back to this feature later.</p>
]]></content:encoded>
			<wfw:commentRss>http://orion.gusak.eu/2011/07/gsoc-2011-%e2%80%93-status-report-%e2%80%93-july-3rd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

