* Model extensibility compatibility fix. No public API changed.
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/WorkingCopyOwner.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/WorkingCopyOwner.java
index e54e21c..20df46f 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/WorkingCopyOwner.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/core/WorkingCopyOwner.java
@@ -14,7 +14,7 @@
import org.eclipse.dltk.internal.core.BufferManager;
import org.eclipse.dltk.internal.core.DefaultWorkingCopyOwner;
import org.eclipse.dltk.internal.core.ExternalScriptProject;
-import org.eclipse.dltk.internal.core.ScriptFolder;
+import org.eclipse.dltk.internal.core.ModelElement;
import org.eclipse.dltk.internal.core.SourceModule;
/**
@@ -142,7 +142,7 @@
IProjectFragment fragment = project.getProjectFragment(Path.EMPTY);
IScriptFolder parent = fragment
.getScriptFolder(IProjectFragment.DEFAULT_SCRIPT_FOLDER_NAME);
- SourceModule result = new SourceModule((ScriptFolder) parent, name,
+ SourceModule result = new SourceModule((ModelElement) parent, name,
this);
result.becomeWorkingCopy(problemRequestor, monitor);
return result;
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractSourceModule.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractSourceModule.java
index cdc7bcb..a73e38a 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractSourceModule.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/AbstractSourceModule.java
@@ -693,11 +693,7 @@
return e.getModelStatus();
}
if (resource != null) {
- char[][] inclusionPatterns = ((ProjectFragment) root)
- .fullInclusionPatternChars();
- char[][] exclusionPatterns = ((ProjectFragment) root)
- .fullExclusionPatternChars();
- if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns))
+ if (Util.isExcluded(resource, root))
return new ModelStatus(
IModelStatusConstants.ELEMENT_NOT_ON_BUILDPATH, this);
if (!resource.isAccessible())
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BuildpathChange.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BuildpathChange.java
index 3250e32..8a7309a 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BuildpathChange.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/BuildpathChange.java
@@ -257,14 +257,14 @@
result |= HAS_LIBRARY_CHANGE;
}
- ProjectFragment[] pkgFragmentRoots = null;
+ IProjectFragment[] pkgFragmentRoots = null;
if (removedRoots != null) {
- ProjectFragment oldRoot = (ProjectFragment) removedRoots
+ IProjectFragment oldRoot = (IProjectFragment) removedRoots
.get(this.oldResolvedBuildpath[i].getPath());
if (oldRoot != null) { // use old root if any (could be
// none
// if entry wasn't bound)
- pkgFragmentRoots = new ProjectFragment[] { oldRoot };
+ pkgFragmentRoots = new IProjectFragment[] { oldRoot };
}
}
if (pkgFragmentRoots == null) {
@@ -290,9 +290,14 @@
// remember timestamp of jars that were removed (in case they
// are added as external jar in the same operation)
for (int j = 0, length = pkgFragmentRoots.length; j < length; j++) {
- ProjectFragment root = pkgFragmentRoots[j];
+ IProjectFragment root = pkgFragmentRoots[j];
if (root.isArchive() && !root.isExternal()) {
- Object resource = root.resource;
+ Object resource = null;
+ if (root instanceof ProjectFragment) {
+ resource = ((ProjectFragment) root).resource;
+ } else {
+ resource = root.getResource();
+ }
File file = null;
if (resource instanceof File) {
file = (File) resource;
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CommitWorkingCopyOperation.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CommitWorkingCopyOperation.java
index d647117..b36997f 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CommitWorkingCopyOperation.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CommitWorkingCopyOperation.java
@@ -21,12 +21,12 @@
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IModelStatus;
import org.eclipse.dltk.core.IModelStatusConstants;
+import org.eclipse.dltk.core.IProjectFragment;
import org.eclipse.dltk.core.ISourceModule;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.internal.core.util.Messages;
import org.eclipse.dltk.internal.core.util.Util;
-
/**
* Commits the contents of a working copy compilation unit to its original
* element and resource, bringing the script Model up-to-date with the current
@@ -70,32 +70,39 @@
*/
protected void executeOperation() throws ModelException {
try {
- beginTask(Messages.workingCopy_commit, 2);
+ beginTask(Messages.workingCopy_commit, 2);
SourceModule workingCopy = getSourceModule();
-
- if (ExternalScriptProject.EXTERNAL_PROJECT_NAME.equals(workingCopy.getScriptProject().getElementName())) {
+
+ if (ExternalScriptProject.EXTERNAL_PROJECT_NAME.equals(workingCopy
+ .getScriptProject().getElementName())) {
// case of a working copy without a resource
workingCopy.getBuffer().save(this.progressMonitor, this.force);
return;
}
-
+
ISourceModule primary = workingCopy.getPrimary();
boolean isPrimary = workingCopy.isPrimary();
ModelElementDeltaBuilder deltaBuilder = null;
- ProjectFragment root = (ProjectFragment) workingCopy.getAncestor(IModelElement.PROJECT_FRAGMENT);
+ IProjectFragment root = (IProjectFragment) workingCopy
+ .getAncestor(IModelElement.PROJECT_FRAGMENT);
boolean isIncluded = !Util.isExcluded(workingCopy);
- IFile resource = (IFile)workingCopy.getResource();
- if (isPrimary || (root.validateOnBuildpath().isOK() &&
- isIncluded && resource.isAccessible() &&
- Util.isValidSourceModule(workingCopy, workingCopy.getResource()))) {
-
+ IFile resource = (IFile) workingCopy.getResource();
+ if (isPrimary
+ || (root instanceof ProjectFragment
+ && ((ProjectFragment) root).validateOnBuildpath()
+ .isOK() && isIncluded
+ && resource.isAccessible() && Util
+ .isValidSourceModule(workingCopy, workingCopy
+ .getResource()))) {
+
// force opening so that the delta builder can get the old info
if (!isPrimary && !primary.isOpen()) {
primary.open(null);
}
- // creates the delta builder (this remembers the content of the cu) if:
+ // creates the delta builder (this remembers the content of the
+ // cu) if:
// - it is not excluded
// - and it is not a primary or it is a non-consistent primary
if (isIncluded && (!isPrimary || !workingCopy.isConsistent())) {
@@ -105,55 +112,63 @@
// save the cu
IBuffer primaryBuffer = primary.getBuffer();
if (!isPrimary) {
- if (primaryBuffer == null) return;
+ if (primaryBuffer == null)
+ return;
char[] primaryContents = primaryBuffer.getCharacters();
boolean hasSaved = false;
try {
IBuffer workingCopyBuffer = workingCopy.getBuffer();
- if (workingCopyBuffer == null) return;
- primaryBuffer.setContents(workingCopyBuffer.getCharacters());
+ if (workingCopyBuffer == null)
+ return;
+ primaryBuffer.setContents(workingCopyBuffer
+ .getCharacters());
primaryBuffer.save(this.progressMonitor, this.force);
primary.makeConsistent(this);
hasSaved = true;
} finally {
- if (!hasSaved){
- // restore original buffer contents since something went wrong
+ if (!hasSaved) {
+ // restore original buffer contents since something
+ // went wrong
primaryBuffer.setContents(primaryContents);
}
}
} else {
- // for a primary working copy no need to set the content of the buffer again
+ // for a primary working copy no need to set the content of
+ // the buffer again
primaryBuffer.save(this.progressMonitor, this.force);
primary.makeConsistent(this);
}
} else {
- // working copy on cu outside buildpath OR resource doesn't exist yet
+ // working copy on cu outside buildpath OR resource doesn't
+ // exist yet
String encoding = null;
try {
encoding = resource.getCharset();
- }
- catch (CoreException ce) {
+ } catch (CoreException ce) {
// use no encoding
}
String contents = workingCopy.getSource();
- if (contents == null) return;
+ if (contents == null)
+ return;
try {
- byte[] bytes = encoding == null
- ? contents.getBytes()
- : contents.getBytes(encoding);
- ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+ byte[] bytes = encoding == null ? contents.getBytes()
+ : contents.getBytes(encoding);
+ ByteArrayInputStream stream = new ByteArrayInputStream(
+ bytes);
if (resource.exists()) {
- resource.setContents(
- stream,
- this.force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
- null);
+ resource.setContents(stream,
+ this.force ? IResource.FORCE
+ | IResource.KEEP_HISTORY
+ : IResource.KEEP_HISTORY, null);
} else {
- resource.create(stream, this.force, this.progressMonitor);
+ resource.create(stream, this.force,
+ this.progressMonitor);
}
} catch (CoreException e) {
throw new ModelException(e);
} catch (UnsupportedEncodingException e) {
- throw new ModelException(e, IModelStatusConstants.IO_EXCEPTION);
+ throw new ModelException(e,
+ IModelStatusConstants.IO_EXCEPTION);
}
}
@@ -187,9 +202,11 @@
protected SourceModule getSourceModule() {
return (SourceModule) getElementToProcess();
}
+
protected ISchedulingRule getSchedulingRule() {
IResource resource = getElementToProcess().getResource();
- if (resource == null) return null;
+ if (resource == null)
+ return null;
IWorkspace workspace = resource.getWorkspace();
if (resource.exists()) {
return workspace.getRuleFactory().modifyRule(resource);
@@ -205,15 +222,16 @@
* operation is not a working copy
* <li>ELEMENT_NOT_PRESENT - the compilation unit the working copy is based
* on no longer exists.
- * <li>UPDATE_CONFLICT - the original compilation unit has changed since
- * the working copy was created and the operation specifies no force
+ * <li>UPDATE_CONFLICT - the original compilation unit has changed since the
+ * working copy was created and the operation specifies no force
* <li>READ_ONLY - the original compilation unit is in read-only mode
* </ul>
*/
public IModelStatus verify() {
SourceModule cu = getSourceModule();
if (!cu.isWorkingCopy()) {
- return new ModelStatus(IModelStatusConstants.INVALID_ELEMENT_TYPES, cu);
+ return new ModelStatus(IModelStatusConstants.INVALID_ELEMENT_TYPES,
+ cu);
}
if (cu.hasResourceChanged() && !this.force) {
return new ModelStatus(IModelStatusConstants.UPDATE_CONFLICT);
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CopyResourceElementsOperation.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CopyResourceElementsOperation.java
index ba0033f..bd19933 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CopyResourceElementsOperation.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CopyResourceElementsOperation.java
@@ -157,14 +157,12 @@
* fragments, false otherwise
*/
private boolean createNeededScriptFolders(IContainer sourceFolder,
- ProjectFragment root, IPath newFragName, boolean moveFolder)
+ IProjectFragment root, IPath newFragName, boolean moveFolder)
throws ModelException {
boolean containsReadOnlyScriptFolder = false;
IContainer parentFolder = (IContainer) root.getResource();
ModelElementDelta projectDelta = null;
IPath sideEffectPackageName = new Path(""); //$NON-NLS-1$
- char[][] inclusionPatterns = root.fullInclusionPatternChars();
- char[][] exclusionPatterns = root.fullExclusionPatternChars();
for (int i = 0; i < newFragName.segmentCount(); i++) {
String subFolderName = newFragName.segment(i);
sideEffectPackageName = sideEffectPackageName.append(subFolderName);
@@ -185,8 +183,7 @@
if (i < newFragName.segmentCount() - 1 // all but the last one
// are side effect
// packages
- && !Util.isExcluded(parentFolder, inclusionPatterns,
- exclusionPatterns)) {
+ && !Util.isExcluded(parentFolder, root)) {
if (projectDelta == null) {
projectDelta = getDeltaFor(root.getScriptProject());
}
@@ -227,11 +224,11 @@
* this source element and its destination. If the operation is a cross
* project operation
* <ul>
- * <li>On a copy, the delta should be rooted in the dest project <li>On a
- * move, two deltas are generated
+ * <li>On a copy, the delta should be rooted in the dest project
+ * <li>On a move, two deltas are generated
* <ul>
- * <li>one rooted in the source project <li>one rooted in the destination
- * project
+ * <li>one rooted in the source project
+ * <li>one rooted in the destination project
* </ul>
* </ul>
* If the operation is rooted in a single project, the delta is rooted in
@@ -264,7 +261,7 @@
* if the operation is unable to complete
*/
private void processSourceModuleResource(ISourceModule source,
- ScriptFolder dest) throws ModelException {
+ IScriptFolder dest) throws ModelException {
String newCUName = getNewNameFor(source);
String destName = (newCUName != null) ? newCUName : source
.getElementName();
@@ -288,7 +285,7 @@
// or an
// IProject
IFile destFile = destFolder.getFile(new Path(destName));
- SourceModule destCU = new SourceModule(dest, destName,
+ SourceModule destCU = new SourceModule((ModelElement) dest, destName,
DefaultWorkingCopyOwner.PRIMARY);
if (sourceResource == null || !destFile.equals(sourceResource)) {
try {
@@ -372,7 +369,7 @@
String oldName = /* Util.getNameWithoutScriptLikeExtension( */source
.getElementName();// );
String newName = /* Util.getNameWithoutScriptLikeExtension( */newCUName;// )
- // ;
+ // ;
prepareDeltas(source.getType(oldName), destCU.getType(newName),
isMove());
}
@@ -419,13 +416,13 @@
switch (element.getElementType()) {
case IModelElement.SOURCE_MODULE:
processSourceModuleResource((ISourceModule) element,
- (ScriptFolder) dest);
+ (IScriptFolder) dest);
createdElements.add(((IScriptFolder) dest).getSourceModule(element
.getElementName()));
break;
case IModelElement.SCRIPT_FOLDER:
- processScriptFolderResource((ScriptFolder) element,
- (ProjectFragment) dest, getNewNameFor(element));
+ processScriptFolderResource((IScriptFolder) element,
+ (IProjectFragment) dest, getNewNameFor(element));
break;
default:
throw new ModelException(new ModelStatus(
@@ -457,12 +454,14 @@
* @exception ScriptModelException
* if the operation is unable to complete
*/
- private void processScriptFolderResource(ScriptFolder source,
- ProjectFragment root, String newName) throws ModelException {
+ private void processScriptFolderResource(IScriptFolder source,
+ IProjectFragment root, String newName) throws ModelException {
try {
// String[] newFragName = (newName == null) ? source.path.segments()
// : Util.getTrimmedSimpleNames(newName);
- IPath newFragName = (newName == null) ? source.path : new Path(
+ IPath source_path = source.getPath().removeFirstSegments(
+ source.getParent().getPath().segmentCount());
+ IPath newFragName = (newName == null) ? source_path : new Path(
newName);
IScriptFolder newFrag = root.getScriptFolder(newFragName);
IResource[] resources = collectResourcesOfInterest(source);
@@ -580,11 +579,10 @@
}
// Update package statement in compilation unit if needed
if (!Util.equalArraysOrNull(new Object[] { newFragName },
- new Object[] { source.path })) { // if package has been
+ new Object[] { source_path })) { // if package has been
// renamed, update the
// compilation units
- char[][] inclusionPatterns = root.fullInclusionPatternChars();
- char[][] exclusionPatterns = root.fullExclusionPatternChars();
+
for (int i = 0; i < resources.length; i++) {
String resourceName = resources[i].getName();
IDLTKLanguageToolkit toolkit = DLTKLanguageManager
@@ -596,10 +594,10 @@
// we only consider potential compilation units
ISourceModule cu = newFrag
.getSourceModule(resourceName);
- if (Util.isExcluded(cu.getPath(), inclusionPatterns,
- exclusionPatterns, false/*
- * not a folder
- */))
+ if (Util.isExcluded(cu.getPath(), root, false/*
+ * not a
+ * folder
+ */))
continue;
if (DLTKCore.DEBUG) {
System.err
@@ -712,7 +710,8 @@
/**
* Possible failures:
* <ul>
- * <li>NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation <li>
+ * <li>NO_ELEMENTS_TO_PROCESS - no elements supplied to the operation
+ * <li>
* INDEX_OUT_OF_BOUNDS - the number of renamings supplied to the operation
* does not match the number of elements that were supplied.
* </ul>
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CreateScriptFolderOperation.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CreateScriptFolderOperation.java
index 41257f2..9b1c807 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CreateScriptFolderOperation.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/CreateScriptFolderOperation.java
@@ -76,13 +76,11 @@
*/
protected void executeOperation() throws ModelException {
ModelElementDelta delta = null;
- ProjectFragment root = (ProjectFragment) getParentElement();
+ IProjectFragment root = (IProjectFragment) getParentElement();
beginTask(Messages.operation_createScriptFolderProgress, this.pkgName.segmentCount());
IContainer parentFolder = (IContainer) root.getResource();
IPath sideEffectPackageName = Path.EMPTY;
ArrayList results = new ArrayList(this.pkgName.segmentCount());
- char[][] inclusionPatterns = root.fullInclusionPatternChars();
- char[][] exclusionPatterns = root.fullExclusionPatternChars();
int i;
for (i = 0; i < this.pkgName.segmentCount(); i++) {
String subFolderName = this.pkgName.segment(i);
@@ -92,7 +90,7 @@
createFolder(parentFolder, subFolderName, force);
parentFolder = parentFolder.getFolder(new Path(subFolderName));
IScriptFolder addedFrag = root.getScriptFolder(sideEffectPackageName);
- if (!Util.isExcluded(parentFolder, inclusionPatterns, exclusionPatterns)) {
+ if (!Util.isExcluded(parentFolder, root)) {
if (delta == null) {
delta = newModelElementDelta();
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java
index e21d1f1..3f0ca68 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/DeltaProcessor.java
@@ -734,7 +734,7 @@
case IModelElement.SCRIPT_FOLDER:
if (rootInfo != null) {
if (rootInfo.project.contains(resource)) {
- ProjectFragment root = (ProjectFragment) rootInfo
+ IProjectFragment root = (IProjectFragment) rootInfo
.getProjectFragment(null);
// create package handle
IPath pkgPath = path.removeFirstSegments(rootInfo.rootPath
@@ -774,7 +774,7 @@
IScriptFolder pkgFragment = null;
switch (this.currentElement.getElementType()) {
case IModelElement.PROJECT_FRAGMENT:
- ProjectFragment root = (ProjectFragment) this.currentElement;
+ IProjectFragment root = (IProjectFragment) this.currentElement;
IPath rootPath = root.getPath();
IPath pkgPath = path.removeLastSegments(1);
IPath pkgName = pkgPath.removeFirstSegments(rootPath
@@ -1002,31 +1002,31 @@
status = (String) externalArchivesStatus.get(entryPath);
if (status != null) {
if (status == EXTERNAL_ZIP_ADDED) {
- ProjectFragment root = (ProjectFragment) scriptProject
+ IProjectFragment root = (IProjectFragment) scriptProject
.getProjectFragment(entryPath);
if (VERBOSE) {
System.out
.println("- External ZIP ADDED, affecting root: " + root.getElementName()); //$NON-NLS-1$
}
- this.elementAdded(root, null, null);
+ this.elementAdded((Openable) root, null, null);
hasDelta = true;
} else if (status == EXTERNAL_ZIP_CHANGED) {
- ProjectFragment root = (ProjectFragment) scriptProject
+ IProjectFragment root = (IProjectFragment) scriptProject
.getProjectFragment(entryPath);
if (VERBOSE) {
System.out
.println("- External ZIP CHANGED, affecting root: " + root.getElementName()); //$NON-NLS-1$
}
- this.contentChanged(root);
+ this.contentChanged((Openable) root);
hasDelta = true;
} else if (status == EXTERNAL_ZIP_REMOVED) {
- ProjectFragment root = (ProjectFragment) scriptProject
+ IProjectFragment root = (IProjectFragment) scriptProject
.getProjectFragment(entryPath);
if (VERBOSE) {
System.out
.println("- External ZIP REMOVED, affecting root: " + root.getElementName()); //$NON-NLS-1$
}
- this.elementRemoved(root, null, null);
+ this.elementRemoved((Openable) root, null, null);
this.state.addBuildpathValidation(scriptProject); // see
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=
@@ -1712,11 +1712,11 @@
((ProjectElementInfo) info).setForeignResources(null);
// if a package fragment root is the project, clear it too
ScriptProject project = (ScriptProject) element;
- ProjectFragment projectRoot = (ProjectFragment) project
+ IProjectFragment projectRoot = (IProjectFragment) project
.getProjectFragment(project.getProject());
if (projectRoot.isOpen()) {
- ((ProjectFragmentInfo) projectRoot.getElementInfo())
- .setForeignResources(null);
+ ((ProjectFragmentInfo) ((Openable) projectRoot)
+ .getElementInfo()).setForeignResources(null);
}
break;
case IModelElement.SCRIPT_FOLDER:
@@ -2774,7 +2774,7 @@
case IModelElement.PROJECT_FRAGMENT:
if (element instanceof ArchiveProjectFragment
|| element instanceof ExternalProjectFragment) {
- ProjectFragment root = (ProjectFragment) element;
+ IProjectFragment root = (IProjectFragment) element;
// index External or zip fragment only once (if the root is
// in its declaring
// project)
@@ -2783,7 +2783,13 @@
char[][] fullInclusionPatternChars = null;
char[][] fullExclusionPatternChars = null;
try {
- buildpathEntry = (BuildpathEntry) root.getBuildpathEntry();
+ if (root instanceof ProjectFragment) {
+ buildpathEntry = (BuildpathEntry) ((ProjectFragment) root)
+ .getBuildpathEntry();
+ } else {
+ buildpathEntry = (BuildpathEntry) root
+ .getRawBuildpathEntry();
+ }
fullInclusionPatternChars = buildpathEntry
.fullInclusionPatternChars();
fullExclusionPatternChars = buildpathEntry
@@ -2817,7 +2823,7 @@
}
int kind = delta.getKind();
if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED) {
- ProjectFragment root = (ProjectFragment) element;
+ IProjectFragment root = (IProjectFragment) element;
this.updateRootIndex(root, Path.EMPTY, delta);
break;
}
@@ -2829,7 +2835,7 @@
case IResourceDelta.REMOVED:
IScriptFolder pkg = null;
if (element instanceof IProjectFragment) {
- ProjectFragment root = (ProjectFragment) element;
+ IProjectFragment root = (IProjectFragment) element;
pkg = root.getScriptFolder(Path.EMPTY);
} else {
pkg = (IScriptFolder) element;
@@ -2965,7 +2971,7 @@
* Updates the index of the given root (assuming it's an addition or a
* removal). This is done recusively, pkg being the current package.
*/
- private void updateRootIndex(ProjectFragment root, IPath pkgPath,
+ private void updateRootIndex(IProjectFragment root, IPath pkgPath,
IResourceDelta delta) {
Openable pkg = (Openable) root.getScriptFolder(pkgPath);
this.updateIndex(pkg, delta);
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ElementCache.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ElementCache.java
index f5ef756..73f222c 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ElementCache.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ElementCache.java
@@ -12,6 +12,8 @@
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.dltk.core.IElementCacheListener;
import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IProjectFragment;
+import org.eclipse.dltk.core.IScriptFolder;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.internal.core.util.LRUCache;
@@ -54,8 +56,8 @@
// We must close an entire external folder of zip.
if (element instanceof ArchiveFolder
|| element instanceof ExternalScriptFolder) {
- ScriptFolder archiveFolder = (ScriptFolder) element;
- ProjectFragment root = (ProjectFragment) archiveFolder
+ IScriptFolder archiveFolder = (IScriptFolder) element;
+ IProjectFragment root = (IProjectFragment) archiveFolder
.getParent();
root.close();
} else {
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java
index 1abc0ad..ab1a345 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ModelManager.java
@@ -737,7 +737,7 @@
* given we have a resource child of the root, it cannot
* be a ZIP fragment
*/
- ProjectFragment root = (ProjectFragment) ((ScriptProject) project)
+ IProjectFragment root = (IProjectFragment) ((ScriptProject) project)
.getFolderProjectFragment(rootPath);
if (root == null)
return null;
@@ -876,7 +876,7 @@
}
if (validSrcModule) {
ISourceModule workingCopy = new SourceModule(
- (ScriptFolder) primaryWorkingCopy.getParent(),
+ (ModelElement) primaryWorkingCopy.getParent(),
primaryWorkingCopy.getElementName(), owner);
if (!workingCopyToInfos.containsKey(workingCopy))
result[index++] = primaryWorkingCopy;
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/NameLookup.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/NameLookup.java
index c111b53..3ad3855 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/NameLookup.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/NameLookup.java
@@ -37,109 +37,115 @@
import org.eclipse.dltk.internal.core.util.Messages;
import org.eclipse.dltk.internal.core.util.Util;
-
/**
* A <code>NameLookup</code> provides name resolution within a Script project.
- * The name lookup facility uses the project's classpath to prioritize the
- * order in which package fragments are searched when resolving a name.
- *
- * <p>Name lookup only returns a handle when the named element actually
- * exists in the model; otherwise <code>null</code> is returned.
- *
- * <p>There are two logical sets of methods within this interface. Methods
- * which start with <code>find*</code> are intended to be convenience methods for quickly
- * finding an element within another element; for instance, for finding a class within a
- * package. The other set of methods all begin with <code>seek*</code>. These methods
- * do comprehensive searches of the <code>IScriptProject</code> returning hits
- * in real time through an <code>IModelElementRequestor</code>.
- *
+ * The name lookup facility uses the project's classpath to prioritize the order
+ * in which package fragments are searched when resolving a name.
+ *
+ * <p>
+ * Name lookup only returns a handle when the named element actually exists in
+ * the model; otherwise <code>null</code> is returned.
+ *
+ * <p>
+ * There are two logical sets of methods within this interface. Methods which
+ * start with <code>find*</code> are intended to be convenience methods for
+ * quickly finding an element within another element; for instance, for finding
+ * a class within a package. The other set of methods all begin with
+ * <code>seek*</code>. These methods do comprehensive searches of the
+ * <code>IScriptProject</code> returning hits in real time through an
+ * <code>IModelElementRequestor</code>.
+ *
*/
public class NameLookup {
public static class Answer {
public IType type;
AccessRestriction restriction;
+
Answer(IType type, AccessRestriction restriction) {
this.type = type;
this.restriction = restriction;
}
+
public boolean ignoreIfBetter() {
- return this.restriction != null && this.restriction.ignoreIfBetter();
+ return this.restriction != null
+ && this.restriction.ignoreIfBetter();
}
+
/*
* Returns whether this answer is better than the other awswer.
* (accessible is better than discouraged, which is better than
* non-accessible)
*/
public boolean isBetter(Answer otherAnswer) {
- if (otherAnswer == null) return true;
- if (this.restriction == null) return true;
- return otherAnswer.restriction != null
- && this.restriction.getProblemId() < otherAnswer.restriction.getProblemId();
+ if (otherAnswer == null)
+ return true;
+ if (this.restriction == null)
+ return true;
+ return otherAnswer.restriction != null
+ && this.restriction.getProblemId() < otherAnswer.restriction
+ .getProblemId();
}
}
-
/*
* Accept flag for all kinds of types
*/
public static boolean VERBOSE = DLTKCore.VERBOSE_SEARCH_NAMELOOKUP;
-
+
private static final IType[] NO_TYPES = {};
public static final int ACCEPT_ALL = 0;
/**
- * The <code>IScriptFolderRoot</code>'s associated
- * with the buildpath of this NameLookup facility's
- * project.
+ * The <code>IScriptFolderRoot</code>'s associated with the buildpath of
+ * this NameLookup facility's project.
*/
protected IProjectFragment[] projectFragments;
/**
- * Table that maps package names to lists of package fragment roots
- * that contain such a package known by this name lookup facility.
- * To allow > 1 package fragment with the same name, values are
- * arrays of package fragment roots ordered as they appear on the
- * buildpath.
- * Note if the list is of size 1, then the IScriptFolderRoot object
- * replaces the array.
+ * Table that maps package names to lists of package fragment roots that
+ * contain such a package known by this name lookup facility. To allow > 1
+ * package fragment with the same name, values are arrays of package
+ * fragment roots ordered as they appear on the buildpath. Note if the list
+ * is of size 1, then the IScriptFolderRoot object replaces the array.
*/
protected HashtableOfArrayToObject scriptFolders;
-
+
/*
- * A set of names (String[]) that are known to be package names.
- * Value is not null for known package.
+ * A set of names (String[]) that are known to be package names. Value is
+ * not null for known package.
*/
protected HashtableOfArrayToObject isPackageCache;
/**
- * Reverse map from root path to corresponding resolved CP entry
- * (so as to be able to figure inclusion/exclusion rules)
+ * Reverse map from root path to corresponding resolved CP entry (so as to
+ * be able to figure inclusion/exclusion rules)
*/
protected Map rootToResolvedEntries;
-
+
/**
- * A map from package handles to a map from type name to an IType or an IType[].
- * Allows working copies to take precedence over compilation units.
+ * A map from package handles to a map from type name to an IType or an
+ * IType[]. Allows working copies to take precedence over compilation units.
*/
protected HashMap typesInWorkingCopies;
public long timeSpentInSeekTypesInSourcePackage = 0;
public long timeSpentInSeekTypesInBinaryPackage = 0;
- public NameLookup(
- IProjectFragment[] ProjectFragments,
- HashtableOfArrayToObject ScriptFolders,
- HashtableOfArrayToObject isPackage,
- ISourceModule[] workingCopies,
+ public NameLookup(IProjectFragment[] ProjectFragments,
+ HashtableOfArrayToObject ScriptFolders,
+ HashtableOfArrayToObject isPackage, ISourceModule[] workingCopies,
Map rootToResolvedEntries) {
long start = -1;
if (VERBOSE) {
- Util.verbose(" BUILDING NameLoopkup"); //$NON-NLS-1$
- Util.verbose(" -> pkg roots size: " + (ProjectFragments == null ? 0 : ProjectFragments.length)); //$NON-NLS-1$
- Util.verbose(" -> pkgs size: " + (ScriptFolders == null ? 0 : ScriptFolders.size())); //$NON-NLS-1$
- Util.verbose(" -> working copy size: " + (workingCopies == null ? 0 : workingCopies.length)); //$NON-NLS-1$
+ Util.verbose(" BUILDING NameLoopkup"); //$NON-NLS-1$
+ Util
+ .verbose(" -> pkg roots size: " + (ProjectFragments == null ? 0 : ProjectFragments.length)); //$NON-NLS-1$
+ Util
+ .verbose(" -> pkgs size: " + (ScriptFolders == null ? 0 : ScriptFolders.size())); //$NON-NLS-1$
+ Util
+ .verbose(" -> working copy size: " + (workingCopies == null ? 0 : workingCopies.length)); //$NON-NLS-1$
start = System.currentTimeMillis();
}
this.projectFragments = ProjectFragments;
@@ -149,15 +155,18 @@
} else {
// clone tables as we're adding packages from working copies
try {
- this.scriptFolders = (HashtableOfArrayToObject) ScriptFolders.clone();
- this.isPackageCache = (HashtableOfArrayToObject) isPackage.clone();
+ this.scriptFolders = (HashtableOfArrayToObject) ScriptFolders
+ .clone();
+ this.isPackageCache = (HashtableOfArrayToObject) isPackage
+ .clone();
} catch (CloneNotSupportedException e1) {
- // ignore (implementation of HashtableOfArrayToObject supports cloning)
+ // ignore (implementation of HashtableOfArrayToObject supports
+ // cloning)
}
this.typesInWorkingCopies = new HashMap();
for (int i = 0, length = workingCopies.length; i < length; i++) {
ISourceModule workingCopy = workingCopies[i];
- ScriptFolder pkg = (ScriptFolder) workingCopy.getParent();
+ IScriptFolder pkg = (IScriptFolder) workingCopy.getParent();
HashMap typeMap = (HashMap) this.typesInWorkingCopies.get(pkg);
if (typeMap == null) {
typeMap = new HashMap();
@@ -177,11 +186,17 @@
if (existing == null) {
typeMap.put(typeName, type);
} else if (existing instanceof IType) {
- typeMap.put(typeName, new IType[] {(IType) existing, type});
+ typeMap.put(typeName, new IType[] {
+ (IType) existing, type });
} else {
IType[] existingTypes = (IType[]) existing;
int existingTypeLength = existingTypes.length;
- System.arraycopy(existingTypes, 0, existingTypes = new IType[existingTypeLength+1], 0, existingTypeLength);
+ System
+ .arraycopy(
+ existingTypes,
+ 0,
+ existingTypes = new IType[existingTypeLength + 1],
+ 0, existingTypeLength);
existingTypes[existingTypeLength] = type;
typeMap.put(typeName, existingTypes);
}
@@ -190,20 +205,26 @@
} catch (ModelException e) {
// working copy doesn't exist -> ignore
}
-
+
// add root of package fragment to cache
IProjectFragment root = (IProjectFragment) pkg.getParent();
- String[] pkgName = pkg.path.segments();
+ IPath pkgPath = pkg.getPath().removeFirstSegments(
+ root.getPath().segmentCount());
+ String[] pkgName = pkgPath.segments();
Object existing = this.scriptFolders.get(pkgName);
if (existing == null) {
this.scriptFolders.put(pkgName, root);
- // cache whether each package and its including packages (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161)
+ // cache whether each package and its including packages
+ // (see
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=119161)
// are actual packages
ProjectElementInfo.addNames(pkgName, this.isPackageCache);
} else {
if (existing instanceof ProjectFragment) {
if (!existing.equals(root))
- this.scriptFolders.put(pkgName, new IProjectFragment[] {(ProjectFragment) existing, root});
+ this.scriptFolders
+ .put(pkgName, new IProjectFragment[] {
+ (IProjectFragment) existing, root });
} else {
IProjectFragment[] roots = (IProjectFragment[]) existing;
int rootLength = roots.length;
@@ -215,7 +236,12 @@
}
}
if (containsRoot) {
- System.arraycopy(roots, 0, roots = new IProjectFragment[rootLength+1], 0, rootLength);
+ System
+ .arraycopy(
+ roots,
+ 0,
+ roots = new IProjectFragment[rootLength + 1],
+ 0, rootLength);
roots[rootLength] = root;
this.scriptFolders.put(pkgName, roots);
}
@@ -223,88 +249,96 @@
}
}
}
-
+
this.rootToResolvedEntries = rootToResolvedEntries;
- if (VERBOSE) {
- Util.verbose(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ if (VERBOSE) {
+ Util
+ .verbose(" -> spent: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
/**
- * Returns true if:<ul>
- * <li>the given type is an existing class and the flag's <code>ACCEPT_CLASSES</code>
- * bit is on
- * <li>the given type is an existing interface and the <code>ACCEPT_INTERFACES</code>
- * bit is on
- * <li>neither the <code>ACCEPT_CLASSES</code> or <code>ACCEPT_INTERFACES</code>
- * bit is on
- * </ul>
- * Otherwise, false is returned.
+ * Returns true if:
+ * <ul>
+ * <li>the given type is an existing class and the flag's
+ * <code>ACCEPT_CLASSES</code> bit is on
+ * <li>the given type is an existing interface and the
+ * <code>ACCEPT_INTERFACES</code> bit is on
+ * <li>neither the <code>ACCEPT_CLASSES</code> or
+ * <code>ACCEPT_INTERFACES</code> bit is on
+ * </ul>
+ * Otherwise, false is returned.
*/
- protected boolean acceptType(IType type, int acceptFlags, boolean isSourceType) {
+ protected boolean acceptType(IType type, int acceptFlags,
+ boolean isSourceType) {
return true;
}
/**
- * Finds every type in the project whose simple name matches
- * the prefix, informing the requestor of each hit. The requestor
- * is polled for cancellation at regular intervals.
- *
- * <p>The <code>partialMatch</code> argument indicates partial matches
- * should be considered.
+ * Finds every type in the project whose simple name matches the prefix,
+ * informing the requestor of each hit. The requestor is polled for
+ * cancellation at regular intervals.
+ *
+ * <p>
+ * The <code>partialMatch</code> argument indicates partial matches should
+ * be considered.
*/
- private void findAllTypes(String prefix, boolean partialMatch, int acceptFlags, IModelElementRequestor requestor) {
- int count= this.projectFragments.length;
- for (int i= 0; i < count; i++) {
+ private void findAllTypes(String prefix, boolean partialMatch,
+ int acceptFlags, IModelElementRequestor requestor) {
+ int count = this.projectFragments.length;
+ for (int i = 0; i < count; i++) {
if (requestor.isCanceled())
return;
- IProjectFragment root= this.projectFragments[i];
- IModelElement[] packages= null;
+ IProjectFragment root = this.projectFragments[i];
+ IModelElement[] packages = null;
try {
- packages= root.getChildren();
+ packages = root.getChildren();
} catch (ModelException npe) {
continue; // the root is not present, continue;
}
if (packages != null) {
- for (int j= 0, packageCount= packages.length; j < packageCount; j++) {
+ for (int j = 0, packageCount = packages.length; j < packageCount; j++) {
if (requestor.isCanceled())
return;
- seekTypes(prefix, (IScriptFolder) packages[j], partialMatch, acceptFlags, requestor);
+ seekTypes(prefix, (IScriptFolder) packages[j],
+ partialMatch, acceptFlags, requestor);
}
}
}
}
/**
- * Returns the <code>ISourceModule</code> which defines the type
- * named <code>qualifiedTypeName</code>, or <code>null</code> if
- * none exists. The domain of the search is bounded by the classpath
- * of the <code>IScriptProject</code> this <code>NameLookup</code> was
- * obtained from.
+ * Returns the <code>ISourceModule</code> which defines the type named
+ * <code>qualifiedTypeName</code>, or <code>null</code> if none exists. The
+ * domain of the search is bounded by the classpath of the
+ * <code>IScriptProject</code> this <code>NameLookup</code> was obtained
+ * from.
* <p>
- * The name must be fully qualified (eg "java.lang.Object", "java.util.Hashtable$Entry")
+ * The name must be fully qualified (eg "java.lang.Object",
+ * "java.util.Hashtable$Entry")
*/
public ISourceModule findSourceModule(String qualifiedTypeName) {
String[] pkgName = CharOperation.NO_STRINGS;
String cuName = qualifiedTypeName;
- int index= qualifiedTypeName.lastIndexOf('.');
+ int index = qualifiedTypeName.lastIndexOf('.');
if (index != -1) {
- pkgName= Util.splitOn('.', qualifiedTypeName, 0, index);
- cuName= qualifiedTypeName.substring(index + 1);
+ pkgName = Util.splitOn('.', qualifiedTypeName, 0, index);
+ cuName = qualifiedTypeName.substring(index + 1);
}
- index= cuName.indexOf('$');
+ index = cuName.indexOf('$');
if (index != -1) {
- cuName= cuName.substring(0, index);
+ cuName = cuName.substring(0, index);
}
Object value = this.scriptFolders.get(pkgName);
if (value != null) {
if (value instanceof ProjectFragment) {
- return findSourceModule(pkgName, cuName, (ProjectFragment) value);
+ return findSourceModule(pkgName, cuName,
+ (IProjectFragment) value);
} else {
IProjectFragment[] roots = (IProjectFragment[]) value;
- for (int i= 0; i < roots.length; i++) {
- ProjectFragment root= (ProjectFragment) roots[i];
+ for (int i = 0; i < roots.length; i++) {
+ IProjectFragment root = (IProjectFragment) roots[i];
ISourceModule cu = findSourceModule(pkgName, cuName, root);
if (cu != null)
return cu;
@@ -313,16 +347,17 @@
}
return null;
}
-
+
private IPath toPath(String pkgName[]) {
IPath path = new Path(""); //$NON-NLS-1$
- for( int i = 0; i < pkgName.length;++i ) {
+ for (int i = 0; i < pkgName.length; ++i) {
path = path.append(pkgName[i]);
}
return path;
}
-
- private ISourceModule findSourceModule(String[] pkgName, String cuName, ProjectFragment root) {
+
+ private ISourceModule findSourceModule(String[] pkgName, String cuName,
+ IProjectFragment root) {
if (!root.isArchive()) {
IScriptFolder pkg = root.getScriptFolder(toPath(pkgName));
try {
@@ -338,32 +373,33 @@
}
}
return null;
-}
+ }
private static boolean equals(String s1, String s2) {
return s1 == null ? s2 == null : s1.equals(s2);
}
/**
- * Returns the package fragment whose path matches the given
- * (absolute) path, or <code>null</code> if none exist. The domain of
- * the search is bounded by the buildpath of the <code>IScriptProject</code>
- * this <code>NameLookup</code> was obtained from.
- * The path can be:
- * - internal to the workbench: "/Project/src"
- * - external to the workbench: "c:/jdk/classes.zip/java/lang"
+ * Returns the package fragment whose path matches the given (absolute)
+ * path, or <code>null</code> if none exist. The domain of the search is
+ * bounded by the buildpath of the <code>IScriptProject</code> this
+ * <code>NameLookup</code> was obtained from. The path can be: - internal to
+ * the workbench: "/Project/src" - external to the workbench:
+ * "c:/jdk/classes.zip/java/lang"
*/
public IScriptFolder findScriptFolder(IPath path) {
if (!path.isAbsolute()) {
- throw new IllegalArgumentException(Messages.path_mustBeAbsolute);
+ throw new IllegalArgumentException(Messages.path_mustBeAbsolute);
}
-/*
- * TODO (jerome) this code should rather use the package fragment map to find the candidate package, then
- * check if the respective enclosing root maps to the one on this given IPath.
- */
- IResource possibleFragment = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ /*
+ * TODO (jerome) this code should rather use the package fragment map to
+ * find the candidate package, then check if the respective enclosing
+ * root maps to the one on this given IPath.
+ */
+ IResource possibleFragment = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(path);
if (possibleFragment == null) {
- //external jar
+ // external jar
for (int i = 0; i < this.projectFragments.length; i++) {
IProjectFragment root = this.projectFragments[i];
if (!root.isExternal() || root.isBuiltin()) {
@@ -397,51 +433,56 @@
return null;
}
switch (fromFactory.getElementType()) {
- case IModelElement.SCRIPT_FOLDER:
- return (IScriptFolder) fromFactory;
- case IModelElement.SCRIPT_PROJECT:
- // default package in a default root
- ScriptProject project = (ScriptProject) fromFactory;
- try {
- IBuildpathEntry entry = project.getBuildpathEntryFor(path);
- if (entry != null) {
- IProjectFragment root =
- project.getProjectFragment(project.getResource());
- Object defaultPkgRoot = this.scriptFolders.get(CharOperation.NO_STRINGS);
- if (defaultPkgRoot == null) {
- return null;
- }
- if (defaultPkgRoot instanceof ProjectFragment && defaultPkgRoot.equals(root))
- return ((ProjectFragment) root).getScriptFolder(Path.EMPTY);
- else {
- IProjectFragment[] roots = (IProjectFragment[]) defaultPkgRoot;
- for (int i = 0; i < roots.length; i++) {
- if (roots[i].equals(root)) {
- return ((ProjectFragment) root).getScriptFolder(Path.EMPTY);
- }
+ case IModelElement.SCRIPT_FOLDER:
+ return (IScriptFolder) fromFactory;
+ case IModelElement.SCRIPT_PROJECT:
+ // default package in a default root
+ ScriptProject project = (ScriptProject) fromFactory;
+ try {
+ IBuildpathEntry entry = project.getBuildpathEntryFor(path);
+ if (entry != null) {
+ IProjectFragment root = project
+ .getProjectFragment(project.getResource());
+ Object defaultPkgRoot = this.scriptFolders
+ .get(CharOperation.NO_STRINGS);
+ if (defaultPkgRoot == null) {
+ return null;
+ }
+ if (defaultPkgRoot instanceof ProjectFragment
+ && defaultPkgRoot.equals(root))
+ return ((IProjectFragment) root)
+ .getScriptFolder(Path.EMPTY);
+ else {
+ IProjectFragment[] roots = (IProjectFragment[]) defaultPkgRoot;
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].equals(root)) {
+ return ((IProjectFragment) root)
+ .getScriptFolder(Path.EMPTY);
}
}
}
- } catch (ModelException e) {
- return null;
}
+ } catch (ModelException e) {
return null;
- case IModelElement.PROJECT_FRAGMENT:
- return ((ProjectFragment)fromFactory).getScriptFolder(Path.EMPTY);
+ }
+ return null;
+ case IModelElement.PROJECT_FRAGMENT:
+ return ((IProjectFragment) fromFactory)
+ .getScriptFolder(Path.EMPTY);
}
}
return null;
}
/**
- * Returns the package fragments whose name matches the given
- * (qualified) name, or <code>null</code> if none exist.
- *
- * The name can be:
- * - empty: ""
- * - qualified: "pack.pack1.pack2"
- * @param partialMatch partial name matches qualify when <code>true</code>,
- * only exact name matches qualify when <code>false</code>
+ * Returns the package fragments whose name matches the given (qualified)
+ * name, or <code>null</code> if none exist.
+ *
+ * The name can be: - empty: "" - qualified: "pack.pack1.pack2"
+ *
+ * @param partialMatch
+ * partial name matches qualify when <code>true</code>, only
+ * exact name matches qualify when <code>false</code>
*/
public IScriptFolder[] findScriptFolders(String name, boolean partialMatch) {
if (partialMatch) {
@@ -451,12 +492,14 @@
Object[][] keys = this.scriptFolders.keyTable;
for (int i = 0, length = keys.length; i < length; i++) {
String[] pkgName = (String[]) keys[i];
- if (pkgName != null && Util.startsWithIgnoreCase(pkgName, splittedName)) {
+ if (pkgName != null
+ && Util.startsWithIgnoreCase(pkgName, splittedName)) {
Object value = this.scriptFolders.valueTable[i];
if (value instanceof ProjectFragment) {
- IScriptFolder pkg = ((ProjectFragment) value).getScriptFolder(toPath(pkgName));
+ IScriptFolder pkg = ((IProjectFragment) value)
+ .getScriptFolder(toPath(pkgName));
if (oneFragment == null) {
- oneFragment = new IScriptFolder[] {pkg};
+ oneFragment = new IScriptFolder[] { pkg };
} else {
if (pkgs == null) {
pkgs = new ArrayList();
@@ -467,10 +510,11 @@
} else {
IProjectFragment[] roots = (IProjectFragment[]) value;
for (int j = 0, length2 = roots.length; j < length2; j++) {
- ProjectFragment root = (ProjectFragment) roots[j];
- IScriptFolder pkg = root.getScriptFolder(toPath(pkgName));
+ IProjectFragment root = (IProjectFragment) roots[j];
+ IScriptFolder pkg = root
+ .getScriptFolder(toPath(pkgName));
if (oneFragment == null) {
- oneFragment = new IScriptFolder[] {pkg};
+ oneFragment = new IScriptFolder[] { pkg };
} else {
if (pkgs == null) {
pkgs = new ArrayList();
@@ -482,7 +526,8 @@
}
}
}
- if (pkgs == null) return oneFragment;
+ if (pkgs == null)
+ return oneFragment;
int resultLength = pkgs.size();
IScriptFolder[] result = new IScriptFolder[resultLength];
pkgs.toArray(result);
@@ -493,12 +538,14 @@
if (value == null)
return null;
if (value instanceof ProjectFragment) {
- return new IScriptFolder[] {((ProjectFragment) value).getScriptFolder(toPath(splittedName))};
+ return new IScriptFolder[] { ((IProjectFragment) value)
+ .getScriptFolder(toPath(splittedName)) };
} else {
IProjectFragment[] roots = (IProjectFragment[]) value;
IScriptFolder[] result = new IScriptFolder[roots.length];
- for (int i= 0; i < roots.length; i++) {
- result[i] = ((ProjectFragment) roots[i]).getScriptFolder(toPath(splittedName));
+ for (int i = 0; i < roots.length; i++) {
+ result[i] = ((IProjectFragment) roots[i])
+ .getScriptFolder(toPath(splittedName));
}
return result;
}
@@ -506,57 +553,56 @@
}
/**
- * Find type considering secondary types but without waiting for indexes.
- * It means that secondary types may be not found under certain circumstances...
+ * Find type considering secondary types but without waiting for indexes. It
+ * means that secondary types may be not found under certain
+ * circumstances...
+ *
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=118789"
*/
- public Answer findType(String typeName, String packageName, boolean partialMatch, int acceptFlags, boolean checkRestrictions) {
- return findType(typeName,
- packageName,
- partialMatch,
- acceptFlags,
- true/* consider secondary types */,
- false/* do NOT wait for indexes */,
- checkRestrictions,
- null);
+ public Answer findType(String typeName, String packageName,
+ boolean partialMatch, int acceptFlags, boolean checkRestrictions) {
+ return findType(typeName, packageName, partialMatch, acceptFlags,
+ true/* consider secondary types */, false/*
+ * do NOT wait for
+ * indexes
+ */, checkRestrictions,
+ null);
}
/**
- * Find type. Considering secondary types and waiting for indexes depends on given corresponding parameters.
+ * Find type. Considering secondary types and waiting for indexes depends on
+ * given corresponding parameters.
*/
- public Answer findType(
- String typeName,
- String packageName,
- boolean partialMatch,
- int acceptFlags,
- boolean considerSecondaryTypes,
- boolean waitForIndexes,
- boolean checkRestrictions,
- IProgressMonitor monitor) {
+ public Answer findType(String typeName, String packageName,
+ boolean partialMatch, int acceptFlags,
+ boolean considerSecondaryTypes, boolean waitForIndexes,
+ boolean checkRestrictions, IProgressMonitor monitor) {
if (packageName == null || packageName.length() == 0) {
- packageName= IScriptFolder.DEFAULT_FOLDER_NAME;
- } else if (typeName.length() > 0 && Character.isLowerCase(typeName.charAt(0))) {
+ packageName = IScriptFolder.DEFAULT_FOLDER_NAME;
+ } else if (typeName.length() > 0
+ && Character.isLowerCase(typeName.charAt(0))) {
// see if this is a known package and not a type
- if (findScriptFolders(packageName + "." + typeName, false) != null) return null; //$NON-NLS-1$
+ if (findScriptFolders(packageName + "." + typeName, false) != null)return null; //$NON-NLS-1$
}
// Look for concerned package fragments
ModelElementRequestor elementRequestor = new ModelElementRequestor();
seekScriptFolders(packageName, false, elementRequestor);
- IScriptFolder[] packages= elementRequestor.getScriptFolders();
+ IScriptFolder[] packages = elementRequestor.getScriptFolders();
// Try to find type in package fragments list
IType type = null;
- int length= packages.length;
+ int length = packages.length;
HashSet projects = null;
IScriptProject scriptProject = null;
Answer suggestedAnswer = null;
- for (int i= 0; i < length; i++) {
+ for (int i = 0; i < length; i++) {
type = findType(typeName, packages[i], partialMatch, acceptFlags);
if (type != null) {
AccessRestriction accessRestriction = null;
if (checkRestrictions) {
- accessRestriction = getViolatedRestriction(typeName, packageName, type, accessRestriction);
+ accessRestriction = getViolatedRestriction(typeName,
+ packageName, type, accessRestriction);
}
Answer answer = new Answer(type, accessRestriction);
if (!answer.ignoreIfBetter()) {
@@ -565,11 +611,10 @@
} else if (answer.isBetter(suggestedAnswer))
// remember suggestion and keep looking
suggestedAnswer = answer;
- }
- else if (suggestedAnswer == null && considerSecondaryTypes) {
+ } else if (suggestedAnswer == null && considerSecondaryTypes) {
if (scriptProject == null) {
scriptProject = packages[i].getScriptProject();
- } else if (projects == null) {
+ } else if (projects == null) {
if (!scriptProject.equals(packages[i].getScriptProject())) {
projects = new HashSet(3);
projects.add(scriptProject);
@@ -583,74 +628,94 @@
if (suggestedAnswer != null)
// no better answer was found
return suggestedAnswer;
-
+
return type == null ? null : new Answer(type, null);
}
- private AccessRestriction getViolatedRestriction(String typeName, String packageName, IType type, AccessRestriction accessRestriction) {
- ProjectFragment root = (ProjectFragment) type.getAncestor(IModelElement.PROJECT_FRAGMENT);
- BuildpathEntry entry = (BuildpathEntry) this.rootToResolvedEntries.get(root);
+ private AccessRestriction getViolatedRestriction(String typeName,
+ String packageName, IType type, AccessRestriction accessRestriction) {
+ IProjectFragment root = (IProjectFragment) type
+ .getAncestor(IModelElement.PROJECT_FRAGMENT);
+ BuildpathEntry entry = (BuildpathEntry) this.rootToResolvedEntries
+ .get(root);
if (entry != null) { // reverse map always contains resolved CP entry
AccessRuleSet accessRuleSet = entry.getAccessRuleSet();
if (accessRuleSet != null) {
- // TODO (philippe) improve char[] <-> String conversions to avoid performing them on the fly
- char[][] packageChars = CharOperation.splitOn('.', packageName.toCharArray());
+ // TODO (philippe) improve char[] <-> String conversions to
+ // avoid performing them on the fly
+ char[][] packageChars = CharOperation.splitOn('.', packageName
+ .toCharArray());
char[] typeChars = typeName.toCharArray();
- accessRestriction = accessRuleSet.getViolatedRestriction(CharOperation.concatWith(packageChars, typeChars, '/'));
+ accessRestriction = accessRuleSet
+ .getViolatedRestriction(CharOperation.concatWith(
+ packageChars, typeChars, '/'));
}
}
return accessRestriction;
}
/**
- * Returns the first type in the given package whose name
- * matches the given (unqualified) name, or <code>null</code> if none
- * exist. Specifying a <code>null</code> package will result in no matches.
- * The domain of the search is bounded by the Script project from which
- * this name lookup was obtained.
- *
- * @param name the name of the type to find
- * @param pkg the package to search
- * @param partialMatch partial name matches qualify when <code>true</code>,
- * only exact name matches qualify when <code>false</code>
- * @param acceptFlags a bit mask describing if classes, interfaces or both classes and interfaces
- * are desired results. If no flags are specified, all types are returned.
- * @param considerSecondaryTypes flag to know whether secondary types has to be considered
- * during the search
- *
+ * Returns the first type in the given package whose name matches the given
+ * (unqualified) name, or <code>null</code> if none exist. Specifying a
+ * <code>null</code> package will result in no matches. The domain of the
+ * search is bounded by the Script project from which this name lookup was
+ * obtained.
+ *
+ * @param name
+ * the name of the type to find
+ * @param pkg
+ * the package to search
+ * @param partialMatch
+ * partial name matches qualify when <code>true</code>, only
+ * exact name matches qualify when <code>false</code>
+ * @param acceptFlags
+ * a bit mask describing if classes, interfaces or both classes
+ * and interfaces are desired results. If no flags are specified,
+ * all types are returned.
+ * @param considerSecondaryTypes
+ * flag to know whether secondary types has to be considered
+ * during the search
+ *
* @see #ACCEPT_CLASSES
* @see #ACCEPT_INTERFACES
* @see #ACCEPT_ENUMS
* @see #ACCEPT_ANNOTATIONS
*/
- public IType findType(String name, IScriptFolder pkg, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes) {
- IType type = findType(name, pkg, partialMatch, acceptFlags);
+ public IType findType(String name, IScriptFolder pkg, boolean partialMatch,
+ int acceptFlags, boolean considerSecondaryTypes) {
+ IType type = findType(name, pkg, partialMatch, acceptFlags);
return type;
}
/**
- * Returns the first type in the given package whose name
- * matches the given (unqualified) name, or <code>null</code> if none
- * exist. Specifying a <code>null</code> package will result in no matches.
- * The domain of the search is bounded by the Script project from which
- * this name lookup was obtained.
- * <br>
- * Note that this method does not find secondary types.
- * <br>
- * @param name the name of the type to find
- * @param pkg the package to search
- * @param partialMatch partial name matches qualify when <code>true</code>,
- * only exact name matches qualify when <code>false</code>
- * @param acceptFlags a bit mask describing if classes, interfaces or both classes and interfaces
- * are desired results. If no flags are specified, all types are returned.
- *
+ * Returns the first type in the given package whose name matches the given
+ * (unqualified) name, or <code>null</code> if none exist. Specifying a
+ * <code>null</code> package will result in no matches. The domain of the
+ * search is bounded by the Script project from which this name lookup was
+ * obtained. <br>
+ * Note that this method does not find secondary types. <br>
+ *
+ * @param name
+ * the name of the type to find
+ * @param pkg
+ * the package to search
+ * @param partialMatch
+ * partial name matches qualify when <code>true</code>, only
+ * exact name matches qualify when <code>false</code>
+ * @param acceptFlags
+ * a bit mask describing if classes, interfaces or both classes
+ * and interfaces are desired results. If no flags are specified,
+ * all types are returned.
+ *
* @see #ACCEPT_CLASSES
* @see #ACCEPT_INTERFACES
* @see #ACCEPT_ENUMS
* @see #ACCEPT_ANNOTATIONS
*/
- public IType findType(String name, IScriptFolder pkg, boolean partialMatch, int acceptFlags) {
- if (pkg == null) return null;
+ public IType findType(String name, IScriptFolder pkg, boolean partialMatch,
+ int acceptFlags) {
+ if (pkg == null)
+ return null;
// Return first found (ignore duplicates).
SingleTypeRequestor typeRequestor = new SingleTypeRequestor();
@@ -659,86 +724,110 @@
}
/**
- * Returns the type specified by the qualified name, or <code>null</code>
- * if none exist. The domain of
- * the search is bounded by the Script project from which this name lookup was obtained.
- *
- * @param name the name of the type to find
- * @param partialMatch partial name matches qualify when <code>true</code>,
- * only exact name matches qualify when <code>false</code>
- * @param acceptFlags a bit mask describing if classes, interfaces or both classes and interfaces
- * are desired results. If no flags are specified, all types are returned.
- *
+ * Returns the type specified by the qualified name, or <code>null</code> if
+ * none exist. The domain of the search is bounded by the Script project
+ * from which this name lookup was obtained.
+ *
+ * @param name
+ * the name of the type to find
+ * @param partialMatch
+ * partial name matches qualify when <code>true</code>, only
+ * exact name matches qualify when <code>false</code>
+ * @param acceptFlags
+ * a bit mask describing if classes, interfaces or both classes
+ * and interfaces are desired results. If no flags are specified,
+ * all types are returned.
+ *
* @see #ACCEPT_CLASSES
* @see #ACCEPT_INTERFACES
* @see #ACCEPT_ENUMS
* @see #ACCEPT_ANNOTATIONS
*/
public IType findType(String name, boolean partialMatch, int acceptFlags) {
- NameLookup.Answer answer = findType(name, partialMatch, acceptFlags, false/*don't check restrictions*/);
+ NameLookup.Answer answer = findType(name, partialMatch, acceptFlags,
+ false/* don't check restrictions */);
return answer == null ? null : answer.type;
}
-
- public Answer findType(String name, boolean partialMatch, int acceptFlags, boolean checkRestrictions) {
- return findType(name, partialMatch, acceptFlags, true/*consider secondary types*/, true/*wait for indexes*/, checkRestrictions, null);
+
+ public Answer findType(String name, boolean partialMatch, int acceptFlags,
+ boolean checkRestrictions) {
+ return findType(name, partialMatch, acceptFlags, true/*
+ * consider
+ * secondary types
+ */, true/*
+ * wait for
+ * indexes
+ */,
+ checkRestrictions, null);
}
- public Answer findType(String name, boolean partialMatch, int acceptFlags, boolean considerSecondaryTypes, boolean waitForIndexes, boolean checkRestrictions, IProgressMonitor monitor) {
- int index= name.lastIndexOf('.');
- String className= null, packageName= null;
+
+ public Answer findType(String name, boolean partialMatch, int acceptFlags,
+ boolean considerSecondaryTypes, boolean waitForIndexes,
+ boolean checkRestrictions, IProgressMonitor monitor) {
+ int index = name.lastIndexOf('.');
+ String className = null, packageName = null;
if (index == -1) {
- packageName= IScriptFolder.DEFAULT_FOLDER_NAME;
- className= name;
+ packageName = IScriptFolder.DEFAULT_FOLDER_NAME;
+ className = name;
} else {
- packageName= name.substring(0, index);
- className= name.substring(index + 1);
+ packageName = name.substring(0, index);
+ className = name.substring(index + 1);
}
- return findType(className, packageName, partialMatch, acceptFlags, considerSecondaryTypes, waitForIndexes, checkRestrictions, monitor);
+ return findType(className, packageName, partialMatch, acceptFlags,
+ considerSecondaryTypes, waitForIndexes, checkRestrictions,
+ monitor);
}
private IType getMemberType(IType type, String name, int dot) {
while (dot != -1) {
- int start = dot+1;
+ int start = dot + 1;
dot = name.indexOf('.', start);
- String typeName = name.substring(start, dot == -1 ? name.length() : dot);
+ String typeName = name.substring(start, dot == -1 ? name.length()
+ : dot);
type = type.getType(typeName);
}
return type;
}
-
+
public boolean isPackage(String[] pkgName) {
return this.isPackageCache.get(pkgName) != null;
}
/**
- * Returns true if the given element's name matches the
- * specified <code>searchName</code>, otherwise false.
- *
- * <p>The <code>partialMatch</code> argument indicates partial matches
- * should be considered.
- * NOTE: in partialMatch mode, the case will be ignored, and the searchName must already have
- * been lowercased.
+ * Returns true if the given element's name matches the specified
+ * <code>searchName</code>, otherwise false.
+ *
+ * <p>
+ * The <code>partialMatch</code> argument indicates partial matches should
+ * be considered. NOTE: in partialMatch mode, the case will be ignored, and
+ * the searchName must already have been lowercased.
*/
- protected boolean nameMatches(String searchName, IModelElement element, boolean partialMatch) {
+ protected boolean nameMatches(String searchName, IModelElement element,
+ boolean partialMatch) {
if (partialMatch) {
- // partial matches are used in completion mode, thus case insensitive mode
- return element.getElementName().toLowerCase().startsWith(searchName);
+ // partial matches are used in completion mode, thus case
+ // insensitive mode
+ return element.getElementName().toLowerCase()
+ .startsWith(searchName);
} else {
return element.getElementName().equals(searchName);
}
}
/**
- * Returns true if the given cu's name matches the
- * specified <code>searchName</code>, otherwise false.
- *
- * <p>The <code>partialMatch</code> argument indicates partial matches
- * should be considered.
- * NOTE: in partialMatch mode, the case will be ignored, and the searchName must already have
- * been lowercased.
+ * Returns true if the given cu's name matches the specified
+ * <code>searchName</code>, otherwise false.
+ *
+ * <p>
+ * The <code>partialMatch</code> argument indicates partial matches should
+ * be considered. NOTE: in partialMatch mode, the case will be ignored, and
+ * the searchName must already have been lowercased.
*/
- protected boolean nameMatches(String searchName, ISourceModule cu, boolean partialMatch) {
+ protected boolean nameMatches(String searchName, ISourceModule cu,
+ boolean partialMatch) {
if (partialMatch) {
- // partial matches are used in completion mode, thus case insensitive mode
+ // partial matches are used in completion mode, thus case
+ // insensitive mode
return cu.getElementName().toLowerCase().startsWith(searchName);
} else {
return Util.equalsIgnoreExtension(cu.getElementName(), searchName);
@@ -746,40 +835,44 @@
}
/**
- * Notifies the given requestor of all package fragments with the
- * given name. Checks the requestor at regular intervals to see if the
- * requestor has canceled. The domain of
- * the search is bounded by the <code>IScriptProject</code>
- * this <code>NameLookup</code> was obtained from.
- *
- * @param partialMatch partial name matches qualify when <code>true</code>;
- * only exact name matches qualify when <code>false</code>
+ * Notifies the given requestor of all package fragments with the given
+ * name. Checks the requestor at regular intervals to see if the requestor
+ * has canceled. The domain of the search is bounded by the
+ * <code>IScriptProject</code> this <code>NameLookup</code> was obtained
+ * from.
+ *
+ * @param partialMatch
+ * partial name matches qualify when <code>true</code>; only
+ * exact name matches qualify when <code>false</code>
*/
- public void seekScriptFolders(String name, boolean partialMatch, IModelElementRequestor requestor) {
-/* if (VERBOSE) {
- Util.verbose(" SEEKING PACKAGE FRAGMENTS"); //$NON-NLS-1$
- Util.verbose(" -> name: " + name); //$NON-NLS-1$
- Util.verbose(" -> partial match:" + partialMatch); //$NON-NLS-1$
- }
-*/ if (partialMatch) {
+ public void seekScriptFolders(String name, boolean partialMatch,
+ IModelElementRequestor requestor) {
+ /*
+ * if (VERBOSE) { Util.verbose(" SEEKING PACKAGE FRAGMENTS");
+ * //$NON-NLS-1$ Util.verbose(" -> name: " + name); //$NON-NLS-1$
+ * Util.verbose(" -> partial match:" + partialMatch); //$NON-NLS-1$ }
+ */if (partialMatch) {
String[] splittedName = Util.splitOn('.', name, 0, name.length());
Object[][] keys = this.scriptFolders.keyTable;
for (int i = 0, length = keys.length; i < length; i++) {
if (requestor.isCanceled())
return;
String[] pkgName = (String[]) keys[i];
- if (pkgName != null && Util.startsWithIgnoreCase(pkgName, splittedName)) {
+ if (pkgName != null
+ && Util.startsWithIgnoreCase(pkgName, splittedName)) {
Object value = this.scriptFolders.valueTable[i];
if (value instanceof ProjectFragment) {
- ProjectFragment root = (ProjectFragment) value;
- requestor.acceptScriptFolder(root.getScriptFolder(toPath(pkgName)));
+ IProjectFragment root = (IProjectFragment) value;
+ requestor.acceptScriptFolder(root
+ .getScriptFolder(toPath(pkgName)));
} else {
IProjectFragment[] roots = (IProjectFragment[]) value;
for (int j = 0, length2 = roots.length; j < length2; j++) {
if (requestor.isCanceled())
return;
- ProjectFragment root = (ProjectFragment) roots[j];
- requestor.acceptScriptFolder(root.getScriptFolder(toPath(pkgName)));
+ IProjectFragment root = (IProjectFragment) roots[j];
+ requestor.acceptScriptFolder(root
+ .getScriptFolder(toPath(pkgName)));
}
}
}
@@ -788,15 +881,17 @@
String[] splittedName = Util.splitOn('.', name, 0, name.length());
Object value = this.scriptFolders.get(splittedName);
if (value instanceof ProjectFragment) {
- requestor.acceptScriptFolder(((ProjectFragment) value).getScriptFolder(toPath(splittedName)));
+ requestor.acceptScriptFolder(((IProjectFragment) value)
+ .getScriptFolder(toPath(splittedName)));
} else {
IProjectFragment[] roots = (IProjectFragment[]) value;
if (roots != null) {
for (int i = 0, length = roots.length; i < length; i++) {
if (requestor.isCanceled())
return;
- ProjectFragment root = (ProjectFragment) roots[i];
- requestor.acceptScriptFolder(root.getScriptFolder(toPath(splittedName)));
+ IProjectFragment root = (IProjectFragment) roots[i];
+ requestor.acceptScriptFolder(root
+ .getScriptFolder(toPath(splittedName)));
}
}
}
@@ -805,61 +900,72 @@
/**
* Notifies the given requestor of all types (classes and interfaces) in the
- * given package fragment with the given (unqualified) name.
- * Checks the requestor at regular intervals to see if the requestor
- * has canceled. If the given package fragment is <code>null</code>, all types in the
- * project whose simple name matches the given name are found.
- *
- * @param name The name to search
- * @param pkg The corresponding package fragment
- * @param partialMatch partial name matches qualify when <code>true</code>;
- * only exact name matches qualify when <code>false</code>
- * @param acceptFlags a bit mask describing if classes, interfaces or both classes and interfaces
- * are desired results. If no flags are specified, all types are returned.
- * @param requestor The requestor that collects the result
- *
+ * given package fragment with the given (unqualified) name. Checks the
+ * requestor at regular intervals to see if the requestor has canceled. If
+ * the given package fragment is <code>null</code>, all types in the project
+ * whose simple name matches the given name are found.
+ *
+ * @param name
+ * The name to search
+ * @param pkg
+ * The corresponding package fragment
+ * @param partialMatch
+ * partial name matches qualify when <code>true</code>; only
+ * exact name matches qualify when <code>false</code>
+ * @param acceptFlags
+ * a bit mask describing if classes, interfaces or both classes
+ * and interfaces are desired results. If no flags are specified,
+ * all types are returned.
+ * @param requestor
+ * The requestor that collects the result
+ *
* @see #ACCEPT_CLASSES
* @see #ACCEPT_INTERFACES
* @see #ACCEPT_ENUMS
* @see #ACCEPT_ANNOTATIONS
*/
- public void seekTypes(String name, IScriptFolder pkg, boolean partialMatch, int acceptFlags, IModelElementRequestor requestor) {
-/* if (VERBOSE) {
- Util.verbose(" SEEKING TYPES"); //$NON-NLS-1$
- Util.verbose(" -> name: " + name); //$NON-NLS-1$
- Util.verbose(" -> pkg: " + ((ModelElement) pkg).toStringWithAncestors()); //$NON-NLS-1$
- Util.verbose(" -> partial match:" + partialMatch); //$NON-NLS-1$
- }
-*/
- String matchName= partialMatch ? name.toLowerCase() : name;
+ public void seekTypes(String name, IScriptFolder pkg, boolean partialMatch,
+ int acceptFlags, IModelElementRequestor requestor) {
+ /*
+ * if (VERBOSE) { Util.verbose(" SEEKING TYPES"); //$NON-NLS-1$
+ * Util.verbose(" -> name: " + name); //$NON-NLS-1$
+ * Util.verbose(" -> pkg: " + ((ModelElement)
+ * pkg).toStringWithAncestors()); //$NON-NLS-1$
+ * Util.verbose(" -> partial match:" + partialMatch); //$NON-NLS-1$ }
+ */
+ String matchName = partialMatch ? name.toLowerCase() : name;
if (pkg == null) {
findAllTypes(matchName, partialMatch, acceptFlags, requestor);
return;
}
- IProjectFragment root= (IProjectFragment) pkg.getParent();
+ IProjectFragment root = (IProjectFragment) pkg.getParent();
try {
// look in working copies first
int firstDot = -1;
String topLevelTypeName = null;
- int packageFlavor= root.getKind();
- if (this.typesInWorkingCopies != null || packageFlavor == IProjectFragment.K_SOURCE) {
+ int packageFlavor = root.getKind();
+ if (this.typesInWorkingCopies != null
+ || packageFlavor == IProjectFragment.K_SOURCE) {
firstDot = matchName.indexOf('.');
if (!partialMatch)
- topLevelTypeName = firstDot == -1 ? matchName : matchName.substring(0, firstDot);
+ topLevelTypeName = firstDot == -1 ? matchName : matchName
+ .substring(0, firstDot);
}
if (this.typesInWorkingCopies != null) {
- if (seekTypesInWorkingCopies(matchName, pkg, firstDot, partialMatch, topLevelTypeName, acceptFlags, requestor))
+ if (seekTypesInWorkingCopies(matchName, pkg, firstDot,
+ partialMatch, topLevelTypeName, acceptFlags, requestor))
return;
}
-
+
// look in model
- switch (packageFlavor) {
- case IProjectFragment.K_SOURCE :
- seekTypesInSourcePackage(matchName, pkg, firstDot, partialMatch, topLevelTypeName, acceptFlags, requestor);
- break;
- default :
- return;
+ switch (packageFlavor) {
+ case IProjectFragment.K_SOURCE:
+ seekTypesInSourcePackage(matchName, pkg, firstDot,
+ partialMatch, topLevelTypeName, acceptFlags, requestor);
+ break;
+ default:
+ return;
}
} catch (ModelException e) {
return;
@@ -869,15 +975,10 @@
/**
* Performs type search in a source package.
*/
- protected void seekTypesInSourcePackage(
- String name,
- IScriptFolder pkg,
- int firstDot,
- boolean partialMatch,
- String topLevelTypeName,
- int acceptFlags,
- IModelElementRequestor requestor) {
-
+ protected void seekTypesInSourcePackage(String name, IScriptFolder pkg,
+ int firstDot, boolean partialMatch, String topLevelTypeName,
+ int acceptFlags, IModelElementRequestor requestor) {
+
long start = -1;
if (VERBOSE)
start = System.currentTimeMillis();
@@ -891,13 +992,21 @@
IModelElement cu = compilationUnits[i];
String cuName = cu.getElementName();
int lastDot = cuName.lastIndexOf('.');
- if (lastDot != topLevelTypeName.length() || !topLevelTypeName.regionMatches(0, cuName, 0, lastDot))
+ if (lastDot != topLevelTypeName.length()
+ || !topLevelTypeName.regionMatches(0, cuName,
+ 0, lastDot))
continue;
- IType type = ((ISourceModule) cu).getType(topLevelTypeName);
+ IType type = ((ISourceModule) cu)
+ .getType(topLevelTypeName);
type = getMemberType(type, name, firstDot);
- if (acceptType(type, acceptFlags, true/*a source type*/)) { // accept type checks for existence
+ if (acceptType(type, acceptFlags, true/* a source type */)) { // accept
+ // type
+ // checks
+ // for
+ // existence
requestor.acceptType(type);
- break; // since an exact match was requested, no other matching type can exist
+ break; // since an exact match was requested, no
+ // other matching type can exist
}
}
} catch (ModelException e) {
@@ -905,18 +1014,21 @@
}
} else {
try {
- String cuPrefix = firstDot == -1 ? name : name.substring(0, firstDot);
+ String cuPrefix = firstDot == -1 ? name : name.substring(0,
+ firstDot);
IModelElement[] compilationUnits = pkg.getChildren();
for (int i = 0, length = compilationUnits.length; i < length; i++) {
if (requestor.isCanceled())
return;
IModelElement cu = compilationUnits[i];
- if (!cu.getElementName().toLowerCase().startsWith(cuPrefix))
+ if (!cu.getElementName().toLowerCase().startsWith(
+ cuPrefix))
continue;
try {
IType[] types = ((ISourceModule) cu).getTypes();
for (int j = 0, typeLength = types.length; j < typeLength; j++)
- seekTypesInTopLevelType(name, firstDot, types[j], requestor, acceptFlags);
+ seekTypesInTopLevelType(name, firstDot,
+ types[j], requestor, acceptFlags);
} catch (ModelException e) {
// cu doesn't exist -> ignore
}
@@ -927,42 +1039,48 @@
}
} finally {
if (VERBOSE)
- this.timeSpentInSeekTypesInSourcePackage += System.currentTimeMillis()-start;
+ this.timeSpentInSeekTypesInSourcePackage += System
+ .currentTimeMillis()
+ - start;
}
}
-
+
/**
* Notifies the given requestor of all types (classes and interfaces) in the
- * given type with the given (possibly qualified) name. Checks
- * the requestor at regular intervals to see if the requestor
- * has canceled.
+ * given type with the given (possibly qualified) name. Checks the requestor
+ * at regular intervals to see if the requestor has canceled.
*/
- protected boolean seekTypesInType(String prefix, int firstDot, IType type, IModelElementRequestor requestor, int acceptFlags) {
- IType[] types= null;
+ protected boolean seekTypesInType(String prefix, int firstDot, IType type,
+ IModelElementRequestor requestor, int acceptFlags) {
+ IType[] types = null;
try {
- types= type.getTypes();
+ types = type.getTypes();
} catch (ModelException npe) {
return false; // the enclosing type is not present
}
- int length= types.length;
- if (length == 0) return false;
-
+ int length = types.length;
+ if (length == 0)
+ return false;
+
String memberPrefix = prefix;
boolean isMemberTypePrefix = false;
if (firstDot != -1) {
- memberPrefix= prefix.substring(0, firstDot);
+ memberPrefix = prefix.substring(0, firstDot);
isMemberTypePrefix = true;
}
- for (int i= 0; i < length; i++) {
+ for (int i = 0; i < length; i++) {
if (requestor.isCanceled())
return false;
- IType memberType= types[i];
- if (memberType.getElementName().toLowerCase().startsWith(memberPrefix))
+ IType memberType = types[i];
+ if (memberType.getElementName().toLowerCase().startsWith(
+ memberPrefix))
if (isMemberTypePrefix) {
- String subPrefix = prefix.substring(firstDot + 1, prefix.length());
- return seekTypesInType(subPrefix, subPrefix.indexOf('.'), memberType, requestor, acceptFlags);
+ String subPrefix = prefix.substring(firstDot + 1, prefix
+ .length());
+ return seekTypesInType(subPrefix, subPrefix.indexOf('.'),
+ memberType, requestor, acceptFlags);
} else {
- if (acceptType(memberType, acceptFlags, true/*a source type*/)) {
+ if (acceptType(memberType, acceptFlags, true/* a source type */)) {
requestor.acceptMemberType(memberType);
return true;
}
@@ -970,52 +1088,54 @@
}
return false;
}
-
- protected boolean seekTypesInTopLevelType(String prefix, int firstDot, IType topLevelType, IModelElementRequestor requestor, int acceptFlags) {
+
+ protected boolean seekTypesInTopLevelType(String prefix, int firstDot,
+ IType topLevelType, IModelElementRequestor requestor,
+ int acceptFlags) {
if (!topLevelType.getElementName().toLowerCase().startsWith(prefix))
return false;
if (firstDot == -1) {
- if (acceptType(topLevelType, acceptFlags, true/*a source type*/)) {
+ if (acceptType(topLevelType, acceptFlags, true/* a source type */)) {
requestor.acceptType(topLevelType);
return true;
}
} else {
- return seekTypesInType(prefix, firstDot, topLevelType, requestor, acceptFlags);
+ return seekTypesInType(prefix, firstDot, topLevelType, requestor,
+ acceptFlags);
}
return false;
}
-
+
/*
- * Seeks the type with the given name in the map of types with precedence (coming from working copies)
- * Return whether a type has been found.
+ * Seeks the type with the given name in the map of types with precedence
+ * (coming from working copies) Return whether a type has been found.
*/
- protected boolean seekTypesInWorkingCopies(
- String name,
- IScriptFolder pkg,
- int firstDot,
- boolean partialMatch,
- String topLevelTypeName,
- int acceptFlags,
- IModelElementRequestor requestor) {
+ protected boolean seekTypesInWorkingCopies(String name, IScriptFolder pkg,
+ int firstDot, boolean partialMatch, String topLevelTypeName,
+ int acceptFlags, IModelElementRequestor requestor) {
if (!partialMatch) {
- HashMap typeMap = (HashMap) (this.typesInWorkingCopies == null ? null : this.typesInWorkingCopies.get(pkg));
+ HashMap typeMap = (HashMap) (this.typesInWorkingCopies == null ? null
+ : this.typesInWorkingCopies.get(pkg));
if (typeMap != null) {
Object object = typeMap.get(topLevelTypeName);
if (object instanceof IType) {
IType type = getMemberType((IType) object, name, firstDot);
- if (acceptType(type, acceptFlags, true/*a source type*/)) {
+ if (acceptType(type, acceptFlags, true/* a source type */)) {
requestor.acceptType(type);
return true; // don't continue with compilation unit
}
} else if (object instanceof IType[]) {
- if (object == NO_TYPES) return true; // all types where deleted -> type is hidden
+ if (object == NO_TYPES)
+ return true; // all types where deleted -> type is
+ // hidden
IType[] topLevelTypes = (IType[]) object;
for (int i = 0, length = topLevelTypes.length; i < length; i++) {
if (requestor.isCanceled())
return false;
- IType type = getMemberType(topLevelTypes[i], name, firstDot);
- if (acceptType(type, acceptFlags, true/*a source type*/)) {
+ IType type = getMemberType(topLevelTypes[i], name,
+ firstDot);
+ if (acceptType(type, acceptFlags, true/* a source type */)) {
requestor.acceptType(type);
return true; // return the first one
}
@@ -1023,7 +1143,8 @@
}
}
} else {
- HashMap typeMap = (HashMap) (this.typesInWorkingCopies == null ? null : this.typesInWorkingCopies.get(pkg));
+ HashMap typeMap = (HashMap) (this.typesInWorkingCopies == null ? null
+ : this.typesInWorkingCopies.get(pkg));
if (typeMap != null) {
Iterator iterator = typeMap.values().iterator();
while (iterator.hasNext()) {
@@ -1031,16 +1152,18 @@
return false;
Object object = iterator.next();
if (object instanceof IType) {
- seekTypesInTopLevelType(name, firstDot, (IType) object, requestor, acceptFlags);
+ seekTypesInTopLevelType(name, firstDot, (IType) object,
+ requestor, acceptFlags);
} else if (object instanceof IType[]) {
IType[] topLevelTypes = (IType[]) object;
for (int i = 0, length = topLevelTypes.length; i < length; i++)
- seekTypesInTopLevelType(name, firstDot, topLevelTypes[i], requestor, acceptFlags);
+ seekTypesInTopLevelType(name, firstDot,
+ topLevelTypes[i], requestor, acceptFlags);
}
}
}
}
return false;
}
-
+
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectElementInfo.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectElementInfo.java
index fbc1dec..207f830 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectElementInfo.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ProjectElementInfo.java
@@ -278,7 +278,7 @@
} else {
if (existing instanceof ProjectFragment) {
fragmentsCache.put(pkgName, new IProjectFragment[] {
- (ProjectFragment) existing, root });
+ (IProjectFragment) existing, root });
} else {
IProjectFragment[] entry = (IProjectFragment[]) existing;
IProjectFragment[] copy = new IProjectFragment[entry.length + 1];
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptFolder.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptFolder.java
index 402f240..95cf8dc 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptFolder.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptFolder.java
@@ -39,7 +39,7 @@
protected final IPath path;
private final String elementName;
- protected ScriptFolder(ProjectFragment parent, IPath path) {
+ protected ScriptFolder(ModelElement parent, IPath path) {
super(parent);
this.path = path;
@@ -147,22 +147,11 @@
HashSet vChildren = new HashSet();
try {
IProjectFragment root = getProjectFragment();
- char[][] inclusionPatterns = null;
- if (root instanceof ProjectFragment) {
- inclusionPatterns = ((ProjectFragment) root)
- .fullInclusionPatternChars();
- }
- char[][] exclusionPatterns = null;
- if (root instanceof ProjectFragment) {
- exclusionPatterns = ((ProjectFragment) root)
- .fullExclusionPatternChars();
- }
IResource[] members = ((IContainer) underlyingResource).members();
for (int i = 0, max = members.length; i < max; i++) {
IResource child = members[i];
if (child.getType() != IResource.FOLDER
- && !Util.isExcluded(child, inclusionPatterns,
- exclusionPatterns)) {
+ && !Util.isExcluded(child, root)) {
IModelElement childElement;
if (kind == IProjectFragment.K_SOURCE
&& Util.isValidSourceModule(this, child)) {
@@ -336,7 +325,7 @@
if (getProjectFragment() instanceof ProjectFragment) {
return ((ScriptFolderInfo) getElementInfo())
.getForeignResources(getResource(),
- (ProjectFragment) getProjectFragment());
+ (IProjectFragment) getProjectFragment());
}
return ModelElementInfo.NO_NON_SCRIPT_RESOURCES;
}
@@ -368,8 +357,8 @@
ModelElement classFile = (ModelElement) getSourceModule(classFileName);
return classFile.getHandleFromMemento(memento, owner);
case JEM_USER_ELEMENT:
- return MementoModelElementUtil.getHandleFromMemento(memento,
- this, owner);
+ return MementoModelElementUtil.getHandleFromMemento(memento, this,
+ owner);
}
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SearchableEnvironmentRequestor.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SearchableEnvironmentRequestor.java
index 6461b64..75f5b87 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SearchableEnvironmentRequestor.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SearchableEnvironmentRequestor.java
@@ -12,9 +12,10 @@
import org.eclipse.dltk.compiler.CharOperation;
import org.eclipse.dltk.compiler.env.ISourceModule;
import org.eclipse.dltk.core.DLTKCore;
-import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IProjectFragment;
import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.IType;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.internal.codeassist.ISearchRequestor;
@@ -99,7 +100,7 @@
if (this.checkAccessRestrictions
&& (!type.getScriptProject().equals(this.project))) {
- ProjectFragment root = (ProjectFragment) type
+ IProjectFragment root = (IProjectFragment) type
.getAncestor(IModelElement.PROJECT_FRAGMENT);
BuildpathEntry entry = (BuildpathEntry) this.nameLookup.rootToResolvedEntries
.get(root);
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SetBuildpathOperation.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SetBuildpathOperation.java
index 82410b3..ff7be18 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SetBuildpathOperation.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SetBuildpathOperation.java
@@ -223,7 +223,7 @@
&& path.isPrefixOf(location) && !path.equals(location)) {
IProjectFragment[] roots = this.project
.computeProjectFragments(buildpath[i]);
- ProjectFragment root = (ProjectFragment) roots[0];
+ IProjectFragment root = (IProjectFragment) roots[0];
// now the output location becomes a package fragment -
// along with any subfolders
ArrayList folders = new ArrayList();
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SourceModule.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SourceModule.java
index eed03e1..714c646 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SourceModule.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/SourceModule.java
@@ -37,7 +37,7 @@
// ~ Constructors
- public SourceModule(ScriptFolder parent, String name, WorkingCopyOwner owner) {
+ public SourceModule(ModelElement parent, String name, WorkingCopyOwner owner) {
super(parent, name, owner, false);
if (DLTKCore.VERBOSE) {
@@ -228,7 +228,7 @@
ModelManager manager = ModelManager.getModelManager();
- SourceModule workingCopy = new SourceModule((ScriptFolder) getParent(),
+ SourceModule workingCopy = new SourceModule((ModelElement) getParent(),
getElementName(), workingCopyOwner);
ModelManager.PerWorkingCopyInfo perWorkingCopyInfo = manager
.getPerWorkingCopyInfo(workingCopy, false /* don't create */,
@@ -446,7 +446,7 @@
* ()
*/
protected ISourceModule getOriginalSourceModule() {
- return new SourceModule((ScriptFolder) getParent(), getElementName(),
+ return new SourceModule((ModelElement) getParent(), getElementName(),
DefaultWorkingCopyOwner.PRIMARY);
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchy.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchy.java
index 8cc7fd8..71fbe7b 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchy.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/hierarchy/TypeHierarchy.java
@@ -12,13 +12,47 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
-import org.eclipse.core.runtime.*;
-import org.eclipse.dltk.core.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.DLTKLanguageManager;
+import org.eclipse.dltk.core.ElementChangedEvent;
+import org.eclipse.dltk.core.IBuildpathEntry;
+import org.eclipse.dltk.core.IElementChangedListener;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IModelElementDelta;
+import org.eclipse.dltk.core.IModelStatusConstants;
+import org.eclipse.dltk.core.IProjectFragment;
+import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.IType;
+import org.eclipse.dltk.core.ITypeHierarchy;
+import org.eclipse.dltk.core.ITypeHierarchyChangedListener;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.WorkingCopyOwner;
import org.eclipse.dltk.core.search.IDLTKSearchScope;
import org.eclipse.dltk.core.search.SearchEngine;
-import org.eclipse.dltk.internal.core.*;
+import org.eclipse.dltk.internal.core.ModelElement;
+import org.eclipse.dltk.internal.core.ModelStatus;
+import org.eclipse.dltk.internal.core.Openable;
+import org.eclipse.dltk.internal.core.Region;
+import org.eclipse.dltk.internal.core.ScriptProject;
+import org.eclipse.dltk.internal.core.SourceModule;
+import org.eclipse.dltk.internal.core.TypeVector;
import org.eclipse.dltk.internal.core.util.Messages;
import org.eclipse.dltk.internal.core.util.Util;
@@ -724,7 +758,7 @@
case IModelElement.PROJECT_FRAGMENT:
return isAffectedByPackageFragmentRoot(delta, element);
case IModelElement.SCRIPT_FOLDER:
- return isAffectedByPackageFragment(delta, (ScriptFolder) element);
+ return isAffectedByPackageFragment(delta, (IScriptFolder) element);
case IModelElement.SOURCE_MODULE:
return isAffectedByOpenable(delta, element);
}
@@ -833,7 +867,7 @@
* hierarchy
*/
private boolean isAffectedByPackageFragment(IModelElementDelta delta,
- ScriptFolder element) {
+ IScriptFolder element) {
switch (delta.getKind()) {
case IModelElementDelta.ADDED:
// if the package fragment is in the projects being considered, this
@@ -1125,10 +1159,10 @@
* the same name.
*/
protected boolean packageRegionContainsSamePackageFragment(
- ScriptFolder element) {
+ IScriptFolder element) {
IModelElement[] pkgs = this.packageRegion.getElements();
for (int i = 0; i < pkgs.length; i++) {
- ScriptFolder pkg = (ScriptFolder) pkgs[i];
+ IScriptFolder pkg = (IScriptFolder) pkgs[i];
if (pkg.getElementName().equals(element.getElementName())) {
return true;
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/HandleFactory.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/HandleFactory.java
index 7e18ecd..2f60754 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/HandleFactory.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/HandleFactory.java
@@ -35,7 +35,6 @@
import org.eclipse.dltk.internal.core.Model;
import org.eclipse.dltk.internal.core.ModelManager;
import org.eclipse.dltk.internal.core.Openable;
-import org.eclipse.dltk.internal.core.ProjectFragment;
import org.eclipse.dltk.internal.core.ScriptProject;
/**
@@ -103,7 +102,7 @@
IScriptFolder pkgFragment = (IScriptFolder) this.packageHandles
.get(pkgName);
if (pkgFragment == null) {
- pkgFragment = ((ProjectFragment) this.lastPkgFragmentRoot)
+ pkgFragment = ((IProjectFragment) this.lastPkgFragmentRoot)
.getScriptFolder(toPath(pkgName));
this.packageHandles.put(pkgName, pkgFragment);
}
diff --git a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/Util.java b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/Util.java
index 7915f35..2afbce5 100644
--- a/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/Util.java
+++ b/core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/util/Util.java
@@ -629,19 +629,15 @@
case IModelElement.PROJECT_FRAGMENT:
return false;
case IModelElement.SCRIPT_FOLDER:
- ProjectFragment root = (ProjectFragment) element
+ IProjectFragment root = (IProjectFragment) element
.getAncestor(IModelElement.PROJECT_FRAGMENT);
IResource resource = element.getResource();
- return resource != null
- && isExcluded(resource, root.fullInclusionPatternChars(),
- root.fullExclusionPatternChars());
+ return resource != null && isExcluded(resource, root);
case IModelElement.SOURCE_MODULE:
- root = (ProjectFragment) element
+ root = (IProjectFragment) element
.getAncestor(IModelElement.PROJECT_FRAGMENT);
resource = element.getResource();
- if (resource != null
- && isExcluded(resource, root.fullInclusionPatternChars(),
- root.fullExclusionPatternChars()))
+ if (resource != null && isExcluded(resource, root))
return true;
return isExcluded(element.getParent());
default:
@@ -682,6 +678,16 @@
|| resourceType == IResource.PROJECT);
}
+ public final static boolean isExcluded(IResource resource,
+ IProjectFragment fragment) {
+ IPath path = resource.getFullPath();
+ // ensure that folders are only excluded if all of their children are
+ // excluded
+ int resourceType = resource.getType();
+ return isExcluded(path, fragment, resourceType == IResource.FOLDER
+ || resourceType == IResource.PROJECT);
+ }
+
public static boolean isValidSourceModule(IModelElement parent,
IResource resource) {
IDLTKLanguageToolkit toolkit = DLTKLanguageManager
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 fd4c467..623ce12 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
@@ -27,6 +27,7 @@
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IModelElementDelta;
import org.eclipse.dltk.core.IProjectFragment;
+import org.eclipse.dltk.core.IScriptFolder;
import org.eclipse.dltk.core.IScriptModel;
import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.dltk.core.ModelException;
@@ -37,7 +38,6 @@
import org.eclipse.dltk.internal.core.Model;
import org.eclipse.dltk.internal.core.ModelElement;
import org.eclipse.dltk.internal.core.ModelManager;
-import org.eclipse.dltk.internal.core.ScriptFolder;
import org.eclipse.dltk.internal.core.ScriptProject;
import org.eclipse.dltk.internal.core.util.Util;
@@ -302,7 +302,7 @@
if (DLTKCore.DEBUG) {
System.err.println("TODO: Check. Bug possible..."); //$NON-NLS-1$
}
- String relativePath = ((ScriptFolder) element).getPath()
+ String relativePath = ((ModelElement) element).getPath()
.toString() + '/';
containerPath = root.getPath();
containerPathToString = containerPath.toString();
@@ -582,7 +582,9 @@
return Path.EMPTY;
return element.getPath();
case IModelElement.SCRIPT_FOLDER:
- String relativePath = ((ScriptFolder) element).getRelativePath()
+ String relativePath = ((IScriptFolder) element).getPath()
+ .removeFirstSegments(
+ element.getParent().getPath().segmentCount())
.toString() + '/';
return getPath(element.getParent(), relativeToRoot).append(
new Path(relativePath));
diff --git a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/MethodNameMatchRequestorWrapper.java b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/MethodNameMatchRequestorWrapper.java
index 5e443ac..8c2c446 100644
--- a/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/MethodNameMatchRequestorWrapper.java
+++ b/core/plugins/org.eclipse.dltk.core/search/org/eclipse/dltk/internal/core/search/MethodNameMatchRequestorWrapper.java
@@ -20,12 +20,12 @@
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.MethodNameMatchRequestor;
import org.eclipse.dltk.core.search.TypeNameRequestor;
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;
@@ -146,8 +146,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];