internal/lsp/cache: parse go.mod file before running go mod tidy
internal/lsp/cache: parse go.mod file before running go mod tidy

This change reorders the logic within ModTidyHandle and ParseModHandle to parse the modfile first before we copy the contents to the temporary go.mod file. This was causing issues where a go.mod would be in a bad state and then we would try to run "go mod tidy" on the corrupted file.

Change-Id: I1df8fb70f5f3e2bcff306a58b16bc96c32debf2a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219480
Run-TryBot: Rohan Challa <9671c73253cee9b18b8df367e3e627fab2863fe8@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Rebecca Stambler <d7cf11e5f299d88ea8348366a9fc4f7c335c3afa@golang.org>

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