diff options
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.java | 19 |
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, |