diff options
author | Ayushman Jain | 2011-05-04 14:47:31 +0000 |
---|---|---|
committer | Ayushman Jain | 2011-05-04 14:47:31 +0000 |
commit | 9309fad26eb4113a283f2c853c44a62715f49d70 (patch) | |
tree | f558258d2de60d07ca0c01250ad4b2ff42d677b7 /org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core | |
parent | 5527337a36439b5f7161d1700f05a2afcdb55c60 (diff) | |
download | eclipse.jdt.core-9309fad26eb4113a283f2c853c44a62715f49d70.tar.gz eclipse.jdt.core-9309fad26eb4113a283f2c853c44a62715f49d70.tar.xz eclipse.jdt.core-9309fad26eb4113a283f2c853c44a62715f49d70.zip |
HEAD- Fixed bug 90486: Give more info when a dependency cycle is detected
Diffstat (limited to 'org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core')
4 files changed, 28 insertions, 8 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java index 5f92071838..1a00353539 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaModelStatus.java @@ -344,7 +344,7 @@ public class JavaModelStatus extends Status implements IJavaModelStatus, IJavaMo case CLASSPATH_CYCLE: javaProject = (IJavaProject)this.elements[0]; - return Messages.bind(Messages.classpath_cycle, javaProject.getElementName()); + return Messages.bind(Messages.classpath_cycle, new String[] {javaProject.getElementName(), this.string}); case DISABLED_CP_EXCLUSION_PATTERNS: javaProject = (IJavaProject)this.elements[0]; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java index 4b58e5503f..327a352c9a 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProject.java @@ -372,7 +372,7 @@ public class JavaProject int length = rscProjects.length; JavaProject[] projects = new JavaProject[length]; - HashSet cycleParticipants = new HashSet(); + LinkedHashSet cycleParticipants = new LinkedHashSet(); HashSet traversed = new HashSet(); // compute cycle participants @@ -406,9 +406,29 @@ public class JavaProject 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)); + new JavaModelStatus(IJavaModelStatusConstants.CLASSPATH_CYCLE, project, cycleString)); } } else { project.flushClasspathProblemMarkers(true, false); @@ -2063,7 +2083,7 @@ public class JavaProject * @see IJavaProject */ public boolean hasClasspathCycle(IClasspathEntry[] preferredClasspath) { - HashSet cycleParticipants = new HashSet(); + LinkedHashSet cycleParticipants = new LinkedHashSet(); HashMap preferredClasspaths = new HashMap(1); preferredClasspaths.put(this, preferredClasspath); updateCycleParticipants(new ArrayList(2), cycleParticipants, ResourcesPlugin.getWorkspace().getRoot(), new HashSet(2), preferredClasspaths); @@ -3127,7 +3147,7 @@ public class JavaProject */ public void updateCycleParticipants( ArrayList prereqChain, - HashSet cycleParticipants, + LinkedHashSet cycleParticipants, IWorkspaceRoot workspaceRoot, HashSet traversed, Map preferredClasspaths){ diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java index b32f44c8f7..a97dc6dd1d 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -716,7 +716,7 @@ private boolean isWorthBuilding() throws CoreException { * needs to propagate structural changes to the other projects in the cycle. */ void mustPropagateStructuralChanges() { - HashSet cycleParticipants = new HashSet(3); + LinkedHashSet cycleParticipants = new LinkedHashSet(3); this.javaProject.updateCycleParticipants(new ArrayList(), cycleParticipants, this.workspaceRoot, new HashSet(3), null); IPath currentPath = this.javaProject.getPath(); Iterator i= cycleParticipants.iterator(); diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties index cc8f1d606b..e75e56ba7a 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/messages.properties @@ -141,7 +141,7 @@ classpath_cannotUseDistinctSourceFolderAsOutput = Source folder ''{0}'' in proje classpath_cannotUseLibraryAsOutput = Source folder ''{0}'' in project ''{2}'' cannot output to library ''{1}'' classpath_closedProject = Required project ''{0}'' needs to be open classpath_couldNotWriteClasspathFile = Could not write ''.classpath'' file of project ''{0}'': {1} -classpath_cycle = A cycle was detected in the build path of project ''{0}'' +classpath_cycle = A cycle was detected in the build path of project ''{0}''. The cycle consists of projects '{'{1}'}' classpath_duplicateEntryPath = Build path contains duplicate entry: ''{0}'' for project ''{1}'' classpath_illegalContainerPath = Illegal classpath container path: ''{0}'' in project ''{1}'', must have at least one segment (containerID+hints) classpath_illegalEntryInClasspathFile = Illegal entry in ''.classpath'' of project ''{0}'' file: {1} |