mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-27 02:45:32 +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;
|
private Database db;
|
||||||
|
|
||||||
public static final int VERSION = 17;
|
public static final int VERSION = 18;
|
||||||
// 0 - the beginning of it all
|
// 0 - the beginning of it all
|
||||||
// 1 - first change to kick off upgrades
|
// 1 - first change to kick off upgrades
|
||||||
// 2 - added file inclusions
|
// 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).
|
// 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
|
// 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.
|
// 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 LINKAGES = Database.DATA_AREA;
|
||||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
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) {
|
public void enqueue(IPDOMIndexerTask subjob) {
|
||||||
boolean notifyBusy= false;
|
|
||||||
synchronized (fTaskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
fTaskQueue.addLast(subjob);
|
fTaskQueue.addLast(subjob);
|
||||||
if (fIndexerJob == null) {
|
if (fIndexerJob == null) {
|
||||||
|
@ -429,22 +428,18 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
fCompletedHeaders= 0;
|
fCompletedHeaders= 0;
|
||||||
fIndexerJob = new PDOMIndexerJob(this);
|
fIndexerJob = new PDOMIndexerJob(this);
|
||||||
fIndexerJob.schedule();
|
fIndexerJob.schedule();
|
||||||
notifyBusy= true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (notifyBusy) {
|
|
||||||
notifyState(IndexerStateEvent.STATE_BUSY);
|
notifyState(IndexerStateEvent.STATE_BUSY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IPDOMIndexerTask getNextTask() {
|
IPDOMIndexerTask getNextTask() {
|
||||||
boolean idle= false;
|
|
||||||
IPDOMIndexerTask result= null;
|
IPDOMIndexerTask result= null;
|
||||||
synchronized (fTaskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
if (fTaskQueue.isEmpty()) {
|
if (fTaskQueue.isEmpty()) {
|
||||||
fCurrentTask= null;
|
fCurrentTask= null;
|
||||||
fIndexerJob= null;
|
fIndexerJob= null;
|
||||||
idle= true;
|
notifyState(IndexerStateEvent.STATE_IDLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (fCurrentTask != null) {
|
if (fCurrentTask != null) {
|
||||||
|
@ -454,31 +449,24 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
|
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (idle) {
|
|
||||||
notifyState(IndexerStateEvent.STATE_IDLE);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cancelledJob(boolean byManager) {
|
void cancelledJob(boolean byManager) {
|
||||||
boolean idle= false;
|
|
||||||
synchronized (fTaskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
fCurrentTask= null;
|
fCurrentTask= null;
|
||||||
if (!byManager) {
|
if (!byManager) {
|
||||||
fTaskQueue.clear();
|
fTaskQueue.clear();
|
||||||
}
|
}
|
||||||
idle= fTaskQueue.isEmpty();
|
if (fTaskQueue.isEmpty()) {
|
||||||
if (idle) {
|
|
||||||
fIndexerJob= null;
|
fIndexerJob= null;
|
||||||
|
notifyState(IndexerStateEvent.STATE_IDLE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fIndexerJob = new PDOMIndexerJob(this);
|
fIndexerJob = new PDOMIndexerJob(this);
|
||||||
fIndexerJob.schedule();
|
fIndexerJob.schedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (idle) {
|
|
||||||
notifyState(IndexerStateEvent.STATE_IDLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIndexerIdle() {
|
public boolean isIndexerIdle() {
|
||||||
|
@ -599,7 +587,6 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyState(final int state) {
|
private void notifyState(final int state) {
|
||||||
assert !Thread.holdsLock(fTaskQueueMutex);
|
|
||||||
if (state == IndexerStateEvent.STATE_IDLE) {
|
if (state == IndexerStateEvent.STATE_IDLE) {
|
||||||
synchronized(fTaskQueueMutex) {
|
synchronized(fTaskQueueMutex) {
|
||||||
fTaskQueueMutex.notifyAll();
|
fTaskQueueMutex.notifyAll();
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
@ -206,4 +207,16 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
||||||
public boolean mayHaveChildren() {
|
public boolean mayHaveChildren() {
|
||||||
return false;
|
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.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
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.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
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.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||||
|
@ -37,13 +41,19 @@ import org.eclipse.core.runtime.Status;
|
||||||
* @author Doug Schaefer
|
* @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;
|
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 {
|
public PDOMCStructure(PDOM pdom, PDOMNode parent, ICompositeType compType) throws CoreException {
|
||||||
super(pdom, parent, compType.getNameCharArray());
|
super(pdom, parent, compType.getNameCharArray());
|
||||||
// linked list is initialized by malloc zeroing allocated storage
|
// 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) {
|
public PDOMCStructure(PDOM pdom, int record) {
|
||||||
|
@ -68,7 +78,12 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOM
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getKey() throws DOMException {
|
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 {
|
private static class GetFields implements IPDOMVisitor {
|
||||||
|
@ -155,4 +170,20 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOM
|
||||||
public boolean mayHaveChildren() {
|
public boolean mayHaveChildren() {
|
||||||
return true;
|
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 java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
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.IPDOMMemberOwner;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
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.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.PDOMNode;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -304,18 +302,6 @@ ICPPClassScope, IPDOMMemberOwner {
|
||||||
return this;
|
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 {
|
public void addChild(PDOMNode member) throws CoreException {
|
||||||
addMember(member);
|
addMember(member);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
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.IASTNamedTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
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.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
@ -229,12 +227,6 @@ implements ICPPNamespace, ICPPNamespaceScope {
|
||||||
return visitor.getResult();
|
return visitor.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IScope getParent() throws DOMException {
|
|
||||||
// TODO
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFullyCached() throws DOMException {
|
public boolean isFullyCached() throws DOMException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -244,6 +236,5 @@ implements ICPPNamespace, ICPPNamespaceScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getMemberBindings() throws DOMException {fail(); return null;}
|
public IBinding[] getMemberBindings() throws DOMException {fail(); return null;}
|
||||||
public IName getScopeName() throws DOMException {fail(); return null;}
|
|
||||||
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue