diff --git a/platform/configuration-store-impl/src/ProjectStoreBase.kt b/platform/configuration-store-impl/src/ProjectStoreBase.kt index 47bef851e907..147d50ca8883 100644 --- a/platform/configuration-store-impl/src/ProjectStoreBase.kt +++ b/platform/configuration-store-impl/src/ProjectStoreBase.kt @@ -272,7 +272,8 @@ abstract class ProjectStoreBase(final override val project: Project) : Component override fun getDirectoryStorePathOrBase(): String = PathUtil.getParentPath(projectFilePath) - override suspend fun doSave(result: SaveResult, forceSavingAllSettings: Boolean) { } // dummy implementation for Upsource + // dummy implementation for Upsource + override suspend fun doSave(result: SaveResult, forceSavingAllSettings: Boolean) { } } private fun composeFileBasedProjectWorkSpacePath(filePath: String) = "${FileUtil.getNameWithoutExtension(filePath)}${WorkspaceFileType.DOT_DEFAULT_EXTENSION}" diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/FileInfo.java b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/FileInfo.java index d724d22a8391..b97165b4f9ce 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/FileInfo.java +++ b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/FileInfo.java @@ -5,7 +5,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ListWithSelection; -class FileInfo { +final class FileInfo { private final VirtualFile myFile; private final ListWithSelection myHandleType = new ListWithSelection<>(); diff --git a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java index 1289e5eb7042..b5ef9bd9e5df 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/vcs/readOnlyHandler/ReadonlyStatusHandlerImpl.java @@ -12,34 +12,47 @@ import com.intellij.openapi.components.Storage; import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.MultiValuesMap; import com.intellij.openapi.util.registry.Registry; +import com.intellij.openapi.util.text.Strings; import com.intellij.openapi.vfs.ReadonlyStatusHandler; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.WritingAccessProvider; import com.intellij.testFramework.LightVirtualFile; import com.intellij.util.containers.ContainerUtil; -import gnu.trove.THashSet; +import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import static com.intellij.openapi.util.text.StringUtil.isEmpty; +import java.util.*; @State(name = "ReadonlyStatusHandler", storages = @Storage(StoragePathMacros.WORKSPACE_FILE)) -public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements PersistentStateComponent { +public final class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements PersistentStateComponent { private static final Logger LOG = Logger.getInstance(ReadonlyStatusHandlerImpl.class); - private final Project myProject; - protected boolean myClearReadOnlyInTests; - public static class State { + private final Project myProject; + private boolean myClearReadOnlyInTests; + + public static final class State { public boolean SHOW_DIALOG = true; + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + State state = (State)o; + + if (SHOW_DIALOG != state.SHOW_DIALOG) return false; + + return true; + } + + @Override + public int hashCode() { + return (SHOW_DIALOG ? 1 : 0); + } } private State myState = new State(); @@ -68,7 +81,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements checkThreading(); - Set realFiles = new THashSet<>(originalFiles.size()); + Set realFiles = new HashSet<>(originalFiles.size()); for (VirtualFile file : originalFiles) { if (file instanceof LightVirtualFile) { VirtualFile originalFile = ((LightVirtualFile)file).getOriginalFile(); @@ -76,7 +89,9 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements file = originalFile; } } - if (file instanceof VirtualFileWindow) file = ((VirtualFileWindow)file).getDelegate(); + if (file instanceof VirtualFileWindow) { + file = ((VirtualFileWindow)file).getDelegate(); + } if (file != null) { realFiles.add(file); } @@ -166,11 +181,11 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements return fileInfos; } - public static void processFiles(final List fileInfos, @Nullable String changelist) { + public static void processFiles(@NotNull List fileInfos, @Nullable String changelist) { FileInfo[] copy = fileInfos.toArray(new FileInfo[0]); - MultiValuesMap handleTypeToFile = new MultiValuesMap<>(); + MultiMap handleTypeToFile = new MultiMap<>(); for (FileInfo fileInfo : copy) { - handleTypeToFile.put(fileInfo.getSelectedHandleType(), fileInfo.getFile()); + handleTypeToFile.putValue(fileInfo.getSelectedHandleType(), fileInfo.getFile()); } for (HandleType handleType : handleTypeToFile.keySet()) { @@ -197,8 +212,7 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements myClearReadOnlyInTests = clearReadOnlyInTests; } - private static class OperationStatusImpl extends OperationStatus { - + private static final class OperationStatusImpl extends OperationStatus { private final VirtualFile[] myReadonlyFiles; @NotNull private final String myReadOnlyReason; @@ -225,7 +239,9 @@ public class ReadonlyStatusHandlerImpl extends ReadonlyStatusHandler implements @NotNull public String getReadonlyFilesMessage() { if (hasReadonlyFiles()) { - if (!isEmpty(myReadOnlyReason)) return myReadOnlyReason; + if (!Strings.isEmpty(myReadOnlyReason)) { + return myReadOnlyReason; + } if (myReadonlyFiles.length > 1) { StringBuilder buf = new StringBuilder(); for (VirtualFile file : myReadonlyFiles) { diff --git a/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchMatcherTest.java b/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchMatcherTest.java index cc561cf0e564..6d843b36ccc4 100644 --- a/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchMatcherTest.java +++ b/platform/vcs-tests/testSrc/com/intellij/openapi/vcs/PatchMatcherTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.vcs; import com.intellij.openapi.diff.impl.patch.TextFilePatch; @@ -12,14 +12,12 @@ import java.nio.file.Paths; import java.util.Collections; import java.util.List; -import static com.intellij.openapi.vcs.PatchAutoInitTest.create; - public class PatchMatcherTest extends HeavyPlatformTestCase { public void testMatchPathAboveProject() { Path ioFile = Paths.get(myProject.getBasePath()).getParent().resolve("file.txt"); PathKt.createFile(ioFile); myFilesToDelete.add(ioFile); - TextFilePatch patch = create("../file.txt"); + TextFilePatch patch = PatchAutoInitTest.create("../file.txt"); MatchPatchPaths iterator = new MatchPatchPaths(myProject); List filePatchInProgresses = iterator.execute(Collections.singletonList(patch));