1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.mock; 18 19 import org.eclipse.core.resources.IProject; 20 import org.eclipse.core.resources.IResource; 21 import org.eclipse.core.runtime.IPath; 22 import org.eclipse.core.runtime.IProgressMonitor; 23 import org.eclipse.core.runtime.jobs.ISchedulingRule; 24 import org.eclipse.jdt.core.IBuffer; 25 import org.eclipse.jdt.core.IClasspathEntry; 26 import org.eclipse.jdt.core.IJavaElement; 27 import org.eclipse.jdt.core.IJavaModel; 28 import org.eclipse.jdt.core.IJavaProject; 29 import org.eclipse.jdt.core.IOpenable; 30 import org.eclipse.jdt.core.IPackageFragment; 31 import org.eclipse.jdt.core.IPackageFragmentRoot; 32 import org.eclipse.jdt.core.IRegion; 33 import org.eclipse.jdt.core.IType; 34 import org.eclipse.jdt.core.ITypeHierarchy; 35 import org.eclipse.jdt.core.JavaCore; 36 import org.eclipse.jdt.core.JavaModelException; 37 import org.eclipse.jdt.core.WorkingCopyOwner; 38 import org.eclipse.jdt.core.eval.IEvaluationContext; 39 40 import sun.reflect.generics.reflectiveObjects.NotImplementedException; 41 42 import java.util.Map; 43 44 public class JavaProjectMock implements IJavaProject { 45 46 private IProject mProject; 47 48 private IClasspathEntry[] mEntries; 49 private IPath mOutputLocation; 50 private String mCompilerCompliance = "1.4"; //$NON-NLS-1 51 private String mCompilerSource = "1.4"; //$NON-NLS-1 52 private String mCompilerTarget = "1.4"; //$NON-NLS-1 53 JavaProjectMock(IClasspathEntry[] entries, IPath outputLocation)54 public JavaProjectMock(IClasspathEntry[] entries, IPath outputLocation) { 55 mEntries = entries; 56 mOutputLocation = outputLocation; 57 } 58 getProject()59 public IProject getProject() { 60 if (mProject == null) { 61 mProject = new ProjectMock(); 62 } 63 64 return mProject; 65 } 66 67 setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor)68 public void setRawClasspath(IClasspathEntry[] entries, IProgressMonitor monitor) 69 throws JavaModelException { 70 mEntries = entries; 71 } 72 setRawClasspath(IClasspathEntry[] entries, IPath outputLocation, IProgressMonitor monitor)73 public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation, 74 IProgressMonitor monitor) throws JavaModelException { 75 mEntries = entries; 76 mOutputLocation = outputLocation; 77 } 78 getRawClasspath()79 public IClasspathEntry[] getRawClasspath() throws JavaModelException { 80 return mEntries; 81 } 82 getOutputLocation()83 public IPath getOutputLocation() throws JavaModelException { 84 return mOutputLocation; 85 } 86 getOption(String optionName, boolean inheritJavaCoreOptions)87 public String getOption(String optionName, boolean inheritJavaCoreOptions) { 88 if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) { 89 return mCompilerCompliance; 90 } else if (optionName.equals(JavaCore.COMPILER_SOURCE)) { 91 return mCompilerSource; 92 } else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) { 93 return mCompilerTarget; 94 } 95 96 return null; 97 } 98 setOption(String optionName, String optionValue)99 public void setOption(String optionName, String optionValue) { 100 if (optionName.equals(JavaCore.COMPILER_COMPLIANCE)) { 101 mCompilerCompliance = optionValue; 102 } else if (optionName.equals(JavaCore.COMPILER_SOURCE)) { 103 mCompilerSource = optionValue; 104 } else if (optionName.equals(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM)) { 105 mCompilerTarget = optionValue; 106 } else { 107 throw new NotImplementedException(); 108 } 109 } 110 111 112 // -------- UNIMPLEMENTED METHODS ---------------- 113 decodeClasspathEntry(String encodedEntry)114 public IClasspathEntry decodeClasspathEntry(String encodedEntry) { 115 throw new NotImplementedException(); 116 } 117 encodeClasspathEntry(IClasspathEntry classpathEntry)118 public String encodeClasspathEntry(IClasspathEntry classpathEntry) { 119 throw new NotImplementedException(); 120 } 121 findElement(IPath path)122 public IJavaElement findElement(IPath path) throws JavaModelException { 123 throw new NotImplementedException(); 124 } 125 findElement(IPath path, WorkingCopyOwner owner)126 public IJavaElement findElement(IPath path, WorkingCopyOwner owner) throws JavaModelException { 127 throw new NotImplementedException(); 128 } 129 findPackageFragment(IPath path)130 public IPackageFragment findPackageFragment(IPath path) throws JavaModelException { 131 throw new NotImplementedException(); 132 } 133 findPackageFragmentRoot(IPath path)134 public IPackageFragmentRoot findPackageFragmentRoot(IPath path) throws JavaModelException { 135 throw new NotImplementedException(); 136 } 137 findPackageFragmentRoots(IClasspathEntry entry)138 public IPackageFragmentRoot[] findPackageFragmentRoots(IClasspathEntry entry) { 139 throw new NotImplementedException(); 140 } 141 findType(String fullyQualifiedName)142 public IType findType(String fullyQualifiedName) throws JavaModelException { 143 throw new NotImplementedException(); 144 } 145 findType(String fullyQualifiedName, IProgressMonitor progressMonitor)146 public IType findType(String fullyQualifiedName, IProgressMonitor progressMonitor) 147 throws JavaModelException { 148 throw new NotImplementedException(); 149 } 150 findType(String fullyQualifiedName, WorkingCopyOwner owner)151 public IType findType(String fullyQualifiedName, WorkingCopyOwner owner) 152 throws JavaModelException { 153 throw new NotImplementedException(); 154 } 155 findType(String packageName, String typeQualifiedName)156 public IType findType(String packageName, String typeQualifiedName) throws JavaModelException { 157 throw new NotImplementedException(); 158 } 159 findType(String fullyQualifiedName, WorkingCopyOwner owner, IProgressMonitor progressMonitor)160 public IType findType(String fullyQualifiedName, WorkingCopyOwner owner, 161 IProgressMonitor progressMonitor) throws JavaModelException { 162 throw new NotImplementedException(); 163 } 164 findType(String packageName, String typeQualifiedName, IProgressMonitor progressMonitor)165 public IType findType(String packageName, String typeQualifiedName, 166 IProgressMonitor progressMonitor) throws JavaModelException { 167 throw new NotImplementedException(); 168 } 169 findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner)170 public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner) 171 throws JavaModelException { 172 throw new NotImplementedException(); 173 } 174 findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner, IProgressMonitor progressMonitor)175 public IType findType(String packageName, String typeQualifiedName, WorkingCopyOwner owner, 176 IProgressMonitor progressMonitor) throws JavaModelException { 177 throw new NotImplementedException(); 178 } 179 getAllPackageFragmentRoots()180 public IPackageFragmentRoot[] getAllPackageFragmentRoots() throws JavaModelException { 181 throw new NotImplementedException(); 182 } 183 getNonJavaResources()184 public Object[] getNonJavaResources() throws JavaModelException { 185 throw new NotImplementedException(); 186 } 187 188 @SuppressWarnings("unchecked") getOptions(boolean inheritJavaCoreOptions)189 public Map getOptions(boolean inheritJavaCoreOptions) { 190 throw new NotImplementedException(); 191 } 192 getPackageFragmentRoot(String jarPath)193 public IPackageFragmentRoot getPackageFragmentRoot(String jarPath) { 194 throw new NotImplementedException(); 195 } 196 getPackageFragmentRoot(IResource resource)197 public IPackageFragmentRoot getPackageFragmentRoot(IResource resource) { 198 throw new NotImplementedException(); 199 } 200 getPackageFragmentRoots()201 public IPackageFragmentRoot[] getPackageFragmentRoots() throws JavaModelException { 202 throw new NotImplementedException(); 203 } 204 getPackageFragmentRoots(IClasspathEntry entry)205 public IPackageFragmentRoot[] getPackageFragmentRoots(IClasspathEntry entry) { 206 throw new NotImplementedException(); 207 } 208 getPackageFragments()209 public IPackageFragment[] getPackageFragments() throws JavaModelException { 210 throw new NotImplementedException(); 211 } 212 getRequiredProjectNames()213 public String[] getRequiredProjectNames() throws JavaModelException { 214 throw new NotImplementedException(); 215 } 216 getResolvedClasspath(boolean ignoreUnresolvedEntry)217 public IClasspathEntry[] getResolvedClasspath(boolean ignoreUnresolvedEntry) 218 throws JavaModelException { 219 throw new NotImplementedException(); 220 } 221 hasBuildState()222 public boolean hasBuildState() { 223 throw new NotImplementedException(); 224 } 225 hasClasspathCycle(IClasspathEntry[] entries)226 public boolean hasClasspathCycle(IClasspathEntry[] entries) { 227 throw new NotImplementedException(); 228 } 229 isOnClasspath(IJavaElement element)230 public boolean isOnClasspath(IJavaElement element) { 231 throw new NotImplementedException(); 232 } 233 isOnClasspath(IResource resource)234 public boolean isOnClasspath(IResource resource) { 235 throw new NotImplementedException(); 236 } 237 newEvaluationContext()238 public IEvaluationContext newEvaluationContext() { 239 throw new NotImplementedException(); 240 } 241 newTypeHierarchy(IRegion region, IProgressMonitor monitor)242 public ITypeHierarchy newTypeHierarchy(IRegion region, IProgressMonitor monitor) 243 throws JavaModelException { 244 throw new NotImplementedException(); 245 } 246 newTypeHierarchy(IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor)247 public ITypeHierarchy newTypeHierarchy(IRegion region, WorkingCopyOwner owner, 248 IProgressMonitor monitor) throws JavaModelException { 249 throw new NotImplementedException(); 250 } 251 newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor)252 public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, IProgressMonitor monitor) 253 throws JavaModelException { 254 throw new NotImplementedException(); 255 } 256 newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner, IProgressMonitor monitor)257 public ITypeHierarchy newTypeHierarchy(IType type, IRegion region, WorkingCopyOwner owner, 258 IProgressMonitor monitor) throws JavaModelException { 259 throw new NotImplementedException(); 260 } 261 readOutputLocation()262 public IPath readOutputLocation() { 263 throw new NotImplementedException(); 264 } 265 readRawClasspath()266 public IClasspathEntry[] readRawClasspath() { 267 throw new NotImplementedException(); 268 } 269 270 @SuppressWarnings("unchecked") setOptions(Map newOptions)271 public void setOptions(Map newOptions) { 272 throw new NotImplementedException(); 273 } 274 setOutputLocation(IPath path, IProgressMonitor monitor)275 public void setOutputLocation(IPath path, IProgressMonitor monitor) throws JavaModelException { 276 throw new NotImplementedException(); 277 } 278 setRawClasspath(IClasspathEntry[] entries, boolean canModifyResources, IProgressMonitor monitor)279 public void setRawClasspath(IClasspathEntry[] entries, boolean canModifyResources, 280 IProgressMonitor monitor) throws JavaModelException { 281 throw new NotImplementedException(); 282 } 283 setRawClasspath(IClasspathEntry[] entries, IPath outputLocation, boolean canModifyResources, IProgressMonitor monitor)284 public void setRawClasspath(IClasspathEntry[] entries, IPath outputLocation, 285 boolean canModifyResources, IProgressMonitor monitor) throws JavaModelException { 286 throw new NotImplementedException(); 287 } 288 getChildren()289 public IJavaElement[] getChildren() throws JavaModelException { 290 throw new NotImplementedException(); 291 } 292 hasChildren()293 public boolean hasChildren() throws JavaModelException { 294 throw new NotImplementedException(); 295 } 296 exists()297 public boolean exists() { 298 throw new NotImplementedException(); 299 } 300 getAncestor(int ancestorType)301 public IJavaElement getAncestor(int ancestorType) { 302 throw new NotImplementedException(); 303 } 304 getAttachedJavadoc(IProgressMonitor monitor)305 public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException { 306 throw new NotImplementedException(); 307 } 308 getCorrespondingResource()309 public IResource getCorrespondingResource() throws JavaModelException { 310 throw new NotImplementedException(); 311 } 312 getElementName()313 public String getElementName() { 314 throw new NotImplementedException(); 315 } 316 getElementType()317 public int getElementType() { 318 throw new NotImplementedException(); 319 } 320 getHandleIdentifier()321 public String getHandleIdentifier() { 322 throw new NotImplementedException(); 323 } 324 getJavaModel()325 public IJavaModel getJavaModel() { 326 throw new NotImplementedException(); 327 } 328 getJavaProject()329 public IJavaProject getJavaProject() { 330 throw new NotImplementedException(); 331 } 332 getOpenable()333 public IOpenable getOpenable() { 334 throw new NotImplementedException(); 335 } 336 getParent()337 public IJavaElement getParent() { 338 throw new NotImplementedException(); 339 } 340 getPath()341 public IPath getPath() { 342 throw new NotImplementedException(); 343 } 344 getPrimaryElement()345 public IJavaElement getPrimaryElement() { 346 throw new NotImplementedException(); 347 } 348 getResource()349 public IResource getResource() { 350 throw new NotImplementedException(); 351 } 352 getSchedulingRule()353 public ISchedulingRule getSchedulingRule() { 354 throw new NotImplementedException(); 355 } 356 getUnderlyingResource()357 public IResource getUnderlyingResource() throws JavaModelException { 358 throw new NotImplementedException(); 359 } 360 isReadOnly()361 public boolean isReadOnly() { 362 throw new NotImplementedException(); 363 } 364 isStructureKnown()365 public boolean isStructureKnown() throws JavaModelException { 366 throw new NotImplementedException(); 367 } 368 369 @SuppressWarnings("unchecked") getAdapter(Class adapter)370 public Object getAdapter(Class adapter) { 371 throw new NotImplementedException(); 372 } 373 close()374 public void close() throws JavaModelException { 375 throw new NotImplementedException(); 376 } 377 findRecommendedLineSeparator()378 public String findRecommendedLineSeparator() throws JavaModelException { 379 throw new NotImplementedException(); 380 } 381 getBuffer()382 public IBuffer getBuffer() throws JavaModelException { 383 throw new NotImplementedException(); 384 } 385 hasUnsavedChanges()386 public boolean hasUnsavedChanges() throws JavaModelException { 387 throw new NotImplementedException(); 388 } 389 isConsistent()390 public boolean isConsistent() throws JavaModelException { 391 throw new NotImplementedException(); 392 } 393 isOpen()394 public boolean isOpen() { 395 throw new NotImplementedException(); 396 } 397 makeConsistent(IProgressMonitor progress)398 public void makeConsistent(IProgressMonitor progress) throws JavaModelException { 399 throw new NotImplementedException(); 400 } 401 open(IProgressMonitor progress)402 public void open(IProgressMonitor progress) throws JavaModelException { 403 throw new NotImplementedException(); 404 } 405 save(IProgressMonitor progress, boolean force)406 public void save(IProgressMonitor progress, boolean force) throws JavaModelException { 407 throw new NotImplementedException(); 408 } 409 findElement(String bindingKey, WorkingCopyOwner owner)410 public IJavaElement findElement(String bindingKey, WorkingCopyOwner owner) 411 throws JavaModelException { 412 throw new NotImplementedException(); 413 } 414 } 415