mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Fixed the binding type bug that prevented incremental indexing from getting hooked up correctly. Hookedup fields to their classes. Added support for viewing members in the IndexView and reordered the way members are added.
This commit is contained in:
parent
a9d3047502
commit
943a30e50c
7 changed files with 85 additions and 21 deletions
|
@ -76,7 +76,7 @@ public abstract class PDOMBinding extends PDOMNode implements IBinding {
|
|||
}
|
||||
|
||||
public int getBindingType() throws CoreException {
|
||||
return pdom.getDB().getChar(record + TYPE_OFFSET);
|
||||
return pdom.getDB().getInt(record + TYPE_OFFSET);
|
||||
}
|
||||
|
||||
public boolean hasDeclarations() throws CoreException {
|
||||
|
|
|
@ -28,8 +28,9 @@ public abstract class PDOMMember extends PDOMBinding {
|
|||
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMMember(PDOMDatabase pdom, PDOMNode parent, IASTName name, int type) throws CoreException {
|
||||
public PDOMMember(PDOMDatabase pdom, PDOMMemberOwner parent, IASTName name, int type) throws CoreException {
|
||||
super(pdom, parent, name, type);
|
||||
parent.addMember(this);
|
||||
}
|
||||
|
||||
public PDOMMember(PDOMDatabase pdom, int record) {
|
||||
|
|
|
@ -24,8 +24,9 @@ import org.eclipse.core.runtime.CoreException;
|
|||
public class PDOMMemberOwner extends PDOMBinding {
|
||||
|
||||
private static final int FIRST_MEMBER = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int LAST_MEMBER = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
|
||||
|
||||
public PDOMMemberOwner(PDOMDatabase pdom, PDOMNode parent, IASTName name,
|
||||
int type) throws CoreException {
|
||||
|
@ -41,12 +42,14 @@ public class PDOMMemberOwner extends PDOMBinding {
|
|||
}
|
||||
|
||||
public void addMember(PDOMMember member) throws CoreException {
|
||||
PDOMMember first = getFirstMember();
|
||||
if (first != null) {
|
||||
first.setPrevMember(member);
|
||||
member.setNextMember(first);
|
||||
}
|
||||
PDOMMember last = getLastMember();
|
||||
if (last != null) {
|
||||
last.setNextMember(member);
|
||||
member.setPrevMember(last);
|
||||
} else // first add
|
||||
setFirstMember(member);
|
||||
|
||||
setLastMember(member);
|
||||
member.setMemberOwner(this);
|
||||
}
|
||||
|
||||
|
@ -55,11 +58,21 @@ public class PDOMMemberOwner extends PDOMBinding {
|
|||
pdom.getDB().getInt(record + FIRST_MEMBER));
|
||||
}
|
||||
|
||||
public PDOMMember getLastMember() throws CoreException {
|
||||
return (PDOMMember)getLinkage().getBinding(
|
||||
pdom.getDB().getInt(record + LAST_MEMBER));
|
||||
}
|
||||
|
||||
public void setFirstMember(PDOMMember member) throws CoreException {
|
||||
int memberrec = member != null ? member.getRecord() : 0;
|
||||
pdom.getDB().putInt(record + FIRST_MEMBER, memberrec);
|
||||
}
|
||||
|
||||
public void setLastMember(PDOMMember member) throws CoreException {
|
||||
int memberrec = member != null ? member.getRecord() : 0;
|
||||
pdom.getDB().putInt(record + LAST_MEMBER, memberrec);
|
||||
}
|
||||
|
||||
public int getNumMembers() throws CoreException {
|
||||
int n = 0;
|
||||
|
||||
|
@ -69,6 +82,14 @@ public class PDOMMemberOwner extends PDOMBinding {
|
|||
return n;
|
||||
}
|
||||
|
||||
public PDOMMember getMember(int index) throws CoreException {
|
||||
int n = 0;
|
||||
for (PDOMMember member = getFirstMember(); member != null; member = member.getNextMember())
|
||||
if (n++ == index)
|
||||
return member;
|
||||
return null;
|
||||
}
|
||||
|
||||
public PDOMMember[] findMembers(char[] name) throws CoreException {
|
||||
ArrayList members = new ArrayList();
|
||||
|
||||
|
|
|
@ -332,8 +332,19 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
|||
PDOMName nextName = getNextInBinding();
|
||||
if (prevName != null)
|
||||
prevName.setNextInBinding(nextName);
|
||||
else
|
||||
else {
|
||||
switch (getFlags()) {
|
||||
case IS_DECLARATION:
|
||||
getPDOMBinding().setFirstDeclaration(nextName);
|
||||
break;
|
||||
case IS_DEFINITION:
|
||||
getPDOMBinding().setFirstDefinition(nextName);
|
||||
break;
|
||||
case IS_REFERENCE:
|
||||
getPDOMBinding().setFirstReference(nextName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextName != null)
|
||||
nextName.setPrevInBinding(prevName);
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMCPPField extends PDOMMember implements ICPPField {
|
||||
|
||||
public PDOMCPPField(PDOMDatabase pdom, PDOMNode parent, IASTName name)
|
||||
public PDOMCPPField(PDOMDatabase pdom, PDOMCPPClassType parent, IASTName name)
|
||||
throws CoreException {
|
||||
super(pdom, parent, name, PDOMCPPLinkage.CPPFIELD);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
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.cpp.CPPBlockScope;
|
||||
|
@ -23,14 +26,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
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.PDOMMember;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMemberOwner;
|
||||
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.NodeVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -89,7 +90,7 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (binding instanceof PDOMBinding)
|
||||
pdomBinding = (PDOMBinding)binding;
|
||||
else if (binding instanceof CPPField)
|
||||
pdomBinding = new PDOMCPPField(pdom, parent, name);
|
||||
pdomBinding = new PDOMCPPField(pdom, (PDOMCPPClassType)parent, name);
|
||||
else if (binding instanceof CPPVariable) {
|
||||
if (!(binding.getScope() instanceof CPPBlockScope))
|
||||
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
|
||||
|
@ -103,7 +104,7 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
}
|
||||
|
||||
// Add in the name
|
||||
if (pdomBinding != null)
|
||||
if (pdomBinding != null && name.getFileLocation() != null)
|
||||
new PDOMName(pdom, name, pdomBinding);
|
||||
|
||||
return pdomBinding;
|
||||
|
@ -127,6 +128,18 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (binding instanceof ICPPVariable)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
case CPPFUNCTION:
|
||||
if (binding instanceof ICPPFunction)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
case CPPCLASSTYPE:
|
||||
if (binding instanceof ICPPClassType)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
case CPPFIELD:
|
||||
if (binding instanceof ICPPField)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
}
|
||||
return pdomBinding == null;
|
||||
}
|
||||
|
@ -138,6 +151,11 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
FindBinding visitor = new FindBinding(pdom, binding);
|
||||
getIndex().visit(visitor);
|
||||
return visitor.pdomBinding;
|
||||
} else if (parent instanceof PDOMMemberOwner) {
|
||||
PDOMMemberOwner owner = (PDOMMemberOwner)parent;
|
||||
PDOMMember[] members = owner.findMembers(binding.getNameCharArray());
|
||||
if (members.length > 0)
|
||||
return members[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -153,6 +171,8 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
return new PDOMCPPFunction(pdom, record);
|
||||
case CPPCLASSTYPE:
|
||||
return new PDOMCPPClassType(pdom, record);
|
||||
case CPPFIELD:
|
||||
return new PDOMCPPField(pdom, record);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.pdom.PDOMUpdator;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
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.PDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
|
@ -58,6 +59,7 @@ import org.eclipse.ui.IActionBars;
|
|||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
|
@ -171,8 +173,16 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
BTreeIndex visitor = new BTreeIndex(pdom, index);
|
||||
linkage.getIndex().visit(visitor);
|
||||
PDOMBinding binding = pdom.getBinding(visitor.result);
|
||||
if (binding != null)
|
||||
if (binding != null) {
|
||||
viewer.replace(parent, index, binding);
|
||||
if (binding instanceof PDOMMemberOwner) {
|
||||
PDOMMemberOwner owner = (PDOMMemberOwner)binding;
|
||||
viewer.setChildCount(binding, owner.getNumMembers());
|
||||
}
|
||||
}
|
||||
} else if (parent instanceof PDOMMemberOwner) {
|
||||
PDOMMemberOwner owner = (PDOMMemberOwner)parent;
|
||||
viewer.replace(parent, index, owner.getMember(index));
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
|
@ -214,8 +224,9 @@ public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
|||
else if (element instanceof IBinding)
|
||||
return PlatformUI.getWorkbench().getSharedImages().getImage(
|
||||
ISharedImages.IMG_OBJ_ELEMENT);
|
||||
// else if (element instanceof ICProject)
|
||||
// return super.getImage(element);
|
||||
else if (element instanceof ICProject)
|
||||
return PlatformUI.getWorkbench().getSharedImages().getImage(
|
||||
IDE.SharedImages.IMG_OBJ_PROJECT);
|
||||
else
|
||||
return PlatformUI.getWorkbench().getSharedImages().getImage(
|
||||
ISharedImages.IMG_OBJ_ELEMENT);
|
||||
|
|
Loading…
Add table
Reference in a new issue