Monthly Archive for May, 2009

Flash on Tap and Flashbelt

Tomorrow I will leave for my trip to the USA. First conference will be the Flash on Tap conference which is happening for the first time. Then shortly afterwards I will speak at flashbelt. This is now the 3rd 6th flashbelt conference but for me the first time speaking there.

I have never been to the States before so I am really looking forward to it. At my session “AudioTool’s Private Parts” which had been completely renewed for the FFK09 in Germany I will talk of course about the technologies that our tool uses and show some examples using Hobnox Open Source. I will also show a live preview of AS3V running in Eclipse and how it integrates into the daily workflow.

AS3V Preview

AS3V Here is the first preview of what AS3V looks like in Eclipse. I have written about 30 rules which include cyclomatic complexity checks and unreachable code detection. Most of the time was getting AS3V to link against the asc.jar from the Flex SDK inside Eclipse which is a real nightmare if you ever tried that one for yourself. However — it works. And hopefully I can forget about all the code I had to write pretty soon.

You can see in the screenshot that AS3V places markers in your Eclipse code. It works as an incremental project builder which means it is pretty fast since it only evaluates all your sources that have changed independently. If you have any suggestions for possible rules, please tell me. The Flex SDK coding conventions could be interesting for instance. Right now the Eclipse plug-in has still some problems but I think that a first version might be released in the next few weeks.

The return of AS3V

In September 2008 I started working on a tool called AS3V. The goal of AS3V was to parse source code and to check the code against a set of rules. My main problem with the first attempt of AS3V was that I used ANTLR. ANTLR is a great tool to create a compiler but for ActionScript 3 and its various strange behaviours you have to do a lot of hacking. Parsing ActionScript, XML and regular expressions with the optional semicolon in ECMAScript is not really fun using such a tool. metaas went that path and unfortunately their parser fails very often.

This is the reason why I started writing a parser manually from scratch. But this is also not a good idea. What about Adobe changing the language or adding features? I would have to change my parser. This is for instance a problem you have with FDT. Adobe releases a feature and it will take a while until you can adopt that. Maybe that feature is only beta but you want to use it. So are you going to implement it or not? Since the Flex SDK is open source I decided to take a completly different approach. Option one is to modify the original ASC. I think this is a bad idea. On every update from the Adobe guys you would have to patch the compiler again, and release a compiled version of that. This is what flexcover does. But I do not want to replace core parts of the Flex SDK with a modified compiler. So this is the reason why AS3V links only against the ASC. This means basically I do not care about what Adobe does with the compiler as long as the API stays consistent. This means also AS3V knows only as much as the ASC. This is sometimes a problem but in most cases not so important. ASC drops for instance braces every time. AS3V does not know if you write if(true) trace('foo'); or if(true) { trace('foo'); }. But in the end AS3V is able to analyze the real compiler output which is huge; theoretically every implicit cast can be watched!

Now enough theory. Why bother using AS3V and what is it good for? Imagine a loop like this:


for( var y: int = 0; y < height; ++y )
  for( var x: int = 0; x < width; ++x )
    index = y * width + x;

AS3V is currently smart enough to analyze the statement y * width + x and to figure out that y and width do not change in the inner loop. AS3V is therefore able to warn you about unneccessary calculations. There are lot of other rules I have already implemented which help you writing better code. For instance the pattern if( expr0 ) { if( expr1 ) { foo(); } } can be reduced to if( expr0 && expr1 ) { foo(); }.

There is a lot of room for other rules. I am happy to see some progress and hope that other people will find AS3V as useful as I. In the current state I have to implement more rules and a little bit more complex ones like dead code detection with constant folding. A release is targeted once I am happy with the rule set.

Not to forget: An Eclipse plugin which will show you appropriate warnings as neat little icons is of course also planned.

MetaLaunch For Eclipse

MetaLaunch Plug-inEver wanted to start multiple launchers with one single click in Eclipse? MetaLaunch will solve this issue. Just select the launchers you want to start and then change the order to fit your needs. You can also select to launch those tasks sequential or in a one shot.

Unfortunately I have not figured out yet how I could abort the launch process if mxmlc fails for instance. This is due to the fact that the fcsh process is persistent and does not return for instance a non-zero exit code when mxmlc reported an error. However, the MetaLaunch plug-in can help you in a lot of cases. For instance if you are developing a multi-client application and you want to launch every time four instances of the Flash Player etc.

The address of the Eclipse update site:

http://metalaunch.joa-ebert.com/update

Semantic Highlightning For PBDT

Semantic highlightningPBDT has now support for semantic highlightning. Thanks to the FDT guys again for answering a lot of Eclipse releated questions. Semantic highlightning works currently with parameters, input and output declarations and for defined preprocessor directives. Just have a look at the screenshot. I have also integrated complete color preferences support. If you go to Preferences > PBDT > Colors you can change everything the way you like.

PBDT with basic refactoring

PBDT RefactoringPBDT has a new feature which is basic refactoring. Simply select the variable you want to rename and press Alt+Shift+R or select “Rename” from the context menu. There are currently two issues with refactoring. If the refactoring entry in the context menu is disabled please select the variable and try again. The same for the shortcut. If you want to refactor something, just select it first in the text. Once I figure out how Eclipse handles changes of the caret position I will fix that.

The second is about scopes. If you redefine a variable in a different scope the refactoring is not correct. But I guess 99% of the developers will not get in touch with this issue.
In this example i would be refactored in the outer and inner scope which is not correct.

void evaluatePixel()
{
        int i;

        {
        	int i;
        	i;
        }

        i;

        out = sampleNearest(src,outCoord());
}