Search code examples
javaeclipsemethodsabstract-syntax-treeeclipse-jdt

Using ICompilationUnit for ASTParser.setSource() method in eclipse jdt/ast


ASTParser.setSource has polymorphic methods with different input types.

enter image description here

However, when I use ICompilationUnit as an input to setSource method,

enter image description here

I got an error saying I didn't use char[] as an input parameter.

enter image description here

Why this error?

ADDED

I use eclipse jdt/ast as a part of stand alone java program. In the course of doing that, I don't use eclipse project/resources, but load the java source into char[] as a parameter for setSource(). I'm not sure, but the eclipse may recognize that it's not run as a plugin to block the usage of other polymorphic methods.


Solution

  • I was trying to execute the jdt/ast as a library for stand-alone java program. When I rerun them in plugin context, everything works fine.