зеркало из https://github.com/golang/tools.git
6fcd7783a1
Use the new inlining technology to implement a first change-signature refactoring, by rewriting the declaration to be a trivial wrapper around a declaration with modified signature, inlining the wrapper, and then performing string substitution to replace references to the synthetic delegate. This demonstrates the power of inlining, which can be seen as a more general tool for rewriting source code: express old code as new code, recognize instances of old code (in this case, calls), and inline. However, this CL was still rather difficult, primarily because of (1) the problem of manipulating syntax without breaking formatting and comments, and (2) the problem of composing multiple refactoring operations, which in general requires iterative type checking. Neither of those difficulties have general solutions: any form of nontrivial AST manipulation tends to result in an unacceptable movement of comments, and iterative type checking is difficult because it may involve an arbitrarily modified package graph, and because it is difficult to correlate references in the previous version of the package with references in the new version of the package. But in the case of removing a parameter, these problems are solvable: We can avoid most AST mangling by restricting the scope of rewriting to the function signature. We can type check the new package using the imports of the old package. We can find the next reference in the new package by counting. Fixes golang/go#63534 Change-Id: Iba5fa6b0da503b7723bea1b43fd2c4151576a672 Reviewed-on: https://go-review.googlesource.com/c/tools/+/532495 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Findley <rfindley@google.com> |
||
---|---|---|
.. | ||
clone.go |