Fix problem with removed problem markers

This commit is contained in:
alexey-andreev 2015-01-18 19:20:42 +04:00
parent 8188878488
commit 3f7d02affb
3 changed files with 12 additions and 4 deletions

View File

@ -90,6 +90,7 @@
<attribute name="message"/> <attribute name="message"/>
<attribute name="lineNumber"/> <attribute name="lineNumber"/>
<attribute name="teavm-eclipse-plugin.problemMarker.project"/> <attribute name="teavm-eclipse-plugin.problemMarker.project"/>
<attribute name="teavm-eclipse-plugin.problemMarker.profile"/>
</extension> </extension>
<extension id="configMarker" point="org.eclipse.core.resources.markers" name="TeaVM configuration problem"> <extension id="configMarker" point="org.eclipse.core.resources.markers" name="TeaVM configuration problem">
<super type="org.eclipse.core.resources.problemmarker"/> <super type="org.eclipse.core.resources.problemmarker"/>

View File

@ -43,6 +43,7 @@ public class TeaVMEclipsePlugin extends AbstractUIPlugin {
public static final String CLASS_DIALOG_ID = ID + ".dialogs.classSelection"; public static final String CLASS_DIALOG_ID = ID + ".dialogs.classSelection";
public static final String PROBLEM_MARKER_ID = ID + ".problemMarker"; public static final String PROBLEM_MARKER_ID = ID + ".problemMarker";
public static final String PROBLEM_MARKER_PROJECT_ATTRIBUTE = ID + ".problemMarker.project"; public static final String PROBLEM_MARKER_PROJECT_ATTRIBUTE = ID + ".problemMarker.project";
public static final String PROBLEM_MARKER_PROFILE_ATTRIBUTE = ID + ".problemMarker.profile";
public static final String CONFIG_MARKER_ID = ID + ".configMarker"; public static final String CONFIG_MARKER_ID = ID + ".configMarker";
private static TeaVMEclipsePlugin defaultInstance; private static TeaVMEclipsePlugin defaultInstance;
private ConcurrentMap<IProject, TeaVMProjectSettings> settingsMap = new ConcurrentHashMap<>(); private ConcurrentMap<IProject, TeaVMProjectSettings> settingsMap = new ConcurrentHashMap<>();

View File

@ -60,13 +60,15 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
monitor.beginTask("Running TeaVM", profiles.length * TICKS_PER_PROFILE); monitor.beginTask("Running TeaVM", profiles.length * TICKS_PER_PROFILE);
try { try {
prepareClassPath(); prepareClassPath();
removeMarkers();
ClassLoader classLoader = new URLClassLoader(classPath, TeaVMProjectBuilder.class.getClassLoader()); ClassLoader classLoader = new URLClassLoader(classPath, TeaVMProjectBuilder.class.getClassLoader());
for (TeaVMProfile profile : profiles) { for (TeaVMProfile profile : profiles) {
SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, TICKS_PER_PROFILE); SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, TICKS_PER_PROFILE);
buildProfile(kind, subMonitor, profile, classLoader); buildProfile(kind, subMonitor, profile, classLoader);
} }
IMarker[] markers = getProject().findMarkers(TeaVMEclipsePlugin.PROBLEM_MARKER_ID, true, IResource.DEPTH_INFINITE);
for (IMarker marker : markers) {
System.out.println("MARKER INSTALLED: " + marker.getId());
}
} finally { } finally {
monitor.done(); monitor.done();
sourceContainers = null; sourceContainers = null;
@ -94,6 +96,7 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
if ((kind == AUTO_BUILD || kind == INCREMENTAL_BUILD) && !shouldBuild(profile)) { if ((kind == AUTO_BUILD || kind == INCREMENTAL_BUILD) && !shouldBuild(profile)) {
return; return;
} }
removeMarkers(profile);
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager(); IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
TeaVMTool tool = new TeaVMTool(); TeaVMTool tool = new TeaVMTool();
tool.setClassLoader(classLoader); tool.setClassLoader(classLoader);
@ -225,14 +228,17 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
profileClasses.put(profile, new HashSet<>(classes)); profileClasses.put(profile, new HashSet<>(classes));
} }
private void removeMarkers() throws CoreException { private void removeMarkers(TeaVMProfile profile) throws CoreException {
for (IProject project : getProject().getWorkspace().getRoot().getProjects()) { for (IProject project : getProject().getWorkspace().getRoot().getProjects()) {
IMarker[] markers = project.findMarkers(TeaVMEclipsePlugin.PROBLEM_MARKER_ID, true, IMarker[] markers = project.findMarkers(TeaVMEclipsePlugin.PROBLEM_MARKER_ID, true,
IResource.DEPTH_INFINITE); IResource.DEPTH_INFINITE);
for (IMarker marker : markers) { for (IMarker marker : markers) {
String projectName = (String)marker.getAttribute(TeaVMEclipsePlugin.PROBLEM_MARKER_PROJECT_ATTRIBUTE); String projectName = (String)marker.getAttribute(TeaVMEclipsePlugin.PROBLEM_MARKER_PROJECT_ATTRIBUTE);
if (projectName.equals(getProject().getName())) { String profileName = (String)marker.getAttribute(TeaVMEclipsePlugin.PROBLEM_MARKER_PROFILE_ATTRIBUTE);
if (projectName.equals(getProject().getName()) && profileName.equals(profile.getName())) {
marker.delete(); marker.delete();
System.out.println("MARKER REMOVED: " + marker.getId() + " while building project " +
getProject().getName());
} }
} }
} }