AS3V For Ant Released

Since I started the development of some other library I completly put AS3V aside because the Eclipse integration with FDT is currently not possible. But since AS3V is working already I decided to release a version really quick that allows you to use AS3V as an Ant Task or simply from command line.

I know it would be better to have it as an Eclipse Plug-in with nice little markers etc. but for that I need some more extension points in FDT. I do not know about FlexBuilder but it would be probably the same.

The file includes an example build and some test cases that show you how AS3V can detect common errors and mistakes. There is currently not that much documentation available for the rules and parameters you can specify. Putting a list online with all rules and nice descriptions is of course something I would like to do but currently the time for that is missing. I hope everything is self-explaining if you have a look at the readme and example files.

Update: The AS3V package has been updated with one bug fix and some modifications so that AS3V will produce a more interesting log output if it fails for some reason. Using AS3V with Eclipse works only if you specify fork="true" like in the Flex SDK example from the build file that comes with the zip.

31 Comments

  1. rumori
    Posted Jun 26, 2009 at 6:51 pm | Permalink

    Jumping on this right away, great work.

  2. Posted Jun 26, 2009 at 6:58 pm | Permalink

    By the way, as3v.googlecode.com will be updated soon as well. But it is Friday evening you know :)

  3. Posted Jun 26, 2009 at 10:54 pm | Permalink

    Hey – this looks really cool! However I’m getting a ‘premature end of file error’ on the ant task (either main or flexSDK). I did set my FlexSDK path.

    /home/davidwilhelm/as3v/build.xml:41: org.xml.sax.SAXParseException: Premature end of file.

    I also tried the command line java -jar approach, but couldn’t figure out how to feed it the files to parse. I couldn’t even get the -help option to work. If you could give some examples of using it on the command line that would be great.

    thx

  4. Posted Jun 27, 2009 at 12:13 pm | Permalink

    I think that I know what the problem is but I will not be in the office before Monday.

    Commandline should work like “java -jar as3v.jar -help”. The most important parameters are -sp for a source path and -asc to specify the path to your asc.jar. To check the examples it would be “java -jar as3v.jar -asc path/to/asc.jar -sp examples”.

  5. Posted Jun 27, 2009 at 12:56 pm | Permalink

    hey joa,
    thanks for the great tool! i hope the fdt guys provide you with the neccessary extension points soon, as3v as an eclipse plugin would totally rock, i imagine quifixes for instance…

  6. Posted Jun 27, 2009 at 1:16 pm | Permalink

    Exactly. Providing quick fixes would be possible. I still have to decide though if it will be an FDT only plug-in. If that would be the case I could ignore the missing extension points and one could take full advantage of additional features (like quickfixes).

  7. Posted Jun 27, 2009 at 9:31 pm | Permalink

    thanks for the help – I have the commandline working now – should be a breeze to hook up to it in vim :D

  8. Posted Jun 28, 2009 at 12:57 pm | Permalink

    I am quite sure that I can fix the Ant version with one additional line of code for every platform. Great that it works for you now.

    Tomorrow is also a good day to release an Eclipse plug-in. I think I might just put FlashBuilder aside for now and concentrate on the FDT-only version.

  9. Posted Jun 29, 2009 at 9:01 am | Permalink

    David, the Ant task should work now for you too.

  10. Posted Jun 29, 2009 at 1:57 pm | Permalink

    As extension point maybe this could help: http://bugs.adobe.com/jira/browse/SDK-18718

  11. Patrick Pietens
    Posted Jun 29, 2009 at 2:03 pm | Permalink

    Hi – great work! I get an error using the ANT version though:

    “org.eclipse.ant.internal.ui.antsupport.AntSecurityException
    [as3v] at org.eclipse.ant.internal.ui.antsupport.AntSecurityManager.checkExit(AntSecurityManager.java:54)”

    Using the commandline everything works like a charm. Can;t wait for the FDT plugin.

    Cheers

  12. Posted Jun 29, 2009 at 2:36 pm | Permalink

    Yes, this has been identified. If you use the forked VM version, which is described in the flexSDK task of the example build, everything will be fine.

    Basically, if you use AS3V via Ant from inside Eclipse, you have to specify fork=”true” currently.

  13. Posted Jun 29, 2009 at 4:07 pm | Permalink

    very cool! got the command line version up and running. using it to clean up some sloppy code now ;-) thanks!

  14. Posted Jun 29, 2009 at 10:27 pm | Permalink

    Hey joa

    I was able to get the commandline version working in Vim , feeding warnings into the quickfix window, and jumping to the lines specified. So I’m happy about that!

    I noticed a couple of things..

    I couldn’t get the use-config option to work – it always seems to look in the same dir as where the command is called from, or failing that , the location of as3v.jar. But maybe I’m just calling it wrong.

    It checks every file in the source-path and subdirectories..results in a alot of messages. is there any way to specify a single file?

    It doesn’t give the filename, just the classname. Perhaps this is by design..

    I’m working around these issues by wrapping the call to as3v in a shell script, but I thought you might want to be aware of them, in case they are bugs.

    Cheers

  15. Posted Jun 30, 2009 at 10:07 am | Permalink

    David,

    first of all, let me appreciate for the poor command line version. I hacked it together real quick so there are currently some glitches and missing features you notice.

    – There has to be an as3v-default.xml. AS3V will always load the default configuration. If you specify your custom configuration, the settings are overriden, but you can not delete the as3v-default.xml.

    – There is a way to specify a single file, but not from command line. The Eclipse plug-in for instance works as an incremental project builder, so only single (modified) files are parsed.

    – Do you want the file name instead of classname? It does not make a difference for me. Is there a special reason for outputting the filename?

    Maybe you can share your shell script with other users? I think I will have to fix up some things and provide a proper documentation before I continue with the Eclipse plug-in.

  16. Posted Jul 2, 2009 at 1:20 am | Permalink

    Hello today i add As3v to Flashdeveloped like Toolbar button
    More info you can find on FD forum

    http://www.flashdevelop.org/community/viewtopic.php?f=4&t=5033

  17. Philippe
    Posted Jul 2, 2009 at 10:05 pm | Permalink

    Please keep making a command line tool.

    A filename as input is simple to automate for a command line tool.

    A more friendly (ie. standart file:line:column) output would be nice.

    Keep up the good work!

  18. Posted Jul 3, 2009 at 11:36 am | Permalink

    Philippe,

    I am not sure if a command line version makes that much sense for a couple of reasons:

    – Initialization of ASC is time consuming
    – Startup of Java is time consuming
    – HotSpot will be time consuming

    The better approach would be to keep an AS3V running and query it for information. I am not sure if this will integrate easy with FD but it is basically the same concept which tools like fdb use.

    Not to forget that there is an even bigger problem. ASC is currently used in a way so that you do not have to load playerglobals.swc etc. This is fine with me currently since AS3V does no interprocedural analysis but it might change in the near future. This means basically that a command line version would have to compile always the complete dependency graph for your class and this is where it will get nasty. Although, I am not sure how they handle incremental compilation. Maybe that would be an option.

    Right now I could implement the single-file option for FD but I think a query-based architecture would be better.

  19. Philippe
    Posted Jul 3, 2009 at 9:20 pm | Permalink

    I agree that a query based tool would be more suited for FlashDevelop – I was suggesting to keep a command line tool for maximum compatibility with alternative editors.

    FlashDevelop (even if it’s .NET) keeps a lot of Java processes in memory using custom wrappers to use them in a query-based model: asc, fdb, fcsh and mxmlc. I am even proud of the hack used to keep mxmlc.jar in memory (this provides incremental compilation for free).

    So if your tool does, like mxmlc.jar, provide a static main entry point (flex2.tools.Compiler.main) we could certainly integrate efficiently your tool.

  20. Posted Jul 4, 2009 at 10:57 am | Permalink

    Okay, so first of all I am happy to see some bugs people posted in your forum. At least two of them a real and have to be fixed.

    Now for FlashDevelop we can make a version really quick. AS3V has been designed for embedding and custom project models. So therefore we can simply write a FD tool which fits your needs.

    For a more generic version I will update the command line tool with two features:
    – Customized output (e.g. %level %filename:%line:%column %message)
    – Single file parsing

    For FlashDevelop we could create an even better version using a JNI wrapper — if you want. For instance, the C++ library could make use of pipes. The handling could be even better. But that is just an option. If you do not think its feasable we could simply add a tool that works query based.

    I will work on the command line version on Monday and put everything on GoogleCode if I can find the time. You or someone else could also contribute on the FD task if you are interested.

  21. Philippe
    Posted Jul 4, 2009 at 3:39 pm | Permalink

    I’ve check out the code and I’m trying to figure out how this works…

    As far as FlashDevelop is concerned, a JAR will be perfectly fine, but I’m curious about the JNI suggestion: do you mean a DLL?

  22. Posted Jul 4, 2009 at 6:55 pm | Permalink

    Yes exactly. But that DLL would be loaded from a Java process. That way a more convinient connection would be possible for you. Altough if you are fine with a simple process there is no need to do the extra work.

    Do not check out the code — it is completly out of date. I will update the repository on Monday.

  23. Posted Jul 24, 2009 at 7:30 pm | Permalink

    This looks like a useful tool, however when I run it from eclipse on a somewhat large Flex project, I get the following output: (removed directory names to protect the innocent)

    Buildfile: C:\…\build.xml
    main:
    [as3v] ActionScript3 Verifier running …
    [as3v] [Fatal Error] :-1:-1: Premature end of file.

    BUILD FAILED
    C:\…\build.xml:30: org.xml.sax.SAXParseException: Premature end of file.

    Total time: 1 second

    Any way of figuring out what file it is choking on? I have like 20 or 30 .as files now I think.

  24. Posted Jul 24, 2009 at 8:09 pm | Permalink

    David, do you have the latest version? I tested AS3V with projects that contain thousands of classes.

    Anyways I am sorry that I could not continue the development and fix some bugs. Especially the FD integration is still on my plate. Work keeps me pretty busy at the moment.

    I hope I will find some time during the next weeks.

  25. Alan
    Posted Aug 5, 2009 at 5:55 am | Permalink

    Any work from the guys at powerflasher to hook you up with ‘more extension points in FDT’?

    Maybe a feature request on powerflasher’s Jira will help….

    Great work BTW.

  26. Paul B
    Posted Sep 11, 2009 at 4:37 pm | Permalink

    Thanks Joa for creating this.

    Can you tell me if the google code has been updated? I just checked it out but can’t find the rules package.

    Cheers

  27. Posted Oct 7, 2009 at 6:06 pm | Permalink

    Joa I also get a “premature end of file” error. I downloaded the latest code today.

    [as3v] ActionScript3 Verifier running …
    [as3v] [Fatal Error] as3v3394498810895234175.log:1:1: Premature end of file.

    BUILD FAILED
    C:\…\ant\as3v\build.xml:29: org.xml.sax.SAXParseException: Premature end of file.

    I ran through FDT 3.1.1. Any ideas?

  28. Posted Oct 8, 2009 at 10:40 am | Permalink

    Joa, problem solved: I was running my External Tools through the Smartfox JRE rather than the default workspace JRE.

    I went to Run/External Tools/Open External Tools Dialog/JRE Tab and checked “Run in the Workspace JRE”.

    Hopefully this is useful to someone with similar problems.

  29. Posted Nov 11, 2009 at 7:32 pm | Permalink

    I’d been getting the same

    [as3v] ActionScript3 Verifier running …
    [as3v] [Fatal Error] as3v3394498810895234175.log:1:1: Premature end of file.

    problem as others, using AS3V in FDT with Ant. I actually found that _removing_ fork=”true” fixed the problem. I think that’s contrary to what’s said above, unless I misunderstood? Hopefully this might help anyone else with the same problem.

    Thanks for a nice piece of kit :)

  30. Posted Nov 19, 2009 at 9:17 pm | Permalink

    What about PixelBender optimizator?

    For example change this:
    add f2.r, f1.a
    add f2.g, f1.a

    to this:
    add f2.rg, f1.aa

    I can change PB-asm code and compile it again with apbj/dpbj, but having something like “PBV” will be really nice thing.

  31. layola
    Posted Aug 6, 2010 at 7:33 am | Permalink

    main:
    [as3v] ActionScript3 Verifier running …
    [as3v] Example01, Ln 22, Col 15: Avoid unneccessary calculations inside loops.
    [as3v] Example02, Ln 14, Col 40: Avoid jumbled loop incrementers. This is usually a mistake and very confusing if intended.
    [as3v] Example02, Ln 14, Col 27: Avoid unneccessary calculations inside loops.
    [as3v] Example03, Ln 22, Col 16: Index will be promoted to Number and slow down performance significantly. Consider a cast to int.
    [as3v] Example03, Ln 12, Col 20: Use Vector. instead of Array.
    [as3v] Example04, Ln 7, Col 9: Literal should be a static constant member.
    [as3v] Example04, Ln 13, Col 12: You are using this string 5 times in this method. Consider using a variable for it.
    [as3v] Example05, Ln 14, Col 12: Avoid unconditional if statements.
    [as3v] Example05, Ln 20, Col 13: Avoid unconditional if statements.
    [as3v] Example05, Ln 20, Col 13: Unreachable code detected.

    BUILD FAILED
    L:\working\idressUp\study\AS3V\build.xml:29: Example05, Ln 20, Col 13: Unreachable code detected.

    Total time: 1 second

One Trackback

  1. […] die Tage auf Joa Ebert’s AS3V ANT Plugin gestoßen, das eine echte Unterstützung bei der täglichen AS3-Programmierung darstellt. Im […]