From cc325e9b5f84c06cfc5c4b0a68d4540ed70706c9 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Wed, 9 Apr 2003 15:07:59 +0000 Subject: [PATCH] Patch for Hoda Amer: - Uses "StringBuffer" instead of "String" in CModelBuilder and a couple other places for better performance. - Displays the volatile decorative for volatile declarations. - Changes the background of some icons to transparent. --- .../core/model/FunctionDeclaration.java | 20 +++---- .../internal/core/model/CModelBuilder.java | 56 +++++++++--------- .../icons/full/obj16/enum_obj.gif | Bin 901 -> 910 bytes .../icons/full/obj16/enumerator_obj.gif | Bin 844 -> 853 bytes .../icons/full/obj16/typedef_obj.gif | Bin 901 -> 910 bytes .../icons/full/obj16/var_declaration_obj.gif | Bin 882 -> 895 bytes .../icons/full/ovr16/c_ovr.gif | Bin 819 -> 826 bytes .../icons/full/ovr16/static_co.gif | Bin 66 -> 833 bytes .../icons/full/ovr16/volatile_co.gif | Bin 80 -> 833 bytes .../cdt/internal/ui/CPluginImages.java | 1 + .../cdt/ui/CElementImageDescriptor.java | 6 +- .../eclipse/cdt/ui/CElementLabelProvider.java | 34 +++++------ 12 files changed, 59 insertions(+), 58 deletions(-) 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 c8ad3e80bac..bd079ec9b74 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 @@ -50,26 +50,26 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction } public String getSignature(){ - String sig = getElementName(); + StringBuffer sig = new StringBuffer(getElementName()); if(getNumberOfParameters() > 0){ - sig += "("; + sig.append("("); String[] paramTypes = getParameterTypes(); int i = 0; - sig += paramTypes[i++]; + sig.append(paramTypes[i++]); while (i < paramTypes.length){ - sig += (", "); - sig += paramTypes[i++]; + sig.append(", "); + sig.append(paramTypes[i++]); } - sig += ")"; + sig.append(")"); } else{ - sig += "()"; + sig.append("()"); } if(isConst()) - sig += " const"; + sig.append(" const"); if(isVolatile()) - sig += " volatile"; - return sig; + sig.append(" volatile"); + return sig.toString(); } public String getParameterInitializer(int pos) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java index e74a32642c5..c331a7ab740 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java @@ -372,75 +372,75 @@ public class CModelBuilder { } private String getType(Declaration declaration, Declarator declarator){ - String type = ""; + StringBuffer type = new StringBuffer(); // get type from declaration - type = getDeclarationType(declaration); + type.append(getDeclarationType(declaration)); // add pointerr or reference from declarator if any - type += getDeclaratorPointerOperation(declarator); - return type; + type.append(getDeclaratorPointerOperation(declarator)); + return type.toString(); } private String getDeclarationType(Declaration declaration){ - String type = ""; + StringBuffer type = new StringBuffer(); if(declaration instanceof ParameterDeclaration){ ParameterDeclaration paramDeclaration = (ParameterDeclaration) declaration; if(paramDeclaration.getDeclSpecifier().isConst()) - type += "const "; + type.append("const "); if(paramDeclaration.getDeclSpecifier().isVolatile()) - type += "volatile "; + type.append("volatile "); TypeSpecifier typeSpecifier = paramDeclaration.getTypeSpecifier(); if(typeSpecifier == null){ - type += paramDeclaration.getDeclSpecifier().getTypeName(); + type.append(paramDeclaration.getDeclSpecifier().getTypeName()); } else if(typeSpecifier instanceof ElaboratedTypeSpecifier){ ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier; - type += getElaboratedTypeSignature(elab); + type.append(getElaboratedTypeSignature(elab)); } } if(declaration instanceof SimpleDeclaration){ SimpleDeclaration simpleDeclaration = (SimpleDeclaration) declaration; if(simpleDeclaration.getDeclSpecifier().isConst()) - type += "const "; + type.append("const "); if(simpleDeclaration.getDeclSpecifier().isVolatile()) - type += "volatile "; + type.append("volatile "); TypeSpecifier typeSpecifier = simpleDeclaration.getTypeSpecifier(); if(typeSpecifier == null){ - type += simpleDeclaration.getDeclSpecifier().getTypeName(); + type.append(simpleDeclaration.getDeclSpecifier().getTypeName()); } else if(typeSpecifier instanceof ElaboratedTypeSpecifier){ ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier; - type += getElaboratedTypeSignature(elab); + type.append(getElaboratedTypeSignature(elab)); } } - return type; + return type.toString(); } private String getElaboratedTypeSignature(ElaboratedTypeSpecifier elab){ - String type = ""; + StringBuffer type = new StringBuffer(); int t = elab.getClassKey(); switch (t){ case ClassKey.t_class: - type = "class"; + type.append("class"); break; case ClassKey.t_struct: - type = "struct"; + type.append("struct"); break; case ClassKey.t_union: - type = "union"; + type.append("union"); break; case ClassKey.t_enum: - type = "enum"; + type.append("enum"); break; }; - type += " "; - type += elab.getName().toString(); - return type; + type.append(" "); + type.append(elab.getName().toString()); + return type.toString(); } private String getDeclaratorPointerOperation(Declarator declarator){ - String pointerString = ""; + StringBuffer pointerString = new StringBuffer(); List pointerOperators = declarator.getPointerOperators(); if(pointerOperators != null) { Iterator i = pointerOperators.iterator(); @@ -448,19 +448,19 @@ public class CModelBuilder { PointerOperator po = (PointerOperator) i.next(); switch (po.getType()){ case PointerOperator.t_pointer: - pointerString += "*"; + pointerString.append("*"); break; case PointerOperator.t_reference: - pointerString += "&"; + pointerString.append("&"); break; } if(po.isConst()) - pointerString += " const"; + pointerString.append(" const"); if(po.isVolatile()) - pointerString += " volatile"; + pointerString.append(" volatile"); } } - return pointerString; + return pointerString.toString(); } } diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/enum_obj.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/enum_obj.gif index c175692aabae46e65ccdae725de0a90b4ed3efc2..3ce0d82ebc4f7b9cfca96f5f1a2cdef1ae9752de 100644 GIT binary patch delta 145 zcmV;C0B-+<2aX2?M@dFFIk5!@1Aig;1OWg5{{Soi0000G01yB`2x|cU2^>hUpuj}m zz<~q6kfFkFvYoAto5xYMvnqPo@|Ix=s<)gQ$jqN&?U#EK@$yasIX>1nLK@l%*pj%Kmq_eMoTw5 delta 135 zcmV;20C@k72ZaX(M@dFFH?ai>19&U|0000G01yBG2xhUpuvL(!O>c{5FEmV zwZ2KLwa_4~THrEj1V@pe!i)eyhRjIIp}>nEH)iZ8FwwV^D!FglGAPla786CBSn;63L|98A+)6MY06W?2G*AEl diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/enumerator_obj.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/enumerator_obj.gif index 36b599585eecda64740eda0042e42b733ee81493..a73f31a81f672296f6ad81b7a7a376ccaeb02e28 100644 GIT binary patch delta 87 zcmX@Zc9o6Q-P6s&aw97TvxnkO7Dfh!{|q_|Kp+5w4je`d|2btmHY_+;pTs6)abm;5 q!|ejBT{AV(79Q?mF>X4GRu7a|mn2oY?Tt$xz^^K*fpo h^7}ivj`AFt5#V#Qo1e4e$%_q3PEOWfWn*Em1^|0t8WsQm diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/typedef_obj.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/typedef_obj.gif index f93b646ddb1cddb45daa911386e6589133b3badb..7e3ace3e77b5802bc9903ec83293fdf2f85d2184 100644 GIT binary patch delta 145 zcmV;C0B-+<2aX2?M@dFFIk5!@1Aig;1OWg5{{Soi0000G01yB`2x|cU2^>hUpuj}m zz$pX=U?I3~vd>gfL_L3o)XDW19&U|0000G01yBG2xhUpuvL(!O>c{5FEmV zwZ2KLwa_4~THrEj1V@pe!i^wlITUyi+yDS5QD*EYFwr-SCpUhhHP9tY05WN|e3>z( p#+d_4_Qa`?FK@&xsSn;63L|B<3+&VBI06R6uGBf}H diff --git a/core/org.eclipse.cdt.ui/icons/full/obj16/var_declaration_obj.gif b/core/org.eclipse.cdt.ui/icons/full/obj16/var_declaration_obj.gif index 8ac3c0a1d1de2ca76446e4a7840eed67590d2d7a..74a3d222c700233db61a466ee8c7e313384d1a20 100644 GIT binary patch delta 129 zcmeyw_MeT_-P6s&aw97TbCKdt7Dfh!{|q_|Kp+5w4jeHI|2btmHYhk&{C}h9z`%K_ zfzg5IUo$)Z9ESoCRW26>!4nM?QqEp$Gy)Wz+t~yUSpO8@5SXBpe9Fgjq7qZD7W=F} g83KuiT6q<}v9MoJJi@5VE>Ze3Z`tJujEoG{09E@Zf&c&j delta 116 zcmey*_KA(v-P6s&d?PCdbE*yl5C{Mv14lT+e@+>X4GRu7a|kQBFsxU!Vd0c+66RR< z(6NpAt)hd0!aT-*kJ&q^BpFcsviWFdcb(oYA^* TkN1g*>F%u_leKIm1Q@IVr+g)) diff --git a/core/org.eclipse.cdt.ui/icons/full/ovr16/c_ovr.gif b/core/org.eclipse.cdt.ui/icons/full/ovr16/c_ovr.gif index d15ab503ebe131703fae4966d5ea650d25cbd32f..ae434bfb4c5a0927a25fea98b33db55bb73f1673 100644 GIT binary patch delta 60 zcmdnYwu_C`-P6s&aw97Tv##P#7Dfh!{|q_|K)?=!4jkeP|2btWCNS97v9NtoJ~3f| NV+)tG5f2B0H2|7F4VC}^ delta 53 zcmdnRwwaC9-P6s&d?PCdvziVA5U>Lw1BV2|e@+>T2@LjiENq{YH3}4+n>i%CR3ro# FtN|Hh3O)b; diff --git a/core/org.eclipse.cdt.ui/icons/full/ovr16/static_co.gif b/core/org.eclipse.cdt.ui/icons/full/ovr16/static_co.gif index 08438a590ab4ebfbfaffbbe40fb91e679fd8b5bc..6b6a2a083435486985c3957256050487de81beb7 100644 GIT binary patch literal 833 zcmds0Jxc>Y5Pb=etb!2kR7?{h1iujlkw~sMG-ynvpq-6GQ9(rzJ!~Xesda3{B88>I z#zweOut{x~PMfpRL};%_JvR!U&@Z*tYEgdBAlk{|8pz zG$iXvYu=>OCZph7yzjJsmY z@S*Q*4FP7SV~7;kV~+7q3?QFy4ACX-L241>lu5=4q^9tsCL)e;O5csE!EE%Sa(+Ma z)CYJ697A%CH{$Qlpa0l?_a)p2>$LI|8S_QCLD`Y5SoQ6Ur{}5n9=sZUNAPT{2Ma;+0_jp1iz)L0 zNns(9a*7m!jp>&(A{OzRdm-EmGjrygGxvY@{_XAELtpyxN9uI#*R`u7>bmp!y!*NP z`s0y|h>Dnqi-bs4q$+BnE*hd)NmDTsbFmQ1s&y4NaTgEqtkzHolW>WUNRT8|(j;9n zBniL<8Z4Tr&YDxlR9!Vxv&IscskvIHWw9XXrta#Yo<)k-O!3G*EnzIB|%yF|Y%hJbKB6ssJ&youZlHnF%k*J3hwU%xfmdL{oXwr=x z=!XOfVGS6hVM!@G7z{ShU}ZU1X<|;eXBmk;#u7z%B)%dS79>5x6CZIJ1K>qDMxz!h z@dKK4V+WiNj6zrg25CB>1rG*;4RqFus+u%0C)pTAqK~meky#6D>n|2Q->&<4f-EQ~${o!yp9*?Kf>HP0;wffTWs(H(2Ik$_Of1DS8pIiu^ u!s~kJ^-bJgUdhwT=eIYzi;ul$S1-Tc{JQ_t|9!WA^%c7H;k0ML YhqZ1EYxE5koxE@`pfYhP1B10S0NlP9rT_o{ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index 3932d826b6e..c79e22aea1f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -124,6 +124,7 @@ public class CPluginImages { public static final ImageDescriptor DESC_OVR_STATIC= create(T_OVR, "static_co.gif"); public static final ImageDescriptor DESC_OVR_CONSTANT= create(T_OVR, "c_ovr.gif"); + public static final ImageDescriptor DESC_OVR_VOLATILE= create(T_OVR, "volatile_co.gif"); public static final ImageDescriptor DESC_OVR_WARNING= create(T_OVR, "warning_co.gif"); public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif"); 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 bfc3f17c620..d8309d2eccc 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 @@ -162,11 +162,11 @@ public class CElementImageDescriptor extends CompositeImageDescriptor { private void drawTopRight() { int x= getSize().x; ImageData data= null; - /* if ((fFlags & ABSTRACT) != 0) { - data= CPluginImages.DESC_OVR_ABSTRACT.getImageData(); + if ((fFlags & VOLATILE) != 0) { + data= CPluginImages.DESC_OVR_VOLATILE.getImageData(); x-= data.width; drawImage(data, x, 0); - }*/ + } if ((fFlags & CONSTANT) != 0) { data= CPluginImages.DESC_OVR_CONSTANT.getImageData(); x-= data.width; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java index 5066b9c5dfa..0e205b1b92e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java @@ -60,16 +60,16 @@ public class CElementLabelProvider extends LabelProvider { if (element instanceof ICElement) { ICElement celem= (ICElement)element; - String name = ""; + StringBuffer name = new StringBuffer(); switch(celem.getElementType()){ case ICElement.C_FIELD: case ICElement.C_VARIABLE: case ICElement.C_VARIABLE_DECLARATION: IVariableDeclaration vDecl = (IVariableDeclaration) celem; - name = vDecl.getElementName(); + name.append(vDecl.getElementName()); if((vDecl.getTypeName() != null) &&(vDecl.getTypeName().length() > 0)){ - name += " : "; - name += vDecl.getTypeName(); + name.append(" : "); + name.append(vDecl.getTypeName()); } break; case ICElement.C_FUNCTION: @@ -77,48 +77,48 @@ public class CElementLabelProvider extends LabelProvider { case ICElement.C_METHOD: case ICElement.C_METHOD_DECLARATION: IFunctionDeclaration fDecl = (IFunctionDeclaration) celem; - name = fDecl.getSignature(); + name.append(fDecl.getSignature()); if((fDecl.getReturnType() != null) &&(fDecl.getReturnType().length() > 0)){ - name += " : "; - name += fDecl.getReturnType(); + name.append(" : "); + name.append(fDecl.getReturnType()); } break; case ICElement.C_STRUCT: case ICElement.C_UNION: case ICElement.C_ENUMERATION: if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){ - name = celem.getElementName(); + name.append(celem.getElementName()); } else if (celem instanceof IVariableDeclaration) { IVariableDeclaration varDecl = (IVariableDeclaration) celem; - name = varDecl.getTypeName(); + name.append(varDecl.getTypeName()); } break; case ICElement.C_TYPEDEF: ITypeDef tDecl = (ITypeDef) celem; - name = tDecl.getElementName(); + name.append(tDecl.getElementName()); if((tDecl.getTypeName() != null) &&(tDecl.getTypeName().length() > 0)){ - name += " : "; - name += tDecl.getTypeName(); + name.append(" : "); + name.append(tDecl.getTypeName()); } break; case ICElement.C_NAMESPACE: if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){ - name = celem.getElementName(); + name.append(celem.getElementName()); } else if (celem instanceof INamespace) { INamespace nDecl = (INamespace) celem; - name = nDecl.getTypeName(); + name.append(nDecl.getTypeName()); } break; default: - name= celem.getElementName(); + name.append(celem.getElementName()); break; } if (celem instanceof IBinary) { IBinary bin = (IBinary)celem; - name += " - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]"; + name.append(" - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]"); } - return name; + return name.toString(); } return fWorkbenchLabelProvider.getText(element); }