compilationUnitT(#id, #package, #fileS, [#import_1, ...], [#def_1, ...] )

Represents a Java compilation unit, that is a file that contains a set of import and type declarations that are compiled together and belong to the same package. The import and type declarations are children of the compilation unit. The package is the parent of the compilation unit. The file is a reference to an element that is not part of the Java AST. This is specified by:

Added/changed in JT 2.6: Formerly fileT – See notes on Changes JTranformer 2.5 -> 2.6.

Arguments

#id: id
the unique ID assigned to this fact.

#package: packageT, 'defaultPackage'
Id of the containing package or 'defaultPackage'.

#file: fileS, 'dummyFile'
Id of the file that contains this compilation unit or 'dummyFile' for Bytecode classes.

[#import_1,…]: importT
List of IDs of import declarations contained in the compilation unit. The order in the list corresponds to the textual order in the file.

[#def_1,…]: classT
List of IDs of type declarations contained in the compilation unit. The order in the list corresponds to the textual order in the file.

Sample Java Source

package packaged;

import java.util.List;

public class DummyClass {
	List list;
}

Its PEF Representation

packageT(#Package, 'packaged'),
compilationUnitT(#CompilationUnit, #Package, #File, [#Import], [#Class]),
importT(#Import, #CompilationUnit, #Imported),
classT(#Class, #CompilationUnit, 'DummyClass', [#Field]),
fieldT(...

AST Specification

ast_node_def('Java',compilationUnitT,[
     ast_arg(id,     mult(1,1,no ), id,    [compilationUnitT]),
     ast_arg(parent, mult(0,1,no),  id,    [packageT,'defaultPackage']),
     ast_arg(file,   mult(1,1,no ), id,    [fileS,'dummyFile']),  %dummyFile for byteCode classes.
     ast_arg(imports,mult(0,*,ord), id,    [importT]),
     ast_arg(defs,   mult(0,*,ord), id,    [classT])
]).
research/jtransformer/api/java/pefs/3.0/compilationunitt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2018