Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2021-02-12 02:16:26 -0500
committerAndrey Loskutov2021-02-12 09:06:20 -0500
commit43b405562eab0627b3e3f3bb9aaa3352beb98d40 (patch)
treefca617be3fab180178bda031d154ad23ae92339c
parent54cbcecbcecbf6440267f83b8db07bdcbce457a9 (diff)
downloadeclipse.jdt.core-43b405562eab0627b3e3f3bb9aaa3352beb98d40.tar.gz
eclipse.jdt.core-43b405562eab0627b3e3f3bb9aaa3352beb98d40.tar.xz
eclipse.jdt.core-43b405562eab0627b3e3f3bb9aaa3352beb98d40.zip
Bug 571017 - Use atomic marker creation API in JavaBuilder
The new marker API from Bug 570914 allows to create markers with attributes and therefore avoids sending out resource change events for every attribute change. JDT core dependencies have already increased the minimum required resource API version in a previous commit. Change-Id: Ie63b8a05d2cf7ef6b4bfe20900b7d9dc66e853bd Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/JavaBuilder.java51
1 files changed, 21 insertions, 30 deletions
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 701acb199d..7aa915eaec 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
@@ -239,15 +239,12 @@ protected IProject[] build(int kind, Map ignored, IProgressMonitor monitor) thro
if (DEBUG)
System.out.println(Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile));
removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile),
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- JavaBuilder.SOURCE_ID
- }
- );
+
+ Map<String, Object> attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE, Messages.bind(Messages.build_missingSourceFile, e.missingSourceFile));
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
} finally {
for (int i = 0, l = this.participants == null ? 0 : this.participants.length; i < l; i++)
this.participants[i].buildFinished(this.javaProject);
@@ -341,16 +338,12 @@ private void createInconsistentBuildMarker(CoreException coreException) throws C
if (message == null)
message = coreException.getMessage();
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
- Messages.bind(Messages.build_inconsistentProject, message),
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- Integer.valueOf(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
+ Map<String, Object> attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE, Messages.bind(Messages.build_inconsistentProject, message));
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IJavaModelMarker.CATEGORY_ID, Integer.valueOf(CategorizedProblem.CAT_BUILDPATH));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
}
private void cleanup() {
@@ -751,18 +744,16 @@ private boolean isWorthBuilding() throws CoreException {
+ " was not built"); //$NON-NLS-1$
removeProblemsAndTasksFor(this.currentProject); // make this the only problem for this project
- IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttributes(
- new String[] {IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID},
- new Object[] {
+
+ Map<String, Object> attributes = new HashMap<>();
+ attributes.put(IMarker.MESSAGE,
isClasspathBroken(prereq, true)
- ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName())
- : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()),
- Integer.valueOf(IMarker.SEVERITY_ERROR),
- Integer.valueOf(CategorizedProblem.CAT_BUILDPATH),
- JavaBuilder.SOURCE_ID
- }
- );
+ ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName())
+ : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()));
+ attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
+ attributes.put(IJavaModelMarker.CATEGORY_ID, Integer.valueOf(CategorizedProblem.CAT_BUILDPATH));
+ attributes.put(IMarker.SOURCE_ID, JavaBuilder.SOURCE_ID);
+ this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, attributes);
return false;
}
}

Back to the top