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

Get more of the FFS working. Also turned on Java 5 for cdt.core.

This commit is contained in:
Doug Schaefer 2007-12-28 21:29:45 +00:00
parent 5ff70f6e97
commit 0d50d5b222
9 changed files with 268 additions and 17 deletions

View file

@ -6,7 +6,7 @@
<classpathentry kind="src" path="utils"/>
<classpathentry kind="src" path="parser"/>
<classpathentry kind="src" path="templateengine"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -1,12 +1,12 @@
#Thu Oct 05 16:52:57 CEST 2006
#Fri Dec 28 14:46:56 EST 2007
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.4
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -46,6 +46,7 @@ Export-Package: org.eclipse.cdt.core,
org.eclipse.cdt.internal.core.dom.parser.c;x-friends:="org.eclipse.cdt.refactoring",
org.eclipse.cdt.internal.core.dom.parser.cpp;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.refactoring",
org.eclipse.cdt.internal.core.envvar,
org.eclipse.cdt.internal.core.ffs;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.index;x-friends:="org.eclipse.cdt.ui",
org.eclipse.cdt.internal.core.index.provider,
org.eclipse.cdt.internal.core.language,
@ -94,4 +95,4 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filebuffers;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.1.0,2.0.0)"
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-RequiredExecutionEnvironment: J2SE-1.5

View file

@ -707,7 +707,7 @@
<extension
point="org.eclipse.core.filesystem.filesystems">
<filesystem
scheme="ffs">
scheme="ecproj">
<run
class="org.eclipse.cdt.internal.core.ffs.FFSFileSystem">
</run>

View file

@ -0,0 +1,45 @@
/**********************************************************************
* Copyright (c) 2007 Wind River 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.internal.core.ffs;
import java.net.URI;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
* Contents of the ecproj file.
*/
public class FFSEcprojFile {
private final URI uri;
private final IFileStore root;
private final FFSFileSystem fileSystem;
public FFSEcprojFile(FFSFileSystem fileSystem, URI uri) throws CoreException {
this.uri = uri;
this.fileSystem = fileSystem;
this.root = EFS.getStore(uri);
}
public FFSFileSystem getFileSystem() {
return fileSystem;
}
public IFileStore getRoot() {
return new FFSFileStore(this, null, root);
}
}

View file

@ -0,0 +1,157 @@
/**********************************************************************
* Copyright (c) 2007 Wind River 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.internal.core.ffs;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.IFileSystem;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
* @author Doug Schaefer
*
*/
public class FFSFileStore implements org.eclipse.core.filesystem.IFileStore {
private final IFileStore target;
private final IFileStore parent;
private final FFSEcprojFile ecprojFile;
public FFSFileStore(FFSEcprojFile ecprojFile, IFileStore parent, IFileStore target) {
this.ecprojFile = ecprojFile;
this.parent = parent;
this.target = target;
}
public IFileInfo[] childInfos(int options, IProgressMonitor monitor) throws CoreException {
return target.childInfos(options, monitor);
}
public String[] childNames(int options, IProgressMonitor monitor) throws CoreException {
// TODO child handling
return target.childNames(options, monitor);
}
public IFileStore[] childStores(int options, IProgressMonitor monitor) throws CoreException {
IFileStore[] targetChildren = target.childStores(options, monitor);
IFileStore[] children = new IFileStore[targetChildren.length];
for (int i = 0; i < children.length; ++i)
children[i] = new FFSFileStore(ecprojFile, this, targetChildren[i]);
return children;
}
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
target.copy(destination, options, monitor);
}
public void delete(int options, IProgressMonitor monitor) throws CoreException {
target.delete(options, monitor);
}
public IFileInfo fetchInfo() {
return target.fetchInfo();
}
public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException {
return target.fetchInfo(options, monitor);
}
public IFileStore getChild(IPath path) {
IFileStore store = getChild(path.segment(0));
if (store == null)
return null;
return store.getChild(path.removeFirstSegments(1));
}
public IFileStore getChild(String name) {
// TODO child handling
return target.getChild(name);
}
public IFileSystem getFileSystem() {
return ecprojFile.getFileSystem();
}
public String getName() {
return target.getName();
}
public IFileStore getParent() {
return parent;
}
public boolean isParentOf(IFileStore other) {
if (other == null || !(other instanceof FFSFileStore))
return false;
if (other.equals(this))
return true;
return isParentOf(other.getParent());
}
public IFileStore mkdir(int options, IProgressMonitor monitor) throws CoreException {
return target.mkdir(options, monitor);
}
public void move(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
// TODO what happens if destination is a different target file system?
target.move(destination, options, monitor);
}
public InputStream openInputStream(int options, IProgressMonitor monitor) throws CoreException {
return target.openInputStream(options, monitor);
}
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
return target.openOutputStream(options, monitor);
}
public void putInfo(IFileInfo info, int options, IProgressMonitor monitor) throws CoreException {
target.putInfo(info, options, monitor);
}
public File toLocalFile(int options, IProgressMonitor monitor) throws CoreException {
return target.toLocalFile(options, monitor);
}
public URI toURI() {
// TODO
// need base URI from file system
// then add in the child path as the query
return null;
}
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (adapter == IFileStore.class || adapter == FFSFileStore.class)
return this;
return null;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof FFSFileStore)
return target.equals(((FFSFileStore)obj).target);
else
return target.equals(obj);
}
}

