mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +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
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
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];
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
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.c.ICCompositeTypeScope;
|
||||
|
||||
/**
|
||||
* Created on Nov 8, 2004
|
||||
|
@ -24,6 +27,10 @@ public class CField extends CVariable implements IField {
|
|||
public CFieldProblem( IASTNode node, int id, char[] arg ) {
|
||||
super( node, id, arg );
|
||||
}
|
||||
|
||||
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||
throw new DOMException(this);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
|
@ -31,5 +38,10 @@ public class CField extends CVariable implements IField {
|
|||
public CField(IASTName 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.IASTNode;
|
||||
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.ICPPASTDeclSpecifier;
|
||||
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 {
|
||||
return ((ICPPField)getBinding()).getClassOwner();
|
||||
}
|
||||
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||
return getClassOwner();
|
||||
}
|
||||
}
|
||||
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 {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
||||
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||
return getClassOwner();
|
||||
}
|
||||
}
|
||||
|
||||
public CPPField( IASTName name ){
|
||||
|
@ -155,4 +163,9 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
|||
public ICPPDelegate createDelegate( IASTName name ) {
|
||||
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.IASTName;
|
||||
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.cpp.ICPPClassType;
|
||||
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 );
|
||||
}
|
||||
|
||||
public ICompositeType getCompositeTypeOwner() throws DOMException {
|
||||
return getClassOwner();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
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.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
|
@ -41,24 +42,32 @@ class PDOMCField extends PDOMCVariable implements IField {
|
|||
return PDOMCLinkage.CFIELD;
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
public boolean isStatic() {
|
||||
// ISO/IEC 9899:TC1 6.7.2.1
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
public boolean isExtern() {
|
||||
// ISO/IEC 9899:TC1 6.7.2.1
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
public boolean isAuto() {
|
||||
// ISO/IEC 9899:TC1 6.7.2.1
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
public boolean isRegister() {
|
||||
// ISO/IEC 9899:TC1 6.7.2.1
|
||||
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;
|
||||
|
||||
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.ICPPField;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -44,7 +44,7 @@ class PDOMCPPField extends PDOMCPPVariable implements ICPPField {
|
|||
return PDOMCPPLinkage.CPPFIELD;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
public ICPPClassType getClassOwner() {
|
||||
try {
|
||||
return (ICPPClassType)getParentNode();
|
||||
} 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));
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isMutable() throws DOMException {
|
||||
public boolean isMutable() {
|
||||
return getBit(getByte(record + ANNOTATIONS), PDOMCPPAnnotation.MUTABLE_OFFSET);
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isAuto() throws DOMException {
|
||||
public boolean isAuto() {
|
||||
// ISO/IEC 14882:2003 9.2.6
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isExtern() throws DOMException {
|
||||
public boolean isExtern() {
|
||||
// ISO/IEC 14882:2003 9.2.6
|
||||
return false;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean isRegister() throws DOMException {
|
||||
public boolean isRegister() {
|
||||
// ISO/IEC 14882:2003 9.2.6
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICompositeType getCompositeTypeOwner() {
|
||||
return getClassOwner();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,18 +281,20 @@ class THHierarchyModel {
|
|||
THGraphNode gnode= fGraph.getNode(fSelectedTypeNode.getElement());
|
||||
if (gnode != null) {
|
||||
ICElement[] members= gnode.getMembers(fShowInheritedMembers);
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
ICElement member= members[i];
|
||||
if (member.equals(oldSelection)) {
|
||||
fSelectedMember= member;
|
||||
return;
|
||||
if (members != null) {
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
ICElement member= members[i];
|
||||
if (member.equals(oldSelection)) {
|
||||
fSelectedMember= member;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
ICElement member= members[i];
|
||||
if (fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) {
|
||||
fSelectedMember= member;
|
||||
return;
|
||||
for (int i = 0; i < members.length; i++) {
|
||||
ICElement member= members[i];
|
||||
if (fMemberSignatureToSelect.equals(TypeHierarchyUI.getLocalElementSignature(member))) {
|
||||
fSelectedMember= member;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.IEnumeration;
|
||||
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.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
|
@ -224,6 +225,9 @@ public class TypeHierarchyUI {
|
|||
else if (memberBinding instanceof ICPPMember) {
|
||||
return ((ICPPMember) memberBinding).getClassOwner();
|
||||
}
|
||||
else if (memberBinding instanceof IField) {
|
||||
return ((IField) memberBinding).getCompositeTypeOwner();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -271,7 +275,8 @@ public class TypeHierarchyUI {
|
|||
public static boolean isValidInput(IBinding binding) {
|
||||
if (isValidTypeInput(binding)
|
||||
|| binding instanceof ICPPMember
|
||||
|| binding instanceof IEnumerator) {
|
||||
|| binding instanceof IEnumerator
|
||||
|| binding instanceof IField) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue