Comments (3)
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.
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.
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)
- How to make a third-party member function as deprecated HOT 11
- Please add an option under the 'hint' category to specify a max length for hints HOT 3
- [Annotations] false positive param-type-mismatch on a class member function HOT 5
- ERROR: script/core/hint.lua:320: attempt to index a nil value (local 'last') HOT 3
- [FEATURE-REQUEST] Configuration option to disable didRenameFiles prompt HOT 1
- Unable to use `@enum` or `@alias` type in table index (index signature) HOT 2
- Hint display is incorrect when using plugin
- Modifying `.luarc.json` instead of `settings.json` with the Extension API HOT 4
- Unexpected behavior of terminal pop-up
- `say hello` does not make helix happy - `#40fd1d7` HOT 1
- Incorrect `fix-indent` behaviour when writing for loops at root scope HOT 14
- generic param no hint HOT 2
- Table literals aren't properly checked for field injections and missing fields HOT 1
- 性能问题 CPU占用高 HOT 3
- 自动修改 require 路径出现错误
- Completion for instance of class in array of instances HOT 2
- Not using latest version of LuaCats/love2d submodule HOT 2
- Packing multiple returns into a table only shows first return value
- Disallow ? on values HOT 6
- is there way to lua-ls as a formater in ci? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lua-language-server.