Skip to content

Commit

Permalink
go/ast: add Apply, for rewriting ASTs
Browse files Browse the repository at this point in the history
Based on work by Robert Griesemer.

Fixes golang#17108

DO NOT REVIEW

Work in progress. Notes:

Needs more tests, particularly of interactions between modifications,
like Delete then InsertAfter, Delete then InsertBefore, and so on.
Even just the few tests I've added so far have helped to clarify the API.

I've changed Apply to not walk the node inserted by InsertAfter.

Optimize: Need to allocate a single ApplyCursor and reuse it.

TODO: Review API, consider shrinking it a bit. Do we need ApplyCursor.IsFile
to be exported? ApplyCursor.Name? And so on.

Should Apply do anything with comments and/or CommentMaps?

Should Apply.Name be renamed Apply.FieldName?

Change-Id: I291bb3f8aba85abdeb728714c08702c082617f54
  • Loading branch information
josharian committed Aug 15, 2017
1 parent 4457175 commit a324fba
Show file tree
Hide file tree
Showing 2 changed files with 632 additions and 0 deletions.
Loading

0 comments on commit a324fba

Please sign in to comment.