Skip to content

Commit

Permalink
[cnf] Make CnfWatcher dependent on Eclipse WS
Browse files Browse the repository at this point in the history
Was previously dependent on Bnd workspace only.

Signed-off-by: Fr Jeremy Krieg <fr.jkrieg@greekwelfaresa.org.au>
  • Loading branch information
kriegfrj committed Jan 19, 2022
1 parent 3013ead commit 2ea1a38
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions org.bndtools.builder/src/org/bndtools/builder/impl/CnfWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
Expand All @@ -36,9 +36,11 @@ public class CnfWatcher implements IResourceChangeListener {
@Reference
BndtoolsBuilder builder;

// Bnd workspace, not Eclipse workspace.
@Reference
Workspace workspace;
IWorkspace eclipseWorkspace;

@Reference
Workspace bndWorkspace;

@Override
public void resourceChanged(final IResourceChangeEvent event) {
Expand All @@ -51,16 +53,15 @@ public void resourceChanged(final IResourceChangeEvent event) {

private void processEvent(IResourceChangeEvent event) {
try {
final IProject cnfProject = WorkspaceUtils.findCnfProject(ResourcesPlugin.getWorkspace()
.getRoot(), workspace);
final IProject cnfProject = WorkspaceUtils.findCnfProject(eclipseWorkspace.getRoot(), bndWorkspace);
if (cnfProject == null)
return;

IResourceDelta delta = event.getDelta();
if (delta.findMember(cnfProject.getFullPath()) == null)
return;

Collection<Project> allProjects = workspace.getAllProjects();
Collection<Project> allProjects = bndWorkspace.getAllProjects();
if (allProjects.isEmpty())
return;

Expand All @@ -72,14 +73,14 @@ private void processEvent(IResourceChangeEvent event) {
@Override
public IStatus runInWorkspace(IProgressMonitor arg0) throws CoreException {
try {
workspace.clear();
workspace.refresh();
workspace.getPlugins();
bndWorkspace.clear();
bndWorkspace.refresh();
bndWorkspace.getPlugins();

BndtoolsBuilder.dirty.addAll(allProjects);
MarkerSupport ms = new MarkerSupport(cnfProject);
ms.deleteMarkers("*");
ms.setMarkers(workspace, BndtoolsConstants.MARKER_BND_WORKSPACE_PROBLEM);
ms.setMarkers(bndWorkspace, BndtoolsConstants.MARKER_BND_WORKSPACE_PROBLEM);
} catch (Exception e) {
return new Status(IStatus.ERROR, PLUGIN_ID,
"error during workspace refresh",
Expand Down

0 comments on commit 2ea1a38

Please sign in to comment.