Add Goto Definition for cabal common sections#4375
Conversation
|
@VenInf I think this PR is relevant to you as well and might be implementing some util functions you could benefit from as well. Could you review this PR? |
fendor
left a comment
There was a problem hiding this comment.
Thanks for the PR!
This looks very nice, just a couple of tests missing, then this is good to merge :)
| case uriToFilePath' uri of | ||
| Nothing -> | ||
| pure $ InR $ InR Null | ||
| Just filePath -> do |
There was a problem hiding this comment.
Prefer getNormalizedFilePathE which takes care of the validation.
| case uriToFilePath' uri of | |
| Nothing -> | |
| pure $ InR $ InR Null | |
| Just filePath -> do | |
| nfp <- getNormalizedFilePathE uri |
Then use fromNormalizedFilePath if you need the underlying FilePath.
| @@ -1,12 +1,16 @@ | |||
| module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs) where | |||
| {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} | |||
| module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, findTextWord, findFieldLine, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs, getFieldEndPosition, getSectionArgEndPosition, getNameEndPosition, getFieldLineEndPosition, getFieldLSPRange) where | |||
There was a problem hiding this comment.
I am amazed stylish-haskell accepts this.
Would you mind introducing a couple of new lines to make this easier to read? E.g.
| module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, findTextWord, findFieldLine, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs, getFieldEndPosition, getSectionArgEndPosition, getNameEndPosition, getFieldLineEndPosition, getFieldLSPRange) where | |
| module Ide.Plugin.Cabal.Completion.CabalFields | |
| ( findStanzaForColumn, | |
| findFieldSection, | |
| findTextWord, | |
| ... | |
| ) where |
or something like that?
| @@ -1,12 +1,16 @@ | |||
| module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs) where | |||
| {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} | |||
There was a problem hiding this comment.
| {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} |
Looks unused?
| import qualified Distribution.Fields as Syntax | ||
| import qualified Distribution.Parsec.Position as Syntax | ||
| import Ide.Plugin.Cabal.Completion.Types | ||
| import qualified Language.LSP.Protocol.Types as LSPTypes |
There was a problem hiding this comment.
Nitpick:
| import qualified Language.LSP.Protocol.Types as LSPTypes | |
| import qualified Language.LSP.Protocol.Types as LSP |
Other parts of the codebase use this qualified import. Perhaps we should have some kind of style guide? Hard to tell.
| -- that are not a space or column. | ||
|
|
||
| -- This function currently only considers words inside of a @FieldLine@. |
There was a problem hiding this comment.
| -- that are not a space or column. | |
| -- This function currently only considers words inside of a @FieldLine@. | |
| -- that are not a space or column. | |
| -- | |
| -- This function currently only considers words inside of a @FieldLine@. |
Otherwise, the haddock comment will not be attached to the function :)
|
Thank you for your work! The only comment I might have, is that I thought about mimicking |
VeryMilkyJoe
left a comment
There was a problem hiding this comment.
Very nice feature and the code looks great, thanks!
I think once we get some tests, we're ready to merge 🥳
62972ef to
8f164e2
Compare
8f164e2 to
c2d980c
Compare
e35a426 to
d0d0f94
Compare
fendor
left a comment
There was a problem hiding this comment.
LGTM, awesome, thank you very much!
* Add goto-definitions for cabal common sections * Add default direct cradle hie.yaml file to testdata * incorporate changes requested in haskell#4375 * add tests for cabal goto-definition
This PR is the start of a go to definition code action for cabal files.