1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00
David Inglis 2004-07-15 17:00:02 +00:00
parent 0336349ebe
commit 6f08973e2d
6 changed files with 28 additions and 72 deletions

View file

@ -44,7 +44,7 @@ public class ArchiveContainer extends Openable implements IArchiveContainer {
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
throws CModelException {
// this will bootstrap/start the runner for the project.
CModelManager.getDefault().getBinaryRunner(getCProject());
CModelManager.getDefault().getBinaryRunner(getCProject(), true);
return true;
}

View file

@ -20,7 +20,7 @@ public class ArchiveContainerInfo extends OpenableInfo {
}
synchronized void sync() {
BinaryRunner runner = CModelManager.getDefault().getBinaryRunner(getElement().getCProject());
BinaryRunner runner = CModelManager.getDefault().getBinaryRunner(getElement().getCProject(), true);
if (runner != null) {
runner.waitIfRunning();
}

View file

@ -54,7 +54,7 @@ public class BinaryContainer extends Openable implements IBinaryContainer {
protected boolean buildStructure(OpenableInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource)
throws CModelException {
// this will bootstrap/start the runner for the project.
CModelManager.getDefault().getBinaryRunner(getCProject());
CModelManager.getDefault().getBinaryRunner(getCProject(), true);
return true;
}

View file

@ -20,7 +20,7 @@ public class BinaryContainerInfo extends OpenableInfo {
}
synchronized void sync() {
BinaryRunner runner = CModelManager.getDefault().getBinaryRunner(getElement().getCProject());
BinaryRunner runner = CModelManager.getDefault().getBinaryRunner(getElement().getCProject(), true);
if (runner != null) {
runner.waitIfRunning();
}

View file

@ -152,8 +152,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
// Register to the workspace;
ResourcesPlugin.getWorkspace().addResourceChangeListener(factory,
IResourceChangeEvent.PRE_BUILD
| IResourceChangeEvent.POST_CHANGE
IResourceChangeEvent.POST_CHANGE
| IResourceChangeEvent.PRE_DELETE
| IResourceChangeEvent.PRE_CLOSE);
@ -585,14 +584,16 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
}
public BinaryRunner getBinaryRunner(ICProject project) {
public BinaryRunner getBinaryRunner(ICProject project, boolean start) {
BinaryRunner runner = null;
synchronized(binaryRunners) {
runner = (BinaryRunner)binaryRunners.get(project.getProject());
if (runner == null) {
runner = new BinaryRunner(project.getProject());
binaryRunners.put(project.getProject(), runner);
runner.start();
if (start) {
runner.start();
}
}
}
return runner;
@ -601,6 +602,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
public void removeBinaryRunner(ICProject cproject) {
removeBinaryRunner(cproject.getProject());
}
public void removeBinaryRunner(IProject project) {
BinaryRunner runner = (BinaryRunner) binaryRunners.remove(project);
if (runner != null) {
@ -677,13 +679,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
break;
case IResourceChangeEvent.PRE_BUILD :
// No need now.
if(delta != null) {
this.checkProjectsBeingAddedOrRemoved(delta);
}
break;
case IResourceChangeEvent.POST_CHANGE :
try {
if (delta != null) {
@ -928,52 +923,6 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
}
}
/**
* Process the given delta and look for projects being added, opened,
* or closed
*/
public void checkProjectsBeingAddedOrRemoved(IResourceDelta delta) {
IResource resource = delta.getResource();
switch (resource.getType()) {
case IResource.ROOT :
if (this.cProjectsCache == null) {
try {
this.cProjectsCache = this.getCModel().getCProjects();
} catch (CModelException e) {
}
}
IResourceDelta[] children = delta.getAffectedChildren();
for (int i = 0, length = children.length; i < length; i++) {
this.checkProjectsBeingAddedOrRemoved(children[i]);
}
break;
case IResource.PROJECT :
if (0 != (delta.getFlags() & IResourceDelta.OPEN)) {
IProject project = (IProject) resource;
if (!project.isOpen()) {
// project closing... stop the runner.
BinaryRunner runner = (BinaryRunner)binaryRunners.get(project);
if (runner != null ) {
runner.stop();
}
} else {
if ( binaryRunners.get(project) == null ) {
// project opening... lets add the runner to the
// map but no need to start it since the deltas
// will populate containers
binaryRunners.put(project, new BinaryRunner(project));
}
}
} else if (0 != (delta.getFlags() & IResourceDelta.REMOVED)) {
IProject project = (IProject) resource;
removeBinaryRunner(project);
binaryParsersMap.remove(project);
}
break;
}
}
/**
* Returns the set of elements which are out of synch with their buffers.
*/
@ -1125,6 +1074,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
public void deleting(IProject project){
// discard all indexing jobs for this project
this.getIndexManager().discardJobs(project.getName());
removeBinaryRunner(project);
}
}

View file

@ -428,7 +428,7 @@ public class DeltaProcessor {
try {
IResource resource = delta.getResource();
ICElement current = createElement(resource);
updateChildren = updateCurrentDeltaAndIndex(delta);
updateChildren = updateCurrentDeltaAndIndex(current, delta);
if (current == null || current instanceof ISourceRoot) {
nonCResourcesChanged(parent, delta);
} else if (current instanceof ICProject) {
@ -437,7 +437,8 @@ public class DeltaProcessor {
if (!cprj.getProject().isOpen() || cModel.findCProject(cprj.getProject()) == null) {
nonCResourcesChanged(parent, delta);
}
} else {
}
if (current != null) {
parent = current;
}
} catch (CModelException e) {
@ -489,10 +490,9 @@ public class DeltaProcessor {
* Returns whether the children of the given delta must be processed.
* @throws a CModelException if the delta doesn't correspond to a c element of the given type.
*/
private boolean updateCurrentDeltaAndIndex(IResourceDelta delta) throws CModelException {
private boolean updateCurrentDeltaAndIndex(ICElement element, IResourceDelta delta) throws CModelException {
IResource resource = delta.getResource();
ICElement element = createElement(resource);
switch (delta.getKind()) {
case IResourceDelta.ADDED :
@ -500,7 +500,7 @@ public class DeltaProcessor {
updateIndexAddResource(element, delta);
elementAdded(element, delta);
}
return false;
return true;
case IResourceDelta.REMOVED :
if (element != null) {
@ -523,15 +523,21 @@ public class DeltaProcessor {
} else if (resource.getType() == IResource.PROJECT) {
if ((flags & IResourceDelta.OPEN) != 0) {
// project has been opened or closed
IProject res = (IProject)resource;
IProject project = (IProject)resource;
if (element != null) {
if (res.isOpen()) {
if (project.isOpen()) {
if ( CoreModel.hasCNature(project) ) {
// project opening... lets add the runner to the
// map but no need to start it since the deltas
// will populate containers
CModelManager.getDefault().getBinaryRunner((ICProject)element, false);
}
elementOpened(element, delta);
updateIndexAddResource(element, delta);
} else {
elementClosed(element, delta);
updateIndexRemoveResource(element, delta);
return true;
}
elementClosed(element, delta);
updateIndexRemoveResource(element, delta);
//Don't process children
return false;
}
@ -552,7 +558,7 @@ public class DeltaProcessor {
elementRemoved(element, delta);
updateIndexRemoveResource(element, delta);
}
return false;
return true;
}
}
}