scalameta / scalagen

WIP - Scalameta powered code generation
Apache License 2.0
40 stars 5 forks source link

Syntactic vs Semantic discovery. #6

Open DavidDudson opened 6 years ago

DavidDudson commented 6 years ago

Syntactic

Search for an annotation with the appropriate name. Not fully qualified.

Pros: Extremely fast, no overhead. Cons: Will break if two annotations with the same name exist.

Semantic

Searches for an annotation with the correct fully qualified name.

Pros: Safe Cons: May have to build a semantic database of the source file

I believe that we should stick with syntactic discovery for now. If enough users wish for semantic discovery we should add it via a flag, so that those who don't need semantic discovery, do not have to take the performance hit.

olafurpg commented 6 years ago

Semantic discovery has one more advantage: generators can access the fully qualified names in the code. I think for now we can start with syntactic discovery just to get off the ground, I'm happy to help setup semantic discovery later down the road. The changes should be

DavidDudson commented 6 years ago

I propose we push for at a bare minimum FQN discovery for 0.1, with the potential for semantic-db etc. being added to generator contexts for 0.2