Macro2.hx 861 B

123456789101112131415161718192021222324252627282930313233343536
  1. import haxe.macro.Context;
  2. @:deprecated
  3. typedef DeprecatedType = String;
  4. class Macro2 {
  5. public static function init() {
  6. Context.onAfterTyping(afterTyping);
  7. }
  8. static function afterTyping(_) {
  9. Context.info("Info", Context.currentPos());
  10. Context.warning(("1" :DeprecatedType), Context.currentPos());
  11. Context.warning("2", Context.currentPos());
  12. Context.warning("3", Context.currentPos());
  13. var messages = Context.getMessages();
  14. var order = Lambda.fold(messages, (msg, acc) -> switch msg {
  15. case Warning(w, _) if (w.length == 1): acc + w;
  16. case Info(_, _): acc + 'i';
  17. case _: acc;
  18. }, "") + "|";
  19. Context.filterMessages(function(msg) {
  20. switch msg {
  21. case Warning(w, _) if (w.length == 1): order += w;
  22. case Info(_, _): order += 'i';
  23. case _:
  24. }
  25. return true;
  26. });
  27. Context.warning(order, Context.currentPos());
  28. }
  29. }