mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Patch for 149565, by Andrew Ferguson (creating API for PDom)
This commit is contained in:
parent
5239cb2ebd
commit
6e62fd8891
35 changed files with 398 additions and 451 deletions
|
@ -18,7 +18,11 @@ import org.eclipse.cdt.core.dom.IPDOMManager;
|
|||
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.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
|
@ -28,9 +32,6 @@ import org.eclipse.cdt.internal.core.pdom.PDOM;
|
|||
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.c.PDOMCStructure;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPClassType;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPNamespace;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPNamespaceAlias;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +89,7 @@ public class AllTypesCache {
|
|||
return;
|
||||
case ICElement.C_STRUCT:
|
||||
if (node instanceof PDOMCStructure)
|
||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||
types.add(new PDOMTypeInfo((IBinding)node, kind, project));
|
||||
return;
|
||||
case ICElement.C_UNION:
|
||||
return;
|
||||
|
@ -109,25 +110,28 @@ public class AllTypesCache {
|
|||
try {
|
||||
switch (kind) {
|
||||
case ICElement.C_NAMESPACE:
|
||||
if (node instanceof PDOMCPPNamespace || node instanceof PDOMCPPNamespaceAlias)
|
||||
if (node instanceof ICPPNamespace || node instanceof ICPPNamespaceAlias)
|
||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||
return;
|
||||
case ICElement.C_CLASS:
|
||||
if (node instanceof PDOMCPPClassType
|
||||
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_class)
|
||||
if (node instanceof ICPPClassType
|
||||
&& ((ICPPClassType)node).getKey() == ICPPClassType.k_class)
|
||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||
return;
|
||||
case ICElement.C_STRUCT:
|
||||
if (node instanceof PDOMCPPClassType
|
||||
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_struct)
|
||||
if (node instanceof ICPPClassType
|
||||
&& ((ICPPClassType)node).getKey() == ICPPClassType.k_struct)
|
||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||
return;
|
||||
case ICElement.C_UNION:
|
||||
if (node instanceof PDOMCPPClassType
|
||||
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_union)
|
||||
if (node instanceof ICPPClassType
|
||||
&& ((ICPPClassType)node).getKey() == ICPPClassType.k_union)
|
||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||
return;
|
||||
case ICElement.C_ENUMERATION:
|
||||
if (node instanceof IEnumeration
|
||||
/*&& node instanceof ICPPBinding*/)
|
||||
types.add(new PDOMTypeInfo((IEnumeration)node, kind, project));
|
||||
return;
|
||||
case ICElement.C_TYPEDEF:
|
||||
return;
|
||||
|
|
|
@ -13,11 +13,15 @@
|
|||
package org.eclipse.cdt.core.browser;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMResolver;
|
||||
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.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -27,11 +31,11 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMTypeInfo implements ITypeInfo {
|
||||
|
||||
private final PDOMBinding binding;
|
||||
private final IBinding binding;
|
||||
private final int elementType;
|
||||
private final ICProject project;
|
||||
|
||||
public PDOMTypeInfo(PDOMBinding binding, int elementType, ICProject project) {
|
||||
public PDOMTypeInfo(IBinding binding, int elementType, ICProject project) {
|
||||
this.binding = binding;
|
||||
this.elementType = elementType;
|
||||
this.project = project;
|
||||
|
@ -95,21 +99,19 @@ public class PDOMTypeInfo implements ITypeInfo {
|
|||
}
|
||||
|
||||
public IQualifiedTypeName getQualifiedTypeName() {
|
||||
StringBuffer buf = new StringBuffer(binding.getName());
|
||||
try {
|
||||
PDOMNode parent = binding.getParentNode();
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent instanceof PDOMBinding)
|
||||
{
|
||||
buf.insert(0, ((PDOMBinding)parent).getName() + "::");
|
||||
}
|
||||
parent = parent.getParentNode();
|
||||
String qn;
|
||||
if(binding instanceof ICPPBinding) {
|
||||
try {
|
||||
qn = CPPVisitor.renderQualifiedName(((ICPPBinding)binding).getQualifiedName());
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de); // can't happen when (binding instanceof PDOMBinding)
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
return new QualifiedTypeName(buf.toString());
|
||||
} else {
|
||||
qn = binding.getName();
|
||||
}
|
||||
|
||||
return new QualifiedTypeName(qn);
|
||||
}
|
||||
|
||||
public ITypeReference[] getReferences() {
|
||||
|
@ -118,8 +120,10 @@ public class PDOMTypeInfo implements ITypeInfo {
|
|||
|
||||
public ITypeReference getResolvedReference() {
|
||||
try {
|
||||
PDOMName name = binding.getFirstDefinition();
|
||||
return name != null ? new PDOMTypeReference(name, project) : null;
|
||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||
IPDOMResolver resolver = (IPDOMResolver) pdom.getAdapter(IPDOMResolver.class);
|
||||
IASTName[] names= resolver.getDefinitions(binding);
|
||||
return names != null && names.length > 0 ? new PDOMTypeReference(names[0], project) : null;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
package org.eclipse.cdt.core.browser;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -29,11 +29,11 @@ import org.eclipse.core.runtime.Path;
|
|||
*/
|
||||
public class PDOMTypeReference implements ITypeReference {
|
||||
|
||||
private final PDOMName name;
|
||||
private final IASTName name;
|
||||
private final ICProject project;
|
||||
private final IPath path;
|
||||
|
||||
public PDOMTypeReference(PDOMName name, ICProject project) {
|
||||
public PDOMTypeReference(IASTName name, ICProject project) {
|
||||
this.name = name;
|
||||
this.project = project;
|
||||
this.path = new Path(name.getFileLocation().getFileName());
|
||||
|
|
|
@ -704,7 +704,7 @@ public class CPPVisitor {
|
|||
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) parent;
|
||||
if( dtor.getNestedDeclarator() == null ) {
|
||||
while( parent.getParent() instanceof IASTDeclarator )
|
||||
parent = (IASTDeclarator) parent.getParent();
|
||||
parent = parent.getParent();
|
||||
ASTNodeProperty prop = parent.getPropertyInParent();
|
||||
if( prop == IASTSimpleDeclaration.DECLARATOR )
|
||||
return dtor.getFunctionScope();
|
||||
|
@ -765,7 +765,7 @@ public class CPPVisitor {
|
|||
n = ns[ ns.length - 1 ];
|
||||
}
|
||||
|
||||
return (ICPPScope) CPPVisitor.getContainingScope( n );
|
||||
return CPPVisitor.getContainingScope( n );
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
|
@ -1987,6 +1987,20 @@ public class CPPVisitor {
|
|||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the qualified name by concatenating component names with the
|
||||
* Scope resolution operator ::
|
||||
* @param qn the component names
|
||||
* @return the qualified name
|
||||
*/
|
||||
public static String renderQualifiedName(String[] qn) {
|
||||
StringBuffer result = new StringBuffer();
|
||||
for(int i=0; i<qn.length; i++) {
|
||||
result.append(qn[i] + (i+1<qn.length ? "::" : "")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String [] getQualifiedName( IBinding binding ){
|
||||
IASTName [] ns = null;
|
||||
try {
|
||||
|
|
|
@ -57,7 +57,7 @@ public class PDOM extends PlatformObject
|
|||
|
||||
private Database db;
|
||||
|
||||
public static final int VERSION = 11;
|
||||
public static final int VERSION = 12;
|
||||
// 0 - the beginning of it all
|
||||
// 1 - first change to kick off upgrades
|
||||
// 2 - added file inclusions
|
||||
|
@ -70,6 +70,7 @@ public class PDOM extends PlatformObject
|
|||
// 9 - base classes
|
||||
// 10 - typedefs, types on C++ variables
|
||||
// 11 - changed how members work
|
||||
// 12 - one more change for members (is-a list -> has-a list)
|
||||
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
|
|
|
@ -9,31 +9,31 @@
|
|||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
package org.eclipse.cdt.internal.core.pdom.db;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.ListItem;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Represents a linked list
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public abstract class PDOMMemberOwner extends PDOMBinding {
|
||||
|
||||
private static final int FIRST_MEMBER = PDOMBinding.RECORD_SIZE + 0;
|
||||
public class PDOMNodeLinkedList {
|
||||
PDOM pdom;
|
||||
int offset;
|
||||
PDOMLinkage linkage;
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||
private static final int FIRST_MEMBER = 0;
|
||||
protected static final int RECORD_SIZE = 4;
|
||||
|
||||
public PDOMMemberOwner(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
}
|
||||
|
||||
public PDOMMemberOwner(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
public PDOMNodeLinkedList(PDOM pdom, int offset, PDOMLinkage linkage) {
|
||||
this.pdom = pdom;
|
||||
this.offset = offset;
|
||||
this.linkage = linkage;
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
|
@ -41,12 +41,10 @@ public abstract class PDOMMemberOwner extends PDOMBinding {
|
|||
}
|
||||
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
super.accept(visitor);
|
||||
ListItem firstItem = getFirstMemberItem();
|
||||
if (firstItem == null)
|
||||
return;
|
||||
|
||||
PDOMLinkage linkage = getLinkage();
|
||||
ListItem item = firstItem;
|
||||
do {
|
||||
PDOMNode node = linkage.getNode(item.getItem());
|
||||
|
@ -59,7 +57,7 @@ public abstract class PDOMMemberOwner extends PDOMBinding {
|
|||
|
||||
private ListItem getFirstMemberItem() throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int item = db.getInt(record + FIRST_MEMBER);
|
||||
int item = db.getInt(offset + FIRST_MEMBER);
|
||||
return item != 0 ? new ListItem(db, item) : null;
|
||||
}
|
||||
|
||||
|
@ -71,7 +69,7 @@ public abstract class PDOMMemberOwner extends PDOMBinding {
|
|||
firstMember.setItem(member.getRecord());
|
||||
firstMember.setNext(firstMember);
|
||||
firstMember.setPrev(firstMember);
|
||||
db.putInt(record + FIRST_MEMBER, firstMember.getRecord());
|
||||
db.putInt(offset + FIRST_MEMBER, firstMember.getRecord());
|
||||
} else {
|
||||
ListItem newMember = new ListItem(db);
|
||||
newMember.setItem(member.getRecord());
|
||||
|
@ -82,5 +80,4 @@ public abstract class PDOMMemberOwner extends PDOMBinding {
|
|||
newMember.setNext(firstMember);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Interface for PDOM entities that contain members
|
||||
*/
|
||||
public interface IPDOMMemberOwner {
|
||||
public void addMember(PDOMNode member) throws CoreException;
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Symbian Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Symbian - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* Mirrors type-hierarchy from DOM interfaces
|
||||
*/
|
||||
abstract public class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
||||
public PDOMCPPBinding(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
public PDOMCPPBinding(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
}
|
||||
|
||||
// TODO: performance?
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
List result = new ArrayList();
|
||||
try {
|
||||
PDOMNode node = this;
|
||||
while (node != null) {
|
||||
if (node instanceof PDOMBinding) {
|
||||
result.add(0, ((PDOMBinding)node).getName());
|
||||
}
|
||||
node = node.getParentNode();
|
||||
}
|
||||
return (String[]) result.toArray(new String[result.size()]);
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: performance?
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
String[] preResult = getQualifiedName();
|
||||
char[][] result = new char[preResult.length][];
|
||||
for(int i=0; i<preResult.length; i++) {
|
||||
result[i] = preResult[i].toCharArray();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
}
|
|
@ -50,8 +50,8 @@ public abstract class PDOMNode implements IPDOMNode{
|
|||
|
||||
// parent
|
||||
db.putInt(record + PARENT, parent != null ? parent.getRecord() : 0);
|
||||
if (parent instanceof PDOMMemberOwner)
|
||||
((PDOMMemberOwner)parent).addMember(this);
|
||||
if (parent instanceof IPDOMMemberOwner)
|
||||
((IPDOMMemberOwner)parent).addMember(this);
|
||||
}
|
||||
|
||||
protected abstract int getRecordSize();
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCEnumeration extends PDOMBinding implements IEnumeration {
|
||||
class PDOMCEnumeration extends PDOMBinding implements IEnumeration {
|
||||
|
||||
private static final int FIRST_ENUMERATOR = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
|
||||
class PDOMCEnumerator extends PDOMBinding implements IEnumerator {
|
||||
|
||||
private static final int ENUMERATION = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int NEXT_ENUMERATOR = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
|
|
@ -16,8 +16,9 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
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.PDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -25,10 +26,10 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCField extends PDOMBinding implements IField {
|
||||
class PDOMCField extends PDOMBinding implements IField {
|
||||
|
||||
public PDOMCField(PDOM pdom, PDOMMemberOwner parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
public PDOMCField(PDOM pdom, IPDOMMemberOwner parent, IASTName name) throws CoreException {
|
||||
super(pdom, (PDOMNode) parent, name);
|
||||
}
|
||||
|
||||
public PDOMCField(PDOM pdom, int record) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCFunction extends PDOMBinding implements IFunction {
|
||||
class PDOMCFunction extends PDOMBinding implements IFunction {
|
||||
|
||||
public PDOMCFunction(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
|
|
|
@ -36,10 +36,10 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
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.PDOMFile;
|
||||
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.PDOMNamedNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -49,7 +49,7 @@ import org.eclipse.core.runtime.Status;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCLinkage extends PDOMLinkage {
|
||||
class PDOMCLinkage extends PDOMLinkage {
|
||||
|
||||
public PDOMCLinkage(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
|
@ -124,8 +124,8 @@ public class PDOMCLinkage extends PDOMLinkage {
|
|||
if (binding instanceof IParameter)
|
||||
return null; // skip parameters
|
||||
else if (binding instanceof IField) { // must be before IVariable
|
||||
if (parent instanceof PDOMMemberOwner)
|
||||
pdomBinding = new PDOMCField(pdom, (PDOMMemberOwner)parent, name);
|
||||
if (parent instanceof IPDOMMemberOwner)
|
||||
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, name);
|
||||
} else if (binding instanceof IVariable)
|
||||
pdomBinding = new PDOMCVariable(pdom, parent, name);
|
||||
else if (binding instanceof IFunction)
|
||||
|
@ -240,9 +240,9 @@ public class PDOMCLinkage extends PDOMLinkage {
|
|||
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
|
||||
getIndex().accept(visitor);
|
||||
return visitor.pdomBinding;
|
||||
} else if (parent instanceof PDOMMemberOwner) {
|
||||
} else if (parent instanceof IPDOMMemberOwner) {
|
||||
FindBinding2 visitor = new FindBinding2(binding.getNameCharArray(), getBindingType(binding));
|
||||
PDOMMemberOwner owner = (PDOMMemberOwner)parent;
|
||||
IPDOMMemberOwner owner = (IPDOMMemberOwner)parent;
|
||||
try {
|
||||
owner.accept(visitor);
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -24,7 +24,9 @@ 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.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMemberOwner;
|
||||
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.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -34,16 +36,28 @@ import org.eclipse.core.runtime.Status;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCStructure extends PDOMMemberOwner implements ICompositeType {
|
||||
|
||||
public class PDOMCStructure extends PDOMBinding implements ICompositeType, IPDOMMemberOwner {
|
||||
private static final int MEMBERLIST = PDOMBinding.RECORD_SIZE;
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
||||
public PDOMCStructure(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
// linked list is initialized by malloc zeroing allocated storage
|
||||
}
|
||||
|
||||
public PDOMCStructure(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
super.accept(visitor);
|
||||
new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkage()).accept(visitor);
|
||||
}
|
||||
|
||||
public void addMember(PDOMNode member) throws CoreException {
|
||||
new PDOMNodeLinkedList(pdom, record+MEMBERLIST, getLinkage()).addMember(member);
|
||||
}
|
||||
|
||||
public int getNodeType() {
|
||||
return PDOMCLinkage.CSTRUCTURE;
|
||||
}
|
||||
|
@ -129,4 +143,7 @@ public class PDOMCStructure extends PDOMMemberOwner implements ICompositeType {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCTypedef extends PDOMBinding implements ITypedef {
|
||||
class PDOMCTypedef extends PDOMBinding implements ITypedef {
|
||||
|
||||
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCVariable extends PDOMBinding implements IVariable {
|
||||
class PDOMCVariable extends PDOMBinding implements IVariable {
|
||||
|
||||
public PDOMCVariable(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCPPBase implements ICPPBase {
|
||||
class PDOMCPPBase implements ICPPBase {
|
||||
|
||||
private static final int BASECLASS = 0;
|
||||
private static final int NEXTBASE = 4;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType {
|
||||
class PDOMCPPBasicType extends PDOMNode implements ICPPBasicType {
|
||||
|
||||
public static final int TYPE_ID = PDOMNode.RECORD_SIZE + 0; // short
|
||||
public static final int FLAGS = PDOMNode.RECORD_SIZE + 2; // short
|
||||
|
|
|
@ -34,9 +34,11 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
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;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
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.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -45,13 +47,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
||||
ICPPClassScope {
|
||||
class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
||||
ICPPClassScope, IPDOMMemberOwner {
|
||||
|
||||
private static final int FIRSTBASE = PDOMMemberOwner.RECORD_SIZE + 0;
|
||||
private static final int KEY = PDOMMemberOwner.RECORD_SIZE + 4; // byte
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMMemberOwner.RECORD_SIZE + 5;
|
||||
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 4; // byte
|
||||
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, PDOMNode parent, IASTName name)
|
||||
throws CoreException {
|
||||
|
@ -62,8 +65,14 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
if (binding instanceof ICPPClassType) // not sure why it wouldn't
|
||||
key = ((ICPPClassType) binding).getKey();
|
||||
pdom.getDB().putByte(record + KEY, (byte) key);
|
||||
// linked list is initialized by storage being zero'd by malloc
|
||||
}
|
||||
|
||||
|
||||
public void addMember(PDOMNode member) throws CoreException {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkage());
|
||||
list.addMember(member);
|
||||
}
|
||||
|
||||
public PDOMCPPClassType(PDOM pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
@ -122,6 +131,12 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
}
|
||||
}
|
||||
|
||||
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||
super.accept(visitor);
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkage());
|
||||
list.accept(visitor);
|
||||
}
|
||||
|
||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||
// TODO
|
||||
return new ICPPConstructor[0];
|
||||
|
@ -261,15 +276,7 @@ public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType,
|
|||
return ICPPClassType.k_class; // or something
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
try {
|
||||
return getParentNode() instanceof PDOMLinkage;
|
||||
|
|
|
@ -18,8 +18,10 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
|||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -27,7 +29,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCPPEnumeration extends PDOMBinding implements IEnumeration {
|
||||
class PDOMCPPEnumeration extends PDOMCPPBinding implements IEnumeration, ICPPBinding {
|
||||
|
||||
private static final int FIRST_ENUMERATOR = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -25,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPEnumerator extends PDOMBinding implements IEnumerator {
|
||||
class PDOMCPPEnumerator extends PDOMCPPBinding implements IEnumerator, ICPPBinding {
|
||||
|
||||
private static final int ENUMERATION = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int NEXT_ENUMERATOR = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPField extends PDOMBinding implements ICPPField {
|
||||
class PDOMCPPField extends PDOMCPPBinding implements ICPPField {
|
||||
|
||||
public PDOMCPPField(PDOM pdom, PDOMCPPClassType parent, IASTName name)
|
||||
throws CoreException {
|
||||
|
@ -59,14 +59,6 @@ public class PDOMCPPField extends PDOMBinding implements ICPPField {
|
|||
return CPPVisitor.getQualifiedName( this );
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -36,7 +37,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPFunction extends PDOMBinding implements ICPPFunction, ICPPFunctionType {
|
||||
class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFunctionType {
|
||||
|
||||
public static final int NUM_PARAMS = PDOMBinding.RECORD_SIZE + 0;
|
||||
public static final int FIRST_PARAM = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
@ -139,18 +140,6 @@ public class PDOMCPPFunction extends PDOMBinding implements ICPPFunction, ICPPFu
|
|||
return false;
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IType[] getParameterTypes() throws DOMException {
|
||||
try {
|
||||
int n = pdom.getDB().getInt(record + NUM_PARAMS);
|
||||
|
|
|
@ -45,10 +45,10 @@ import org.eclipse.cdt.core.model.ILanguage;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
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.PDOMFile;
|
||||
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.PDOMNamedNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
@ -59,7 +59,7 @@ import org.eclipse.core.runtime.Status;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPLinkage extends PDOMLinkage {
|
||||
class PDOMCPPLinkage extends PDOMLinkage {
|
||||
|
||||
public PDOMCPPLinkage(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
|
@ -139,12 +139,12 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
if (!(binding.getScope() instanceof CPPBlockScope))
|
||||
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
|
||||
} else if (binding instanceof ICPPMethod && parent instanceof PDOMCPPClassType) {
|
||||
pdomBinding = new PDOMCPPMethod(pdom, (PDOMCPPClassType)parent, name);
|
||||
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
|
||||
} else if (binding instanceof CPPImplicitMethod && parent instanceof PDOMCPPClassType) {
|
||||
if(!name.isReference()) {
|
||||
//because we got the implicit method off of an IASTName that is not a reference,
|
||||
//it is no longer completly implicit and it should be treated as a normal method.
|
||||
pdomBinding = new PDOMCPPMethod(pdom, (PDOMCPPClassType)parent, name);
|
||||
pdomBinding = new PDOMCPPMethod(pdom, parent, name);
|
||||
}
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
|
||||
|
@ -298,9 +298,9 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
FindBinding visitor = new FindBinding(pdom, binding.getNameCharArray(), getBindingType(binding));
|
||||
getIndex().accept(visitor);
|
||||
return visitor.pdomBinding;
|
||||
} else if (parent instanceof PDOMMemberOwner) {
|
||||
} else if (parent instanceof IPDOMMemberOwner) {
|
||||
FindBinding2 visitor = new FindBinding2(binding.getNameCharArray(), getBindingType(binding));
|
||||
PDOMMemberOwner owner = (PDOMMemberOwner)parent;
|
||||
IPDOMMemberOwner owner = (IPDOMMemberOwner)parent;
|
||||
try {
|
||||
owner.accept(visitor);
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -29,7 +29,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -37,14 +38,14 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPMethod extends PDOMBinding implements ICPPMethod, ICPPFunctionType {
|
||||
class PDOMCPPMethod extends PDOMCPPBinding implements ICPPMethod, ICPPFunctionType {
|
||||
|
||||
public static final int NUM_PARAMS = PDOMBinding.RECORD_SIZE + 0;
|
||||
public static final int FIRST_PARAM = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
||||
public static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 8;
|
||||
|
||||
public PDOMCPPMethod(PDOM pdom, PDOMMemberOwner parent, IASTName name) throws CoreException {
|
||||
public PDOMCPPMethod(PDOM pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name);
|
||||
IASTNode parentNode = name.getParent();
|
||||
if (parentNode instanceof ICPPASTFunctionDeclarator) {
|
||||
|
@ -147,18 +148,6 @@ public class PDOMCPPMethod extends PDOMBinding implements ICPPMethod, ICPPFuncti
|
|||
return false;
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
|||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.FindBindingsInBTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
|
@ -38,7 +39,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPNamespace extends PDOMBinding
|
||||
class PDOMCPPNamespace extends PDOMCPPBinding
|
||||
implements ICPPNamespace, ICPPNamespaceScope {
|
||||
|
||||
private static final int INDEX_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
@ -70,7 +71,7 @@ public class PDOMCPPNamespace extends PDOMBinding
|
|||
getIndex().accept(new IBTreeVisitor() {
|
||||
public int compare(int record) throws CoreException {
|
||||
return 1;
|
||||
};
|
||||
}
|
||||
public boolean visit(int record) throws CoreException {
|
||||
PDOMBinding binding = pdom.getBinding(record);
|
||||
if (binding != null) {
|
||||
|
@ -79,7 +80,7 @@ public class PDOMCPPNamespace extends PDOMBinding
|
|||
visitor.leave(binding);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,18 +88,6 @@ public class PDOMCPPNamespace extends PDOMBinding
|
|||
getIndex().insert(child.getRecord(), child.getIndexComparator());
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IBinding[] getMemberBindings() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPNamespaceAlias extends PDOMBinding implements
|
||||
class PDOMCPPNamespaceAlias extends PDOMCPPBinding implements
|
||||
ICPPNamespaceAlias {
|
||||
|
||||
public PDOMCPPNamespaceAlias(PDOM pdom, PDOMNode parent,
|
||||
|
@ -54,18 +54,6 @@ public class PDOMCPPNamespaceAlias extends PDOMBinding implements
|
|||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public int getDelegateType() {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
|
||||
class PDOMCPPParameter extends PDOMNamedNode implements ICPPParameter {
|
||||
|
||||
private static final int NEXT_PARAM = PDOMNamedNode.RECORD_SIZE + 0;
|
||||
private static final int TYPE = PDOMNamedNode.RECORD_SIZE + 4;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
|
||||
class PDOMCPPTypedef extends PDOMBinding implements ITypedef {
|
||||
|
||||
private static final int TYPE = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ 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.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMCPPBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -29,7 +30,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
|
||||
class PDOMCPPVariable extends PDOMCPPBinding implements ICPPVariable {
|
||||
|
||||
private static final int TYPE_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
@ -90,17 +91,4 @@ public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
|
|||
public boolean isStatic() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,38 +17,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.PathUtil;
|
||||
import org.eclipse.cdt.core.browser.QualifiedTypeName;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
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.CHelpProviderManager;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
||||
import org.eclipse.cdt.internal.ui.codemanipulation.AddIncludesOperation;
|
||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||
import org.eclipse.cdt.ui.IRequiredInclude;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -72,6 +40,41 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog;
|
|||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
import org.eclipse.ui.texteditor.IUpdate;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.PathUtil;
|
||||
import org.eclipse.cdt.core.browser.QualifiedTypeName;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||
import org.eclipse.cdt.ui.IRequiredInclude;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
|
||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
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.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CHelpProviderManager;
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
||||
import org.eclipse.cdt.internal.ui.codemanipulation.AddIncludesOperation;
|
||||
import org.eclipse.cdt.internal.ui.text.CWordFinder;
|
||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||
|
||||
// TODO this is a big TODO.
|
||||
public class AddIncludeOnSelectionAction extends Action implements IUpdate {
|
||||
|
||||
|
@ -286,7 +289,7 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
|
|||
{
|
||||
PDOMBinding pdomBinding = (PDOMBinding) pdomBindings.get(i);
|
||||
|
||||
if (pdomBinding instanceof PDOMMemberOwner //class or struct
|
||||
if (pdomBinding instanceof IPDOMMemberOwner //class or struct
|
||||
|| pdomBinding instanceof IEnumeration)
|
||||
{
|
||||
PDOMName currentDef = pdomBinding.getFirstDefinition();
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
@ -17,27 +18,33 @@ import java.util.List;
|
|||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCStructure;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPClassType;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkage;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
|
@ -144,153 +151,49 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
|
|||
|
||||
//TODO search for macro
|
||||
|
||||
if ((flags & FIND_ALL_TYPES) == FIND_ALL_TYPES)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
boolean matches= false;
|
||||
if ((flags & FIND_ALL_TYPES) == FIND_ALL_TYPES) {
|
||||
matches= true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//C++
|
||||
if (pdomBinding.getLinkage() instanceof PDOMCPPLinkage)
|
||||
{
|
||||
switch (pdomBinding.getNodeType()) {
|
||||
case PDOMCPPLinkage.CPPCLASSTYPE:
|
||||
{
|
||||
switch (((PDOMCPPClassType)pdomBinding).getKey())
|
||||
{
|
||||
case ICPPClassType.k_class:
|
||||
case ICompositeType.k_struct:
|
||||
if (((flags & FIND_CLASS_STRUCT) == FIND_CLASS_STRUCT))
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case ICompositeType.k_union:
|
||||
if ((flags & FIND_UNION) == FIND_UNION)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PDOMCPPLinkage.CPPENUMERATION:
|
||||
if ((flags & FIND_ENUM) == FIND_ENUM)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPENUMERATOR:
|
||||
if ((flags & FIND_ENUMERATOR) == FIND_ENUMERATOR)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPFIELD:
|
||||
if ((flags & FIND_FIELD) == FIND_FIELD)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPFUNCTION:
|
||||
if ((flags & FIND_FUNCTION) == FIND_FUNCTION)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPMETHOD:
|
||||
if ((flags & FIND_METHOD) == FIND_METHOD)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPNAMESPACE:
|
||||
case PDOMCPPLinkage.CPPNAMESPACEALIAS:
|
||||
if ((flags & FIND_NAMESPACE) == FIND_NAMESPACE)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPTYPEDEF:
|
||||
if ((flags & FIND_TYPEDEF) == FIND_TYPEDEF)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCPPLinkage.CPPVARIABLE:
|
||||
if ((flags & FIND_VARIABLE) == FIND_VARIABLE)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//C
|
||||
else if (pdomBinding.getLinkage() instanceof PDOMCLinkage)
|
||||
{
|
||||
switch (pdomBinding.getNodeType()) {
|
||||
case PDOMCLinkage.CSTRUCTURE:
|
||||
switch (((PDOMCStructure)pdomBinding).getKey())
|
||||
{
|
||||
case ICompositeType.k_struct:
|
||||
if (((flags & FIND_CLASS_STRUCT) == FIND_CLASS_STRUCT))
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case ICompositeType.k_union:
|
||||
if ((flags & FIND_UNION) == FIND_UNION)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PDOMCLinkage.CENUMERATION:
|
||||
if ((flags & FIND_ENUM) == FIND_ENUM)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCLinkage.CENUMERATOR:
|
||||
if ((flags & FIND_ENUMERATOR) == FIND_ENUMERATOR)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCLinkage.CFIELD:
|
||||
if ((flags & FIND_FIELD) == FIND_FIELD)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCLinkage.CFUNCTION:
|
||||
if ((flags & FIND_FUNCTION) == FIND_FUNCTION)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCLinkage.CTYPEDEF:
|
||||
if ((flags & FIND_TYPEDEF) == FIND_TYPEDEF)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
case PDOMCLinkage.CVARIABLE:
|
||||
if ((flags & FIND_VARIABLE) == FIND_VARIABLE)
|
||||
{
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (pdomBinding instanceof ICompositeType) {
|
||||
ICompositeType ct= (ICompositeType) pdomBinding;
|
||||
switch (ct.getKey()) {
|
||||
case ICompositeType.k_struct:
|
||||
case ICPPClassType.k_class:
|
||||
matches= (flags & FIND_CLASS_STRUCT) != 0;
|
||||
break;
|
||||
case ICompositeType.k_union:
|
||||
matches= (flags & FIND_UNION) != 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (pdomBinding instanceof IEnumeration) {
|
||||
matches= (flags & FIND_ENUM) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof IEnumerator) {
|
||||
matches= (flags & FIND_ENUMERATOR) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof IField) {
|
||||
matches= (flags & FIND_FIELD) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof ICPPMethod) {
|
||||
matches= (flags & FIND_METHOD) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof IVariable) {
|
||||
matches= (flags & FIND_VARIABLE) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof IFunction) {
|
||||
matches= (flags & FIND_FUNCTION) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof ICPPNamespace || pdomBinding instanceof ICPPNamespaceAlias) {
|
||||
matches= (flags & FIND_NAMESPACE) != 0;
|
||||
}
|
||||
else if (pdomBinding instanceof ITypedef) {
|
||||
matches= (flags & FIND_TYPEDEF) != 0;
|
||||
}
|
||||
if (matches) {
|
||||
createMatches(pdomBinding.getLinkage().getLanguage(), pdomBinding);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
pdom.releaseReadLock();
|
||||
|
|
|
@ -15,31 +15,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||
import org.eclipse.cdt.core.browser.TypeSearchScope;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
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.cpp.PDOMCPPLinkage;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -48,7 +23,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
|
|||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
@ -57,6 +31,38 @@ import org.eclipse.ui.IEditorPart;
|
|||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutline;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.AllTypesCache;
|
||||
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||
import org.eclipse.cdt.core.browser.TypeSearchScope;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class NewClassWizardUtil {
|
||||
|
||||
/**
|
||||
|
@ -366,7 +372,7 @@ public class NewClassWizardUtil {
|
|||
* Search for the given qualified name of the give
|
||||
* @param typeName qualified name of the type to search
|
||||
* @param project
|
||||
* @param pdomNodeType PDOMCPPLinkage type
|
||||
* @param queryType Class of interface type to search for (e.g. ICPPClassType.class)
|
||||
* @return one of {@link #SEARCH_MATCH_ERROR},
|
||||
* {@link #SEARCH_MATCH_FOUND_ANOTHER_NAMESPACE},
|
||||
* {@link #SEARCH_MATCH_FOUND_ANOTHER_TYPE},
|
||||
|
@ -374,7 +380,7 @@ public class NewClassWizardUtil {
|
|||
* {@link #SEARCH_MATCH_FOUND_EXACT} or
|
||||
* {@link #SEARCH_MATCH_NOTFOUND}.
|
||||
*/
|
||||
public static int searchForCppType(IQualifiedTypeName typeName, ICProject project, int pdomNodeType) {
|
||||
public static int searchForCppType(IQualifiedTypeName typeName, ICProject project, Class queryType) {
|
||||
if(project == null) {
|
||||
return SEARCH_MATCH_ERROR;
|
||||
}
|
||||
|
@ -388,35 +394,29 @@ public class NewClassWizardUtil {
|
|||
boolean sameTypeNameExists = false;
|
||||
boolean sameNameDifferentTypeExists = false;
|
||||
|
||||
for (int i = 0; i < bindings.length; ++i)
|
||||
{
|
||||
PDOMBinding binding = (PDOMBinding)bindings[i];
|
||||
PDOMBinding pdomBinding = pdom.getLinkage(GPPLanguage.getDefault()).adaptBinding(binding);
|
||||
for (int i = 0; i < bindings.length; ++i) {
|
||||
ICPPBinding binding = (ICPPBinding)bindings[i];
|
||||
|
||||
//get the fully qualified name of this binding
|
||||
String bindingFullName = getBindingQualifiedName(pdomBinding);
|
||||
String bindingFullName = CPPVisitor.renderQualifiedName(binding.getQualifiedName());
|
||||
|
||||
int currentNodeType = pdomBinding.getNodeType();
|
||||
Class currentNodeType = binding.getClass();
|
||||
// full binding
|
||||
if (currentNodeType == pdomNodeType)
|
||||
{
|
||||
if (bindingFullName.equals(fullyQualifiedTypeName))
|
||||
{
|
||||
if (queryType.isAssignableFrom(currentNodeType)) {
|
||||
if (bindingFullName.equals(fullyQualifiedTypeName)) {
|
||||
return SEARCH_MATCH_FOUND_EXACT;
|
||||
} else {
|
||||
// same type , same name , but different name space
|
||||
// see if there is an exact match;
|
||||
sameTypeNameExists = true;
|
||||
}
|
||||
}
|
||||
else if(currentNodeType == PDOMCPPLinkage.CPPCLASSTYPE ||
|
||||
currentNodeType == PDOMCPPLinkage.CPPENUMERATION ||
|
||||
currentNodeType == PDOMCPPLinkage.CPPNAMESPACE ||
|
||||
currentNodeType == PDOMCPPLinkage.CPPTYPEDEF ||
|
||||
currentNodeType == PDOMCPPLinkage.CPPBASICTYPE)
|
||||
} else if(ICPPClassType.class.isAssignableFrom(currentNodeType) ||
|
||||
IEnumeration.class.isAssignableFrom(currentNodeType) || // TODO - this should maybe be ICPPEnumeration
|
||||
ICPPNamespace.class.isAssignableFrom(currentNodeType) ||
|
||||
ITypeDef.class.isAssignableFrom(currentNodeType) ||
|
||||
ICPPBasicType.class.isAssignableFrom(currentNodeType))
|
||||
{
|
||||
if (bindingFullName.equals(fullyQualifiedTypeName))
|
||||
{
|
||||
if (bindingFullName.equals(fullyQualifiedTypeName)) {
|
||||
return SEARCH_MATCH_FOUND_EXACT_ANOTHER_TYPE;
|
||||
} else {
|
||||
// different type , same name , but different name space
|
||||
|
@ -436,25 +436,4 @@ public class NewClassWizardUtil {
|
|||
}
|
||||
return SEARCH_MATCH_NOTFOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully qualified name for a given PDOMBinding
|
||||
* @param pdomBinding
|
||||
* @return binding's fully qualified name
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static String getBindingQualifiedName(PDOMBinding pdomBinding) throws CoreException
|
||||
{
|
||||
StringBuffer buf = new StringBuffer(pdomBinding.getName());
|
||||
PDOMNode parent = pdomBinding.getParentNode();
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent instanceof PDOMBinding)
|
||||
{
|
||||
buf.insert(0, ((PDOMBinding)parent).getName() + "::"); //$NON-NLS-1$
|
||||
}
|
||||
parent = parent.getParentNode();
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ import org.eclipse.cdt.core.browser.PathUtil;
|
|||
import org.eclipse.cdt.core.browser.QualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.TypeSearchScope;
|
||||
import org.eclipse.cdt.core.browser.TypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
|
@ -65,8 +67,6 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
|||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkage;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
|
||||
import org.eclipse.cdt.internal.ui.util.SWTUtil;
|
||||
|
@ -1488,13 +1488,13 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
/* search for parent name space first */
|
||||
int searchResult;
|
||||
if (typeName.isQualified()) {
|
||||
searchResult = NewClassWizardUtil.searchForCppType(typeName.getEnclosingTypeName(),project, PDOMCPPLinkage.CPPNAMESPACE);
|
||||
searchResult = NewClassWizardUtil.searchForCppType(typeName.getEnclosingTypeName(),project, ICPPNamespace.class);
|
||||
if (searchResult != NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT) {
|
||||
status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.EnclosingNamespaceNotExists")); //$NON-NLS-1$
|
||||
return status;
|
||||
}
|
||||
}
|
||||
searchResult = NewClassWizardUtil.searchForCppType(typeName, project, PDOMCPPLinkage.CPPNAMESPACE);
|
||||
searchResult = NewClassWizardUtil.searchForCppType(typeName, project, ICPPNamespace.class);
|
||||
switch(searchResult) {
|
||||
case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
|
||||
status.setOK();
|
||||
|
@ -1563,7 +1563,7 @@ public class NewClassCreationWizardPage extends NewElementWizardPage {
|
|||
fullyQualifiedName = new QualifiedTypeName(namespace).append(typeName);
|
||||
}
|
||||
}
|
||||
int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project,PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
int searchResult = NewClassWizardUtil.searchForCppType(fullyQualifiedName, project, ICPPClassType.class);
|
||||
switch(searchResult) {
|
||||
case NewClassWizardUtil.SEARCH_MATCH_FOUND_EXACT:
|
||||
status.setError(NewClassWizardMessages.getString("NewClassCreationWizardPage.error.ClassNameExists")); //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue