From 450e32afb84941558b20b71e84a86ecfc3f31cb4 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 7 Nov 2008 11:10:02 +0000 Subject: [PATCH] Use URIUtil.toURI() instead of File.toURI(), related to bug 252744 --- .../org/eclipse/cdt/internal/core/model/Binary.java | 3 ++- .../internal/core/model/ExternalTranslationUnit.java | 10 ++++++++++ .../core/sourcelookup/AbsolutePathSourceContainer.java | 2 +- .../core/sourcelookup/MapEntrySourceContainer.java | 8 +++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java index e0ce0ab2fa0..44dc5b650eb 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Binary.java @@ -37,6 +37,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.cdt.internal.core.util.MementoTokenizer; +import org.eclipse.core.filesystem.URIUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.Assert; @@ -340,7 +341,7 @@ public class Binary extends Openable implements IBinary { if (wkspFile != null) tu = new TranslationUnit(this, wkspFile, id); else - tu = new ExternalTranslationUnit(this, file.toURI(), id); + tu = new ExternalTranslationUnit(this, Path.fromOSString(filename), id); if (! info.includesChild(tu)) info.addChild(tu); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java index 70f39be28ea..de4af83ea04 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ExternalTranslationUnit.java @@ -16,12 +16,22 @@ package org.eclipse.cdt.internal.core.model; import java.net.URI; import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.runtime.IPath; /** * ExternalTranslationUnit */ public class ExternalTranslationUnit extends TranslationUnit { + public ExternalTranslationUnit(ICElement parent, java.io.File file, String contentTypeID) { + this(parent, URIUtil.toURI(file.getAbsolutePath()), contentTypeID); + } + + public ExternalTranslationUnit(ICElement parent, IPath location, String contentTypeID) { + super(parent, URIUtil.toURI(location), contentTypeID); + } + public ExternalTranslationUnit(ICElement parent, URI uri, String contentTypeID) { super(parent, uri, contentTypeID); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java index 6b5a91f487c..bad09e453cf 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/sourcelookup/AbsolutePathSourceContainer.java @@ -64,7 +64,7 @@ public class AbsolutePathSourceContainer extends AbstractSourceContainer { { IPath path = Path.fromOSString(file.getCanonicalPath()); String id = CoreModel.getRegistedContentTypeId(project.getProject(), path.lastSegment()); - return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, file.toURI(), id) }; + return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, path, id) }; } } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java index e4cb05c00a9..bd298663bae 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/MapEntrySourceContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 2008 QNX Software Systems and others. + * Copyright (c) 2004, 2008 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -99,8 +99,9 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { { String id; try { - id = CoreModel.getRegistedContentTypeId(project.getProject(), Path.fromOSString(file.getCanonicalPath()).lastSegment()); - return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, file.toURI(), id) }; + final IPath location= Path.fromOSString(file.getCanonicalPath()); + id = CoreModel.getRegistedContentTypeId(project.getProject(), location.lastSegment()); + return new ExternalTranslationUnit[] { new ExternalTranslationUnit(project, location, id) }; } catch (IOException e) { e.printStackTrace(); } } } @@ -147,6 +148,7 @@ public class MapEntrySourceContainer extends AbstractSourceContainer { /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals( Object o ) { if ( !(o instanceof MapEntrySourceContainer ) ) return false;