Custom SDK Setup

Hi,

I have been trying to setup a custom SDK using .SWC files. Everything seems to b working correctly with the subclass od SdkType but when in the project that uses the library, the swc file don't seem to be correctly registered.

Basically I'm using this pattern in setupSdkPaths(SdK)

SdkModificator modificator = sdk.getSdkModificator();
VirtualFile child = sdkRoot.findFileByRelativePath("frameworks/libs/player/11.1/playerglobal.swc");
modificator.addRoot(child, OrderRootType.CLASSES);
modificator.commitChanges();

Is the above correct to get the classes correctly added to the project's symbol table for libraries of the SDK?

Thanks,
Mike

9 comments

Hi,

This question was kindof of abstract but I have got a little more information now.

As I have stated, everything is working fine for the custom Sdk up to the point of module initializiation. The playerglobal.swc is listed in the External Libraries, SDK child tree item.

The problem is it seems like the library has not been "registered" correctly with the code model.

When I right click on the "playerglobal.swc" entry in External Library child tree item and select Add as library..., the select classes, then select the Level and Add to module the binary classes from the external library get added to the code model as expected and I et code completion for all the classes in the swc.

So I gues my real question is, what is the command/API in Intellij12 that allows me to execute that "Add as library.." to actually add the SDK libraries to the modules code model?

Thanks,
Mike

0

Hi Mike,
glad to meet you at our forum! B-)

As I can guess you want to configure Flash module and Flash build configurations (BCs) programmatically. Unfortunately Flash module setup is different from all other IntelliJ IDEA module types and corersponding API is not part of Community Edition, so it is not open-source. I can give you some classes/methods names that you can invoke from your plugin without seeing their implementation. To have code green and compilable you need to add FlexSupport.jar and flex-shared.jar files to your Plugin module dependencies (from <IntelliJ IDEA installation>/plugins/flex/lib/ folder)

  • SDK should be of type com.intellij.lang.javascript.flex.sdk.FlexSdkType2. The easiest way to create it is to call com.intellij.lang.javascript.flex.sdk.FlexSdkUtils.createOrGetSdk(FlexSdkType2.getInstance(), "/path/to/sdk/home"). All SWCs from <SDK>/frameworks/libs willl be included in the SDK. Note that when you select this SDK at Dependencies tab of some Flash BC - SWCs set is filtered depending on BC type (selected at General tab) and target player. You can see resulting SWC set under SDK node in the table at Dependencies tab.
  • Libraries should be of type com.intellij.lang.javascript.flex.library.FlexLibraryType.FLEX_LIBRARY.


Programmatic setting up dependency of BC on SDK or on Library is much more tricky thing impossible to guess without looking into IntelliJ IDEA Ultimate Edition source code, but it's not open-sourced. So before I give you any other hints can you please describe the whole task you want to accomplish?

Alexander

0

Hi Alexander,

Actually, I am not using the Flash Module. I have created a custom module type and custom sdk that is independent of the Flex SDK.

What I am trying to accomplish is to setup a cross compiler that uses swcs for the Falcon compiler. This has nothing to do with any Flash API.

The funny thing is, I have most of it working perfectly in your awsome IDE!

The only thing I am stuck on is getting the swcs in the custom sdk to be registered for the modules library dependenices so the classes contained can be used in code completion.

Am I breaking rules here trying to use a bit of ActionScript functionality without wanting to compile swfs? I know I will have to recreate actions that create new AS classes and interfaces, I'm pretty confident I can do that. I already have the compiler cross compiling in your IDE just fine with project forms settings etc. Its just the SWC issue right now! :)

So again, I have no dependency on the Flex module jar code in this plugin.

Mike
Apache Flex / FalconJx

0

SWC is an archive, so you need to add swc files like this:

final VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(swcFile);
    if (jarRoot != null) {
      sdkModificator.addRoot(jarRoot, OrderRootType.CLASSES);
    }

