BowlerHatLLC / vscode-as3mxml

ActionScript & MXML language extension for Visual Studio Code. Develop apps for Adobe AIR, Adobe Flash Player, or Apache Royale.
https://as3mxml.com/
Apache License 2.0
257 stars 40 forks source link

Code intelligence in COMPILE::JS and COMPILE::SWF blocks #155

Closed Harbs closed 1 year ago

Harbs commented 7 years ago

It looks to me like the first target in the list of targets is used for code intelligence.

This means that if you have:

        "targets": [
            "JSRoyale",
            "SWF"
        ],

You get code intelligence for COMPILE::JS blocks but not COMPILE::SWF blocks.

If you have:

        "targets": [
            "SWF",
            "JSRoyale"
        ],

You get code intelligence for COMPILE::SWF blocks but not COMPILE::JS blocks.

Ideally, it would be best if the correct blocks would be associated with their targets. I assume this is hard, but it would be VERY useful.

joshtynjala commented 7 years ago

I tried to get this working a while back, but, unfortunately, I couldn't figure it out.

Harbs commented 7 years ago

I guess my assumption was right...

Harbs commented 7 years ago

Maybe a command to toggle the order of targets in the asconfigc file would be a decent workaround?

That way you could toggle the "main" target while working in a specific block to get code assist without going to the asconfigc file and changing it manually.

joshtynjala commented 6 years ago

@Harbs

I took a look at this one today. I've figured out how I can force COMPILE::SWF and COMPILE::JS both to be true when using the compiler for code intelligence in Visual Studio Code. Completion, hover, and other features seem to be working correctly in both blocks now.

There is one issue. If the same variable name is defined separately in both COMPILE::SWF and COMPILE::JS in the same function, but both variables have a different type, you'll now get a compiler error in Visual Studio Code that you wouldn't get when compiling from the command line.

For one example, see the layout() function in org.apache.royale.html.beads.layouts.HorizontalLayout. The contentView variable is typed as ILayoutView in COMPILE::SWF and it's typed as IParentIUIBase in COMPILE::JS. I'm sure that there are many more.

If I'm to commit this change, you're probably going to need to make a ton of changes in the Royale framework to clear up these new conflicts. I think it's the right change to make for the user experience in Visual Studio Code, but I'd like to know what you and others on the Royale team think too.

Harbs commented 6 years ago

Let me make sure I have this straight:

This is an issue only within a single function. If there are two separate functions:

COMPILE::SWF
override public function layout():Boolean
{
  // some code
}
COMPILE::JS
override public function layout():Boolean
{
  // some code
}

Rather than:

override public function layout():Boolean
{
  COMPILE::SWF
  {
    // some code
  }
  COMPILE::JS
  {
    // some code
  }

}

It will work. Right?

Additionally: If there's only SWF or JSRoyale specified in the asconfig file it will also work. Right?

joshtynjala commented 6 years ago

I completely forgot that you could create separate functions with conditional compilation... I'll need to try it out to be sure, but separate functions might not work at all with this solution because they'll conflict with each other. I may be going back to the drawing board on this one.

To be clear, I was actually suggesting that you'd simply rename the variables in the same function instead of splitting it into two functions. Both options need to work for me to commit this change, but I don't think having two separate functions will work, unfortunately.