Lines 50-55
Link Here
|
50 |
|
50 |
|
51 |
private boolean inCompiler; |
51 |
private boolean inCompiler; |
52 |
|
52 |
|
|
|
53 |
protected boolean keepStoringProblemMarkers; |
53 |
protected SimpleSet filesWithAnnotations = null; |
54 |
protected SimpleSet filesWithAnnotations = null; |
54 |
|
55 |
|
55 |
public static int MAX_AT_ONCE = 2000; // best compromise between space used and speed |
56 |
public static int MAX_AT_ONCE = 2000; // best compromise between space used and speed |
Lines 85-90
Link Here
|
85 |
this.nameEnvironment = javaBuilder.nameEnvironment; |
86 |
this.nameEnvironment = javaBuilder.nameEnvironment; |
86 |
this.sourceLocations = this.nameEnvironment.sourceLocations; |
87 |
this.sourceLocations = this.nameEnvironment.sourceLocations; |
87 |
this.notifier = javaBuilder.notifier; |
88 |
this.notifier = javaBuilder.notifier; |
|
|
89 |
this.keepStoringProblemMarkers = true; // may get disabled when missing classfiles are encountered |
88 |
|
90 |
|
89 |
if (buildStarting) { |
91 |
if (buildStarting) { |
90 |
this.newState = newState == null ? new State(javaBuilder) : newState; |
92 |
this.newState = newState == null ? new State(javaBuilder) : newState; |
Lines 200-205
Link Here
|
200 |
// noop |
202 |
// noop |
201 |
} |
203 |
} |
202 |
|
204 |
|
|
|
205 |
protected void addAllSourceFiles(final ArrayList sourceFiles) throws CoreException { |
206 |
for (int i = 0, l = sourceLocations.length; i < l; i++) { |
207 |
final ClasspathMultiDirectory sourceLocation = sourceLocations[i]; |
208 |
final char[][] exclusionPatterns = sourceLocation.exclusionPatterns; |
209 |
final char[][] inclusionPatterns = sourceLocation.inclusionPatterns; |
210 |
final boolean isAlsoProject = sourceLocation.sourceFolder.equals(javaBuilder.currentProject); |
211 |
final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount(); |
212 |
final IContainer outputFolder = sourceLocation.binaryFolder; |
213 |
final boolean isOutputFolder = sourceLocation.sourceFolder.equals(outputFolder); |
214 |
sourceLocation.sourceFolder.accept( |
215 |
new IResourceProxyVisitor() { |
216 |
public boolean visit(IResourceProxy proxy) throws CoreException { |
217 |
switch(proxy.getType()) { |
218 |
case IResource.FILE : |
219 |
if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())) { |
220 |
IResource resource = proxy.requestResource(); |
221 |
if (exclusionPatterns != null || inclusionPatterns != null) |
222 |
if (Util.isExcluded(resource, inclusionPatterns, exclusionPatterns)) return false; |
223 |
sourceFiles.add(new SourceFile((IFile) resource, sourceLocation)); |
224 |
} |
225 |
return false; |
226 |
case IResource.FOLDER : |
227 |
if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null |
228 |
if (Util.isExcluded(proxy.requestResource(), inclusionPatterns, exclusionPatterns)) return false; |
229 |
IPath folderPath = null; |
230 |
if (isAlsoProject) |
231 |
if (isExcludedFromProject(folderPath = proxy.requestFullPath())) return false; |
232 |
if (!isOutputFolder) { |
233 |
if (folderPath == null) |
234 |
folderPath = proxy.requestFullPath(); |
235 |
createFolder(folderPath.removeFirstSegments(segmentCount), outputFolder); |
236 |
} |
237 |
} |
238 |
return true; |
239 |
} |
240 |
}, |
241 |
IResource.NONE |
242 |
); |
243 |
notifier.checkCancel(); |
244 |
} |
245 |
} |
246 |
|
203 |
protected void cleanUp() { |
247 |
protected void cleanUp() { |
204 |
this.nameEnvironment.cleanup(); |
248 |
this.nameEnvironment.cleanup(); |
205 |
|
249 |
|
Lines 550-574
Link Here
|
550 |
*/ |
594 |
*/ |
551 |
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException { |
595 |
protected void storeProblemsFor(SourceFile sourceFile, CategorizedProblem[] problems) throws CoreException { |
552 |
if (sourceFile == null || problems == null || problems.length == 0) return; |
596 |
if (sourceFile == null || problems == null || problems.length == 0) return; |
|
|
597 |
// once a classpath error is found, ignore all other problems for this project so the user can see the main error |
598 |
// but still try to compile as many source files as possible to help the case when the base libraries are in source |
599 |
if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file |
553 |
|
600 |
|
554 |
String missingClassFile = null; |
|
|
555 |
IResource resource = sourceFile.resource; |
601 |
IResource resource = sourceFile.resource; |
556 |
HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes(); |
602 |
HashSet managedMarkerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes(); |
557 |
for (int i = 0, l = problems.length; i < l; i++) { |
603 |
for (int i = 0, l = problems.length; i < l; i++) { |
558 |
CategorizedProblem problem = problems[i]; |
604 |
CategorizedProblem problem = problems[i]; |
559 |
int id = problem.getID(); |
605 |
int id = problem.getID(); |
|
|
606 |
|
607 |
// handle missing classfile situation |
560 |
if (id == IProblem.IsClassPathCorrect) { |
608 |
if (id == IProblem.IsClassPathCorrect) { |
561 |
JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project |
609 |
String missingClassfileName = problem.getArguments()[0]; |
562 |
String[] args = problem.getArguments(); |
610 |
if (JavaBuilder.DEBUG) |
563 |
missingClassFile = args[0]; |
611 |
System.out.println(Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); |
|
|
612 |
boolean isInvalidClasspathError = JavaCore.ERROR.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)); |
613 |
// insert extra classpath problem, and make it the only problem for this project (optional) |
614 |
if (isInvalidClasspathError && JavaCore.ABORT.equals(javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true))) { |
615 |
JavaBuilder.removeProblemsAndTasksFor(javaBuilder.currentProject); // make this the only problem for this project |
616 |
this.keepStoringProblemMarkers = false; |
617 |
} |
618 |
IMarker marker = this.javaBuilder.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); |
619 |
marker.setAttribute(IMarker.MESSAGE, Messages.bind(Messages.build_incompleteClassPath, missingClassfileName)); |
620 |
marker.setAttribute(IMarker.SEVERITY, isInvalidClasspathError ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING); |
621 |
marker.setAttribute(IJavaModelMarker.CATEGORY_ID, CategorizedProblem.CAT_BUILDPATH); |
622 |
marker.setAttribute(IMarker.GENERATED_BY, JavaBuilder.GENERATED_BY); |
623 |
// even if we're not keeping more markers, still fall through rest of the problem reporting, so that offending |
624 |
// IsClassPathCorrect problem gets recorded since it may help locate the offending reference |
564 |
} |
625 |
} |
565 |
|
626 |
|
566 |
String markerType = problem.getMarkerType(); |
627 |
String markerType = problem.getMarkerType(); |
567 |
boolean managedProblem = false; |
628 |
boolean managedProblem = false; |
568 |
if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType) |
629 |
if (IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER.equals(markerType) |
569 |
|| (managedProblem = managedMarkerTypes.contains(markerType))) { |
630 |
|| (managedProblem = managedMarkerTypes.contains(markerType))) { |
570 |
IMarker marker = resource.createMarker(markerType); |
631 |
IMarker marker = resource.createMarker(markerType); |
571 |
|
632 |
|
572 |
// standard attributes |
633 |
// standard attributes |
573 |
marker.setAttributes( |
634 |
marker.setAttributes( |
574 |
JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES, |
635 |
JAVA_PROBLEM_MARKER_ATTRIBUTE_NAMES, |
Lines 593-601
Link Here
|
593 |
if (extraLength > 0) { |
654 |
if (extraLength > 0) { |
594 |
marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues()); |
655 |
marker.setAttributes(extraAttributeNames, problem.getExtraMarkerAttributeValues()); |
595 |
} |
656 |
} |
|
|
657 |
|
658 |
if (!this.keepStoringProblemMarkers) return; // only want the one error recorded on this source file |
596 |
} |
659 |
} |
597 |
if (missingClassFile != null) |
|
|
598 |
throw new MissingClassFileException(missingClassFile); |
599 |
} |
660 |
} |
600 |
} |
661 |
} |
601 |
|
662 |
|