Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Eclipse CDT: Modify and save AST

I have just seen you replied to my comment on SO[1]. My initial
comment may not have been as helpful as you would have liked because I
was confused by you saying it was similar to [2] which may have other
issues, but is certainly being run in main. I have now seen your later
comments where you indicate you are indeed running as plug-ins.

Have you looked at what is in the CDT source code, for example
is a pretty small use case of ast rewriting.

Jonah Graham
Kichwa Coders Ltd.

On 26 November 2016 at 23:45, Jonah Graham <jonah@xxxxxxxxxxxxxxxx> wrote:
> Hi,
> Sounds like you are running without OSGi classloaders. You have
> compiled OK, but the class cannot be found at runtime (that is what
> NoClassDefFoundError means).. Is your code in an Eclipse plug-in so
> that all the dependencies are pulled in correctly at compile time? Are
> you then running as an Eclipse Application or similar OSGi so that the
> OSGi classloaders are used?
> If you are running an Eclipse app (and therefore using the expected
> classloaders), perhaps you are missing some require bundles in your
> manifest? That can happen if you use compile time only dependencies in
> the
> HTH,
> Jonah
> ~~~
> Jonah Graham
> Kichwa Coders Ltd.
> On 26 November 2016 at 23:08, sim0s <gerasimu_s@xxxxxxxxxxx> wrote:
>> I'm exploring ways to alter the AST of a C/C++ code (e.g., rename a node, add
>> a new variable) and apply these changes to the source file.
>> I did a lot of reading here in SO and in Eclipse forums. However I didn't
>> find a minimal working example.
>> It seems that the correct way to make changes in an AST is by using the
>> ASTRewrite class.
>> A similar question was asked in SO a few months ago, but it is still
>> pending.
>> Here is where I'm stuck at the moment:
>> //get the factory
>> INodeFactory nodeFactory = myAST.getASTNodeFactory();
>> //create a new function declarator
>> IASTNode n =
>> nodeFactory.newFunctionDeclarator(nodeFactory.newName("testMe"));
>> //get the rewriter
>> ASTRewrite rewriter = ASTRewrite.create(mainAST);
>> //replace node with n, node is not null
>> rewriter.replace(node, n, null);
>> //make the changes
>> Change c = rewriter.rewriteAST();
>> c.perform(new NullProgressMonitor());
>> When I run this code snippet, I get a
>> java.lang.NoClassDefFoundError: org/eclipse/ltk/core/refactoring/Change
>> Any hints are appreciated.
>> --
>> View this message in context:
>> Sent from the Eclipse CDT - Development mailing list archive at
>> _______________________________________________
>> cdt-dev mailing list
>> cdt-dev@xxxxxxxxxxx
>> To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top