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() {
|
ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
|
||||||
|
|
||||||
public void resourceChanged(IResourceChangeEvent event) {
|
public void resourceChanged(IResourceChangeEvent event) {
|
||||||
IResourceDelta delta = event.getDelta();
|
|
||||||
try {
|
if(event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE) {
|
||||||
delta.accept(new IResourceDeltaVisitor() {
|
IProject project = event.getResource().getProject();
|
||||||
|
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
try {
|
||||||
if(delta.getResource() instanceof IProject && delta.getKind() == IResourceDelta.ADDED) {
|
if(project.exists() && project.isOpen() && project.hasNature(CProjectNature.C_NATURE_ID)) {
|
||||||
IProject project = (IProject) delta.getResource();
|
clearDataForProject(project);
|
||||||
loadSettings(ResourcesPlugin.getWorkspace().getRoot(), project);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// should never happen due to checks above
|
||||||
}
|
}
|
||||||
);
|
|
||||||
} catch (CoreException e) {
|
return;
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public synchronized void loadExtensions() {
|
||||||
|
@ -255,6 +279,7 @@ public class RefreshScopeManager {
|
||||||
|
|
||||||
if(resourceSet == null) {
|
if(resourceSet == null) {
|
||||||
resourceSet = new LinkedHashSet<IResource>();
|
resourceSet = new LinkedHashSet<IResource>();
|
||||||
|
fProjectToResourcesMap.put(project, resourceSet);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +542,20 @@ public class RefreshScopeManager {
|
||||||
if(fResourceToExclusionsMap != null)
|
if(fResourceToExclusionsMap != null)
|
||||||
fResourceToExclusionsMap.clear();
|
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) {
|
public ExclusionInstance getInstanceForClassName(String className) {
|
||||||
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
RefreshExclusionFactory factory = getFactoryForClassName(className);
|
||||||
|
|
Loading…
Add table
Reference in a new issue