View file

@ -14,6 +14,8 @@ package org.eclipse.cdt.internal.core.ffs;
import java.io.File;
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.core.filesystem.EFS;
@ -23,24 +25,54 @@ import org.eclipse.core.filesystem.provider.FileSystem;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
/**
* @author Doug Schaefer
*
* This is the virtual file system. It maps URIs to files in underlying file systems.
* In doing so, it allows the hierarchical structure of URIs to be different.
* In particular, you can add files from one location to another and excludes files
* and directories from the tree.
* This is the flexible file system. It allows you to add and exclude
* entries from from a given directory.
*
* The URI's for this system are as follows:
*
* ecproj:///<ecproj file location>?<logical path>#<ecproj file schema>
*
* For example:
*
* ecproj:///c:/Eclipse/workspace/s?.project
*
*/
public class FFSFileSystem extends FileSystem {
public FFSFileSystem() {
private Map<URI, FFSEcprojFile> ecprojFiles = new HashMap<URI, FFSEcprojFile>();
private synchronized FFSEcprojFile getEcprojFile(FFSFileSystem fileSystem, URI uri) throws CoreException {
uri.normalize();
FFSEcprojFile ecprojFile = ecprojFiles.get(uri);
if (ecprojFile == null) {
ecprojFile = new FFSEcprojFile(fileSystem, uri);
ecprojFiles.put(uri, ecprojFile);
}
return ecprojFile;
}
public IFileStore getStore(URI uri) {
try {
URI realURI = new URI(getScheme(), uri.getSchemeSpecificPart(), uri.getFragment());
return EFS.getStore(realURI);
String ecprojScheme = uri.getFragment();
if (ecprojScheme == null)
ecprojScheme = EFS.SCHEME_FILE;
URI ecprojURI = new URI(ecprojScheme, uri.getAuthority(), uri.getPath(), null, null);
FFSEcprojFile ecprojFile = getEcprojFile(this, ecprojURI);
IFileStore root = ecprojFile.getRoot();
String pathStr = uri.getQuery();
if (pathStr == null)
return root;
IPath path = new Path(pathStr);
if (path.segmentCount() == 0)
return root;
return root.getChild(path);
} catch (URISyntaxException e) {
CCorePlugin.log(e);
} catch (CoreException e) {

View file

@ -2405,7 +2405,7 @@
<filesystemContributor
class="org.eclipse.cdt.internal.ui.ffs.FFSFileSystemContributor"
label="Flexible File System"
scheme="ffs">
scheme="ecproj">
</filesystemContributor>
</extension>

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.ffs;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
@ -21,12 +22,22 @@ import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
import org.eclipse.cdt.internal.core.ffs.FFSFileSystem;
/**
* @author Doug Schaefer
*
*/
public class FFSFileSystemContributor extends FileSystemContributor {
public URI getURI(String string) {
try {
return new URI(string);
} catch (URISyntaxException e) {
return super.getURI(string);
}
}
public URI browseFileSystem(String initialPath, Shell shell) {
DirectoryDialog dialog = new DirectoryDialog(shell);
dialog.setMessage("Select Project Location");
@ -42,7 +53,12 @@ public class FFSFileSystemContributor extends FileSystemContributor {
if (selectedDirectory == null) {
return null;
}
return new File(selectedDirectory).toURI();
URI rootURI = new File(selectedDirectory).toURI();
try {
return new URI("ecproj", rootURI.getAuthority(), rootURI.getPath(), null, rootURI.getScheme());
} catch (URISyntaxException e) {
return rootURI;
}
}
}