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

Add quick fixes for E2 warnings and errors #2871

Merged
merged 4 commits into from
Dec 9, 2023
Merged

Conversation

Vurv78
Copy link
Contributor

@Vurv78 Vurv78 commented Nov 17, 2023

image

All of the currently existing quick fixes. Good majority of warnings don't have quick fixes either because they aren't that simple or would require doing more than just replacing the string at the warning's trace.

Quick fixes allow you to address problems menu issues easily. You can tell if a warning has a quick fix if that green arrow is on the icon, and apply it by right clicking the problem and pressing "Quick fix".

Current api only supports replacing the string at the trace with another one. Maybe in the future more complex quick fixes could exist (adding something to the top of the file, moving an entire block, etc), but that's out of the scope of this pr.

And errors are not implemented mostly cause I can't really think of any that would have quick fixes. (Maybe just the = inside equation one to replace it with ==?)

  • This also reimplements the changed() on an input warning that was missing from the compiler rewrite.

@Vurv78
Copy link
Contributor Author

Vurv78 commented Nov 17, 2023

Could add an "implement all quick fixes" button to the validation bar right click menu, if people want it right now. Otherwise could be done in another PR.

@Denneisk
Copy link
Member

Error: Right parenthesis ()) missing, to close argument list
Could be quick-fixed?

If you could have a quick-fix for ,) (just remove the comma) that would also be nice.

Table[1, number] = "Test"
# Error (1/1): Cannot assign type s to object expecting n
# Fixed to ->
Table[1, string] = "Test"

? Maybe too complicated

@Vurv78
Copy link
Contributor Author

Vurv78 commented Nov 17, 2023

Table[1, number] = "Test"
# Error (1/1): Cannot assign type s to object expecting n
# Fixed to ->
Table[1, string] = "Test"

? Maybe too complicated

This seems doable, just change trace to the type (assuming it's not already) then replace with expected type

Error: Right parenthesis ()) missing, to close argument list
Could be quick-fixed?

Now this i'm not so sure. Think this can be a false positive, would need to look into it

@Denneisk
Copy link
Member

This seems doable, just change trace to the type (assuming it's not already) then replace with expected type

I actually noticed after that you can just do untyped Table[1].

@Vurv78 Vurv78 marked this pull request as draft November 26, 2023 03:11
@Vurv78
Copy link
Contributor Author

Vurv78 commented Nov 26, 2023

Marked draft as I will add support for multiple changes for more complex fixes

* Support multiple replacements
* Quick fix support for Error, although none currently implemented.
* Add (Quick fix available) at the end of a problem instead of changing icon. It's more clear and works for errors too.
@Vurv78 Vurv78 marked this pull request as ready for review December 7, 2023 03:41
* Preprocessor rewritten to use traces instead of mostly columns
* Quick fixes to convert `normal` -> `number` for preprocessor
* Quick fixes to convert non CamelCase variables to camelCase in preprocessor
* Parser supports quick fixes now
* Add warning for use of `normal` type in parser (this should really be handled in analyzer, though..)
* Add quick fix for normal use in parser
* Tokenizer supports quick fixes now
* Added invalid escape quick fix (deletes the \)
@Vurv78 Vurv78 changed the title Add quick fixes for warnings Add quick fixes for E2 warnings and errors Dec 7, 2023
@Vurv78
Copy link
Contributor Author

Vurv78 commented Dec 7, 2023

Added significantly more quick fixes and support for the preprocessor, tokenizer and parser

Also added warning for using normal type in parser.

@Vurv78 Vurv78 merged commit 33d3fac into wiremod:master Dec 9, 2023
1 check failed
@Vurv78 Vurv78 deleted the quickfix branch December 9, 2023 23:54
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