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.
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 901 B After Width: | Height: | Size: 910 B |
Before Width: | Height: | Size: 844 B After Width: | Height: | Size: 853 B |
Before Width: | Height: | Size: 901 B After Width: | Height: | Size: 910 B |
Before Width: | Height: | Size: 882 B After Width: | Height: | Size: 895 B |
Before Width: | Height: | Size: 819 B After Width: | Height: | Size: 826 B |
Before Width: | Height: | Size: 66 B After Width: | Height: | Size: 833 B |
Before Width: | Height: | Size: 80 B After Width: | Height: | Size: 833 B |
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|