jlchmura / lpc-language-server

LPC Language Server
MIT License
11 stars 1 forks source link

Provide a way for lang server to determine infered object types. #41

Open jlchmura opened 3 months ago

jlchmura commented 3 months ago

In this example, the language server does not know what type of object is assigned the variable me.

int main(object me) {
  return me->query_is_player();
}

We need a way to tell the server that me is, for example, an object (or blueprint) of type /std/living.c. In some cases we may be able to determine this once the type checker is rebuilt to utilize flow nodes. In other situations, type inference may not be possible and we'll need a way to provide a hint.

One possibility is to use an extension of jsdoc. Example:

/**
 * Main function
 * @param {"/std/living.c"} me The living object (player or mob)
 * @returns {int} 1 if the living object  a player
 */

Where the type hint {"/std/living.c"} would imply that me is also of type object.

Note: this may only be needed in Fluff and older LD versions. The latest version of LD allows "named" object types.