Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Is it possible to hook into the eclipse compiler?(searching for possibilities to add functionality to the eclipse compiler)
icon5.gif  Is it possible to hook into the eclipse compiler? [message #647487] Thu, 06 January 2011 16:00 Go to next message
Amos  is currently offline Amos Friend
Messages: 3
Registered: January 2011
Junior Member
Hi all,

I have written some java code to perform source code scannings with the help of the JDT API. This scanning is meant to find things which aren't allowed in my company (e.g. usage of JSplitPane) and should be performed every day on our continous integration system which uses the eclipse compiler.

Now my intention was, is it possible to integrate my "conditional rules" to the eclipse compiler, so my code is getting the actual AST and/or the CompilationUnit which the compiler is currently working on, so i can do my checks?
Or is there another possibility to hook into the work of the compiler?
Otherwise it would be a waste of time and resources if the compiler parses everything, and when he is done i will have to do the exact same work again.

Thanks for your help and time!
Greetings
Amos

[Updated on: Thu, 06 January 2011 16:02]

Report message to a moderator

Re: Is it possible to hook into the eclipse compiler? [message #647507 is a reply to message #647487] Thu, 06 January 2011 17:10 Go to previous messageGo to next message
David Goodenough is currently offline David GoodenoughFriend
Messages: 157
Registered: July 2009
Senior Member
Amos wrote:

> Hi all,
>
> I have written some java code to perform source code scannings with the
> help of the JDT API. This scanning is meant to find things which aren't
> allowed in my company (e.g. usage of JSplitPane). This source code
> scanning should be performed every day on our continous integration system
> which uses the eclipse compiler.
>
> Now my intention was, is it possible to integrate my "conditional rules"
> to the eclipse compiler, so my code is getting the actual AST and/or the
> CompilationUnit which the compiler is currently working on, so i can do my
> checks? Or is there another possibility to hook into the work of the
> compiler? Otherwise it would be a waste of time and resources if the
> compiler parses everything, and when he is done i will have to do the
> exact same work again.
>
> Thanks for your help and time!
> Greetings
> Amos

You might try looking at the lombok project. (projectlombok.org).

David
Re: Is it possible to hook into the eclipse compiler? [message #647514 is a reply to message #647487] Thu, 06 January 2011 17:58 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 1/6/2011 9:30 PM, Amos wrote:
> Hi all,
>
> I have written some java code to perform source code scannings with the
> help of the JDT API. This scanning is meant to find things which aren't
> allowed in my company (e.g. usage of JSplitPane).
> This source code scanning should be performed every day on our continous
> integration system which uses the eclipse compiler.
>
> Now my intention was, is it possible to integrate my "conditional rules"
> to the eclipse compiler, so my code is getting the actual AST and/or the
> CompilationUnit which the compiler is currently working on, so i can do
> my checks? Or is there another possibility to hook into the work of the
> compiler? Otherwise it would be a waste of time and resources if the
> compiler parses everything, and when he is done i will have to do the
> exact same work again.
>
> Thanks for your help and time!
> Greetings
> Amos
>
Yes. Take a look at org.eclipse.jdt.core.compiler.CompilationParticipant.
Re: Is it possible to hook into the eclipse compiler? [message #647559 is a reply to message #647487] Fri, 07 January 2011 04:36 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 06/01/11 9:30 PM, Amos wrote:
> I have written some java code to perform source code scannings with the
> help of the JDT API. This scanning is meant to find things which aren't
> allowed in my company (e.g. usage of JSplitPane).
> This source code scanning should be performed every day on our continous
> integration system which uses the eclipse compiler.
>
> Now my intention was, is it possible to integrate my "conditional rules"
> to the eclipse compiler, so my code is getting the actual AST and/or the
> CompilationUnit which the compiler is currently working on, so i can do
> my checks? Or is there another possibility to hook into the work of the
> compiler? Otherwise it would be a waste of time and resources if the
> compiler parses everything, and when he is done i will have to do the
> exact same work again.

Can't this be done with Checkstyle? http://eclipse-cs.sourceforge.net/


--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: Is it possible to hook into the eclipse compiler? [message #647583 is a reply to message #647487] Fri, 07 January 2011 07:49 Go to previous messageGo to next message
Amos  is currently offline Amos Friend
Messages: 3
Registered: January 2011
Junior Member
@Prakash
No i don't think checkstyle can do what i need. For example i need to find all classes which extend a specific class and extract some information of these classes, there comes no way to my mind how checkstyle could do this Sad But if you know, pls let me know =)

@Deepak Azad
I have already had a look at the CompilationParticipant but how i understood this, it is more like pre / post compilation work like cleaning up and so on but not that the compiler lets me hook into the compilation unit which it is currently working on, so i can check this unit too and create for my "rules" compiler warnings and things alike.
Best case would be, compiler does its work, handles me the compilation unit (or something similar) and maybe the AST, i can do my work and generate warnings/errors which will the compiler print out, so the whole source code has not to be parsed and analyized twice (we are talking about 5mio LoC here).

any ideas?
thanks in advance
Amos

[Updated on: Fri, 07 January 2011 07:53]

Report message to a moderator

Re: Is it possible to hook into the eclipse compiler? [message #647586 is a reply to message #647487] Fri, 07 January 2011 08:23 Go to previous messageGo to next message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
On 06.01.2011 17:00, Amos wrote:
> Hi all,
>
> I have written some java code to perform source code scannings with
> the help of the JDT API. This scanning is meant to find things which
> aren't allowed in my company (e.g. usage of JSplitPane).
> This source code scanning should be performed every day on our
> continous integration system which uses the eclipse compiler.
Depending on the level of trust one has on its employees there might be
a simpler solution: you could define access restrictions on your
projects (Java Build Path) which would prevent the restricted things
from being able to be used.

Dani
>
> Now my intention was, is it possible to integrate my "conditional
> rules" to the eclipse compiler, so my code is getting the actual AST
> and/or the CompilationUnit which the compiler is currently working on,
> so i can do my checks? Or is there another possibility to hook into
> the work of the compiler? Otherwise it would be a waste of time and
> resources if the compiler parses everything, and when he is done i
> will have to do the exact same work again.
>
> Thanks for your help and time!
> Greetings
> Amos
>
Re: Is it possible to hook into the eclipse compiler? [message #647587 is a reply to message #647586] Fri, 07 January 2011 08:35 Go to previous message
Amos  is currently offline Amos Friend
Messages: 3
Registered: January 2011
Junior Member
hi Dani,
thanks for your answer but unfortunately its not that easy, because it is not only things which aren't allowed to use, there are several other rules to be adhered, e.g. every class has a @author tag, some things are not allowed to use, classes of a specific hiearchy have to contain special things / these things have to be a checked and so on...

I wish there was an simple solution Wink

pretty cool would be a way to reuse (NOT copy paste!) my code for an eclipse plug-in which could provide restricted access informations on the fly for the programmers while typing and create problems in the eclipse problem view / mark them in the code as errors / warnings

[Updated on: Fri, 07 January 2011 08:38]

Report message to a moderator

Previous Topic:Web page editor and JSF tools for eclipse 3.6.1 x64
Next Topic:Want to show Dialog of Open Type (ctrl+shift+T) on button click
Goto Forum:
  


Current Time: Wed Apr 24 22:07:24 GMT 2024

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

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

Back to the top