This commit is contained in:
Eugene Vigdorchik
2005-03-24 20:50:48 +03:00
parent 4d05597d4d
commit 1bb3ff8c00
4 changed files with 7 additions and 5 deletions
@@ -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) {