@@ -83,6 +83,12 @@ headerEdit =
8383 , _text = " -- header comment \n "
8484 }
8585
86+ typingBurstEditCount :: Int
87+ typingBurstEditCount = 5
88+
89+ typingBurstDelay :: Seconds
90+ typingBurstDelay = 0.25
91+
8692data DocumentPositions = DocumentPositions {
8793 -- | A position that can be used to generate non null goto-def and completion responses
8894 identifierP :: Maybe Position ,
@@ -100,6 +106,14 @@ allWithIdentifierPos f docs = case applicableDocs of
100106 where
101107 applicableDocs = filter (isJust . identifierP) docs
102108
109+ applyTypingBurst :: [DocumentPositions ] -> Session ()
110+ applyTypingBurst docs =
111+ forM_ [1 .. typingBurstEditCount] $ \ n -> do
112+ forM_ docs $ \ DocumentPositions {.. } ->
113+ changeDoc doc [charEdit stringLiteralP]
114+ when (n < typingBurstEditCount) $
115+ liftIO $ sleep typingBurstDelay
116+
103117experiments :: HasConfig => [Bench ]
104118experiments =
105119 [
@@ -115,6 +129,15 @@ experiments =
115129 Nothing -> return False
116130 return $ and r,
117131 ---------------------------------------------------------------------------------------
132+ bench " semanticTokens after typing burst" $ \ docs -> do
133+ applyTypingBurst docs
134+ r <- forM docs $ \ DocumentPositions {.. } -> do
135+ tks <- getSemanticTokens doc
136+ case tks ^? LSP. _L of
137+ Just _ -> return True
138+ Nothing -> return False
139+ return $ and r,
140+ ---------------------------------------------------------------------------------------
118141 bench " hover" $ allWithIdentifierPos $ \ DocumentPositions {.. } ->
119142 isJust <$> getHover doc (fromJust identifierP),
120143 ---------------------------------------------------------------------------------------
@@ -124,6 +147,11 @@ experiments =
124147 flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
125148 isJust <$> getHover doc (fromJust identifierP),
126149 ---------------------------------------------------------------------------------------
150+ bench " hover after typing burst" $ \ docs -> do
151+ applyTypingBurst docs
152+ flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
153+ isJust <$> getHover doc (fromJust identifierP),
154+ ---------------------------------------------------------------------------------------
127155 bench
128156 " hover after cradle edit"
129157 (\ docs -> do
@@ -158,10 +186,15 @@ experiments =
158186 hasDefinitions <$> getDefinitions doc (fromJust identifierP),
159187 ---------------------------------------------------------------------------------------
160188 bench " getDefinition after edit" $ \ docs -> do
161- forM_ docs $ \ DocumentPositions {.. } ->
162- changeDoc doc [charEdit stringLiteralP]
163- flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
164- hasDefinitions <$> getDefinitions doc (fromJust identifierP),
189+ forM_ docs $ \ DocumentPositions {.. } ->
190+ changeDoc doc [charEdit stringLiteralP]
191+ flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
192+ hasDefinitions <$> getDefinitions doc (fromJust identifierP),
193+ ---------------------------------------------------------------------------------------
194+ bench " getDefinition after typing burst" $ \ docs -> do
195+ applyTypingBurst docs
196+ flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
197+ hasDefinitions <$> getDefinitions doc (fromJust identifierP),
165198 ---------------------------------------------------------------------------------------
166199 bench " documentSymbols" $ allM $ \ DocumentPositions {.. } -> do
167200 fmap (either (not . null ) (not . null )) . getDocumentSymbols $ doc,
@@ -172,6 +205,11 @@ experiments =
172205 flip allM docs $ \ DocumentPositions {.. } ->
173206 either (not . null ) (not . null ) <$> getDocumentSymbols doc,
174207 ---------------------------------------------------------------------------------------
208+ bench " documentSymbols after typing burst" $ \ docs -> do
209+ applyTypingBurst docs
210+ flip allM docs $ \ DocumentPositions {.. } ->
211+ either (not . null ) (not . null ) <$> getDocumentSymbols doc,
212+ ---------------------------------------------------------------------------------------
175213 bench " completions" $ \ docs -> do
176214 flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
177215 not . null <$> getCompletions doc (fromJust identifierP),
@@ -182,6 +220,11 @@ experiments =
182220 flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
183221 not . null <$> getCompletions doc (fromJust identifierP),
184222 ---------------------------------------------------------------------------------------
223+ bench " completions after typing burst" $ \ docs -> do
224+ applyTypingBurst docs
225+ flip allWithIdentifierPos docs $ \ DocumentPositions {.. } ->
226+ not . null <$> getCompletions doc (fromJust identifierP),
227+ ---------------------------------------------------------------------------------------
185228 bench
186229 " code actions"
187230 ( \ docs -> do
@@ -206,6 +249,17 @@ experiments =
206249 getCodeActions doc (Range p p))
207250 ),
208251 ---------------------------------------------------------------------------------------
252+ bench
253+ " code actions after typing burst"
254+ ( \ docs -> do
255+ unless (any (isJust . identifierP) docs) $
256+ error " None of the example modules is suitable for this experiment"
257+ applyTypingBurst docs
258+ not . null . catMaybes <$> forM docs (\ DocumentPositions {.. } -> do
259+ forM identifierP $ \ p ->
260+ getCodeActions doc (Range p p))
261+ ),
262+ ---------------------------------------------------------------------------------------
209263 bench
210264 " code actions after cradle edit"
211265 ( \ docs -> do
@@ -383,7 +437,7 @@ configP =
383437
384438 packageP = ExamplePackage
385439 <$> strOption (long " example-package-name" <> value " Cabal" )
386- <*> option versionP (long " example-package-version" <> value (makeVersion [3 ,6 , 0 ,0 ]))
440+ <*> option versionP (long " example-package-version" <> value (makeVersion [3 ,16 , 1 ,0 ]))
387441 pathOrScriptP = ExamplePath <$> strOption (long " example-path" )
388442 <|> ExampleScript <$> strOption (long " example-script" ) <*> many (strOption (long " example-script-args" <> help " arguments for the example generation script" ))
389443
0 commit comments