lundi 5 octobre 2015

How to get reflection data on class mentioned in macro definition?

I'm using white box macro annotations for code generation. And I'd like step beyond trivial quasiquote substitution and decide macros basing on extra information:

  • check actual types of terms
  • find all members for a trait including inherited

I understand that currently processed file is yet not available for reflection when macro expansion is called. It remains in AST form.

But, all dependent files should be already compiled by that time. So, if AST passed to a macro definition has type named MyType, that type should already be declared somewhere. The sad news is that MyType may be an alias introduced in import statement.

So, I figured the following problems should be solved to make rich macros:

  1. From given term calculate its canonical name
  2. Check if that name is defined in the current file and get corresponding SymTree
  3. In the other case take project classpath containing already compiled files and search canonical name in them.

And, I have no clue how to approach each of the tasks. Could you suggest some way out of there?





Aucun commentaire:

Enregistrer un commentaire