mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tests fix
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
package com.intellij.lang.java;
|
||||
|
||||
import com.intellij.formatting.Block;
|
||||
import com.intellij.formatting.FormattingModel;
|
||||
import com.intellij.formatting.FormattingModelBuilder;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -47,9 +48,9 @@ public class JavaFormattingModelBuilder implements FormattingModelBuilder {
|
||||
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
|
||||
final FileElement fileElement = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
|
||||
LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
|
||||
return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), AbstractJavaBlock.createJavaBlock(fileElement,
|
||||
settings),
|
||||
FormattingDocumentModelImpl.createOn(element.getContainingFile()));
|
||||
Block block = AbstractJavaBlock.createJavaBlock(fileElement, settings);
|
||||
FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
|
||||
return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model);
|
||||
}
|
||||
|
||||
public TextRange getRangeAffectingIndent(final PsiFile file, final int offset, final ASTNode elementAtOffset) {
|
||||
|
||||
@@ -37,32 +37,30 @@ public class JavaImportOptimizer implements ImportOptimizer {
|
||||
|
||||
@NotNull
|
||||
public Runnable processFile(final PsiFile file) {
|
||||
if (file instanceof PsiJavaFile) {
|
||||
Project project = file.getProject();
|
||||
final PsiImportList newImportList = JavaCodeStyleManager.getInstance(project).prepareOptimizeImportsResult((PsiJavaFile)file);
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if (newImportList != null) {
|
||||
final PsiDocumentManager manager = PsiDocumentManager.getInstance(file.getProject());
|
||||
final Document document = manager.getDocument(file);
|
||||
if (document != null) {
|
||||
manager.commitDocument(document);
|
||||
}
|
||||
final PsiImportList oldImportList = ((PsiJavaFile)file).getImportList();
|
||||
assert oldImportList != null;
|
||||
oldImportList.replace(newImportList);
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
if (!(file instanceof PsiJavaFile)) {
|
||||
return EmptyRunnable.getInstance();
|
||||
}
|
||||
Project project = file.getProject();
|
||||
final PsiImportList newImportList = JavaCodeStyleManager.getInstance(project).prepareOptimizeImportsResult((PsiJavaFile)file);
|
||||
return new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if (newImportList != null) {
|
||||
final PsiDocumentManager manager = PsiDocumentManager.getInstance(file.getProject());
|
||||
final Document document = manager.getDocument(file);
|
||||
if (document != null) {
|
||||
manager.commitDocument(document);
|
||||
}
|
||||
final PsiImportList oldImportList = ((PsiJavaFile)file).getImportList();
|
||||
assert oldImportList != null;
|
||||
oldImportList.replace(newImportList);
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean supports(PsiFile file) {
|
||||
|
||||
@@ -76,15 +76,12 @@ public class ImportHelper{
|
||||
|
||||
List<Pair<String, Boolean>> resultList = new ArrayList<Pair<String, Boolean>>(names.size());
|
||||
for(int i = 0; i < entries.length; i++){
|
||||
PackageEntry entry = entries[i];
|
||||
//if (!entry.isSpecial()) {
|
||||
for(int j = 0; j < names.size(); j++){
|
||||
if (entryForName[j] == i){
|
||||
resultList.add(names.get(j));
|
||||
names.set(j, null);
|
||||
}
|
||||
for(int j = 0; j < names.size(); j++){
|
||||
if (entryForName[j] == i){
|
||||
resultList.add(names.get(j));
|
||||
names.set(j, null);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
for (Pair<String, Boolean> name : names) {
|
||||
if (name != null) resultList.add(name);
|
||||
|
||||
@@ -36,9 +36,8 @@ public class JavaHelper extends Helper {
|
||||
|
||||
if (element.getTreePrev() != null) {
|
||||
ASTNode prev = element.getTreePrev();
|
||||
ASTNode lastCompositePrev;
|
||||
while (prev instanceof CompositeElement && !TreeUtil.isStrongWhitespaceHolder(prev.getElementType())) {
|
||||
lastCompositePrev = prev;
|
||||
ASTNode lastCompositePrev = prev;
|
||||
prev = prev.getLastChildNode();
|
||||
if (prev == null) { // element.prev is "empty composite"
|
||||
return getIndentInner(lastCompositePrev, includeNonSpace, recursionLevel + 1);
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
package b;
|
||||
import a.*;
|
||||
|
||||
import static u.U.C;
|
||||
|
||||
public class B extends A {
|
||||
|
||||
Reference in New Issue
Block a user