我可以使用 RascalMPL 从 Java 文件解析 JPA 注释吗?就像下面的
@Entity
public class Customers {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "CustomerID", nullable = false)
private Integer customerId;
@Basic
@Column(name = "CustomerName", nullable = true, length = 50)
private String customerName;
@Basic
@Column(name = "ContactName", nullable = true, length = 50)
private String contactName;
@Basic
@Column(name = "Address", nullable = true, length = 50)
private String address;
@Basic
@Column(name = "City", nullable = true, length = 20)
private String city;
@Basic
@Column(name = "PostalCode", nullable = true, length = 10)
private String postalCode;
@Basic
@Column(name = "Country", nullable = true, length = 15)
private String country;
@OneToMany(mappedBy = "customersByCustomerId")
private Collection<Orders> ordersByCustomerId;
.....
}
我已经成功地用 Rascal 的 createM3FromFile 和 createAstFromFile 解析了文件,但我不确定如何遍历它来提取注释。