0

Currently I'm working on an annotation in Java and everything works great. My AbstractProcessor creates the new files and can emit errors and warnings when needed. What is not working are real time errors and warnings. So what do I mean with that?

Assume I annotate a non parent method with @Override. The IDE will give me a real time error that I can not override this method since it is not part of the parent class. Same also goes for deprecated methods. Whenever you try to call one of these methods you get a warning about it. Note that these errors and warnings are emitted immediately and I do not have to rebuild my project to get notified about them.

Actually my warnings and errors are only emitted when I rebuild my project so how can I implement real time errors and warnings? Not sure if that matters but I use Intellij as IDE.

Cilenco
  • 6,951
  • 17
  • 72
  • 152
  • I think your IDE compiles the file on the fly and gets the warning from the compiler messages – Eugene Aug 29 '18 at 10:25
  • Yes that would make sense. But why isn't my `Processor` invoked then on the fly? Can I somewhere see the source of the `@Override` processor? – Cilenco Aug 29 '18 at 10:33
  • I assume you have written a compile time annotation processor and your IDE is eclipse? You can probably, but that would require lots of time to find I guess, it's part of `javac`, somewhere, somehow – Eugene Aug 29 '18 at 10:36
  • Yeah my annotations have `RetentionPolicy.SOURCE` and my IDE is Intellij. – Cilenco Aug 29 '18 at 10:41
  • I guess in such a case there is not hook or action in intellij set-up to handle this annotation and let's say underline an incorrect usage. I don't know how that is done in intellij, but obviously it's possible; as there are tools that do this... – Eugene Aug 29 '18 at 10:44

1 Answers1

0

It depends on your IDE.

For example, I use eclipse. After setup the annotation processor. It can show the error immediately when I save the file. Like this:

enter image description here

For your IDE, this page may help.

Dean Xu
  • 4,438
  • 1
  • 17
  • 44