Skip to content

Commit 71a4c12

Browse files
facboygoogle-java-format Team
authored andcommitted
Fix java.lang.RuntimeException: Document is locked by write PSI operations errors
Also update to `google-java-format` 1.17.0 Fixes #960 FUTURE_COPYBARA_INTEGRATE_REVIEW=#960 from facboy:master 10cef1b PiperOrigin-RevId: 560727815
1 parent 4ebb6f5 commit 71a4c12

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

idea_plugin/build.gradle.kts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
plugins { id("org.jetbrains.intellij") version "1.13.3" }
17+
plugins { id("org.jetbrains.intellij") version "1.15.0" }
1818

1919
apply(plugin = "org.jetbrains.intellij")
2020

2121
apply(plugin = "java")
2222

2323
repositories { mavenCentral() }
2424

25-
val googleJavaFormatVersion = "1.16.0"
25+
val googleJavaFormatVersion = "1.17.0"
2626

2727
java {
2828
sourceCompatibility = JavaVersion.VERSION_11
@@ -37,7 +37,7 @@ intellij {
3737

3838
tasks {
3939
patchPluginXml {
40-
version.set("${googleJavaFormatVersion}.2")
40+
version.set("${googleJavaFormatVersion}.0")
4141
sinceBuild.set("213")
4242
untilBuild.set("")
4343
}
@@ -49,12 +49,12 @@ tasks {
4949

5050
withType<Test>().configureEach {
5151
jvmArgs(
52-
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
53-
"--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
54-
"--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
55-
"--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
56-
"--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
57-
"--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
52+
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
53+
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
54+
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
55+
"--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
56+
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
57+
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
5858
)
5959
}
6060
}

idea_plugin/src/main/java/com/google/googlejavaformat/intellij/GoogleJavaFormatImportOptimizer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public boolean supports(@NotNull PsiFile file) {
6565
return Runnables.doNothing();
6666
}
6767

68-
return () -> document.setText(text);
68+
return () -> {
69+
if (documentManager.isDocumentBlockedByPsi(document)) {
70+
documentManager.doPostponedOperationsAndUnblockDocument(document);
71+
}
72+
document.setText(text);
73+
};
6974
}
7075
}

0 commit comments

Comments
 (0)