[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-dev] Using the CDT API from a Java application, rather than an Eclipse Plugin
|
I'm trying to use the CDT API from an ordinary Java application, and not
from an Eclipse plug-in.
Generally speaking, is that possible?
When I try to run the below program, I get an exception regarding a "closed
workspace".
Is there another way for getting the AST, that doesn't involve Eclipse?
Exception in thread "main" java.lang.ExceptionInInitializerError
at JavaApp.main(InstrumentMe.java:18)
Caused by: java.lang.IllegalStateException: Workspace is closed.
at
org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java
:340)
at org.eclipse.cdt.internal.core.model.CModel.<init>(CModel.java:37)
at
org.eclipse.cdt.internal.core.model.CModelManager.<init>(CModelManager.java:
90)
at
org.eclipse.cdt.internal.core.model.CModelManager.getDefault(CModelManager.j
ava:175)
at org.eclipse.cdt.core.model.CoreModel.<clinit>(CoreModel.java:68)
... 1 more
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class JavaApp {
public static void main(String[] args) {
try
{
String FN="C:\\CFILES\\File.c";
IPath iPath=new Path(FN);
ITranslationUnit TemplateTransUnit=(ITranslationUnit)
CoreModel.getDefault().create(iPath);
IASTTranslationUnit TemplateAST=TemplateTransUnit.getAST();
System.out.println(TemplateAST.getRawSignature());
}catch (Exception e) {e.printStackTrace();}
}
}