I'm trying to learn ASTParser with the help of this tutorial. When I compile the first slice of code:
ASTParser parser = ASTParser.newParser(AST.JLS2);
parser.setSource("".toCharArray());
CompilationUnit unit = (CompilationUnit) parser.createAST(null);
unit.recordModifications()开发者_如何学C;
AST ast = unit.getAST();
I get this error:
Source non found. The JAR of this class file belongs to container 'Plug-in Dependencies' which does not allow modifications to source attachments on its entries.
What can I do?
According to this, you should include these jar files:
- org.eclipse.core.contenttype.jar
- org.eclipse.core.jobs.jar
- org.eclipse.core.resources.jar
- org.eclipse.core.runtime.jar
- org.eclipse.equinox.common.jar
- org.eclipse.equinox.preferences.jar
- org.eclipse.jdt.core.jar
- org.eclipse.osgi.jar
精彩评论