From c8075218df87be17329a0291b87fa45247660701 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Tue, 4 Sep 2012 17:34:05 -0400 Subject: [PATCH 1/3] bug 388755: Fix EFSExtensionProvider to return conventional path on Windows as C:/path (without extra leading slash) Change-Id: I82507744f069d774579f0bdd301e210df8157305 --- .../efsextension/tests/EFSExtensionTests.java | 4 +- .../cdt/core/EFSExtensionProvider.java | 48 +++++++++-------- .../eclipse/cdt/core/ErrorParserManager.java | 52 ++++++------------- 3 files changed, 44 insertions(+), 60 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java index e05d2756de4..42cfc668cf9 100644 --- a/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java +++ b/core/org.eclipse.cdt.core.tests/misc/org/eclipse/cdt/core/internal/efsextension/tests/EFSExtensionTests.java @@ -235,7 +235,7 @@ public class EFSExtensionTests extends TestCase { String path = EFSExtensionManager.getDefault().getMappedPath(originalURI); - assertEquals(path, "/c:/foo"); + assertEquals(path, "c:/foo"); } public void testGetPathFromURI() { @@ -248,7 +248,7 @@ public class EFSExtensionTests extends TestCase { String path = EFSExtensionManager.getDefault().getMappedPath(originalURI); - assertEquals(path, "/c:/foo"); + assertEquals(path, "c:/foo"); } public void testExtension() { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java index 10053b70211..3c70e1db98a 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java @@ -14,6 +14,7 @@ import java.net.URI; import java.net.URISyntaxException; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.URIUtil; /** @@ -22,25 +23,25 @@ import org.eclipse.core.runtime.URIUtil; * operate on virtual EFS filesystems (where IFileStores are just links to other IFileStores), or that operate * on the physical file backed by an IFileStore, without having to know the implementation details of a given * EFS filesystem. - * + * * Provides a default implementation that assumes that URIs for the given filesystem map directly to resources * in the physical filesystem, and that the path component of the URI is a direct representation of the * absolute path to the file in the physical filesystem. - * + * * Clients wishing to support a filesystem with different behaviour should extend this class and override its * methods where appropriate. - * + * * Clients should not typically call methods on this class or its descendants directly. Instead, they should * call the appropriate method in FileSystemUtilityManager so that said manager can properly route calls to * the proper utility, depending on the filesystem. - * + * * EXPERIMENTAL. This class or interface has been added as part of a work in progress. There * is no guarantee that this API will work or that it will remain the same. Please do not use this API without * consulting with the CDT team. - * + * * @author crecoskie * @since 5.2 - * + * */ public abstract class EFSExtensionProvider { @@ -48,20 +49,25 @@ public abstract class EFSExtensionProvider { * If the EFS store represented by locationURI is backed by a physical file, gets the path corresponding * to the underlying file as the operating system on hosting machine would see it. In the future, it would * be better if EFS had an API for this. - * + * * @param locationURI * @return String representing the path, or null if there is an error or if there is no such * physical file. */ public String getPathFromURI(URI locationURI) { - return locationURI.getPath(); + String path = locationURI.getPath(); + // URI path on Windows is represented as "/C:/path" + if (path != null && Platform.getOS().equals(Platform.WS_WIN32) && path.matches("/[A-Za-z]:.*")) { //$NON-NLS-1$ + path = path.substring(1); + } + return path; } /** * In the case of a virtual filesystem, where URIs in the given filesystem are just soft links in EFS to * URIs in other filesystems, returns the URI that this URI links to. If the filesystem is not virtual, * then this method acts as an identity mapping. - * + * * @param locationURI * @return A URI corresponding to the linked store, or null on error. */ @@ -73,25 +79,25 @@ public abstract class EFSExtensionProvider { * Creates a new URI which clones the contents of the original URI, but with the path replaced by the * given absolute path, such that calling getPathFromURI() on the returned URI will return the given path. Returns * null on error. - * + * * The default implementation places the path in the path field of the URI, ensuring that there is a leading slash. * It also determines whether or not to convert backslashes in the provided path based on whether or not the * local operating system's file separator is a backslash, thus ensuring proper behaviour for URIs corresponding * to the local filesystem. - * + * * @param locationOnSameFilesystem * @param path An absolute path. * @return URI */ public URI createNewURIFromPath(URI locationOnSameFilesystem, String path) { URI uri = locationOnSameFilesystem; - + Path p = new Path(path); String pathString = p.toString(); // to convert any backslashes to slashes if we are on Windows final int length = pathString.length(); StringBuffer pathBuf = new StringBuffer(length + 1); - // force the path to be absolute + // force the path to be absolute including Windows where URI path is represented as "/C:/path" if (length > 0 && (pathString.charAt(0) != '/')) { pathBuf.append('/'); } @@ -99,9 +105,9 @@ public abstract class EFSExtensionProvider { if (pathString.startsWith("//")) //$NON-NLS-1$ pathBuf.append('/').append('/'); pathBuf.append(pathString); - + try { - //Bug 326957 - EFSExtensionProvider does not handle URI's correctly + //Bug 326957 - EFSExtensionProvider does not handle URI's correctly return new URI(uri.getScheme(), uri.getAuthority(), pathBuf.toString(), // replaced! uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { @@ -115,11 +121,11 @@ public abstract class EFSExtensionProvider { * another path (say, on the local machine), this method returns the path that the store maps to. I.e., it * returns the path that the path returned by getPathFromURI(URI locationURI) maps to. If there is no such * mapping, then an identity mapping of the paths is assumed. - * + * * Typically if a filesystem maps one filesytem to another, it will place the mapped path in the path * field of its URIs (which the default implementation assumes), but this is not guaranteed to be so for * all filesystem implementations. - * + * * @return String representing the path, or null on error. */ public String getMappedPath(URI locationURI) { @@ -129,7 +135,7 @@ public abstract class EFSExtensionProvider { /** * Returns true if the given URI is part of a virtual filesystem and thus points to another underlying * URI. Returns false otherwise. By default, filesystems are assumed to be non-virtual. - * + * * @param locationURI * @return boolean */ @@ -139,12 +145,12 @@ public abstract class EFSExtensionProvider { /** * Creates a new URI with the same components as the baseURI, except that calling - * getPathFromURI() on the new URI will return a path that has the extension appended to + * getPathFromURI() on the new URI will return a path that has the extension appended to * the path returned by baseURI.getPathFromURI() - * + * * The default implementation assumes that the path component of the URI is used * to store the path. - * + * * @param baseURI * @param extension * @return the new URI, or null on error. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java index 3dc57672c5e..54e062665cb 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java @@ -71,7 +71,7 @@ public class ErrorParserManager extends OutputStream implements IConsoleParser, * @since 5.4 */ public static final String BUILD_CONTEXT = "build"; //$NON-NLS-1$ - + private int nOpens; private int lineCounter=0; @@ -221,16 +221,7 @@ public class ErrorParserManager extends OutputStream implements IConsoleParser, */ public void pushDirectory(IPath dir) { if (dir != null) { - URI uri; - URI workingDirectoryURI = getWorkingDirectoryURI(); - if (!dir.isAbsolute()) { - uri = URIUtil.append(workingDirectoryURI, dir.toString()); - } else { - uri = toURI(dir); - if (uri == null) { - return; - } - } + URI uri = toURI(dir); pushDirectoryURI(uri); } } @@ -485,18 +476,9 @@ outer: * @return - file in the workspace or {@code null} if such a file doesn't exist */ protected IFile findFileInWorkspace(IPath path) { - URI uri; - if (!path.isAbsolute()) { - URI workingDirectoryURI = getWorkingDirectoryURI(); - uri = EFSExtensionManager.getDefault().append(workingDirectoryURI, path.toString()); - } - else { - uri = toURI(path); - if (uri == null) { - return null; - } - } - return findFileInWorkspace(uri); + URI uri = toURI(path); + IFile file = findFileInWorkspace(uri); + return file; } /** @@ -728,10 +710,7 @@ outer: } /** - * Converts a location {@link IPath} to an {@link URI}. Contrary to - * {@link URIUtil#toURI(IPath)} this method does not assume that the path belongs - * to local file system. - * + * Converts a location {@link IPath} to an {@link URI}. * The returned URI uses the scheme and authority of the current working directory * as returned by {@link #getWorkingDirectoryURI()} * @@ -740,16 +719,15 @@ outer: * @since 5.1 */ private URI toURI(IPath path) { -// try { - URI baseURI = getWorkingDirectoryURI(); - String uriString = path.toString(); + URI uri = null; + URI workingDirectoryURI = getWorkingDirectoryURI(); + if (path.isAbsolute()) { + uri = EFSExtensionManager.getDefault().createNewURIFromPath(workingDirectoryURI, path.toString()); + } else { + uri = EFSExtensionManager.getDefault().append(workingDirectoryURI, path.toString()); + } - // On Windows "C:/folder/" -> "/C:/folder/" - if (path.isAbsolute() && uriString.charAt(0) != IPath.SEPARATOR) { - uriString = IPath.SEPARATOR + uriString; - } - - return EFSExtensionManager.getDefault().createNewURIFromPath(baseURI, uriString); + return uri; } /** @@ -828,7 +806,7 @@ outer: public static String[] getErrorParserAvailableIdsInContext(String context) { return ErrorParserExtensionManager.getErrorParserAvailableIdsInContext(context); } - + /** * @return IDs of error parsers contributed through error parser extension point. * @since 5.2 From 1de79e8703370570f646014eafe2e105b29d235e Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Wed, 5 Sep 2012 11:01:07 -0400 Subject: [PATCH 2/3] Bug 387193 - TVT/DVT3.8:TCT100: ARA: Incorrect mirrorred strings occurred on UPC options page of bupc properties on Linux --- .../ui/properties/BuildOptionSettingsUI.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java index eb5f833f8d6..9a81a62e026 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2011 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation 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 @@ -72,7 +72,6 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; -import org.eclipse.osgi.util.TextProcessor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -279,8 +278,8 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { if (applicabilityCalculator == null || applicabilityCalculator.isOptionVisible(config, holder, opt)) { String optId = getToolSettingsPrefStore().getOptionId(opt); - final String nameStr = TextProcessor.process(opt.getName()); - String tipStr = TextProcessor.process(opt.getToolTip()); + final String nameStr = opt.getName(); + String tipStr = opt.getToolTip(); String contextId = opt.getContextId(); if (pageHasToolTipBox && (tipStr==null || tipStr.trim().length()==0)) { @@ -923,7 +922,7 @@ public class BuildOptionSettingsUI extends AbstractToolSettingUI { IHoldsOptions holder = (IHoldsOptions)options[index][0]; if (holder == null) break; // The array may not be full IOption opt = (IOption)options[index][1]; - String tipStr = TextProcessor.process(opt.getToolTip()); + String tipStr = opt.getToolTip(); // check to see if the option has an applicability calculator IOptionApplicability applicabilityCalculator = opt.getApplicabilityCalculator(); From 8fb2b6a3c65f8e4b0ca4a976865e19379c9ccc3d Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Wed, 5 Sep 2012 15:57:20 -0400 Subject: [PATCH 3/3] bug 388755: Added extra check for schema "file" while fixing path "/C:/path" on Windows in EFSExtensionProvider --- .../src/org/eclipse/cdt/core/EFSExtensionProvider.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java index 3c70e1db98a..3889556adc3 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/EFSExtensionProvider.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.core; import java.net.URI; import java.net.URISyntaxException; +import org.eclipse.core.filesystem.EFS; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.URIUtil; @@ -56,9 +57,12 @@ public abstract class EFSExtensionProvider { */ public String getPathFromURI(URI locationURI) { String path = locationURI.getPath(); - // URI path on Windows is represented as "/C:/path" - if (path != null && Platform.getOS().equals(Platform.WS_WIN32) && path.matches("/[A-Za-z]:.*")) { //$NON-NLS-1$ - path = path.substring(1); + String schema = locationURI.getScheme(); + if (schema != null && schema.equals(EFS.SCHEME_FILE) && Platform.getOS().equals(Platform.WS_WIN32)) { + // URI path on Windows is represented as "/C:/path" + if (path != null && path.matches("/[A-Za-z]:.*")) { //$NON-NLS-1$ + path = path.substring(1); + } } return path; }