clemos / haxe-sublime-bundle

Sublime Text bundle for Haxe programming language
Apache License 2.0
237 stars 86 forks source link

Auto-completion doesn't consider target parameters from hxml file. #86

Closed nadako closed 11 years ago

nadako commented 11 years ago

When using hxml file for building project, autocompletion doesn't pass target parameters (like -swf) to the --display call for haxe completion. Because of that, target-related defines are not present and autocompletion doesn't work if some library uses any code that is defined only for specific target.

For example, h3d library by Nicholas is currently flash-only and uses UInt which is only defined in haxe for flash (via #if flash) and when I try to use it in ST, I get the following error message in the ST3 bottom bar:

blahblah/h2d/Tile.hx: Class not found: UInt.

clemos commented 11 years ago

The plugin should normally pass all needed parameters, borrowed from the .hxml file it found, in particular the target. I suspect it's an issue with your project / Haxe, not with the plugin itself. For instance, UInt is not defined in Haxe3 anymore, so I believe h3d is likely Haxe2 only for now (and it used to be cross platform, by the way, not flash only...) Does your project compile in ST (Ctrl+Enter) ? Does it compile using a terminal ? What is displayed in the ST Console when compiling ? What does your .hxml look like ? The bottom bar (status bar) should display something like Main.hx (swf:test.swf) corresponding to your .hxml build if it found it. Does it ? If you still think it's an issue with the plugin, please provide a reproductible example. Regards.

RealyUniqueName commented 11 years ago

I'm sure h3d is Haxe3 only, because Nicolas is always using latest version of Haxe.

nadako commented 11 years ago

Yep, h3d is haxe3 only and I'm using haxe3. Build works. Acutally I took a look at HaxeComplete.py file and saw the commented-out line that adds target parameter to currentBuild.args, and I think that's the problem. Because the --display call uses build.args which doesn't include target parameter.

Here's my build.hxml file:

-cp src
-main Main
-lib h3d
-lib hxsl
-swf bin/Main.swf
-swf-version 11.6

And here's the sample Main.hx:

package;

class Main
{
    var enterFrameDispatcher:flash.events.IEventDispatcher;
    var engine:h3d.Engine;
    var scene:h2d.Scene;

    function new(enterFrameDispatcher)
    {
        this.enterFrameDispatcher = enterFrameDispatcher;
        engine = new h3d.Engine();
        engine.onReady = onEngineReady;
        engine.init();
    }

    function onEngineReady()
    {
        enterFrameDispatcher.addEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame);
        scene = new h2d.Scene();
    }

    function onEnterFrame(_)
    {
        scene.checkEvents();
        engine.render(scene);
    }

    static function main()
    {
        new Main(flash.Lib.current);
    }
}
clemos commented 11 years ago

My bad, autocompletion target has indeed been dropped in a recent change... It should be fixed now, please confirm. Thanks!

nadako commented 11 years ago

It works now, thanks!