mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Patch for Hoda Amer:
This patch adds a new C Model Element Type: Enumerator. It also displays the element's type name instead of the element's name if the element's name is null.
This commit is contained in:
parent
34877663fe
commit
c13b3fc240
6 changed files with 123 additions and 8 deletions
|
@ -139,6 +139,11 @@ public interface ICElement extends IAdaptable {
|
|||
*/
|
||||
static final int C_TYPEDEF = 78;
|
||||
|
||||
/**
|
||||
* Enumerator.
|
||||
*/
|
||||
static final int C_ENUMERATOR = 79;
|
||||
|
||||
/**
|
||||
* Modifier indicating a class constructor
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.eclipse.cdt.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
|
||||
***********************************************************************/
|
||||
public interface IEnumerator extends ISourceManipulation{
|
||||
|
||||
/**
|
||||
* Returns the enumerator constant expression if any.
|
||||
* Returns null otherwise.
|
||||
* @return String
|
||||
*/
|
||||
String getConstantExpression();
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.eclipse.cdt.core.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/*
|
||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
|
@ -17,8 +19,12 @@ public interface IParent {
|
|||
* @exception CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
ICElement[] getChildren(); //throws CModelException;
|
||||
ICElement[] getChildren();
|
||||
|
||||
/**
|
||||
* returns the children of a certain type
|
||||
*/
|
||||
public ArrayList getChildrenOfType(int type);
|
||||
/**
|
||||
* Returns whether this element has one or more immediate children.
|
||||
* This is a convenience method, and may be more efficient than
|
||||
|
@ -27,5 +33,7 @@ public interface IParent {
|
|||
* @exception CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
boolean hasChildren(); //throws CModelException;
|
||||
boolean hasChildren();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ import org.eclipse.cdt.core.model.IEnumeration;
|
|||
|
||||
public class Enumeration extends SourceManipulation implements IEnumeration{
|
||||
|
||||
String typeName = "";
|
||||
boolean isStatic = false;
|
||||
boolean isConst = false;
|
||||
boolean isVolatile = false;
|
||||
|
||||
public Enumeration(ICElement parent, String name) {
|
||||
super(parent, name, CElement.C_ENUMERATION);
|
||||
}
|
||||
|
@ -35,13 +40,14 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
* @see org.eclipse.cdt.core.model.IVariableDeclaration#getTypeName()
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return null;
|
||||
return typeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IVariableDeclaration#setTypeName(java.lang.String)
|
||||
*/
|
||||
public void setTypeName(String type) {
|
||||
typeName = type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,21 +61,45 @@ public class Enumeration extends SourceManipulation implements IEnumeration{
|
|||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||
*/
|
||||
public boolean isConst() {
|
||||
return false;
|
||||
return isConst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isStatic()
|
||||
*/
|
||||
public boolean isStatic() {
|
||||
return false;
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IDeclaration#isVolatile()
|
||||
*/
|
||||
public boolean isVolatile() {
|
||||
return false;
|
||||
return isVolatile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isConst.
|
||||
* @param isConst The isConst to set
|
||||
*/
|
||||
public void setConst(boolean isConst) {
|
||||
this.isConst = isConst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isStatic.
|
||||
* @param isStatic The isStatic to set
|
||||
*/
|
||||
public void setStatic(boolean isStatic) {
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isVolatile.
|
||||
* @param isVolatile The isVolatile to set
|
||||
*/
|
||||
public void setVolatile(boolean isVolatile) {
|
||||
this.isVolatile = isVolatile;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IEnumerator;
|
||||
|
||||
/**********************************************************************
|
||||
* 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
|
||||
***********************************************************************/
|
||||
public class Enumerator extends SourceManipulation implements IEnumerator{
|
||||
|
||||
String constantExpression = "";
|
||||
|
||||
public Enumerator(ICElement parent, String name) {
|
||||
super(parent, name, CElement.C_ENUMERATOR);
|
||||
}
|
||||
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new SourceManipulationInfo(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IEnumerator#getConstantExptrssion()
|
||||
*/
|
||||
public String getConstantExpression() {
|
||||
return constantExpression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the constantExpression.
|
||||
* @param constantExpression The constantExpression to set
|
||||
*/
|
||||
public void setConstantExpression(String constantExpression) {
|
||||
this.constantExpression = constantExpression;
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,6 @@ package org.eclipse.cdt.ui;
|
|||
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.IVariable;
|
||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||
import org.eclipse.cdt.internal.ui.CElementImageProvider;
|
||||
import org.eclipse.cdt.internal.ui.ErrorTickAdornmentProvider;
|
||||
|
@ -68,6 +67,15 @@ public class CElementLabelProvider extends LabelProvider {
|
|||
IFunctionDeclaration fdecl = (IFunctionDeclaration) celem;
|
||||
name = fdecl.getSignature();
|
||||
break;
|
||||
case ICElement.C_STRUCT:
|
||||
case ICElement.C_ENUMERATION:
|
||||
if(celem.getElementName() != null){
|
||||
name = celem.getElementName();
|
||||
} else {
|
||||
IVariableDeclaration varDecl = (IVariableDeclaration) celem;
|
||||
name = varDecl.getTypeName();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
name= celem.getElementName();
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue