1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

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.
This commit is contained in:
Doug Schaefer 2003-04-09 15:07:59 +00:00
parent 3268c4fc9f
commit cc325e9b5f
12 changed files with 59 additions and 58 deletions

View file

@ -50,26 +50,26 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
} }
public String getSignature(){ public String getSignature(){
String sig = getElementName(); StringBuffer sig = new StringBuffer(getElementName());
if(getNumberOfParameters() > 0){ if(getNumberOfParameters() > 0){
sig += "("; sig.append("(");
String[] paramTypes = getParameterTypes(); String[] paramTypes = getParameterTypes();
int i = 0; int i = 0;
sig += paramTypes[i++]; sig.append(paramTypes[i++]);
while (i < paramTypes.length){ while (i < paramTypes.length){
sig += (", "); sig.append(", ");
sig += paramTypes[i++]; sig.append(paramTypes[i++]);
} }
sig += ")"; sig.append(")");
} }
else{ else{
sig += "()"; sig.append("()");
} }
if(isConst()) if(isConst())
sig += " const"; sig.append(" const");
if(isVolatile()) if(isVolatile())
sig += " volatile"; sig.append(" volatile");
return sig; return sig.toString();
} }
public String getParameterInitializer(int pos) { public String getParameterInitializer(int pos) {

View file

@ -372,75 +372,75 @@ public class CModelBuilder {
} }
private String getType(Declaration declaration, Declarator declarator){ private String getType(Declaration declaration, Declarator declarator){
String type = ""; StringBuffer type = new StringBuffer();
// get type from declaration // get type from declaration
type = getDeclarationType(declaration); type.append(getDeclarationType(declaration));
// add pointerr or reference from declarator if any // add pointerr or reference from declarator if any
type += getDeclaratorPointerOperation(declarator); type.append(getDeclaratorPointerOperation(declarator));
return type; return type.toString();
} }
private String getDeclarationType(Declaration declaration){ private String getDeclarationType(Declaration declaration){
String type = ""; StringBuffer type = new StringBuffer();
if(declaration instanceof ParameterDeclaration){ if(declaration instanceof ParameterDeclaration){
ParameterDeclaration paramDeclaration = (ParameterDeclaration) declaration; ParameterDeclaration paramDeclaration = (ParameterDeclaration) declaration;
if(paramDeclaration.getDeclSpecifier().isConst()) if(paramDeclaration.getDeclSpecifier().isConst())
type += "const "; type.append("const ");
if(paramDeclaration.getDeclSpecifier().isVolatile()) if(paramDeclaration.getDeclSpecifier().isVolatile())
type += "volatile "; type.append("volatile ");
TypeSpecifier typeSpecifier = paramDeclaration.getTypeSpecifier(); TypeSpecifier typeSpecifier = paramDeclaration.getTypeSpecifier();
if(typeSpecifier == null){ if(typeSpecifier == null){
type += paramDeclaration.getDeclSpecifier().getTypeName(); type.append(paramDeclaration.getDeclSpecifier().getTypeName());
} }
else if(typeSpecifier instanceof ElaboratedTypeSpecifier){ else if(typeSpecifier instanceof ElaboratedTypeSpecifier){
ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier; ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier;
type += getElaboratedTypeSignature(elab); type.append(getElaboratedTypeSignature(elab));
} }
} }
if(declaration instanceof SimpleDeclaration){ if(declaration instanceof SimpleDeclaration){
SimpleDeclaration simpleDeclaration = (SimpleDeclaration) declaration; SimpleDeclaration simpleDeclaration = (SimpleDeclaration) declaration;
if(simpleDeclaration.getDeclSpecifier().isConst()) if(simpleDeclaration.getDeclSpecifier().isConst())
type += "const "; type.append("const ");
if(simpleDeclaration.getDeclSpecifier().isVolatile()) if(simpleDeclaration.getDeclSpecifier().isVolatile())
type += "volatile "; type.append("volatile ");
TypeSpecifier typeSpecifier = simpleDeclaration.getTypeSpecifier(); TypeSpecifier typeSpecifier = simpleDeclaration.getTypeSpecifier();
if(typeSpecifier == null){ if(typeSpecifier == null){
type += simpleDeclaration.getDeclSpecifier().getTypeName(); type.append(simpleDeclaration.getDeclSpecifier().getTypeName());
} }
else if(typeSpecifier instanceof ElaboratedTypeSpecifier){ else if(typeSpecifier instanceof ElaboratedTypeSpecifier){
ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier; ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier;
type += getElaboratedTypeSignature(elab); type.append(getElaboratedTypeSignature(elab));
} }
} }
return type; return type.toString();
} }
private String getElaboratedTypeSignature(ElaboratedTypeSpecifier elab){ private String getElaboratedTypeSignature(ElaboratedTypeSpecifier elab){
String type = ""; StringBuffer type = new StringBuffer();
int t = elab.getClassKey(); int t = elab.getClassKey();
switch (t){ switch (t){
case ClassKey.t_class: case ClassKey.t_class:
type = "class"; type.append("class");
break; break;
case ClassKey.t_struct: case ClassKey.t_struct:
type = "struct"; type.append("struct");
break; break;
case ClassKey.t_union: case ClassKey.t_union:
type = "union"; type.append("union");
break; break;
case ClassKey.t_enum: case ClassKey.t_enum:
type = "enum"; type.append("enum");
break; break;
}; };
type += " "; type.append(" ");
type += elab.getName().toString(); type.append(elab.getName().toString());
return type; return type.toString();
} }
private String getDeclaratorPointerOperation(Declarator declarator){ private String getDeclaratorPointerOperation(Declarator declarator){
String pointerString = ""; StringBuffer pointerString = new StringBuffer();
List pointerOperators = declarator.getPointerOperators(); List pointerOperators = declarator.getPointerOperators();
if(pointerOperators != null) { if(pointerOperators != null) {
Iterator i = pointerOperators.iterator(); Iterator i = pointerOperators.iterator();
@ -448,19 +448,19 @@ public class CModelBuilder {
PointerOperator po = (PointerOperator) i.next(); PointerOperator po = (PointerOperator) i.next();
switch (po.getType()){ switch (po.getType()){
case PointerOperator.t_pointer: case PointerOperator.t_pointer:
pointerString += "*"; pointerString.append("*");
break; break;
case PointerOperator.t_reference: case PointerOperator.t_reference:
pointerString += "&"; pointerString.append("&");
break; break;
} }
if(po.isConst()) if(po.isConst())
pointerString += " const"; pointerString.append(" const");
if(po.isVolatile()) if(po.isVolatile())
pointerString += " volatile"; pointerString.append(" volatile");
} }
} }
return pointerString; return pointerString.toString();
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 B

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 882 B

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 819 B

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 B

After

Width:  |  Height:  |  Size: 833 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 B

After

Width:  |  Height:  |  Size: 833 B

View file

@ -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_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_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_WARNING= create(T_OVR, "warning_co.gif");
public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif"); public static final ImageDescriptor DESC_OVR_ERROR= create(T_OVR, "error_co.gif");

View file

@ -162,11 +162,11 @@ public class CElementImageDescriptor extends CompositeImageDescriptor {
private void drawTopRight() { private void drawTopRight() {
int x= getSize().x; int x= getSize().x;
ImageData data= null; ImageData data= null;
/* if ((fFlags & ABSTRACT) != 0) { if ((fFlags & VOLATILE) != 0) {
data= CPluginImages.DESC_OVR_ABSTRACT.getImageData(); data= CPluginImages.DESC_OVR_VOLATILE.getImageData();
x-= data.width; x-= data.width;
drawImage(data, x, 0); drawImage(data, x, 0);
}*/ }
if ((fFlags & CONSTANT) != 0) { if ((fFlags & CONSTANT) != 0) {
data= CPluginImages.DESC_OVR_CONSTANT.getImageData(); data= CPluginImages.DESC_OVR_CONSTANT.getImageData();
x-= data.width; x-= data.width;

View file

@ -60,16 +60,16 @@ public class CElementLabelProvider extends LabelProvider {
if (element instanceof ICElement) { if (element instanceof ICElement) {
ICElement celem= (ICElement)element; ICElement celem= (ICElement)element;
String name = ""; StringBuffer name = new StringBuffer();
switch(celem.getElementType()){ switch(celem.getElementType()){
case ICElement.C_FIELD: case ICElement.C_FIELD:
case ICElement.C_VARIABLE: case ICElement.C_VARIABLE:
case ICElement.C_VARIABLE_DECLARATION: case ICElement.C_VARIABLE_DECLARATION:
IVariableDeclaration vDecl = (IVariableDeclaration) celem; IVariableDeclaration vDecl = (IVariableDeclaration) celem;
name = vDecl.getElementName(); name.append(vDecl.getElementName());
if((vDecl.getTypeName() != null) &&(vDecl.getTypeName().length() > 0)){ if((vDecl.getTypeName() != null) &&(vDecl.getTypeName().length() > 0)){
name += " : "; name.append(" : ");
name += vDecl.getTypeName(); name.append(vDecl.getTypeName());
} }
break; break;
case ICElement.C_FUNCTION: case ICElement.C_FUNCTION:
@ -77,48 +77,48 @@ public class CElementLabelProvider extends LabelProvider {
case ICElement.C_METHOD: case ICElement.C_METHOD:
case ICElement.C_METHOD_DECLARATION: case ICElement.C_METHOD_DECLARATION:
IFunctionDeclaration fDecl = (IFunctionDeclaration) celem; IFunctionDeclaration fDecl = (IFunctionDeclaration) celem;
name = fDecl.getSignature(); name.append(fDecl.getSignature());
if((fDecl.getReturnType() != null) &&(fDecl.getReturnType().length() > 0)){ if((fDecl.getReturnType() != null) &&(fDecl.getReturnType().length() > 0)){
name += " : "; name.append(" : ");
name += fDecl.getReturnType(); name.append(fDecl.getReturnType());
} }
break; break;
case ICElement.C_STRUCT: case ICElement.C_STRUCT:
case ICElement.C_UNION: case ICElement.C_UNION:
case ICElement.C_ENUMERATION: case ICElement.C_ENUMERATION:
if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){ if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){
name = celem.getElementName(); name.append(celem.getElementName());
} else if (celem instanceof IVariableDeclaration) { } else if (celem instanceof IVariableDeclaration) {
IVariableDeclaration varDecl = (IVariableDeclaration) celem; IVariableDeclaration varDecl = (IVariableDeclaration) celem;
name = varDecl.getTypeName(); name.append(varDecl.getTypeName());
} }
break; break;
case ICElement.C_TYPEDEF: case ICElement.C_TYPEDEF:
ITypeDef tDecl = (ITypeDef) celem; ITypeDef tDecl = (ITypeDef) celem;
name = tDecl.getElementName(); name.append(tDecl.getElementName());
if((tDecl.getTypeName() != null) &&(tDecl.getTypeName().length() > 0)){ if((tDecl.getTypeName() != null) &&(tDecl.getTypeName().length() > 0)){
name += " : "; name.append(" : ");
name += tDecl.getTypeName(); name.append(tDecl.getTypeName());
} }
break; break;
case ICElement.C_NAMESPACE: case ICElement.C_NAMESPACE:
if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){ if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){
name = celem.getElementName(); name.append(celem.getElementName());
} else if (celem instanceof INamespace) { } else if (celem instanceof INamespace) {
INamespace nDecl = (INamespace) celem; INamespace nDecl = (INamespace) celem;
name = nDecl.getTypeName(); name.append(nDecl.getTypeName());
} }
break; break;
default: default:
name= celem.getElementName(); name.append(celem.getElementName());
break; 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.append(" - [" + bin.getCPU() + (bin.isLittleEndian() ? "le" : "be") + "]");
} }
return name; return name.toString();
} }
return fWorkbenchLabelProvider.getText(element); return fWorkbenchLabelProvider.getText(element);
} }