-
-
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
Real-time syntax checking (even if you're not using Bucklescript) #191
Comments
I've been reluctant to add parser errors because I'm afraid to introduce an incorrect error message on a perfectly valid file. But if you have a list of really easy to spot errors, you can publish it here, maybe some of them can be implemented. For ex, the warning on partially applying parameters doesn't seem a good idea, it could cause too many false positives. by the way, thank you for your issues, they really force me to continue working on the ocaml side of this project.. |
It would make sense to start with things that don't parse (assuming your parser matches the compiler's parser faithfully when it reports an error or warning). For example:
It would be neat if the parser could usefully resynchronize after an error so it could find multiple parse errors in one pass, but just finding the first error automatically and within at most a few seconds would be a big help. I admit, the partial-application check is a stretch. How about this?
Indentation suggests that
Or here, the indentation suggests that bar is called in the else, which is not the case. Sometimes I get these when I add conditionals:
Other checks could look at indentation of match and try constructs and whether they are missing begin..end or (..). (One case for a construct followed by a less-indented statement, another for nested match/try-with where a On the other hand, while it would be useful and user-friendly to compare syntax against indentation, I'm not sure these examples justify spending a lot of time to implement them. What do you think? As for false positives, I believe IJ lets you report both errors and warnings. I expect they could be user-configurable inspections. Right-clicking in the scroll bar gives you this menu: then "Customize Highlighting Level" shows:
My pleasure. It's gratifying to see improvements after submitting issues. Frequently I don't get a response, let alone a resolution, to issues I submit to other open source projects. Also, I enjoy crafting clear and useful reports. |
plugin version: 0.81
I build
coq
from the command line. It would be quite helpful for ReasonML to highlight some syntax errors/questionable constructs in real time. It doesn't have to be 100% comprehensive, but I find I make certain mistakes over and over due to OCaml's odd syntax for certain constructs. Better to find them while I'm editing before I start the real compile. (Maybe you already support this for Bucklescript.)For example, fairly frequently I end up with semicolons where I should have "in" (too much Java coding, perhaps), such as the first line in the code below. The compiler unhelpfully reports the error at the beginning of the last line.
Perhaps you could also compare indentation to the block structure (à la Python) and have the real-time parsing show squiggly red lines for errors. For example if you have cases in match or with constructs, they need to be parentheses or in begin..end--otherwise they may include subsequent (unindented) statements.
It would also be very cool to highlight places where functions are partially applied; this isn't used all that often so I frequently misread these as regular calls, especially when I'm reading someone else's code. For example:
If you want to support this, let me know and I'll come up with a more complete list of troublesome OCaml syntax. Or if these examples aren't completely clear.
The text was updated successfully, but these errors were encountered: