Skip to content
Browse files

fix exception from buildpath changes on windows, bug 401623

  • Loading branch information...
1 parent 15af04a commit 2dae68799a8829e04fa9acae12901bf7939d22bc @panchenko committed
View
15 ...eclipse.dltk.core/environment/org/eclipse/dltk/core/environment/EnvironmentPathUtils.java
@@ -229,4 +229,19 @@ public static IFileHandle getFile(IModelElement element,
}
}
+ /**
+ * Answers if the specified full path belongs to the local environment.
+ */
+ public static boolean isLocalEnvironment(IPath fullPath) {
+ final String device = fullPath.getDevice();
+ if (device != null) {
+ final int pos = device.indexOf(SEPARATOR);
+ if (pos >= 0) {
+ return LocalEnvironment.ENVIRONMENT_ID.equals(device.substring(
+ 0, pos));
+ }
+ }
+ return false;
+ }
+
}
View
13 ...gins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ExternalFolderChange.java
@@ -11,7 +11,6 @@
package org.eclipse.dltk.internal.core;
import java.util.HashSet;
-import java.util.Iterator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -35,25 +34,23 @@ public ExternalFolderChange(ScriptProject project,
*/
public void updateExternalFoldersIfNecessary(boolean refreshIfExistAlready,
IProgressMonitor monitor) throws ModelException {
- HashSet oldFolders = ExternalFoldersManager
+ HashSet<IPath> oldFolders = ExternalFoldersManager
.getExternalFolders(this.oldResolvedBuildpath);
IBuildpathEntry[] newResolvedBuildpath = this.project
.getResolvedBuildpath();
- HashSet newFolders = ExternalFoldersManager
+ HashSet<IPath> newFolders = ExternalFoldersManager
.getExternalFolders(newResolvedBuildpath);
if (newFolders == null)
return;
ExternalFoldersManager foldersManager = ModelManager
.getExternalManager();
- Iterator iterator = newFolders.iterator();
- while (iterator.hasNext()) {
- Object folderPath = iterator.next();
+ for (IPath folderPath : newFolders) {
if (oldFolders == null || !oldFolders.remove(folderPath)) {
try {
- foldersManager.createLinkFolder((IPath) folderPath,
+ foldersManager.createLinkFolder(folderPath,
refreshIfExistAlready, monitor);
} catch (CoreException e) {
- throw new ModelException(e);
+ ModelException.propagate(e);
}
}
}
View
19 ...ns/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ExternalFoldersManager.java
@@ -28,9 +28,11 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.dltk.annotations.Nullable;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.IBuildpathEntry;
import org.eclipse.dltk.core.IScriptProjectFilenames;
+import org.eclipse.dltk.core.environment.EnvironmentPathUtils;
import org.eclipse.dltk.internal.core.util.Util;
public class ExternalFoldersManager {
@@ -43,18 +45,23 @@
* Returns a set of external path to external folders referred to on the
* given buildpath. Returns null if none.
*/
- public static HashSet getExternalFolders(IBuildpathEntry[] buildpath) {
+ @Nullable
+ public static HashSet<IPath> getExternalFolders(IBuildpathEntry[] buildpath) {
if (buildpath == null)
return null;
- HashSet folders = null;
+ HashSet<IPath> folders = null;
for (int i = 0; i < buildpath.length; i++) {
IBuildpathEntry entry = buildpath[i];
if (entry.getEntryKind() == IBuildpathEntry.BPE_LIBRARY) {
IPath entryPath = entry.getPath();
- if (isExternalFolderPath(entryPath)) {
- if (folders == null)
- folders = new HashSet();
- folders.add(entryPath);
+ if (EnvironmentPathUtils.isLocalEnvironment(entryPath)) {
+ final IPath local = EnvironmentPathUtils
+ .getLocalPath(entryPath);
+ if (isExternalFolderPath(local)) {
+ if (folders == null)
+ folders = new HashSet<IPath>();
+ folders.add(local);
+ }
}
}
}
View
14 core/plugins/org.eclipse.dltk.core/model/org/eclipse/dltk/internal/core/ScriptProject.java
@@ -942,11 +942,11 @@ public ResolvedBuildpath resolveBuildpath(IBuildpathEntry[] rawClasspath,
ExternalFoldersManager externalFoldersManager = ModelManager
.getExternalManager();
ResolvedBuildpath result = new ResolvedBuildpath();
- Map knownDrives = new HashMap();
+ Map<String, Boolean> knownDrives = new HashMap<String, Boolean>();
Map referencedEntriesMap = new HashMap();
List<IPath> rawLibrariesPath = new ArrayList<IPath>();
- LinkedHashSet resolvedEntries = new LinkedHashSet();
+ LinkedHashSet<IBuildpathEntry> resolvedEntries = new LinkedHashSet<IBuildpathEntry>();
if (resolveChainedLibraries) {
for (int index = 0; index < rawClasspath.length; index++) {
@@ -1125,9 +1125,10 @@ public ResolvedBuildpath resolveBuildpath(IBuildpathEntry[] rawClasspath,
private void addToResult(IBuildpathEntry rawEntry,
IBuildpathEntry resolvedEntry, ResolvedBuildpath result,
- LinkedHashSet resolvedEntries,
+ LinkedHashSet<IBuildpathEntry> resolvedEntries,
ExternalFoldersManager externalFoldersManager,
- Map oldChainedEntriesMap, boolean addAsChainedEntry, Map knownDrives) {
+ Map oldChainedEntriesMap, boolean addAsChainedEntry,
+ Map<String, Boolean> knownDrives) {
IPath resolvedPath;
// If it's already been resolved, do not add to resolvedEntries
@@ -1192,11 +1193,12 @@ private void copyFromOldChainedEntry(BuildpathEntry resolvedEntry,
* File#exists() takes lot of time for an unmapped drive. Hence, cache the
* info. https://bugs.eclipse.org/bugs/show_bug.cgi?id=338649
*/
- private boolean driveExists(IPath sourcePath, Map knownDrives) {
+ private boolean driveExists(IPath sourcePath,
+ Map<String, Boolean> knownDrives) {
String drive = sourcePath.getDevice();
if (drive == null)
return true;
- Boolean good = (Boolean) knownDrives.get(drive);
+ Boolean good = knownDrives.get(drive);
if (good == null) {
if (new File(drive).exists()) {
knownDrives.put(drive, Boolean.TRUE);

0 comments on commit 2dae687

Please sign in to comment.
Something went wrong with that request. Please try again.