-
Notifications
You must be signed in to change notification settings - Fork 221
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
Downgrade editor placeholder in source file
from error to warning.
#547
Downgrade editor placeholder in source file
from error to warning.
#547
Conversation
cc @ahoppen , in case there's a better way to hold these APIs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Tested via this code:
I guess logically the code must be formatted even with the warnings. (like Xcode does) |
0aa33d1
to
c71c897
Compare
Right, I missed the handling of this error during my testing. This should be fixed now. Thanks! |
There is some situation where is the placeholder throws an error, but I guess the code should be formatted even with these errors. (like Xcode does with Re-Indent)
Expected results:
|
Those cases would be trickier to handle, since it would require handling individual error cases in very specific ways. For example, the
so the file as written is syntactically invalid, because a function parameter has to have a colon and a type. We can't just ignore those in the current implementation because we hang certain formatting commands off of individual tokens, some of those commands have to be balanced, and if a token is missing, we'll end up imbalanced. We can do better here, I think. Since swift-format's algorithm was first written, we can now visit all the tokens (even the missing ones) in the tree, not just the ones that are present in source text. That would remedy the imbalanced-command problem and give us a way to handle cases like this better, and essentially would let us format even arbitrarily invalid code. That's a bigger refactoring though, so I'm not going to try to tackle it in this PR. But it's a great future enhancement. |
…errors Downgrade `editor placeholder in source file` from error to warning.
No tests for this currently, since we don't have tests for the top-level API layer (we should, though). Tested by running the command line tool manually:
Fixes #526.