To provide a better experience to the user of the SmallJava editor and tooling, we customize the appearance of SmallJava members (fields and methods) in several places of the UI.
First of all, we give a better string representation of members by also showing their type
feature; thus, the string representation of a member is its name and its type's name separated by a colon :
. Moreover, for methods, we also show the type of each parameter. We mimic the representation of Java members as implemented by Eclipse JDT. We then implement the methods for string representation in SmallJavaModelUtil
:
def memberAsString(SJMember m) { m.name + if (m instanceof SJMethod) "(" + m.params.map[type.name].join(", ") + ")" else "" } def memberAsStringWithType(SJMember m) { m.memberAsString + " : " + m.type.name }
We also borrow icons from Eclipse JDT for classes, fields, and methods. As we saw in Chapter 6, Customizing Xtext Components, we can specify the label representation for...