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

interface script scope #7

Open
bmos opened this issue Apr 9, 2022 · 2 comments
Open

interface script scope #7

bmos opened this issue Apr 9, 2022 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@bmos
Copy link

bmos commented Apr 9, 2022

When running luacheck on a lua file attached to an interface object, luacheck doesn't know what the parent template of the file is (so it doesn't know about the functions whitelisted in that template). Since this is not a function of my parser script, but rather of luacheck, I would have to fork luacheck iteself to add some feature for scope detection (which would be FG specific) if I wanted to actually 'fix' this.

One easier option is to add all functions to a global definition table which would resolve those errors. The downside is that luacheckrc would not know if you're calling a function that doesn't exist in that interface object. For example, using "setComboBoxReadOnly" would not show an error if used in a script that was attached to a numbercontrol. Effectively it would be whitelisting all functions of all interface objects for use in all interface scripts.

Another option is to add per-file definitions via a lua comment such as "-- luacheck: globals getName" which would allow use of that function in the file. This is a significant task for each developer, but would preserve much more linting functionality.

@bmos bmos added the help wanted Extra attention is needed label Apr 9, 2022
@bmos
Copy link
Author

bmos commented Apr 10, 2022

luacheck might actually do what I need here.
https://luacheck.readthedocs.io/en/stable/config.html#per-file-and-per-path-overrides

@bmos bmos added the enhancement New feature or request label Apr 10, 2022
@bmos
Copy link
Author

bmos commented Apr 10, 2022

It would require generating a luacheck file for each project it's used in (something I was already considering that could be a big improvement for execution speed and flexibility).

  • Parse project to create an array linking script filenames to their interface object names.
  • Run current parsing logic on the inherited dataset (such as CoreRPG and Moon Tracker extension).
  • Use inherited dataset to add per-file whitelists for any files found in project.

The downside is that you would have to re-run this program on the project directory whenever you created a new file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant