philippejer / vala-language-server-alpha

Basic Vala Language Server
GNU Lesser General Public License v2.1
22 stars 1 forks source link

Seq autocomplition #24

Open gavr123456789 opened 4 years ago

gavr123456789 commented 4 years ago

It seems it does not work if there is already something after(I assume that because of an error)

1 image 2 image

Prince781 commented 4 years ago

Just curious, but could you post the source code for this example? I want to test it on our language server as well.

Thanks for the hard work @philippejer by the way!

gavr123456789 commented 4 years ago

@Prince781 oh, ofc ^^
Minimal example:

class Sequence {
    int data = 0;
    public Sequence add (int a){
        this.data += a;
        return this;
    }
}

void main(){
    var test = new Sequence();
    test.add(5)
        .       //here no autocompletion
        .add(2);
}
philippejer commented 4 years ago

Hello!

Yes, the problem with this type of scenario is that my approach is quite basic, it assumes that the lines under the cursor are valid code (well, at least parse-able). So it does not grok this type of complex multi-line fluent style code unless you're editing the end of the expression (and then again, not always).

@Prince781 I guess this is the type of code where the modifications you have made on the parser must be useful :)

But even from inside the parser, it does not seem so easy to say "ignore everything after that point until you get back to regular programming" (or something like that).

Maybe, a pragmatic approach could be to compute a diff with the last "good" version of the current file, and in most cases it should be easy to:

Prince781 commented 4 years ago

@philippejer yes, FYI this issue is handled fine in VLS for the reasons you mentioned.

philippejer commented 4 years ago

Nice! (I just saw your PR in Vala ;) )