And similar way for library. Probably that was the problem. By the way you may find the source code of 'Add as library...' action in com.intellij.ide.projectView.actions.MarkLibraryRootAction class. To find the action source code I used the following algorythm:
- searched for 'Add as Library...' text (Edit | Find | Find in Path, with 'whole words only' option) - found it in ActionsBundle.properties: action.CreateLibraryFromFile.text=Add as Library...
- searched for 'CreateLibraryFromFile', found it in RichPlatformActions.xml and it poits to MarkLibraryRootAction class.

But I'm not sure that your plugin needs to introduce its own module type and SDK type. Finally what features will your plugin provide? If it is only editing ActionScript code and compiling it using FalconJx then you can probably get it out-of the box without writing a plugin.
Editing is already supported - for this you can use either Flash module or even a Java module. Yes, you can keep *.as files in Java modue, setup dependencies on swc libraries and you'll get code completion and resolve.
To enable FalconJX compiler or actually any other action you can setup an ant script or External Tool (Settings | External Tools).

Well, if you want FalconJX to work out of the box without any ant or other configuration - then yes, you need to write a plugin, but it will be enough if the plugin contains only one action like 'Build with my compiler'. So far I don't see any need in custom module and SDK type.

0

Well,

Its a bit more complicated that what I am describing here. I'm actually working with someone(he has even talked with John Lindquist about this project) right now that has a JavaScript Guice framework with injection in JS that this is going to be used with. So yes, in my view an SDK is important because we will be distributing other framework resources along with the compiler.

Second, we don't want any Flex dependencies, I am not using the Flex compiler or SDK for this project, nor the Flash Player. I wrote my own compiler and emitter for this project so it wasn't coupled with FalconJx and Apache Flex.

See; https://github.com/teotigraphix/RandoriCompiler (develop)
See; https://github.com/labriola/RandoriAS (develop)

By looking at those projects, you may understand what I am talking about here is pretty large. So yes, I see a custom Module type as a very important feature because this project wants to highlight the use of as and js. I amy be wrong, but this is the path I am taking at the moment.

I will look into that you have showed me above and see if that will register what I need.

Thanks you for your time!
Mike

0

Ok, I'm going to agree about custom SDK type. Probably you'd like to implement custom SdkAdditionalData.

Custom module type allows you to customize tabs shown in the Project Structure dialog. By default there are Sources, Paths and Dependencies. Custom module type (together with custom ModuleConfigurationEditorProvider) allows you to remove standard tab or add custom with own module-level settings.
If these 3 standard tabs is exacly what you need - keep using standard JavaModuleType. Note that it is possible to avoid 'Java' word in UI. As an example - Android module. There's no Android module type, but UI looks as if there is.

Probably you'll find Facet concept useful. Custom facet allows to have subnode of Module node at Project Structure dialog with its own additional settings. You may allow to have multiple facets per module.

0

Ok Great!

This is looking good Alexander, thank you for your answers. :)

I was able to register the swcs correctly using the JarFileSystem, so this was exactly the problem with the SWC not getting registered. I would have never found that, I'm still green with this plugin API.

I can see many things I am going to develop with IDEA, such a good framework. I have developed in Eclipse plugins but, your openapi after I get passed the shock of many missing javadocs, is much less verbose than Eclipse. Although I like Eclipse for things as well, I never play favorites in tech, just use the tool the suites the job.

I will look into facets, I was wondering about them, I am still new to IntelliJ myself, so all of this is learning the terminology with me.

I won't hesitate to ask more questions if needed. :)

Thanks again,
Mike

0
I would have never found that, I'm still green with this plugin API

The best way to learn API is to see how similar things are already implemented. I'm sure you'd find the trick with JarFileSystem as soon as you started to look how 'Add as Library...' action is implemented.

Concepts like Facets are documented in embedded help (also available online).
I think you already looked through Plugin Development topics.

0

Yeah, you are probably right, I would have found it eventually.

I spent a day researching the Go language plugin. That was a but high octane for what I needed but has a huge amount of resources, very talented programer he is.

What was really a GREAT learning resource is the DevKit plugin source code! That had everything I needed to get up to speed on, plus I could "see" everything in the UI to make connections about implementation.

Some times my perfectionism gets in the way of progress with me, but this time I said I would just write a plugin, get it to work and worry if I was doing it right after it did what I wanted it to, at least a little. :)

Mike

0

Please sign in to leave a comment.