-
Notifications
You must be signed in to change notification settings - Fork 186
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
Refresh Syntactic/SemanticDocument between rule evaluations to better handle overlapping patches #1204
Comments
If there are multiple rules, the fixed output is only written once at the end, and each We could maybe before compting the new fixed output, relying on this assertion, trigger a new compilation? |
Maybe I am misunderstanding, but this is indeed what I was suggesting by
|
I have experienced some @bjaglin Have you ever seen this |
@adpi2 I think I have. I will try to write a scripted. |
Apologies, the |
Looking at the code and seeing that patches are applied after execution of all rules, I am wondering if we should update this issue and keep it open. It seems that rules (no matter if they are semantic or syntactic) all run against the same state (source & semanticdb). @olafurpg was that a design decision or a result of the most simple implementation? Making syntactic rules actually incremental/successive would only require some implementation changes in |
When several rules are requested on the same invocation (either explicitly or implicitly via the
.scalafix.conf
rules attribute),and there is at least one semantic rule that is not in the first position, that one might observe a source file that does not match the semanticDB available in the classpath (raising a, theStaleSemanticdbError
), because another rule patched that file after compilationSyntactic/SemanticDocument
passed as input is the same for all rules, regardless of patches applied by other rules. In other words, rules appear to run in parallel and not in the sequential order one would expect based on the config/CLI args. That causes unexpectedPatch
behavior when different rules touch the same tokens, leading to invalid source code after the invocation.The workaround is to run these conflicting rules in separate invocations to force several patch applications.
Mitigation ideas:
ScalafixArguments.run()
inIN_PLACE
mode), but for other modes (ScalafixArguments.evaluate()
orCHECK
/STDOUT
), we will need temporary files.IN_PLACE
mode).ScalafixArguments
would need to take an optional callback that would instruct the client to recompile sources after the patches of a rule is applied. Forsbt-scalafix
, given the execution model of sbt, the safe way to do that would be from a command sincecompile
would have to be triggered multiple times within the same invocation. If we want the current input keys to benefit from that, we should investigate to which extend we could useExtracted#runTask
, which has limitations.The text was updated successfully, but these errors were encountered: