List of usage examples for org.eclipse.jdt.internal.core JavaModelStatus JavaModelStatus
public JavaModelStatus(int code, IJavaElement element, IPath path)
From source file:com.codenvy.ide.ext.java.server.internal.core.JavaElement.java
License:Open Source License
/** * Creates and returns a new Java model exception for this element with the given status. *///from ww w . j av a2s.c o m public JavaModelException newJavaModelException(IStatus status) { if (status instanceof IJavaModelStatus) return new JavaModelException((IJavaModelStatus) status); else return new JavaModelException( new JavaModelStatus(status.getSeverity(), status.getCode(), status.getMessage())); }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
public static void validateCycles(Map preferredClasspaths) throws JavaModelException { //long start = System.currentTimeMillis(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject[] rscProjects = workspaceRoot.getProjects(); int length = rscProjects.length; JavaProject[] projects = new JavaProject[length]; LinkedHashSet cycleParticipants = new LinkedHashSet(); HashSet traversed = new HashSet(); // compute cycle participants ArrayList prereqChain = new ArrayList(); for (int i = 0; i < length; i++) { if (hasJavaNature(rscProjects[i])) { JavaProject project = (projects[i] = (JavaProject) JavaCore.create(rscProjects[i])); if (!traversed.contains(project.getPath())) { prereqChain.clear();/* w w w . j ava2s .c o m*/ project.updateCycleParticipants(prereqChain, cycleParticipants, workspaceRoot, traversed, preferredClasspaths); } } } //System.out.println("updateAllCycleMarkers: " + (System.currentTimeMillis() - start) + " ms"); for (int i = 0; i < length; i++) { JavaProject project = projects[i]; if (project != null) { if (cycleParticipants.contains(project.getPath())) { IMarker cycleMarker = project.getCycleMarker(); String circularCPOption = project.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true); int circularCPSeverity = JavaCore.ERROR.equals(circularCPOption) ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING; if (cycleMarker != null) { // update existing cycle marker if needed try { int existingSeverity = ((Integer) cycleMarker.getAttribute(IMarker.SEVERITY)) .intValue(); if (existingSeverity != circularCPSeverity) { cycleMarker.setAttribute(IMarker.SEVERITY, circularCPSeverity); } } catch (CoreException e) { throw new JavaModelException(e); } } else { IJavaProject[] projectsInCycle; String cycleString = ""; //$NON-NLS-1$ if (cycleParticipants.isEmpty()) { projectsInCycle = null; } else { projectsInCycle = new IJavaProject[cycleParticipants.size()]; Iterator it = cycleParticipants.iterator(); int k = 0; while (it.hasNext()) { //projectsInCycle[i++] = (IPath) it.next(); IResource member = workspaceRoot.findMember((IPath) it.next()); if (member != null && member.getType() == IResource.PROJECT) { projectsInCycle[k] = JavaCore.create((IProject) member); if (projectsInCycle[k] != null) { if (k != 0) cycleString += ", "; //$NON-NLS-1$ cycleString += projectsInCycle[k++].getElementName(); } } } } // create new marker project.createClasspathProblemMarker(new JavaModelStatus( IJavaModelStatusConstants.CLASSPATH_CYCLE, project, cycleString)); } } else { project.flushClasspathProblemMarkers(true, false, false); } } } }