From 679b7c8db31dc00c952ba06b3f85b47096c0d308 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Fri, 28 Mar 2003 21:05:24 +0000 Subject: [PATCH] Patch for Hoda Amer: - The static sign will show if the parser sets isStatic() to true for any element. For now, I am just saving this info in the element info. We could change it later if we need another icon for variables and functions. --- .../eclipse/cdt/core/model/IDeclaration.java | 28 ++++++++++ .../cdt/core/model/IFunctionDeclaration.java | 12 +---- .../org/eclipse/cdt/core/model/IMember.java | 36 +------------ .../eclipse/cdt/core/model/IStructure.java | 2 +- .../org/eclipse/cdt/core/model/IVariable.java | 5 +- .../cdt/core/model/IVariableDeclaration.java | 4 +- .../cdt/internal/core/model/Field.java | 21 +++++--- .../cdt/internal/core/model/FieldInfo.java | 17 ++++-- .../core/model/FunctionDeclaration.java | 45 ++++++++++++++-- .../cdt/internal/core/model/FunctionInfo.java | 35 ++++++++++++ .../core/model/MethodDeclaration.java | 48 ++++++++--------- .../cdt/internal/core/model/MethodInfo.java | 29 ++-------- .../cdt/internal/core/model/Structure.java | 36 ++++++++++--- .../internal/core/model/StructureInfo.java | 53 ++++++++++++++++++- .../cdt/internal/core/model/Variable.java | 25 +++++++++ .../core/model/VariableDeclaration.java | 26 ++++++++- .../cdt/internal/core/model/VariableInfo.java | 27 ++++++++++ .../core/model/SimpleDeclarationWrapper.java | 36 ++++++++++++- .../internal/ui/CElementImageProvider.java | 33 +++++------- .../cdt/ui/CElementImageDescriptor.java | 18 +++---- 20 files changed, 376 insertions(+), 160 deletions(-) create mode 100644 core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java new file mode 100644 index 00000000000..7686d5cda29 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IDeclaration.java @@ -0,0 +1,28 @@ +package org.eclipse.cdt.core.model; + +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * Rational Software - Initial API and implementation +***********************************************************************/ + +public interface IDeclaration extends ICElement, ISourceManipulation, ISourceReference { + boolean isStatic(); + boolean isConst(); + boolean isVolatile(); + + /** + * Returns the access Control of the member. The access qualifier + * can be examine using the AccessControl class. + * + * @exception CModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @see IAccessControl + */ + int getAccessControl(); +} 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 3f4599d9b7d..3c92553b850 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 @@ -8,7 +8,7 @@ package org.eclipse.cdt.core.model; /** * Represents a function */ -public interface IFunctionDeclaration extends ICElement, ISourceReference, ISourceManipulation { +public interface IFunctionDeclaration extends IDeclaration { /** * Returns the type signatures of the exceptions this method throws, @@ -63,14 +63,4 @@ public interface IFunctionDeclaration extends ICElement, ISourceReference, ISour * Returns the signature of the method. */ String getSignature(); - - /** - * Returns the access Control of the member. The access qualifier - * can be examine using the AccessControl class. - * - * @exception CModelException if this element does not exist or if an - * exception occurs while accessing its corresponding resource. - * @see IAccessControl - */ - 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 018df892ebc..c927d156a3c 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 @@ -10,46 +10,12 @@ package org.eclipse.cdt.core.model; * This set consists of IType, IMethod, * IField. */ -public interface IMember extends ICElement, ISourceReference, ISourceManipulation { +public interface IMember extends IDeclaration { static final int V_PUBLIC = 0; static final int V_PROTECTED = 1; static final int V_PRIVATE = 2; - - /** - * 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(); - - /** - * Returns whether this method/field is declared constant. - * - * @exception CModelException if this element does not exist or if an - * exception occurs while accessing its corresponding resource. - */ - 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 - * can be examine using the AccessControl class. - * - * @exception CModelException if this element does not exist or if an - * exception occurs while accessing its corresponding resource. - * @see IAccessControl - */ - public int getAccessControl(); /** * Returns the member's visibility * V_PRIVATE = 0 V_PROTECTED = 1 V_PUBLIC = 2 diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IStructure.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IStructure.java index a2594809d73..9fd93bf4306 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IStructure.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IStructure.java @@ -8,7 +8,7 @@ package org.eclipse.cdt.core.model; /** * Represent struct(ure), class or union. */ -public interface IStructure extends IInheritance, IParent, ICElement, IVariableDeclaration { +public interface IStructure extends IInheritance, IParent, IDeclaration { //public String instantiatesTemplate(); public IField getField(String name); 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 832cf9f43f2..3c8452dd010 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 @@ -8,9 +8,6 @@ package org.eclipse.cdt.core.model; /** * Represents a global variable. */ -public interface IVariable extends ICElement , ISourceManipulation, ISourceReference { - public String getTypeName(); - public void setTypeName(String type); +public interface IVariable extends IVariableDeclaration { 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 7ef1c9c5f9c..664327a2fcf 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 @@ -8,9 +8,7 @@ package org.eclipse.cdt.core.model; /** * Represents the declaration of a variable. */ -public interface IVariableDeclaration extends ICElement, ISourceManipulation, ISourceReference { - +public interface IVariableDeclaration extends IDeclaration { 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 4a1c68ded9d..9526548008e 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 @@ -22,8 +22,8 @@ public class Field extends SourceManipulation implements IField { return getFieldInfo().isMutable(); } - public void setIsMutable(boolean mutable){ - getFieldInfo().setIsMutable(mutable); + public void setMutable(boolean mutable){ + getFieldInfo().setMutable(mutable); } public String getTypeName() { @@ -38,16 +38,24 @@ public class Field extends SourceManipulation implements IField { return getFieldInfo().isConst(); } - public void setIsConst(boolean isConst) { - getFieldInfo().setIsConst(isConst); + public void setConst(boolean isConst) { + getFieldInfo().setConst(isConst); } public boolean isVolatile() { return getFieldInfo().isVolatile(); } - public void setIsVolatile(boolean isVolatile) { - getFieldInfo().setIsVolatile(isVolatile); + public void setVolatile(boolean isVolatile) { + getFieldInfo().setVolatile(isVolatile); + } + + public boolean isStatic() { + return getFieldInfo().isStatic(); + } + + public void setStatic(boolean isStatic) { + getFieldInfo().setStatic(isStatic); } public int getVisibility() { @@ -58,6 +66,7 @@ public class Field extends SourceManipulation implements IField { getFieldInfo().setVisibility(visibility); } + public FieldInfo getFieldInfo(){ return (FieldInfo) getElementInfo(); } 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 index b1ac9f12948..4dd86e3adde 100644 --- 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 @@ -20,6 +20,7 @@ public class FieldInfo extends SourceManipulationInfo { boolean isConst = false; boolean isVolatile = false; boolean isMutable = false; + boolean isStatic = false; int visibility; protected FieldInfo (CElement element) { @@ -48,6 +49,7 @@ public class FieldInfo extends SourceManipulationInfo { && (isVolatile == otherInfo.isVolatile()) && (isMutable == otherInfo.isMutable()) && (visibility == otherInfo.getVisibility()) + && (isStatic == otherInfo.isStatic()) ) return true; else @@ -66,7 +68,7 @@ public class FieldInfo extends SourceManipulationInfo { return isConst; } - protected void setIsConst(boolean isConst){ + protected void setConst(boolean isConst){ this.isConst = isConst; } @@ -74,15 +76,23 @@ public class FieldInfo extends SourceManipulationInfo { return isVolatile; } - protected void setIsVolatile(boolean isVolatile){ + protected void setVolatile(boolean isVolatile){ this.isVolatile = isVolatile; } + public boolean isStatic() { + return isStatic; + } + + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + protected boolean isMutable(){ return isMutable; } - protected void setIsMutable(boolean mutable){ + protected void setMutable(boolean mutable){ this.isMutable = mutable; } /** @@ -100,5 +110,4 @@ public class FieldInfo extends SourceManipulationInfo { public void setVisibility(int visibility) { this.visibility = visibility; } - } 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 9b40d837e81..66a3640ccd8 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 @@ -51,9 +51,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction } public String getSignature(){ - String sig = getReturnType(); - sig += " "; - sig += getElementName(); + String sig = getElementName(); if(getNumberOfParameters() > 0){ sig += "("; String[] paramTypes = getParameterTypes(); @@ -79,6 +77,7 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction return getFunctionInfo().getAccessControl(); } + public String[] getExceptions(){ return new String[] {}; } @@ -98,4 +97,44 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction ); } + /** + * FunctionDeclarations and Functions can not be constant + * @see org.eclipse.cdt.core.model.IDeclaration#isConst() + */ + public boolean isConst(){ + return false; + } + + /** + * Returns the isStatic. + * @return boolean + */ + public boolean isStatic() { + return getFunctionInfo().isStatic(); + } + + /** + * Returns the isVolatile. + * @return boolean + */ + public boolean isVolatile() { + return getFunctionInfo().isVolatile(); + } + + /** + * Sets the isStatic. + * @param isStatic The isStatic to set + */ + public void setStatic(boolean isStatic) { + getFunctionInfo().setStatic(isStatic); + } + + /** + * Sets the isVolatile. + * @param isVolatile The isVolatile to set + */ + public void setVolatile(boolean isVolatile) { + getFunctionInfo().setVolatile(isVolatile); + } + } 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 f25de53e961..e3b21d18710 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 @@ -10,6 +10,9 @@ class FunctionInfo extends SourceManipulationInfo { protected int flags; protected String returnType = ""; protected int numOfParams; + protected boolean isStatic; + protected boolean isVolatile; + protected FunctionInfo (CElement element) { super(element); @@ -31,4 +34,36 @@ class FunctionInfo extends SourceManipulationInfo { protected void setReturnType(String type){ returnType = type; } + /** + * Returns the isStatic. + * @return boolean + */ + public boolean isStatic() { + return isStatic; + } + + /** + * Returns the isVolatile. + * @return boolean + */ + public boolean isVolatile() { + return isVolatile; + } + + /** + * Sets the isStatic. + * @param isStatic The isStatic to set + */ + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + + /** + * Sets the isVolatile. + * @param isVolatile The isVolatile to set + */ + public void setVolatile(boolean isVolatile) { + this.isVolatile = isVolatile; + } + } 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 index 185c742314d..7f6e260d6b8 100644 --- 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 @@ -16,6 +16,8 @@ import org.eclipse.cdt.core.model.IMethodDeclaration; public class MethodDeclaration extends FunctionDeclaration implements IMethodDeclaration{ + boolean isConst; + boolean isVolatile; public MethodDeclaration(ICElement parent, String name){ super(parent, name, CElement.C_METHOD_DECLARATION); @@ -52,55 +54,49 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec } public void setIsAbstract(boolean isAbstract){ - getMethodInfo().setIsAbstract(isAbstract); - } - - public boolean isStatic(){ - return getMethodInfo().isStatic(); - } - - public void setIsStatic(boolean isStatic){ - getMethodInfo().setIsStatic(isStatic); + getMethodInfo().setAbstract(isAbstract); } public boolean isInline(){ return getMethodInfo().isInline(); } - public void setIsInline(boolean isInline){ - getMethodInfo().setIsInline(isInline); + public void setInline(boolean isInline){ + getMethodInfo().setInline(isInline); } public boolean isVirtual(){ return getMethodInfo().isVirtual(); } - public void setIsVirtual(boolean isVirtual){ - getMethodInfo().setIsVirtual(isVirtual); + public void setVirtual(boolean isVirtual){ + getMethodInfo().setVirtual(isVirtual); } public boolean isFriend(){ return getMethodInfo().isFriend(); } - public void setIsFriend(boolean isFriend){ - getMethodInfo().setIsFriend(isFriend); + public void setFriend(boolean isFriend){ + getMethodInfo().setFriend(isFriend); } public boolean isConst(){ - return getMethodInfo().isConst(); + return isConst; } - public void setIsConst(boolean isConst){ - getMethodInfo().setIsConst(isConst); + public void setConst(boolean isConst){ + this.isConst = isConst; + getMethodInfo().setConst(isConst); } public boolean isVolatile(){ - return getMethodInfo().isVolatile(); + return isVolatile; } - public void setIsVolatile(boolean isVolatile){ - getMethodInfo().setIsVolatile(isVolatile); + public void setVolatile(boolean isVolatile){ + this.isVolatile = isVolatile; + getMethodInfo().setVolatile(isVolatile); } public int getVisibility(){ @@ -110,11 +106,6 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec 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); @@ -128,7 +119,10 @@ public class MethodDeclaration extends FunctionDeclaration implements IMethodDec * See if we need anything else to put in equals here */ public boolean equals(Object other) { - return ( super.equals(other) ); + return ( super.equals(other) + && isConst() == ((MethodDeclaration)other).isConst() + && isVolatile() == ((MethodDeclaration)other).isVolatile() + ); } } 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 index 154c4c82b0b..eb3b34d72b7 100644 --- 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 @@ -16,12 +16,10 @@ 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) { @@ -33,23 +31,15 @@ public class MethodInfo extends FunctionInfo { return isAbstract; } - public void setIsAbstract(boolean isAbstract){ + public void setAbstract(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){ + public void setInline(boolean isInline){ this.isInline = isInline; } @@ -57,7 +47,7 @@ public class MethodInfo extends FunctionInfo { return isVirtual; } - public void setIsVirtual(boolean isVirtual){ + public void setVirtual(boolean isVirtual){ this.isVirtual = isVirtual; } @@ -65,7 +55,7 @@ public class MethodInfo extends FunctionInfo { return isFriend; } - public void setIsFriend(boolean isFriend){ + public void setFriend(boolean isFriend){ this.isFriend = isFriend; } @@ -73,18 +63,9 @@ public class MethodInfo extends FunctionInfo { return isConst; } - public void setIsConst(boolean isConst){ + public void setConst(boolean isConst){ this.isConst = isConst; } - - public boolean isVolatile(){ - return isVolatile; - } - - public void setIsVolatile(boolean isVolatile){ - this.isVolatile = isVolatile; - } - /** * Returns the 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 16d4edc6d50..c20fddf8fa4 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 @@ -52,6 +52,9 @@ public class Structure extends SourceManipulation implements IStructure { return false; } + /** + * @see org.eclipse.cdt.core.model.IDeclaration#getAccessControl() + */ public int getAccessControl(){ return 0; } @@ -75,6 +78,30 @@ public class Structure extends SourceManipulation implements IStructure { getStructureInfo().setTypeString(type); } + public boolean isConst() { + return getStructureInfo().isConst(); + } + + public void setConst(boolean isConst) { + getStructureInfo().setConst(isConst); + } + + public boolean isVolatile() { + return getStructureInfo().isVolatile(); + } + + public void setVolatile(boolean isVolatile) { + getStructureInfo().setVolatile(isVolatile); + } + + public boolean isStatic() { + return getStructureInfo().isStatic(); + } + + public void setStatic(boolean isStatic) { + getStructureInfo().setStatic(isStatic); + } + public StructureInfo getStructureInfo(){ return (StructureInfo) getElementInfo(); } @@ -92,6 +119,7 @@ public class Structure extends SourceManipulation implements IStructure { baseTypes = newBase; } + protected CElementInfo createElementInfo () { return new StructureInfo(this); } @@ -104,12 +132,4 @@ public class Structure extends SourceManipulation implements IStructure { return 0; } - - /** - * @see org.eclipse.cdt.core.model.IVariableDeclaration#getAccesControl() - */ - public int getAccesControl() { - return 0; - } - } 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 index f0aba19e744..99b7f92534f 100644 --- 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 @@ -15,7 +15,10 @@ import org.eclipse.cdt.core.model.ICElement; public class StructureInfo extends SourceManipulationInfo { String type; - + boolean isConst = false; + boolean isVolatile = false; + boolean isStatic = false; + protected StructureInfo (CElement element) { super(element); @@ -50,5 +53,53 @@ public class StructureInfo extends SourceManipulationInfo { return true; } + /** + * Returns the isConst. + * @return boolean + */ + public boolean isConst() { + return isConst; + } + + /** + * Returns the isStatic. + * @return boolean + */ + public boolean isStatic() { + return isStatic; + } + + /** + * Returns the isVolatile. + * @return boolean + */ + public boolean isVolatile() { + return isVolatile; + } + + /** + * Sets the isConst. + * @param isConst The isConst to set + */ + public void setConst(boolean isConst) { + this.isConst = isConst; + } + + /** + * Sets the isStatic. + * @param isStatic The isStatic to set + */ + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + + /** + * Sets the isVolatile. + * @param isVolatile The isVolatile to set + */ + public void setVolatile(boolean isVolatile) { + this.isVolatile = isVolatile; + } + } 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 402f116b5cf..45776ed32c0 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 @@ -21,6 +21,31 @@ public class Variable extends SourceManipulation implements IVariable { public void setTypeName(String type){ getVariableInfo().setTypeName(type); } + + public boolean isConst() { + return getVariableInfo().isConst(); + } + + public void setConst(boolean isConst) { + getVariableInfo().setConst(isConst); + } + + public boolean isVolatile() { + return getVariableInfo().isVolatile(); + } + + public void setVolatile(boolean isVolatile) { + getVariableInfo().setVolatile(isVolatile); + } + + public boolean isStatic() { + return getVariableInfo().isStatic(); + } + + public void setStatic(boolean isStatic) { + getVariableInfo().setStatic(isStatic); + } + 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 92fc3c56c08..f9834d73333 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 @@ -26,11 +26,35 @@ public class VariableDeclaration extends SourceManipulation implements IVariable getVariableInfo().setTypeString(type); } + public boolean isConst() { + return getVariableInfo().isConst(); + } + + public void setConst(boolean isConst) { + getVariableInfo().setConst(isConst); + } + + public boolean isVolatile() { + return getVariableInfo().isVolatile(); + } + + public void setVolatile(boolean isVolatile) { + getVariableInfo().setVolatile(isVolatile); + } + + public boolean isStatic() { + return getVariableInfo().isStatic(); + } + + public void setStatic(boolean isStatic) { + getVariableInfo().setStatic(isStatic); + } + public VariableInfo getVariableInfo(){ return (VariableInfo) getElementInfo(); } protected CElementInfo createElementInfo () { - return new SourceManipulationInfo(this); + return new VariableInfo(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 6707d99c118..17f634ee6b3 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 @@ -9,6 +9,9 @@ class VariableInfo extends SourceManipulationInfo { protected int flags; String typeStr = ""; + boolean isConst = false; + boolean isVolatile = false; + boolean isStatic = false; protected VariableInfo (CElement element) { super(element); @@ -41,4 +44,28 @@ class VariableInfo extends SourceManipulationInfo { protected void setTypeString(String type){ typeStr = type; } + protected boolean isConst(){ + return isConst; + } + + protected void setConst(boolean isConst){ + this.isConst = isConst; + } + + protected boolean isVolatile(){ + return isVolatile; + } + + protected void setVolatile(boolean isVolatile){ + this.isVolatile = isVolatile; + } + + public boolean isStatic() { + return isStatic; + } + + public void setStatic(boolean isStatic) { + this.isStatic = isStatic; + } + } 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 74327770f5a..b04e436abbf 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 @@ -257,9 +257,11 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci private CElement createField(CElement parent, String name){ Field newElement = new Field( parent, name ); newElement.setTypeName ( getTypeName() ); - newElement.setIsConst(isConst()); - newElement.setIsMutable(isMutable()); + newElement.setMutable(isMutable()); newElement.setVisibility(this.getCurrentVisibility()); + newElement.setConst(isConst()); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } @@ -272,6 +274,9 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci private CElement createVariable(CElement parent, String name){ Variable newElement = new Variable( parent, name ); newElement.setTypeName ( getTypeName() ); + newElement.setConst(isConst()); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } @@ -284,6 +289,9 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci private CElement createVariableDeclaration(CElement parent, String name){ VariableDeclaration newElement = new VariableDeclaration( parent, name ); newElement.setTypeName ( getTypeName() ); + newElement.setConst(isConst()); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } @@ -307,6 +315,8 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci newElement.setParameterTypes(parameterTypes); newElement.setReturnType( getTypeName() ); newElement.setVisibility(this.getCurrentVisibility()); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } @@ -329,6 +339,8 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci newElement.setParameterTypes(parameterTypes); newElement.setReturnType( getTypeName() ); newElement.setVisibility(this.getCurrentVisibility()); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } @@ -340,8 +352,18 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci * @return CElement */ private CElement createFunctionDeclaration(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()); + } + FunctionDeclaration newElement = new FunctionDeclaration( parent, name ); + newElement.setParameterTypes(parameterTypes); newElement.setReturnType( getTypeName() ); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } @@ -353,8 +375,18 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci * @return CElement */ private CElement createFunction(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()); + } + Function newElement = new Function( parent, name ); + newElement.setParameterTypes(parameterTypes); newElement.setReturnType( getTypeName() ); + newElement.setVolatile(isVolatile()); + newElement.setStatic(isStatic()); return newElement; } 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 a1bbcd805b8..a561515f4cd 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 @@ -10,6 +10,7 @@ import org.eclipse.cdt.core.model.ICElement; 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.core.model.IDeclaration; import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry; import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CUIPlugin; @@ -281,28 +282,18 @@ public class CElementImageProvider { int flags= computeBasicAdornmentFlags(element, renderFlags); - /* if (showOverlayIcons(renderFlags) && element instanceof ISourceReference) { - ISourceReference sourceReference= (ISourceReference)element; - int modifiers= getModifiers(sourceReference); - - if (Flags.isAbstract(modifiers) && confirmAbstract((IMember) sourceReference)) - flags |= JavaElementImageDescriptor.ABSTRACT; - if (Flags.isFinal(modifiers)) - flags |= JavaElementImageDescriptor.FINAL; - if (Flags.isSynchronized(modifiers) && confirmSynchronized((IMember) sourceReference)) - flags |= JavaElementImageDescriptor.SYNCHRONIZED; - if (Flags.isStatic(modifiers)) - flags |= JavaElementImageDescriptor.STATIC; - - if (sourceReference instanceof IType) { - try { - if (JavaModelUtil.hasMainMethod((IType)sourceReference)) - flags |= JavaElementImageDescriptor.RUNNABLE; - } catch (JavaModelException e) { - // do nothing. Can't compute runnable adornment. - } + if (showOverlayIcons(renderFlags) && element instanceof IDeclaration) { + IDeclaration decl = (IDeclaration) element; + if(decl.isStatic()){ + flags |= CElementImageDescriptor.STATIC; } - } */ + if(decl.isConst()){ + flags |= CElementImageDescriptor.CONSTANT; + } + if(decl.isVolatile()){ + flags |= CElementImageDescriptor.VOLATILE; + } + } return flags; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java index b40cd7de8ee..769b07169ea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java @@ -33,11 +33,11 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { /** Flag to render the abstract adornment */ public final static int ABSTRACT= 0x001; - /** Flag to render the final adornment */ - public final static int FINAL= 0x002; + /** Flag to render the const adornment */ + public final static int CONSTANT= 0x002; - /** Flag to render the synchronized adornment */ - public final static int SYNCHRONIZED= 0x004; + /** Flag to render the volatile adornment */ + public final static int VOLATILE= 0x004; /** Flag to render the static adornment */ public final static int STATIC= 0x008; @@ -160,8 +160,8 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { } private void drawTopRight() { - //int x= getSize().x; - //ImageData data= null; + int x= getSize().x; + ImageData data= null; /* if ((fFlags & ABSTRACT) != 0) { data= CPluginImages.DESC_OVR_ABSTRACT.getImageData(); x-= data.width; @@ -171,19 +171,19 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { data= CPluginImages.DESC_OVR_FINAL.getImageData(); x-= data.width; drawImage(data, x, 0); - } + }*/ if ((fFlags & STATIC) != 0) { data= CPluginImages.DESC_OVR_STATIC.getImageData(); x-= data.width; drawImage(data, x, 0); - } */ + } } private void drawBottomRight() { //Point size= getSize(); //int x= size.x; //ImageData data= null; - /* if ((fFlags & SYNCHRONIZED) != 0) { + /*if ((fFlags & SYNCHRONIZED) != 0) { data= CPluginImages.DESC_OVR_SYNCH.getImageData(); x-= data.width; drawImage(data, x, size.y - data.height);