mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Index: Let PDOMCStructure implement ICCompositeTypeScope
This commit is contained in:
parent
b8e36d1cae
commit
96dc647bc7
6 changed files with 53 additions and 44 deletions
|
@ -64,7 +64,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
|
||||
private Database db;
|
||||
|
||||
public static final int VERSION = 17;
|
||||
public static final int VERSION = 18;
|
||||
// 0 - the beginning of it all
|
||||
// 1 - first change to kick off upgrades
|
||||
// 2 - added file inclusions
|
||||
|
@ -83,6 +83,7 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
// 15 - fixed offsets for pointer types and qualifier types and PDOMCPPVariable (bug 160540).
|
||||
// 16 - have PDOMCPPField store type information, and PDOMCPPNamespaceAlias store what it is aliasing
|
||||
// 17 - use single linked list for names in file, adds a link to enclosing defintion name.
|
||||
// 18 - distinction between c-unions and c-structs.
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
|
|
|
@ -421,7 +421,6 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
}
|
||||
|
||||
public void enqueue(IPDOMIndexerTask subjob) {
|
||||
boolean notifyBusy= false;
|
||||
synchronized (fTaskQueueMutex) {
|
||||
fTaskQueue.addLast(subjob);
|
||||
if (fIndexerJob == null) {
|
||||
|
@ -429,22 +428,18 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
fCompletedHeaders= 0;
|
||||
fIndexerJob = new PDOMIndexerJob(this);
|
||||
fIndexerJob.schedule();
|
||||
notifyBusy= true;
|
||||
notifyState(IndexerStateEvent.STATE_BUSY);
|
||||
}
|
||||
}
|
||||
if (notifyBusy) {
|
||||
notifyState(IndexerStateEvent.STATE_BUSY);
|
||||
}
|
||||
}
|
||||
|
||||
IPDOMIndexerTask getNextTask() {
|
||||
boolean idle= false;
|
||||
IPDOMIndexerTask result= null;
|
||||
synchronized (fTaskQueueMutex) {
|
||||
if (fTaskQueue.isEmpty()) {
|
||||
fCurrentTask= null;
|
||||
fIndexerJob= null;
|
||||
idle= true;
|
||||
notifyState(IndexerStateEvent.STATE_IDLE);
|
||||
}
|
||||
else {
|
||||
if (fCurrentTask != null) {
|
||||
|
@ -454,31 +449,24 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
|
||||
}
|
||||
}
|
||||
if (idle) {
|
||||
notifyState(IndexerStateEvent.STATE_IDLE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void cancelledJob(boolean byManager) {
|
||||
boolean idle= false;
|
||||
synchronized (fTaskQueueMutex) {
|
||||
fCurrentTask= null;
|
||||
if (!byManager) {
|
||||
fTaskQueue.clear();
|
||||
}
|
||||
idle= fTaskQueue.isEmpty();
|
||||
if (idle) {
|
||||
if (fTaskQueue.isEmpty()) {
|
||||
fIndexerJob= null;
|
||||
notifyState(IndexerStateEvent.STATE_IDLE);
|
||||
}
|
||||
else {
|
||||
fIndexerJob = new PDOMIndexerJob(this);
|
||||
fIndexerJob.schedule();
|
||||
}
|
||||
}
|
||||
if (idle) {
|
||||
notifyState(IndexerStateEvent.STATE_IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isIndexerIdle() {
|
||||
|
@ -599,7 +587,6 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
|||
}
|
||||
|
||||
private void notifyState(final int state) {
|
||||
assert !Thread.holdsLock(fTaskQueueMutex);
|
||||
if (state == IndexerStateEvent.STATE_IDLE) {
|
||||
synchronized(fTaskQueueMutex) {
|
||||
fTaskQueueMutex.notifyAll();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
|
@ -206,4 +207,16 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
public boolean mayHaveChildren() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IName getScopeName() throws DOMException {
|
||||
try {
|
||||
PDOMName name = getFirstDefinition();
|
||||
if (name == null)
|
||||
name = getFirstDeclaration();
|
||||
return name;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,14 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
|
@ -37,13 +41,19 @@ import org.eclipse.core.runtime.Status;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOMMemberOwner {
|
||||
public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCompositeTypeScope, IPDOMMemberOwner {
|
||||
private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||
private static final int KEY = MEMBERLIST + 4; // byte
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
|
||||
|
||||
public PDOMCStructure(PDOM pdom, PDOMNode parent, ICompositeType compType) throws CoreException {
|
||||
super(pdom, parent, compType.getNameCharArray());
|
||||
// linked list is initialized by malloc zeroing allocated storage
|
||||
try {
|
||||
pdom.getDB().putByte(record + KEY, (byte) compType.getKey());
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
}
|
||||
|
||||
public PDOMCStructure(PDOM pdom, int record) {
|
||||
|
@ -68,7 +78,12 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOM
|
|||
}
|
||||
|
||||
public int getKey() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
try {
|
||||
return pdom.getDB().getByte(record + KEY);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return ICompositeType.k_struct; // or something
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetFields implements IPDOMVisitor {
|
||||
|
@ -155,4 +170,20 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOM
|
|||
public boolean mayHaveChildren() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ICompositeType getCompositeType() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public IBinding getBinding(char[] name) throws DOMException {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||
fail(); return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
|
@ -52,7 +51,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.FindEquivalentBinding;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -304,18 +302,6 @@ ICPPClassScope, IPDOMMemberOwner {
|
|||
return this;
|
||||
}
|
||||
|
||||
public IName getScopeName() throws DOMException {
|
||||
try {
|
||||
PDOMName name = getFirstDefinition();
|
||||
if (name == null)
|
||||
name = getFirstDefinition();
|
||||
return name;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
addMember(member);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
|
@ -23,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
|
@ -229,12 +227,6 @@ implements ICPPNamespace, ICPPNamespaceScope {
|
|||
return visitor.getResult();
|
||||
}
|
||||
|
||||
|
||||
public IScope getParent() throws DOMException {
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isFullyCached() throws DOMException {
|
||||
return true;
|
||||
}
|
||||
|
@ -244,6 +236,5 @@ implements ICPPNamespace, ICPPNamespaceScope {
|
|||
}
|
||||
|
||||
public IBinding[] getMemberBindings() throws DOMException {fail(); return null;}
|
||||
public IName getScopeName() throws DOMException {fail(); return null;}
|
||||
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue