Giter VIP home page Giter VIP logo

Comments (3)

tmillr avatar tmillr commented on September 26, 2024

No you didn't get anything wrong afaik. I wish this was supported too.

However, it now triggers injected-field on all user-defined values not defined in the base class like the myHelperFunction method :(

You (or the downstream user) could always just manually ignore those errors I suppose (using ---@diagnostic), and I think those funcs/methods would still get applied to the derived class type.

Also, FWIW, there's this lol:

---@class MyImpl: Base
local foo = New("MyImpl")

;(--[[@as Base]]foo).OnClick = function(self, x, y)

end

function foo:myHelperFunction()
end

...but that would have to be done manually for each overridden method, and this LSP doesn't necessarily warn you or make it obvious when you are doing so (overriding).

Another hack that might work (in some sense?):

local foo = New {
    OnClick = function(self, x, y)

    end,

    myHelperFunction = function()

    end
}

but then users would be required to call New() like this every single time...

Hopefully this gets fixed or improved if/when the LSP is refactored (#2366).

from lua-language-server.

emmericp avatar emmericp commented on September 26, 2024

FWIW I implemented this as a plugin for our stuff that just injects a @Class annotation together with a lot of @field annotations: https://github.com/DeadlyBossMods/LuaLS-Config/blob/main/DBM-Plugin.lua

from lua-language-server.

bavalpey avatar bavalpey commented on September 26, 2024

I'm looking through your solution, @emmericp and I can't wrap my head around what exactly you've done to accomplish this.

from lua-language-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.