INRIA / spoon

Spoon is a metaprogramming library to analyze and transform Java source code. :spoon: is made with :heart:, :beers: and :sparkles:. It parses source files to build a well-designed AST with powerful analysis and transformation API.
http://spoon.gforge.inria.fr/
Other
1.74k stars 346 forks source link

feature: sniper mode (aka high fidelity code transformation) #1284

Closed monperrus closed 5 years ago

monperrus commented 7 years ago

we only rewrite the changed nodes, keeping the original formatting.

see ROADMAP

monperrus commented 7 years ago

depends on #1168

monperrus commented 7 years ago

useful for repairnator and co

tdurieux commented 7 years ago

see #1358

monperrus commented 5 years ago

closed per #1927

monperrus commented 4 years ago

FYI: An Algorithm for Layout Preservation in Refactoring Transformations https://link.springer.com/chapter/10.1007/978-3-642-28830-2_3

monperrus commented 4 years ago

More papers on high-fidelity / layout preserving code transformation:

High-fidelity C/C++ code transformation (2017) https://www.sciencedirect.com/science/article/pii/S0167642307000718/pdf

Detaching and reconstructing the documentary structure of source code (2010) https://www.researchgate.net/profile/Gabor_Kusper/publication/284888833_ICAI2010-volume2/links/5659ad0408aeafc2aac4c23a/ICAI2010-volume2.pdf#page=401

Layout preserving parser for refactoring in Erlang (2009) https://pdfs.semanticscholar.org/8487/eeda4c867e8f7cd13d83391488b2abec4a39.pdf

revcpp: A reversible c++ preprocessor (2015) https://www.lrde.epita.fr/~sigoure/revcpp.pdf

Scrap you reprinter (2017) https://www.cs.kent.ac.uk/people/staff/dao7/publ/reprinter2017.pdf

monperrus commented 4 years ago

Transformation tools with high-fidelity / layout preserving features (thanks to @jurgenvinju):

jurgenvinju commented 4 years ago

Tools:

Relevant papers:

jurgenvinju commented 4 years ago

the paper which coined the term "hifi" transformation for "no loss of layout and source code comments":

"High Fidelity C/C++ Code Transformation" by Daniel Waddington and Bin Yao https://www.researchgate.net/publication/222998573_High-Fidelity_CC_Code_Transformation

monperrus commented 4 years ago

FYI, JavaParser calls this feature "lexical preservation", see @ftomassetti's post https://tomassetti.me/lexical-preservation-javaparser/

jlundhol commented 4 years ago

This paper by Rodin T. A. Aarssen and Tijs van der Storm suggesting "Separator Syntax Trees" might be of interest:

High-fidelity metaprogramming with separator syntax trees (2020) https://dl.acm.org/doi/abs/10.1145/3372884.3373162