mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Bug 137959 - Added struct kind to PDOMCPPClassType.
Also cleaned up the firing of PDOM change events so that they happen on each write lock release.
This commit is contained in:
parent
c3aab566fd
commit
7626fb1115
10 changed files with 56 additions and 43 deletions
|
@ -53,7 +53,7 @@ public class PDOM extends PlatformObject
|
|||
|
||||
private Database db;
|
||||
|
||||
public static final int VERSION = 6;
|
||||
public static final int VERSION = 7;
|
||||
// 0 - the beginning of it all
|
||||
// 1 - first change to kick off upgrades
|
||||
// 2 - added file inclusions
|
||||
|
@ -61,6 +61,7 @@ public class PDOM extends PlatformObject
|
|||
// 4 - added parameters in C++
|
||||
// 5 - added types and restructured nodes a bit
|
||||
// 6 - function style macros.
|
||||
// 7 - class key
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
|
@ -124,7 +125,7 @@ public class PDOM extends PlatformObject
|
|||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public void fireChange() {
|
||||
private void fireChange() {
|
||||
if (listeners == null)
|
||||
return;
|
||||
Iterator i = listeners.iterator();
|
||||
|
@ -334,6 +335,7 @@ public class PDOM extends PlatformObject
|
|||
++lockCount;
|
||||
mutex.notifyAll();
|
||||
}
|
||||
fireChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,14 +35,24 @@ import org.eclipse.core.runtime.CoreException;
|
|||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType, ICPPClassScope {
|
||||
public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
||||
ICPPClassScope {
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMMemberOwner.RECORD_SIZE + 0;
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
private static final int KEY = PDOMMemberOwner.RECORD_SIZE + 0; // byte
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMMemberOwner.RECORD_SIZE + 1;
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, IASTName name)
|
||||
throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
int key = 0;
|
||||
if (binding instanceof ICPPClassType) // not sure why it wouldn't
|
||||
key = ((ICPPClassType) binding).getKey();
|
||||
pdom.getDB().putByte(record + KEY, (byte) key);
|
||||
}
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, int bindingRecord) {
|
||||
|
@ -56,7 +66,7 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
public int getNodeType() {
|
||||
return PDOMCPPLinkage.CPPCLASSTYPE;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
if (type instanceof PDOMBinding)
|
||||
return record == ((PDOMBinding)type).getRecord();
|
||||
|
@ -116,8 +126,12 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
}
|
||||
|
||||
public int getKey() throws DOMException {
|
||||
// TODO
|
||||
return ICPPClassType.k_class;
|
||||
try {
|
||||
return pdom.getDB().getByte(record + KEY);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICPPClassType.k_class; // or something
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
|
@ -135,7 +149,7 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
public ICPPClassType getClassType() {
|
||||
return null;
|
||||
// TODO - do we need the real type?
|
||||
//throw new PDOMNotImplementedError();
|
||||
// throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPMethod[] getImplicitMethods() {
|
||||
|
@ -201,5 +215,5 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
public void setFullyCached(boolean b) throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -91,8 +91,6 @@ public class CtagsHandleDelta extends CtagsIndexerJob {
|
|||
return e.getStatus();
|
||||
} catch (InterruptedException e) {
|
||||
return Status.CANCEL_STATUS;
|
||||
} finally {
|
||||
pdom.fireChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,6 @@ public class CtagsReindex extends CtagsIndexerJob {
|
|||
return e.getStatus();
|
||||
} finally {
|
||||
monitor.done();
|
||||
pdom.fireChange();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
|
|
@ -151,8 +151,6 @@ class PDOMFastHandleDelta extends PDOMFastIndexerJob {
|
|||
} finally {
|
||||
pdom.releaseWriteLock();
|
||||
}
|
||||
|
||||
pdom.fireChange();
|
||||
}
|
||||
|
||||
protected void removeTU(ITranslationUnit tu) throws CoreException, InterruptedException {
|
||||
|
|
|
@ -68,9 +68,6 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
|
|||
} finally {
|
||||
pdom.releaseWriteLock();
|
||||
}
|
||||
|
||||
// Tell the world
|
||||
pdom.fireChange();
|
||||
}
|
||||
|
||||
protected void addSymbols(ILanguage language, IASTTranslationUnit ast) throws InterruptedException, CoreException {
|
||||
|
|
|
@ -123,10 +123,6 @@ public abstract class PDOMFullIndexerJob implements IPDOMIndexerTask {
|
|||
}
|
||||
};
|
||||
});;
|
||||
|
||||
// Tell the world
|
||||
pdom.fireChange();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -52,9 +52,17 @@ public class PDOMNullIndexer implements IPDOMIndexer {
|
|||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
pdom.clear();
|
||||
pdom.fireChange();
|
||||
return Status.OK_STATUS;
|
||||
try {
|
||||
pdom.acquireWriteLock();
|
||||
pdom.clear();
|
||||
return Status.OK_STATUS;
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
} catch (InterruptedException e) {
|
||||
return Status.CANCEL_STATUS;
|
||||
} finally {
|
||||
pdom.releaseWriteLock();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
|
|
|
@ -57,8 +57,23 @@ public class IndexLabelProvider extends LabelProvider {
|
|||
desc = CElementImageProvider.getVariableImageDescriptor();
|
||||
else if (element instanceof IFunction)
|
||||
desc = CElementImageProvider.getFunctionImageDescriptor();
|
||||
else if (element instanceof ICPPClassType)
|
||||
desc = CElementImageProvider.getClassImageDescriptor();
|
||||
else if (element instanceof ICPPClassType) {
|
||||
try {
|
||||
switch (((ICPPClassType)element).getKey()) {
|
||||
case ICPPClassType.k_class:
|
||||
desc = CElementImageProvider.getClassImageDescriptor();
|
||||
break;
|
||||
case ICPPClassType.k_struct:
|
||||
desc = CElementImageProvider.getStructImageDescriptor();
|
||||
break;
|
||||
case ICPPClassType.k_union:
|
||||
desc = CElementImageProvider.getUnionImageDescriptor();
|
||||
break;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
else if (element instanceof ICompositeType)
|
||||
desc = CElementImageProvider.getStructImageDescriptor();
|
||||
else if (element instanceof ICPPNamespace)
|
||||
|
|
|
@ -402,20 +402,6 @@ public class IndexView extends ViewPart implements PDOM.IListener, IElementChang
|
|||
viewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
viewer.refresh();
|
||||
// ICModel model = CoreModel.getDefault().getCModel();
|
||||
// viewer.setInput(model);
|
||||
// try {
|
||||
// ICProject[] cprojects = model.getCProjects();
|
||||
// int n = 0;
|
||||
// for (int i = 0; i < cprojects.length; ++i) {
|
||||
// PDOMDatabase pdom = (PDOMDatabase)PDOM.getPDOM(cprojects[i].getProject());
|
||||
// if (pdom != null)
|
||||
// ++n;
|
||||
// }
|
||||
// viewer.setChildCount(model, n);
|
||||
// } catch (CModelException e) {
|
||||
// CUIPlugin.getDefault().log(e);
|
||||
// }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue