Search in sources :

Example 1 with LazyFunction

use of com.redhat.ceylon.model.loader.model.LazyFunction in project ceylon-compiler by ceylon.

the class Naming method quoteMethodNameIfProperty.

private static String quoteMethodNameIfProperty(Function method) {
    String name = method.getName();
    if (!method.isShared()) {
        name = suffixName(Suffix.$priv$, name);
    }
    // Toplevel methods keep their original name because their names might be mangled
    if (method instanceof LazyFunction) {
        return ((LazyFunction) method).getRealName();
    }
    // since local methods have a $getter suffix
    if (!method.isClassOrInterfaceMember())
        return name;
    // do not quote method names if we have a refined constraint
    Function refinedMethod = (Function) method.getRefinedDeclaration();
    if (refinedMethod instanceof JavaMethod) {
        return ((JavaMethod) refinedMethod).getRealName();
    }
    // get/is with at least one more letter, no parameter and non-void type
    if (((name.length() >= 4 && name.startsWith("get")) || name.length() >= 3 && name.startsWith("is")) && method.getFirstParameterList().getParameters().isEmpty() && !AbstractTransformer.isAnything(method.getType()))
        return quote(name);
    // set with one parameter and void type
    if ((name.length() >= 4 && name.startsWith("set")) && method.getFirstParameterList().getParameters().size() == 1 && AbstractTransformer.isAnything(method.getType()))
        return quote(name);
    return name;
}
Also used : LazyFunction(com.redhat.ceylon.model.loader.model.LazyFunction) Function(com.redhat.ceylon.model.typechecker.model.Function) JavaMethod(com.redhat.ceylon.model.loader.model.JavaMethod) LazyFunction(com.redhat.ceylon.model.loader.model.LazyFunction)

Aggregations

JavaMethod (com.redhat.ceylon.model.loader.model.JavaMethod)1 LazyFunction (com.redhat.ceylon.model.loader.model.LazyFunction)1 Function (com.redhat.ceylon.model.typechecker.model.Function)1