Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2011-08-26 20:37:42 +0000
committerJeff Johnston2011-08-26 20:40:21 +0000
commit79c2a82d9f6628a0000780b761da5f6a13bb79d3 (patch)
treea7841596b80370780e47e04ab7a6d412db9d3fac
parenta412c3967ae55368fc9fee6b139fb12a7042459c (diff)
downloadorg.eclipse.linuxtools-79c2a82d9f6628a0000780b761da5f6a13bb79d3.tar.gz
org.eclipse.linuxtools-79c2a82d9f6628a0000780b761da5f6a13bb79d3.tar.xz
org.eclipse.linuxtools-79c2a82d9f6628a0000780b761da5f6a13bb79d3.zip
Fix ChangeLog plug-in to find method/function.
2011-08-26 Jeff Johnston <jjohnstn@redhat.com> * src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java (extractSynchronizeModelInfo): Create PatchFile using IResource. (getWorkspaceFile): Removed. (filterNonExistentFiles): Ditto. (guessFunctionNames): Fix to remove usage of FileStoreEditorInput which does not work with TextDocumentProvider. Switch to use FileEditorInput and pass IResource from PatchFile. * src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java (compare): Use resource paths to compare. * src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java (PatchFile): Change constructor to take an IResource. (getPath): Fix to use IResource to get path. (equals): Compare resources rather than paths.
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/ChangeLog16
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java18
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java2
-rw-r--r--changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java57
4 files changed, 28 insertions, 65 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/ChangeLog b/changelog/org.eclipse.linuxtools.changelog.core/ChangeLog
index dad77615c4..401ea5835d 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/ChangeLog
+++ b/changelog/org.eclipse.linuxtools.changelog.core/ChangeLog
@@ -1,3 +1,19 @@
+2011-08-26 Jeff Johnston <jjohnstn@redhat.com>
+
+ * src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java (extractSynchronizeModelInfo):
+ Create PatchFile using IResource.
+ (getWorkspaceFile): Removed.
+ (filterNonExistentFiles): Ditto.
+ (guessFunctionNames): Fix to remove usage of FileStoreEditorInput which
+ does not work with TextDocumentProvider. Switch to use FileEditorInput and
+ pass IResource from PatchFile.
+ * src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java (compare): Use
+ resource paths to compare.
+ * src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java (PatchFile):
+ Change constructor to take an IResource.
+ (getPath): Fix to use IResource to get path.
+ (equals): Compare resources rather than paths.
+
2011-08-24 Jeff Johnston <jjohnstn@redhat.com>
* build.properties: Add icons to binary.
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java
index 8fff90a685..2620b4f394 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFile.java
@@ -17,7 +17,6 @@ import java.util.ArrayList;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
/**
*
@@ -26,7 +25,6 @@ import org.eclipse.core.runtime.Path;
*/
public class PatchFile {
- private IPath fpath;
private IStorage storage;
private ArrayList<PatchRangeElement> pranges = new ArrayList<PatchRangeElement>();
@@ -51,14 +49,10 @@ public class PatchFile {
this.removedfile = removedfile;
}
- public PatchFile(String filePath) {
- fpath = new Path(filePath);
+ public PatchFile(IResource resource) {
+ this.resource = resource;
}
- public PatchFile(IPath filePath) {
- fpath = filePath;
- }
-
public void addLineRange(int from, int to, boolean localChange) {
pranges.add(new PatchRangeElement(from, to, localChange));
@@ -76,7 +70,7 @@ public class PatchFile {
public IPath getPath() {
- return fpath;
+ return resource.getFullPath();
}
public IStorage getStorage() {
@@ -87,10 +81,6 @@ public class PatchFile {
this.storage = storage;
}
- public void setResource(IResource resource) {
- this.resource = resource;
- }
-
public IResource getResource() {
return resource;
}
@@ -107,7 +97,7 @@ public class PatchFile {
PatchFile that = (PatchFile) o;
// check fpath + count
- if (!this.fpath.removeTrailingSeparator().toString().equals(that.getPath().removeTrailingSeparator().toString()) ||
+ if (!this.resource.equals(that.resource) ||
this.countRanges() != that.countRanges())
return false;
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java
index 81ab784dac..d961325cdf 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PatchFileComparator.java
@@ -15,7 +15,7 @@ import java.util.Comparator;
public class PatchFileComparator implements Comparator<PatchFile> {
public int compare(PatchFile p1, PatchFile p2) {
- return p1.getPath().toOSString().compareToIgnoreCase(p2.getPath().toOSString());
+ return p1.getResource().getLocation().toOSString().compareToIgnoreCase(p2.getResource().getLocation().toOSString());
}
}
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java
index 408cfe3043..0803e48247 100644
--- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java
+++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/changelog/core/actions/PrepareChangeLogAction.java
@@ -23,14 +23,10 @@ import org.eclipse.compare.rangedifferencer.RangeDifference;
import org.eclipse.compare.rangedifferencer.RangeDifferencer;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -65,11 +61,10 @@ import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IURIEditorInput;
+import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.FileDocumentProvider;
import org.eclipse.ui.editors.text.StorageDocumentProvider;
-import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.part.FileEditorInput;
@@ -184,14 +179,10 @@ public class PrepareChangeLogAction extends ChangeLogAction {
extractSynchronizeModelInfo((ISynchronizeModelElement)element, newPath, newList, removeList, changeList);
else {
if (!(d.getName().equals("ChangeLog"))) { //$NON-NLS-1$
- IPath finalPath = path.append(d.getName());
- PatchFile p = new PatchFile(finalPath);
+ PatchFile p = new PatchFile(d.getResource());
int kind = d.getKind() & Differencer.CHANGE_TYPE_MASK;
if (kind == Differencer.CHANGE) {
changeList.add(p);
- // Save the resource so we can later figure out what
- // lines changed
- p.setResource(d.getResource());
} else if (kind == Differencer.ADDITION) {
p.setNewfile(true);
newList.add(p);
@@ -206,14 +197,10 @@ public class PrepareChangeLogAction extends ChangeLogAction {
}
} else {
if (!(d.getName().equals("ChangeLog"))) { //$NON-NLS-1$
- IPath finalPath = path.append(d.getName());
- PatchFile p = new PatchFile(finalPath);
+ PatchFile p = new PatchFile(d.getResource());
int kind = d.getKind() & Differencer.CHANGE_TYPE_MASK;
if (kind == Differencer.CHANGE) {
changeList.add(p);
- // Save the resource so we can later figure out what lines
- // changed
- p.setResource(d.getResource());
} else if (kind == Differencer.ADDITION) {
p.setNewfile(true);
newList.add(p);
@@ -332,7 +319,7 @@ public class PrepareChangeLogAction extends ChangeLogAction {
// New, Removed, and Changed lists.
for (SyncInfo info : infos) {
int kind = SyncInfo.getChange(info.getKind());
- PatchFile p = new PatchFile(info.getLocal().getFullPath());
+ PatchFile p = new PatchFile(info.getLocal());
// Check the type of entry and sort into lists. Do not add an entry
// for ChangeLog files.
@@ -346,8 +333,6 @@ public class PrepareChangeLogAction extends ChangeLogAction {
} else if (kind == SyncInfo.CHANGE) {
if (info.getLocal().getType() == IResource.FILE) {
changeList.add(p);
- // Save the resource so we can later figure out which lines were changed
- p.setResource(info.getLocal());
}
}
} else {
@@ -556,13 +541,8 @@ public class PrepareChangeLogAction extends ChangeLogAction {
// check if the file type is supported
// get editor input for target file
- IPath path = getWorkspaceRoot().getLocation().append(patchFileInfo.getPath());
- IFileStore fileStore = EFS.getLocalFileSystem().getStore(path);
- IFile workspaceFile = getWorkspaceFile(fileStore);
- IURIEditorInput fei = null;
- if (workspaceFile != null)
- fei = new FileEditorInput(workspaceFile);
- fei = new FileStoreEditorInput(fileStore);
+
+ IFileEditorInput fei = new FileEditorInput((IFile)patchFileInfo.getResource());
SourceEditorInput sei = new SourceEditorInput(patchFileInfo.getStorage());
@@ -622,31 +602,8 @@ public class PrepareChangeLogAction extends ChangeLogAction {
ChangelogPlugin.getDefault().getLog().log(
new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR,
e.getMessage(), e));
+ e.printStackTrace();
}
return fnames;
}
-
- private static IFile getWorkspaceFile(IFileStore fileStore) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile[] files = root.findFilesForLocationURI(fileStore.toURI());
- files = filterNonExistentFiles(files);
- if (files == null || files.length == 0)
- return null;
-
- // for now only return the first file
- return files[0];
- }
-
- private static IFile[] filterNonExistentFiles(IFile[] files) {
- if (files == null)
- return null;
-
- int length = files.length;
- ArrayList<IFile> existentFiles = new ArrayList<IFile>(length);
- for (int i = 0; i < length; i++) {
- if (files[i].exists())
- existentFiles.add(files[i]);
- }
- return existentFiles.toArray(new IFile[existentFiles.size()]);
- }
}

Back to the top