コード例 #1
0
    public void enterConstructorDeclaration(JavaParser.ConstructorDeclarationContext ctx) {
      int access = getClassBodyDeclarationAccessFlag(ctx.getParent().getParent());
      String paramDescriptors =
          createParamDescriptors(ctx.formalParameters().formalParameterList());
      String descriptor = paramDescriptors + "V";

      currentType.getMethods().add(new JavaMethod(currentType, access, "<init>", descriptor));
    }
コード例 #2
0
    public void enterClassBodyDeclaration(JavaParser.ClassBodyDeclarationContext ctx) {
      if (ctx.getChildCount() == 2) {
        ParseTree first = ctx.getChild(0);

        if (first instanceof TerminalNode) {
          if (((TerminalNode) first).getSymbol().getType() == JavaParser.STATIC) {
            currentType
                .getMethods()
                .add(new JavaMethod(currentType, JavaType.FLAG_STATIC, "<clinit>", "()V"));
          }
        }
      }
    }
コード例 #3
0
    public void enterMethodDeclaration(
        ParserRuleContext ctx,
        TerminalNode identifier,
        JavaParser.FormalParametersContext formalParameters,
        JavaParser.TypeContext returnType) {

      int access = getClassBodyDeclarationAccessFlag(ctx.getParent().getParent());
      String name = identifier.getText();
      String paramDescriptors = createParamDescriptors(formalParameters.formalParameterList());
      String returnDescriptor = createDescriptor(returnType, 0);
      String descriptor = paramDescriptors + returnDescriptor;

      currentType.getMethods().add(new JavaMethod(currentType, access, name, descriptor));
    }