mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-13232 Remove ignoring of multiline comments that was previously added for PY-12932
It would not help to preseve indentation of code fragments commented without whitespace after '#' (i.e. commented not in PyCharm) anyway.
This commit is contained in:
@@ -109,10 +109,6 @@ public class PyPreFormatProcessor implements PreFormatProcessor {
|
||||
if (charAfterDash == '#' || charAfterDash == ':') {
|
||||
return; // doc comment
|
||||
}
|
||||
if (commentSpansSeveralLines(comment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String commentTextWithoutDash = origText.substring(commentStart + 1);
|
||||
final String newText;
|
||||
if (isTrailingComment(comment)) {
|
||||
@@ -134,38 +130,6 @@ public class PyPreFormatProcessor implements PreFormatProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean commentSpansSeveralLines(@NotNull PsiComment comment) {
|
||||
|
||||
for (PsiElement prevElement = comment.getPrevSibling(); prevElement != null; prevElement = prevElement.getPrevSibling()) {
|
||||
if (prevElement instanceof PsiWhiteSpace) {
|
||||
if (StringUtil.countNewLines(prevElement.getText()) > 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (prevElement instanceof PsiComment) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (PsiElement nextElement = comment.getNextSibling(); nextElement != null; nextElement = nextElement.getNextSibling()) {
|
||||
if (nextElement instanceof PsiWhiteSpace) {
|
||||
if (StringUtil.countNewLines(nextElement.getText()) > 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (nextElement instanceof PsiComment) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isTrailingComment(@NotNull PsiComment comment) {
|
||||
final PsiElement prevElement = comment.getPrevSibling();
|
||||
return !(prevElement instanceof PsiWhiteSpace) || !prevElement.textContains('\n');
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# This line is not considered as part of multiline comment.
|
||||
|
||||
#for c in string.ascii_lowercase:
|
||||
# if c not in 'aeiou':
|
||||
# print(c)
|
||||
|
||||
#And this one too.
|
||||
@@ -1,7 +0,0 @@
|
||||
# This line is not considered as part of multiline comment.
|
||||
|
||||
#for c in string.ascii_lowercase:
|
||||
# if c not in 'aeiou':
|
||||
# print(c)
|
||||
|
||||
# And this one too.
|
||||
@@ -0,0 +1,4 @@
|
||||
#some
|
||||
#invalid
|
||||
#pep-8
|
||||
#comment
|
||||
@@ -0,0 +1,4 @@
|
||||
# some
|
||||
# invalid
|
||||
# pep-8
|
||||
# comment
|
||||
@@ -496,11 +496,6 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-12932
|
||||
public void testMultilineCommentIgnored() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-12938
|
||||
public void testDoubleHashCommentIgnored() {
|
||||
doTest();
|
||||
@@ -516,6 +511,11 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
// PY-13232
|
||||
public void testWhitespaceInsertedAfterHashSignInMultilineComment() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
/**
|
||||
* This test merely checks that call to {@link com.intellij.psi.codeStyle.CodeStyleManager#reformat(com.intellij.psi.PsiElement)}
|
||||
* is possible for Python sources.
|
||||
|
||||
Reference in New Issue
Block a user