@@ -79,6 +79,12 @@ charEdit p =
79
79
.+ # rangeLength .== Nothing
80
80
.+ # text .== " a"
81
81
82
+ headerEdit :: TextDocumentContentChangeEvent
83
+ headerEdit =
84
+ TextDocumentContentChangeEvent $ InL $ # range .== Range (Position 0 0 ) (Position 0 0 )
85
+ .+ # rangeLength .== Nothing
86
+ .+ # text .== " -- header comment \n "
87
+
82
88
data DocumentPositions = DocumentPositions {
83
89
-- | A position that can be used to generate non null goto-def and completion responses
84
90
identifierP :: Maybe Position ,
@@ -112,6 +118,16 @@ experiments =
112
118
waitForProgressDone
113
119
return True ,
114
120
---------------------------------------------------------------------------------------
121
+ bench " edit-header" $ \ docs -> do
122
+ forM_ docs $ \ DocumentPositions {.. } -> do
123
+ changeDoc doc [headerEdit]
124
+ -- wait for a fresh build start
125
+ waitForProgressStart
126
+ -- wait for the build to be finished
127
+ output " edit: waitForProgressDone"
128
+ waitForProgressDone
129
+ return True ,
130
+ ---------------------------------------------------------------------------------------
115
131
bench " hover after edit" $ \ docs -> do
116
132
forM_ docs $ \ DocumentPositions {.. } ->
117
133
changeDoc doc [charEdit stringLiteralP]
@@ -276,23 +292,26 @@ configP =
276
292
<*> optional (option auto (long " samples" <> metavar " NAT" <> help " override sampling count" ))
277
293
<*> strOption (long " ghcide" <> metavar " PATH" <> help " path to ghcide" <> value " ghcide" )
278
294
<*> option auto (long " timeout" <> value 60 <> help " timeout for waiting for a ghcide response" )
279
- <*> ( Example " name"
280
- <$> (Right <$> packageP)
295
+ <*> ( Example
296
+ <$> exampleName
297
+ <*> (ExampleHackage <$> packageP)
281
298
<*> (some moduleOption <|> pure [" src/Distribution/Simple.hs" ])
282
299
<*> pure []
283
- <|>
284
- Example " name "
285
- <$> ( Left <$> pathP)
286
- <*> some moduleOption
287
- <*> pure [] )
300
+ <|> Example
301
+ <$> exampleName
302
+ <*> pathOrScriptP
303
+ <*> some moduleOption
304
+ <*> pure [] )
288
305
<*> switch (long " lsp-config" <> help " Read an LSP config payload from standard input" )
289
306
where
290
307
moduleOption = strOption (long " example-module" <> metavar " PATH" )
308
+ exampleName = strOption (long " example-name" <> metavar " NAME" )
291
309
292
310
packageP = ExamplePackage
293
311
<$> strOption (long " example-package-name" <> value " Cabal" )
294
312
<*> option versionP (long " example-package-version" <> value (makeVersion [3 ,6 ,0 ,0 ]))
295
- pathP = strOption (long " example-path" )
313
+ pathOrScriptP = ExamplePath <$> strOption (long " example-path" )
314
+ <|> ExampleScript <$> strOption (long " example-script" ) <*> many (strOption (long " example-script-args" <> help " arguments for the example generation script" ))
296
315
297
316
versionP :: ReadM Version
298
317
versionP = maybeReader $ extract . readP_to_S parseVersion
@@ -581,13 +600,25 @@ setup :: HasConfig => IO SetupResult
581
600
setup = do
582
601
-- when alreadyExists $ removeDirectoryRecursive examplesPath
583
602
benchDir <- case exampleDetails(example ? config) of
584
- Left examplePath -> do
603
+ ExamplePath examplePath -> do
585
604
let hieYamlPath = examplePath </> " hie.yaml"
586
605
alreadyExists <- doesFileExist hieYamlPath
587
606
unless alreadyExists $
588
607
cmd_ (Cwd examplePath) (FileStdout hieYamlPath) (" gen-hie" :: String )
589
608
return examplePath
590
- Right ExamplePackage {.. } -> do
609
+ ExampleScript examplePath' scriptArgs -> do
610
+ let exampleDir = examplesPath </> exampleName (example ? config)
611
+ alreadySetup <- doesDirectoryExist exampleDir
612
+ unless alreadySetup $ do
613
+ createDirectoryIfMissing True exampleDir
614
+ examplePath <- makeAbsolute examplePath'
615
+ cmd_ (Cwd exampleDir) examplePath scriptArgs
616
+ let hieYamlPath = exampleDir </> " hie.yaml"
617
+ alreadyExists <- doesFileExist hieYamlPath
618
+ unless alreadyExists $
619
+ cmd_ (Cwd exampleDir) (FileStdout hieYamlPath) (" gen-hie" :: String )
620
+ return exampleDir
621
+ ExampleHackage ExamplePackage {.. } -> do
591
622
let path = examplesPath </> package
592
623
package = packageName <> " -" <> showVersion packageVersion
593
624
hieYamlPath = path </> " hie.yaml"
@@ -633,8 +664,9 @@ setup = do
633
664
whenJust (shakeProfiling ? config) $ createDirectoryIfMissing True
634
665
635
666
let cleanUp = case exampleDetails(example ? config) of
636
- Right _ -> removeDirectoryRecursive examplesPath
637
- Left _ -> return ()
667
+ ExampleHackage _ -> removeDirectoryRecursive examplesPath
668
+ ExampleScript _ _ -> removeDirectoryRecursive examplesPath
669
+ ExamplePath _ -> return ()
638
670
639
671
runBenchmarks = runBenchmarksFun benchDir
640
672
0 commit comments