mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: NotNull in getChanges
SvnIntegrateChangesTask calls getChanges() with null CLMGate, although it could later fail with NPE in the SvnChangeProvider. Substitute it with an equivalent fake implementation.
This commit is contained in:
@@ -20,13 +20,12 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.VcsProviderMarker;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The provider of change information (from the point of view of VCS).
|
||||
*
|
||||
* @author max
|
||||
*/
|
||||
public interface ChangeProvider extends VcsProviderMarker {
|
||||
/**
|
||||
@@ -41,11 +40,12 @@ public interface ChangeProvider extends VcsProviderMarker {
|
||||
* @param dirtyScope a changes on the virtual file system
|
||||
* @param builder a builder of VCS changes
|
||||
* @param progress a current progress object
|
||||
* @param addGate
|
||||
* @throws VcsException if there there is a VCS specific problem
|
||||
*/
|
||||
void getChanges(final VcsDirtyScope dirtyScope, final ChangelistBuilder builder, final ProgressIndicator progress,
|
||||
final ChangeListManagerGate addGate) throws VcsException;
|
||||
void getChanges(@NotNull VcsDirtyScope dirtyScope,
|
||||
@NotNull ChangelistBuilder builder,
|
||||
@NotNull ProgressIndicator progress,
|
||||
@NotNull ChangeListManagerGate addGate) throws VcsException;
|
||||
|
||||
/**
|
||||
* Returns true if the initial unsaved modification of a document should cause dirty scope invalidation
|
||||
|
||||
@@ -105,7 +105,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
private final IgnoredFilesComponent myIgnoredIdeaLevel;
|
||||
private boolean myExcludedConvertedToIgnored;
|
||||
private volatile ProgressIndicator myUpdateChangesProgressIndicator = createProgressIndicator();
|
||||
@NotNull private volatile ProgressIndicator myUpdateChangesProgressIndicator = createProgressIndicator();
|
||||
|
||||
public static final Topic<LocalChangeListsLoadedListener> LISTS_LOADED = new Topic<LocalChangeListsLoadedListener>(
|
||||
"LOCAL_CHANGE_LISTS_LOADED", LocalChangeListsLoadedListener.class);
|
||||
@@ -747,8 +747,11 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
}
|
||||
}
|
||||
|
||||
private void actualUpdate(final UpdatingChangeListBuilder builder, final VcsDirtyScope scope, final AbstractVcs vcs,
|
||||
final DataHolder dataHolder, final ChangeListManagerGate gate) {
|
||||
private void actualUpdate(@NotNull UpdatingChangeListBuilder builder,
|
||||
@NotNull VcsDirtyScope scope,
|
||||
@NotNull AbstractVcs vcs,
|
||||
@NotNull DataHolder dataHolder,
|
||||
@NotNull ChangeListManagerGate gate) {
|
||||
try {
|
||||
final ChangeProvider changeProvider = vcs.getChangeProvider();
|
||||
if (changeProvider != null) {
|
||||
|
||||
@@ -726,6 +726,7 @@ public class ChangeListWorker implements ChangeListsWriteOperations {
|
||||
myListsToDisappear.addAll(names);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
ChangeListManagerGate createSelfGate() {
|
||||
return new MyGate(this);
|
||||
}
|
||||
|
||||
+3
-2
@@ -22,6 +22,7 @@ import com.intellij.openapi.vcs.changes.ChangeProvider;
|
||||
import com.intellij.openapi.vcs.changes.ChangelistBuilder;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScope;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -34,8 +35,8 @@ public class MockDelayingChangeProvider implements ChangeProvider {
|
||||
myLock = new Object();
|
||||
}
|
||||
|
||||
public void getChanges(final VcsDirtyScope dirtyScope, final ChangelistBuilder builder, final ProgressIndicator progress,
|
||||
final ChangeListManagerGate addGate)
|
||||
public void getChanges(@NotNull final VcsDirtyScope dirtyScope, @NotNull final ChangelistBuilder builder, @NotNull final ProgressIndicator progress,
|
||||
@NotNull final ChangeListManagerGate addGate)
|
||||
throws VcsException {
|
||||
synchronized (myLock) {
|
||||
if (myExecuteInsideUpdate == null) {
|
||||
|
||||
+5
-4
@@ -30,6 +30,7 @@ import com.intellij.testFramework.fixtures.TempDirTestFixture;
|
||||
import com.intellij.testFramework.vcs.AbstractJunitVcsTestCase;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
@@ -190,10 +191,10 @@ public class ExternalChangesDetectionVcsTest extends AbstractJunitVcsTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChanges(VcsDirtyScope dirtyScope,
|
||||
final ChangelistBuilder builder,
|
||||
ProgressIndicator progress,
|
||||
ChangeListManagerGate addGate) throws VcsException {
|
||||
public void getChanges(@NotNull VcsDirtyScope dirtyScope,
|
||||
@NotNull final ChangelistBuilder builder,
|
||||
@NotNull ProgressIndicator progress,
|
||||
@NotNull ChangeListManagerGate addGate) throws VcsException {
|
||||
for (FilePath path : dirtyScope.getDirtyFiles()) {
|
||||
builder.processUnversionedFile(path.getVirtualFile());
|
||||
}
|
||||
|
||||
+2
-2
@@ -70,8 +70,8 @@ public class CvsChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChanges(final VcsDirtyScope dirtyScope, final ChangelistBuilder builder, final ProgressIndicator progress,
|
||||
final ChangeListManagerGate addGate) throws VcsException {
|
||||
public void getChanges(@NotNull final VcsDirtyScope dirtyScope, @NotNull final ChangelistBuilder builder, @NotNull final ProgressIndicator progress,
|
||||
@NotNull final ChangeListManagerGate addGate) throws VcsException {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Processing changes for scope " + dirtyScope);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,11 @@ public class GitChangeProvider implements ChangeProvider {
|
||||
@NotNull private final FileDocumentManager myFileDocumentManager;
|
||||
@NotNull private final ProjectLevelVcsManager myVcsManager;
|
||||
|
||||
public GitChangeProvider(@NotNull Project project, @NotNull Git git, ChangeListManager changeListManager,
|
||||
@NotNull FileDocumentManager fileDocumentManager, @NotNull ProjectLevelVcsManager vcsManager) {
|
||||
public GitChangeProvider(@NotNull Project project,
|
||||
@NotNull Git git,
|
||||
@NotNull ChangeListManager changeListManager,
|
||||
@NotNull FileDocumentManager fileDocumentManager,
|
||||
@NotNull ProjectLevelVcsManager vcsManager) {
|
||||
myProject = project;
|
||||
myGit = git;
|
||||
myChangeListManager = changeListManager;
|
||||
@@ -62,10 +65,10 @@ public class GitChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChanges(final VcsDirtyScope dirtyScope,
|
||||
final ChangelistBuilder builder,
|
||||
final ProgressIndicator progress,
|
||||
final ChangeListManagerGate addGate) throws VcsException {
|
||||
public void getChanges(@NotNull VcsDirtyScope dirtyScope,
|
||||
@NotNull final ChangelistBuilder builder,
|
||||
@NotNull final ProgressIndicator progress,
|
||||
@NotNull final ChangeListManagerGate addGate) throws VcsException {
|
||||
final GitVcs vcs = GitVcs.getInstance(myProject);
|
||||
if (vcs == null) {
|
||||
// already disposed or not yet initialized => ignoring
|
||||
@@ -109,7 +112,7 @@ public class GitChangeProvider implements ChangeProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public static void appendNestedVcsRootsToDirt(final VcsDirtyScope dirtyScope, GitVcs vcs, final ProjectLevelVcsManager vcsManager) {
|
||||
private static void appendNestedVcsRootsToDirt(final VcsDirtyScope dirtyScope, GitVcs vcs, final ProjectLevelVcsManager vcsManager) {
|
||||
final Set<FilePath> recursivelyDirtyDirectories = dirtyScope.getRecursivelyDirtyDirectories();
|
||||
if (recursivelyDirtyDirectories.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -71,8 +71,8 @@ public class HgChangeProvider implements ChangeProvider {
|
||||
public void doCleanup(List<VirtualFile> files) {
|
||||
}
|
||||
|
||||
public void getChanges(VcsDirtyScope dirtyScope, ChangelistBuilder builder,
|
||||
ProgressIndicator progress, ChangeListManagerGate addGate) throws VcsException {
|
||||
public void getChanges(@NotNull VcsDirtyScope dirtyScope, @NotNull ChangelistBuilder builder,
|
||||
@NotNull ProgressIndicator progress, @NotNull ChangeListManagerGate addGate) throws VcsException {
|
||||
if (myProject.isDisposed()) return;
|
||||
final Collection<HgChange> changes = new HashSet<HgChange>();
|
||||
changes.addAll(process(builder, dirtyScope.getRecursivelyDirtyDirectories()));
|
||||
|
||||
@@ -77,8 +77,8 @@ public class SvnChangeProvider implements ChangeProvider {
|
||||
mySvnFileUrlMapping = (SvnFileUrlMappingImpl) vcs.getSvnFileUrlMapping();
|
||||
}
|
||||
|
||||
public void getChanges(@NotNull VcsDirtyScope dirtyScope, @NotNull ChangelistBuilder builder, @Nullable ProgressIndicator progress,
|
||||
final ChangeListManagerGate addGate) throws VcsException {
|
||||
public void getChanges(@NotNull VcsDirtyScope dirtyScope, @NotNull ChangelistBuilder builder, @NotNull ProgressIndicator progress,
|
||||
@NotNull ChangeListManagerGate addGate) throws VcsException {
|
||||
final SvnScopeZipper zipper = new SvnScopeZipper(dirtyScope);
|
||||
zipper.run();
|
||||
|
||||
@@ -138,7 +138,7 @@ public class SvnChangeProvider implements ChangeProvider {
|
||||
}
|
||||
|
||||
private static void processUnsaved(@NotNull VcsDirtyScope dirtyScope,
|
||||
ChangeListManagerGate addGate,
|
||||
@NotNull ChangeListManagerGate addGate,
|
||||
@NotNull SvnChangeProviderContext context)
|
||||
throws SVNException {
|
||||
FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
|
||||
|
||||
@@ -25,14 +25,12 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.InvokeAfterUpdateMode;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vcs.changes.*;
|
||||
import com.intellij.openapi.vcs.changes.ui.CommitChangeListDialog;
|
||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vcs.update.*;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -337,7 +335,7 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
|
||||
if (!myVcs.getProject().isDisposed()) {
|
||||
try {
|
||||
new SvnChangeProvider(myVcs).getChanges(dirtyScope, changesBuilder, indicator, null);
|
||||
new SvnChangeProvider(myVcs).getChanges(dirtyScope, changesBuilder, indicator, new FakeGate());
|
||||
}
|
||||
catch (VcsException e) {
|
||||
caughtError.set(SvnBundle.message("action.Subversion.integrate.changes.error.unable.to.collect.changes.text", e.getMessage()));
|
||||
@@ -357,4 +355,63 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable {
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
|
||||
private static class FakeGate implements ChangeListManagerGate {
|
||||
@Override
|
||||
public List<LocalChangeList> getListsCopy() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LocalChangeList findChangeList(String name) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList addChangeList(String name, String comment) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChangeList findOrCreateList(String name, String comment) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editComment(String name, String comment) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editName(String oldName, String newName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListsToDisappear(Collection<String> names) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStatus getStatus(VirtualFile file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FileStatus getStatus(@NotNull FilePath filePath) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileStatus getStatus(File file) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultChangeList(@NotNull String list) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user