As you may have seen if you are subscribed to the cvs mailing list, I've
been working on the CodeModel. It is progressing well, and most of the
statement types have been dealt with.
Give a look to CodeWritterTest and CodeWritterInsertTest to understand how
it is used.
Implementation:
The rewritter switches between two modes when visiting the code model:
- inserting (when 'inserting' some new code)
- updating (when visiting an element that have not moved)
Change made to the model are captured by the Element. There is two different
kinds of change tracking:
- mandatory element: unmodified/replaced (for example, a while statement
condition must always be present)
- optional element: unmodified/added/removed/replaced (for example, the
value associated to a return statement).
The rewritter combines the change type and the current mode to decide how
the source code should be updated.
There is still much to do, but there is enough to know that it is a working
solution.
To do:
- ForStatement (need to change the declaration node from statement type to
expression type first)
- expressions handling
- code style (the indent manager is definitely not what it should be, and
should probably have more responsabilities, such as
CodeWritter::beginNewStatement).
Feedbacks are more than welcome,
Baptiste.
|