mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 03:53:21 +02:00
Patch for Hoda Amer:
- updates the C model to enable the Outline view to display type and visibility info for both fields and methods.
This commit is contained in:
parent
481e7cbf62
commit
dd13b8fe53
31 changed files with 920 additions and 505 deletions
|
@ -16,5 +16,5 @@ public interface IField extends IMember, IVariableDeclaration {
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
public boolean isMutable() throws CModelException;
|
public boolean isMutable();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,71 +8,6 @@ package org.eclipse.cdt.core.model;
|
||||||
/**
|
/**
|
||||||
* Represents a function.
|
* 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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declaring <code>"void f(int a) throw (x2, x3);"</code>,
|
|
||||||
* would return the array <code>{"x2", "x3"}</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a method declared as <code>void foo(String text, int length=9)</code>
|
|
||||||
* would return the array <code>{"9"}</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>void foo(string text, int length)</code>
|
|
||||||
* would return the array <code>{"string","int"}</code>.
|
|
||||||
*
|
|
||||||
* @see Signature
|
|
||||||
*/
|
|
||||||
public String[] getParameterTypes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the type signature of the return value of this method.
|
|
||||||
* For constructors, this returns the signature for void.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>int getName()</code>
|
|
||||||
* would return <code>"int"</code>.
|
|
||||||
*
|
|
||||||
* @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 <code>Flags</code>.
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public interface IFunctionDeclaration extends ICElement, ISourceReference, ISour
|
||||||
*
|
*
|
||||||
* @see Signature
|
* @see Signature
|
||||||
*/
|
*/
|
||||||
String[] getExceptions() throws CModelException;
|
String[] getExceptions();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of parameters of this method.
|
* Returns the number of parameters of this method.
|
||||||
|
@ -55,18 +55,14 @@ public interface IFunctionDeclaration extends ICElement, ISourceReference, ISour
|
||||||
String[] getParameterTypes();
|
String[] getParameterTypes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type signature of the return value of this method.
|
* Returns the return value of this method.
|
||||||
* For constructors, this returns the signature for void.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>public String getName()</code>
|
|
||||||
* would return <code>"String"</code>.
|
|
||||||
*
|
|
||||||
* @exception CModelException if this element does not exist or if an
|
|
||||||
* exception occurs while accessing its corresponding resource.
|
|
||||||
*
|
|
||||||
* @see Signature
|
|
||||||
*/
|
*/
|
||||||
String getReturnType() throws CModelException;
|
String getReturnType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the signature of the method.
|
||||||
|
*/
|
||||||
|
String getSignature();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the access Control of the member. The access qualifier
|
* 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.
|
* exception occurs while accessing its corresponding resource.
|
||||||
* @see IAccessControl
|
* @see IAccessControl
|
||||||
*/
|
*/
|
||||||
int getAccessControl() throws CModelException;
|
int getAccessControl();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,21 +12,20 @@ package org.eclipse.cdt.core.model;
|
||||||
*/
|
*/
|
||||||
public interface IMember extends ICElement, ISourceReference, ISourceManipulation {
|
public interface IMember extends ICElement, ISourceReference, ISourceManipulation {
|
||||||
|
|
||||||
///**
|
static final int V_PUBLIC = 0;
|
||||||
//* Returns the structure in which this member is declared, or <code>null</code>
|
static final int V_PROTECTED = 1;
|
||||||
//* if this member is not declared in a type (for example, a top-level type).
|
static final int V_PRIVATE = 2;
|
||||||
//*/
|
|
||||||
//IStructure belongsTo() throws CModelException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the member as class scope.
|
* Returns true if the member has class scope. For example static methods in
|
||||||
* For example static methods in C++ have class scope
|
* C++ have class scope
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
public boolean hasClassScope() throws CModelException;
|
public boolean hasClassScope();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this method/field is declared constant.
|
* 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 CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* 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
|
* 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.
|
* exception occurs while accessing its corresponding resource.
|
||||||
* @see IAccessControl
|
* @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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,110 +8,6 @@ package org.eclipse.cdt.core.model;
|
||||||
/**
|
/**
|
||||||
* Represents the definition method of a class.
|
* 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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declaring <code>"throws IOException"</code>,
|
|
||||||
* would return the array <code>{"QIOException;"}</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a method declared as <code>public void foo(String text, int length=9)</code>
|
|
||||||
* would return the array <code>{"9"}</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>void foo(String text, int length)</code>
|
|
||||||
* would return the array <code>{"String","int"}</code>.
|
|
||||||
*
|
|
||||||
* @see Signature
|
|
||||||
*/
|
|
||||||
String[] getParameterTypes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the type signature of the return value of this method.
|
|
||||||
* For constructors, this returns the signature for void.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>public String getName()</code>
|
|
||||||
* would return <code>"String"</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>virtual void m() = 0;</code>.
|
|
||||||
*
|
|
||||||
* @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;
|
|
||||||
}
|
|
|
@ -10,71 +10,13 @@ package org.eclipse.cdt.core.model;
|
||||||
*/
|
*/
|
||||||
public interface IMethodDeclaration extends IMember, IFunctionDeclaration {
|
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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declaring <code>"throws IOException"</code>,
|
|
||||||
* would return the array <code>{"QIOException;"}</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a method declared as <code>public void foo(String text, int length=9)</code>
|
|
||||||
* would return the array <code>{"9"}</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>void foo(String text, int length)</code>
|
|
||||||
* would return the array <code>{"String","int"}</code>.
|
|
||||||
*
|
|
||||||
* @see Signature
|
|
||||||
*/
|
|
||||||
String[] getParameterTypes();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the type signature of the return value of this method.
|
|
||||||
* For constructors, this returns the signature for void.
|
|
||||||
*
|
|
||||||
* <p>For example, a source method declared as <code>public String getName()</code>
|
|
||||||
* would return <code>"String"</code>.
|
|
||||||
*
|
|
||||||
* @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.
|
* Returns whether this method is a constructor.
|
||||||
*
|
*
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
boolean isConstructor() throws CModelException;
|
boolean isConstructor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this method is a destructor.
|
* 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 CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
boolean isDestructor() throws CModelException;
|
boolean isDestructor();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this method is an operator method.
|
* 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 CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
boolean isOperator() throws CModelException;
|
boolean isOperator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this method is declared pure virtual.
|
* 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 CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* 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.
|
* Returns whether this method is declared virtual.
|
||||||
*
|
*
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
boolean isVirtual() throws CModelException;
|
boolean isVirtual();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if the member is a friend.
|
* return true if the member is a friend.
|
||||||
*/
|
*/
|
||||||
public boolean isFriend() throws CModelException;
|
public boolean isFriend();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ package org.eclipse.cdt.core.model;
|
||||||
* Represents a global variable.
|
* Represents a global variable.
|
||||||
*/
|
*/
|
||||||
public interface IVariable extends ICElement , ISourceManipulation, ISourceReference {
|
public interface IVariable extends ICElement , ISourceManipulation, ISourceReference {
|
||||||
public String getType();
|
public String getTypeName();
|
||||||
|
public void setTypeName(String type);
|
||||||
public String getInitializer();
|
public String getInitializer();
|
||||||
public int getAccessControl() throws CModelException;
|
public int getAccessControl() throws CModelException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ package org.eclipse.cdt.core.model;
|
||||||
*/
|
*/
|
||||||
public interface IVariableDeclaration extends ICElement, ISourceManipulation, ISourceReference {
|
public interface IVariableDeclaration extends ICElement, ISourceManipulation, ISourceReference {
|
||||||
|
|
||||||
public String getType ();
|
public String getTypeName();
|
||||||
public int getAccessControl() throws CModelException;
|
public void setTypeName(String type);
|
||||||
|
public int getAccessControl();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IField;
|
import org.eclipse.cdt.core.model.IField;
|
||||||
|
|
||||||
|
@ -15,22 +14,52 @@ public class Field extends SourceManipulation implements IField {
|
||||||
super(parent, name, CElement.C_FIELD);
|
super(parent, name, CElement.C_FIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMutable() throws CModelException {
|
public int getAccessControl(){
|
||||||
return false;
|
return getFieldInfo().getAccessControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public boolean isMutable(){
|
||||||
* @IVariable
|
return getFieldInfo().isMutable();
|
||||||
*/
|
|
||||||
public String getType() {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
public void setIsMutable(boolean mutable){
|
||||||
* @IVariable
|
getFieldInfo().setIsMutable(mutable);
|
||||||
*/
|
}
|
||||||
public String getInitializer() {
|
|
||||||
return "";
|
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 CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource.
|
* exception occurs while accessing its corresponding resource.
|
||||||
*/
|
*/
|
||||||
public boolean hasClassScope() throws CModelException {
|
public boolean hasClassScope(){
|
||||||
return false;
|
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 () {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,45 +5,12 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IFunction;
|
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) {
|
public Function(ICElement parent, String name) {
|
||||||
super(parent, name, CElement.C_FUNCTION);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,41 +5,94 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||||
|
|
||||||
public class FunctionDeclaration extends SourceManipulation implements 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) {
|
public FunctionDeclaration(ICElement parent, String name) {
|
||||||
super(parent, name, CElement.C_FUNCTION_DECLARATION);
|
super(parent, name, CElement.C_FUNCTION_DECLARATION);
|
||||||
|
fParameterTypes= fgEmptyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getExceptions() throws CModelException {
|
public FunctionDeclaration(ICElement parent, String name, int type) {
|
||||||
return new String[] {};
|
super(parent, name, type);
|
||||||
|
fParameterTypes= fgEmptyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReturnType(){
|
||||||
|
return returnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReturnType(String type){
|
||||||
|
returnType = type;
|
||||||
|
getFunctionInfo().setReturnType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNumberOfParameters() {
|
public int getNumberOfParameters() {
|
||||||
return 0;
|
return fParameterTypes == null ? 0 : fParameterTypes.length;
|
||||||
}
|
|
||||||
|
|
||||||
public String getParameterInitializer(int pos) {
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameterTypes() {
|
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 {
|
public String[] getExceptions(){
|
||||||
return "";
|
return new String[] {};
|
||||||
}
|
|
||||||
|
|
||||||
public int getAccessControl() throws CModelException {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CElementInfo createElementInfo () {
|
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())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
class FunctionInfo extends SourceManipulationInfo {
|
class FunctionInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected int flags;
|
protected int flags;
|
||||||
|
protected String returnType;
|
||||||
|
protected int numOfParams;
|
||||||
|
|
||||||
protected FunctionInfo (CElement element) {
|
protected FunctionInfo (CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
|
@ -21,4 +23,12 @@ class FunctionInfo extends SourceManipulationInfo {
|
||||||
protected void setAccessControl(int flags) {
|
protected void setAccessControl(int flags) {
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getReturnType(){
|
||||||
|
return returnType;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setReturnType(String type){
|
||||||
|
returnType = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,120 +5,12 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IMethod;
|
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);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,22 +37,22 @@ public class Structure extends SourceManipulation implements IStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUnion() {
|
public boolean isUnion() {
|
||||||
return getElementType() == ICElement.C_UNION;
|
return getStructureInfo().isUnion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClass() {
|
public boolean isClass() {
|
||||||
return getElementType() == ICElement.C_CLASS;
|
return getStructureInfo().isClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStruct() {
|
public boolean isStruct() {
|
||||||
return getElementType() == ICElement.C_STRUCT;
|
return getStructureInfo().isStruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAbstract() {
|
public boolean isAbstract() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAccessControl() throws CModelException {
|
public int getAccessControl(){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,14 +67,17 @@ public class Structure extends SourceManipulation implements IStructure {
|
||||||
/**
|
/**
|
||||||
* @see IVariable
|
* @see IVariable
|
||||||
*/
|
*/
|
||||||
public String getType() {
|
public String getTypeName() {
|
||||||
if (isClass())
|
return getStructureInfo().getTypeName();
|
||||||
return "class";
|
}
|
||||||
if (isUnion())
|
|
||||||
return "union";
|
public void setTypeName(String type){
|
||||||
return "struct";
|
getStructureInfo().setTypeString(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructureInfo getStructureInfo(){
|
||||||
|
return (StructureInfo) getElementInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IVariable
|
* @see IVariable
|
||||||
*/
|
*/
|
||||||
|
@ -90,7 +93,7 @@ public class Structure extends SourceManipulation implements IStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CElementInfo createElementInfo () {
|
protected CElementInfo createElementInfo () {
|
||||||
return new SourceManipulationInfo(this);
|
return new StructureInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -166,4 +166,66 @@ public class Util {
|
||||||
public static int combineHashCodes(int hashCode1, int hashCode2) {
|
public static int combineHashCodes(int hashCode1, int hashCode2) {
|
||||||
return hashCode1 * 17 + 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,13 @@ public class Variable extends SourceManipulation implements IVariable {
|
||||||
super(parent, name, CElement.C_VARIABLE);
|
super(parent, name, CElement.C_VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getTypeName() {
|
||||||
return "";
|
return getVariableInfo().getTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTypeName(String type){
|
||||||
|
getVariableInfo().setTypeName(type);
|
||||||
|
}
|
||||||
public String getInitializer() {
|
public String getInitializer() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,22 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
||||||
super(parent, name, CElement.C_VARIABLE_DECLARATION);
|
super(parent, name, CElement.C_VARIABLE_DECLARATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAccessControl() {
|
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 () {
|
protected CElementInfo createElementInfo () {
|
||||||
return new SourceManipulationInfo(this);
|
return new SourceManipulationInfo(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,8 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
class VariableInfo extends SourceManipulationInfo {
|
class VariableInfo extends SourceManipulationInfo {
|
||||||
|
|
||||||
protected int flags;
|
protected int flags;
|
||||||
|
String typeStr;
|
||||||
|
|
||||||
protected VariableInfo (CElement element) {
|
protected VariableInfo (CElement element) {
|
||||||
super(element);
|
super(element);
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
@ -18,7 +19,26 @@ class VariableInfo extends SourceManipulationInfo {
|
||||||
return flags;
|
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) {
|
protected void setAccessControl(int flags) {
|
||||||
this.flags = flags;
|
this.flags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setTypeString(String type){
|
||||||
|
typeStr = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,9 +129,10 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
ICElementWrapper wrapper = (ICElementWrapper)container;
|
ICElementWrapper wrapper = (ICElementWrapper)container;
|
||||||
Object parent = wrapper.getElement();
|
Object parent = wrapper.getElement();
|
||||||
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
|
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
|
||||||
if( wrapper instanceof SimpleDeclarationWrapper )
|
if( wrapper instanceof SimpleDeclarationWrapper ){
|
||||||
result.setParent( (CElement)wrapper.getElement() );
|
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());
|
result.setParent( (TranslationUnit)wrapper.getElement());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,34 +88,43 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
// this is an attribute or a varaible
|
// this is an attribute or a varaible
|
||||||
if( parentElement instanceof IStructure )
|
if( parentElement instanceof IStructure )
|
||||||
{
|
{
|
||||||
declaration = new Field( parentElement, currentDeclarator.getName().toString() );
|
declaration = createField( parentElement, currentDeclarator.getName().toString() );
|
||||||
}
|
}
|
||||||
else if( parentElement instanceof ITranslationUnit )
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Parameter [] parameters = (Parameter []) clause.toArray( new Parameter[ clause.size() ]);
|
||||||
// this is a function or a method
|
// this is a function or a method
|
||||||
if( parentElement instanceof IStructure )
|
if( parentElement instanceof IStructure )
|
||||||
{
|
{
|
||||||
declaration = new Method( parentElement, currentDeclarator.getName().toString() );
|
declaration = createMethodDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( parentElement instanceof ITranslationUnit )
|
else if( parentElement instanceof ITranslationUnit )
|
||||||
{
|
{
|
||||||
declaration = new FunctionDeclaration( parentElement, currentDeclarator.getName().toString() );
|
if (isFunctionDefinition())
|
||||||
}
|
{
|
||||||
|
// if it belongs to a class, then create a method
|
||||||
Parameter [] parameters = (Parameter []) clause.toArray( new Parameter[ clause.size() ]);
|
// else create a function
|
||||||
|
// this will not be known until we have cross reference information
|
||||||
for( int j = 0; j< parameters.length; ++j )
|
declaration = createFunction( parentElement, currentDeclarator.getName().toString(), parameters );
|
||||||
{
|
}
|
||||||
Parameter parm = parameters[j];
|
else
|
||||||
|
{
|
||||||
}
|
declaration = createFunctionDeclaration( parentElement, currentDeclarator.getName().toString(), parameters );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hook up the offsets
|
// 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_public = 0;
|
||||||
public static final int v_protected = 1;
|
public static final int v_protected = 1;
|
||||||
public static final int v_private = 3;
|
public static final int v_private = 2;
|
||||||
|
|
||||||
private int currentVisibility;
|
private int currentVisibility;
|
||||||
/**
|
/**
|
||||||
|
@ -233,5 +242,115 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
public void setCurrentVisibility(int currentVisibility) {
|
public void setCurrentVisibility(int currentVisibility) {
|
||||||
this.currentVisibility = 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,5 +220,33 @@ public class DeclSpecifier {
|
||||||
public void setName(Name name) {
|
public void setName(Name name) {
|
||||||
this.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 "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/private_m.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/private_m.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 94 B |
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/protected_m.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/protected_m.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 B |
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/public_m.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/obj16/public_m.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 97 B |
|
@ -14,6 +14,8 @@ import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
import org.eclipse.cdt.core.model.ICFile;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
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.internal.ui.util.ImageDescriptorRegistry;
|
||||||
import org.eclipse.cdt.ui.*;
|
import org.eclipse.cdt.ui.*;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -211,7 +213,17 @@ public class CElementImageProvider {
|
||||||
case ICElement.C_VARIABLE:
|
case ICElement.C_VARIABLE:
|
||||||
return CPluginImages.DESC_OBJS_FIELD;
|
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:
|
case ICElement.C_FUNCTION:
|
||||||
return CPluginImages.DESC_OBJS_FUNCTION;
|
return CPluginImages.DESC_OBJS_FUNCTION;
|
||||||
|
|
||||||
|
@ -248,7 +260,9 @@ public class CElementImageProvider {
|
||||||
case ICElement.C_VARIABLE:
|
case ICElement.C_VARIABLE:
|
||||||
return CPluginImages.DESC_OBJS_FIELD;
|
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:
|
||||||
case ICElement.C_FUNCTION_DECLARATION:
|
case ICElement.C_FUNCTION_DECLARATION:
|
||||||
return CPluginImages.DESC_OBJS_FUNCTION;
|
return CPluginImages.DESC_OBJS_FUNCTION;
|
||||||
|
|
|
@ -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_STRUCT= NAME_PREFIX + "struct_obj.gif";
|
||||||
public static final String IMG_OBJS_UNION= NAME_PREFIX + "union_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_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_DECLARATION= NAME_PREFIX + "cdeclaration_obj.gif";
|
||||||
public static final String IMG_OBJS_INCLUDE= NAME_PREFIX + "include_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";
|
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_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_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_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_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_INCLUDE= createManaged(T_OBJ, IMG_OBJS_INCLUDE);
|
||||||
public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
|
public static final ImageDescriptor DESC_OBJS_MACRO= createManaged(T_OBJ, IMG_OBJS_MACRO);
|
||||||
|
|
|
@ -8,6 +8,9 @@ package org.eclipse.cdt.ui;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICFile;
|
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.CElementImageProvider;
|
||||||
import org.eclipse.cdt.internal.ui.ErrorTickAdornmentProvider;
|
import org.eclipse.cdt.internal.ui.ErrorTickAdornmentProvider;
|
||||||
import org.eclipse.cdt.internal.ui.IAdornmentProvider;
|
import org.eclipse.cdt.internal.ui.IAdornmentProvider;
|
||||||
|
@ -57,12 +60,29 @@ public class CElementLabelProvider extends LabelProvider {
|
||||||
if (element instanceof ICElement) {
|
if (element instanceof ICElement) {
|
||||||
ICElement celem= (ICElement)element;
|
ICElement celem= (ICElement)element;
|
||||||
|
|
||||||
String name= celem.getElementName();
|
String name;
|
||||||
if (celem.getElementType() == ICElement.C_FUNCTION) {
|
switch(celem.getElementType()){
|
||||||
name += "()";
|
case ICElement.C_FUNCTION:
|
||||||
} else if(celem.getElementType() == ICElement.C_FUNCTION_DECLARATION) {
|
case ICElement.C_FUNCTION_DECLARATION:
|
||||||
name += "();";
|
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) {
|
if (celem instanceof IBinary) {
|
||||||
IBinary bin = (IBinary)celem;
|
IBinary bin = (IBinary)celem;
|
||||||
name += " - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]";
|
name += " - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]";
|
||||||
|
|
Loading…
Add table
Reference in a new issue