Fahim Farook
Fahim Farook

Reputation: 1483

How to programmatically create literals using Eclipse AST

How to create different types of objects and literals using Eclipse AST?

i.e. To create primitives like 'c', 1, 1.5f. To create objects literals like new Employee('str')

Upvotes: 0

Views: 84

Answers (1)

Templar
Templar

Reputation: 1871

You have to use AST class, here's a documentation for it.

For example creating a StringLiteral which contains Hello World phrase.

AST ast = newAST(AST.JLS4)
StringLiteral literal = ast.newStringLiteral();
literal.setLiteralValue("Hello World");

Upvotes: 1

Related Questions