Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-03-10 04:50:03 -0500
committerMilos Kleint2011-03-10 04:50:03 -0500
commit824b5b4cca8ff1524cf7489fa22b3716e1bafd74 (patch)
tree463c02ed3f24688e3a51d5149b32752945777556 /org.eclipse.m2e.editor.xml
parentaa508686c8a384b6b34bd6e7e0256efaaa5fb177 (diff)
downloadm2e-core-824b5b4cca8ff1524cf7489fa22b3716e1bafd74.tar.gz
m2e-core-824b5b4cca8ff1524cf7489fa22b3716e1bafd74.tar.xz
m2e-core-824b5b4cca8ff1524cf7489fa22b3716e1bafd74.zip
shall always find the IFile closest to root (the project's own pom file). Have I already mentioned I don't like IFile and the workspace concept in general?
Ideally we should find a match for the fie in open editors but this shall be sufficient.
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java19
1 files changed, 9 insertions, 10 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
index 924bf505..dfce5ce0 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/internal/XmlUtils.java
@@ -95,23 +95,22 @@ public class XmlUtils {
IFileStore folder = buf.getFileStore();
File file = new File(folder.toURI());
IPath path = Path.fromOSString(file.getAbsolutePath());
- Stack<IResource> stack = new Stack<IResource>();
+ Stack<IFile> stack = new Stack<IFile>();
//here we need to find the most inner project to the path.
//we do so by shortening the path and remembering all the resources identified.
// at the end we pick the last one from the stack. is there a catch to it?
- IResource ifile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
+ IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
if (ifile != null) {
stack.push(ifile);
- } else {
- while(path.segmentCount() > 1) {
- ResourcesPlugin.getWorkspace().getRoot().findMember(path);
- if(ifile != null) {
- stack.push(ifile);
- }
- path = path.removeFirstSegments(1);
+ }
+ while(path.segmentCount() > 1) {
+ IResource ires = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if(ires != null && ires instanceof IFile) {
+ stack.push((IFile)ires);
}
+ path = path.removeFirstSegments(1);
}
- IResource res = stack.empty() ? null : stack.pop();
+ IFile res = stack.empty() ? null : stack.pop();
if (res != null) {
IProject prj = res.getProject();
//the project returned is in a way unrelated to nested child poms that don't have an opened project,

Back to the top