is there a convention for what to do in a macro (while expanding the macro) to signal to the IDE to annotate the code in some way. For example I have a macro which sometimes detects unreachable code. It would be great if that could annotate the code if the user loads the file inside cider β¦
Normally it's done by throwing an exception. But I understand you want more of a "warn". I'd say that's normally done by printing. Since you'd be connected to a REPL, you would see something being printed. This is what the compiler does to notify you of warnings.
throw exception?
is unreachable code intentionally added by the macro?
I donβt want to throw an exception. the code will still work.
I just want to notify the ide to annotate something.
I don't know if cider annotate anything. Maybe look at clojure-lsp and how it can unravel macroses
imagine for a very very simple case that I have a my-if macro, and during the macro expansion, it realizes that the else part is unreachable. the code still works, but it would be nice to notify the user of this fact.
in common lisp and slime, the macro expander is allowed to raise a warning condition.
conditions being a generalization of exceptions used in CL
I'm not aware if similar technic exist in clojure
I think the most used mechanism for this would be clj-kondo hooks. https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md