I’m trying to make the auto-completion work with my class, but I can’t find a way to make auto completion know that “this class is a child of that class”.
Please try putting a —@DeepInspect comment on the class() function definition.
---@DeepInspect function class() end
This will prevent Glider from caching the class() return value for performance reasons. Adding the comment should only be necessary for core library functions that are too dynamic to cache the results.
Since there are no formal “classes” in lua, the class aware autocomplete is slightly open to interpretation, sorry about this confusion. While we make the best attempt to analyze your source code and provide you with the best results, the dynamic nature of Lua makes this difficult. When we say “class aware autocomplete” we mean Gliders ability to track class instances and provide autocomplete suggestions on them. This works best for library functions and simple factory type oop methodologies but we found metatable based oop difficult to analyze properly from a performance standpoint.
If Glider fails to recognize a class, you can add annotations to help it figure out classes like this:
--the following table just gives Glider an example of what a spaceship object looks like ---@classdef spaceship local SpaceshipPrototype= {} SpaceshipPrototype.speed = 0 --this just tells Glider that speed is a number SpaceshipPrototype.name = "" --this just tells Glider that name is a string SpaceshipPrototype.isAlive = true --this just tells Glider that isAlive is a bool ... ... --Note that you do not need both of the annotations, any one is sufficient. ---@return @class spaceship local function createSpaceship() end ---@class spaceship local spaceshipInstance = createSpaceship()
---@classdef Ammo Ammo = class(Actor) ---@return @class Ammo function Ammo.new(...) return Ammo(...) end function Ammo:init(params) Actor.init(self, params) self.renderComponent = RenderComponent.new() --- code... --- end function Ammo:update() Actor.update(self) --- more code... --- end
So now, I get the init & update function when I call Ammo.new().
I wish there would be a way to see the autocompletion from “myAmmo.renderComponent” though. Right now, a “not so efficient way” to do that is by adding something like :
under the “function Ammo.new(…)” line (or anywhere else) so that way, any instances of Ammo knows the class of renderComponent. But it would be great if it could detect it inside the init() function automaticly. Just on wish-list :).
Otherwise, the CTRL-Click is all buggy (Go to Declaration). When I CTRL-Click on RenderComponent (or any “class”), it often leads me to a completely random file. Any explanation for this ?
Finally, is it possible that I need to open all file before auto completion works ? I have 7 file named Enemy1, Enemy2, Enemy3… , Enemy7, in my auto-completion I only see Enemy1 and Enemy2 until I open the other files. Anybody got that issue ?
Sorry about the delay in getting back to you. You may let Glider know about superclasses like this:
---@classdef spaceship @extends ship
So you can use this to explicitly tell Glider about any inherited members.
Otherwise, the CTRL-Click is all buggy (Go to Declaration). When I CTRL-Click on RenderComponent (or any “class”), it often leads me to a completely random file. Any explanation for this ?
Where does it end up going? Any patterns in this behaviour?
Finally, is it possible that I need to open all file before auto completion works ? I have 7 file named Enemy1, Enemy2, Enemy3… , Enemy7, in my auto-completion I only see Enemy1 and Enemy2 until I open the other files. Anybody got that issue ?
For performance reasons Glider does not scan all your project files proactively. It only scans them when opened in the editor. To change this behaviour please see this screenshot:
Please try putting a —@DeepInspect comment on the class() function definition.
---@DeepInspect function class() end
This will prevent Glider from caching the class() return value for performance reasons. Adding the comment should only be necessary for core library functions that are too dynamic to cache the results.
Since there are no formal “classes” in lua, the class aware autocomplete is slightly open to interpretation, sorry about this confusion. While we make the best attempt to analyze your source code and provide you with the best results, the dynamic nature of Lua makes this difficult. When we say “class aware autocomplete” we mean Gliders ability to track class instances and provide autocomplete suggestions on them. This works best for library functions and simple factory type oop methodologies but we found metatable based oop difficult to analyze properly from a performance standpoint.
If Glider fails to recognize a class, you can add annotations to help it figure out classes like this:
--the following table just gives Glider an example of what a spaceship object looks like ---@classdef spaceship local SpaceshipPrototype= {} SpaceshipPrototype.speed = 0 --this just tells Glider that speed is a number SpaceshipPrototype.name = "" --this just tells Glider that name is a string SpaceshipPrototype.isAlive = true --this just tells Glider that isAlive is a bool ... ... --Note that you do not need both of the annotations, any one is sufficient. ---@return @class spaceship local function createSpaceship() end ---@class spaceship local spaceshipInstance = createSpaceship()
Ok, so for the CTRL_Click being buggy, I found out that it’s when the file isn’t open, so this is related to problem #3 where I have to open file before in order for Glider to scan the project files, as you mentioned.
I did have the option “Scan Entire Project” checked, anything else to make Glider scan everything ? I had that option checked all along.
---@classdef Ammo Ammo = class(Actor) ---@return @class Ammo function Ammo.new(...) return Ammo(...) end function Ammo:init(params) Actor.init(self, params) self.renderComponent = RenderComponent.new() --- code... --- end function Ammo:update() Actor.update(self) --- more code... --- end
So now, I get the init & update function when I call Ammo.new().
I wish there would be a way to see the autocompletion from “myAmmo.renderComponent” though. Right now, a “not so efficient way” to do that is by adding something like :
under the “function Ammo.new(…)” line (or anywhere else) so that way, any instances of Ammo knows the class of renderComponent. But it would be great if it could detect it inside the init() function automaticly. Just on wish-list :).
Otherwise, the CTRL-Click is all buggy (Go to Declaration). When I CTRL-Click on RenderComponent (or any “class”), it often leads me to a completely random file. Any explanation for this ?
Finally, is it possible that I need to open all file before auto completion works ? I have 7 file named Enemy1, Enemy2, Enemy3… , Enemy7, in my auto-completion I only see Enemy1 and Enemy2 until I open the other files. Anybody got that issue ?
Sorry about the delay in getting back to you. You may let Glider know about superclasses like this:
---@classdef spaceship @extends ship
So you can use this to explicitly tell Glider about any inherited members.
Otherwise, the CTRL-Click is all buggy (Go to Declaration). When I CTRL-Click on RenderComponent (or any “class”), it often leads me to a completely random file. Any explanation for this ?
Where does it end up going? Any patterns in this behaviour?
Finally, is it possible that I need to open all file before auto completion works ? I have 7 file named Enemy1, Enemy2, Enemy3… , Enemy7, in my auto-completion I only see Enemy1 and Enemy2 until I open the other files. Anybody got that issue ?
For performance reasons Glider does not scan all your project files proactively. It only scans them when opened in the editor. To change this behaviour please see this screenshot:
Ok, so for the CTRL_Click being buggy, I found out that it’s when the file isn’t open, so this is related to problem #3 where I have to open file before in order for Glider to scan the project files, as you mentioned.
I did have the option “Scan Entire Project” checked, anything else to make Glider scan everything ? I had that option checked all along.