@@ -25,7 +25,9 @@ import Distribution.PackageDescription (CondTree (..),
25
25
GenericPackageDescription (.. ),
26
26
Library (libBuildInfo ),
27
27
hsSourceDirs )
28
+ import Distribution.Types.Benchmark (Benchmark (.. ))
28
29
import Distribution.Types.Executable (Executable (.. ))
30
+ import Distribution.Types.TestSuite (TestSuite (.. ))
29
31
import Distribution.Types.UnqualComponentName
30
32
import Distribution.Utils.Path (getSymbolicPath )
31
33
import Ide.Plugin.Cabal.FilepathCompletions
@@ -434,9 +436,9 @@ exposedModuleExtraction gpd =
434
436
where
435
437
libM = condLibrary gpd
436
438
437
- otherModulesExtraction :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
438
- otherModulesExtraction Nothing _ = []
439
- otherModulesExtraction (Just name) gpd
439
+ otherModulesExtractionExecutable :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
440
+ otherModulesExtractionExecutable Nothing _ = []
441
+ otherModulesExtractionExecutable (Just name) gpd
440
442
| exeName executable == (mkUnqualComponentName $ T. unpack name) = map getSymbolicPath $ hsSourceDirs $ buildInfo executable
441
443
| otherwise = []
442
444
where
@@ -450,6 +452,38 @@ otherModulesExtraction (Just name) gpd
450
452
)
451
453
execsM
452
454
455
+ otherModulesExtractionTestSuite :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
456
+ otherModulesExtractionTestSuite Nothing _ = []
457
+ otherModulesExtractionTestSuite (Just name) gpd
458
+ | testName testSuite == (mkUnqualComponentName $ T. unpack name) = map getSymbolicPath $ hsSourceDirs $ testBuildInfo testSuite
459
+ | otherwise = []
460
+ where
461
+ testSuite = condTreeData $ snd $ fromJust res
462
+ testSuitesM = condTestSuites gpd
463
+ res =
464
+ List. find
465
+ (\ (_, cTree) -> do
466
+ let testsName = testName $ condTreeData cTree
467
+ testsName == (mkUnqualComponentName $ T. unpack name)
468
+ )
469
+ testSuitesM
470
+
471
+ otherModulesExtractionBenchmark :: Maybe T. Text -> GenericPackageDescription -> [FilePath ]
472
+ otherModulesExtractionBenchmark Nothing _ = []
473
+ otherModulesExtractionBenchmark (Just name) gpd
474
+ | benchmarkName bMark == (mkUnqualComponentName $ T. unpack name) = map getSymbolicPath $ hsSourceDirs $ benchmarkBuildInfo bMark
475
+ | otherwise = []
476
+ where
477
+ bMark = condTreeData $ snd $ fromJust res
478
+ bMarksM = condBenchmarks gpd
479
+ res =
480
+ List. find
481
+ (\ (_, cTree) -> do
482
+ let bMarkName = benchmarkName $ condTreeData cTree
483
+ bMarkName == (mkUnqualComponentName $ T. unpack name)
484
+ )
485
+ bMarksM
486
+
453
487
{- | Completer to be used when a directory can be completed for the field,
454
488
takes the file path of the directory to start from.
455
489
Only completes directories.
@@ -522,39 +556,43 @@ stanzaKeywordMap =
522
556
Map. fromList
523
557
[
524
558
( " library"
525
- , \ n -> Map. fromList $
559
+ , \ _ -> Map. fromList $
526
560
[ (" exposed-modules:" , modulesCompleter exposedModuleExtraction) -- identifier list
527
561
, (" virtual-modules:" , noopCompleter)
528
562
, (" exposed:" , constantCompleter [" True" , " False" ])
529
563
, (" visibility:" , constantCompleter [" private" , " public" ])
530
564
, (" reexported-modules:" , noopCompleter) -- export list, i.e. "orig-okg:Name as NewName"
531
565
, (" signatures:" , noopCompleter) -- list of signatures
566
+ , (" other-modules:" , modulesCompleter exposedModuleExtraction)
532
567
]
533
- ++ libExecTestBenchCommons n
568
+ ++ libExecTestBenchCommons
534
569
)
535
570
,
536
571
( " executable"
537
572
, \ n -> Map. fromList $
538
573
[ (" main-is:" , filePathCompleter)
539
574
, (" scope:" , constantCompleter [" public" , " private" ])
575
+ , (" other-modules:" , modulesCompleter (otherModulesExtractionExecutable n))
540
576
]
541
- ++ libExecTestBenchCommons n
577
+ ++ libExecTestBenchCommons
542
578
)
543
579
,
544
580
( " test-suite"
545
581
, \ n -> Map. fromList $
546
582
[ (" type:" , constantCompleter [" exitcode-stdio-1.0" , " detailed-0.9" ])
547
583
, (" main-is:" , filePathCompleter)
584
+ , (" other-modules:" , modulesCompleter (otherModulesExtractionTestSuite n))
548
585
]
549
- ++ libExecTestBenchCommons n
586
+ ++ libExecTestBenchCommons
550
587
)
551
588
,
552
589
( " benchmark"
553
590
, \ n -> Map. fromList $
554
591
[ (" type:" , noopCompleter)
555
592
, (" main-is:" , filePathCompleter)
593
+ , (" other-modules:" , modulesCompleter (otherModulesExtractionBenchmark n))
556
594
]
557
- ++ libExecTestBenchCommons n
595
+ ++ libExecTestBenchCommons
558
596
)
559
597
,
560
598
( " foreign-library"
@@ -604,9 +642,8 @@ stanzaKeywordMap =
604
642
)
605
643
]
606
644
where
607
- libExecTestBenchCommons n =
645
+ libExecTestBenchCommons =
608
646
[ (" build-depends:" , noopCompleter)
609
- , (" other-modules:" , modulesCompleter (otherModulesExtraction n))
610
647
, (" hs-source-dirs:" , directoryCompleter)
611
648
, (" default-extensions:" , noopCompleter)
612
649
, (" other-extensions:" , noopCompleter)
0 commit comments