mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 18:56:02 +02:00
TypeHierarchy: allow to open from c-fields.
This commit is contained in:
parent
6335d2b66f
commit
6d8bdf8d18
8 changed files with 83 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 IBM Corporation and others.
|
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
@ -17,4 +18,11 @@ public interface IField extends IVariable {
|
||||||
|
|
||||||
public static final IField[] EMPTY_FIELD_ARRAY = new IField[0];
|
public static final IField[] EMPTY_FIELD_ARRAY = new IField[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the composite type that owns the field.
|
||||||
|
* @throws DOMException
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
ICompositeType getCompositeTypeOwner() throws DOMException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,12 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
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.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created on Nov 8, 2004
|
* Created on Nov 8, 2004
|
||||||
|
@ -24,6 +27,10 @@ public class CField extends CVariable implements IField {
|
||||||
public CFieldProblem( IASTNode node, int id, char[] arg ) {
|
public CFieldProblem( IASTNode node, int id, char[] arg ) {
|
||||||
super( node, id, arg );
|
super( node, id, arg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
throw new DOMException(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -32,4 +39,9 @@ public class CField extends CVariable implements IField {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
ICCompositeTypeScope scope = (ICCompositeTypeScope) getScope();
|
||||||
|
return scope.getCompositeType();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ 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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||||
|
@ -45,6 +46,9 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() throws DOMException {
|
||||||
return ((ICPPField)getBinding()).getClassOwner();
|
return ((ICPPField)getBinding()).getClassOwner();
|
||||||
}
|
}
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
return getClassOwner();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
||||||
/**
|
/**
|
||||||
|
@ -64,6 +68,10 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
||||||
public boolean isStatic() throws DOMException {
|
public boolean isStatic() throws DOMException {
|
||||||
throw new DOMException( this );
|
throw new DOMException( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
return getClassOwner();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CPPField( IASTName name ){
|
public CPPField( IASTName name ){
|
||||||
|
@ -155,4 +163,9 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
||||||
public ICPPDelegate createDelegate( IASTName name ) {
|
public ICPPDelegate createDelegate( IASTName name ) {
|
||||||
return new CPPFieldDelegate( name, this );
|
return new CPPFieldDelegate( name, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
// mstodo Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
|
@ -81,4 +82,8 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
||||||
return new CPPFieldDelegate( name, this );
|
return new CPPFieldDelegate( name, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||||
|
return getClassOwner();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
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.IPDOMMemberOwner;
|
||||||
|
@ -41,24 +42,32 @@ class PDOMCField extends PDOMCVariable implements IField {
|
||||||
return PDOMCLinkage.CFIELD;
|
return PDOMCLinkage.CFIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatic() throws DOMException {
|
public boolean isStatic() {
|
||||||
// ISO/IEC 9899:TC1 6.7.2.1
|
// ISO/IEC 9899:TC1 6.7.2.1
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExtern() throws DOMException {
|
public boolean isExtern() {
|
||||||
// ISO/IEC 9899:TC1 6.7.2.1
|
// ISO/IEC 9899:TC1 6.7.2.1
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuto() throws DOMException {
|
public boolean isAuto() {
|
||||||
// ISO/IEC 9899:TC1 6.7.2.1
|
// ISO/IEC 9899:TC1 6.7.2.1
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRegister() throws DOMException {
|
public boolean isRegister() {
|
||||||
// ISO/IEC 9899:TC1 6.7.2.1
|
// ISO/IEC 9899:TC1 6.7.2.1
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() {
|
||||||
|
try {
|
||||||
|
return (ICompositeType)getParentNode();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
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.ICPPField;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
@ -44,7 +44,7 @@ class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
|
||||||
return PDOMCPPLinkage.CPPFIELD;
|
return PDOMCPPLinkage.CPPFIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPClassType getClassOwner() throws DOMException {
|
public ICPPClassType getClassOwner() {
|
||||||
try {
|
try {
|
||||||
return (ICPPClassType)getParentNode();
|
return (ICPPClassType)getParentNode();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -53,30 +53,34 @@ class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() {
|
||||||
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATIONS));
|
return PDOMCPPAnnotation.getVisibility(getByte(record + ANNOTATIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public boolean isMutable() throws DOMException {
|
public boolean isMutable() {
|
||||||
return getBit(getByte(record + ANNOTATIONS), PDOMCPPAnnotation.MUTABLE_OFFSET);
|
return getBit(getByte(record + ANNOTATIONS), PDOMCPPAnnotation.MUTABLE_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public boolean isAuto() throws DOMException {
|
public boolean isAuto() {
|
||||||
// ISO/IEC 14882:2003 9.2.6
|
// ISO/IEC 14882:2003 9.2.6
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public boolean isExtern() throws DOMException {
|
public boolean isExtern() {
|
||||||
// ISO/IEC 14882:2003 9.2.6
|
// ISO/IEC 14882:2003 9.2.6
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public boolean isRegister() throws DOMException {
|
public boolean isRegister() {
|
||||||
// ISO/IEC 14882:2003 9.2.6
|
// ISO/IEC 14882:2003 9.2.6
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICompositeType getCompositeTypeOwner() {
|
||||||
|
return getClassOwner();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,6 +281,7 @@ class THHierarchyModel {
|
||||||
THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
|
THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
|
||||||
if (gnode != null) {
|
if (gnode != null) {
|
||||||
ICElement[] members= gnode.getMembers(fShowInheritedMembers);
|
ICElement[] members= gnode.getMembers(fShowInheritedMembers);
|
||||||
|
if (members != null) {
|
||||||
for (int i = 0; i < members.length; i++) {
|
for (int i = 0; i < members.length; i++) {
|
||||||
ICElement member= members[i];
|
ICElement member= members[i];
|
||||||
if (member.equals(oldSelection)) {
|
if (member.equals(oldSelection)) {
|
||||||
|
@ -298,6 +299,7 @@ class THHierarchyModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private THNode createNode(THNode parent, THGraphNode gnode, THGraphNode inputNode) {
|
private THNode createNode(THNode parent, THGraphNode gnode, THGraphNode inputNode) {
|
||||||
ICElement element = gnode.getElement();
|
ICElement element = gnode.getElement();
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||||
|
@ -224,6 +225,9 @@ public class TypeHierarchyUI {
|
||||||
else if (memberBinding instanceof ICPPMember) {
|
else if (memberBinding instanceof ICPPMember) {
|
||||||
return ((ICPPMember) memberBinding).getClassOwner();
|
return ((ICPPMember) memberBinding).getClassOwner();
|
||||||
}
|
}
|
||||||
|
else if (memberBinding instanceof IField) {
|
||||||
|
return ((IField) memberBinding).getCompositeTypeOwner();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +275,8 @@ public class TypeHierarchyUI {
|
||||||
public static boolean isValidInput(IBinding binding) {
|
public static boolean isValidInput(IBinding binding) {
|
||||||
if (isValidTypeInput(binding)
|
if (isValidTypeInput(binding)
|
||||||
|| binding instanceof ICPPMember
|
|| binding instanceof ICPPMember
|
||||||
|| binding instanceof IEnumerator) {
|
|| binding instanceof IEnumerator
|
||||||
|
|| binding instanceof IField) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue