Fix 'Open tcl namespace' search
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/ScriptModelUtil.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/ScriptModelUtil.java
index dcedda5..90d6d98 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/ScriptModelUtil.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/ScriptModelUtil.java
@@ -11,6 +11,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
@@ -30,8 +31,10 @@
* @param unit
*/
public static void reconcile(ISourceModule unit) throws ModelException {
- unit.reconcile(false /* don't force problem detection */,
- null /* use primary owner */, null /* no progress monitor */);
+ /* don't force problem detection */
+ /* use primary owner */
+ /* no progress monitor */
+ unit.reconcile(false, null, null);
}
public static boolean isPrimary(ISourceModule unit) {
@@ -51,9 +54,9 @@
}
/**
- * Returns the package fragment root of <code>IModelElement</code>. If
- * the given element is already a package fragment root, the element itself
- * is returned.
+ * Returns the package fragment root of <code>IModelElement</code>. If the
+ * given element is already a package fragment root, the element itself is
+ * returned.
*/
public static IProjectFragment getProjectFragment(IModelElement element) {
return (IProjectFragment) element
@@ -218,4 +221,16 @@
return false;
}
+ public static IPath toPath(String[] pkgName) {
+ if (pkgName.length == 0) {
+ return Path.EMPTY;
+ } else {
+ IPath path = new Path(pkgName[0]);
+ for (int i = 1; i < pkgName.length; ++i) {
+ path = path.append(pkgName[i]);
+ }
+ return path;
+ }
+ }
+
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectFragment.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectFragment.java
index 4270efe..21b2ec2 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectFragment.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectFragment.java
@@ -32,6 +32,7 @@
import org.eclipse.dltk.core.IProjectFragment;
import org.eclipse.dltk.core.IScriptFolder;
import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.ScriptModelUtil;
import org.eclipse.dltk.core.WorkingCopyOwner;
import org.eclipse.dltk.core.environment.EnvironmentPathUtils;
import org.eclipse.dltk.internal.core.util.MementoTokenizer;
@@ -536,13 +537,6 @@
}
public IScriptFolder getScriptFolder(String[] pkgName) {
- if (pkgName.length == 0) {
- return this.getScriptFolder(Path.EMPTY);
- }
- IPath path = new Path(pkgName[0]);
- for (int i = 1; i < pkgName.length; ++i) {
- path = path.append(pkgName[i]);
- }
- return this.getScriptFolder(path);
+ return this.getScriptFolder(ScriptModelUtil.toPath(pkgName));
}
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptProject.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptProject.java
index ffb37f0..8d6cdde 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptProject.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptProject.java
@@ -195,9 +195,10 @@
* segment. The path may be relative or absolute.
*/
public IProjectFragment getProjectFragment(IPath path) {
- boolean isBuiltin = path.toString().startsWith(
- IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR);
- if (!path.isAbsolute() && !isBuiltin) {
+ boolean isSpecial = !path.isEmpty()
+ && path.segment(0)
+ .startsWith(IBuildpathEntry.BUILDPATH_SPECIAL);
+ if (!path.isAbsolute() && !isSpecial) {
path = getPath().append(path);
}
int segmentCount = path.segmentCount();
@@ -215,7 +216,9 @@
// still
// resolve to a source/lib folder
// thus will try to guess based on existing resource
- if (isBuiltin) {
+ if (isSpecial
+ && path.segment(0).startsWith(
+ IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR)) {
return new BuiltinProjectFragment(path, this);
}
if (org.eclipse.dltk.compiler.util.Util.isArchiveFileName(path
@@ -232,8 +235,8 @@
.getProject(path.lastSegment()));
} else {
// lib being a folder
- IFolder folder = this.project.getWorkspace().getRoot()
- .getFolder(path);
+ IResource folder = this.project.getWorkspace().getRoot()
+ .findMember(path);
if (folder != null) {
IProjectFragment projectFragment = getProjectFragment(folder);
return projectFragment;
diff --git a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/DLTKSearchScope.java b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/DLTKSearchScope.java
index c7509b1..fd4c467 100644
--- a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/DLTKSearchScope.java
+++ b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/DLTKSearchScope.java
@@ -704,8 +704,8 @@
int index = -1;
int separatorIndex = resourcePathString.indexOf(FILE_ENTRY_SEPARATOR);
boolean isZIPFile = separatorIndex != -1;
- boolean isBuiltin = resourcePathString
- .startsWith(IBuildpathEntry.BUILTIN_EXTERNAL_ENTRY_STR);
+ boolean isSpecial = resourcePathString
+ .startsWith(IBuildpathEntry.BUILDPATH_SPECIAL);
if (isZIPFile) {
// internal or external jar (case 3, 4, or 5)
String zipPath = resourcePathString.substring(0, separatorIndex);
@@ -727,7 +727,7 @@
return project
.getProjectFragment(this.containerPaths[index]);
}
- if (isBuiltin) {
+ if (isSpecial) {
return project
.getProjectFragment(this.containerPaths[index]);
}
diff --git a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/TypeNameMatchRequestorWrapper.java b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/TypeNameMatchRequestorWrapper.java
index 825d432..b0c3f5d 100644
--- a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/TypeNameMatchRequestorWrapper.java
+++ b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/TypeNameMatchRequestorWrapper.java
@@ -19,13 +19,13 @@
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.IType;
import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.ScriptModelUtil;
import org.eclipse.dltk.core.search.BasicSearchEngine;
import org.eclipse.dltk.core.search.IDLTKSearchScope;
import org.eclipse.dltk.core.search.TypeNameMatchRequestor;
import org.eclipse.dltk.core.search.TypeNameRequestor;
import org.eclipse.dltk.internal.compiler.env.AccessRestriction;
import org.eclipse.dltk.internal.core.Openable;
-import org.eclipse.dltk.internal.core.ProjectFragment;
import org.eclipse.dltk.internal.core.util.HandleFactory;
import org.eclipse.dltk.internal.core.util.HashtableOfArrayToObject;
@@ -41,12 +41,11 @@
public class TypeNameMatchRequestorWrapper implements
IRestrictedAccessTypeRequestor {
TypeNameMatchRequestor requestor;
- private final IDLTKSearchScope scope; // scope is needed to retrieve project
- // path
- // for external resource
- private HandleFactory handleFactory; // in case of IJavaSearchScope
- // defined by clients, use an
- // HandleFactory instead
+ // scope is needed to retrieve project path for external resource
+ private final IDLTKSearchScope scope;
+ // in case of IJavaSearchScope defined by clients, use an HandleFactory
+ // instead
+ private HandleFactory handleFactory;
/**
* Cache package fragment root information to optimize speed performance.
@@ -163,8 +162,8 @@
IScriptFolder pkgFragment = (IScriptFolder) this.packageHandles
.get(pkgName);
if (pkgFragment == null) {
- pkgFragment = ((ProjectFragment) this.lastProjectFragment)
- .getScriptFolder(pkgName);
+ pkgFragment = ((IProjectFragment) this.lastProjectFragment)
+ .getScriptFolder(ScriptModelUtil.toPath(pkgName));
this.packageHandles.put(pkgName, pkgFragment);
}
String simpleName = simpleNames[length];