mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs]: cleanUp remove deprecated usage, lambdify
This commit is contained in:
@@ -36,7 +36,6 @@ import com.intellij.openapi.roots.JdkOrderEntry;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -82,19 +81,17 @@ public class DvcsUtil {
|
||||
/**
|
||||
* Comparator for virtual files by name
|
||||
*/
|
||||
public static final Comparator<VirtualFile> VIRTUAL_FILE_PRESENTATION_COMPARATOR = new Comparator<VirtualFile>() {
|
||||
public int compare(final VirtualFile o1, final VirtualFile o2) {
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (o1 == null) {
|
||||
return -1;
|
||||
}
|
||||
if (o2 == null) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getPresentableUrl().compareTo(o2.getPresentableUrl());
|
||||
public static final Comparator<VirtualFile> VIRTUAL_FILE_PRESENTATION_COMPARATOR = (o1, o2) -> {
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (o1 == null) {
|
||||
return -1;
|
||||
}
|
||||
if (o2 == null) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getPresentableUrl().compareTo(o2.getPresentableUrl());
|
||||
};
|
||||
|
||||
@NotNull
|
||||
@@ -105,12 +102,7 @@ public class DvcsUtil {
|
||||
@NotNull
|
||||
public static List<VirtualFile> findVirtualFilesWithRefresh(@NotNull List<File> files) {
|
||||
RefreshVFsSynchronously.refreshFiles(files);
|
||||
return ContainerUtil.mapNotNull(files, new Function<File, VirtualFile>() {
|
||||
@Override
|
||||
public VirtualFile fun(File file) {
|
||||
return VfsUtil.findFileByIoFile(file, false);
|
||||
}
|
||||
});
|
||||
return ContainerUtil.mapNotNull(files, file -> VfsUtil.findFileByIoFile(file, false));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,17 +116,12 @@ public class DvcsUtil {
|
||||
|
||||
@NotNull
|
||||
public static String getShortRepositoryName(@NotNull Repository repository) {
|
||||
return getShortRepositoryName(repository.getProject(), repository.getRoot());
|
||||
return VcsImplUtil.getShortVcsRootName(repository.getProject(), repository.getRoot());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getShortNames(@NotNull Collection<? extends Repository> repositories) {
|
||||
return StringUtil.join(repositories, new Function<Repository, String>() {
|
||||
@Override
|
||||
public String fun(Repository repository) {
|
||||
return getShortRepositoryName(repository);
|
||||
}
|
||||
}, ", ");
|
||||
return StringUtil.join(repositories, (Function<Repository, String>)repository -> getShortRepositoryName(repository), ", ");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -220,12 +207,7 @@ public class DvcsUtil {
|
||||
ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeCompleted(project);
|
||||
}
|
||||
|
||||
public static final Comparator<Repository> REPOSITORY_COMPARATOR = new Comparator<Repository>() {
|
||||
@Override
|
||||
public int compare(Repository o1, Repository o2) {
|
||||
return o1.getPresentableUrl().compareTo(o2.getPresentableUrl());
|
||||
}
|
||||
};
|
||||
public static final Comparator<Repository> REPOSITORY_COMPARATOR = Comparator.comparing(Repository::getPresentableUrl);
|
||||
|
||||
public static void assertFileExists(File file, String message) throws IllegalStateException {
|
||||
if (!file.exists()) {
|
||||
@@ -248,12 +230,7 @@ public class DvcsUtil {
|
||||
|
||||
@NotNull
|
||||
public static String tryLoadFile(@NotNull final File file, @Nullable String encoding) throws RepoStateException {
|
||||
return tryOrThrow(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return StringUtil.convertLineSeparators(FileUtil.loadFile(file, encoding)).trim();
|
||||
}
|
||||
}, file);
|
||||
return tryOrThrow(() -> StringUtil.convertLineSeparators(FileUtil.loadFile(file, encoding)).trim(), file);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -406,12 +383,7 @@ public class DvcsUtil {
|
||||
}
|
||||
|
||||
public static <T extends Repository> List<T> sortRepositories(@NotNull Collection<T> repositories) {
|
||||
List<T> validRepositories = ContainerUtil.filter(repositories, new Condition<T>() {
|
||||
@Override
|
||||
public boolean value(T t) {
|
||||
return t.getRoot().isValid();
|
||||
}
|
||||
});
|
||||
List<T> validRepositories = ContainerUtil.filter(repositories, t -> t.getRoot().isValid());
|
||||
Collections.sort(validRepositories, REPOSITORY_COMPARATOR);
|
||||
return validRepositories;
|
||||
}
|
||||
@@ -492,12 +464,8 @@ public class DvcsUtil {
|
||||
|
||||
@Nullable
|
||||
public static PushSupport getPushSupport(@NotNull final AbstractVcs vcs) {
|
||||
return ContainerUtil.find(Extensions.getExtensions(PushSupport.PUSH_SUPPORT_EP, vcs.getProject()), new Condition<PushSupport>() {
|
||||
@Override
|
||||
public boolean value(final PushSupport support) {
|
||||
return support.getVcs().equals(vcs);
|
||||
}
|
||||
});
|
||||
return ContainerUtil.find(Extensions.getExtensions(PushSupport.PUSH_SUPPORT_EP, vcs.getProject()),
|
||||
support -> support.getVcs().equals(vcs));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -507,12 +475,7 @@ public class DvcsUtil {
|
||||
|
||||
@NotNull
|
||||
public static String joinShortNames(@NotNull Collection<? extends Repository> repositories, int limit) {
|
||||
return joinWithAnd(ContainerUtil.map(repositories, new Function<Repository, String>() {
|
||||
@Override
|
||||
public String fun(@NotNull Repository repository) {
|
||||
return getShortRepositoryName(repository);
|
||||
}
|
||||
}), limit);
|
||||
return joinWithAnd(ContainerUtil.map(repositories, (Function<Repository, String>)repository -> getShortRepositoryName(repository)), limit);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -523,7 +486,7 @@ public class DvcsUtil {
|
||||
if (size == 2) return strings.get(0) + " and " + strings.get(1);
|
||||
|
||||
boolean isLimited = limit >= 2 && limit < size;
|
||||
int listCount = isLimited ? limit - 1 : size - 1;
|
||||
int listCount = (isLimited ? limit : size) - 1;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < listCount; i++) {
|
||||
|
||||
Reference in New Issue
Block a user