Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: handle formatting on files that do not parse #31291

Open
stamblerre opened this issue Apr 5, 2019 · 2 comments

Comments

Projects
None yet
5 participants
@stamblerre
Copy link
Contributor

commented Apr 5, 2019

If we don't check a package's parse errors before formatting, we may encounter a case where we delete code on format.

Repro:

package foo

func _() {
	f(),
	f()
}

To handle this, we check the parse errors before formatting. However, we should confirm that these errors belong to the file in question and lie within the specified range before failing.

@stamblerre stamblerre added the gopls label Apr 5, 2019

@gopherbot gopherbot added this to the Unreleased milestone Apr 5, 2019

@bcmills bcmills added the NeedsFix label Apr 10, 2019

@myitcv

This comment has been minimized.

Copy link
Member

commented Apr 17, 2019

@stamblerre @ianthehat - should/can we also use this issue to pick up the conversation from https://go-review.googlesource.com/c/tools/+/171019/2#message-f8bec621217d3d2caad7dda408cdc629c71aaed6:

We should have a discussion about overall approach. The source package needs to return errors, because it has no idea about the environment it is running in, the question is whether the lsp package should log or propagate those errors. We were propagating them because we had no wired up way of logging, but I fixed that recently, so now we could choose to log them instead. We need to decide what level of failure should result in an error vs an empty result (does formatting a non existent file count as an actual error?)

Or do you want to capture that discussion about error propagation elsewhere?

@ianthehat

This comment has been minimized.

Copy link

commented Apr 17, 2019

I think that is a separate issue. In fact, is now issue #31526

@stamblerre stamblerre changed the title x/tools/internal/lsp: handle rangeFormatting on files that do not parse x/tools/internal/lsp: handle formatting on files that do not parse May 20, 2019

@stamblerre stamblerre changed the title x/tools/internal/lsp: handle formatting on files that do not parse x/tools/gopls: handle formatting on files that do not parse Jul 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.