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

Exception in plugin PluginId "ghcide-code-actions-imports-exports" while processing SMethod_TextDocumentCodeAction #4175

Closed
soulomoon opened this issue Apr 14, 2024 · 4 comments
Labels
component: imports plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@soulomoon
Copy link
Collaborator

soulomoon commented Apr 14, 2024

I open hls-test-utils/src/Test/Hls.hs, and try to use DataColumn. It throw error condition:

Error condition, please check your setup and/or the [issue tracker](https:/haskell/haskell-language-server/issues): 
ghcide-code-actions-imports-exports: Internal Error: Exception in plugin PluginId "ghcide-code-actions-imports-exports" while processing SMethod_TextDocumentCodeAction: bug in srcspan parser
CallStack (from HasCallStack):
  error, called at plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs:958:22 in hskll-lngg-srvr-2.7.0.0-dbac2051:Development.IDE.Plugin.CodeAction

the logs:

024-04-14T11:54:36.631150Z | Error | ghcide-code-actions-imports-exports: Internal Error: Exception in plugin PluginId "ghcide-code-actions-imports-exports" while processing SMethod_TextDocumentCodeAction: bug in srcspan parser
CallStack (from HasCallStack):
  error, called at plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs:957:22 in hskll-lngg-srvr-2.7.0.0-227ab907:Development.IDE.Plugin.CodeAction
2024-04-14T11:54:37.526240Z | Error | ghcide-code-actions-imports-exports: Internal Error: Exception in plugin PluginId "ghcide-code-actions-imports-exports" while processing SMethod_TextDocumentCodeAction: bug in srcspan parser
CallStack (from HasCallStack):
  error, called at plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs:957:22 in hskll-lngg-srvr-2.7.0.0-227ab907:Development.IDE.Plugin.CodeAction
2024-04-14T11:54:39.420600Z | Error | ghcide-code-actions-imports-exports: Internal Error: Exception in plugin PluginId "ghcide-code-actions-imports-exports" while processing SMethod_TextDocumentCodeAction: bug in srcspan parser
CallStack (from HasCallStack):

It should suggest to import LoggingColumn(DataColumn)

@soulomoon soulomoon added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Apr 14, 2024
@soulomoon soulomoon reopened this Apr 14, 2024
@soulomoon
Copy link
Collaborator Author

soulomoon commented Apr 14, 2024

It's odd since we do not have the file plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs

@jhrcek
Copy link
Collaborator

jhrcek commented Apr 14, 2024

I can't reproduce this. What GHC version are you working with?

It's odd since we do not have the file plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs

Isn't it this file / error?

@soulomoon
Copy link
Collaborator Author

soulomoon commented Apr 14, 2024

I can't reproduce this. What GHC version are you working with?

ghc 9.8.2, right, that is the file

@jhrcek
Copy link
Collaborator

jhrcek commented Apr 14, 2024

Ok, managed to reproduce the error.

Full error from which suggestions are being extracted:

Data constructor not in scope:
  DataColumn :: Ide.Logger.LoggingColumn
Suggested fix:
  Add ‘DataColumn’ to one of these import lists:
    ‘Development.IDE’ (at /home/jhrcek/Devel/github.com/haskell/haskell-language-server/hls-test-utils/src/Test/Hls.hs:83:1-62)
    ‘Ide.Logger’ (at /home/jhrcek/Devel/github.com/haskell/haskell-language-server/hls-test-utils/src/Test/Hls.hs:(94,1)-(102,59))

The regex extracts the following 2 items which go to the readSrcSpan parser:

srcspan="/home/jhrcek/Devel/github.com/haskell/haskell-language-server/hls-test-utils/src/Test/Hls.hs:83:1-62"
srcspan="/home/jhrcek/Devel/github.com/haskell/haskell-language-server/hls-test-utils/src/Test/Hls.hs:(94,1"

The issue seems to be caused by my fix which made the regex stricter, but now is unable to deal with multiline src spans.
I'll take a stab at fixing this over the next few days.

EDIT: actually this is a different code path unrelated to myfix, but I'll look at it anyway..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: imports plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

2 participants