fdorg / flashdevelop

FlashDevelop is a free and open source code editor.
MIT License
826 stars 222 forks source link

noCompletion isn't respected when using a build macro #1443

Open ciscoheat opened 7 years ago

ciscoheat commented 7 years ago

In Haxedevelop 5.2.0.3 with Haxe 3.4, @:noCompletion isn't respected for hiding fields if the class is created with a build macro. In the following example, both start and start2 are displayed.

Main.hx

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

    public function new() {
        this.| // both start and start2 are displayed
    }

    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");
        startField.meta.push({name: ":noCompletion", params: [], pos: Context.currentPos()});
        return fields;
    }
}

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

Gama11 commented 7 years ago

I don't think FD's internal completion engine supports noCompletion yet... (0 usages when doing a find in files across all FD files) - so that's probably what you're seeing. That would mean FD never gets to displaying compiler completion in this case, for whatever reason.

Interesting observation: when I add a function foo() {} at the end of Main.hx, it works as expected. Very strange.

Gama11 commented 7 years ago

Oh, I think I know what's going on... If FD gets back an empty list from Haxe, it "doesn't trust it", so to speak, and continues to display internal completion instead. Very interesting.

Gama11 commented 7 years ago

Hm.. I was about to make a PR with the change (it's just about removing a list > 0 check), but it admittedly looks quite strange (almost buggy) to have completion appear briefly and then immediately disappear because there are 0 results :/

Neverbirth commented 7 years ago

Yeah, it's strange heh, but I would probably go with it.