clemos / haxe-sublime-bundle

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

Autocompletion doesn't work when adding noCompletion in a build class #269

Open ciscoheat opened 7 years ago

ciscoheat commented 7 years ago

With Haxe 3.4, adding @:noCompletion to a class created with a build macro prevents autocompletion.

Main.hx

@:build(Builder.build())
class Main 
{   
    static function main() {
        new Main();
    }

    public function new() {
        this.| // "No autocompletion available"
    }

    public function start() {
        trace("start");
    }

    @:noCompletion public function start2() {
        trace("start2");
    }
}

Builder.hx

import haxe.macro.Context;

using Lambda;

class Builder
{
    public static function build() {
        var fields = Context.getBuildFields();
        var startField = fields.find(function(f) return f.name == "start");
        // Commenting out this line makes it work:
        startField.meta.push({name: ":noCompletion", params: [], pos: Context.currentPos()});
        return fields;
    }
}

haxe --display Main.hx@0 returns <list></list>, so that seems to work.

clemos commented 7 years ago

Isn't this a feature :p ? In any case, I guess it should be reported to the compiler, shouldn't it ?

ciscoheat commented 7 years ago

Yes, it seems to work, I got it confused with the same issue for Haxedevelop. But I see now that there is no autocompletion for startField inside Builder.hx.

import haxe.macro.Context;

using Lambda;

class Builder
{
    public static function build() {
        var fields = Context.getBuildFields();
        fields.| // autocompletion for array works fine
        var startField = fields.find(function(f) return f.name == "start");
        startField.meta.push({name: ":noCompletion", params: [], pos: Context.currentPos()});
        startField.| // no autocompletion, no error
        return fields;
    }
}