-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support of types with dots in their name #5
Comments
I've been using double underscore as a namespace token for my own purposes. Did this work with EmmyLua? |
Well it definitely worked at some point, because the annotations were working just fine, so I guess there was a regression some time? Not sure I could tell you when though :( |
I'd rather reserve ---@class pl.List |
Well that's annoying :( I would have lots of stuff to change, over multiple projects referencing each other etc.
What are the downsides of allowing this character?
By the way, some of the types have multiple dots in them, kind of reflecting the package path.
|
The downside is just:
It makes much more sense that ---@class SomeClass
---@field thing number | string | thread | { [1]: "this" | "that", [2]: number } When you want to refer to the type of
as opposed to:
This neatly addresses #6 However, if your penlight types are accurate, you won't actually need to change anything. Because penlight does have ---@type pl.List
local list = pl.List({1, 2, 3, 4}) |
Right, that's fine maybe for the penlight example, but I do have lots of @Class (and associated @type/param etc in various projects using the lib) declarations that are using it like this: Let's say I have a ...
--------------------------------------------------------------------------------
---@class CompanyName.Bus.Message.Method
local Method = {}
---@param call CompanyName.Bus.Message.Method.Call
---@return CompanyName.Bus.Message.Method.Return
function Method.Return(call) end
--- @return CompanyName.Bus.Message.Method.Call
function Method.Call() end
--------------------------------------------------------------------------------
---@class CompanyName.Bus.Message.Signal
local Signal = {}
---@param member string The signal name
function Signal:setMember(member) end
---@param interface string The interface name
function Signal:setInterface(interface) end
---@return CompanyName.Bus.Object.Iterator
function Signal:begin() end
...
return {
Method = Method,
Signal = Signal,
...
}
For instance Do I have no other way than changing all my annotations? Looking at the code, I see it's |
Yeah, to my knowledge it was never their intention to support periods in identifiers. I assume that it was working by accident. However, you're absolutely more than welcome to fork and make that change. You'll want to update: https://github.com/Benjamin-Dobell/IntelliJ-Luanalysis/blob/master/src/main/java/com/tang/intellij/lua/doc.flex#L60 (Looks like I changed the former file in 6562d4b#diff-905bb6d2efe1bd61d74c550117c8f132L59-R59) I won't lie, GrammarKit is new to me, so why it was working in the past with periods in just one of those two locations is beyond me. Anyway, once you've made those two changes, use GrammarKit (https://github.com/JetBrains/Grammar-Kit) to regenerate, quite literally right-click the file in IntelliJ and it's in the context-menu. Then just build again and you're good to go. As mentioned, I'm unfortunately not interested in making this change myself. I absolutely understand why you want namespaces, having global types and no way of organising them is a recipe for disaster. I'd just rather solve that issue with #3, which needs further brainstorming. Maybe the solution could involve the use of periods to traverse consumer namespaces. However, as for allowing periods in names/identifiers themselves; I don't think I've ever seen a programming language that allows that. Period is usually a token reserved for indexing, which is how I'd like to use the token. |
Yeah no worries, I understand your point of view. Thanks for the details on how to regenerate it. Not sure I'll do that, but who knows. |
Yeah, impressively, the VSCode plugin actually uses the same code as the Java plugin! It's my intention to get a Luanalysis VSCode build up and running too. |
That's great :) Just as confusing, |
I stumbled into more examples of annotations in other languages allowing periods in class names. For instance https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/audits/server-response-time.js#L49-L54 Is there really no hope of ever getting this to work like in EmmyLua? :) (even though it was never intended, but still :P) |
Instead of trying to retroactively reserve |
I have a rather large codebase using EmmyLua annotations, and some types have dots (
.
) in them.It seems IntelliJ-Luanalysis doesn't support that.
This is quite useful when adding annotations to third-party libs for instance.
Example with a Penlight function:
This fails with the first @param type since the dots isn't recognized as part of the type name. Same with the return type.
The text was updated successfully, but these errors were encountered: