java - Programmatically capture compiler errors from Eclipse -
i trying write program can extract compiler errors (or other things bad build paths) eclipse's "problems" view.
i have not been able find documentation on how might done.
i've got 3 possible solutions you:
don't use eclipse
this easiest way go. eclipse producing visual presentation of build errors, , want structured presentation, they're bad match.
on other hand, if run javac
command-line, output easy capture , relatively easy parse right there. if need more precise in parsing errors, @ running javacompiler
in code , providing custom diagnosticlistener
it.
if it's important capture nuances of eclipse compiler, can run command line (in batch mode). there's nice blog post describes process here: ecj - eclipse compiler java. here's short version: find ecj jar in eclipse distribution (mine in plugins/org.eclipse.jdt.core_3.8.3.v20130121-145325.jar
) , run on command line
java -jar <ecj.jar> <sourcefiles>
naturally, can run within java finer control.
use gui automation fetch errors
this clumsy, useful testing scenarios, want automated tester verify eclipse project builds way expect.
you can use tool autohotkey or sikuli or awt robot automatically fetch errors. simplest routine can think of goes this:
- click on "problems" tab bring front
- click on "errors" top-level node, selecting it
- type hot-key copy; errors copied clipboard, 1 per line
- paste or otherwise dump clipboard file
- repeat 2-4 other categories want capture, "warnings"
rewrite eclipse plugin
finally, if want need kind of real-time capture of error messages that's transparent user, you're stuck this.
you'll need go eclipse source code, definition of "problems" view , modify pass code information on side. whoever needs have use custom-built version of eclipse , not standard version.
Comments
Post a Comment