diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IField.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IField.java index db776726bad..b44451e71db 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IField.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IField.java @@ -16,5 +16,5 @@ public interface IField extends IMember, IVariableDeclaration { * @exception CModelException if this element does not exist or if an * exception occurs while accessing its corresponding resource. */ - public boolean isMutable() throws CModelException; + public boolean isMutable(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunction.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunction.java index 3b66b6edcf2..bd1717f0c0a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunction.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunction.java @@ -8,71 +8,6 @@ package org.eclipse.cdt.core.model; /** * Represents a function. */ -public interface IFunction extends ICElement, ISourceReference, ISourceManipulation { +public interface IFunction extends IFunctionDeclaration { - /** - * Returns the exceptions this method throws, in the order declared in the source. - * or an empty array if this method throws no exceptions. - * - *
For example, a source method declaring "void f(int a) throw (x2, x3);"
,
- * would return the array {"x2", "x3"}
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- */
- public String[] getExceptions() throws CModelException;
-
- /**
- * Returns the number of parameters of this method.
- */
- public int getNumberOfParameters();
-
- /**
- * Returns the initializer of parameters pos for this method.
- * Returns an empty string if this argument has no initializer.
- *
- *
For example, a method declared as void foo(String text, int length=9)
- * would return the array {"9"}
.
- *
- * @exception CModelException if this argument does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- public String getParameterInitializer(int pos);
-
- /**
- * Returns the type signatures for the parameters of this method.
- * Returns an empty array if this method has no parameters.
- * This is a handle-only method.
- *
- *
For example, a source method declared as void foo(string text, int length)
- * would return the array {"string","int"}
.
- *
- * @see Signature
- */
- public String[] getParameterTypes();
-
- /**
- * Returns the type signature of the return value of this method.
- * For constructors, this returns the signature for void.
- *
- *
For example, a source method declared as int getName()
- * would return "int"
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- * @see Signature
- */
- public String getReturnType() throws CModelException;
-
- /**
- * Returns the access Control of the member. The value can be
- * can be examined using class Flags
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- * @see Flags
- */
- public int getAccessControl() throws CModelException;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java
index 53272f1eff8..3f4599d9b7d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IFunctionDeclaration.java
@@ -23,7 +23,7 @@ public interface IFunctionDeclaration extends ICElement, ISourceReference, ISour
*
* @see Signature
*/
- String[] getExceptions() throws CModelException;
+ String[] getExceptions();
/**
* Returns the number of parameters of this method.
@@ -55,18 +55,14 @@ public interface IFunctionDeclaration extends ICElement, ISourceReference, ISour
String[] getParameterTypes();
/**
- * Returns the type signature of the return value of this method.
- * For constructors, this returns the signature for void.
- *
- *
For example, a source method declared as public String getName()
- * would return "String"
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- * @see Signature
+ * Returns the return value of this method.
*/
- String getReturnType() throws CModelException;
+ String getReturnType();
+
+ /**
+ * Returns the signature of the method.
+ */
+ String getSignature();
/**
* Returns the access Control of the member. The access qualifier
@@ -76,5 +72,5 @@ public interface IFunctionDeclaration extends ICElement, ISourceReference, ISour
* exception occurs while accessing its corresponding resource.
* @see IAccessControl
*/
- int getAccessControl() throws CModelException;
+ int getAccessControl();
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMember.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMember.java
index a0667250b8c..018df892ebc 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMember.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMember.java
@@ -12,21 +12,20 @@ package org.eclipse.cdt.core.model;
*/
public interface IMember extends ICElement, ISourceReference, ISourceManipulation {
- ///**
- //* Returns the structure in which this member is declared, or null
- //* if this member is not declared in a type (for example, a top-level type).
- //*/
- //IStructure belongsTo() throws CModelException;
+ static final int V_PUBLIC = 0;
+ static final int V_PROTECTED = 1;
+ static final int V_PRIVATE = 2;
+
/**
- * Returns true if the member as class scope.
- * For example static methods in C++ have class scope
+ * Returns true if the member has class scope. For example static methods in
+ * C++ have class scope
*
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- public boolean hasClassScope() throws CModelException;
+ public boolean hasClassScope();
/**
* Returns whether this method/field is declared constant.
@@ -34,7 +33,13 @@ public interface IMember extends ICElement, ISourceReference, ISourceManipulatio
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- public boolean isConst() throws CModelException;
+ public boolean isConst();
+
+ /**
+ * Returns if this member is volatile or not
+ * @return boolean
+ */
+ public boolean isVolatile();
/**
* Returns the access Control of the member. The access qualifier
@@ -44,5 +49,12 @@ public interface IMember extends ICElement, ISourceReference, ISourceManipulatio
* exception occurs while accessing its corresponding resource.
* @see IAccessControl
*/
- public int getAccessControl() throws CModelException;
+ public int getAccessControl();
+ /**
+ * Returns the member's visibility
+ * V_PRIVATE = 0 V_PROTECTED = 1 V_PUBLIC = 2
+ * @return int
+ */
+ public int getVisibility();
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java
index 294b11cb593..61d18a9a2d1 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethod.java
@@ -8,110 +8,6 @@ package org.eclipse.cdt.core.model;
/**
* Represents the definition method of a class.
*/
-public interface IMethod extends IMember, IFunction {
+public interface IMethod extends IMethodDeclaration {
- /**
- * Returns the type signatures of the exceptions this method throws,
- * in the order declared in the source. Returns an empty array
- * if this method throws no exceptions.
- *
- *
For example, a source method declaring "throws IOException"
,
- * would return the array {"QIOException;"}
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- * @see Signature
- */
- String[] getExceptions() throws CModelException;
-
- /**
- * Returns the number of parameters of this method.
- */
- int getNumberOfParameters();
-
- /**
- * Returns the initializer of parameters pos for this method.
- * Returns an empty string if this argument has no initializer.
- *
- *
For example, a method declared as public void foo(String text, int length=9)
- * would return the array {"9"}
.
- *
- * @exception CModelException if this argument does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- String getParameterInitializer(int pos);
-
- /**
- * Returns the type signatures for the parameters of this method.
- * Returns an empty array if this method has no parameters.
- * This is a handle-only method.
- *
- *
For example, a source method declared as void foo(String text, int length)
- * would return the array {"String","int"}
.
- *
- * @see Signature
- */
- String[] getParameterTypes();
-
- /**
- * Returns the type signature of the return value of this method.
- * For constructors, this returns the signature for void.
- *
- *
For example, a source method declared as public String getName()
- * would return "String"
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- * @see Signature
- */
- String getReturnType() throws CModelException;
-
- /**
- * Returns whether this method is a constructor.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- boolean isConstructor() throws CModelException;
-
- /**
- * Returns whether this method is a destructor.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- boolean isDestructor() throws CModelException;
-
- /**
- * Returns whether this method is an operator method.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- boolean isOperator() throws CModelException;
-
- /**
- * Returns whether this method is declared pure virtual.
- *
- *
For example, a source method declared as virtual void m() = 0;
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- boolean isAbstract() throws CModelException;
-
- /**
- * Returns whether this method is declared virtual.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- boolean isVirtual() throws CModelException;
-
- /**
- * return true if the member is a friend.
- */
- public boolean isFriend() throws CModelException;
-}
+}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java
index 78cd8d4cb0e..23a7a1e352a 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMethodDeclaration.java
@@ -10,71 +10,13 @@ package org.eclipse.cdt.core.model;
*/
public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
- /**
- * Returns the type signatures of the exceptions this method throws,
- * in the order declared in the source. Returns an empty array
- * if this method throws no exceptions.
- *
- *
For example, a source method declaring "throws IOException"
,
- * would return the array {"QIOException;"}
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- * @see Signature
- */
- String[] getExceptions() throws CModelException;
-
- /**
- * Returns the number of parameters of this method.
- */
- int getNumberOfParameters();
-
- /**
- * Returns the initializer of parameters pos for this method.
- * Returns an empty string if this argument has no initializer.
- *
- *
For example, a method declared as public void foo(String text, int length=9)
- * would return the array {"9"}
.
- *
- * @exception CModelException if this argument does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- String getParameterInitializer(int pos);
-
- /**
- * Returns the type signatures for the parameters of this method.
- * Returns an empty array if this method has no parameters.
- * This is a handle-only method.
- *
- *
For example, a source method declared as void foo(String text, int length)
- * would return the array {"String","int"}
.
- *
- * @see Signature
- */
- String[] getParameterTypes();
-
- /**
- * Returns the type signature of the return value of this method.
- * For constructors, this returns the signature for void.
- *
- *
For example, a source method declared as public String getName()
- * would return "String"
.
- *
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- *
- * @see Signature
- */
- String getReturnType() throws CModelException;
-
/**
* Returns whether this method is a constructor.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- boolean isConstructor() throws CModelException;
+ boolean isConstructor();
/**
* Returns whether this method is a destructor.
@@ -82,7 +24,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- boolean isDestructor() throws CModelException;
+ boolean isDestructor();
/**
* Returns whether this method is an operator method.
@@ -90,7 +32,7 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- boolean isOperator() throws CModelException;
+ boolean isOperator();
/**
* Returns whether this method is declared pure virtual.
@@ -100,18 +42,31 @@ public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- boolean isAbstract() throws CModelException;
+ boolean isAbstract();
+ /**
+ * Returns if this method is static or not
+ * @return boolean
+ */
+ public boolean isStatic();
+
+ /**
+ * Returns if this method is inline or not
+ * @return boolean
+ */
+ public boolean isInline();
+
/**
* Returns whether this method is declared virtual.
*
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- boolean isVirtual() throws CModelException;
+ boolean isVirtual();
/**
* return true if the member is a friend.
*/
- public boolean isFriend() throws CModelException;
+ public boolean isFriend();
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariable.java
index 5708996a27d..832cf9f43f2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariable.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariable.java
@@ -9,7 +9,8 @@ package org.eclipse.cdt.core.model;
* Represents a global variable.
*/
public interface IVariable extends ICElement , ISourceManipulation, ISourceReference {
- public String getType();
+ public String getTypeName();
+ public void setTypeName(String type);
public String getInitializer();
public int getAccessControl() throws CModelException;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariableDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariableDeclaration.java
index a91bdf07906..7ef1c9c5f9c 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariableDeclaration.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IVariableDeclaration.java
@@ -10,6 +10,7 @@ package org.eclipse.cdt.core.model;
*/
public interface IVariableDeclaration extends ICElement, ISourceManipulation, ISourceReference {
- public String getType ();
- public int getAccessControl() throws CModelException;
+ public String getTypeName();
+ public void setTypeName(String type);
+ public int getAccessControl();
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java
index 62f640a5252..4a1c68ded9d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Field.java
@@ -5,7 +5,6 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
-import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IField;
@@ -15,22 +14,52 @@ public class Field extends SourceManipulation implements IField {
super(parent, name, CElement.C_FIELD);
}
- public boolean isMutable() throws CModelException {
- return false;
+ public int getAccessControl(){
+ return getFieldInfo().getAccessControl();
}
- /*
- * @IVariable
- */
- public String getType() {
- return "";
+ public boolean isMutable(){
+ return getFieldInfo().isMutable();
}
- /*
- * @IVariable
- */
- public String getInitializer() {
- return "";
+ public void setIsMutable(boolean mutable){
+ getFieldInfo().setIsMutable(mutable);
+ }
+
+ public String getTypeName() {
+ return getFieldInfo().getTypeName();
+ }
+
+ public void setTypeName(String type) {
+ getFieldInfo().setTypeName(type);
+ }
+
+ public boolean isConst() {
+ return getFieldInfo().isConst();
+ }
+
+ public void setIsConst(boolean isConst) {
+ getFieldInfo().setIsConst(isConst);
+ }
+
+ public boolean isVolatile() {
+ return getFieldInfo().isVolatile();
+ }
+
+ public void setIsVolatile(boolean isVolatile) {
+ getFieldInfo().setIsVolatile(isVolatile);
+ }
+
+ public int getVisibility() {
+ return getFieldInfo().getVisibility();
+ }
+
+ public void setVisibility(int visibility) {
+ getFieldInfo().setVisibility(visibility);
+ }
+
+ public FieldInfo getFieldInfo(){
+ return (FieldInfo) getElementInfo();
}
/**
@@ -41,35 +70,22 @@ public class Field extends SourceManipulation implements IField {
* @exception CModelException if this element does not exist or if an
* exception occurs while accessing its corresponding resource.
*/
- public boolean hasClassScope() throws CModelException {
+ public boolean hasClassScope(){
return false;
}
- /**
- * Returns whether this method/field is declared constant.
- *
- * @see IMember
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- public boolean isConst() throws CModelException {
- return false;
- }
-
- /**
- * Returns the access Control of the member. The access qualifier
- * can be examine using the AccessControl class.
- *
- * @see IMember
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- public int getAccessControl() throws CModelException {
- return 0;
- }
-
protected CElementInfo createElementInfo () {
- return new SourceManipulationInfo(this);
+ return new FieldInfo(this);
}
+ // tests both info stored in element and element info
+ public boolean isIdentical(Field other){
+ FieldInfo otherInfo= other.getFieldInfo();
+ if ( (this.equals(other))
+ && (getFieldInfo().hasSameContentsAs(otherInfo))
+ )
+ return true;
+ else
+ return false;
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FieldInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FieldInfo.java
new file mode 100644
index 00000000000..7ce84237cf4
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FieldInfo.java
@@ -0,0 +1,104 @@
+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.IMember;
+
+public class FieldInfo extends SourceManipulationInfo {
+
+ int flags = 0;
+ String typeStr;
+ boolean isConst = false;
+ boolean isVolatile = false;
+ boolean isMutable = false;
+ int visibility;
+
+ protected FieldInfo (CElement element) {
+ super(element);
+ flags = 0;
+ visibility = IMember.V_PRIVATE;
+ }
+
+ protected int getAccessControl() {
+ return flags;
+ }
+
+ protected String getTypeName(){
+ return typeStr;
+ }
+
+ /**
+ * Tests info stored in element info only
+ * @param otherInfo
+ * @return boolean
+ */
+ public boolean hasSameContentsAs( SourceManipulationInfo info){
+ FieldInfo otherInfo = (FieldInfo) info;
+ if( (typeStr.equals(otherInfo.getTypeName()))
+ && (isConst == otherInfo.isConst())
+ && (isVolatile == otherInfo.isVolatile())
+ && (isMutable == otherInfo.isMutable())
+ && (visibility == otherInfo.getVisibility())
+ )
+ return true;
+ else
+ return false;
+ }
+
+ protected void setAccessControl(int flags) {
+ this.flags = flags;
+ }
+
+ protected void setTypeName(String type){
+ typeStr = type;
+ }
+
+ protected boolean isConst(){
+ return isConst;
+ }
+
+ protected void setIsConst(boolean isConst){
+ this.isConst = isConst;
+ }
+
+ protected boolean isVolatile(){
+ return isVolatile;
+ }
+
+ protected void setIsVolatile(boolean isVolatile){
+ this.isVolatile = isVolatile;
+ }
+
+ protected boolean isMutable(){
+ return isMutable;
+ }
+
+ protected void setIsMutable(boolean mutable){
+ this.isMutable = mutable;
+ }
+ /**
+ * Returns the visibility.
+ * @return int
+ */
+ public int getVisibility() {
+ return visibility;
+ }
+
+ /**
+ * Sets the visibility.
+ * @param visibility The visibility to set
+ */
+ public void setVisibility(int visibility) {
+ this.visibility = visibility;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Function.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Function.java
index 64dffe6a9e5..7246a96c54e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Function.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Function.java
@@ -5,45 +5,12 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
-import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunction;
-public class Function extends SourceManipulation implements IFunction {
+public class Function extends FunctionDeclaration implements IFunction {
public Function(ICElement parent, String name) {
super(parent, name, CElement.C_FUNCTION);
}
-
- public String[] getExceptions() throws CModelException {
- return new String[] {};
- }
-
- public int getNumberOfParameters() {
- return 0;
- }
-
- public String getParameterInitializer(int pos) {
- return "";
- }
-
- public String[] getParameterTypes() {
- return new String[0];
- }
-
- public String getReturnType() throws CModelException {
- return "";
- }
-
- public int getAccessControl() throws CModelException {
- return getFunctionInfo().getAccessControl();
- }
-
- public FunctionInfo getFunctionInfo() {
- return (FunctionInfo)getElementInfo();
- }
-
- protected CElementInfo createElementInfo () {
- return new FunctionInfo(this);
- }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java
index 123013ba0f8..129b793f8c2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java
@@ -5,41 +5,94 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
-import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunctionDeclaration;
public class FunctionDeclaration extends SourceManipulation implements IFunctionDeclaration {
+ /**
+ * An empty list of Strings
+ */
+ protected static final String[] fgEmptyList= new String[] {};
+ protected String[] fParameterTypes;
+ protected String returnType;
public FunctionDeclaration(ICElement parent, String name) {
super(parent, name, CElement.C_FUNCTION_DECLARATION);
+ fParameterTypes= fgEmptyList;
}
- public String[] getExceptions() throws CModelException {
- return new String[] {};
+ public FunctionDeclaration(ICElement parent, String name, int type) {
+ super(parent, name, type);
+ fParameterTypes= fgEmptyList;
+ }
+
+ public String getReturnType(){
+ return returnType;
+ }
+
+ public void setReturnType(String type){
+ returnType = type;
+ getFunctionInfo().setReturnType(type);
}
public int getNumberOfParameters() {
- return 0;
- }
-
- public String getParameterInitializer(int pos) {
- return "";
+ return fParameterTypes == null ? 0 : fParameterTypes.length;
}
public String[] getParameterTypes() {
- return new String[0];
+ return fParameterTypes;
+ }
+
+ public void setParameterTypes(String[] parameterTypes) {
+ fParameterTypes = parameterTypes;
+ }
+
+ public String getSignature(){
+ String sig = getReturnType();
+ sig += " ";
+ sig += getElementName();
+ if(getNumberOfParameters() > 0){
+ sig += "(";
+ String[] paramTypes = getParameterTypes();
+ int i = 0;
+ sig += paramTypes[i++];
+ while (i < paramTypes.length){
+ sig += (", ");
+ sig += paramTypes[i++];
+ }
+ sig += ")";
+ }
+ else{
+ sig += "()";
+ }
+ return sig;
+ }
+
+ public String getParameterInitializer(int pos) {
+ return "";
+ }
+
+ public int getAccessControl(){
+ return getFunctionInfo().getAccessControl();
}
- public String getReturnType() throws CModelException {
- return "";
- }
-
- public int getAccessControl() throws CModelException {
- return 0;
+ public String[] getExceptions(){
+ return new String[] {};
}
protected CElementInfo createElementInfo () {
- return new SourceManipulationInfo(this);
+ return new FunctionInfo(this);
}
+
+ protected FunctionInfo getFunctionInfo(){
+ return (FunctionInfo) getElementInfo();
+ }
+
+ public boolean equals(Object other) {
+ return ( super.equals(other)
+ && Util.equalArraysOrNull(fParameterTypes, ((FunctionDeclaration)other).fParameterTypes)
+ && getReturnType().equals(((FunctionDeclaration)other).getReturnType())
+ );
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionInfo.java
index 73a4e69f8ea..f835118a08e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionInfo.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionInfo.java
@@ -8,6 +8,8 @@ package org.eclipse.cdt.internal.core.model;
class FunctionInfo extends SourceManipulationInfo {
protected int flags;
+ protected String returnType;
+ protected int numOfParams;
protected FunctionInfo (CElement element) {
super(element);
@@ -21,4 +23,12 @@ class FunctionInfo extends SourceManipulationInfo {
protected void setAccessControl(int flags) {
this.flags = flags;
}
+
+ protected String getReturnType(){
+ return returnType;
+ }
+
+ protected void setReturnType(String type){
+ returnType = type;
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Method.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Method.java
index 61f09dc93a1..adaf4a5bfa8 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Method.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Method.java
@@ -5,120 +5,12 @@ package org.eclipse.cdt.internal.core.model;
* All Rights Reserved.
*/
-import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IMethod;
-public class Method extends SourceManipulation implements IMethod {
+public class Method extends MethodDeclaration implements IMethod{
- public Method(ICElement parent, String name) {
+ public Method(ICElement parent, String name){
super(parent, name, CElement.C_METHOD);
}
-
- /**
- * @see IMethod
- */
- public boolean isConstructor() throws CModelException {
- return getElementName().equals(getParent().getElementName());
- }
-
- /**
- * @see IMethod
- */
- public boolean isDestructor() throws CModelException {
- return getElementName().startsWith("~");
- }
-
- /**
- * @see IMethod
- */
- public boolean isOperator() throws CModelException {
- return getElementName().startsWith("operator");
- }
-
- /**
- * @see IMethod
- */
- public boolean isAbstract() throws CModelException {
- return false;
- }
-
- /**
- * @see IMethod
- */
- public boolean isVirtual() throws CModelException {
- return false;
- }
-
- /**
- * @see IMethod
- */
- public boolean isFriend() throws CModelException {
- return false;
- }
-
- /**
- * @see IMethod
- */
- public String[] getExceptions() {
- return new String[0];
- }
-
- /**
- * @see IMethod
- */
- public int getNumberOfParameters() {
- return 0;
- }
-
- public String getParameterInitializer(int pos) {
- return "";
- }
-
- public String[] getParameterTypes() {
- return new String[0];
- }
-
- public String getReturnType() throws CModelException {
- return "";
- }
-
- /**
- * Returns true if the member as class scope.
- * For example static methods in C++ have class scope
- *
- * @see IMember
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- public boolean hasClassScope() throws CModelException {
- return false;
- }
-
- /**
- * Returns whether this method/field is declared constant.
- *
- * @see IMember
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- public boolean isConst() throws CModelException {
- return false;
- }
-
- /**
- * Returns the access Control of the member. The access qualifier
- * can be examine using the AccessControl class.
- *
- * @see IMember
- * @exception CModelException if this element does not exist or if an
- * exception occurs while accessing its corresponding resource.
- */
- public int getAccessControl() throws CModelException {
- return 0;
- }
-
- protected CElementInfo createElementInfo () {
- return new SourceManipulationInfo(this);
- }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java
new file mode 100644
index 00000000000..185c742314d
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodDeclaration.java
@@ -0,0 +1,134 @@
+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.IMethodDeclaration;
+
+public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{
+
+
+ public MethodDeclaration(ICElement parent, String name){
+ super(parent, name, CElement.C_METHOD_DECLARATION);
+ }
+
+
+ public MethodDeclaration(ICElement parent, String name, int type){
+ super(parent, name, type);
+ }
+
+ /**
+ * @see IMethod
+ */
+ public boolean isConstructor(){
+ return getElementName().equals(getParent().getElementName());
+ }
+
+ /**
+ * @see IMethod
+ */
+ public boolean isDestructor() {
+ return getElementName().startsWith("~");
+ }
+
+ /**
+ * @see IMethod
+ */
+ public boolean isOperator(){
+ return getElementName().startsWith("operator");
+ }
+
+ public boolean isAbstract(){
+ return getMethodInfo().isAbstract();
+ }
+
+ public void setIsAbstract(boolean isAbstract){
+ getMethodInfo().setIsAbstract(isAbstract);
+ }
+
+ public boolean isStatic(){
+ return getMethodInfo().isStatic();
+ }
+
+ public void setIsStatic(boolean isStatic){
+ getMethodInfo().setIsStatic(isStatic);
+ }
+
+ public boolean isInline(){
+ return getMethodInfo().isInline();
+ }
+
+ public void setIsInline(boolean isInline){
+ getMethodInfo().setIsInline(isInline);
+ }
+
+ public boolean isVirtual(){
+ return getMethodInfo().isVirtual();
+ }
+
+ public void setIsVirtual(boolean isVirtual){
+ getMethodInfo().setIsVirtual(isVirtual);
+ }
+
+ public boolean isFriend(){
+ return getMethodInfo().isFriend();
+ }
+
+ public void setIsFriend(boolean isFriend){
+ getMethodInfo().setIsFriend(isFriend);
+ }
+
+ public boolean isConst(){
+ return getMethodInfo().isConst();
+ }
+
+ public void setIsConst(boolean isConst){
+ getMethodInfo().setIsConst(isConst);
+ }
+
+ public boolean isVolatile(){
+ return getMethodInfo().isVolatile();
+ }
+
+ public void setIsVolatile(boolean isVolatile){
+ getMethodInfo().setIsVolatile(isVolatile);
+ }
+
+ public int getVisibility(){
+ return getMethodInfo().getVisibility();
+ }
+
+ public void setVisibility(int visibility){
+ getMethodInfo().setVisibility(visibility);
+ }
+ // do we need this one or not?
+ // can we get this info from the parser or not?
+ public boolean hasClassScope(){
+ return false;
+ }
+
+ protected CElementInfo createElementInfo () {
+ return new MethodInfo(this);
+ }
+
+ private MethodInfo getMethodInfo(){
+ return (MethodInfo) getElementInfo();
+ }
+
+ /*
+ * See if we need anything else to put in equals here
+ */
+ public boolean equals(Object other) {
+ return ( super.equals(other) );
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodInfo.java
new file mode 100644
index 00000000000..154c4c82b0b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MethodInfo.java
@@ -0,0 +1,105 @@
+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.IMember;
+
+public class MethodInfo extends FunctionInfo {
+
+ boolean isAbstract = false;
+ boolean isStatic = false;
+ boolean isInline = false;
+ boolean isVirtual = false;
+ boolean isFriend = false;
+ boolean isConst = false;
+ boolean isVolatile = false;
+ int visibility;
+
+ MethodInfo(CElement element) {
+ super(element);
+ visibility = IMember.V_PRIVATE;
+ }
+
+ public boolean isAbstract(){
+ return isAbstract;
+ }
+
+ public void setIsAbstract(boolean isAbstract){
+ this.isAbstract = isAbstract;
+ }
+
+ public boolean isStatic(){
+ return isStatic;
+ }
+
+ public void setIsStatic(boolean isStatic){
+ this.isStatic = isStatic;
+ }
+
+ public boolean isInline(){
+ return isInline;
+ }
+
+ public void setIsInline(boolean isInline){
+ this.isInline = isInline;
+ }
+
+ public boolean isVirtual(){
+ return isVirtual;
+ }
+
+ public void setIsVirtual(boolean isVirtual){
+ this.isVirtual = isVirtual;
+ }
+
+ public boolean isFriend(){
+ return isFriend;
+ }
+
+ public void setIsFriend(boolean isFriend){
+ this.isFriend = isFriend;
+ }
+
+ public boolean isConst(){
+ return isConst;
+ }
+
+ public void setIsConst(boolean isConst){
+ this.isConst = isConst;
+ }
+
+ public boolean isVolatile(){
+ return isVolatile;
+ }
+
+ public void setIsVolatile(boolean isVolatile){
+ this.isVolatile = isVolatile;
+ }
+
+
+ /**
+ * Returns the visibility.
+ * @return int
+ */
+ public int getVisibility() {
+ return visibility;
+ }
+
+ /**
+ * Sets the visibility.
+ * @param visibility The visibility to set
+ */
+ public void setVisibility(int visibility) {
+ this.visibility = visibility;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java
index 30df405ba43..16d4edc6d50 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Structure.java
@@ -37,22 +37,22 @@ public class Structure extends SourceManipulation implements IStructure {
}
public boolean isUnion() {
- return getElementType() == ICElement.C_UNION;
+ return getStructureInfo().isUnion();
}
public boolean isClass() {
- return getElementType() == ICElement.C_CLASS;
+ return getStructureInfo().isClass();
}
public boolean isStruct() {
- return getElementType() == ICElement.C_STRUCT;
+ return getStructureInfo().isStruct();
}
public boolean isAbstract() {
return false;
}
- public int getAccessControl() throws CModelException {
+ public int getAccessControl(){
return 0;
}
@@ -67,14 +67,17 @@ public class Structure extends SourceManipulation implements IStructure {
/**
* @see IVariable
*/
- public String getType() {
- if (isClass())
- return "class";
- if (isUnion())
- return "union";
- return "struct";
+ public String getTypeName() {
+ return getStructureInfo().getTypeName();
+ }
+
+ public void setTypeName(String type){
+ getStructureInfo().setTypeString(type);
+ }
+
+ public StructureInfo getStructureInfo(){
+ return (StructureInfo) getElementInfo();
}
-
/**
* @see IVariable
*/
@@ -90,7 +93,7 @@ public class Structure extends SourceManipulation implements IStructure {
}
protected CElementInfo createElementInfo () {
- return new SourceManipulationInfo(this);
+ return new StructureInfo(this);
}
/**
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureInfo.java
new file mode 100644
index 00000000000..f0aba19e744
--- /dev/null
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/StructureInfo.java
@@ -0,0 +1,54 @@
+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;
+
+public class StructureInfo extends SourceManipulationInfo {
+
+ String type;
+
+ protected StructureInfo (CElement element) {
+ super(element);
+
+ if (element.getElementType() == ICElement.C_CLASS)
+ type = "class";
+ else if (element.getElementType() == ICElement.C_UNION)
+ type = "union";
+ else
+ type = "struct";
+ }
+
+ public boolean isUnion() {
+ return element.getElementType() == ICElement.C_UNION;
+ }
+
+ public boolean isClass() {
+ return element.getElementType() == ICElement.C_CLASS;
+ }
+
+ public boolean isStruct() {
+ return element.getElementType() == ICElement.C_STRUCT;
+ }
+
+ public String getTypeName(){
+ return type;
+ }
+
+ public void setTypeString(String elmType){
+ type = elmType;
+ }
+ public boolean hasSameContentsAs( StructureInfo otherInfo){
+ return true;
+ }
+
+}
+
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
index cd5dae3ab3b..ca546c3f547 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java
@@ -166,4 +166,66 @@ public class Util {
public static int combineHashCodes(int hashCode1, int hashCode2) {
return hashCode1 * 17 + hashCode2;
}
+ /**
+ * Compares two arrays using equals() on the elements.
+ * Either or both arrays may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * If both are arrays, returns true iff they have the same length and
+ * all elements compare true with equals.
+ */
+ public static boolean equalArraysOrNull(Object[] a, Object[] b) {
+ if (a == b) return true;
+ if (a == null || b == null) return false;
+
+ int len = a.length;
+ if (len != b.length) return false;
+ for (int i = 0; i < len; ++i) {
+ if (a[i] == null) {
+ if (b[i] != null) return false;
+ } else {
+ if (!a[i].equals(b[i])) return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * Compares two arrays using equals() on the elements.
+ * Either or both arrays may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * If both are arrays, returns true iff they have the same length and
+ * all elements are equal.
+ */
+ public static boolean equalArraysOrNull(int[] a, int[] b) {
+ if (a == b)
+ return true;
+ if (a == null || b == null)
+ return false;
+ int len = a.length;
+ if (len != b.length)
+ return false;
+ for (int i = 0; i < len; ++i) {
+ if (a[i] != b[i])
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Compares two objects using equals().
+ * Either or both array may be null.
+ * Returns true if both are null.
+ * Returns false if only one is null.
+ * Otherwise, return the result of comparing with equals().
+ */
+ public static boolean equalOrNull(Object a, Object b) {
+ if (a == b) {
+ return true;
+ }
+ if (a == null || b == null) {
+ return false;
+ }
+ return a.equals(b);
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java
index 13b870457e8..402f116b5cf 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Variable.java
@@ -14,10 +14,13 @@ public class Variable extends SourceManipulation implements IVariable {
super(parent, name, CElement.C_VARIABLE);
}
- public String getType() {
- return "";
+ public String getTypeName() {
+ return getVariableInfo().getTypeName();
}
+ public void setTypeName(String type){
+ getVariableInfo().setTypeName(type);
+ }
public String getInitializer() {
return "";
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java
index c9e4fc44b6c..92fc3c56c08 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableDeclaration.java
@@ -14,14 +14,22 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
super(parent, name, CElement.C_VARIABLE_DECLARATION);
}
- public String getType() {
- return "";
- }
-
public int getAccessControl() {
- return 0;
+ return getVariableInfo().getAccessControl();
}
+ public String getTypeName() {
+ return getVariableInfo().getTypeName();
+ }
+
+ public void setTypeName(String type) {
+ getVariableInfo().setTypeString(type);
+ }
+
+ public VariableInfo getVariableInfo(){
+ return (VariableInfo) getElementInfo();
+ }
+
protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this);
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableInfo.java
index 14ebea22877..c4c491305ba 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableInfo.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/VariableInfo.java
@@ -8,7 +8,8 @@ package org.eclipse.cdt.internal.core.model;
class VariableInfo extends SourceManipulationInfo {
protected int flags;
-
+ String typeStr;
+
protected VariableInfo (CElement element) {
super(element);
flags = 0;
@@ -18,7 +19,26 @@ class VariableInfo extends SourceManipulationInfo {
return flags;
}
+ protected String getTypeName(){
+ return typeStr;
+ }
+
+ protected void setTypeName(String type){
+ typeStr = type;
+ }
+
+ protected boolean hasSameContentsAs( VariableInfo otherInfo){
+ if(typeStr.equals(otherInfo.getTypeName()))
+ return true;
+ else
+ return false;
+ }
+
protected void setAccessControl(int flags) {
this.flags = flags;
}
+
+ protected void setTypeString(String type){
+ typeStr = type;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
index 2796524fb6c..74cb4325b76 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/NewModelBuilder.java
@@ -129,9 +129,10 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
ICElementWrapper wrapper = (ICElementWrapper)container;
Object parent = wrapper.getElement();
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
- if( wrapper instanceof SimpleDeclarationWrapper )
+ if( wrapper instanceof SimpleDeclarationWrapper ){
result.setParent( (CElement)wrapper.getElement() );
- else if ( wrapper instanceof TranslationUnitWrapper )
+ result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
+ } else if ( wrapper instanceof TranslationUnitWrapper )
result.setParent( (TranslationUnit)wrapper.getElement());
return result;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
index c9cb995d503..9d196d7d533 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/SimpleDeclarationWrapper.java
@@ -88,34 +88,43 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
// this is an attribute or a varaible
if( parentElement instanceof IStructure )
{
- declaration = new Field( parentElement, currentDeclarator.getName().toString() );
+ declaration = createField( parentElement, currentDeclarator.getName().toString() );
}
else if( parentElement instanceof ITranslationUnit )
{
- declaration = new Variable( parentElement, currentDeclarator.getName().toString() );
+ if(isExtern())
+ {
+ declaration = createVariableDeclaration( parentElement, currentDeclarator.getName().toString() );
+ }
+ else
+ {
+ declaration = createVariable( parentElement, currentDeclarator.getName().toString() );
+ }
}
}
else
{
+ Parameter [] parameters = (Parameter []) clause.toArray( new Parameter[ clause.size() ]);
// this is a function or a method
if( parentElement instanceof IStructure )
{
- declaration = new Method( parentElement, currentDeclarator.getName().toString() );
+ declaration = createMethodDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
}
else if( parentElement instanceof ITranslationUnit )
{
- declaration = new FunctionDeclaration( parentElement, currentDeclarator.getName().toString() );
- }
-
- Parameter [] parameters = (Parameter []) clause.toArray( new Parameter[ clause.size() ]);
-
- for( int j = 0; j< parameters.length; ++j )
- {
- Parameter parm = parameters[j];
-
- }
-
+ if (isFunctionDefinition())
+ {
+ // if it belongs to a class, then create a method
+ // else create a function
+ // this will not be known until we have cross reference information
+ declaration = createFunction( parentElement, currentDeclarator.getName().toString(), parameters );
+ }
+ else
+ {
+ declaration = createFunctionDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
+ }
+ }
}
// hook up the offsets
@@ -216,7 +225,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
public static final int v_public = 0;
public static final int v_protected = 1;
- public static final int v_private = 3;
+ public static final int v_private = 2;
private int currentVisibility;
/**
@@ -233,5 +242,115 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
public void setCurrentVisibility(int currentVisibility) {
this.currentVisibility = currentVisibility;
}
+
+ /**
+ * Creates a Field and fills its info
+ * @param parent
+ * @param name
+ * @return CElement
+ */
+ private CElement createField(CElement parent, String name){
+ Field newElement = new Field( parent, name );
+ newElement.setTypeName ( getTypeName() );
+ newElement.setIsConst(isConst());
+ newElement.setIsMutable(isMutable());
+ newElement.setVisibility(this.getCurrentVisibility());
+ return newElement;
+ }
+
+ /**
+ * Creates a Variable and fills its info
+ * @param parent
+ * @param name
+ * @return CElement
+ */
+ private CElement createVariable(CElement parent, String name){
+ Variable newElement = new Variable( parent, name );
+ newElement.setTypeName ( getTypeName() );
+ return newElement;
+ }
+
+ /**
+ * Creates a VariableDeclaration and fills its info
+ * @param parent
+ * @param name
+ * @return CElement
+ */
+ private CElement createVariableDeclaration(CElement parent, String name){
+ VariableDeclaration newElement = new VariableDeclaration( parent, name );
+ newElement.setTypeName ( getTypeName() );
+ return newElement;
+ }
+
+
+ /**
+ * Creates a MethodDeclaration and fills its info
+ * @param parent
+ * @param name
+ * @param parameters
+ * @return CElement
+ */
+ private CElement createMethodDeclaration(CElement parent, String name, Parameter[] parameters){
+ String[] parameterTypes = new String[parameters.length];
+ for( int j = 0; j< parameters.length; ++j )
+ {
+ Parameter param = parameters[j];
+ parameterTypes[j] = new String(param.getTypeName());
+ }
+
+ MethodDeclaration newElement = new MethodDeclaration( parent, name );
+ newElement.setParameterTypes(parameterTypes);
+ newElement.setReturnType( getTypeName() );
+ newElement.setVisibility(this.getCurrentVisibility());
+ return newElement;
+ }
+
+ /**
+ * Creates a Method and fills its info
+ * @param parent
+ * @param name
+ * @param parameters
+ * @return CElement
+ */
+ private CElement createMethod(CElement parent, String name, Parameter[] parameters){
+ String[] parameterTypes = new String[parameters.length];
+ for( int j = 0; j< parameters.length; ++j )
+ {
+ Parameter param = parameters[j];
+ parameterTypes[j] = new String(param.getTypeName());
+ }
+
+ Method newElement = new Method( parent, name );
+ newElement.setParameterTypes(parameterTypes);
+ newElement.setReturnType( getTypeName() );
+ newElement.setVisibility(this.getCurrentVisibility());
+ return newElement;
+ }
+
+ /**
+ * Creates a FunctionDeclaration and fills its info
+ * @param parent
+ * @param name
+ * @param parameters
+ * @return CElement
+ */
+ private CElement createFunctionDeclaration(CElement parent, String name, Parameter[] parameters){
+ FunctionDeclaration newElement = new FunctionDeclaration( parent, name );
+ newElement.setReturnType( getTypeName() );
+ return newElement;
+ }
+
+ /**
+ * Creates a Function and fills its info
+ * @param parent
+ * @param name
+ * @param parameters
+ * @return CElement
+ */
+ private CElement createFunction(CElement parent, String name, Parameter[] parameters){
+ Function newElement = new Function( parent, name );
+ newElement.setReturnType( getTypeName() );
+ return newElement;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/DeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/DeclSpecifier.java
index 65cd62da48e..3306eae34fa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/DeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/DeclSpecifier.java
@@ -220,5 +220,33 @@ public class DeclSpecifier {
public void setName(Name name) {
this.name = name;
}
+
+ /**
+ * Returns the type as a String
+ * @return String
+ */
+ public String getTypeName(){
+ switch(getType()){
+ case t_char:
+ return "char";
+ case t_wchar_t:
+ return "wchar_t";
+ case t_bool:
+ return "bool";
+ case t_int:
+ return "int";
+ case t_float:
+ return "float";
+ case t_double:
+ return "double";
+ case t_void:
+ return "void";
+ case t_type:
+ if (getName() != null)
+ return getName().toString();
+ default:
+ return "";
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/private_m.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/private_m.gif
new file mode 100644
index 00000000000..b5b88535179
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/obj16/private_m.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/protected_m.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/protected_m.gif
new file mode 100644
index 00000000000..2b76d36edf5
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/obj16/protected_m.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/public_m.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/public_m.gif
new file mode 100644
index 00000000000..18103b11fc7
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/obj16/public_m.gif differ
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
index 491a2f94a14..df0e836334d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementImageProvider.java
@@ -14,6 +14,8 @@ import org.eclipse.cdt.core.model.IBinary;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.ui.*;
import org.eclipse.core.resources.IProject;
@@ -211,7 +213,17 @@ public class CElementImageProvider {
case ICElement.C_VARIABLE:
return CPluginImages.DESC_OBJS_FIELD;
- case ICElement.C_METHOD: // FIXME: provide an icon for methods.
+ case ICElement.C_METHOD:
+ case ICElement.C_METHOD_DECLARATION:
+ IMethodDeclaration md= (IMethodDeclaration)celement;
+ switch(md.getVisibility()){
+ case IMember.V_PUBLIC:
+ return CPluginImages.DESC_OBJS_PUBLIC_METHOD;
+ case IMember.V_PROTECTED:
+ return CPluginImages.DESC_OBJS_PROTECTED_METHOD;
+ case IMember.V_PRIVATE:
+ return CPluginImages.DESC_OBJS_PRIVATE_METHOD;
+ }
case ICElement.C_FUNCTION:
return CPluginImages.DESC_OBJS_FUNCTION;
@@ -248,7 +260,9 @@ public class CElementImageProvider {
case ICElement.C_VARIABLE:
return CPluginImages.DESC_OBJS_FIELD;
- case ICElement.C_METHOD: // FIXME: Provide a different icon.
+ case ICElement.C_METHOD: // assumed public
+ return CPluginImages.DESC_OBJS_PUBLIC_METHOD;
+
case ICElement.C_FUNCTION:
case ICElement.C_FUNCTION_DECLARATION:
return CPluginImages.DESC_OBJS_FUNCTION;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
index 8560c809362..d92d3acb7b7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java
@@ -48,6 +48,9 @@ public class CPluginImages {
public static final String IMG_OBJS_STRUCT= NAME_PREFIX + "struct_obj.gif";
public static final String IMG_OBJS_UNION= NAME_PREFIX + "union_obj.gif";
public static final String IMG_OBJS_FUNCTION= NAME_PREFIX + "function_obj.gif";
+ public static final String IMG_OBJS_PUBLIC_METHOD= NAME_PREFIX + "public_m.gif";
+ public static final String IMG_OBJS_PROTECTED_METHOD= NAME_PREFIX + "protected_m.gif";
+ public static final String IMG_OBJS_PRIVATE_METHOD= NAME_PREFIX + "private_m.gif";
public static final String IMG_OBJS_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif";
public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_obj.gif";
public static final String IMG_OBJS_MACRO= NAME_PREFIX + "define_obj.gif";
@@ -70,6 +73,9 @@ public class CPluginImages {
public static final ImageDescriptor DESC_OBJS_STRUCT= createManaged(T_OBJ, IMG_OBJS_STRUCT);
public static final ImageDescriptor DESC_OBJS_UNION= createManaged(T_OBJ, IMG_OBJS_UNION);
public static final ImageDescriptor DESC_OBJS_FUNCTION= createManaged(T_OBJ, IMG_OBJS_FUNCTION);
+ public static final ImageDescriptor DESC_OBJS_PUBLIC_METHOD= createManaged(T_OBJ, IMG_OBJS_PUBLIC_METHOD);
+ public static final ImageDescriptor DESC_OBJS_PROTECTED_METHOD= createManaged(T_OBJ, IMG_OBJS_PROTECTED_METHOD);
+ public static final ImageDescriptor DESC_OBJS_PRIVATE_METHOD= createManaged(T_OBJ, IMG_OBJS_PRIVATE_METHOD);
public static final ImageDescriptor DESC_OBJS_DECLARARION= createManaged(T_OBJ, IMG_OBJS_DECLARATION);
public static final ImageDescriptor DESC_OBJS_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
index 81f5625de04..5b5bcbd1327 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java
@@ -8,6 +8,9 @@ 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.ICFile;
+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;
import org.eclipse.cdt.internal.ui.IAdornmentProvider;
@@ -57,12 +60,29 @@ public class CElementLabelProvider extends LabelProvider {
if (element instanceof ICElement) {
ICElement celem= (ICElement)element;
- String name= celem.getElementName();
- if (celem.getElementType() == ICElement.C_FUNCTION) {
- name += "()";
- } else if(celem.getElementType() == ICElement.C_FUNCTION_DECLARATION) {
- name += "();";
+ String name;
+ switch(celem.getElementType()){
+ case ICElement.C_FUNCTION:
+ case ICElement.C_FUNCTION_DECLARATION:
+ case ICElement.C_METHOD:
+ case ICElement.C_METHOD_DECLARATION:
+ IFunctionDeclaration fdecl = (IFunctionDeclaration) celem;
+ name = fdecl.getSignature();
+ break;
+ case ICElement.C_VARIABLE:
+ IVariable var = (IVariable) celem;
+ name = var.getTypeName() + " " + var.getElementName();
+ break;
+ case ICElement.C_VARIABLE_DECLARATION:
+ case ICElement.C_FIELD:
+ IVariableDeclaration vdecl = (IVariableDeclaration) celem;
+ name = vdecl.getTypeName() + " " + vdecl.getElementName();
+ break;
+ default:
+ name= celem.getElementName();
+ break;
}
+
if (celem instanceof IBinary) {
IBinary bin = (IBinary)celem;
name += " - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]";