@@ -3,6 +3,7 @@ module Reporting.Exit.Crawl
4 , Problem(..)
4 , Problem(..)
5 , Origin(..)
5 , Origin(..)
@@ -36,7 +37,7 @@ data Exit
38data Problem
39data Problem
39− = ModuleNotFound Origin Module.Raw [FilePath]
40+ = ModuleNotFound Origin Module.Raw SrcDirs
40 | ModuleAmbiguous Origin Module.Raw [FilePath] [Pkg.Package]
41 | ModuleAmbiguous Origin Module.Raw [FilePath] [Pkg.Package]
41 | BadHeader FilePath Time.UTCTime BS.ByteString Compiler.Error
42 | BadHeader FilePath Time.UTCTime BS.ByteString Compiler.Error
42 | ModuleNameReservedForKernel Origin Module.Raw
43 | ModuleNameReservedForKernel Origin Module.Raw
@@ -55,6 +56,11 @@ data Origin
55 | Module FilePath Module.Raw
56 | Module FilePath Module.Raw
59-- TO REPORT
65-- TO REPORT
@@ -113,8 +119,8 @@ toReport exit =
113problemToReport :: Problem -> Help.Report
119problemToReport :: Problem -> Help.Report
114problemToReport problem =
120problemToReport problem =
115 case problem of
121 case problem of
116− ModuleNotFound origin name dirs ->
122+ ModuleNotFound origin name srcDirs ->
117− notFoundToDoc origin name dirs
123+ notFoundToDoc origin name srcDirs
119 ModuleAmbiguous origin child paths pkgs ->
125 ModuleAmbiguous origin child paths pkgs ->
120 ambiguousToDoc origin child paths pkgs
126 ambiguousToDoc origin child paths pkgs
@@ -173,7 +179,7 @@ badTagToDoc path name tag hintName summary =
176−-- HELPERS
182+-- NAMELESS
179namelessToDoc :: FilePath -> Module.Raw -> Help.Report
185namelessToDoc :: FilePath -> Module.Raw -> Help.Report
@@ -194,31 +200,34 @@ namelessToDoc path name =
197−notFoundToDoc :: Origin -> Module.Raw -> [FilePath] -> Help.Report
207+notFoundToDoc :: Origin -> Module.Raw -> SrcDirs -> Help.Report
198−notFoundToDoc origin child dirs =
208+notFoundToDoc origin child srcDirs =
199 case origin of
209 case origin of
200 ElmJson ->
210 ElmJson ->
201 Help.report "MODULE NOT FOUND" (Just "elm.json")
211 Help.report "MODULE NOT FOUND" (Just "elm.json")
202 "Your elm.json says your project has the following module:"
212 "Your elm.json says your project has the following module:"
203 [ D.indent 4 $ D.red $ D.fromString $ Module.nameToString child
213 [ D.indent 4 $ D.red $ D.fromString $ Module.nameToString child
204 , D.reflow $
214 , D.reflow $
205− "When creating packages, all modules must live in the\
215+ "When creating packages, all modules must live in the src/ directory."
206− \ src/ directory, but I cannot find it there."
209 File path ->
218 File path ->
210 Help.report "UNKNOWN IMPORT" (Just path)
219 Help.report "UNKNOWN IMPORT" (Just path)
211 ("I cannot find a `" ++ Module.nameToString child ++ "` module to import.")
220 ("I cannot find a `" ++ Module.nameToString child ++ "` module to import.")
212− (notFoundDetails child dirs)
221+ (notFoundDetails child srcDirs)
214 Module path parent ->
223 Module path parent ->
215 Help.report "UNKNOWN IMPORT" (Just path)
224 Help.report "UNKNOWN IMPORT" (Just path)
216 ("The " ++ Module.nameToString parent ++ " module has a bad import:")
225 ("The " ++ Module.nameToString parent ++ " module has a bad import:")
217− (notFoundDetails child dirs)
226+ (notFoundDetails child srcDirs)
220−notFoundDetails :: Module.Raw -> [FilePath] -> [D.Doc]
229+notFoundDetails :: Module.Raw -> SrcDirs -> [D.Doc]
221−notFoundDetails child dirs =
230+notFoundDetails child srcDirs =
223 simulatedCode =
232 simulatedCode =
224 D.indent 4 $ D.red $ D.fromString $ "import " ++ Module.nameToString child
233 D.indent 4 $ D.red $ D.fromString $ "import " ++ Module.nameToString child
@@ -230,26 +239,37 @@ notFoundDetails child dirs =
230 "Do you want the one from the " ++ Pkg.toString pkg
239 "Do you want the one from the " ++ Pkg.toString pkg
231 ++ " package? If so, run this command to add that dependency to your elm.json file:"
240 ++ " package? If so, run this command to add that dependency to your elm.json file:"
232 , D.indent 4 $ D.green $ D.fromString $ "elm install " ++ Pkg.toString pkg
241 , D.indent 4 $ D.green $ D.fromString $ "elm install " ++ Pkg.toString pkg
233− , D.reflow $
244+ D.reflow $
234− "If you want a local file, make sure the directory that contains the `"
245+ "If you want a local file, make sure the `"
246+ ++ Module.nameToString child
247+ ++ "` module is in your src/ directory."
251+ "If you want a local file, make sure the `"
235− ++ Module.nameToString child
252+ ++ Module.nameToString child
236− ++ "` module is listed in your elm.json \"source-directories\" field."
253+ ++ "` module is in one of the \"source-directories\" listed in your elm.json file."
239 Nothing ->
256 Nothing ->
240 [ simulatedCode
257 [ simulatedCode
241 , "I cannot find that module! Is there a typo in the module name?"
258 , "I cannot find that module! Is there a typo in the module name?"
242 , D.reflow $
259 , D.reflow $
243− case dirs of
260+ case srcDirs of
262+ "When creating a package, all modules must live in the src/ directory."
245 "The \"source-directories\" field of your elm.json is empty, so I only\
265 "The \"source-directories\" field of your elm.json is empty, so I only\
246 \ searched in packages. Maybe you need to add a \"src\" directory there?"
266 \ searched in packages. Maybe you need to add a \"src\" directory there?"
248− [dir] ->
268+ App [dir] ->
249 "The \"source-directories\" field of your elm.json tells me to only look in the "
269 "The \"source-directories\" field of your elm.json tells me to only look in the "
250 ++ dir ++ " directory, but it is not there. Maybe it is in a package that is not installed yet?"
270 ++ dir ++ " directory, but it is not there. Maybe it is in a package that is not installed yet?"
252− dir:_:_ ->
272+ App (dir:_:_) ->
253 "The \"source-directories\" field of your elm.json tells me to look in directories like "
273 "The \"source-directories\" field of your elm.json tells me to look in directories like "
254 ++ dir ++ ", but it is not in any of them. Maybe it is in a package that is not installed yet?"
274 ++ dir ++ ", but it is not in any of them. Maybe it is in a package that is not installed yet?"