@@ -46,9 +46,9 @@ import System.FilePath (joinPath,
46
46
takeDirectory ,
47
47
(<.>) , (</>) )
48
48
49
- -- | CodeActions for going to definitions.
49
+ -- | Handler for going to definitions.
50
50
--
51
- -- Provides a CodeAction for going to the definition in a cabal file,
51
+ -- Provides a handler for going to the definition in a cabal file,
52
52
-- gathering all possible definitions by calling subfunctions.
53
53
54
54
-- TODO: Resolve more cases for go-to definition.
@@ -93,13 +93,10 @@ gotoCommonSectionDefinition
93
93
-> Syntax. Position -- ^ Cursor position
94
94
-> [Syntax. Field Syntax. Position ] -- ^ Trimmed cabal AST on a cursor
95
95
-> Maybe Definition
96
- gotoCommonSectionDefinition uri commonSections cursor fieldsOfInterest =
97
- case CabalFields. findTextWord cursor fieldsOfInterest of
98
- Nothing -> Nothing
99
- Just cursorText -> do
100
- case find (isSectionArgName cursorText) commonSections of
101
- Just commonSection -> Just $ Definition $ InL $ Location uri $ CabalFields. getFieldLSPRange commonSection
102
- Nothing -> Nothing
96
+ gotoCommonSectionDefinition uri commonSections cursor fieldsOfInterest = do
97
+ cursorText <- CabalFields. findTextWord cursor fieldsOfInterest
98
+ commonSection <- find (isSectionArgName cursorText) commonSections
99
+ Just $ Definition $ InL $ Location uri $ CabalFields. getFieldLSPRange commonSection
103
100
where
104
101
isSectionArgName name (Syntax. Section _ sectionArgName _) = name == CabalFields. onelineSectionArgs sectionArgName
105
102
isSectionArgName _ _ = False
@@ -192,9 +189,13 @@ lookupBuildTargetPackageDescription (PackageDescription {..}) (Just buildTargetN
192
189
then Just benchmarkBuildInfo
193
190
else Nothing
194
191
195
- -- | Converts a name of a module to a FilePath
196
- -- Warning: Makes a lot of assumptions and generally
197
- -- not advised to use.
192
+ -- | Converts a name of a module to a FilePath.
193
+ -- Is needed to guess the relative path to a file
194
+ -- using the name of the module.
195
+ -- We assume, that correct module naming is guaranteed.
196
+ --
197
+ -- Warning: Generally not advised to use, if there are
198
+ -- better ways to get the path.
198
199
--
199
200
-- Examples: (output is system dependent)
200
201
-- >>> toHaskellFile "My.Module.Lib"
0 commit comments