Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define内部类生成错误$ #105

Closed
gyk001 opened this issue Jun 25, 2014 · 1 comment
Closed

define内部类生成错误$ #105

gyk001 opened this issue Jun 25, 2014 · 1 comment
Assignees
Labels
Milestone

Comments

@gyk001
Copy link

gyk001 commented Jun 25, 2014

配置

import.packages = xx.xx, com.google.common.collect

模板

<!-- #define(Map<String, MapDifference.ValueDifference<ColInfo>> differing) -->

生成的java源码

  @Override
  public void render(final JetPageContext $ctx) throws Throwable {
    final JetContext context = $ctx.getContext();
    final JetWriter $out = $ctx.getWriter();
    Map<String,com.google.common.collect.MapDifference$ValueDifference<xx.xx.ColInfo>> differing = (Map<String,com.google.common.collect.MapDifference$ValueDifference<xx.xx.ColInfo>>) context.get("differing"); // line: 1
    $out.print($txt_2, $txt_2_bytes);
    $out.flush();
  }

应该生成 com.google.common.collect.MapDifference.ValueDifference而不是com.google.common.collect.MapDifference$ValueDifference

@subchen subchen added the bug label Jun 25, 2014
@subchen subchen self-assigned this Jun 25, 2014
@subchen
Copy link
Owner

subchen commented Jun 25, 2014

ClassUtils.getShortClassName() 有问题,修复如下:

public static String getShortClassName(Class<?> klass) {
    if (klass.isPrimitive()) {
        return klass.getName();
    } else {
        String pkg = klass.getPackage().getName();
        if (default_package_set.contains(pkg)) {
            if (klass.isMemberClass()) {
                // 内部类
                return klass.getEnclosingClass().getSimpleName() + "." + klass.getSimpleName();
            } else {
                return klass.getSimpleName();
            }
        } else {
            if (klass.isMemberClass()) {
                // 内部类
                return klass.getEnclosingClass().getName() + "." + klass.getSimpleName();
            } else {
                return klass.getName();
            }
        }
    }
}

@subchen subchen added this to the 1.2.9 milestone Jun 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants