-
-
Notifications
You must be signed in to change notification settings - Fork 390
Improve parsing of import suggestions extending multiple multiline imports (fixes #4175) #4177
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1973,15 +1973,18 @@ regexSingleMatch msg regex = case matchRegexUnifySpaces msg regex of | |||
_ -> Nothing | ||||
|
||||
-- | Process a list of (module_name, filename:src_span) values | ||||
-- | Eg. [(Data.Map, app/ModuleB.hs:2:1-18), (Data.HashMap.Strict, app/ModuleB.hs:3:1-29)] | ||||
-- | ||||
-- Eg. [(Data.Map, app/ModuleB.hs:2:1-18), (Data.HashMap.Strict, app/ModuleB.hs:3:1-29)] | ||||
regExImports :: T.Text -> Maybe [(T.Text, T.Text)] | ||||
regExImports msg | ||||
| Just mods' <- allMatchRegex msg "‘([^’]*)’" | ||||
, Just srcspans' <- allMatchRegex msg | ||||
-- This regex has to be able to deal both with single-line srcpans like "(/path/to/File.hs:2:1-18)" | ||||
-- as well as multi-line srcspans like "(/path/to/File.hs:(3,1)-(5,2))" | ||||
#if MIN_VERSION_ghc(9,7,0) | ||||
"\\(at ([^)]*)\\)" | ||||
"\\(at ([^:]+:[^ ]+)\\)" | ||||
#else | ||||
"\\(([^)]*)\\)" | ||||
"\\(([^:]+:[^ ]+)\\)" | ||||
Comment on lines
+1985
to
+1987
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is almost the same, do you think it is a good idea to remove the CPP and use a regex with an optional group like: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this doesn't work, because it introduces a new capturing group in the regex, which changes the number of matches and because of that it fails the check on this line: haskell-language-server/plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction.hs Line 1989 in 97aac54
I thought I could use non-capturing groups (by adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll wait for further suggestions if you have any and will merge it in the afternoon otherwise. |
||||
#endif | ||||
, mods <- [mod | [_,mod] <- mods'] | ||||
, srcspans <- [srcspan | [_,srcspan] <- srcspans'] | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original regex didn't correctly deal with import lists spanning multiple lines.
Instead of extracting the whole of
it would only extract
which led to errors in src span parser described in #4175