-
Notifications
You must be signed in to change notification settings - Fork 2
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
With latest IntelliJ & plugin version 1.5.6, getting IllegalStateException: Attempt to modify PSI for non-committed Document! #87
Comments
@tnorbye Do you think you might be able to have a look at this, please? |
Sorry, I somehow missed this bug when it was filed in March. I just took a look -- and I can't repro this, and I've never seen it happen. And from the thread dump, this is the formatting processor which is called from IntelliJ's own formatting hook. The formatting hook does use PSI to manipulate the document -- and the error message is "Attempt to modify PSI for non-committed Document!". So in theory, the fix would be for the plugin to call But -- this should be done before formatting begins, not in the callback for an individual PSI element -- so I would think the formatting action itself should do it, not a formatting processor. And I looked at a handful of other formatting processors; all of them are doing PSI manipulation, and none of them are trying to do document manipulation. Do you have any other third party plugins installed? I wonder if one of them is doing document manipulation without committing it back to PSI, leaving the document dirty and triggering the above error on the next PSI manipulation. |
Sorry, took me a while to get back to this. It looks like the culprit is the ktlint plugin. I'll see about filing an issue there & referencing this one. |
Great, thanks for chasing this down! |
Here's the issue I filed: nbadal/ktlint-intellij-plugin#323 |
Hi Tor, The extensions are defined like this:
The order of the The
The
Now run the plugin with setup above and start with a simple document containing text:
After the first invocation of reformatting the document, it will be changed to:
At the second invocation of reformatting the document both the post formatters processors will be run and the When
Rerun the plugin and start again with file:
After the first run of reformatting the document, it is changed to:
|
Btw, ktlint plugin has been changed as well to prevent problems in case the KDoc Formatter runs before Ktlint formatter. |
@matthewadams Did you have any chance to look into this? |
No, apologies still haven't had a chance -- very busy these days and it sounds like nobody is actually blocked since it sounds like you changed ktlint to work around this? |
Our team is encountering this issue in a large multi-module project, which is quite frustrating. We've tried the latest versions of ktlint, but to no avail. If I can find some spare time this weekend, I plan to examine the reproduction provided by @paul-dingemans to gain a better understanding of the problem. Maybe I'll even submit a PR if I'm feeling real frisky. I suspect this issue does not have more traction as this only happens if you have two Intellij formatters enabled and used in the same workspace. Most projects, including many of the other Kotlin projects we have internally, use a build system plugin or CI for linting/format corrections. |
Ever since updating to the latest IntelliJ version, we've been getting the exception with root cause message
Attempt to modify PSI for non-committed Document!
.IntelliJ version info:
Plugin version:
1.5.6
Getting exception:
The text was updated successfully, but these errors were encountered: