Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » AST not as plugin
AST not as plugin [message #156295] Wed, 28 April 2004 05:56 Go to next message
Eclipse UserFriend
Hi,

I've read, that it is possible from M8 on to use the AST independently.
Trying "AST ast = new AST()" does not work because of dependencies.

Could someone give me some link with the description of how to set up
the use of the AST outside of a plugin.

TIA

Frank
Re: AST not as plugin [message #156325 is a reply to message #156295] Wed, 28 April 2004 10:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomannNO.ca.ibm.comSPAM

Le Wed, 28 Apr 2004 11:56:48 +0200, Frank Radermacher
<isag.srl@libero.it> a écrit :
>Could someone give me some link with the description of how to set up
>the use of the AST outside of a plugin.
It doesn't work outside of a plugin, because it requires JavaCore
plugin to be initialized.
--
Olivier
Re: AST not as plugin [message #156336 is a reply to message #156325] Wed, 28 April 2004 12:00 Go to previous messageGo to next message
Eclipse UserFriend
Olivier Thomann wrote:
> Le Wed, 28 Apr 2004 11:56:48 +0200, Frank Radermacher
> <isag.srl@libero.it> a écrit :
>
>>Could someone give me some link with the description of how to set up
>>the use of the AST outside of a plugin.
>
> It doesn't work outside of a plugin, because it requires JavaCore
> plugin to be initialized.
> --
> Olivier

The following code runs untill the end, without initialized JavaCore.

How can I put the CompilationUnit into a file?

Frank

Hashtable hashtable = new Hashtable();
hashtable.put("org.eclipse.jdt.core.compiler.source","1.4 ");
AST ast = new AST(hashtable);
CompilationUnit unit = ast.newCompilationUnit();
PackageDeclaration mrk = ast.newPackageDeclaration();
mrk.setName(ast.newSimpleName("mrk"));
unit.setPackage(mrk);
ImportDeclaration imp_fo_core = ast.newImportDeclaration();
imp_fo_core.setName(ast.newQualifiedName(
ast.newSimpleName("fo"),
ast.newSimpleName("core")) );
imp_fo_core.setOnDemand(true);
unit.imports().add(imp_fo_core);
TypeDeclaration myType = ast.newTypeDeclaration();
myType.setInterface(false);
myType.setModifiers(Modifier.PUBLIC);
myType.setName(ast.newSimpleName("MyType"));
MethodDeclaration method_1 = ast.newMethodDeclaration();
method_1.setConstructor(false);
method_1.setModifiers(Modifier.PUBLIC);
method_1.setName(ast.newSimpleName("actionWriteMessage"));
method_1.setReturnType(ast.newPrimitiveType(PrimitiveType.VO ID));
Block block = ast.newBlock();
MethodInvocation invoc_1 = ast.newMethodInvocation();
invoc_1.setExpression(ast.newQualifiedName(
ast.newSimpleName("System"),
ast.newSimpleName("out")) );
invoc_1.setName(ast.newSimpleName("println"));
InfixExpression infix_1 = ast.newInfixExpression();
infix_1.setOperator(InfixExpression.Operator.PLUS);
StringLiteral literal = ast.newStringLiteral();
literal.setLiteralValue("Ciao");
infix_1.setLeftOperand(literal);
literal = ast.newStringLiteral();
literal.setLiteralValue(" world");
infix_1.setRightOperand(literal);
invoc_1.arguments().add(infix_1);
ExpressionStatement expression_1 =
ast.newExpressionStatement(invoc_1);
block.statements().add(expression_1);
method_1.setBody(block);
myType.bodyDeclarations().add(method_1);
unit.types().add(myType);
String str = unit.toString();
System.out.println(str);
Re: AST not as plugin [message #156340 is a reply to message #156336] Wed, 28 April 2004 12:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomannNO.ca.ibm.comSPAM

Le Wed, 28 Apr 2004 18:00:37 +0200, Frank Radermacher
<isag.srl@libero.it> a écrit :
>The following code runs untill the end, without initialized JavaCore.
This is because you provide a hashtable for the options and you don't
convert existing source code. As soon as you need to get the options
from JavaCore, JavaCore needs to be initialized.
--
Olivier
Re: AST not as plugin [message #156348 is a reply to message #156340] Wed, 28 April 2004 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Olivier Thomann wrote:

> Le Wed, 28 Apr 2004 18:00:37 +0200, Frank Radermacher
> <isag.srl@libero.it> a écrit :
>
>>The following code runs untill the end, without initialized JavaCore.
>
> This is because you provide a hashtable for the options and you don't
> convert existing source code. As soon as you need to get the options
> from JavaCore, JavaCore needs to be initialized.
> --
> Olivier

That means that these guys are compleetly wrong?

http://www.program-transformation.org/Transform/JavaAbstract Syntax

Frank
Re: AST not as plugin [message #156556 is a reply to message #156348] Thu, 29 April 2004 04:47 Go to previous messageGo to next message
Eclipse UserFriend
I believe that no commitment was made to support DOM AST outside Eclipse. If
this works now, this could not work in the future.

Jerome

"Frank Radermacher" <isag.srl@libero.it> wrote in message
news:c6okn6$hvh$1@eclipse.org...
> Olivier Thomann wrote:
>
> > Le Wed, 28 Apr 2004 18:00:37 +0200, Frank Radermacher
> > <isag.srl@libero.it> a
Re: AST not as plugin [message #157211 is a reply to message #156348] Tue, 04 May 2004 12:16 Go to previous message
Eclipse UserFriend
no they are right, but AFAIK serialization only works within Eclipse
with IDocument objects

Frank Radermacher wrote:

> Olivier Thomann wrote:
>
>> Le Wed, 28 Apr 2004 18:00:37 +0200, Frank Radermacher
>> <isag.srl@libero.it> a écrit :
>>
>>> The following code runs untill the end, without initialized JavaCore.
>>
>>
>> This is because you provide a hashtable for the options and you don't
>> convert existing source code. As soon as you need to get the options
>> from JavaCore, JavaCore needs to be initialized.
>> --
>> Olivier
>
>
> That means that these guys are compleetly wrong?
>
> http://www.program-transformation.org/Transform/JavaAbstract Syntax
>
> Frank
>
Previous Topic:CVS keywords in Code Templates
Next Topic:How to I avoid compiling error :)
Goto Forum:
  


Current Time: Fri May 09 16:28:43 EDT 2025

Powered by FUDForum. Page generated in 0.03527 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top