Added stubs for IFile and IMarker.
diff --git a/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/FileStub.java b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/FileStub.java
index b962620..22491f4 100644
--- a/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/FileStub.java
+++ b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/FileStub.java
@@ -6,13 +6,12 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-
package com.google.eclipse.protobuf.junit.stubs;
import java.io.InputStream;
import java.io.Reader;
import java.net.URI;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -23,394 +22,490 @@
*/
public abstract class FileStub implements IFile {
- /** {@inheritDoc} */
- public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {}
+ private final Map<String, List<IMarker>> markersByType = new HashMap<String, List<IMarker>>();
/** {@inheritDoc} */
- public void accept(IResourceVisitor visitor) throws CoreException {}
-
- /** {@inheritDoc} */
- public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException {}
-
- /** {@inheritDoc} */
- public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {}
-
- /** {@inheritDoc} */
- public void clearHistory(IProgressMonitor monitor) throws CoreException {}
-
- /** {@inheritDoc} */
- public boolean contains(ISchedulingRule rule) {
- return false;
+ public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {}
+ public void accept(IResourceVisitor visitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor) throws CoreException {}
+ public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void clearHistory(IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public boolean contains(ISchedulingRule rule) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public IMarker createMarker(String type) throws CoreException {
- return null;
+ MarkerStub marker = new MarkerStub(type);
+ List<IMarker> markers = markersByType.get(type);
+ if (markers == null) {
+ markers = new ArrayList<IMarker>();
+ markersByType.put(type, markers);
+ }
+ markers.add(marker);
+ return marker;
}
/** {@inheritDoc} */
public IResourceProxy createProxy() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- public void delete(boolean force, IProgressMonitor monitor) throws CoreException {}
+ public void delete(boolean force, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {}
+ public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
+ List<IMarker> markers = markersByType.get(type);
+ if (markers != null) markers.clear();
+ }
/** {@inheritDoc} */
public boolean exists() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IMarker findMarker(long id) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {
- return null;
+ List<IMarker> markers = markersByType.get(type);
+ if (markers == null) return new IMarker[0];
+ return markers.toArray(new IMarker[markers.size()]);
}
/** {@inheritDoc} */
public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException {
- return 0;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
@SuppressWarnings("rawtypes") public Object getAdapter(Class adapter) {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public String getFileExtension() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public long getLocalTimeStamp() {
- return 0;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IPath getLocation() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public URI getLocationURI() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IMarker getMarker(long id) {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public long getModificationStamp() {
- return 0;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IPathVariableManager getPathVariableManager() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IContainer getParent() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public Map<QualifiedName, String> getPersistentProperties() throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public String getPersistentProperty(QualifiedName key) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IProject getProject() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IPath getProjectRelativePath() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IPath getRawLocation() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public URI getRawLocationURI() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public ResourceAttributes getResourceAttributes() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public Map<QualifiedName, Object> getSessionProperties() throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public Object getSessionProperty(QualifiedName key) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public int getType() {
- return 0;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IWorkspace getWorkspace() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isAccessible() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isConflicting(ISchedulingRule rule) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isDerived() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isDerived(int options) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isHidden() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isHidden(int options) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isLinked() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isVirtual() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isLinked(int options) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isLocal(int depth) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isPhantom() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isSynchronized(int depth) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isTeamPrivateMember() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isTeamPrivateMember(int options) {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {}
+ public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor)
- throws CoreException {}
-
- /** {@inheritDoc} */
- public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {}
-
- /** {@inheritDoc} */
- public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {}
-
- /** {@inheritDoc} */
- public void revertModificationStamp(long value) throws CoreException {}
-
- /** {@inheritDoc} */
- public void setDerived(boolean isDerived) throws CoreException {}
-
- /** {@inheritDoc} */
- public void setDerived(boolean isDerived, IProgressMonitor monitor) throws CoreException {}
-
- /** {@inheritDoc} */
- public void setHidden(boolean isHidden) throws CoreException {}
-
- /** {@inheritDoc} */
- public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {}
-
- /** {@inheritDoc} */
- public long setLocalTimeStamp(long value) throws CoreException {
- return 0;
+ throws CoreException {
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- public void setPersistentProperty(QualifiedName key, String value) throws CoreException {}
+ public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setReadOnly(boolean readOnly) {}
+ public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {}
+ public void revertModificationStamp(long value) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setSessionProperty(QualifiedName key, Object value) throws CoreException {}
+ public void setDerived(boolean isDerived) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {}
+ public void setDerived(boolean isDerived, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void touch(IProgressMonitor monitor) throws CoreException {}
+ public void setHidden(boolean isHidden) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public long setLocalTimeStamp(long value) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void setPersistentProperty(QualifiedName key, String value) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void setReadOnly(boolean readOnly) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void setSessionProperty(QualifiedName key, Object value) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void touch(IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public void appendContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor)
- throws CoreException {}
+ throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException {}
+ public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void createLink(URI location, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void createLink(URI location, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {}
+ public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public String getCharset() throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public String getCharset(boolean checkImplicit) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public String getCharsetFor(Reader reader) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public InputStream getContents() throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public InputStream getContents(boolean force) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public int getEncoding() throws CoreException {
- return 0;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IPath getFullPath() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public String getName() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public boolean isReadOnly() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor)
- throws CoreException {}
+ throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setCharset(String newCharset) throws CoreException {}
+ public void setCharset(String newCharset) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {}
+ public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public void setContents(InputStream source, boolean force, boolean keepHistory, IProgressMonitor monitor)
- throws CoreException {}
+ throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor)
- throws CoreException {}
+ throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) throws CoreException {}
+ public void setContents(IFileState source, int updateFlags, IProgressMonitor monitor) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
}
diff --git a/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/MarkerStub.java b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/MarkerStub.java
index 848be9a..0578871 100644
--- a/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/MarkerStub.java
+++ b/com.google.eclipse.protobuf.junit/src/com/google/eclipse/protobuf/junit/stubs/MarkerStub.java
@@ -6,10 +6,11 @@
*
* http://www.eclipse.org/legal/epl-v10.html
*/
-
package com.google.eclipse.protobuf.junit.stubs;
-import java.util.Map;
+import static java.util.Collections.unmodifiableMap;
+
+import java.util.*;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
@@ -20,86 +21,115 @@
*/
public class MarkerStub implements IMarker {
- /** {@inheritDoc} */
- @SuppressWarnings("rawtypes") public Object getAdapter(Class adapter) {
- return null;
+ private final Map<String, Object> attributes = new HashMap<String, Object>();
+ private final String type;
+ private final long creationTime;
+
+ public MarkerStub(String type) {
+ this.type = type;
+ creationTime = System.currentTimeMillis();
}
/** {@inheritDoc} */
- public void delete() throws CoreException {}
+ @SuppressWarnings("rawtypes") public Object getAdapter(Class adapter) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ public void delete() throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
public boolean exists() {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public Object getAttribute(String attributeName) throws CoreException {
- return null;
+ return attributes.get(attributeName);
}
/** {@inheritDoc} */
public int getAttribute(String attributeName, int defaultValue) {
- return 0;
+ Object attribute = attributes.get(attributeName);
+ if (attribute instanceof Integer) return (Integer) attribute;
+ return defaultValue;
}
/** {@inheritDoc} */
public String getAttribute(String attributeName, String defaultValue) {
- return null;
+ Object attribute = attributes.get(attributeName);
+ if (attribute instanceof String) return (String) attribute;
+ return defaultValue;
}
/** {@inheritDoc} */
public boolean getAttribute(String attributeName, boolean defaultValue) {
- return false;
+ Object attribute = attributes.get(attributeName);
+ if (attribute instanceof Boolean) return (Boolean) attribute;
+ return defaultValue;
}
/** {@inheritDoc} */
public Map<String, Object> getAttributes() throws CoreException {
- return null;
+ return unmodifiableMap(attributes);
}
/** {@inheritDoc} */
public Object[] getAttributes(String[] attributeNames) throws CoreException {
- return null;
+ List<Object> values = new ArrayList<Object>();
+ for (String name : attributeNames) values.add(attributes.get(name));
+ return values.toArray();
}
/** {@inheritDoc} */
public long getCreationTime() throws CoreException {
- return 0;
+ return creationTime;
}
/** {@inheritDoc} */
public long getId() {
- return 0;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public IResource getResource() {
- return null;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
public String getType() throws CoreException {
- return null;
+ return type;
}
/** {@inheritDoc} */
public boolean isSubtypeOf(String superType) throws CoreException {
- return false;
+ throw new UnsupportedOperationException();
}
/** {@inheritDoc} */
- public void setAttribute(String attributeName, int value) throws CoreException {}
+ public void setAttribute(String attributeName, int value) throws CoreException {
+ attributes.put(attributeName, value);
+ }
/** {@inheritDoc} */
- public void setAttribute(String attributeName, Object value) throws CoreException {}
+ public void setAttribute(String attributeName, Object value) throws CoreException {
+ attributes.put(attributeName, value);
+ }
/** {@inheritDoc} */
- public void setAttribute(String attributeName, boolean value) throws CoreException {}
+ public void setAttribute(String attributeName, boolean value) throws CoreException {
+ attributes.put(attributeName, value);
+ }
/** {@inheritDoc} */
- public void setAttributes(String[] attributeNames, Object[] values) throws CoreException {}
+ public void setAttributes(String[] attributeNames, Object[] values) throws CoreException {
+ throw new UnsupportedOperationException();
+ }
/** {@inheritDoc} */
- public void setAttributes(Map<String, ? extends Object> attributes) throws CoreException {}
+ public void setAttributes(Map<String, ? extends Object> attributes) throws CoreException {
+ this.attributes.putAll(attributes);
+ }
}