Skip to content

Commit 5168f41

Browse files
Move the error marker check to ResourceUtils as helper method
1 parent bb09d46 commit 5168f41

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/ResourceUtils.java

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.eclipse.core.runtime.Platform;
4545
import org.eclipse.core.runtime.URIUtil;
4646
import org.eclipse.jdt.core.IJavaModelMarker;
47+
import org.eclipse.jdt.core.compiler.IProblem;
4748

4849
import com.google.common.base.Charsets;
4950
import com.google.common.io.CharStreams;
@@ -383,4 +384,9 @@ public static IMarker createWarningMarker(String type, IResource resource, Strin
383384
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
384385
return marker;
385386
}
387+
388+
public static boolean isUnresolvedImportError(IMarker marker) {
389+
return marker.getAttribute(IMarker.SEVERITY, 0) == IMarker.SEVERITY_ERROR
390+
&& marker.getAttribute(IJavaModelMarker.ID, 0) == IProblem.ImportNotFound;
391+
}
386392
}

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/TelemetryManager.java

+2-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
import org.eclipse.core.resources.IResource;
2929
import org.eclipse.core.runtime.CoreException;
3030
import org.eclipse.core.runtime.IPath;
31-
import org.eclipse.jdt.core.IJavaModelMarker;
3231
import org.eclipse.jdt.core.IJavaProject;
3332
import org.eclipse.jdt.core.IPackageFragmentRoot;
34-
import org.eclipse.jdt.core.compiler.IProblem;
3533
import org.eclipse.jdt.launching.IVMInstall;
3634
import org.eclipse.jdt.launching.JavaRuntime;
3735
import org.eclipse.jdt.ls.core.internal.JavaClientConnection.JavaLanguageClient;
3836
import org.eclipse.jdt.ls.core.internal.ProjectUtils;
37+
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
3938
import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
4039

4140
import com.google.gson.JsonArray;
@@ -119,7 +118,7 @@ public void onBuildFinished(long buildFinishedTime) {
119118
IMarker[] projectMarkers = project.findMarkers(null /* all markers */, true /* subtypes */, IResource.DEPTH_ZERO);
120119
projectErrors += Stream.of(projectMarkers).filter(m -> m.getAttribute(IMarker.SEVERITY, 0) == IMarker.SEVERITY_ERROR).count();
121120
IMarker[] allmarkers = project.findMarkers(null /* all markers */, true /* subtypes */, IResource.DEPTH_INFINITE);
122-
unresolvedImportErrors += Stream.of(allmarkers).filter(m -> isUnresolvedImportError(m)).count();
121+
unresolvedImportErrors += Stream.of(allmarkers).filter(m -> ResourceUtils.isUnresolvedImportError(m)).count();
123122
} catch (CoreException e) {
124123
// ignore
125124
}
@@ -171,11 +170,6 @@ public void onBuildFinished(long buildFinishedTime) {
171170
telemetryEvent(JAVA_PROJECT_BUILD, properties);
172171
}
173172

174-
private boolean isUnresolvedImportError(IMarker marker) {
175-
return marker.getAttribute(IMarker.SEVERITY, 0) == IMarker.SEVERITY_ERROR
176-
&& marker.getAttribute(IJavaModelMarker.ID, 0) == IProblem.ImportNotFound;
177-
}
178-
179173
/**
180174
* The total size (in bytes) of all dependencies in the workspace
181175
* This should correspond to the total size of dependencies used by a

0 commit comments

Comments
 (0)