|
From: <caw...@us...> - 2007-05-30 13:26:55
|
Revision: 2560
http://svn.sourceforge.net/rubyeclipse/?rev=2560&view=rev
Author: cawilliams
Date: 2007-05-30 06:26:51 -0700 (Wed, 30 May 2007)
Log Message:
-----------
change way we search for external types. Since we don't have package name, we need to just do an exhaustive search for a sourcefolder root which seems like a match for the fulel file path. then we use that to break down teh path into it's root/src folders/filename and use that to grab the actual file in the model.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/ExternalFileTypeInfo.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/ExternalFileTypeInfo.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/ExternalFileTypeInfo.java 2007-05-30 13:25:39 UTC (rev 2559)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/ExternalFileTypeInfo.java 2007-05-30 13:26:51 UTC (rev 2560)
@@ -61,15 +61,18 @@
IRubyModel jmodel= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
IPath[] enclosedPaths= scope.enclosingProjectsAndJars();
- // TODO Remove the last segment of the path, it's the filename. Also remove "package names" from path
- String rootPath = new File(fPath).getParent();
+ IPath filePath = new Path(fPath);
for (int i= 0; i < enclosedPaths.length; i++) {
IPath curr= enclosedPaths[i];
- if (curr.segmentCount() == 1) {
+ if (curr.segmentCount() == 1) { // check the project
IRubyProject jproject= jmodel.getRubyProject(curr.segment(0));
- ISourceFolderRoot root= jproject.getSourceFolderRoot(rootPath);
- if (root.exists()) {
- return findElementInRoot(root);
+ ISourceFolderRoot[] roots = jproject.getSourceFolderRoots();
+ for (int j = 0; j < roots.length; j++) {
+ ISourceFolderRoot root = roots[j];
+ if (root.isExternal() && root.getPath().isPrefixOf(filePath)) {
+ IPath relative = filePath.removeFirstSegments(root.getPath().segmentCount());
+ return findElementInRoot(root, relative);
+ }
}
}
}
@@ -78,18 +81,22 @@
for (int i= 0; i < projects.length; i++) {
IRubyProject jproject= projects[i];
if (!paths.contains(jproject.getPath())) {
- ISourceFolderRoot root= jproject.getSourceFolderRoot(fPath);
- if (root.exists()) {
- return findElementInRoot(root);
+ ISourceFolderRoot[] roots = jproject.getSourceFolderRoots();
+ for (int j = 0; j < roots.length; j++) {
+ ISourceFolderRoot root = roots[j];
+ if (root.isExternal() && root.getPath().isPrefixOf(filePath)) {
+ IPath relative = filePath.removeFirstSegments(root.getPath().segmentCount());
+ return findElementInRoot(root, relative);
+ }
}
}
}
return null;
}
- private IRubyElement findElementInRoot(ISourceFolderRoot root) {
+ private IRubyElement findElementInRoot(ISourceFolderRoot root, IPath relative) {
IRubyElement res;
- ISourceFolder frag= root.getSourceFolder(getPackageName());
+ ISourceFolder frag= root.getSourceFolder(relative.removeLastSegments(1).segments());
String extension= getExtension();
String fullName= getFileName() + '.' + extension;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|