Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2009-10-13 18:58:14 +0000
committerChris Recoskie2009-10-13 18:58:14 +0000
commit9d18807b5560dc87e068c5413640abea3f5b1a71 (patch)
tree2ab73505df2bc794dbff83ac8ab04b1bae5f612e
parent0916bdb4345cbd76d0ed73b6bd0f0c3785558127 (diff)
downloadorg.eclipse.cdt-9d18807b5560dc87e068c5413640abea3f5b1a71.tar.gz
org.eclipse.cdt-9d18807b5560dc87e068c5413640abea3f5b1a71.tar.xz
org.eclipse.cdt-9d18807b5560dc87e068c5413640abea3f5b1a71.zip
fix for 291815 (Add an extension point to allow utilities for virtual EFS filesystems)
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters27
-rw-r--r--core/org.eclipse.cdt.core/META-INF/MANIFEST.MF2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java4
-rw-r--r--core/org.eclipse.cdt.core/plugin.xml1
-rw-r--r--core/org.eclipse.cdt.core/schema/FileSystemUtility.exsd114
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java11
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java5
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IFilesystemUtility.java56
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/FileSystemUtilityManager.java155
9 files changed, 369 insertions, 6 deletions
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
new file mode 100644
index 00000000000..64fa60a00c5
--- /dev/null
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component id="org.eclipse.cdt.core" version="2">
+ <resource path="src/org/eclipse/cdt/core/IFilesystemUtility.java" type="org.eclipse.cdt.core.IFilesystemUtility">
+ <filter id="1109393411">
+ <message_arguments>
+ <message_argument value="5.0.3"/>
+ <message_argument value="org.eclipse.cdt.core.IFilesystemUtility"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="utils/org/eclipse/cdt/utils/FileSystemUtilityManager.java" type="org.eclipse.cdt.utils.FileSystemUtilityManager">
+ <filter id="1109393411">
+ <message_arguments>
+ <message_argument value="5.0.3"/>
+ <message_argument value="org.eclipse.cdt.utils.FileSystemUtilityManager"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="META-INF/MANIFEST.MF">
+ <filter id="924844039">
+ <message_arguments>
+ <message_argument value="5.0.3.qualifier"/>
+ <message_argument value="5.0.0.200806171202"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
index 025d195b04c..5a6c8c0a256 100644
--- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.core; singleton:=true
-Bundle-Version: 5.0.2.qualifier
+Bundle-Version: 5.0.3.qualifier
Bundle-Activator: org.eclipse.cdt.core.CCorePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
index a6010ba6cbb..ed08ff0f728 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
@@ -46,6 +47,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
+import org.eclipse.cdt.utils.FileSystemUtilityManager;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -770,7 +772,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
return path;
}
URI uri= ifl.getURI();
- return new Path(uri.getPath());
+ return new Path(FileSystemUtilityManager.getDefault().getPathFromURI(uri));
}
private void swallowError(IPath file, Throwable e) throws CoreException {
diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml
index a0a03cdb515..d03cd108391 100644
--- a/core/org.eclipse.cdt.core/plugin.xml
+++ b/core/org.eclipse.cdt.core/plugin.xml
@@ -531,6 +531,7 @@
schema="schema/templates.exsd"/>
<extension-point id="templateProcessTypes" name="%templateProcessTypes.name" schema="schema/templateProcessTypes.exsd"/>
<extension-point id="templateAssociations" name="%templateAssociations.name" schema="schema/templateAssociations.exsd"/>
+ <extension-point id="FileSystemUtility" name="File System Utility" schema="schema/FileSystemUtility.exsd"/>
<extension
point="org.eclipse.cdt.core.templateProcessTypes">
diff --git a/core/org.eclipse.cdt.core/schema/FileSystemUtility.exsd b/core/org.eclipse.cdt.core/schema/FileSystemUtility.exsd
new file mode 100644
index 00000000000..82a2499a7ec
--- /dev/null
+++ b/core/org.eclipse.cdt.core/schema/FileSystemUtility.exsd
@@ -0,0 +1,114 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.core" id="FileSystemUtility" name="Filesystem Utility"/>
+ </appInfo>
+ <documentation>
+ This extension point allows one to contribute a so-called &quot;Filesystem Utility&quot; class that can manipulate resources in a given EFS filesystem, and extract meaningful information from the filesystem and its resources.
+ </documentation>
+ </annotation>
+
+ <element name="FileSystemUtility">
+ <annotation>
+ <documentation>
+ An instance of a File System Utility. File System Utilities are mapped to a URI scheme corresponding to an EFS filesystem for which they provide support. These extensions are consulted by CDT in order to extract path information from the filesystem and manipulate filesystem resources.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="scheme" type="string" use="required">
+ <annotation>
+ <documentation>
+ The URI scheme of an EFS filesystem this utility provides support for.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ Java class which implements org.eclipse.cdt.core.IFilesystemUtility to provide support for the filesystem.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.cdt.core.IFilesystemUtility"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="FileSystemUtility"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 5.0.3
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ None.
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
index 9d4592335ea..7dccbec6dd2 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CProjectNature.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2009 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.core;
@@ -70,7 +71,13 @@ public class CProjectNature implements IProjectNature {
newNatures[prevNatures.length] = natureId;
description.setNatureIds(newNatures);
project.setDescription(description, monitor);
- } finally {
+ }
+
+ catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+
+ finally {
monitor.done();
}
}
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 cd32ac1271d..473ce093674 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2009 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
@@ -26,6 +26,7 @@ import java.util.Vector;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.cdt.utils.CygPath;
+import org.eclipse.cdt.utils.FileSystemUtilityManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -283,7 +284,7 @@ public class ErrorParserManager extends OutputStream {
// This relies on the assumption that the EFS filesystem being used stores path information in the path
// portion of the URI. This may not be in fact the case, but most filesystems adhere to such a format.
- String path = locationURI.getPath();
+ String path = FileSystemUtilityManager.getDefault().getPathFromURI(locationURI);
if(path == null)
return false;
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IFilesystemUtility.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IFilesystemUtility.java
new file mode 100644
index 00000000000..a405f4bb44a
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/IFilesystemUtility.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core;
+
+import java.net.URI;
+
+/**
+ * An interface for utility classes that can extract meaningful information from EFS filesystems.
+ *
+ * <strong>EXPERIMENTAL</strong>. 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.0.3
+ *
+ */
+public interface IFilesystemUtility {
+ /**
+ * Gets the path corresponding to the underlying file as the operating system on the target 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);
+
+ /**
+ * In the case of a managed (linked) filesystem, returns the URI that this URI ultimately will
+ * point to.
+ *
+ * @param locationURI
+ * @return URI
+ */
+ public URI getBaseURI(URI locationURI);
+
+
+ /**
+ * Creates a new URI on the same filesystem as another URI, but with a different path.
+ *
+ * @param locationOnSameFilesystem A URI pointing to another resource on the same filesystem that this resource
+ * should be on.
+ * @param path The absolute path to the resource.
+ * @return URI
+ */
+ public URI replacePathInURI(URI locationOnSameFilesystem, String path);
+}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/FileSystemUtilityManager.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/FileSystemUtilityManager.java
new file mode 100644
index 00000000000..33dd86a667b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/FileSystemUtilityManager.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.utils;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IFilesystemUtility;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+/**
+ * Manager class that consults contributors to the FileSystemUtility extension point to perform operations corresponding to those filesystems.
+ *
+ * <strong>EXPERIMENTAL</strong>. 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
+ * @noextend This class is not intended to be extended by clients.
+ * @since 5.0.3
+ */
+public class FileSystemUtilityManager {
+
+ private static FileSystemUtilityManager instance;
+
+ private Map<String, IFilesystemUtility> fSchemeToUtilityImplementerMap;
+
+ private static String EXTENSION_ID = "FileSystemUtility"; //$NON-NLS-1$
+
+ private FileSystemUtilityManager() {
+ fSchemeToUtilityImplementerMap = new HashMap<String, IFilesystemUtility>();
+ loadExtensions();
+ }
+
+ private void loadExtensions() {
+ IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID,
+ EXTENSION_ID);
+ if (extension != null) {
+ IExtension[] extensions = extension.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+
+ String scheme = configElements[j].getAttribute("scheme"); //$NON-NLS-1$
+ String utility = configElements[j].getAttribute("class"); //$NON-NLS-1$
+
+ if (utility != null) {
+ try {
+ Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
+ if (execExt instanceof IFilesystemUtility) {
+ fSchemeToUtilityImplementerMap.put(scheme, (IFilesystemUtility) execExt);
+ }
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ }
+
+ }
+ }
+ }
+
+ }
+
+ public synchronized static FileSystemUtilityManager getDefault() {
+ if(instance == null) {
+ instance = new FileSystemUtilityManager();
+ }
+ return instance;
+ }
+
+ /**
+ * Gets the path out of a URI. Right now this is hardcoded to deal with a select few filesystems.
+ * In the future, it would be better if EFS had an API for this.
+ *
+ * @param locationURI
+ * @return String representing the path.
+ */
+ public String getPathFromURI(URI locationURI) {
+ IFilesystemUtility utility = fSchemeToUtilityImplementerMap.get(locationURI.getScheme());
+
+ if(utility == null) {
+ return locationURI.getPath();
+ }
+
+ else {
+ return utility.getPathFromURI(locationURI);
+ }
+
+ }
+
+ /**
+ * In the case of a managed (linked) filesystem, returns the URI that this URI ultimately will
+ * point to. Otherwise, returns null.
+ *
+ * @param locationURI
+ * @return URI
+ */
+ public URI getManagedURI(URI locationURI) {
+ IFilesystemUtility utility = fSchemeToUtilityImplementerMap.get(locationURI.getScheme());
+
+ if(utility == null) {
+ return null;
+ }
+
+ else {
+ return utility.getBaseURI(locationURI);
+ }
+ }
+
+ /**
+ * Creates a new URI which clones the contents of the original URI, but with the path
+ * replaced by the given path. Returns null on error.
+ *
+ * @param uri
+ * @param path
+ * @return URI
+ */
+ public URI replacePath(URI uri, String path) {
+ IFilesystemUtility utility = fSchemeToUtilityImplementerMap.get(uri.getScheme());
+
+ if(utility == null) {
+ // if there is no corresponding utility, then assume we can just replace the path field
+ try {
+ return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
+ path, // replaced!
+ uri.getQuery(),uri.getFragment());
+ } catch (URISyntaxException e) {
+ CCorePlugin.log(e);
+ }
+
+ return null;
+ }
+
+ else {
+ return utility.replacePathInURI(uri, path);
+ }
+ }
+
+}

Back to the top