use of com.intellij.openapi.vcs.changes.patch.RelativePathCalculator in project intellij-community by JetBrains.
the class ModuleVcsPathPresenter method getPresentableRelativePath.
@Override
public String getPresentableRelativePath(@NotNull final ContentRevision fromRevision, @NotNull final ContentRevision toRevision) {
final FilePath fromPath = fromRevision.getFile();
final FilePath toPath = toRevision.getFile();
// need to use parent path because the old file is already not there
final VirtualFile fromParent = getParentFile(fromPath);
final VirtualFile toParent = getParentFile(toPath);
if (fromParent != null && toParent != null) {
String moduleResult = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
final boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
Module fromModule = fileIndex.getModuleForFile(fromParent, hideExcludedFiles);
Module toModule = fileIndex.getModuleForFile(toParent, hideExcludedFiles);
if (fromModule == null || toModule == null || fromModule.equals(toModule))
return null;
VirtualFile fromContentRoot = fileIndex.getContentRootForFile(fromParent, hideExcludedFiles);
if (fromContentRoot == null)
return null;
String relativePath = VfsUtilCore.getRelativePath(fromParent, fromContentRoot, File.separatorChar);
assert relativePath != null;
relativePath += File.separatorChar;
if (!fromPath.getName().equals(toPath.getName())) {
relativePath += fromPath.getName();
}
return getPresentableRelativePathFor(fromModule, fromContentRoot, relativePath);
}
});
if (moduleResult != null)
return moduleResult;
}
final RelativePathCalculator calculator = new RelativePathCalculator(toPath.getPath(), fromPath.getPath());
calculator.execute();
final String result = calculator.getResult();
return result != null ? result.replace("/", File.separator) : null;
}
use of com.intellij.openapi.vcs.changes.patch.RelativePathCalculator in project intellij-community by JetBrains.
the class PlatformVcsPathPresenter method getPresentableRelativePath.
public String getPresentableRelativePath(final ContentRevision fromRevision, final ContentRevision toRevision) {
RelativePathCalculator calculator = new RelativePathCalculator(toRevision.getFile().getPath(), fromRevision.getFile().getPath());
calculator.execute();
final String result = calculator.getResult();
return (result == null) ? null : result.replace("/", File.separator);
}
Aggregations