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

翻译师:私有变量应该过滤,不进行翻译 #33

Closed
creasy2010 opened this issue Jun 29, 2018 · 2 comments · Fixed by #151
Closed

翻译师:私有变量应该过滤,不进行翻译 #33

creasy2010 opened this issue Jun 29, 2018 · 2 comments · Fixed by #151

Comments

@creasy2010
Copy link
Contributor

目前翻译会把私有变量也翻译出来如下边的logger, 而这个变量在java端是内容的,没有任务语义,应该过滤

import {Logger} from './../../../../../../org/slf4j/Logger';
import java from 'js-to-java';

export interface IUserUpdatePwdRequest {
  serialVersionUID?: number;
  pwdStrength?: string;
  securityType?: string;
  oldPassword?: string;
  logger?: Logger;
  systemType?: string;
  adminId?: string;
  newPassword?: string;
  operationType?: string;
  userId?: string;
  token?: string;
}

export class UserUpdatePwdRequest {
  constructor(params: IUserUpdatePwdRequest) {
    this.serialVersionUID = params.serialVersionUID;
    this.pwdStrength = params.pwdStrength;
    this.securityType = params.securityType;
    this.oldPassword = params.oldPassword;
    this.logger = params.logger;
    this.systemType = params.systemType;
    this.adminId = params.adminId;
    this.newPassword = params.newPassword;
    this.operationType = params.operationType;
    this.userId = params.userId;
    this.token = params.token;
  }

  serialVersionUID?: number;
  pwdStrength?: string;
  securityType?: string;
  oldPassword?: string;
  logger?: Logger;
  systemType?: string;
  adminId?: string;
  newPassword?: string;
  operationType?: string;
  userId?: string;
  token?: string;

  __fields2java() {
    return {
      $class: 'com.qianmi.usercenter.api.bo.security.UserUpdatePwdRequest',
      $: {
        serialVersionUID: java.Long(this.serialVersionUID),
        pwdStrength: java.String(this.pwdStrength),
        securityType: java.String(this.securityType),
        oldPassword: java.String(this.oldPassword),
        logger: this.logger['__fields2java']
          ? this.logger['__fields2java']()
          : this.logger,
        systemType: java.String(this.systemType),
        adminId: java.String(this.adminId),
        newPassword: java.String(this.newPassword),
        operationType: java.String(this.operationType),
        userId: java.String(this.userId),
        token: java.String(this.token),
      },
    };
  }
}

//generate by interpret-cli dubbo2.js
@creasy2010
Copy link
Contributor Author

仅通过private 判断是不可以的, 如下例子,各字段都是private的,然后通过set get方法对外暴露.
image

所以过滤规则应当为两方面的结合:

  1. 修饰符 private|public |protect
  2. get set方法是否暴露

注: java中类的继承, 在抽取 ast对象是做了继承折叠 ;

@AtarisMio
Copy link
Contributor

Implement in #151, please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants