Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nenuadrian/scala-compiler-plugin-method-rewrite
Rewriting/wrapping a method's body using AST TypingTransformer traversal and quasiquotes in a Scala compiler plugin
https://github.com/nenuadrian/scala-compiler-plugin-method-rewrite
ast-traversal metaprogramming scala scala-compiler scala-meta scalac
Last synced: 5 days ago
JSON representation
Rewriting/wrapping a method's body using AST TypingTransformer traversal and quasiquotes in a Scala compiler plugin
- Host: GitHub
- URL: https://github.com/nenuadrian/scala-compiler-plugin-method-rewrite
- Owner: nenuadrian
- Created: 2017-10-24T21:58:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-18T03:10:38.000Z (6 months ago)
- Last Synced: 2024-05-18T04:21:50.507Z (6 months ago)
- Topics: ast-traversal, metaprogramming, scala, scala-compiler, scala-meta, scalac
- Language: Scala
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Scala Compiler Plugin: Annotation-Based Method AST Rewriting
This repository contains a Scala compiler plugin example that demonstrates basic annotation parsing, AST traversal, and method body replacement. It substitutes the block of a method (DefDef) with an inner method, allowing the original code to be wrapped and additional behavior injected.
https://medium.com/@adrian.n/scala-compiler-plugin-annotation-based-method-ast-rewriting-wrapping-substitution-b802f2d922f1
## Overview
This plugin showcases:
- Parsing annotations
- Traversing the Abstract Syntax Tree (AST)
- Replacing method bodies (DefDef)The plugin rewrites annotated methods to include additional behaviour, such as logging or remote execution, without modifying the original method code.