Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Using the CDT API from a Java application, rather than an Eclipse Plugin

Yes, this is the purpose behind breaking out core and UI to separate plug-ins, to allow them to be used headlessly, or using an alternate UI (like a Web UI maybe ;). But as James mentioned, they are not intended to be used outside of the Eclipse Platform (despite what one group has done ;). If this is too resource heavy, we should be looking at ways to make the platform more light weight when run headless.

:D

On Fri, May 7, 2010 at 6:56 AM, James Blackburn <jamesblackburn@xxxxxxxxx> wrote:
On 7 May 2010 11:52, Marica M <marica.marius@xxxxxxxxx> wrote:
> 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?

Make it an Eclipse IApplication. CDT depends on other platform plugins
such as core.resources, and the runtime core.jobs.  You'll still need
OSGI and the platform plugins, but this will allow you to use the core
features headlessly.

James

>
>
> 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();}
>                }
>
> }
>
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top