internal/lsp: Refactor to share logic with rename
internal/lsp: Refactor to share logic with rename

If a package is being operated on, getPackage returns that package information; otherwise nil.

Change-Id: I881056510b8d6862c274a7532fdfbc840c938468
Reviewed-on: https://go-review.googlesource.com/c/tools/+/418791
TryBot-Result: Gopher Robot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
gopls-CI: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Run-TryBot: Dylan Le <19fed614f843e0de8399ba7a25e061ee66748da3@google.com>
Reviewed-by: Robert Findley <9179eee875d1ee628c37fb47d7e749e855ffd21f@google.com>

golang/tools,golang/tools,golang/tools,golang/tools,golang/tools