bscotch / stitch

Tools and apps for GameMaker development: a CLI for pipeline development, a VSCode extension for coding, and more.
Other
111 stars 13 forks source link

Hiding variables marked with @access JSDOC. #227

Open softwareantics opened 6 months ago

softwareantics commented 6 months ago

It would be nice to add the ability to hide variables marked with @private, @protected, etc. Or, simply ignoring variables that have a prefix (such as an underscore).

adam-coster commented 6 months ago

By "hide" do you mean keep them out of autocomplete (would be easy)? Or, for the case of private variables, only allow them to autocomplete in the scope in which they are defined (a little difficult for basic functionality, really difficult for full functionality)?

Or should they be in autocomplete but show a warning when used?

If such variables do get used without autocomplete, would that be flagged as an error?

softwareantics commented 6 months ago

I think a good solution to start would be to hide variables from autocomplete that are marked as private via JSDocs or maybe prefixed with an underscore.

Adapting later on to provide more intelligent autocomplete would be a good idea.

Open to suggestions :)

adam-coster commented 6 months ago

This is tricky since I think it's pretty rare that you want something to be universally excluded from autocomplete. We probably need to break it down by case to figure out what kind of behavior would be useful.

Cases that come to mind:

At least for the cases I can think of, I can see a case for Typescript-style protected variables that wouldn't bee too hard to implement. private (also not accessible to constructors/objects inheriting from the parent with that variable) may be doable but definitely adds a layer of complexity.

I can see starting with implementing a @protected JSDoc for self variables that works as described above. Having a configuration option to allow specifying a prefix/pattern to treat matching variables as protected even without the JSDoc wouldn't be a big deal once the functionality was in place.

Does that cover the kind of thing you're imagining? Do you have any specific cases of things you want to hide? If so, where do you want them visible versus invisible, and why?