Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
4c1cbb95
Commit
4c1cbb95
authored
8 years ago
by
Mikhail Golubev
Browse files
Options
Download
Email Patches
Plain Diff
PY-22422 PyPreFormatProcessor doesn't need to unblock/commit document, it operates on PSI
parent
b7b82877
Branches unavailable
Tags unavailable
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/src/com/jetbrains/python/formatter/PyFromImportPostFormatProcessor.java
+5
-2
...ins/python/formatter/PyFromImportPostFormatProcessor.java
python/src/com/jetbrains/python/formatter/PyPreFormatProcessor.java
+4
-10
.../com/jetbrains/python/formatter/PyPreFormatProcessor.java
with
9 additions
and
12 deletions
+9
-12
python/src/com/jetbrains/python/formatter/PyFromImportPostFormatProcessor.java
+
5
-
2
View file @
4c1cbb95
...
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
python/src/com/jetbrains/python/formatter/PyPreFormatProcessor.java
+
4
-
10
View file @
4c1cbb95
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help