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/cmd/gopls: can't add new file to existing package #32341
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Comments
Note that the error in b.go will go away eventually if you make an edit to a.go. |
stamblerre
added
the
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
label
Jun 3, 2019
I am able to reproduce this in VSCode. Thanks for reporting. |
muirdm
added a commit
to muirdm/tools
that referenced
this issue
Jun 9, 2019
Previously when you added a new file to an existing package, the new file would get stuck with the "no package for file" error until you saved the file and then made changed a different file in the package. There were two changes required to make this work: First, we need to invalidate the package cache when a new file is added to a package so that the package will actually re-parse and re-type check. We now notice if file names changed when updating a package's metadata and invalidate the package cache accordingly. Second, when dealing with overlay (unsaved) files, we need to map the *goFile to the package even if we fail to parse the file (e.g. the new file fails to parse when it is empty). If we don't map it to the package, the package won't get refreshed as the file is changed. Fixes golang/go#32341
muirdm
added a commit
to muirdm/tools
that referenced
this issue
Jun 9, 2019
Previously when you added a new file to an existing package, the new file would get stuck with the "no package for file" error until you saved the file and then made changed a different file in the package. There were two changes required to fix the errors: First, we need to invalidate the package cache when a new file is added to a package so that the package will actually re-parse and re-type check. We now notice if file names changed when updating a package's metadata and invalidate the package cache accordingly. Second, when dealing with overlay (unsaved) files, we need to map the *goFile to the package even if we fail to parse the file (e.g. the new file fails to parse when it is empty). If we don't map it to the package, the package won't get refreshed as the file is changed. Fixes golang/go#32341
Change https://golang.org/cl/181417 mentions this issue: |
muirdm
added a commit
to muirdm/tools
that referenced
this issue
Jun 11, 2019
Previously when you added a new file to an existing package, the new file would get stuck with the "no package for file" error until you saved the file and then made changed a different file in the package. There were two changes required to fix the errors: First, we need to invalidate the package cache when a new file is added to a package so that the package will actually re-parse and re-type check. We now notice if file names changed when updating a package's metadata and invalidate the package cache accordingly. Second, when dealing with overlay (unsaved) files, we need to map the *goFile to the package even if we fail to parse the file (e.g. the new file fails to parse when it is empty). If we don't map it to the package, the package won't get refreshed as the file is changed. Fixes golang/go#32341
muirdm
added a commit
to muirdm/tools
that referenced
this issue
Jun 11, 2019
Previously when you added a new file to an existing package, the new file would get stuck with the "no package for file" error until you saved the file and then made changed a different file in the package. There were two changes required to fix the errors: First, we need to invalidate the package cache when a new file is added to a package so that the package will actually re-parse and re-type check. We now notice if file names changed when updating a package's metadata and invalidate the package cache accordingly. Second, when dealing with overlay (unsaved) files, we need to map the *goFile to the package even if we fail to parse the file (e.g. the new file fails to parse when it is empty). If we don't map it to the package, the package won't get refreshed as the file is changed. Fixes golang/go#32341
muirdm
added a commit
to muirdm/tools
that referenced
this issue
Jun 11, 2019
Previously when you added a new file to an existing package, the new file would get stuck with the "no package for file" error until you saved the file and then made changed a different file in the package. There were two changes required to fix the errors: First, we need to invalidate the package cache when a new file is added to a package so that the package will actually re-parse and re-type check. We now notice if file names changed when updating a package's metadata and invalidate the package cache accordingly. Second, when dealing with overlay (unsaved) files, we need to map the *goFile to the package even if we fail to parse the file (e.g. the new file fails to parse when it is empty). If we don't map it to the package, the package won't get refreshed as the file is changed. Fixes golang/go#32341
muirdm
added a commit
to muirdm/tools
that referenced
this issue
Jun 11, 2019
Previously when you added a new file to an existing package, the new file would get stuck with the "no package for file" error until you saved the file and then made changed a different file in the package. There were two changes required to fix the errors: First, we need to invalidate the package cache when a new file is added to a package so that the package will actually re-parse and re-type check. We now notice if file names changed when updating a package's metadata and invalidate the package cache accordingly. Second, when dealing with overlay (unsaved) files, we need to map the *goFile to the package even if we fail to parse the file (e.g. the new file fails to parse when it is empty). If we don't map it to the package, the package won't get refreshed as the file is changed. Fixes golang/go#32341
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
On master (ce1a380) whenever I add a new file to an existing package I get a diagnostic at the first character of the new file saying " is not part of a package". As you might expect, LSP commands don't work inside the new file.
To reproduce, I just created a new file in an existing package with only the package declaration.
For example, if you have foo/a.go:
Create foo/b.go:
and you should see the error in b.go.
The text was updated successfully, but these errors were encountered: