mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Bug 133881 - Make refreshing after building optional
Work in progress.
This commit is contained in:
parent
fe52e11b25
commit
1ab1affd17
7 changed files with 233 additions and 84 deletions
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.ICommandLauncher;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.resources.ACBuilder;
|
import org.eclipse.cdt.core.resources.ACBuilder;
|
||||||
import org.eclipse.cdt.core.resources.IConsole;
|
import org.eclipse.cdt.core.resources.IConsole;
|
||||||
|
import org.eclipse.cdt.core.resources.RefreshScopeManager;
|
||||||
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
||||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||||
import org.eclipse.cdt.make.internal.core.StreamMonitor;
|
import org.eclipse.cdt.make.internal.core.StreamMonitor;
|
||||||
|
@ -295,7 +296,11 @@ public class MakeBuilder extends ACBuilder {
|
||||||
// Do not allow the cancel of the refresh, since the builder is external
|
// Do not allow the cancel of the refresh, since the builder is external
|
||||||
// to Eclipse, files may have been created/modified and we will be out-of-sync.
|
// to Eclipse, files may have been created/modified and we will be out-of-sync.
|
||||||
// The caveat is for huge projects, it may take sometimes at every build.
|
// The caveat is for huge projects, it may take sometimes at every build.
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
// project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
|
|
||||||
|
// use the refresh scope manager to refresh
|
||||||
|
IWorkspaceRunnable runnable = RefreshScopeManager.getInstance().getRefreshRunnable(project);
|
||||||
|
ResourcesPlugin.getWorkspace().run(runnable, null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
MakeCorePlugin.log(e);
|
MakeCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.resources.IConsole;
|
import org.eclipse.cdt.core.resources.IConsole;
|
||||||
|
import org.eclipse.cdt.core.resources.RefreshScopeManager;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
||||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||||
|
@ -51,7 +52,9 @@ import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -196,7 +199,11 @@ public class ExternalBuildRunner extends AbstractBuildRunner {
|
||||||
// The caveat is for huge projects, it may take sometimes at every build.
|
// The caveat is for huge projects, it may take sometimes at every build.
|
||||||
|
|
||||||
// TODO should only refresh output folders
|
// TODO should only refresh output folders
|
||||||
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
//project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
|
|
||||||
|
// use the refresh scope manager to refresh
|
||||||
|
IWorkspaceRunnable runnable = RefreshScopeManager.getInstance().getRefreshRunnable(project);
|
||||||
|
ResourcesPlugin.getWorkspace().run(runnable, null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.IMarkerGenerator;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.resources.ACBuilder;
|
import org.eclipse.cdt.core.resources.ACBuilder;
|
||||||
import org.eclipse.cdt.core.resources.IConsole;
|
import org.eclipse.cdt.core.resources.IConsole;
|
||||||
|
import org.eclipse.cdt.core.resources.RefreshScopeManager;
|
||||||
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
|
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
|
||||||
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
|
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
|
||||||
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
|
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType;
|
||||||
|
@ -58,7 +59,9 @@ import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -1104,8 +1107,11 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
monitor.subTask(ManagedMakeMessages
|
monitor.subTask(ManagedMakeMessages
|
||||||
.getResourceString(REFRESH));
|
.getResourceString(REFRESH));
|
||||||
try {
|
try {
|
||||||
currentProject.refreshLocal(
|
//currentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
IResource.DEPTH_INFINITE, null);
|
|
||||||
|
// use the refresh scope manager to refresh
|
||||||
|
IWorkspaceRunnable runnable = RefreshScopeManager.getInstance().getRefreshRunnable(currentProject);
|
||||||
|
ResourcesPlugin.getWorkspace().run(runnable, null);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
monitor.subTask(ManagedMakeMessages
|
monitor.subTask(ManagedMakeMessages
|
||||||
.getResourceString(REFRESH_ERROR));
|
.getResourceString(REFRESH_ERROR));
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
@ -600,5 +601,12 @@ public class RefreshPolicyTab extends AbstractCPropertyTab {
|
||||||
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
List<RefreshExclusion> exclusions = fResourceToExclusionsMap.get(resource);
|
||||||
fManager.setExclusions(resource, exclusions);
|
fManager.setExclusions(resource, exclusions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fManager.persistSettings();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,14 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.resources.tests;
|
package org.eclipse.cdt.core.resources.tests;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.resources.ExclusionInstance;
|
import org.eclipse.cdt.core.resources.ExclusionInstance;
|
||||||
|
@ -28,7 +32,9 @@ import org.eclipse.core.resources.IProjectDescription;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +44,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
public class RefreshScopeTests extends TestCase {
|
public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
private IResource fFolder1;
|
private IFolder fFolder1;
|
||||||
private IResource fFolder2;
|
private IFolder fFolder2;
|
||||||
private IFolder fFolder3;
|
private IFolder fFolder3;
|
||||||
private IFolder fFolder4;
|
private IFolder fFolder4;
|
||||||
private IFolder fFolder5;
|
private IFolder fFolder5;
|
||||||
|
@ -136,6 +142,8 @@ public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
|
|
||||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||||
|
manager.clearAllData();
|
||||||
|
|
||||||
manager.addResourceToRefresh(fProject, fFolder1);
|
manager.addResourceToRefresh(fProject, fFolder1);
|
||||||
|
|
||||||
IResource[] resources = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
|
IResource[] resources = manager.getResourcesToRefresh(fProject).toArray(new IResource[0]);
|
||||||
|
@ -170,6 +178,8 @@ public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
public void testSetResourcesToRefresh() {
|
public void testSetResourcesToRefresh() {
|
||||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||||
|
manager.clearAllData();
|
||||||
|
|
||||||
List<IResource> resources = new LinkedList<IResource>();
|
List<IResource> resources = new LinkedList<IResource>();
|
||||||
resources.add(fFolder1);
|
resources.add(fFolder1);
|
||||||
resources.add(fFolder2);
|
resources.add(fFolder2);
|
||||||
|
@ -186,6 +196,8 @@ public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
public void testAddRemoveExclusion() {
|
public void testAddRemoveExclusion() {
|
||||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||||
|
manager.clearAllData();
|
||||||
|
|
||||||
manager.addResourceToRefresh(fProject, fProject);
|
manager.addResourceToRefresh(fProject, fProject);
|
||||||
RefreshExclusion exclusion1 = new TestExclusion();
|
RefreshExclusion exclusion1 = new TestExclusion();
|
||||||
manager.addExclusion(fProject, exclusion1);
|
manager.addExclusion(fProject, exclusion1);
|
||||||
|
@ -215,6 +227,8 @@ public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
public void testPersistAndLoad() {
|
public void testPersistAndLoad() {
|
||||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||||
|
manager.clearAllData();
|
||||||
|
|
||||||
manager.addResourceToRefresh(fProject, fProject);
|
manager.addResourceToRefresh(fProject, fProject);
|
||||||
|
|
||||||
RefreshExclusion exclusion1 = new TestExclusion();
|
RefreshExclusion exclusion1 = new TestExclusion();
|
||||||
|
@ -294,6 +308,8 @@ public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
public void testResourceExclusion() {
|
public void testResourceExclusion() {
|
||||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||||
|
manager.clearAllData();
|
||||||
|
|
||||||
manager.addResourceToRefresh(fProject, fProject);
|
manager.addResourceToRefresh(fProject, fProject);
|
||||||
|
|
||||||
// create a series of nested exclusions that include/exclude certain folders
|
// create a series of nested exclusions that include/exclude certain folders
|
||||||
|
@ -340,12 +356,73 @@ public class RefreshScopeTests extends TestCase {
|
||||||
assertEquals(true, manager.shouldResourceBeRefreshed(fFolder5));
|
assertEquals(true, manager.shouldResourceBeRefreshed(fFolder5));
|
||||||
assertEquals(false, manager.shouldResourceBeRefreshed(fFolder6));
|
assertEquals(false, manager.shouldResourceBeRefreshed(fFolder6));
|
||||||
|
|
||||||
|
// now let's create a bunch of files in these directories using java.io.File (so that we don't get
|
||||||
|
// resource deltas happening), and refresh the project according to the policy. We should only see the files
|
||||||
|
// in the same folders above when consulting the resource system
|
||||||
|
IPath path = fProject.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
path = fFolder1.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
path = fFolder2.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
path = fFolder3.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
path = fFolder4.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
path = fFolder5.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
path = fFolder6.getLocation();
|
||||||
|
createTestFile(path);
|
||||||
|
|
||||||
|
// now refresh
|
||||||
|
IWorkspaceRunnable runnable = manager.getRefreshRunnable(fProject);
|
||||||
|
try {
|
||||||
|
ResourcesPlugin.getWorkspace().run(runnable, null);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the proper resources exist in the workspace
|
||||||
|
IResource resource = fProject.getFile("foo.cpp");
|
||||||
|
assertEquals(true, resource.exists());
|
||||||
|
resource = fFolder1.getFile("foo.cpp");
|
||||||
|
assertEquals(false, resource.exists());
|
||||||
|
resource = fFolder2.getFile("foo.cpp");
|
||||||
|
assertEquals(false, resource.exists());
|
||||||
|
resource = fFolder3.getFile("foo.cpp");
|
||||||
|
assertEquals(true, resource.exists());
|
||||||
|
resource = fFolder4.getFile("foo.cpp");
|
||||||
|
assertEquals(false, resource.exists());
|
||||||
|
resource = fFolder5.getFile("foo.cpp");
|
||||||
|
assertEquals(true, resource.exists());
|
||||||
|
resource = fFolder6.getFile("foo.cpp");
|
||||||
|
assertEquals(false, resource.exists());
|
||||||
|
|
||||||
manager.clearAllData();
|
manager.clearAllData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createTestFile(IPath path) {
|
||||||
|
path = path.append("foo.cpp");
|
||||||
|
File file = new File(path.toOSString());
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testDefaults() {
|
public void testDefaults() {
|
||||||
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
RefreshScopeManager manager = RefreshScopeManager.getInstance();
|
||||||
|
manager.clearAllData();
|
||||||
|
|
||||||
// by default, a project should refresh its root
|
// by default, a project should refresh its root
|
||||||
List<IResource> resourcesToRefresh = manager.getResourcesToRefresh(fProject);
|
List<IResource> resourcesToRefresh = manager.getResourcesToRefresh(fProject);
|
||||||
|
@ -384,5 +461,9 @@ public class RefreshScopeTests extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
return new TestSuite(RefreshScopeTests.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.model.tests.ElementDeltaTests;
|
||||||
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
|
||||||
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
|
||||||
import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTests;
|
import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTests;
|
||||||
|
import org.eclipse.cdt.core.resources.tests.RefreshScopeTests;
|
||||||
import org.eclipse.cdt.core.tests.templateengine.AllTemplateEngineTests;
|
import org.eclipse.cdt.core.tests.templateengine.AllTemplateEngineTests;
|
||||||
import org.eclipse.cdt.internal.index.tests.IndexTests;
|
import org.eclipse.cdt.internal.index.tests.IndexTests;
|
||||||
import org.eclipse.cdt.internal.pdom.tests.PDOMTests;
|
import org.eclipse.cdt.internal.pdom.tests.PDOMTests;
|
||||||
|
@ -84,6 +85,8 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
||||||
|
|
||||||
suite.addTest(AllTemplateEngineTests.suite());
|
suite.addTest(AllTemplateEngineTests.suite());
|
||||||
|
|
||||||
|
suite.addTest(RefreshScopeTests.suite());
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,10 @@ import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||||
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
|
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
@ -89,6 +93,40 @@ public class RefreshScopeManager {
|
||||||
private RefreshScopeManager(){
|
private RefreshScopeManager(){
|
||||||
fClassnameToExclusionFactoryMap = new HashMap<String, RefreshExclusionFactory>();
|
fClassnameToExclusionFactoryMap = new HashMap<String, RefreshExclusionFactory>();
|
||||||
loadExtensions();
|
loadExtensions();
|
||||||
|
try {
|
||||||
|
loadSettings();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add a resource change listener that will try to load settings for projects when they open
|
||||||
|
ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
|
||||||
|
|
||||||
|
public void resourceChanged(IResourceChangeEvent event) {
|
||||||
|
IResourceDelta delta = event.getDelta();
|
||||||
|
try {
|
||||||
|
delta.accept(new IResourceDeltaVisitor() {
|
||||||
|
|
||||||
|
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||||
|
if(delta.getResource() instanceof IProject && delta.getKind() == IResourceDelta.ADDED) {
|
||||||
|
IProject project = (IProject) delta.getResource();
|
||||||
|
loadSettings(ResourcesPlugin.getWorkspace().getRoot(), project);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}, IResourceChangeEvent.POST_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void loadExtensions() {
|
public synchronized void loadExtensions() {
|
||||||
|
@ -350,6 +388,16 @@ public class RefreshScopeManager {
|
||||||
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
|
||||||
for (IProject project : workspaceRoot.getProjects()) {
|
for (IProject project : workspaceRoot.getProjects()) {
|
||||||
|
loadSettings(workspaceRoot, project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param workspaceRoot
|
||||||
|
* @param project
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
private void loadSettings(IWorkspaceRoot workspaceRoot, IProject project) throws CoreException {
|
||||||
if (project.isOpen()) {
|
if (project.isOpen()) {
|
||||||
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
if (project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
String xmlString = project.getPersistentProperty(REFRESH_SCOPE_PROPERTY_NAME);
|
String xmlString = project.getPersistentProperty(REFRESH_SCOPE_PROPERTY_NAME);
|
||||||
|
@ -441,7 +489,6 @@ public class RefreshScopeManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void clearExclusions(IResource resource) {
|
public void clearExclusions(IResource resource) {
|
||||||
getResourcesToExclusionsMap();
|
getResourcesToExclusionsMap();
|
||||||
|
@ -459,6 +506,7 @@ public class RefreshScopeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearAllExclusions() {
|
public void clearAllExclusions() {
|
||||||
|
if(fResourceToExclusionsMap != null)
|
||||||
fResourceToExclusionsMap.clear();
|
fResourceToExclusionsMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,25 +544,16 @@ public class RefreshScopeManager {
|
||||||
if (resource instanceof IContainer) {
|
if (resource instanceof IContainer) {
|
||||||
IContainer container = (IContainer) resource;
|
IContainer container = (IContainer) resource;
|
||||||
|
|
||||||
// get any exclusions
|
if (shouldResourceBeRefreshed(resource)) {
|
||||||
boolean isExcluded = false;
|
|
||||||
|
|
||||||
for (RefreshExclusion exclusion : exclusions) {
|
|
||||||
if (exclusion.testExclusionChain(resource)) {
|
|
||||||
isExcluded = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isExcluded) {
|
|
||||||
resource.refreshLocal(IResource.DEPTH_ONE, monitor);
|
resource.refreshLocal(IResource.DEPTH_ONE, monitor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (IResource child : container.members()) {
|
for (IResource child : container.members()) {
|
||||||
refreshResources(child, exclusions, monitor);
|
refreshResources(child, exclusions, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return runnable;
|
return runnable;
|
||||||
|
|
Loading…
Add table
Reference in a new issue