konsoletyper 2015-02-21 23:01:12 +04:00
parent a882a4c956
commit 11437af5ae
2 changed files with 11 additions and 31 deletions

View File

@ -66,32 +66,13 @@ public class DefaultNamingStrategy implements NamingStrategy {
}
private String getNameFor(MethodReference method, char classifier) {
MethodReference origMethod = method;
method = getRealMethod(method);
if (method == null) {
throw new NamingException("Can't provide name for method as it was not found: " + origMethod);
}
ClassReader clsHolder = classSource.get(method.getClassName());
MethodReader methodHolder = clsHolder.getMethod(method.getDescriptor());
if (methodHolder.hasModifier(ElementModifier.STATIC) ||
method.getDescriptor().getName().equals("<init>") ||
methodHolder.getLevel() == AccessLevel.PRIVATE) {
String key = classifier + method.toString();
String alias = privateAliases.get(key);
if (alias == null) {
alias = aliasProvider.getAlias(method);
privateAliases.put(key, alias);
}
return alias;
} else {
String key = classifier + method.getDescriptor().toString();
String alias = aliases.get(key);
if (alias == null) {
alias = aliasProvider.getAlias(method);
aliases.put(key, alias);
}
return alias;
String key = classifier + method.getDescriptor().toString();
String alias = aliases.get(key);
if (alias == null) {
alias = aliasProvider.getAlias(method);
aliases.put(key, alias);
}
return alias;
}
@Override
@ -106,13 +87,13 @@ public class DefaultNamingStrategy implements NamingStrategy {
private String getFullNameFor(MethodReference method, char classifier) throws NamingException {
MethodReference originalMethod = method;
if (!minifying) {
return getNameFor(method.getClassName()) + "_" + getNameFor(method, classifier);
}
method = getRealMethod(method);
if (method == null) {
throw new NamingException("Can't provide name for method as it was not found: " + originalMethod);
}
if (!minifying) {
return getNameFor(method.getClassName()) + "_" + getNameFor(method, classifier);
}
String key = classifier + method.toString();
String alias = privateAliases.get(key);
if (alias == null) {

View File

@ -1604,7 +1604,6 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
String name = expr.getAsyncTarget() == null ? naming.getNameFor(expr.getMethod()) :
naming.getNameForAsync(expr.getMethod());
String fullName = naming.getFullNameFor(expr.getMethod());
DeferredCallSite callSite = prevCallSite;
boolean shouldEraseCallSite = lastCallSite == null;
if (lastCallSite == null) {
@ -1615,7 +1614,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
enterPriority(Priority.COMMA, Associativity.NONE, false);
switch (expr.getType()) {
case STATIC:
writer.append(fullName).append("(");
writer.appendMethodBody(expr.getMethod()).append("(");
prevCallSite = debugEmitter.emitCallSite();
for (int i = 0; i < expr.getArguments().size(); ++i) {
if (i > 0) {
@ -1626,7 +1625,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
break;
case SPECIAL:
writer.append(fullName).append("(");
writer.appendMethodBody(expr.getMethod()).append("(");
prevCallSite = debugEmitter.emitCallSite();
expr.getArguments().get(0).acceptVisitor(this);
hasParams = true;