@@ -131,25 +131,22 @@ private void performOrganizeThenFormat(@NotNull Document document, @NotNull Virt
131
131
return ;
132
132
}
133
133
134
- new WriteCommandAction .Simple (myProject ) {
135
- @ Override
136
- protected void run () {
137
- if (myProject .isDisposed ()) {
138
- return ;
139
- }
140
-
141
- AssistUtils .applySourceEdits (myProject , file , document , fileEdit .getEdits (), Collections .emptySet ());
142
-
143
- // Committing a document here is required in order to guarantee that DartPostFormatProcessor.processText() is called afterwards.
144
- PsiDocumentManager .getInstance (myProject ).commitDocument (document );
145
-
146
- // Run this in an invoke later so that we don't exeucte the initial part of performFormat in a write action.
147
- //noinspection CodeBlock2Expr
148
- OpenApiUtils .safeInvokeLater (() -> {
149
- performFormat (document , file , true , psiFile );
150
- });
134
+ WriteCommandAction .writeCommandAction (myProject ).run (() -> {
135
+ if (myProject .isDisposed ()) {
136
+ return ;
151
137
}
152
- }.execute ();
138
+
139
+ AssistUtils .applySourceEdits (myProject , file , document , fileEdit .getEdits (), Collections .emptySet ());
140
+
141
+ // Committing a document here is required in order to guarantee that DartPostFormatProcessor.processText() is called afterwards.
142
+ PsiDocumentManager .getInstance (myProject ).commitDocument (document );
143
+
144
+ // Run this in an invoke later so that we don't exeucte the initial part of performFormat in a write action.
145
+ //noinspection CodeBlock2Expr
146
+ OpenApiUtils .safeInvokeLater (() -> {
147
+ performFormat (document , file , true , psiFile );
148
+ });
149
+ });
153
150
});
154
151
}
155
152
}
@@ -174,33 +171,30 @@ private void performFormat(@NotNull Document document, @NotNull VirtualFile file
174
171
return ;
175
172
}
176
173
177
- new WriteCommandAction .Simple (myProject ) {
178
- @ Override
179
- protected void run () {
180
- if (myProject .isDisposed ()) {
181
- return ;
182
- }
174
+ WriteCommandAction .writeCommandAction (myProject ).run (() -> {
175
+ if (myProject .isDisposed ()) {
176
+ return ;
177
+ }
183
178
184
- boolean didFormat = false ;
179
+ boolean didFormat = false ;
185
180
186
- final List <SourceEdit > edits = formatResult .getEdits ();
187
- if (edits != null && edits .size () == 1 ) {
188
- final String replacement = StringUtil .convertLineSeparators (edits .get (0 ).getReplacement ());
189
- document .replaceString (0 , document .getTextLength (), replacement );
190
- PsiDocumentManager .getInstance (myProject ).commitDocument (document );
181
+ final List <SourceEdit > edits = formatResult .getEdits ();
182
+ if (edits != null && edits .size () == 1 ) {
183
+ final String replacement = StringUtil .convertLineSeparators (edits .get (0 ).getReplacement ());
184
+ document .replaceString (0 , document .getTextLength (), replacement );
185
+ PsiDocumentManager .getInstance (myProject ).commitDocument (document );
191
186
192
- didFormat = true ;
193
- }
187
+ didFormat = true ;
188
+ }
194
189
195
- // Don't perform the save in a write action - it could invoke EDT work.
196
- if (reSave || didFormat ) {
197
- //noinspection CodeBlock2Expr
198
- OpenApiUtils .safeInvokeLater (() -> {
199
- FileDocumentManager .getInstance ().saveDocument (document );
200
- });
201
- }
190
+ // Don't perform the save in a write action - it could invoke EDT work.
191
+ if (reSave || didFormat ) {
192
+ //noinspection CodeBlock2Expr
193
+ OpenApiUtils .safeInvokeLater (() -> {
194
+ FileDocumentManager .getInstance ().saveDocument (document );
195
+ });
202
196
}
203
- }. execute ( );
197
+ });
204
198
});
205
199
}
206
200
0 commit comments