Reputation: 477
I have used the OpenJDK to modify the Java compiler to display additional warnings. Now I want to use this compiler in Eclipse.
According to this answer Eclipse uses an incremental compiler. Is there a way to disable the incremental compiler and set a path to my custom compiler? Would this be able with a plugin?
Alternatively if this was not possible, how can you build Eclipse on your own?
Upvotes: 1
Views: 853
Reputation: 477
The incremental eclipse compiler is part of the JDT module. Disabling it will also disable features like syntax highlighting, that you probably don't want to miss.
However you can use a plugin to modify the incremental compiler in the JDT using the compilationParticipant
extension point. You can place your own code in the various compilation steps with this approach.
Upvotes: 1
Reputation: 34137
The incremental Eclipse compiler is a core component of Eclipse and therefore not easy to modify or replace. The abstract syntax tree (AST) is not only used to compile source code to bytecod and find errors in this process but also for code highlighting, navigation, searching, refactoring, etc.
In Eclipse the abstract syntax tree is public API and can be created without modifying or replacing the compiler: see Eclipse help - JDT Plug-in Developer Guide - Manipulating Java code.
Alternatively, you can add your rules in SpotBugs which can be seen as the successor of FindBugs. SpotBugs reads bytecode (not source code) and creates an AST based on ASM (which has a different AST API than Eclipse or the OpenJDK compiler). The advantage of using SpotBugs would be that you would not need to implement the displaying of the found bugs and other UI things yourself.
To also answer your last question (which is not relevant if you are using Eclipse's public AST API or SpotBugs): Eclipse can be built e. g. by the Eclipse IDE or headless by the Maven extension Tycho (which is used by the Eclipse project itself, e. g. by JDT via Jenkins based on this pom.xml
).
Upvotes: 1
Reputation: 140417
I agree with the comments given by greg-449: to my knowledge, the compiler that is used to give you syntax highlighting and warnings within the eclipse editor window is baked into eclipse. Beyond that, eclipse JDT provides extension points which might allow you to do some of things you have in mind. See their documentation for further details.
Still, my distinct non-answer: don't do that. Don't invent your own tool chain elements to improve code quality. They will only work for you, and your special eclipse setup.
Instead: look into existing tooling to give you what you want, as in
Upvotes: 1