1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

TypeHierarchy: adds query for subclasses

This commit is contained in:
Markus Schorn 2007-01-19 14:28:39 +00:00
parent ca8df5e182
commit 369981cc43
6 changed files with 33 additions and 14 deletions

View file

@ -212,14 +212,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
return false;
}
public boolean isConstructor() throws CModelException {
return false;
}
public boolean isDestructor() throws CModelException {
return false;
}
public boolean isInline() throws CModelException {
return false;
}

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.model.ext;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
@ -26,16 +27,20 @@ public class MethodHandle extends CElementHandle implements IMethod {
private String[] fParameterTypes;
private ASTAccessVisibility fVisibility;
private boolean fIsStatic;
private boolean fIsConstructor;
private boolean fIsDestructor;
public MethodHandle(ICElement parent, ICPPMethod method) throws DOMException {
super(parent, ICElement.C_METHOD, method.getName());
fParameterTypes= extractParameterTypes(method);
fVisibility= getVisibility(method);
try {
fIsStatic= method.isStatic();
fIsConstructor= method instanceof ICPPConstructor;
if (!fIsConstructor)
fIsDestructor= method.isDestructor();
} catch (DOMException e) {
CCorePlugin.log(e);
fIsStatic= false;
}
}
@ -66,4 +71,12 @@ public class MethodHandle extends CElementHandle implements IMethod {
public ASTAccessVisibility getVisibility() throws CModelException {
return fVisibility;
}
public boolean isConstructor() throws CModelException {
return fIsConstructor;
}
public boolean isDestructor() throws CModelException {
return fIsDestructor;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2007 Wind River Systems, Inc. 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
@ -63,4 +63,9 @@ public interface IIndexName extends IName {
*/
public IIndexName[] getEnclosedNames() throws CoreException;
/**
* Returns whether a declaration is a base-class specifier.
*/
public boolean isBaseSpecifier() throws CoreException;
}

View file

@ -274,7 +274,7 @@ public class THHierarchyModel {
try {
IBinding binding = IndexUI.elementToBinding(index, elem);
if (binding instanceof ICPPClassType) {
IIndexName[] names= index.findNames(binding, IIndex.FIND_ALL_OCCURENCES);
IIndexName[] names= index.findNames(binding, IIndex.FIND_REFERENCES);
for (int i = 0; i < names.length; i++) {
if (monitor.isCanceled()) {
return;

View file

@ -74,6 +74,7 @@ import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IDeclaration;
import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.refactoring.actions.CRefactoringActionGroup;
import org.eclipse.cdt.ui.CUIPlugin;
@ -429,6 +430,16 @@ public class THViewPart extends ViewPart {
ICElement celem= (ICElement)element;
switch (celem.getElementType()) {
case ICElement.C_FIELD: return 1;
case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION:
IMethodDeclaration md= (IMethodDeclaration) celem;
try {
if (md.isConstructor()) return 2;
if (md.isDestructor()) return 3;
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
}
break;
}
}
return 10;

View file

@ -205,8 +205,6 @@ public class TypeHierarchyUI {
case ICElement.C_STRUCT_DECLARATION:
case ICElement.C_UNION_DECLARATION:
// case ICElement.C_TYPEDEF:
// case ICElement.C_CLASS_CTOR:
// case ICElement.C_CLASS_DTOR:
// case ICElement.C_FIELD:
// case ICElement.C_METHOD:
// case ICElement.C_METHOD_DECLARATION: