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

Patch for Hoda Amer:

-Adds template elements (classes, functions and methods) to core model.
-Updates the C Model Builder to recognize templates.
-Adds UI support for templates in outline view.
This commit is contained in:
Doug Schaefer 2003-04-11 14:36:53 +00:00
parent 5c507c27ac
commit d64897da7a
12 changed files with 461 additions and 114 deletions

View file

@ -112,7 +112,7 @@ public interface ICElement extends IAdaptable {
/**
* C++ template class.
*/
static final int C_TEMPLATE = 73;
static final int C_TEMPLATE_CLASS = 73;
/**
* Global variable.
@ -144,6 +144,16 @@ public interface ICElement extends IAdaptable {
*/
static final int C_ENUMERATOR = 79;
/**
* C++ template function.
*/
static final int C_TEMPLATE_FUNCTION = 80;
/**
* C++ template method.
*/
static final int C_TEMPLATE_METHOD = 81;
/**
* Modifier indicating a class constructor
*/

View file

@ -1,6 +1,33 @@
package org.eclipse.cdt.core.model;
/**
*/
public interface ITemplate extends IMember {
/*******************************************************************************
* Copyright (c) 2001 Rational Software Corp. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* Rational Software - initial implementation
******************************************************************************/
public interface ITemplate extends IDeclaration {
/**
* Returns the template parameter types.
* @return String
*/
String[] getTemplateParameterTypes();
/**
* Sets the template parameter types.
* @param paramTypes
*/
void setTemplateParameterTypes(String[] templateParameterTypes);
/**
* Returns the template signature
* @return String
*/
String getTemplateSignature();
/**
* Returns the number of template parameters
* @return int
*/
int getNumberOfTemplateParameters();
}

View file

@ -0,0 +1,71 @@
package org.eclipse.cdt.internal.core.model;
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* Rational Software - Initial API and implementation
***********************************************************************/
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate;
public class ClassTemplate extends Structure implements ITemplate{
protected static final String[] fgEmptyList= new String[] {};
protected String[] templateParameterTypes;
public ClassTemplate(ICElement parent, String name) {
super(parent, CElement.C_TEMPLATE_CLASS, name);
templateParameterTypes= fgEmptyList;
}
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
return templateParameterTypes;
}
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
this.templateParameterTypes = templateParameterTypes;
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/
public int getNumberOfTemplateParameters() {
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/
public String getTemplateSignature() {
StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){
sig.append("<");
String[] paramTypes = getTemplateParameterTypes();
int i = 0;
sig.append(paramTypes[i++]);
while (i < paramTypes.length){
sig.append(", ");
sig.append(paramTypes[i++]);
}
sig.append(">");
}
else{
sig.append("<>");
}
return sig.toString();
}
}

View file

@ -0,0 +1,78 @@
package org.eclipse.cdt.internal.core.model;
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* Rational Software - Initial API and implementation
***********************************************************************/
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate;
public class FunctionTemplate extends FunctionDeclaration implements ITemplate{
protected static final String[] fgEmptyList= new String[] {};
protected String[] templateParameterTypes;
public FunctionTemplate(ICElement parent, String name) {
super(parent, name, CElement.C_TEMPLATE_FUNCTION);
templateParameterTypes= fgEmptyList;
}
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
return templateParameterTypes;
}
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
this.templateParameterTypes = templateParameterTypes;
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/
public int getNumberOfTemplateParameters() {
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/
public String getTemplateSignature() {
StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){
sig.append("<");
String[] paramTypes = getTemplateParameterTypes();
int i = 0;
sig.append(paramTypes[i++]);
while (i < paramTypes.length){
sig.append(", ");
sig.append(paramTypes[i++]);
}
sig.append(">");
}
else{
sig.append("<>");
}
sig.append(this.getSignature());
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
sig.append(" : ");
sig.append(this.getReturnType());
}
return sig.toString();
}
}

View file

@ -0,0 +1,79 @@
package org.eclipse.cdt.internal.core.model;
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* Rational Software - Initial API and implementation
***********************************************************************/
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate;
public class MethodTemplate extends MethodDeclaration implements ITemplate{
protected static final String[] fgEmptyList= new String[] {};
protected String[] templateParameterTypes;
public MethodTemplate(ICElement parent, String name) {
super(parent, name, CElement.C_TEMPLATE_METHOD);
templateParameterTypes= fgEmptyList;
}
/**
* Returns the parameterTypes.
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
* @return String[]
*/
public String[] getTemplateParameterTypes() {
return templateParameterTypes;
}
/**
* Sets the fParameterTypes.
* @param fParameterTypes The fParameterTypes to set
*/
public void setTemplateParameterTypes(String[] templateParameterTypes) {
this.templateParameterTypes = templateParameterTypes;
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
*/
public int getNumberOfTemplateParameters() {
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
}
/**
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
*/
public String getTemplateSignature() {
StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfTemplateParameters() > 0){
sig.append("<");
String[] paramTypes = getTemplateParameterTypes();
int i = 0;
sig.append(paramTypes[i++]);
while (i < paramTypes.length){
sig.append(", ");
sig.append(paramTypes[i++]);
}
sig.append(">");
}
else{
sig.append("<>");
}
sig.append(this.getSignature());
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
sig.append(" : ");
sig.append(this.getReturnType());
}
return sig.toString();
}
}

View file

