-
Notifications
You must be signed in to change notification settings - Fork 233
ScalametaTokenizer: group sequences of whitespace #3786
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
Conversation
scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
Show resolved
Hide resolved
scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScannerTokens.scala
Show resolved
Hide resolved
These will contain contiguous sequences of horizontal whitespace, or sequences of newlines, ignoring trailing or embedded horizontal space.
This looks like a small breaking change for consumers of the tokenizer, since consecutive whitespaces are now collapsed into composite tokens. Scalafix rules are impacted by that change since tokens are exposed at the document level and via each element of the tree without any indirection, so instead of trying to abstract that change away, I am considering signalling it via a breaking change bump. Which got me wondering:
|
Oh well, I didn't realize scalafix was looking at tokens as well.
We usually try to avoid breaking changes... that is, if we know they are breaking. But no, no plans.
@tgodzik Sometime ago, we were debating whether to add some parameters to ScalametaParser, perhaps this might be one case. I think we ended up thinking Dialect is enough, don't remember why. |
I guess in this case a setting would make sense, though not sure how to sensibly add it. We can have a separate tokenized method maybe? |
Any chance you could give me some pointers so that I look at that to unblock the bump on Scalafix side? I went through the tokenisation code paths, but I am not sure where to start. |
I guess we could just add another method to ScalametaTokenizer which will take options. We can then just use that explicitely from scalafix? If needed we can expose it later via the extension methods, but I think it should not be necessary right now. |
@bjaglin let me do it in the next day or two, and release, if this is blocking you. I'm generally in the middle of fixing some bugs that i found by attempting to use scalafmt on the dotty codebase, but can complete the fixes in the next patch. |
does scalafix use the tokenizer directly? or through the parser? |
Only through the parser. |
Also, let's once again make it default, as before scalameta#3786.
Also, let's once again make it default, as before #3786.
Add and use uber whitespace-token containers; these will contain contiguous sequences of horizontal whitespace, or sequences of newlines, ignoring trailing or embedded horizontal space.