Typically, when you are parsing Java code with JDT, you make it as a plugin and do something like this where
1 You first make a project:
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(projectName);
project.create(null);
project.open(null);
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[] { JavaCore.NATURE_ID });
project.setDescription(description, null);
IJavaProject javaProject = JavaCore.create(project);
2 then set the project to your ASTParser:
ASTParser parser = ASTParser.newParser(AST.JLS9);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setProject(javaProject);
Is there a way I can achieve what the above is doing without having to open Eclipse and run as a plugin? There has to be a way to create the same data structures programmatically by recreating the same environment to be as if it is running on the Eclipse IDE. Particularly, I feel like the easiest would be creating a "IJavaProject" object somehow.
What are some ways to do this?
I know making it a headless RCP application is a possibility, but I want to know if I can make it as a standalone Java application by using the appropriate jars or even modifying the jars and creating my own.