@NotNull & simplify logic

This commit is contained in:
Kirill Likhodedov
2015-11-22 18:39:45 +03:00
parent d3fc7949db
commit 0c98c19098
2 changed files with 13 additions and 7 deletions
@@ -234,7 +234,7 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
return changeList != null;
}
public void addChangeToCorrespondingList(final Change change, final VcsKey vcsKey) {
public void addChangeToCorrespondingList(@NotNull Change change, final VcsKey vcsKey) {
final String path = ChangesUtil.getFilePath(change).getPath();
LOG.debug("[addChangeToCorrespondingList] for change " + path + " type: " + change.getType() + " have before revision: " + (change.getBeforeRevision() != null));
assert myDefault != null;
@@ -5,11 +5,13 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.OpenTHashSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -179,7 +181,7 @@ public class LocalChangeListImpl extends LocalChangeList {
});
}
boolean processChange(Change change) {
boolean processChange(@NotNull final Change change) {
LOG.debug("[process change] for '" + myName + "' isDefault: " + myIsDefault + " change: " +
ChangesUtil.getFilePath(change).getPath());
if (myIsDefault) {
@@ -188,12 +190,16 @@ public class LocalChangeListImpl extends LocalChangeList {
return true;
}
for (Change oldChange : myChangesBeforeUpdate) {
if (Comparing.equal(oldChange, change)) {
LOG.debug("[process change] adding bacuae equal to old: " + ChangesUtil.getFilePath(oldChange).getPath());
addChange(change);
return true;
boolean foundSameChange = ContainerUtil.exists(myChangesBeforeUpdate, new Condition<Change>() {
@Override
public boolean value(Change oldChange) {
return Comparing.equal(change, oldChange);
}
});
if (foundSameChange) {
LOG.debug("[process change] adding because equal to old: " + ChangesUtil.getFilePath(change).getPath());
addChange(change);
return true;
}
LOG.debug("[process change] not found");
return false;