mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 06:51:17 +07:00
Tests
This commit is contained in:
@@ -14,4 +14,5 @@ public interface PsiImportList extends PsiElement {
|
||||
PsiImportStatement findSingleClassImportStatement(String qName);
|
||||
PsiImportStatement findOnDemandImportStatement(String packageName);
|
||||
PsiImportStatementBase findSingleImportStatement(String name);
|
||||
boolean isReplaceEquivalent(PsiImportList otherList);
|
||||
}
|
||||
|
||||
@@ -44,10 +44,7 @@ public class OptimizeImportsProcessor extends AbstractLayoutCodeProcessor {
|
||||
public void run() {
|
||||
try {
|
||||
if (newImportList != null) {
|
||||
PsiImportList oldImportList = ((PsiJavaFile)file).getImportList();
|
||||
if (!oldImportList.getText().equals(newImportList.getText())) {
|
||||
oldImportList.replace(newImportList);
|
||||
}
|
||||
((PsiJavaFile)file).getImportList().replace(newImportList);
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
|
||||
@@ -182,6 +182,10 @@ public class PsiImportListImpl extends SlaveRepositoryPsiElement implements PsiI
|
||||
return (PsiImportStatementBase)myNameToSingleImportMap.get(name);
|
||||
}
|
||||
|
||||
public boolean isReplaceEquivalent(PsiImportList otherList) {
|
||||
return getText().equals(otherList.getText());
|
||||
}
|
||||
|
||||
private void initializeMaps() {
|
||||
if (myClassNameToImportMap == null) {
|
||||
myClassNameToImportMap = new HashMap();
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ImportHelper{
|
||||
|
||||
PsiImportList resultList = dummyFile.getImportList();
|
||||
PsiImportList oldList = file.getImportList();
|
||||
if (resultList.getText().equals(oldList.getText())) return null;
|
||||
if (oldList.isReplaceEquivalent(resultList)) return null;
|
||||
return resultList;
|
||||
}
|
||||
catch(IncorrectOperationException e) {
|
||||
|
||||
Reference in New Issue
Block a user