1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.core.runtime.IPath; 15 import org.eclipse.jdt.core.IClasspathEntry; 16 import org.eclipse.jdt.core.IJavaModelStatus; 17 import org.eclipse.jdt.core.IJavaModelStatusConstants; 18 import org.eclipse.jdt.core.JavaModelException; 19 import org.eclipse.jdt.internal.core.builder.JavaBuilder; 20 21 25 public class ClasspathValidation { 26 27 private JavaProject project; 28 29 public ClasspathValidation(JavaProject project) { 30 this.project = project; 31 } 32 33 public void validate() { 34 JavaModelManager.PerProjectInfo perProjectInfo; 35 try { 36 perProjectInfo = this.project.getPerProjectInfo(); 37 } catch (JavaModelException e) { 38 IProject resource = this.project.getProject(); 40 if (resource.isAccessible()) { 41 this.project.flushClasspathProblemMarkers(true, true); 42 43 JavaBuilder.removeProblemsAndTasksFor(resource); 45 } 46 return; 47 } 48 49 IClasspathEntry[] rawClasspath; 51 IPath outputLocation; 52 IJavaModelStatus status; 53 synchronized (perProjectInfo) { 54 rawClasspath = perProjectInfo.rawClasspath; 55 outputLocation = perProjectInfo.outputLocation; 56 status = perProjectInfo.rawClasspathStatus; } 58 59 this.project.flushClasspathProblemMarkers(false, true); 61 if (!status.isOK()) 62 this.project.createClasspathProblemMarker(status); 63 64 this.project.flushClasspathProblemMarkers(false, false); 66 67 if (rawClasspath != JavaProject.INVALID_CLASSPATH && outputLocation != null) { 68 for (int i = 0; i < rawClasspath.length; i++) { 69 status = ClasspathEntry.validateClasspathEntry(this.project, rawClasspath[i], false, true ); 70 if (!status.isOK()) { 71 if (status.getCode() == IJavaModelStatusConstants.INVALID_CLASSPATH && ((ClasspathEntry) rawClasspath[i]).isOptional()) 72 continue; this.project.createClasspathProblemMarker(status); 74 } 75 } 76 status = ClasspathEntry.validateClasspath(this.project, rawClasspath, outputLocation); 77 if (!status.isOK()) 78 this.project.createClasspathProblemMarker(status); 79 } 80 } 81 82 } 83 | Popular Tags |