1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

PDOM - Stoped the PDOMUpdator from running on projects that don't have it turned on. Speed up in adaptBinding. Started recording types for variables, starting with PDOMCPPVariables.

This commit is contained in:
Doug Schaefer 2006-01-24 17:29:52 +00:00
parent 910021b305
commit 6a0b94fd93
5 changed files with 46 additions and 11 deletions

View file

@ -139,13 +139,17 @@ public class PDOMUpdator extends Job {
} }
private void processDelta(ICElementDelta delta) { private void processDelta(ICElementDelta delta) {
// First make sure this project is PDOMable
ICElement element = delta.getElement();
if (element instanceof ICProject && PDOM.getPDOM(((ICProject)element).getProject()) == null)
return;
// process the children first // process the children first
ICElementDelta[] children = delta.getAffectedChildren(); ICElementDelta[] children = delta.getAffectedChildren();
for (int i = 0; i < children.length; ++i) for (int i = 0; i < children.length; ++i)
processDelta(children[i]); processDelta(children[i]);
// what have we got // what have we got
ICElement element = delta.getElement();
if (element.getElementType() == ICElement.C_PROJECT) { if (element.getElementType() == ICElement.C_PROJECT) {
switch (delta.getKind()) { switch (delta.getKind()) {
case ICElementDelta.ADDED: case ICElementDelta.ADDED:

View file

@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
*/ */
public abstract class PDOMBinding extends PDOMNode implements IBinding { public abstract class PDOMBinding extends PDOMNode implements IBinding {
private static final int TYPE_OFFSET = PDOMNode.RECORD_SIZE + 4; // size 4 private static final int BINDING_TYPE_OFFSET = PDOMNode.RECORD_SIZE + 4; // size 4
private static final int FIRST_DECL_OFFSET = PDOMNode.RECORD_SIZE + 8; // size 4 private static final int FIRST_DECL_OFFSET = PDOMNode.RECORD_SIZE + 8; // size 4
private static final int FIRST_DEF_OFFSET = PDOMNode.RECORD_SIZE + 12; // size 4 private static final int FIRST_DEF_OFFSET = PDOMNode.RECORD_SIZE + 12; // size 4
private static final int FIRST_REF_OFFSET = PDOMNode.RECORD_SIZE + 16; // size 4 private static final int FIRST_REF_OFFSET = PDOMNode.RECORD_SIZE + 16; // size 4
@ -37,7 +37,7 @@ public abstract class PDOMBinding extends PDOMNode implements IBinding {
Database db = pdom.getDB(); Database db = pdom.getDB();
// Binding type // Binding type
db.putInt(record + TYPE_OFFSET, type); db.putInt(record + BINDING_TYPE_OFFSET, type);
} }
public PDOMBinding(PDOMDatabase pdom, int record) { public PDOMBinding(PDOMDatabase pdom, int record) {
@ -52,7 +52,7 @@ public abstract class PDOMBinding extends PDOMNode implements IBinding {
} }
public static int getBindingType(PDOMDatabase pdom, int record) throws CoreException { public static int getBindingType(PDOMDatabase pdom, int record) throws CoreException {
return pdom.getDB().getInt(record + TYPE_OFFSET); return pdom.getDB().getInt(record + BINDING_TYPE_OFFSET);
} }
/** /**
@ -76,7 +76,7 @@ public abstract class PDOMBinding extends PDOMNode implements IBinding {
} }
public int getBindingType() throws CoreException { public int getBindingType() throws CoreException {
return pdom.getDB().getInt(record + TYPE_OFFSET); return pdom.getDB().getInt(record + BINDING_TYPE_OFFSET);
} }
public boolean hasDeclarations() throws CoreException { public boolean hasDeclarations() throws CoreException {

View file

@ -148,6 +148,9 @@ public class PDOMCLinkage extends PDOMLinkage {
} }
public PDOMBinding adaptBinding(IBinding binding) throws CoreException { public PDOMBinding adaptBinding(IBinding binding) throws CoreException {
if (binding instanceof PDOMBinding)
return (PDOMBinding)binding;
PDOMNode parent = getParent(binding); PDOMNode parent = getParent(binding);
if (parent == this) { if (parent == this) {
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding)); FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));

View file

@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField;
@ -159,6 +158,9 @@ public class PDOMCPPLinkage extends PDOMLinkage {
if (binding == null || binding instanceof IProblemBinding) if (binding == null || binding instanceof IProblemBinding)
return null; return null;
if (binding instanceof PDOMBinding)
return (PDOMBinding)binding;
PDOMNode parent = getParent(binding); PDOMNode parent = getParent(binding);
if (parent == this) { if (parent == this) {
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding)); FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));

View file

@ -11,10 +11,15 @@
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.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase; import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
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.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
@ -27,8 +32,24 @@ import org.eclipse.core.runtime.CoreException;
*/ */
public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable { public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE + 0;
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
public PDOMCPPVariable(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException { public PDOMCPPVariable(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
super(pdom, parent, name, PDOMCPPLinkage.CPPVARIABLE); super(pdom, parent, name, PDOMCPPLinkage.CPPVARIABLE);
// Find the type record
IASTNode nameParent = name.getParent();
if (nameParent instanceof IASTDeclarator) {
IASTDeclarator declarator = (IASTDeclarator)nameParent;
IType type = CPPVisitor.createType(declarator);
if (type != null && type instanceof IBinding) {
PDOMBinding pdomType = parent.getLinkage().adaptBinding((IBinding)type);
if (pdomType != null)
pdom.getDB().putInt(record + TYPE_OFFSET, pdomType.getRecord());
}
}
} }
public PDOMCPPVariable(PDOMDatabase pdom, int record) { public PDOMCPPVariable(PDOMDatabase pdom, int record) {
@ -44,9 +65,14 @@ public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
} }
public IType getType() throws DOMException { public IType getType() throws DOMException {
// TODO try {
int typeRec = pdom.getDB().getInt(record + TYPE_OFFSET);
return typeRec != 0 ? (IType)getLinkage().getBinding(typeRec) : null;
} catch (CoreException e) {
CCorePlugin.log(e);
return null; return null;
} }
}
public boolean isAuto() throws DOMException { public boolean isAuto() throws DOMException {
throw new PDOMNotImplementedError(); throw new PDOMNotImplementedError();