Hopefuly last empty import list placement issue

This commit is contained in:
Roman Shevchenko
2010-08-12 20:52:08 +04:00
parent 87b0c2b795
commit 86d114f730
4 changed files with 22 additions and 1 deletions
@@ -96,10 +96,17 @@ public class ParseUtil extends ParseUtilBase {
if (anImport == null || !isEmptyImportList(anImport)) return;
final TreeElement next = (TreeElement)TreeUtil.skipElements(anImport.getTreeNext(), ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET);
if (next != null && next != anImport) {
if (next != null) {
anImport.rawRemove();
next.rawInsertBeforeMe(anImport);
}
else {
final TreeElement last = (TreeElement)root.getLastChildNode();
if (last != null && last != anImport) {
anImport.rawRemove();
last.rawInsertAfterMe(anImport);
}
}
}
private static void bindComments(ASTNode root) {
@@ -0,0 +1,7 @@
// unclosed comment
/*
import java.io.*;
class a {
}
@@ -0,0 +1,6 @@
PsiJavaFile:UnclosedComment.java
PsiComment(END_OF_LINE_COMMENT)('// unclosed comment')
PsiWhiteSpace('\n')
PsiComment(C_STYLE_COMMENT)('/*\n\nimport java.io.*;\n\nclass a {\n}')
PsiImportList
<empty list>
@@ -24,4 +24,5 @@ public class CommonJavaParsingTest extends JavaParsingTestCase{
public void testIncompleteCodeBlock() { doTest(true); }
public void testImportListBug() { doTest(true); }
public void testRefParamsAfterError() { doTest(true); }
public void testUnclosedComment() { doTest(true); } // todo: fix
}