[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] C Model Patch - Enumerators
|
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.
Thanks,
Hoda
Index: model/org/eclipse/cdt/core/model/ICElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java,v
retrieving revision 1.5
diff -u -r1.5 ICElement.java
--- model/org/eclipse/cdt/core/model/ICElement.java 27 Mar 2003 17:33:12 -0000 1.5
+++ model/org/eclipse/cdt/core/model/ICElement.java 31 Mar 2003 20:19:51 -0000
@@ -140,6 +140,11 @@
static final int C_TYPEDEF = 78;
/**
+ * Enumerator.
+ */
+ static final int C_ENUMERATOR = 79;
+
+ /**
* Modifier indicating a class constructor
*/
static final int C_CLASS_CTOR = 0x100;
Index: model/org/eclipse/cdt/core/model/IEnumerator.java
===================================================================
RCS file: model/org/eclipse/cdt/core/model/IEnumerator.java
diff -N model/org/eclipse/cdt/core/model/IEnumerator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/core/model/IEnumerator.java 31 Mar 2003 20:19:51 -0000
@@ -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();
+}
Index: model/org/eclipse/cdt/core/model/IParent.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IParent.java,v
retrieving revision 1.1
diff -u -r1.1 IParent.java
--- model/org/eclipse/cdt/core/model/IParent.java 26 Jun 2002 20:37:14 -0000 1.1
+++ model/org/eclipse/cdt/core/model/IParent.java 31 Mar 2003 20:19:51 -0000
@@ -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 @@
* @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 @@
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource
*/
- boolean hasChildren(); //throws CModelException;
+ boolean hasChildren();
+
+
}
Index: model/org/eclipse/cdt/internal/core/model/Enumeration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Enumeration.java,v
retrieving revision 1.1
diff -u -r1.1 Enumeration.java
--- model/org/eclipse/cdt/internal/core/model/Enumeration.java 31 Mar 2003 16:33:54 -0000 1.1
+++ model/org/eclipse/cdt/internal/core/model/Enumeration.java 31 Mar 2003 20:19:51 -0000
@@ -16,6 +16,11 @@
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 @@
* @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 @@
* @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;
}
}
Index: model/org/eclipse/cdt/internal/core/model/Enumerator.java
===================================================================
RCS file: model/org/eclipse/cdt/internal/core/model/Enumerator.java
diff -N model/org/eclipse/cdt/internal/core/model/Enumerator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ model/org/eclipse/cdt/internal/core/model/Enumerator.java 31 Mar 2003 20:19:51 -0000
@@ -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;
+ }
+
+}
Index: src/org/eclipse/cdt/ui/CElementLabelProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java,v
retrieving revision 1.5
diff -u -r1.5 CElementLabelProvider.java
--- src/org/eclipse/cdt/ui/CElementLabelProvider.java 31 Mar 2003 16:33:53 -0000 1.5
+++ src/org/eclipse/cdt/ui/CElementLabelProvider.java 31 Mar 2003 20:20:15 -0000
@@ -8,7 +8,6 @@
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;
@@ -67,6 +66,15 @@
case ICElement.C_METHOD_DECLARATION:
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();