[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Some enhancements
|
This patch:
- 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.
Thanks,
Hoda
Attachment:
enumerator_obj.gif
Description: GIF image
Index: model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java,v
retrieving revision 1.6
diff -u -r1.6 FunctionDeclaration.java
--- model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java 8 Apr 2003 21:30:53 -0000 1.6
+++ model/org/eclipse/cdt/internal/core/model/FunctionDeclaration.java 9 Apr 2003 14:23:46 -0000
@@ -50,26 +50,26 @@
}
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) {
Index: parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.1
diff -u -r1.1 CModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 8 Apr 2003 21:30:53 -0000 1.1
+++ parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 9 Apr 2003 14:23:47 -0000
@@ -370,75 +370,75 @@
}
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();
@@ -446,19 +446,19 @@
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();
}
}
Index: icons/full/obj16/enum_obj.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/obj16/enum_obj.gif,v
retrieving revision 1.2
diff -u -r1.2 enum_obj.gif
Binary files /tmp/cvspy4Ras and enum_obj.gif differ
Index: icons/full/obj16/enumerator_obj.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/obj16/enumerator_obj.gif,v
retrieving revision 1.1
diff -u -r1.1 enumerator_obj.gif
Binary files /tmp/cvsqN5V8J and enumerator_obj.gif differ
Index: icons/full/obj16/typedef_obj.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/obj16/typedef_obj.gif,v
retrieving revision 1.1
diff -u -r1.1 typedef_obj.gif
Binary files /tmp/cvsLeaj01 and typedef_obj.gif differ
Index: icons/full/obj16/var_declaration_obj.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/obj16/var_declaration_obj.gif,v
retrieving revision 1.1
diff -u -r1.1 var_declaration_obj.gif
Binary files /tmp/cvsiQqlMj and var_declaration_obj.gif differ
Index: icons/full/ovr16/c_ovr.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/ovr16/c_ovr.gif,v
retrieving revision 1.2
diff -u -r1.2 c_ovr.gif
Binary files /tmp/cvspIIetB and c_ovr.gif differ
Index: icons/full/ovr16/static_co.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/ovr16/static_co.gif,v
retrieving revision 1.1
diff -u -r1.1 static_co.gif
Binary files /tmp/cvsqHj37S and static_co.gif differ
Index: icons/full/ovr16/volatile_co.gif
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/icons/full/ovr16/volatile_co.gif,v
retrieving revision 1.1
diff -u -r1.1 volatile_co.gif
Binary files /tmp/cvsxxipKa and volatile_co.gif differ
Index: src/org/eclipse/cdt/internal/ui/CPluginImages.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java,v
retrieving revision 1.11
diff -u -r1.11 CPluginImages.java
--- src/org/eclipse/cdt/internal/ui/CPluginImages.java 5 Apr 2003 19:50:43 -0000 1.11
+++ src/org/eclipse/cdt/internal/ui/CPluginImages.java 9 Apr 2003 14:24:21 -0000
@@ -124,6 +124,7 @@
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");
Index: src/org/eclipse/cdt/ui/CElementImageDescriptor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementImageDescriptor.java,v
retrieving revision 1.3
diff -u -r1.3 CElementImageDescriptor.java
--- src/org/eclipse/cdt/ui/CElementImageDescriptor.java 31 Mar 2003 15:52:03 -0000 1.3
+++ src/org/eclipse/cdt/ui/CElementImageDescriptor.java 9 Apr 2003 14:24:21 -0000
@@ -162,11 +162,11 @@
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;
Index: src/org/eclipse/cdt/ui/CElementLabelProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CElementLabelProvider.java,v
retrieving revision 1.11
diff -u -r1.11 CElementLabelProvider.java
--- src/org/eclipse/cdt/ui/CElementLabelProvider.java 8 Apr 2003 21:30:47 -0000 1.11
+++ src/org/eclipse/cdt/ui/CElementLabelProvider.java 9 Apr 2003 14:24:21 -0000
@@ -60,16 +60,16 @@
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 @@
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);
}
Attachment:
static_co.gif
Description: GIF image
Attachment:
volatile_co.gif
Description: GIF image
Attachment:
typedef_obj.gif
Description: GIF image
Attachment:
c_ovr.gif
Description: GIF image
Attachment:
enum_obj.gif
Description: GIF image
Attachment:
var_declaration_obj.gif
Description: GIF image