mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 133881 - Make refreshing after building optional
Fixing project close/delete and open workflows.
This commit is contained in:
parent
5465ec9a3d
commit
f4f78d731d
1 changed files with 57 additions and 18 deletions
|
@ -103,30 +103,54 @@ public class RefreshScopeManager {
|
|||
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;
|
||||
|
||||
if(event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) {
|
||||
IProject project = event.getResource().getProject();
|
||||
|
||||
try {
|
||||
if(project.exists() && project.isOpen() && project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||
clearDataForProject(project);
|
||||
}
|
||||
|
||||
} catch (CoreException e) {
|
||||
// should never happen due to checks above
|
||||
}
|
||||
);
|
||||
} catch (CoreException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IResourceDelta delta = event.getDelta();
|
||||
|
||||
if (delta != null) {
|
||||
try {
|
||||
delta.accept(new IResourceDeltaVisitor() {
|
||||
|
||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||
if (delta.getResource() instanceof IProject) {
|
||||
IProject project = (IProject) delta.getResource();
|
||||
|
||||
if (delta.getKind() == IResourceDelta.ADDED
|
||||
|| (delta.getKind() == IResourceDelta.CHANGED && (delta
|
||||
.getFlags() & IResourceDelta.OPEN) != 0)) {
|
||||
loadSettings(ResourcesPlugin.getWorkspace()
|
||||
.getRoot(), project);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
} catch (CoreException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, IResourceChangeEvent.POST_CHANGE);
|
||||
}, IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);
|
||||
}
|
||||
|
||||
public synchronized void loadExtensions() {
|
||||
|
@ -255,6 +279,7 @@ public class RefreshScopeManager {
|
|||
|
||||
if(resourceSet == null) {
|
||||
resourceSet = new LinkedHashSet<IResource>();
|
||||
fProjectToResourcesMap.put(project, resourceSet);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -517,6 +542,20 @@ public class RefreshScopeManager {
|
|||
if(fResourceToExclusionsMap != null)
|
||||
fResourceToExclusionsMap.clear();
|
||||
}
|
||||
|
||||
public void clearExclusionsForProject(IProject project) {
|
||||
for(IResource resource : fResourceToExclusionsMap.keySet()) {
|
||||
IProject project2 = resource.getProject();
|
||||
if(project2.equals(project)) {
|
||||
fResourceToExclusionsMap.remove(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clearDataForProject(IProject project) {
|
||||
clearResourcesToRefresh(project);
|
||||
clearExclusionsForProject(project);
|
||||
}
|
||||
|
||||
public ExclusionInstance getInstanceForClassName(String className) {
|
||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||
|
|
Loading…
Add table
Reference in a new issue