From 61bb9b156d1c6abfabe85c95c5dc43d6806d1e0e Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Sun, 23 Feb 2003 19:23:13 +0000 Subject: [PATCH] Remove IResource/IFile/IContainer adapters. BinaryContainerAdapter BinaryFileAdapter Container --- .../cdt/internal/core/model/Container.java | 99 ------ .../model/parser/BinaryContainerAdapter.java | 282 ------------------ .../core/model/parser/BinaryFileAdapter.java | 241 --------------- 3 files changed, 622 deletions(-) delete mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Container.java delete mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java delete mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Container.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Container.java deleted file mode 100644 index 5a5bd2d22ef..00000000000 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Container.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.eclipse.cdt.internal.core.model; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; - -public abstract class Container extends Resource implements IContainer { - - /** - * @see IContainer#findMember(String) - */ - public IResource findMember(String name) { - return findMember(name, false); - } - - /** - * @see IContainer#findMember(String, boolean) - */ - public IResource findMember(String name, boolean phantom) { - return findMember(new Path(name), phantom); - } - - /** - * @see IContainer#findMember(IPath) - */ - public IResource findMember(IPath path) { - return findMember(path, false); - } - - /** - * @see IContainer#findMember(IPath) - */ - public IResource findMember(IPath path, boolean phantom) { - path = getFullPath().append(path); - try { - IResource[] resources = members(phantom); - for (int i = 0; i < resources.length; i++) { - if (resources[i].getFullPath().equals(path)) { - return resources[i]; - } - } - } catch (CoreException e) { - } - return null; - } - - /** - * @see IContainer#getFile(String) - */ - public IFile getFile(String name) { - return getFile(new Path(name)); - } - - /** - * @see IContainer#getFolder(String) - */ - public IFolder getFolder(String name) { - return getFolder(new Path(name)); - } - - /** - * @see IContainer#members - */ - public IResource[] members() throws CoreException { - return members(IResource.NONE); - } - - /** - * @see IContainer#members(boolean) - */ - public IResource[] members(boolean phantom) throws CoreException { - return members(phantom ? INCLUDE_PHANTOMS : IResource.NONE); - } - - /* - * @see IContainer#members(int) - */ - public abstract IResource[] members(int memberFlags) throws CoreException; - - /** - * @see IContainer#exits(IPath) - */ - public abstract boolean exists(IPath path); - - /** - * @see IContainer#getFile(IPath) - */ - public abstract IFile getFile(IPath path); - - /** - * @see IContainer#getFolder(IPath) - */ - public abstract IFolder getFolder(IPath path); - -} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java deleted file mode 100644 index a322d9f32f6..00000000000 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryContainerAdapter.java +++ /dev/null @@ -1,282 +0,0 @@ -package org.eclipse.cdt.internal.core.model.parser; - -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - -import java.util.ArrayList; - -import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive; -import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; -import org.eclipse.cdt.internal.core.model.Container; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.QualifiedName; - -/** - */ -public class BinaryContainerAdapter extends Container implements IFolder { - - IBinaryArchive archive; - long timestamp; - ArrayList children; - ArrayList phantomResources; - - public BinaryContainerAdapter (IBinaryArchive ar) { - archive = ar; - phantomResources = new ArrayList(0); - children = new ArrayList(5); - } - - /** - * @see org.eclipse.core.resources.IResource#refreshLocal(int, IProgressMonitor) - */ - public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException { - IFile file = archive.getFile(); - if (file != null) { - file.refreshLocal(depth, monitor); - } - } - - /** - * @see org.eclipse.core.resources.IResource#getFullPath() - */ - public IPath getFullPath() { - IFile file = archive.getFile(); - if (file != null) { - return file.getFullPath(); - } - return new Path(""); - } - - /** - * @see org.eclipse.core.resources.IResource#getParent() - */ - public IContainer getParent() { - IFile file = archive.getFile(); - if (file != null) { - return file.getParent(); - } - return null; - } - - /** - * @see org.eclipse.core.resources.IResource#getType() - */ - public int getType() { - return IResource.FOLDER; - } - - /** - * @see org.eclipse.core.resources.IResource#getModificationStamp() - */ - public long getModificationStamp() { - IFile file = archive.getFile(); - if (file != null) { - return file.getModificationStamp(); - } - return 0; - } - - /** - * @see org.eclipse.core.resources.IFolder#delete(boolean, boolean, IProgressMonitor) - */ - public void delete(boolean force, boolean keepHistory, - IProgressMonitor monitor) throws CoreException { - delete((keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IResource#delete(int, IProgressMonitor) - */ - public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException { - IFile file = archive.getFile(); - if (file != null) { - file.delete(updateFlags, monitor); - } - } - - /** - * @see org.eclipse.core.resources.IResource#touch(IProgressMonitor) - */ - public void touch(IProgressMonitor monitor) throws CoreException { - IFile file = archive.getFile(); - if (file != null) { - file.touch(monitor); - } - } - - /** - * @see org.eclipse.core.resources.IFolder#create(boolean, boolean, IProgressMonitor) - */ - public void create(boolean force, boolean local, IProgressMonitor monitor) - throws CoreException { - create((force ? FORCE : IResource.NONE), local, monitor); - } - - /** - * @see org.eclipse.core.resources.IFolder#create(int, boolean, IProgressMonitor) - */ - public void create(int updateFlags, boolean local, - IProgressMonitor monitor) throws CoreException { - // FIXME: Not implemented. - } - - /** - * @see org.eclipse.core.resources.IFolder#getFile(String) - */ - public IFile getFile(IPath path) { - IFile f = (IFile)findMember(path); - if (f == null) { - // Pass it to parent to create a fake/phantom if the object - // is not in the archive. - IContainer container = getParent(); - if (container != null) { - f = container.getFile(path); - // Add it to the list of phantoms - if (! phantomResources.contains(f)) { - phantomResources.add(f); - phantomResources.trimToSize(); - } - } - } - return f; - } - - /** - * @see org.eclipse.core.resources.IFolder#move(IPath, boolean, boolean, IProgressMonitor) - */ - public void move(IPath destination, boolean force, boolean keepHistory, - IProgressMonitor monitor) throws CoreException { - move(destination, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IContainer#exists(IPath) - */ - public boolean exists(IPath path) { - // Check if it is the archive. - if (getFullPath().equals(path)) { - IFile file = archive.getFile(); - if (file != null) { - return file.exists(); - } - return false; - } - return findMember(path) != null; - } - - /** - * @see org.eclipse.core.resources.IContainer#getFolder(IPath) - */ - public IFolder getFolder(IPath path) { - // Only Files in the archive pass this to the parent - // to create a phatom resource - IFolder f = null; - IContainer container = getParent(); - if (container != null) { - f = container.getFolder(path); - if (!phantomResources.contains(f)) { - phantomResources.add(f); - phantomResources.trimToSize(); - } - } - return f; - } - - /** - * @see org.eclipse.core.resources.IContainer#members(int) - */ - public IResource[] members(int memberFlags) throws CoreException { - final boolean includePhantoms = (memberFlags & IContainer.INCLUDE_PHANTOMS) != 0; - final boolean includeTeamPrivateMember = - (memberFlags & IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS) != 0; - - ArrayList aList = new ArrayList(); - - if (hasChanged()) { - children.clear(); - IBinaryObject[] objects = archive.getObjects(); - for (int i = 0; i < objects.length; i++) { - children.add(new BinaryFileAdapter(this, objects[i])); - } - } - - for (int i = 0; i < children.size(); i++) { - IResource child = (IResource)children.get(i); - if (includeTeamPrivateMember && child.isTeamPrivateMember() || !child.isTeamPrivateMember()) { - aList.add(child); - } - } - - if (includePhantoms) { - aList.addAll(phantomResources); - } - return (IResource[])aList.toArray(new IResource[0]); - } - - /** - * @see org.eclipse.core.resources.IContainer#findDeletedMembersWithHistory(int, IProgressMonitor) - */ - public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor) - throws CoreException { - return new IFile[0]; - } - - /** - * @see org.eclipse.core.resources.IResource#getPersistentProperty(QualifiedName) - */ - public String getPersistentProperty(QualifiedName key) throws CoreException { - IFile file = archive.getFile(); - if (file != null) { - return file.getPersistentProperty(key); - } - return null; - } - - /** - * @see org.eclipse.core.resources.IResource#setPersistentProperty(QualifiedName, String) - */ - public void setPersistentProperty(QualifiedName key, String value) throws CoreException { - IFile file = archive.getFile(); - if (file != null) { - file.setPersistentProperty(key, value); - } - } - - /** - * @see org.eclipse.core.resources.IResource#exists() - */ - public boolean exists() { - IFile file = archive.getFile(); - if (file != null) { - return file.exists(); - } - return false; - } - - boolean hasChanged() { - boolean changed; - long modif = getModificationStamp(); - changed = modif != timestamp; - timestamp = modif; - return changed; - } - /** - * @see org.eclipse.core.resources.IFolder#createLink(org.eclipse.core.runtime.IPath, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void createLink( - IPath localLocation, - int updateFlags, - IProgressMonitor monitor) - throws CoreException { - } - -} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java deleted file mode 100644 index af410fbd8ff..00000000000 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/parser/BinaryFileAdapter.java +++ /dev/null @@ -1,241 +0,0 @@ -package org.eclipse.cdt.internal.core.model.parser; - -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - -import java.io.InputStream; - -import org.eclipse.cdt.core.IBinaryParser.IBinaryObject; -import org.eclipse.cdt.internal.core.model.Resource; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFileState; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.QualifiedName; - -/** - */ -public class BinaryFileAdapter extends Resource implements IFile { - - IBinaryObject object; - IContainer parent; - - public BinaryFileAdapter(IContainer p, IBinaryObject o) { - object = o; - parent = p; - } - - /** - * @see org.eclipse.core.resources.IFile#appendContents(InputStream, boolean, boolean, IProgressMonitor) - */ - public void appendContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { - appendContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IFile#appendContents(InputStream, int, IProgressMonitor) - */ - public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) - throws CoreException { - // FIXME: Not implemented. - } - - /** - * @see org.eclipse.core.resources.IFile#create(InputStream, boolean, IProgressMonitor) - */ - public void create(InputStream source, boolean force, - IProgressMonitor monitor) throws CoreException { - create(source, (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IFile#create(InputStream, int, IProgressMonitor) - */ - public void create(InputStream source, int updateFlags, - IProgressMonitor monitor) throws CoreException { - // FIXME: Not implemented. - } - - /** - * @see org.eclipse.core.resources.IStorage#getContents() - */ - public InputStream getContents() throws CoreException { - return getContents(false); - } - - /** - * @see org.eclipse.core.resources.IFile#getContents(boolean) - */ - public InputStream getContents(boolean force) throws CoreException { - return object.getContents(); - } - - /** - * @see org.eclipse.core.resources.IFile#getEncoding() - */ - public int getEncoding() throws CoreException { - return ENCODING_UNKNOWN; - } - - /** - * @see org.eclipse.core.resources.IFile#getHistory(IProgressMonitor) - */ - public IFileState[] getHistory(IProgressMonitor monitor) - throws CoreException { - return new IFileState[0]; - } - - /** - * @see org.eclipse.core.resources.IFile#move(IPath, boolean, boolean, IProgressMonitor) - */ - public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) - throws CoreException { - move(destination, (keepHistory ? KEEP_HISTORY : IResource.NONE) - | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IFile#setContents(InputStream, boolean, boolean, IProgressMonitor) - */ - public void setContents(InputStream source, boolean force, boolean keepHistory, - IProgressMonitor monitor) throws CoreException { - setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) - | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IFile#setContents(IFileState, boolean, boolean, IProgressMonitor) - */ - public void setContents(IFileState source, boolean force, boolean keepHistory, - IProgressMonitor monitor) throws CoreException { - setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) - | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IFile#setContents(InputStream, int, IProgressMonitor) - */ - public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) - throws CoreException { - // FIXME: Not implemented. - } - - /** - * @see org.eclipse.core.resources.IFile#setContents(IFileState, int, IProgressMonitor) - */ - public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) - throws CoreException { - // FIXME: Not implemented. - } - - /** - * @see org.eclipse.core.resources.IFile#delete(boolean, boolean, IProgressMonitor) - */ - public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) - throws CoreException { - delete((keepHistory ? KEEP_HISTORY : IResource.NONE) - | (force ? FORCE : IResource.NONE), monitor); - } - - /** - * @see org.eclipse.core.resources.IResource#delete(int, IProgressMonitor) - */ - public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException { - // FIXME: Not implemented. - } - - /** - * @see org.eclipse.core.resources.IResource#getFullPath() - */ - public IPath getFullPath() { - IFile file = object.getFile(); - if (file != null) { - return file.getFullPath().append(object.getName()); - } - return new Path(object.getName()); - } - - /** - * @see org.eclipse.core.resources.IResource#getModificationStamp() - */ - public long getModificationStamp() { - IFile file = object.getFile(); - if (file != null) { - return file.getModificationStamp(); - } - return 0; - } - - /** - * @see org.eclipse.core.resources.IResource#getParent() - */ - public IContainer getParent() { - return parent; - } - - /** - * @see org.eclipse.core.resources.IResource#getType() - */ - public int getType() { - return IResource.FILE; - } - - /** - * @see org.eclipse.core.resources.IResource#refreshLocal(int, IProgressMonitor) - */ - public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException { - IFile file = object.getFile(); - if (file != null) { - file.refreshLocal(depth, monitor); - } - } - - /** - * @see org.eclipse.core.resources.IResource#touch(IProgressMonitor) - */ - public void touch(IProgressMonitor monitor) throws CoreException { - IFile file = object.getFile(); - if (file != null) { - file.touch(monitor); - } - } - - /** - * @see org.eclipse.core.resources.IResource#getPersistentProperty(QualifiedName) - */ - public String getPersistentProperty(QualifiedName key) - throws CoreException { - return null; - } - - /** - * @see org.eclipse.core.resources.IResource#setPersistentProperty(QualifiedName, String) - */ - public void setPersistentProperty(QualifiedName key, String value) - throws CoreException { - } - - /** - * @see org.eclipse.core.resources.IResource#exists() - */ - public boolean exists() { - return parent.exists(new Path(getName())); - } - - /** - * @see org.eclipse.core.resources.IFile#createLink(org.eclipse.core.runtime.IPath, int, org.eclipse.core.runtime.IProgressMonitor) - */ - public void createLink( - IPath localLocation, - int updateFlags, - IProgressMonitor monitor) - throws CoreException { - } - -}