@ -1,62 +0,0 @@
package org.eclipse.cdt.internal.core.model;
/**********************************************************************
* Copyright (c) 2002,2003 Rational Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* Rational Software - Initial API and implementation
***********************************************************************/
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITemplate;
public class Template extends SourceManipulation implements ITemplate{
public Template(ICElement parent, String name) {
super(parent, name, CElement.C_TEMPLATE);
}
protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this);
}
/**
* @see org.eclipse.cdt.core.model.IMember#getVisibility()
*/
public int getVisibility() {
return 0;
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl()
*/
public int getAccessControl() {
return 0;
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
*/
public boolean isConst() {
return false;
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
*/
public boolean isStatic() {
return false;
}
/**
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
*/
public boolean isVolatile() {
return false;
}
}

View file

@ -19,6 +19,7 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.INamespace;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITemplate;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.dom.ClassKey;
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
@ -30,6 +31,7 @@ import org.eclipse.cdt.internal.core.dom.ElaboratedTypeSpecifier;
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
import org.eclipse.cdt.internal.core.dom.EnumeratorDefinition;
import org.eclipse.cdt.internal.core.dom.IOffsetable;
import org.eclipse.cdt.internal.core.dom.ITemplateParameterListOwner;
import org.eclipse.cdt.internal.core.dom.Inclusion;
import org.eclipse.cdt.internal.core.dom.Macro;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
@ -37,6 +39,8 @@ import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
import org.eclipse.cdt.internal.core.dom.PointerOperator;
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
import org.eclipse.cdt.internal.core.dom.TemplateParameter;
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
import org.eclipse.cdt.internal.core.parser.Parser;
@ -77,7 +81,7 @@ public class CModelBuilder {
}
protected void generateModelElements (Parent parent, Declaration declaration){
// Namespace
// Namespace Definition
if(declaration instanceof NamespaceDefinition){
NamespaceDefinition nsDef = (NamespaceDefinition) declaration;
IParent namespace = createNamespace(parent, nsDef);
@ -87,8 +91,9 @@ public class CModelBuilder {
Declaration subNsDeclaration = (Declaration) nsDecls.next();
generateModelElements((Parent)namespace, subNsDeclaration);
}
}
}// end Namespace Definition
// Simple Declaration
if(declaration instanceof SimpleDeclaration){
SimpleDeclaration simpleDeclaration = (SimpleDeclaration) declaration;
@ -104,43 +109,93 @@ public class CModelBuilder {
// Structure
else if (typeSpec instanceof ClassSpecifier){
ClassSpecifier classSpecifier = (ClassSpecifier) typeSpec;
IParent classElement = createClass (parent, simpleDeclaration, classSpecifier);
IParent classElement = createClass (parent, simpleDeclaration, classSpecifier, false);
// create the sub declarations
List declarations = classSpecifier.getDeclarations();
Iterator j = declarations.iterator();
while (j.hasNext()){
Declaration subDeclaration = (Declaration)j.next();
generateModelElements((Parent)classElement, subDeclaration);
}
// TODO: create the declarators too here
} // end while j
}
/*-----------------------------------------
* Create declarators of simple declaration
* ----------------------------------------*/
List declarators = simpleDeclaration.getDeclarators();
Iterator d = declarators.iterator();
while (d.hasNext()){
Declarator declarator = (Declarator)d.next();
// typedef
if(simpleDeclaration.getDeclSpecifier().isTypedef()){
createTypeDef(parent, declarator, simpleDeclaration);
} else {
ParameterDeclarationClause pdc = declarator.getParms();
if (pdc == null){
createVariableSpecification(parent, simpleDeclaration, declarator);
}
else{
createFunctionSpecification(parent, simpleDeclaration, declarator, pdc);
}
}
} // end while
} // end if SimpleDeclaration
createElement(parent, simpleDeclaration, declarator);
} // end while d
} // end if SimpleDeclaration
// Template Declaration
if(declaration instanceof TemplateDeclaration){
TemplateDeclaration templateDeclaration = (TemplateDeclaration)declaration;
SimpleDeclaration simpleDeclaration = (SimpleDeclaration)templateDeclaration.getDeclarations().get(0);
TypeSpecifier typeSpec = simpleDeclaration.getTypeSpecifier();
if (typeSpec instanceof ClassSpecifier){
ClassSpecifier classSpecifier = (ClassSpecifier) typeSpec;
ITemplate classTemplate = (ClassTemplate)createClass(parent, simpleDeclaration, classSpecifier, true);
String[] parameterTypes = getTemplateParameters(templateDeclaration);
classTemplate.setTemplateParameterTypes(parameterTypes);
// create the sub declarations
List declarations = classSpecifier.getDeclarations();
Iterator j = declarations.iterator();
while (j.hasNext()){
Declaration subDeclaration = (Declaration)j.next();
generateModelElements((Parent)classTemplate, subDeclaration);
} // end while j
}
List declarators = simpleDeclaration.getDeclarators();
Iterator d = declarators.iterator();
while (d.hasNext()){
Declarator declarator = (Declarator)d.next();
createTemplateElement(parent,templateDeclaration, simpleDeclaration, declarator);
} // end while d
}// end Template Declaration
}
private void createElement(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
// typedef
if(simpleDeclaration.getDeclSpecifier().isTypedef()){
createTypeDef(parent, declarator, simpleDeclaration);
} else {
ParameterDeclarationClause pdc = declarator.getParms();
if (pdc == null){
createVariableSpecification(parent, simpleDeclaration, declarator);
}
else{
createFunctionSpecification(parent, simpleDeclaration, declarator, pdc, false);
}
}
}
private void createTemplateElement(Parent parent, TemplateDeclaration templateDeclaration, SimpleDeclaration simpleDeclaration, Declarator declarator){
ParameterDeclarationClause pdc = declarator.getParms();
if (pdc != null){
ITemplate template = (ITemplate) createFunctionSpecification(parent, simpleDeclaration, declarator, pdc, true);
String[] parameterTypes = getTemplateParameters(templateDeclaration);
template.setTemplateParameterTypes(parameterTypes);
}
/*// typedef
if(simpleDeclaration.getDeclSpecifier().isTypedef()){
createTypeDef(parent, declarator, simpleDeclaration);
} else {
ParameterDeclarationClause pdc = declarator.getParms();
if (pdc == null){
createVariableSpecification(parent, simpleDeclaration, declarator);
}
else{
createFunctionSpecification(parent, simpleDeclaration, declarator, pdc);
}
}
*/
}
private void createInclusion(Parent parent, Inclusion inclusion){
// create element
Include element = new Include((CElement)parent, inclusion.getName());
@ -211,7 +266,7 @@ public class CModelBuilder {
return (IParent)enum;
}
private IParent createClass(Parent parent, SimpleDeclaration simpleDeclaration, ClassSpecifier classSpecifier){
private IParent createClass(Parent parent, SimpleDeclaration simpleDeclaration, ClassSpecifier classSpecifier, boolean isTemplate){
// create element
String className = (classSpecifier.getName() == null ) ? "" : classSpecifier.getName().toString();
int kind;
@ -228,27 +283,35 @@ public class CModelBuilder {
break;
}
Structure classElement = new Structure( (CElement)parent, kind, className );
Structure element;
if(!isTemplate){
Structure classElement = new Structure( (CElement)parent, kind, className );
element = classElement;
} else {
ClassTemplate classTemplate = new ClassTemplate( (CElement)parent, className );
element = classTemplate;
}
// add to parent
parent.addChild((ICElement) classElement);
parent.addChild((ICElement) element);
String type;
// set element position
if( classSpecifier.getName() != null )
{
type = simpleDeclaration.getDeclSpecifier().getTypeName();
classElement.setIdPos( classSpecifier.getName().getStartOffset(), classSpecifier.getName().length() );
element.setIdPos( classSpecifier.getName().getStartOffset(), classSpecifier.getName().length() );
}
else
{
type = classSpecifier.getClassKeyToken().getImage();
classElement.setIdPos(classSpecifier.getClassKeyToken().getOffset(), classSpecifier.getClassKeyToken().getLength());
element.setIdPos(classSpecifier.getClassKeyToken().getOffset(), classSpecifier.getClassKeyToken().getLength());
}
classElement.setTypeName( type );
classElement.setPos(classSpecifier.getStartingOffset(), classSpecifier.getTotalLength());
element.setTypeName( type );
element.setPos(classSpecifier.getStartingOffset(), classSpecifier.getTotalLength());
return classElement;
return element;
}
private void createTypeDef(Parent parent, Declarator declarator, SimpleDeclaration simpleDeclaration){
@ -266,7 +329,7 @@ public class CModelBuilder {
typedef.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
}
private void createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
private VariableDeclaration createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
String declaratorName = declarator.getName().toString();
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
@ -299,13 +362,13 @@ public class CModelBuilder {
parent.addChild( element );
// set position
// hook up the offsets
element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
return element;
}
private void createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, ParameterDeclarationClause pdc){
private FunctionDeclaration createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, ParameterDeclarationClause pdc, boolean isTemplate){
String declaratorName = declarator.getName().toString();
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
// getParameterTypes
@ -315,8 +378,7 @@ public class CModelBuilder {
for( int j = 0; j< parameterList.size(); ++j )
{
ParameterDeclaration param = (ParameterDeclaration )parameterList.get(j);
Declarator paramDeclarator = (Declarator)param.getDeclarators().get(0);
parameterTypes[j] = new String(getType(param, paramDeclarator));
parameterTypes[j] = new String(getType(param, (Declarator)param.getDeclarators().get(0)));
}
if( parent instanceof IStructure )
@ -331,9 +393,16 @@ public class CModelBuilder {
else
{
// method declaration
MethodDeclaration newElement = new MethodDeclaration( parent, declaratorName );
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
element = newElement;
if(!isTemplate){
MethodDeclaration newElement = new MethodDeclaration( parent, declaratorName );
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
element = newElement;
}else {
MethodTemplate newElement = new MethodTemplate(parent, declaratorName);
// newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
element = newElement;
}
}
}
else if(( parent instanceof ITranslationUnit )
@ -352,8 +421,13 @@ public class CModelBuilder {
else
{
// functionDeclaration
FunctionDeclaration newElement = new FunctionDeclaration( parent, declaratorName );
element = newElement;
if(!isTemplate){
FunctionDeclaration newElement = new FunctionDeclaration( parent, declaratorName );
element = newElement;
} else {
FunctionTemplate newElement = new FunctionTemplate( parent, declaratorName );
element = newElement;
}
}
}
element.setParameterTypes(parameterTypes);
@ -368,7 +442,55 @@ public class CModelBuilder {
// hook up the offsets
element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
return element;
}
private String[] getTemplateParameters(ITemplateParameterListOwner templateDeclaration){
// add the parameters
List templateParameters = templateDeclaration.getTemplateParms().getDeclarations();
Iterator i = templateParameters.iterator();
String[] parameterTypes = new String[templateParameters.size()];
for( int j = 0; j< templateParameters.size(); ++j ){
StringBuffer paramType = new StringBuffer();
Declaration decl = (Declaration)templateParameters.get(j);
if(decl instanceof TemplateParameter){
TemplateParameter parameter = (TemplateParameter) decl;
if(parameter.getName() != null){
paramType.append(" ");
paramType.append(parameter.getName().toString());
}else {
int kind = parameter.getKind();
switch (kind){
case TemplateParameter.k_class:
paramType.append("class");
break;
case TemplateParameter.k_typename:
paramType.append("typename");
break;
case TemplateParameter.k_template:
paramType.append("template<");
String[] subParams =getTemplateParameters(parameter);
int p = 0;
if ( subParams.length > 0)
paramType.append(subParams[p++]);
while( p < subParams.length){
paramType.append(", ");
paramType.append(subParams[p++]);
}
paramType.append(">");
break;
default:
break;
} // switch
}
} else if(decl instanceof ParameterDeclaration){
ParameterDeclaration parameter = (ParameterDeclaration) decl;
paramType.append(getType(parameter, (Declarator)parameter.getDeclarators().get(0)));
}
parameterTypes[j] = new String(paramType.toString());
} // end for
return parameterTypes;
}
private String getType(Declaration declaration, Declarator declarator){

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

View file

@ -10,10 +10,11 @@ import org.eclipse.cdt.core.model.IBinaryModule;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IDeclaration;
import org.eclipse.cdt.core.model.IField;
import org.eclipse.cdt.core.model.ILibraryReference;
import org.eclipse.cdt.core.model.IMember;
import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.model.IField;
import org.eclipse.cdt.core.model.ITemplate;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.ui.CElementImageDescriptor;
import org.eclipse.cdt.ui.CUIPlugin;
@ -206,6 +207,7 @@ public class CElementImageProvider {
return CPluginImages.DESC_OBJS_STRUCT;
case ICElement.C_CLASS:
case ICElement.C_TEMPLATE_CLASS:
return CPluginImages.DESC_OBJS_CLASS;
case ICElement.C_UNION:
@ -236,6 +238,7 @@ public class CElementImageProvider {
case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION:
case ICElement.C_TEMPLATE_METHOD:
IMethodDeclaration md= (IMethodDeclaration)celement;
switch(md.getVisibility()){
case IMember.V_PUBLIC:
@ -245,6 +248,7 @@ public class CElementImageProvider {
case IMember.V_PRIVATE:
return CPluginImages.DESC_OBJS_PRIVATE_METHOD;
}
case ICElement.C_FUNCTION:
return CPluginImages.DESC_OBJS_FUNCTION;
@ -252,6 +256,7 @@ public class CElementImageProvider {
return CPluginImages.DESC_OBJS_VAR_DECLARARION;
case ICElement.C_FUNCTION_DECLARATION:
case ICElement.C_TEMPLATE_FUNCTION:
return CPluginImages.DESC_OBJS_DECLARARION;
case ICElement.C_INCLUDE:
@ -262,7 +267,7 @@ public class CElementImageProvider {
case ICElement.C_NAMESPACE:
return CPluginImages.DESC_OBJS_CONTAINER;
}
return null;
}
@ -285,6 +290,9 @@ public class CElementImageProvider {
if(decl.isVolatile()){
flags |= CElementImageDescriptor.VOLATILE;
}
if(element instanceof ITemplate){
flags |= CElementImageDescriptor.TEMPLATE;
}
}
return flags;
}

View file

@ -126,6 +126,7 @@ public class CPluginImages {
public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif");
public static final ImageDescriptor DESC_OVR_CONSTANT= create(T_OVR, "c_ovr.gif");
public static final ImageDescriptor DESC_OVR_VOLATILE= create(T_OVR, "volatile_co.gif");
public static final ImageDescriptor DESC_OVR_TEMPLATE= create(T_OVR, "template_co.gif");
public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif");
public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif");

View file

@ -31,7 +31,7 @@ import org.eclipse.jface.util.Assert;
public class CElementImageDescriptor extends CompositeImageDescriptor {
/** Flag to render the abstract adornment */
public final static int ABSTRACT= 0x001;
public final static int TEMPLATE= 0x001;
/** Flag to render the const adornment */
public final static int CONSTANT= 0x002;
@ -177,6 +177,11 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
x-= data.width;
drawImage(data, x, 0);
}
if ((fFlags & TEMPLATE) != 0) {
data= CPluginImages.DESC_OVR_TEMPLATE.getImageData();
x-= data.width;
drawImage(data, x, 0);
}
}
private void drawBottomRight() {

View file

@ -9,6 +9,7 @@ import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionDeclaration;
import org.eclipse.cdt.core.model.INamespace;
import org.eclipse.cdt.core.model.ITemplate;
import org.eclipse.cdt.core.model.ITypeDef;
import org.eclipse.cdt.core.model.IVariableDeclaration;
import org.eclipse.cdt.internal.ui.CElementImageProvider;
@ -109,6 +110,13 @@ public class CElementLabelProvider extends LabelProvider {
name.append(nDecl.getTypeName());
}
break;
case ICElement.C_TEMPLATE_CLASS:
case ICElement.C_TEMPLATE_FUNCTION:
case ICElement.C_TEMPLATE_METHOD:
ITemplate template = (ITemplate) celem;
String signature = template.getTemplateSignature();
name.append(signature);
break;
default:
name.append(celem.getElementName());
break;