-
Notifications
You must be signed in to change notification settings - Fork 97
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Thank you for this change, this was so annoying! Could you undo all the auto formatting? It will lead to unnecessary merge conflicts for other contributions, and its best done by maintainers when the time is right. Thank you! |
Sorry for that, I've restored changes done by the formatter. |
Yes, I think encoding the screenshot as a test would be good enough. Thanks! |
I have a question about this test case,
which is marked as "known broken". Expected failure here means "user should not write code like that" or "currently we don't support this feature"? |
That test case is marked as known broken because it reproduces a known bug that needs to be fixed. Which your PR does |
Now we can extend |
The test which was marked as "known broken" previously can pass now, and I added a new test to demonstrate extending constructors. However, current implementation breaks the "extend multi line import with value", because spaces are dropped before removing the trailing comma, causing multi line collapsed. This can be fixed by removing the comma in the end of the import list but keeping spaces. |
let rest' = case parent of | ||
"" -> ", " <> rest | ||
_ -> case T.breakOn parent rest of | ||
(h, T.stripPrefix parent -> Just r) -> case T.uncons (T.dropWhile isSpace r) of | ||
Just (')', _) -> ")" <> h <> r | ||
Just ('(', xs) -> let imported = T.takeWhile (/= ')') xs in T.concat ["," ,imported , "), " , h , removeHeadingComma (T.tail (T.dropWhile (/= ')') r))] | ||
_ -> "), " <> h <> r | ||
_ -> "), " <> rest | ||
binding' = (if T.null parent then id else T.init) renderedBinding | ||
in removeTrailingComma $ T.concat [pre, "(", binding', rest'] |
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.
I find this code very hard to read. Could you try to golf it a bit to make it more readable? Some concrete suggestions:
- whitespace and layout
- both
rest'
andbinding'
perform branching on whetherparent
is null. Make this more apparent - introduce more names or add more comments, there's a lot of character matching that is hard to follow
- consider replacing some of the character matching with regexes if that makes things simpler.
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.
Thanks for your suggestions! I totally agree. It lacks of extensibility and is hard to read 😢
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.
@berberman are you planning to implement this suggestion?
Anything I can do to help move this forward? :) |
Sorry for the delay; I‘ve been pretty busy recently... |
I'll merge this as it is, please send a new PR for clean-ups. |
* Use exports map * Use exports map in suggestExtendImport * Update test * Support extend constructor * Revert format changes * Support extending constructors * Fix multi line
* Use exports map * Use exports map in suggestExtendImport * Update test * Support extend constructor * Revert format changes * Support extending constructors * Fix multi line
* Use exports map * Use exports map in suggestExtendImport * Update test * Support extend constructor * Revert format changes * Support extending constructors * Fix multi line
Perhaps we no longer need to parse the extended binding, completely depending on the diagnostic message, since we now have
ExportsMap
. Closes haskell/haskell-language-server#609: