mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
[vcs] ApplyPatchContext: remove unused methods
All of addAffectedFile, addPendingRename, registerMissingDirectory update corresponding collections, but none of these collections are queried anywhere.
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
|
||||
package com.intellij.openapi.diff.impl.patch;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -18,11 +17,8 @@ public class ApplyPatchContext {
|
||||
private final int mySkipTopDirs;
|
||||
private final boolean myCreateDirectories;
|
||||
private final boolean myAllowRename;
|
||||
private Map<VirtualFile, String> myPendingRenames = null;
|
||||
private final Map<VirtualFile, FilePath> myPathsBeforeRename = new HashMap<VirtualFile, FilePath>();
|
||||
private final TreeSet<String> myMissingDirectories = new TreeSet<String>();
|
||||
private final List<FilePath> myAffectedFiles = new ArrayList<FilePath>();
|
||||
|
||||
|
||||
public ApplyPatchContext(final VirtualFile baseDir, final int skipTopDirs, final boolean createDirectories, final boolean allowRename) {
|
||||
myBaseDir = baseDir;
|
||||
mySkipTopDirs = skipTopDirs;
|
||||
@@ -50,48 +46,8 @@ public class ApplyPatchContext {
|
||||
return new ApplyPatchContext(myBaseDir, mySkipTopDirs, false, false);
|
||||
}
|
||||
|
||||
public void addPendingRename(VirtualFile file, String newName) {
|
||||
if (myPendingRenames == null) {
|
||||
myPendingRenames = new HashMap<VirtualFile, String>();
|
||||
}
|
||||
myPendingRenames.put(file, newName);
|
||||
}
|
||||
|
||||
public void applyPendingRenames() throws IOException {
|
||||
if (myPendingRenames != null) {
|
||||
for(Map.Entry<VirtualFile, String> entry: myPendingRenames.entrySet()) {
|
||||
final VirtualFile file = entry.getKey();
|
||||
registerBeforeRename(file);
|
||||
file.rename(FilePatch.class, entry.getValue());
|
||||
addAffectedFile(file);
|
||||
}
|
||||
myPendingRenames = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMissingDirectory(final VirtualFile existingDir, final String[] pathNameComponents, final int firstMissingIndex) {
|
||||
String path = existingDir.getPath();
|
||||
for(int i=firstMissingIndex; i<pathNameComponents.length-1; i++) {
|
||||
path += "/" + pathNameComponents [i];
|
||||
myMissingDirectories.add(FileUtil.toSystemDependentName(path));
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<String> getMissingDirectories() {
|
||||
return Collections.unmodifiableSet(myMissingDirectories);
|
||||
}
|
||||
|
||||
public void addAffectedFile(FilePath filePath) {
|
||||
myAffectedFiles.add(filePath);
|
||||
}
|
||||
|
||||
public List<FilePath> getAffectedFiles() {
|
||||
return Collections.unmodifiableList(myAffectedFiles);
|
||||
}
|
||||
|
||||
public void registerBeforeRename(final VirtualFile file) {
|
||||
FilePath path = VcsUtil.getFilePath(new File(file.getPath()), file.isDirectory());
|
||||
addAffectedFile(path);
|
||||
myPathsBeforeRename.put(file, path);
|
||||
}
|
||||
|
||||
@@ -100,8 +56,4 @@ public class ApplyPatchContext {
|
||||
if (path != null) return path;
|
||||
return VcsUtil.getFilePath(file);
|
||||
}
|
||||
|
||||
public void addAffectedFile(final VirtualFile file) {
|
||||
addAffectedFile(VcsUtil.getFilePath(file));
|
||||
}
|
||||
}
|
||||
|
||||
-14
@@ -22,10 +22,8 @@ import com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.FilePathImpl;
|
||||
import com.intellij.openapi.vcs.changes.CommitContext;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -43,13 +41,6 @@ public abstract class ApplyFilePatchBase<T extends FilePatch> implements ApplyFi
|
||||
return myPatch;
|
||||
}
|
||||
|
||||
private FilePath getTarget(final VirtualFile file) {
|
||||
if (myPatch.isNewFile()) {
|
||||
return new FilePathImpl(file, myPatch.getBeforeFileName(), false);
|
||||
}
|
||||
return VcsUtil.getFilePath(file);
|
||||
}
|
||||
|
||||
public Result apply(final VirtualFile fileToPatch,
|
||||
final ApplyPatchContext context,
|
||||
final Project project,
|
||||
@@ -58,7 +49,6 @@ public abstract class ApplyFilePatchBase<T extends FilePatch> implements ApplyFi
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("apply patch called for : " + fileToPatch.getPath());
|
||||
}
|
||||
context.addAffectedFile(getTarget(fileToPatch));
|
||||
if (myPatch.isNewFile()) {
|
||||
applyCreate(fileToPatch, commitContext);
|
||||
} else if (myPatch.isDeletedFile()) {
|
||||
@@ -90,7 +80,6 @@ public abstract class ApplyFilePatchBase<T extends FilePatch> implements ApplyFi
|
||||
if (!beforeNameComponents [beforeNameComponents.length-1].equals(afterNameComponents [afterNameComponents.length-1])) {
|
||||
context.registerBeforeRename(file);
|
||||
file.rename(FilePatch.class, afterNameComponents [afterNameComponents.length-1]);
|
||||
context.addAffectedFile(file);
|
||||
}
|
||||
boolean needMove = (beforeNameComponents.length != afterNameComponents.length);
|
||||
if (!needMove) {
|
||||
@@ -103,7 +92,6 @@ public abstract class ApplyFilePatchBase<T extends FilePatch> implements ApplyFi
|
||||
}
|
||||
context.registerBeforeRename(file);
|
||||
file.move(FilePatch.class, moveTarget);
|
||||
context.addAffectedFile(file);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
@@ -125,7 +113,6 @@ public abstract class ApplyFilePatchBase<T extends FilePatch> implements ApplyFi
|
||||
VirtualFile oldDir = findFileToPatchByComponents(context, beforeNameComponents, changedIndex+1);
|
||||
VirtualFile newDir = findFileToPatchByComponents(context.getPrepareContext(), afterNameComponents, changedIndex+1);
|
||||
if (oldDir != null && newDir == null) {
|
||||
context.addPendingRename(oldDir, afterNameComponents [changedIndex]);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -162,7 +149,6 @@ public abstract class ApplyFilePatchBase<T extends FilePatch> implements ApplyFi
|
||||
}
|
||||
}
|
||||
else {
|
||||
context.registerMissingDirectory(patchedDir, pathNameComponents, i);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user