methodT(#id, #class, 'name', [#param_1,...], TYPE, [#exception_1,...], #body)

Represents the declaration of a method. Static methods have an additional fact “modifierT(ID, 'static')”, where ID is the #id value of the method. Note that (since JT 2.8) constructors are represented separately by constructorT facts and static initializers are represented by classInitializerT facts (see migration tips).

Arguments

#id: id
the unique ID of this method.

#class: classT
the ID of the class containing this method.

'name': atom
the name of the declared method

[#param_1,…]: paramT
the list of IDs of the method parameters.

TYPE: a typeterm
the return type of the method

[#exception_1,…]: classT
list of IDs of checked exceptions thrown by this method.

#body: blockT or 'null'
ID of the block containing the method body

Sample Java Source

class HelloWorld  {                        // -> classT below
  public static void main(String[] args)   // -> methodT and modifierT below
  {                                        // -> blockT below
    System.out.println("Hello World!");    // omitted below
  }
}

Its PEF Representation

classT(#class, #compilationUnit, 'HelloWorld', [..., #meth]). 
methodT(#meth, #class, 'main', [#param], type(basic, void, 0), [], #body).
modifierT(#meth,'static').
paramT(#param, ...).
blockT(#body, #meth, #meth, [#printStatement]).
...

AST Specification

ast_node_def('Java',methodT,[
     ast_arg(id,      mult(1,1,no ), id,  [methodT]), % <-- convention!!!
     ast_arg(parent,  mult(1,1,no ), id,  [classT]), 
     ast_arg(name,    mult(1,1,no ), attr,[atom]),
     ast_arg(params,  mult(0,*,ord), id,  [paramT]),
     ast_arg(type,    mult(1,1,no),  attr,[typeTermType,nullType]),
     ast_arg(excepts, mult(0,*,ord), id,  [classT]), %ord, only for compatibility with current PEF represenation: detection of lists
     ast_arg(body,    mult(0,1,no),  id,  [blockT,nullType])
]).
research/jtransformer/api/java/pefs/2.9/methodt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019