use of com.redhat.ceylon.model.loader.model.JavaMethod in project ceylon-compiler by ceylon.
the class Naming method getMethodNameInternal.
private static String getMethodNameInternal(TypedDeclaration decl) {
String name;
if (decl.isClassOrInterfaceMember() && decl instanceof Function) {
Declaration refined = decl.getRefinedDeclaration();
if (refined instanceof JavaMethod) {
return ((JavaMethod) refined).getRealName();
}
name = quoteMethodNameIfProperty((Function) decl);
} else {
name = decl.getName();
}
if (decl.isClassMember() && "readResolve".equals(name) && Strategy.addReadResolve((Class) decl.getContainer())) {
return quote(name);
}
if (decl.isClassMember() && "writeReplace".equals(name) && Strategy.useSerializationProxy((Class) decl.getContainer())) {
return quote(name);
}
// ERASURE
if (QUOTABLE_METHOD_NAMES.contains(name)) {
return quote(name);
} else {
return quoteIfJavaKeyword(name);
}
}
use of com.redhat.ceylon.model.loader.model.JavaMethod 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;
}
Aggregations