mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-22422 PyPreFormatProcessor doesn't need to unblock/commit document, it operates on PSI
This commit is contained in:
@@ -155,9 +155,12 @@ public class PyFromImportPostFormatProcessor implements PostFormatProcessor {
|
||||
return newFromImport;
|
||||
}
|
||||
else {
|
||||
final int oldLength = fromImport.getTextLength();
|
||||
// Add only trailing comma
|
||||
final PsiElement comma = fromImport.addAfter(generator.createComma().getPsi(), allNames[allNames.length - 1]);
|
||||
codeStyleManager.reformat(comma);
|
||||
fromImport.addAfter(generator.createComma().getPsi(), allNames[allNames.length - 1]);
|
||||
// Adjust spaces around the comma if necessary
|
||||
codeStyleManager.reformat(fromImport, true);
|
||||
myHelper.updateResultRange(oldLength, fromImport.getTextLength());
|
||||
return fromImport;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,16 +82,10 @@ public class PyPreFormatProcessor implements PreFormatProcessor {
|
||||
final PsiDocumentManager manager = PsiDocumentManager.getInstance(myProject);
|
||||
final Document document = manager.getDocument(element.getContainingFile());
|
||||
if (document != null) {
|
||||
manager.doPostponedOperationsAndUnblockDocument(document);
|
||||
try {
|
||||
// collect all comments
|
||||
element.accept(this);
|
||||
for (Couple<PsiComment> pair : myCommentReplacements) {
|
||||
pair.getFirst().replace(pair.getSecond());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
manager.commitDocument(document);
|
||||
// collect all comments
|
||||
element.accept(this);
|
||||
for (Couple<PsiComment> pair : myCommentReplacements) {
|
||||
pair.getFirst().replace(pair.getSecond());
|
||||
}
|
||||
}
|
||||
return TextRange.create(range.getStartOffset(), range.getEndOffset() + myDelta);
|
||||
|
||||
Reference in New Issue
Block a user