Update of /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25606/src/org/rubypeople/eclipse/shams/resources Modified Files: ShamFile.java ShamFolder.java ShamResource.java ShamProject.java Added Files: ShamContainer.java Log Message: 1) refactored RubyBuilder again, this time with better unit tests. 2) refactored Location (and SymbolIndex) to be IFile based, rather than IPath based. 3) general improvement on maintainence of the SymbolIndex. Index: ShamFolder.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFolder.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ShamFolder.java 27 Jun 2004 11:43:13 -0000 1.5 --- ShamFolder.java 12 Nov 2005 19:16:08 -0000 1.6 *************** *** 1,20 **** package org.rubypeople.eclipse.shams.resources; ! import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; - import org.eclipse.core.resources.IMarker; - import org.eclipse.core.resources.IProject; - import org.eclipse.core.resources.IProjectDescription; - import org.eclipse.core.resources.IResource; - import org.eclipse.core.resources.IResourceVisitor; - import org.eclipse.core.resources.IWorkspace; 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 ShamFolder extends ShamResource implements IFolder { public ShamFolder(String aPathString) { --- 1,13 ---- package org.rubypeople.eclipse.shams.resources; ! import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; ! public class ShamFolder extends ShamContainer implements IFolder { public ShamFolder(String aPathString) { *************** *** 27,196 **** public void setDefaultCharset(String charset, IProgressMonitor monitor) ! throws CoreException { ! } ! ! public void create(boolean force, boolean local, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void create(int updateFlags, boolean local, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IFile getFile(String name) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IFolder getFolder(String name) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public boolean exists(IPath path) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource findMember(String name) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource findMember(String name, boolean includePhantoms) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource findMember(IPath path) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource findMember(IPath path, boolean includePhantoms) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IFile getFile(IPath path) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IFolder getFolder(IPath path) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource[] members() throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource[] members(boolean includePhantoms) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IResource[] members(int memberFlags) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public Object getAdapter(Class adapter) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void accept(IResourceVisitor visitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void clearHistory(IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IMarker createMarker(String type) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void delete(boolean force, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public boolean exists() { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IMarker findMarker(long id) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IPath getLocation() { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IMarker getMarker(long id) { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public long getModificationStamp() { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IContainer getParent() { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public String getPersistentProperty(QualifiedName key) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IProject getProject() { ! throw new RuntimeException("Need to implement on sham."); ! } ! ! public IPath getProjectRelativePath() { ! throw new RuntimeException("Need to implement on sham."); } - public Object getSessionProperty(QualifiedName key) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } public int getType() { --- 20,26 ---- public void setDefaultCharset(String charset, IProgressMonitor monitor) ! throws CoreException { } public int getType() { *************** *** 198,315 **** } - public IWorkspace getWorkspace() { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isAccessible() { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isLocal(int depth) { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isPhantom() { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isReadOnly() { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isSynchronized(int depth) { - throw new RuntimeException("Need to implement on sham."); - } - - public void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void setPersistentProperty(QualifiedName key, String value) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void setReadOnly(boolean readOnly) { - throw new RuntimeException("Need to implement on sham."); - } - - public void setSessionProperty(QualifiedName key, Object value) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public void touch(IProgressMonitor monitor) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isDerived() { - throw new RuntimeException("Need to implement on sham."); - } - - public void setDerived(boolean isDerived) throws CoreException { - throw new RuntimeException("Need to implement on sham."); - } - - public boolean isTeamPrivateMember() { - throw new RuntimeException("Need to implement on sham."); - } ! public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); ! } ! public IPath getRawLocation() { ! throw new RuntimeException("Need to implement on sham."); ! } ! public boolean isLinked() { ! throw new RuntimeException("Need to implement on sham."); ! } ! /* (non-Javadoc) ! * @see org.eclipse.core.resources.IContainer#getDefaultCharset() ! */ ! public String getDefaultCharset() throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } ! /* (non-Javadoc) ! * @see org.eclipse.core.resources.IContainer#setDefaultCharset(java.lang.String) ! */ ! public void setDefaultCharset(String charset) throws CoreException { ! // TODO Auto-generated method stub ! ! } ! /* (non-Javadoc) ! * @see org.eclipse.core.resources.IContainer#getDefaultCharset(boolean) ! */ ! public String getDefaultCharset(boolean checkImplicit) throws CoreException { ! // TODO Auto-generated method stub ! return null; ! } } --- 28,58 ---- } ! public void create(boolean force, boolean local, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Sham needs to implement"); ! } ! public void create(int updateFlags, boolean local, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Sham needs to implement"); ! } ! public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Sham needs to implement"); ! } ! public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Sham needs to implement"); ! } ! public IFile getFile(String name) { ! throw new RuntimeException("Sham needs to implement"); ! } ! public IFolder getFolder(String name) { ! throw new RuntimeException("Sham needs to implement"); ! } ! public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException { ! throw new RuntimeException("Sham needs to implement"); ! } } Index: ShamFile.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFile.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ShamFile.java 1 Oct 2005 23:00:50 -0000 1.13 --- ShamFile.java 12 Nov 2005 19:16:08 -0000 1.14 *************** *** 28,34 **** --- 28,36 ---- public class ShamFile extends ShamResource implements IFile { + public static final String WORKSPACE_ROOT = "/test/workspaceRoot"; protected String contents = ""; protected boolean readContentFromFile; private InputStream inputStream; + private IProject project; public void setCharset(String newCharset, IProgressMonitor monitor) *************** *** 55,58 **** --- 57,61 ---- super(aPath); this.readContentFromFile = readContentFromFile; + project = new ShamProject("not specified"); } *************** *** 178,182 **** public IPath getLocation() { ! throw new RuntimeException("Unimplemented method in sham"); } --- 181,185 ---- public IPath getLocation() { ! return new Path(WORKSPACE_ROOT).append(getFullPath()); } *************** *** 198,202 **** public IProject getProject() { ! return new ShamProject("not specified"); } --- 201,205 ---- public IProject getProject() { ! return project; } *************** *** 340,343 **** --- 343,350 ---- } + public void setProject(IProject project) { + this.project = project; + } + private class MonitoredInputStream extends InputStream { *************** *** 357,359 **** --- 364,367 ---- } } + } --- NEW FILE: ShamContainer.java --- package org.rubypeople.eclipse.shams.resources; import java.util.ArrayList; import java.util.Iterator; import java.util.List; 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.resources.IResourceProxyVisitor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; public class ShamContainer extends ShamResource implements IContainer { protected List childResources = new ArrayList(); public ShamContainer(IPath path) { super(path); } public void accept(IResourceProxyVisitor visitor, int flags) throws CoreException { for (Iterator iter = childResources.iterator(); iter.hasNext();) { IResource resource = (IResource) iter.next(); visitor.visit(new ShamResourceProxy(resource)); if (resource instanceof IContainer) { IContainer container = (IContainer) resource; container.accept(visitor, flags); } } } public boolean exists(IPath path) { throw new RuntimeException("Sham must implement"); } public IResource findMember(String name) { throw new RuntimeException("Sham must implement"); } public IResource findMember(String name, boolean includePhantoms) { throw new RuntimeException("Sham must implement"); } public IResource findMember(IPath path) { throw new RuntimeException("Sham must implement"); } public IResource findMember(IPath path, boolean includePhantoms) { throw new RuntimeException("Sham must implement"); } public String getDefaultCharset() throws CoreException { throw new RuntimeException("Sham must implement"); } public String getDefaultCharset(boolean checkImplicit) throws CoreException { throw new RuntimeException("Sham must implement"); } public IFile getFile(IPath path) { throw new RuntimeException("Sham must implement"); } public IFolder getFolder(IPath path) { throw new RuntimeException("Sham must implement"); } public IResource[] members() throws CoreException { return (IResource[]) childResources.toArray(new IResource[0]); } public IResource[] members(boolean includePhantoms) throws CoreException { throw new RuntimeException("Sham must implement"); } public IResource[] members(int memberFlags) throws CoreException { throw new RuntimeException("Sham must implement"); } public IFile[] findDeletedMembersWithHistory(int depth, IProgressMonitor monitor) throws CoreException { throw new RuntimeException("Sham must implement"); } public void setDefaultCharset(String charset) throws CoreException { throw new RuntimeException("Sham must implement"); } public void setDefaultCharset(String charset, IProgressMonitor monitor) throws CoreException { throw new RuntimeException("Sham must implement"); } public void addResource(IResource resource) { childResources.add(resource); } } Index: ShamProject.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamProject.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ShamProject.java 19 Oct 2005 00:33:17 -0000 1.12 --- ShamProject.java 12 Nov 2005 19:16:08 -0000 1.13 *************** *** 34,43 **** import org.eclipse.core.runtime.content.IContentTypeMatcher; ! public class ShamProject extends ShamResource implements IProject { protected String projectName; protected List natures = new ArrayList(); ! ! public ShamProject(String theProjectName) { ! this(new Path("path to " + theProjectName), theProjectName); } --- 34,42 ---- import org.eclipse.core.runtime.content.IContentTypeMatcher; ! public class ShamProject extends ShamContainer implements IProject, IContainer { protected String projectName; protected List natures = new ArrayList(); ! public ShamProject(String theProjectName) { ! this(new Path("/" + theProjectName), theProjectName); } *************** *** 50,54 **** } ! public void build(int kind, String builderName, Map args, IProgressMonitor monitor) throws CoreException {} public void build(int kind, IProgressMonitor monitor) throws CoreException {} --- 49,53 ---- } ! public void build(int kind, String builderName, Map args, IProgressMonitor monitor) throws CoreException {} public void build(int kind, IProgressMonitor monitor) throws CoreException {} *************** *** 139,143 **** public IResource[] members() throws CoreException { ! throw new RuntimeException("Unimplemented method in sham"); } --- 138,142 ---- public IResource[] members() throws CoreException { ! return (IResource[]) childResources.toArray(new IResource[0]); } Index: ShamResource.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamResource.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ShamResource.java 19 Oct 2005 00:33:17 -0000 1.9 --- ShamResource.java 12 Nov 2005 19:16:08 -0000 1.10 *************** *** 11,19 **** package org.rubypeople.eclipse.shams.resources; - import java.util.Collection; - import java.util.Iterator; - - import junit.framework.Assert; - import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IMarker; --- 11,14 ---- *************** *** 33,46 **** public class ShamResource implements IResource { protected IPath path; - private boolean acceptCalled; - private IResourceProxyVisitor proxyVisitorArg; - private int flagsArg; - private Collection resourcesToVisit; public ShamResource(IPath aPath) { - super(); path = aPath; } public void accept(IResourceVisitor visitor) throws CoreException { throw new RuntimeException("Need to implement on sham."); --- 28,44 ---- public class ShamResource implements IResource { protected IPath path; public ShamResource(IPath aPath) { path = aPath; } + public boolean equals(Object obj) { + if (obj instanceof ShamResource) { + ShamResource that = (ShamResource) obj; + return path.equals(that.path); + } + return false; + } + public void accept(IResourceVisitor visitor) throws CoreException { throw new RuntimeException("Need to implement on sham."); *************** *** 245,267 **** } - public void setResourcesToVisit(Collection resourcesToVisit) { - this.resourcesToVisit = resourcesToVisit; - } - - public void assertAcceptCalled(IResourceProxyVisitor expectedVisitor, int expectedFlags) { - Assert.assertTrue("expected call to accept", acceptCalled); - Assert.assertEquals("visitor", expectedVisitor, proxyVisitorArg); - Assert.assertEquals("flags", expectedFlags, flagsArg); - } - public void accept(IResourceProxyVisitor visitor, int flags) throws CoreException { ! proxyVisitorArg = visitor; ! flagsArg = flags; ! for (Iterator iter = resourcesToVisit.iterator(); iter.hasNext();) { ! IResource resource = (IResource) iter.next(); ! visitor.visit(new ShamResourceProxy(resource)); ! ! } ! acceptCalled = true; } --- 243,248 ---- } public void accept(IResourceProxyVisitor visitor, int flags) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); } *************** *** 283,297 **** public ResourceAttributes getResourceAttributes() { ! // TODO Auto-generated method stub ! return null; } public void revertModificationStamp(long value) throws CoreException { ! // TODO Auto-generated method stub ! } public void setResourceAttributes(ResourceAttributes attributes) throws CoreException { ! // TODO Auto-generated method stub } --- 264,276 ---- public ResourceAttributes getResourceAttributes() { ! throw new RuntimeException("Need to implement on sham."); } public void revertModificationStamp(long value) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); } public void setResourceAttributes(ResourceAttributes attributes) throws CoreException { ! throw new RuntimeException("Need to implement on sham."); } |