@@ -79,6 +79,12 @@ charEdit p =
7979 .+ # rangeLength .== Nothing
8080 .+ # text .== " a"
8181
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+
8288data DocumentPositions = DocumentPositions {
8389 -- | A position that can be used to generate non null goto-def and completion responses
8490 identifierP :: Maybe Position ,
@@ -112,6 +118,16 @@ experiments =
112118 waitForProgressDone
113119 return True ,
114120 ---------------------------------------------------------------------------------------
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+ ---------------------------------------------------------------------------------------
115131 bench " hover after edit" $ \ docs -> do
116132 forM_ docs $ \ DocumentPositions {.. } ->
117133 changeDoc doc [charEdit stringLiteralP]
@@ -276,23 +292,26 @@ configP =
276292 <*> optional (option auto (long " samples" <> metavar " NAT" <> help " override sampling count" ))
277293 <*> strOption (long " ghcide" <> metavar " PATH" <> help " path to ghcide" <> value " ghcide" )
278294 <*> 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)
281298 <*> (some moduleOption <|> pure [" src/Distribution/Simple.hs" ])
282299 <*> pure []
283- <|>
284- Example " name "
285- <$> ( Left <$> pathP)
286- <*> some moduleOption
287- <*> pure [] )
300+ <|> Example
301+ <$> exampleName
302+ <*> pathOrScriptP
303+ <*> some moduleOption
304+ <*> pure [] )
288305 <*> switch (long " lsp-config" <> help " Read an LSP config payload from standard input" )
289306 where
290307 moduleOption = strOption (long " example-module" <> metavar " PATH" )
308+ exampleName = strOption (long " example-name" <> metavar " NAME" )
291309
292310 packageP = ExamplePackage
293311 <$> strOption (long " example-package-name" <> value " Cabal" )
294312 <*> 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" ))
296315
297316versionP :: ReadM Version
298317versionP = maybeReader $ extract . readP_to_S parseVersion
@@ -581,13 +600,25 @@ setup :: HasConfig => IO SetupResult
581600setup = do
582601-- when alreadyExists $ removeDirectoryRecursive examplesPath
583602 benchDir <- case exampleDetails(example ? config) of
584- Left examplePath -> do
603+ ExamplePath examplePath -> do
585604 let hieYamlPath = examplePath </> " hie.yaml"
586605 alreadyExists <- doesFileExist hieYamlPath
587606 unless alreadyExists $
588607 cmd_ (Cwd examplePath) (FileStdout hieYamlPath) (" gen-hie" :: String )
589608 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
591622 let path = examplesPath </> package
592623 package = packageName <> " -" <> showVersion packageVersion
593624 hieYamlPath = path </> " hie.yaml"
@@ -633,8 +664,9 @@ setup = do
633664 whenJust (shakeProfiling ? config) $ createDirectoryIfMissing True
634665
635666 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 ()
638670
639671 runBenchmarks = runBenchmarksFun benchDir
640672
0 commit comments