mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +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:
parent
910021b305
commit
6a0b94fd93
5 changed files with 46 additions and 11 deletions
|
@ -139,13 +139,17 @@ public class PDOMUpdator extends Job {
|
|||
}
|
||||
|
||||
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
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
processDelta(children[i]);
|
||||
|
||||
// what have we got
|
||||
ICElement element = delta.getElement();
|
||||
if (element.getElementType() == ICElement.C_PROJECT) {
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
|
|
|
@ -25,10 +25,10 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public abstract class PDOMBinding extends PDOMNode implements IBinding {
|
||||
|
||||
private static final int 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_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 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_DEF_OFFSET = PDOMNode.RECORD_SIZE + 12; // size 4
|
||||
private static final int FIRST_REF_OFFSET = PDOMNode.RECORD_SIZE + 16; // size 4
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 20;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public abstract class PDOMBinding extends PDOMNode implements IBinding {
|
|||
Database db = pdom.getDB();
|
||||
|
||||
// Binding type
|
||||
db.putInt(record + TYPE_OFFSET, type);
|
||||
db.putInt(record + BINDING_TYPE_OFFSET, type);
|
||||
}
|
||||
|
||||
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 {
|
||||
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 {
|
||||
return pdom.getDB().getInt(record + TYPE_OFFSET);
|
||||
return pdom.getDB().getInt(record + BINDING_TYPE_OFFSET);
|
||||
}
|
||||
|
||||
public boolean hasDeclarations() throws CoreException {
|
||||
|
|
|
@ -148,6 +148,9 @@ public class PDOMCLinkage extends PDOMLinkage {
|
|||
}
|
||||
|
||||
public PDOMBinding adaptBinding(IBinding binding) throws CoreException {
|
||||
if (binding instanceof PDOMBinding)
|
||||
return (PDOMBinding)binding;
|
||||
|
||||
PDOMNode parent = getParent(binding);
|
||||
if (parent == this) {
|
||||
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
|
||||
|
|
|
@ -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.ICPPVariable;
|
||||
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.CPPClassType;
|
||||
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)
|
||||
return null;
|
||||
|
||||
if (binding instanceof PDOMBinding)
|
||||
return (PDOMBinding)binding;
|
||||
|
||||
PDOMNode parent = getParent(binding);
|
||||
if (parent == this) {
|
||||
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
|
||||
|
|
|
@ -11,10 +11,15 @@
|
|||
|
||||
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.IASTDeclarator;
|
||||
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.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.dom.PDOMBinding;
|
||||
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 {
|
||||
|
||||
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 {
|
||||
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) {
|
||||
|
@ -44,8 +65,13 @@ public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
|
|||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
// TODO
|
||||
return null;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
|
|
Loading…
Add table
Reference in a new issue