Skip to content
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

LuaLS annotations for E2 API #2855

Closed
wants to merge 1 commit into from
Closed

Conversation

Denneisk
Copy link
Member

@Denneisk Denneisk commented Nov 15, 2023

Lets you use LuaLS annotations for E2 functions. This is part of #2759, but is not a complete solution. This only handles annotation and attributes.

Included in this PR is a demo conversion of the core extension.

Defined annotations:

  • @cost <value> - Sets the individual cost of the function
  • @deprecated [message] - Marks the function as deprecated, with optional message
  • @nodiscard - Marks the function as nodiscard
  • @noreturn - Marks the function as noreturn

Example usage:

---@cost 5000
---@deprecated This is deprecated!
---@nodiscard
e2function void myFunction(string arg) {

This also supports old attribute style

---@cost 500
---@deprecated New deprecation
[nodiscard, deprecated = "Deprecated deprecation"]
e2function ...

Limitations include how this doesn't process params, returns, or anything like that. That'll be for a future installment, likely.
You'll also notice this works by piggybacking off of the current preprocessor. This is the simplest solution. Ideally in the future annotation processor would be self-sustained but that requires figuring out #2759. This is more of an intermediary step to ease the transition before such a system comes into place.

The current way attributes were processed had to be modified to fit this system in. Using annotations is the cleaner option now.

I kept in code for descriptions since it may be useful for future reference. The code is functional, it's just useless without an efficient way to transmit.

@Vurv78
Copy link
Contributor

Vurv78 commented Nov 15, 2023

I don't see the point of this when the root issue still exists e2function

Likely when that api is done this file will be left untouched and deprecated.

@Denneisk
Copy link
Member Author

Denneisk commented Nov 15, 2023

I don't see the point of this when the root issue still exists e2function

So there's less work to do in the future converting from one system to another. Future additions can just use this and someone (most likely you) down the line won't have to write those few annotations.

@Vurv78
Copy link
Contributor

Vurv78 commented Nov 15, 2023

I don't see the point of this when the root issue still exists e2function

So there's less work to do in the future converting from one system to another. Future additions can just use this and someone (most likely you) down the line won't have to write those few annotations.

There's only a few annotations. Another like 30 lines to the pr won't hurt. I'm more referring to you adding onto the extpp which I intend to deprecate entirely and leave there. My concept would use debug.getinfo to scan the function's source for docs rather than each file

@Denneisk
Copy link
Member Author

Ehh I thought they would be cool..

@Denneisk Denneisk closed this Nov 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants