diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java index c9474446c47..7ed251d8d58 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java @@ -8,11 +8,13 @@ * Contributors: * QNX Software Systems - Initial API and implementation * Markus Schorn (Wind River Systems) + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; import org.eclipse.cdt.core.model.IIncludeEntry; import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; 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, IPath[] exclusionPatterns, boolean 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; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java index 68aa9ba08c7..a18c0a9335f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeFileEntry.java @@ -7,12 +7,14 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; import org.eclipse.cdt.core.model.IIncludeFileEntry; import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; 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, IPath[] exclusionPatterns, boolean 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); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java index 86b9aaff242..95285accec0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeReference.java @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Ed Swartz (Nokia) *******************************************************************************/ 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.IIncludeEntry; import org.eclipse.cdt.core.model.IIncludeReference; +import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; 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) { super(celement, null, path.toString(), ICElement.C_VCONTAINER); fIncludeEntry = entry; - fPath = path; + fPath = PathUtil.getCanonicalPath(path); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java index e8819a009ed..4209f5731ba 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroFileEntry.java @@ -7,12 +7,14 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.internal.core.model; import org.eclipse.cdt.core.model.IMacroFileEntry; import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; 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, IPath[] exclusionPatterns, boolean 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); } /** diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java index 13ed72371e7..bb0841e0b51 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/PathUtil.java @@ -8,6 +8,7 @@ * Contributors: * QNX Software Systems - initial API and implementation * Markus Schorn (Wind River Systems) + * Ed Swartz (Nokia) *******************************************************************************/ package org.eclipse.cdt.utils; @@ -41,13 +42,19 @@ public class PathUtil { } public static IPath getCanonicalPath(IPath fullPath) { + if (!fullPath.isAbsolute()) + return fullPath; + File file = fullPath.toFile(); try { 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) { } - return null; + return fullPath; } public static IPath getWorkspaceRelativePath(IPath fullPath) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java index 98499c8d2e7..590727a42b9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OpenIncludeAction.java @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * QNX Software System * Sergey Prigogin, Google - https://bugs.eclipse.org/bugs/show_bug.cgi?id=13221 + * Ed Swartz (Nokia) *******************************************************************************/ 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.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.ILabelProvider; 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.IScannerInfoProvider; 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.dialogs.ElementListSelectionDialog; @@ -165,13 +168,16 @@ public class OpenIncludeAction extends Action { throws CoreException { // in case it is an absolute path IPath includeFile= new Path(name); - if (includeFile.isAbsolute() && includeFile.toFile().exists()) { - list.add(includeFile); - return; + if (includeFile.isAbsolute()) { + includeFile = PathUtil.getCanonicalPath(includeFile); + if (includeFile.toFile().exists()) { + list.add(includeFile); + return; + } } HashSet foundSet = new HashSet(); 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(); if (file.exists()) { IPath[] paths = resolveIncludeLink(path); @@ -201,8 +207,11 @@ public class OpenIncludeAction extends Action { int numSegToRemove = rPath.segmentCount() - name.segmentCount(); IPath sPath = rPath.removeFirstSegments(numSegToRemove); 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); + } return false; } return true;