mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
improved binaryconfig use
This commit is contained in:
parent
a17fa3fe67
commit
d9ad522e13
7 changed files with 197 additions and 179 deletions
|
@ -1,3 +1,18 @@
|
|||
2004-10-14 David Inglis
|
||||
|
||||
Move BinaryConfig into internal.model was no need to be public, also fixed it to
|
||||
be lazy when creating parser interface.
|
||||
|
||||
* model/org/eclipse/cdt/internal/core/model/CModelManager.java
|
||||
* model/org/eclipse/cdt/internal/core/model/CProject.java
|
||||
* src/org/eclipse/cdt/core/BinaryParserConfig.java
|
||||
* src/org/eclipse/cdt/core/CCorePlugin.java
|
||||
* src/org/eclipse/cdt/core/ICExtensionReference.java
|
||||
* src/org/eclipse/cdt/internal/core/CExtensionReference.java
|
||||
|
||||
Removed
|
||||
* model/org/eclipse/cdt/internal/core/model/BinaryParserConfig.java
|
||||
|
||||
2004-10-12 Vladimir Hirsl
|
||||
|
||||
Fix for PR 69604 [Templates] Instantiating template with deferred template instance
|
||||
|
|
|
@ -8,26 +8,39 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core;
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.IBinaryParser;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/*
|
||||
* BinaryParserConfig
|
||||
*/
|
||||
public class BinaryParserConfig {
|
||||
|
||||
IBinaryParser parser;
|
||||
String id;
|
||||
private IBinaryParser parser;
|
||||
private final String id;
|
||||
private final ICExtensionReference ref;
|
||||
|
||||
public BinaryParserConfig(IBinaryParser parser, String id) {
|
||||
this.parser = parser;
|
||||
this.id = id;
|
||||
this.ref = null;
|
||||
}
|
||||
|
||||
public BinaryParserConfig(ICExtensionReference ref) {
|
||||
this.ref = ref;
|
||||
this.id = ref.getID();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public IBinaryParser getBinaryParser() {
|
||||
public IBinaryParser getBinaryParser() throws CoreException {
|
||||
if (parser == null) {
|
||||
parser = (IBinaryParser)ref.createExtension();
|
||||
}
|
||||
return parser;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.BinaryParserConfig;
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CDescriptorEvent;
|
||||
|
@ -25,6 +24,7 @@ import org.eclipse.cdt.core.CProjectNature;
|
|||
import org.eclipse.cdt.core.IBinaryParser;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICDescriptorListener;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||
|
@ -182,7 +182,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
return cModel;
|
||||
}
|
||||
|
||||
public ICElement create (IPath path) {
|
||||
public ICElement create(IPath path) {
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
// Assume it is fullpath relative to workspace
|
||||
IResource res = root.findMember(path);
|
||||
|
@ -203,7 +203,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
return create(res, null);
|
||||
}
|
||||
|
||||
public ICElement create (IResource resource, ICProject cproject) {
|
||||
public ICElement create(IResource resource, ICProject cproject) {
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (celement == null)
|
||||
return;
|
||||
|
||||
//System.out.println("RELEASE " + celement.getElementName());
|
||||
//System.out.println("RELEASE " + celement.getElementName());
|
||||
|
||||
// Remove from the containers.
|
||||
if (celement instanceof IParent) {
|
||||
|
@ -505,31 +505,51 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
|
||||
public BinaryParserConfig[] getBinaryParser(IProject project) {
|
||||
try {
|
||||
BinaryParserConfig[] parsers = (BinaryParserConfig[])binaryParsersMap.get(project);
|
||||
if (parsers == null) {
|
||||
parsers = CCorePlugin.getDefault().getBinaryParserConfigs(project);
|
||||
try {
|
||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(project, false);
|
||||
if (cdesc != null) {
|
||||
ICExtensionReference[] cextensions = cdesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID, true);
|
||||
if (cextensions.length > 0) {
|
||||
ArrayList list = new ArrayList(cextensions.length);
|
||||
for (int i = 0; i < cextensions.length; i++) {
|
||||
BinaryParserConfig config = new BinaryParserConfig(cextensions[i]);
|
||||
list.add(config);
|
||||
}
|
||||
parsers = new BinaryParserConfig[list.size()];
|
||||
list.toArray(parsers);
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
if (parsers == null) {
|
||||
try {
|
||||
BinaryParserConfig config = new BinaryParserConfig(CCorePlugin.getDefault().getDefaultBinaryParser(), CCorePlugin.DEFAULT_BINARY_PARSER_UNIQ_ID);
|
||||
parsers = new BinaryParserConfig[]{config};
|
||||
} catch (CoreException e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parsers != null) {
|
||||
binaryParsersMap.put(project, parsers);
|
||||
return parsers;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
IBinaryParser nullParser = new NullBinaryParser();
|
||||
BinaryParserConfig config = new BinaryParserConfig(nullParser, ""); //$NON-NLS-1$
|
||||
BinaryParserConfig[] configs = new BinaryParserConfig[] {config};
|
||||
return configs;
|
||||
return new BinaryParserConfig[0];
|
||||
}
|
||||
|
||||
public IBinaryFile createBinaryFile(IFile file) {
|
||||
BinaryParserConfig[] parsers = getBinaryParser(file.getProject());
|
||||
int hints = 0;
|
||||
for (int i = 0; i < parsers.length; i++) {
|
||||
IBinaryParser parser = parsers[i].getBinaryParser();
|
||||
IBinaryParser parser = null;
|
||||
try {
|
||||
parser = parsers[i].getBinaryParser();
|
||||
if (parser.getHintBufferSize() > hints) {
|
||||
hints = parser.getHintBufferSize();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
byte[] bytes = new byte[hints];
|
||||
if (hints > 0) {
|
||||
|
@ -553,17 +573,17 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
|
||||
for (int i = 0; i < parsers.length; i++) {
|
||||
try {
|
||||
IBinaryFile bin = parsers[i].getBinaryParser().getBinary(bytes, location);
|
||||
if (bin != null) {
|
||||
return bin;
|
||||
IBinaryParser parser = parsers[i].getBinaryParser();
|
||||
IBinaryFile binFile = parser.getBinary(bytes, location);
|
||||
if (binFile != null) {
|
||||
return binFile;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
//
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: this is a temporary hack until, the CDescriptor manager is
|
||||
* in place and could fire deltas of Parser change.
|
||||
|
@ -593,7 +613,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
|
||||
public BinaryRunner getBinaryRunner(ICProject project, boolean start) {
|
||||
BinaryRunner runner = null;
|
||||
synchronized(binaryRunners) {
|
||||
synchronized (binaryRunners) {
|
||||
runner = (BinaryRunner)binaryRunners.get(project.getProject());
|
||||
if (runner == null) {
|
||||
runner = new BinaryRunner(project.getProject());
|
||||
|
@ -611,7 +631,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
|
||||
public void removeBinaryRunner(IProject project) {
|
||||
BinaryRunner runner = (BinaryRunner) binaryRunners.remove(project);
|
||||
BinaryRunner runner = (BinaryRunner)binaryRunners.remove(project);
|
||||
if (runner != null) {
|
||||
runner.stop();
|
||||
}
|
||||
|
@ -619,8 +639,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
|
||||
public SourceMapper getSourceMapper(ICProject cProject) {
|
||||
SourceMapper mapper = null;
|
||||
synchronized(sourceMappers) {
|
||||
mapper = (SourceMapper) sourceMappers.get(cProject);
|
||||
synchronized (sourceMappers) {
|
||||
mapper = (SourceMapper)sourceMappers.get(cProject);
|
||||
if (mapper == null) {
|
||||
mapper = new SourceMapper(cProject);
|
||||
sourceMappers.put(cProject, mapper);
|
||||
|
@ -632,7 +652,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
* addElementChangedListener method comment.
|
||||
*/
|
||||
public void addElementChangedListener(IElementChangedListener listener) {
|
||||
synchronized(fElementChangedListeners) {
|
||||
synchronized (fElementChangedListeners) {
|
||||
if (!fElementChangedListeners.contains(listener)) {
|
||||
fElementChangedListeners.add(listener);
|
||||
}
|
||||
|
@ -643,7 +663,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
* removeElementChangedListener method comment.
|
||||
*/
|
||||
public void removeElementChangedListener(IElementChangedListener listener) {
|
||||
synchronized(fElementChangedListeners) {
|
||||
synchronized (fElementChangedListeners) {
|
||||
int i = fElementChangedListeners.indexOf(listener);
|
||||
if (i != -1) {
|
||||
fElementChangedListeners.remove(i);
|
||||
|
@ -675,14 +695,14 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (event.getSource() instanceof IWorkspace) {
|
||||
IResourceDelta delta = event.getDelta();
|
||||
IResource resource = event.getResource();
|
||||
switch(event.getType()){
|
||||
switch (event.getType()) {
|
||||
case IResourceChangeEvent.PRE_DELETE :
|
||||
try{
|
||||
try {
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
|
||||
this.deleting((IProject) resource);}
|
||||
}catch (CoreException e){
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -691,7 +711,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (delta != null) {
|
||||
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
|
||||
if (translatedDeltas.length > 0) {
|
||||
for (int i= 0; i < translatedDeltas.length; i++) {
|
||||
for (int i = 0; i < translatedDeltas.length; i++) {
|
||||
registerCModelDelta(translatedDeltas[i]);
|
||||
}
|
||||
}
|
||||
|
@ -710,27 +730,26 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
*/
|
||||
public void descriptorChanged(CDescriptorEvent event) {
|
||||
int flags = event.getFlags();
|
||||
if ((flags & CDescriptorEvent.EXTENSION_CHANGED) != 0) {
|
||||
if ( (flags & CDescriptorEvent.EXTENSION_CHANGED) != 0) {
|
||||
ICDescriptor cdesc = event.getDescriptor();
|
||||
if (cdesc != null) {
|
||||
IProject project = cdesc.getProject();
|
||||
try {
|
||||
String[] newIds = CCorePlugin.getDefault().getBinaryParserIds(project);
|
||||
ICExtensionReference[] newExts = CCorePlugin.getDefault().getBinaryParserExtensions(project);
|
||||
BinaryParserConfig[] currentConfigs = getBinaryParser(project);
|
||||
// anything added/removed
|
||||
if (newIds.length != currentConfigs.length) {
|
||||
if (newExts.length != currentConfigs.length) {
|
||||
resetBinaryParser(project);
|
||||
} else { // may reorder
|
||||
for (int i = 0; i < newIds.length; i++) {
|
||||
String id = newIds[i];
|
||||
if (!id.equals(currentConfigs[i].getId())) {
|
||||
for (int i = 0; i < newExts.length; i++) {
|
||||
if (!newExts[i].getID().equals(currentConfigs[i].getId())) {
|
||||
resetBinaryParser(project);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
//
|
||||
resetBinaryParser(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -762,9 +781,9 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
|
||||
IElementChangedListener[] listeners;
|
||||
int listenerCount;
|
||||
int [] listenerMask;
|
||||
int[] listenerMask;
|
||||
// Notification
|
||||
synchronized(fElementChangedListeners) {
|
||||
synchronized (fElementChangedListeners) {
|
||||
listeners = new IElementChangedListener[fElementChangedListeners.size()];
|
||||
fElementChangedListeners.toArray(listeners);
|
||||
listenerCount = listeners.length;
|
||||
|
@ -772,19 +791,19 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
|
||||
switch (eventType) {
|
||||
case DEFAULT_CHANGE_EVENT:
|
||||
case DEFAULT_CHANGE_EVENT :
|
||||
firePreAutoBuildDelta(deltaToNotify, listeners, listenerMask, listenerCount);
|
||||
firePostChangeDelta(deltaToNotify, listeners, listenerMask, listenerCount);
|
||||
fireReconcileDelta(listeners, listenerMask, listenerCount);
|
||||
break;
|
||||
case ElementChangedEvent.PRE_AUTO_BUILD:
|
||||
case ElementChangedEvent.PRE_AUTO_BUILD :
|
||||
firePreAutoBuildDelta(deltaToNotify, listeners, listenerMask, listenerCount);
|
||||
break;
|
||||
case ElementChangedEvent.POST_CHANGE:
|
||||
case ElementChangedEvent.POST_CHANGE :
|
||||
firePostChangeDelta(deltaToNotify, listeners, listenerMask, listenerCount);
|
||||
fireReconcileDelta(listeners, listenerMask, listenerCount);
|
||||
break;
|
||||
case ElementChangedEvent.POST_RECONCILE:
|
||||
case ElementChangedEvent.POST_RECONCILE :
|
||||
fireReconcileDelta(listeners, listenerMask, listenerCount);
|
||||
break;
|
||||
}
|
||||
|
@ -795,7 +814,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
|
||||
|
||||
if (VERBOSE) {
|
||||
System.out.println("FIRING PRE_AUTO_BUILD Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
System.out.println("FIRING PRE_AUTO_BUILD Delta [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
|
||||
}
|
||||
if (deltaToNotify != null) {
|
||||
|
@ -806,8 +825,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
private void firePostChangeDelta(ICElementDelta deltaToNotify, IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
|
||||
|
||||
// post change deltas
|
||||
if (VERBOSE){
|
||||
System.out.println("FIRING POST_CHANGE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
if (VERBOSE) {
|
||||
System.out.println("FIRING POST_CHANGE Delta [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
|
||||
}
|
||||
if (deltaToNotify != null) {
|
||||
|
@ -819,8 +838,8 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
|
||||
private void fireReconcileDelta(IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
|
||||
ICElementDelta deltaToNotify = mergeDeltas(this.reconcileDeltas.values());
|
||||
if (VERBOSE){
|
||||
System.out.println("FIRING POST_RECONCILE Delta ["+Thread.currentThread()+"]:"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
if (VERBOSE) {
|
||||
System.out.println("FIRING POST_RECONCILE Delta [" + Thread.currentThread() + "]:"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
System.out.println(deltaToNotify == null ? "<NONE>" : deltaToNotify.toString()); //$NON-NLS-1$
|
||||
}
|
||||
if (deltaToNotify != null) {
|
||||
|
@ -834,16 +853,17 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
|
||||
|
||||
final ElementChangedEvent extraEvent = new ElementChangedEvent(deltaToNotify, eventType);
|
||||
for (int i= 0; i < listenerCount; i++) {
|
||||
for (int i = 0; i < listenerCount; i++) {
|
||||
if (listenerMask == null || (listenerMask[i] & eventType) != 0) {
|
||||
final IElementChangedListener listener = listeners[i];
|
||||
long start = -1;
|
||||
if (VERBOSE) {
|
||||
System.out.print("Listener #" + (i+1) + "=" + listener.toString());//$NON-NLS-1$//$NON-NLS-2$
|
||||
System.out.print("Listener #" + (i + 1) + "=" + listener.toString());//$NON-NLS-1$//$NON-NLS-2$
|
||||
start = System.currentTimeMillis();
|
||||
}
|
||||
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief
|
||||
Platform.run(new ISafeRunnable() {
|
||||
|
||||
public void handleException(Throwable exception) {
|
||||
//CCorePlugin.log(exception, "Exception occurred in listener of C element change notification"); //$NON-NLS-1$
|
||||
CCorePlugin.log(exception);
|
||||
|
@ -853,7 +873,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
}
|
||||
});
|
||||
if (VERBOSE) {
|
||||
System.out.println(" -> " + (System.currentTimeMillis()-start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
System.out.println(" -> " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -868,7 +888,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
|
||||
private ICElementDelta mergeDeltas(Collection deltas) {
|
||||
|
||||
synchronized(deltas) {
|
||||
synchronized (deltas) {
|
||||
if (deltas.size() == 0)
|
||||
return null;
|
||||
if (deltas.size() == 1)
|
||||
|
@ -886,7 +906,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (cRoot.equals(element)) {
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int j = 0; j < children.length; j++) {
|
||||
CElementDelta projectDelta = (CElementDelta) children[j];
|
||||
CElementDelta projectDelta = (CElementDelta)children[j];
|
||||
rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
|
||||
insertedTree = true;
|
||||
}
|
||||
|
@ -919,15 +939,15 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (ce instanceof CModelException) {
|
||||
throw (CModelException)ce;
|
||||
} else if (ce.getStatus().getCode() == IResourceStatus.OPERATION_FAILED) {
|
||||
Throwable e= ce.getStatus().getException();
|
||||
Throwable e = ce.getStatus().getException();
|
||||
if (e instanceof CModelException) {
|
||||
throw (CModelException) e;
|
||||
throw (CModelException)e;
|
||||
}
|
||||
}
|
||||
throw new CModelException(ce);
|
||||
} finally {
|
||||
// fire only if there were no awaiting deltas (if there were, they would come from a resource modifying operation)
|
||||
// and the operation has not modified any resource
|
||||
// and the operation has not modified any resource
|
||||
if (!hadAwaitingDeltas && !operation.hasModifiedResource()) {
|
||||
fire(ElementChangedEvent.POST_CHANGE);
|
||||
} // else deltas are fired while processing the resource delta
|
||||
|
@ -983,7 +1003,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
|
||||
ICElement[] children = ((CElementInfo)existingInfo).getChildren();
|
||||
for (int i = 0, size = children.length; i < size; ++i) {
|
||||
CElement child = (CElement) children[i];
|
||||
CElement child = (CElement)children[i];
|
||||
try {
|
||||
child.close();
|
||||
} catch (CModelException e) {
|
||||
|
@ -1010,7 +1030,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
|
||||
ICElement[] children = ((CElementInfo)existingInfo).getChildren();
|
||||
for (int i = 0, size = children.length; i < size; ++i) {
|
||||
CElement child = (CElement) children[i];
|
||||
CElement child = (CElement)children[i];
|
||||
try {
|
||||
child.close();
|
||||
} catch (CModelException e) {
|
||||
|
@ -1087,7 +1107,7 @@ public class CModelManager implements IResourceChangeListener, ICDescriptorListe
|
|||
return this.fDeltaProcessor.indexManager;
|
||||
}
|
||||
|
||||
public void deleting(IProject project){
|
||||
public void deleting(IProject project) {
|
||||
// discard all indexing jobs for this project
|
||||
this.getIndexManager().discardJobs(project.getName());
|
||||
removeBinaryRunner(project);
|
||||
|
|
|
@ -19,10 +19,10 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.BinaryParserConfig;
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.IBinaryParser;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
|
||||
|
@ -202,7 +202,8 @@ public class CProject extends Openable implements ICProject {
|
|||
for (int i = 0; i < binConfigs.length; i++) {
|
||||
IBinaryFile bin;
|
||||
try {
|
||||
bin = binConfigs[i].getBinaryParser().getBinary(entry.getFullLibraryPath());
|
||||
IBinaryParser parser = binConfigs[i].getBinaryParser();
|
||||
bin = parser.getBinary(entry.getFullLibraryPath());
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive)bin);
|
||||
|
@ -211,7 +212,8 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
break;
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
} catch (IOException e) {
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -467,8 +467,8 @@ public class CCorePlugin extends Plugin {
|
|||
return getConsole(null);
|
||||
}
|
||||
|
||||
public BinaryParserConfig[] getBinaryParserConfigs(IProject project) throws CoreException {
|
||||
BinaryParserConfig configs[] = null;
|
||||
public ICExtensionReference[] getBinaryParserExtensions(IProject project) throws CoreException {
|
||||
ICExtensionReference ext[] = new ICExtensionReference[0];
|
||||
if (project != null) {
|
||||
try {
|
||||
ICDescriptor cdesc = getCProjectDescription(project);
|
||||
|
@ -476,57 +476,15 @@ public class CCorePlugin extends Plugin {
|
|||
if (cextensions.length > 0) {
|
||||
ArrayList list = new ArrayList(cextensions.length);
|
||||
for (int i = 0; i < cextensions.length; i++) {
|
||||
IBinaryParser parser = null;
|
||||
try {
|
||||
parser = (IBinaryParser) cextensions[i].createExtension();
|
||||
BinaryParserConfig config = new BinaryParserConfig(parser, cextensions[i].getID());
|
||||
list.add(config);
|
||||
} catch (CoreException e) {
|
||||
Status s = new Status(IStatus.WARNING, PLUGIN_ID, -1, "Binary Parser failure", e); //$NON-NLS-1$
|
||||
log(s);
|
||||
} catch (ClassCastException e) {
|
||||
log(e);
|
||||
list.add(cextensions[i]);
|
||||
}
|
||||
}
|
||||
configs = new BinaryParserConfig[list.size()];
|
||||
list.toArray(configs);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (configs == null) {
|
||||
IBinaryParser parser = getDefaultBinaryParser();
|
||||
if (parser != null) {
|
||||
BinaryParserConfig config = new BinaryParserConfig(parser, DEFAULT_BINARY_PARSER_UNIQ_ID);
|
||||
configs = new BinaryParserConfig[] {config};
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
public String[] getBinaryParserIds(IProject project) throws CoreException {
|
||||
String ids[] = null;
|
||||
if (project != null) {
|
||||
try {
|
||||
ICDescriptor cdesc = getCProjectDescription(project);
|
||||
ICExtensionReference[] cextensions = cdesc.get(BINARY_PARSER_UNIQ_ID, true);
|
||||
if (cextensions.length > 0) {
|
||||
ArrayList list = new ArrayList(cextensions.length);
|
||||
for (int i = 0; i < cextensions.length; i++) {
|
||||
list.add(cextensions[i].getID());
|
||||
}
|
||||
ids = new String[list.size()];
|
||||
list.toArray(ids);
|
||||
ext = (ICExtensionReference[])list.toArray(ext);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
if (ids == null) {
|
||||
ids = new String[] {DEFAULT_BINARY_PARSER_UNIQ_ID};
|
||||
}
|
||||
return ids;
|
||||
return ext;
|
||||
}
|
||||
|
||||
public IBinaryParser[] getBinaryParser(IProject project) throws CoreException {
|
||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core;
|
|||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExecutableExtension;
|
||||
|
||||
public interface ICExtensionReference {
|
||||
|
||||
|
@ -40,6 +41,12 @@ public interface ICExtensionReference {
|
|||
*/
|
||||
public String getExtensionData(String key);
|
||||
|
||||
/**
|
||||
* Returns the project descriptor which this extension reference belongs to.
|
||||
* @return the ICDescriptor
|
||||
*/
|
||||
public ICDescriptor getCDescriptor();
|
||||
|
||||
/**
|
||||
* Creates and returns a new instance of the cextension executable
|
||||
* identified by the <run> attribute of the cextension.
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
* Copyright (c) 2000, 2004 QNX Software Systems and others. All rights
|
||||
* reserved. This program and the accompanying materials are made available
|
||||
* under the terms of the Common Public License v1.0 which accompanies this
|
||||
* distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
* Contributors: QNX Software Systems - Initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
import org.eclipse.cdt.core.CDescriptorEvent;
|
||||
import org.eclipse.cdt.core.ICDescriptor;
|
||||
import org.eclipse.cdt.core.ICExtension;
|
||||
import org.eclipse.cdt.core.ICExtensionReference;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -36,6 +35,10 @@ public class CExtensionReference implements ICExtensionReference {
|
|||
return fId;
|
||||
}
|
||||
|
||||
public ICDescriptor getCDescriptor() {
|
||||
return fDescriptor;
|
||||
}
|
||||
|
||||
private CExtensionInfo getInfo() {
|
||||
return fDescriptor.getInfo(this);
|
||||
}
|
||||
|
@ -45,7 +48,7 @@ public class CExtensionReference implements ICExtensionReference {
|
|||
return true;
|
||||
}
|
||||
if (obj instanceof CExtensionReference) {
|
||||
CExtensionReference ext = (CExtensionReference) obj;
|
||||
CExtensionReference ext = (CExtensionReference)obj;
|
||||
if (ext.fExtPoint.equals(fExtPoint) && ext.fId.equals(fId)) {
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue