1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Patch for Ed Swartz (Nokia) bug 158190. Improve handling of case insensitive paths on Windows.

This commit is contained in:
Doug Schaefer 2007-02-13 18:34:34 +00:00
parent 5cce583c8c
commit 1946cf2dee
6 changed files with 35 additions and 11 deletions

View file

@ -8,11 +8,13 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IIncludeEntry; import org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -25,7 +27,7 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
public IncludeEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includePath, boolean isSystemInclude, public IncludeEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includePath, boolean isSystemInclude,
IPath[] exclusionPatterns, boolean isExported) { IPath[] exclusionPatterns, boolean isExported) {
super(IPathEntry.CDT_INCLUDE, basePath, baseRef, resourcePath, exclusionPatterns, isExported); super(IPathEntry.CDT_INCLUDE, basePath, baseRef, resourcePath, exclusionPatterns, isExported);
this.includePath = (includePath == null) ? Path.EMPTY : includePath; this.includePath = (includePath == null) ? Path.EMPTY : PathUtil.getCanonicalPath(includePath);
this.isSystemInclude = isSystemInclude; this.isSystemInclude = isSystemInclude;
} }

View file

@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IIncludeFileEntry; import org.eclipse.cdt.core.model.IIncludeFileEntry;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -25,7 +27,7 @@ public class IncludeFileEntry extends APathEntry implements IIncludeFileEntry {
public IncludeFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includeFilePath, public IncludeFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includeFilePath,
IPath[] exclusionPatterns, boolean isExported) { IPath[] exclusionPatterns, boolean isExported) {
super(IPathEntry.CDT_INCLUDE_FILE, basePath, baseRef, resourcePath, exclusionPatterns, isExported); super(IPathEntry.CDT_INCLUDE_FILE, basePath, baseRef, resourcePath, exclusionPatterns, isExported);
this.includeFilePath = (includeFilePath == null) ? Path.EMPTY : includeFilePath; this.includeFilePath = (includeFilePath == null) ? Path.EMPTY : PathUtil.getCanonicalPath(includeFilePath);
} }

View file

@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
@ -22,6 +23,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IIncludeEntry; import org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -47,7 +49,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
public IncludeReference(ICElement celement, IIncludeEntry entry, IPath path) { public IncludeReference(ICElement celement, IIncludeEntry entry, IPath path) {
super(celement, null, path.toString(), ICElement.C_VCONTAINER); super(celement, null, path.toString(), ICElement.C_VCONTAINER);
fIncludeEntry = entry; fIncludeEntry = entry;
fPath = path; fPath = PathUtil.getCanonicalPath(path);
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -7,12 +7,14 @@
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.IMacroFileEntry; import org.eclipse.cdt.core.model.IMacroFileEntry;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
@ -25,7 +27,7 @@ public class MacroFileEntry extends APathEntry implements IMacroFileEntry {
public MacroFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath macroFilePath, public MacroFileEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath macroFilePath,
IPath[] exclusionPatterns, boolean isExported) { IPath[] exclusionPatterns, boolean isExported) {
super(IPathEntry.CDT_MACRO_FILE, basePath, baseRef, resourcePath, exclusionPatterns, isExported); super(IPathEntry.CDT_MACRO_FILE, basePath, baseRef, resourcePath, exclusionPatterns, isExported);
this.macroFilePath = (macroFilePath == null) ? Path.EMPTY : macroFilePath; this.macroFilePath = (macroFilePath == null) ? Path.EMPTY : PathUtil.getCanonicalPath(macroFilePath);
} }
/** /**

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* QNX Software Systems - initial API and implementation * QNX Software Systems - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.utils; package org.eclipse.cdt.utils;
@ -41,13 +42,19 @@ public class PathUtil {
} }
public static IPath getCanonicalPath(IPath fullPath) { public static IPath getCanonicalPath(IPath fullPath) {
if (!fullPath.isAbsolute())
return fullPath;
File file = fullPath.toFile(); File file = fullPath.toFile();
try { try {
String canonPath = file.getCanonicalPath(); String canonPath = file.getCanonicalPath();
return new Path(canonPath); IPath canonicalPath = new Path(canonPath);
if (fullPath.getDevice() == null)
canonicalPath = canonicalPath.setDevice(null);
return canonicalPath;
} catch (IOException ex) { } catch (IOException ex) {
} }
return null; return fullPath;
} }
public static IPath getWorkspaceRelativePath(IPath fullPath) { public static IPath getWorkspaceRelativePath(IPath fullPath) {

View file

@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QNX Software System * QNX Software System
* Sergey Prigogin, Google - https://bugs.eclipse.org/bugs/show_bug.cgi?id=13221 * Sergey Prigogin, Google - https://bugs.eclipse.org/bugs/show_bug.cgi?id=13221
* Ed Swartz (Nokia)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
@ -28,6 +29,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action; import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
@ -44,6 +46,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.parser.IScannerInfoProvider;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog; import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
@ -165,13 +168,16 @@ public class OpenIncludeAction extends Action {
throws CoreException { throws CoreException {
// in case it is an absolute path // in case it is an absolute path
IPath includeFile= new Path(name); IPath includeFile= new Path(name);
if (includeFile.isAbsolute() && includeFile.toFile().exists()) { if (includeFile.isAbsolute()) {
includeFile = PathUtil.getCanonicalPath(includeFile);
if (includeFile.toFile().exists()) {
list.add(includeFile); list.add(includeFile);
return; return;
} }
}
HashSet foundSet = new HashSet(); HashSet foundSet = new HashSet();
for (int i = 0; i < includePaths.length; i++) { for (int i = 0; i < includePaths.length; i++) {
IPath path = new Path(includePaths[i]).append(includeFile); IPath path = PathUtil.getCanonicalPath(new Path(includePaths[i]).append(includeFile));
File file = path.toFile(); File file = path.toFile();
if (file.exists()) { if (file.exists()) {
IPath[] paths = resolveIncludeLink(path); IPath[] paths = resolveIncludeLink(path);
@ -201,8 +207,11 @@ public class OpenIncludeAction extends Action {
int numSegToRemove = rPath.segmentCount() - name.segmentCount(); int numSegToRemove = rPath.segmentCount() - name.segmentCount();
IPath sPath = rPath.removeFirstSegments(numSegToRemove); IPath sPath = rPath.removeFirstSegments(numSegToRemove);
sPath = sPath.setDevice(name.getDevice()); sPath = sPath.setDevice(name.getDevice());
if (sPath.equals(name)) if (Platform.getOS().equals(Platform.OS_WIN32) ?
sPath.toOSString().equalsIgnoreCase(name.toOSString()) :
sPath.equals(name)) {
list.add(rPath); list.add(rPath);
}
return false; return false;
} }
return true; return true;