[英]How to programmatically create literals using Eclipse AST
How to create different types of objects and literals using Eclipse AST? 如何使用Eclipse AST创建不同类型的对象和文字?
ie To create primitives like 'c', 1, 1.5f
. 即创建诸如'c', 1, 1.5f
类'c', 1, 1.5f
基元。 To create objects literals like new Employee('str')
创建对象文字如new Employee('str')
You have to use AST
class, here's a documentation for it. 您必须使用AST
类,这是它的文档 。
For example creating a StringLiteral
which contains Hello World
phrase. 例如,创建包含Hello World
短语的StringLiteral
。
AST ast = newAST(AST.JLS4)
StringLiteral literal = ast.newStringLiteral();
literal.setLiteralValue("Hello World");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.