Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

I’ll need a code snippet that reproduces the issue.

foo = 
{
        bar: function(bla){}
};

Using debugShowToken, bar is noted as a localfield instead of a method.

foo.bar(bla);
Again, bar is noted as a field instead of a method, and there is no autocompletion for the arguments (bla doesn't show below).
Also, autocompletion seems to not be present for lightweight objects at all.

baz = function(){}
function baz(){}
A similar problem with instance defined methods/functions, baz is noted as a localfield instead of a method, however in both case argument autocompletion worked.

The supported cases for smart completion (and, by extent, syntax highlighting) are described on the wiki.

Essentially, unless foo in foo.bar is a hinted local variable, object name, namespace, or a similar construct with a definitive meaning, there is no way to know which object’s foo it is without parsing the file backwards mid-highlighting, which is expensive:

foo.bar();
with (obj_some) {
    foo.bar(); // obj_some's foo may not be the same as our foo, or not exist at all
}

Parsing the file backwards on each identifier to figure out whether it is inside a struct literal is also expensive - at most I could go on assumption that any name: that is not case name: is in a struct literal, but this would misfire for a handful of cases.

For local variables I am able to cheat by making various reasonable assumptions (e.g. that unindented function name in a script is a top-level function or that you are not going to sabotage the syntax highlighter by inserting decoy function declarations inside multi-line comments/strings), but neither of above can be handled this way.

I hope to eventually make auto-completion and argument help work for variously unusual cases (it’s not a very good time) as they only trigger on user input, but field syntax highlighting will likely remain similar to how it is now.

(+1)

And I though my code was spaghetti, this just goes to show how complex it is to make such an editor (thank you by the way!),
I wish you good luck continuing it, and a merry Christmas!