Skip to main content
Participant
July 8, 2009
Question

Compiler extension for metadata processing

  • July 8, 2009
  • 2 replies
  • 6178 views

This is carry over discussion from: http://bugs.adobe.com/jira/browse/SDK-18718

I'm looking to do some custom metadata processing in a compiler extension.  There is an old extension mechanism and a newer one.  I think either would work for me but I do have some questions.  I'm hoping to trailblaze metadata processing and make my work public for anyone to use.  I've already heard from one Flex framework developer whose looking for the same functionality.  Ideally, I can come up with capabilities that rival Java's annotation processing and everyone can benefit.

First question: Using either of the extension mechanisms, can I report a compilation error complete with line number and error message?

Second question: Has anyone put any thought into using these extension mechanisms within FlashBuider.  I'm an experienced Eclipse plug-in developer and these compiler extensions don't make much sense if they can't be added to a FB workbench.  The newer extension mechanism allows you to add a jar for an extension via the compiler arguments, but I'm not sure this makes much sense when running inside Eclipse.  Ideally, the FlashBuilder  compiler code would provide an Eclipse extension point for compiler extensions.

I'm eager and willing to do the necessary work to make this possible including providing patches,etc.  Heck I'd even be willing to do the work required to add an extension point in FB.

This topic has been closed for replies.

2 replies

Participant
July 9, 2009

For the logging of errors, you'll want to do something like:

  flex2.compiler.util.ThreadLocalToolkit.logError(path, line, errorMessage);

Participating Frequently
July 9, 2009

To answer the question about why not a FlashBuilder plugin...

We originally considered that approach.  The problem is that not everybody or every project uses FB.  Quite a few are using FDT, or simply the SDK along with ANT or Maven /w flex-mojos for doing builds.  By making the extension points accessible as a cmd-line option, we open up the functionality to everybody.  Inside the FlashBuilder project properties, it's fairly trivial to modify the cmd-line options.  Most people are familiar with this area for doing other things like setting the pre-loader background color in a Flex project.

If you wanted to create a plugin for your own particular extension point, it probably wouldn't be too hard to modify the cmd-line properties for the user when they add your plugin's nature to the project.  Adding your plugin's nature to a project could also copy the necessary jar file into the project for the user.

I believe other eclipse plugins work this way.  The new Google Appengine plugin does similar things to convert a project into an appengine project.

schtooAuthor
Participant
July 9, 2009

Thanks Andrew.  That absolutely makes sense.  I wasn't trying to cast stones.  I was really wondering if you'd tried to do it within FB in addition to the cmdline stuff.  There are a couple of difficulties if we just add it to the compiler parms property but maybe its a good short-term solution.

If you'll humor me, let me think aloud what would be required to add the additional FB plugin support:

-An API in the ExtensionManager to allow the addition of extensions at runtime (ex.  ExtensionManager#addExtension(type,...etc))

-An simplistic extension point in FB that specificies an compiler extension type and an compiler extension class (maybe type isn't even necessary).

-A small snippet of code added to the FB compiler init code that loops through that extension point and calls ExtensionManager#addExtension.

There is one extra twist but its easily solved.  Some compiler extensions would probably only be useful for certain types of projects (those with a certain nature).  So the extension point would either need to have a project nature property - or to be more flexible - just a separate evaluator class to determine if the extension should be activated.  I envision it just having one method:  ICompilerExtensionActivator#activate(IProject) returns boolean. 

All in all - the amount of code here would be pretty small.  Maybe a hundred or so lines of code (granted I can't see the FB code so I'm making some assumptions).   I'm willing to buy beers for any Adobe FB engineers who'd take this on - and of course the Product Manager(s) who'd help make it happen

Participating Frequently
July 9, 2009

I really like the idea of Adobe making it easier to add extensions to a project inside FB.  Unfortunately, we don't have as much say in the FB project since it's closed-source and we'd have to get this added to their timeline /w a high enough priority.  It might be nice to have an nice pretty project properties screen where you could add/delete/re-order compiler extensions assigned to a given project instead of hacking on the one cmd-line field for each extension you wanted to assign to a project.