[vcs] Deprecate VcsContextFactory.create FilePath with directory detector

Detector is called right away, so there is no point in it.
Just inline the call & deprecate the method.
This commit is contained in:
Kirill Likhodedov
2015-05-28 15:16:47 +03:00
parent 4bfee6cf4e
commit 61d879a2a4
3 changed files with 10 additions and 6 deletions
@@ -74,7 +74,10 @@ public interface VcsContextFactory {
* @param file the file for which the FilePath should be created.
* @param detector - called to get to know whether the file is directory, if local file is not found
* @return the FilePath instance.
*
* @deprecated to remove in IDEA 16. Check the virtual file right away and pass to the right constructor.
*/
@Deprecated
FilePath createFilePathOn(final File file, final NotNullFunction<File, Boolean> detector);
/**
@@ -54,10 +54,9 @@ public class VcsContextFactoryImpl implements VcsContextFactory {
public FilePath createFilePathOn(final File file, final NotNullFunction<File, Boolean> detector) {
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
if (virtualFile != null) {
// detector information (loaded here lazily) is not needed - we have real file
return FilePathImpl.create(file);
return createFilePathOn(virtualFile);
}
return FilePathImpl.create(file, detector.fun(file).booleanValue());
return createFilePathOn(file, detector.fun(file).booleanValue());
}
public FilePath createFilePathOn(final File file, final boolean isDirectory) {
@@ -18,8 +18,10 @@ package org.jetbrains.idea.svn.history;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.actions.VcsContextFactory;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.NotNullFunction;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.RootUrlInfo;
import org.jetbrains.idea.svn.SvnUtil;
@@ -84,8 +86,8 @@ public class SvnRepositoryLocation implements RepositoryLocation {
if (rootForUrl != null) {
String relativePath = SvnUtil.getRelativeUrl(rootForUrl.getUrl(), fullPath);
File file = new File(rootForUrl.getPath(), relativePath);
result = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file, detector);
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
result = virtualFile != null ? VcsUtil.getFilePath(virtualFile) : VcsUtil.getFilePath(file, detector.fun(file).booleanValue());
}
return result;