Skip to content

Commit 7518a3a

Browse files
michaelpjpepeiborrajneira
authored
Upgrade to new version of lsp libraries (#2494)
* Update to latest version of lsp libraries * Compute completions on kick This is not only for faster completions. It's also needed to have semi-fresh completions after editing. This is specially important for the first completion request of a file - without this change there are no completions available at all * Emit LSP custom messages on kick start/finish useful to synchonize on these events in tests * Fix completions tests after haskell/lsp#376 * Restore cabal update with comments * Use new lsp in stack 9.0.1 Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: jneira <[email protected]>
1 parent 2fa5994 commit 7518a3a

File tree

63 files changed

+332
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+332
-264
lines changed

.github/workflows/bench.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
119119
${{ env.cache-name }}-${{ runner.os }}-
120120
121+
# To ensure we get the lastest hackage index and not relying on haskell action logic
122+
- run: cabal update
123+
121124
# max-backjumps is increased as a temporary solution
122125
# for dependency resolution failure
123126
- run: cabal configure --enable-benchmarks --max-backjumps 12000

.github/workflows/caching.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ jobs:
182182
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
183183
${{ env.cache-name }}-${{ runner.os }}-
184184
185+
# To ensure we get the lastest hackage index and not relying on haskell action logic
186+
- if: steps.compiled-deps.outputs.cache-hit != 'true'
187+
run: cabal update
188+
185189
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
186190
name: Download sources for bench
187191
# Downloaded separately, to match the tested work/PR workflow guarantees

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ jobs:
179179
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
180180
${{ env.cache-name }}-${{ runner.os }}-
181181
182+
# To ensure we get the lastest hackage index and not relying on haskell action logic
183+
- if: steps.compiled-deps.outputs.cache-hit != 'true'
184+
run: cabal update
185+
182186
# repeating builds to workaround segfaults in windows and ghc-8.8.4
183187
- name: Build
184188
run: cabal build || cabal build || cabal build

cabal-ghc901.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ package *
3737

3838
write-ghc-environment-files: never
3939

40-
index-state: 2021-11-29T12:30:10Z
40+
index-state: 2021-12-29T12:30:08Z
4141

4242
constraints:
4343
-- These plugins don't work on GHC9 yet

cabal-ghc921.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ package *
3636

3737
write-ghc-environment-files: never
3838

39-
index-state: 2021-11-29T12:30:10Z
39+
index-state: 2021-12-29T12:30:08Z
4040

4141
constraints:
4242
-- These plugins doesn't work on GHC92 yet

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ package *
4040

4141
write-ghc-environment-files: never
4242

43-
index-state: 2021-11-29T12:30:10Z
43+
index-state: 2021-12-29T12:30:08Z
4444

4545
constraints:
4646
hyphenation +embed

ghcide/bench/example/HLS

Lines changed: 0 additions & 1 deletion
This file was deleted.

ghcide/bench/lib/Experiments.hs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ experiments =
194194
let edit :: TextDocumentContentChangeEvent =TextDocumentContentChangeEvent
195195
{ _range = Just Range {_start = bottom, _end = bottom}
196196
, _rangeLength = Nothing, _text = t}
197-
bottom = Position maxBoundUinteger 0
197+
bottom = Position maxBound 0
198198
t = T.unlines
199199
[""
200200
,"holef :: [Int] -> [Int]"
@@ -213,7 +213,7 @@ experiments =
213213
flip allM docs $ \DocumentPositions{..} -> do
214214
bottom <- pred . length . T.lines <$> documentContents doc
215215
diags <- getCurrentDiagnostics doc
216-
case requireDiagnostic diags (DsError, (bottom, 8), "Found hole", Nothing) of
216+
case requireDiagnostic diags (DsError, (fromIntegral bottom, 8), "Found hole", Nothing) of
217217
Nothing -> pure True
218218
Just _err -> pure False
219219
)
@@ -404,7 +404,7 @@ runBenchmarksFun dir allBenchmarks = do
404404
++ ["--verbose" | verbose ?config]
405405
++ ["--ot-memory-profiling" | Just _ <- [otMemoryProfiling ?config]]
406406
lspTestCaps =
407-
fullCaps {_window = Just $ WindowClientCapabilities $ Just True}
407+
fullCaps {_window = Just $ WindowClientCapabilities (Just True) Nothing Nothing }
408408
conf =
409409
defaultConfig
410410
{ logStdErr = verbose ?config,
@@ -585,7 +585,7 @@ setupDocumentContents config =
585585
doc <- openDoc m "haskell"
586586

587587
-- Setup the special positions used by the experiments
588-
lastLine <- length . T.lines <$> documentContents doc
588+
lastLine <- fromIntegral . length . T.lines <$> documentContents doc
589589
changeDoc doc [TextDocumentContentChangeEvent
590590
{ _range = Just (Range (Position lastLine 0) (Position lastLine 0))
591591
, _rangeLength = Nothing
@@ -638,9 +638,9 @@ searchSymbol doc@TextDocumentIdentifier{_uri} fileContents pos = do
638638
return res
639639
where
640640
loop pos
641-
| _line pos >= lll =
641+
| (fromIntegral $ _line pos) >= lll =
642642
return Nothing
643-
| _character pos >= lengthOfLine (_line pos) =
643+
| (fromIntegral $ _character pos) >= lengthOfLine (fromIntegral $ _line pos) =
644644
loop (nextLine pos)
645645
| otherwise = do
646646
checks <- checkDefinitions pos &&^ checkCompletions pos
@@ -663,7 +663,3 @@ searchSymbol doc@TextDocumentIdentifier{_uri} fileContents pos = do
663663
checkCompletions pos =
664664
not . null <$> getCompletions doc pos
665665

666-
-- | We don't have a uinteger type yet. So hardcode the maxBound of uinteger, 2 ^ 31 - 1
667-
-- as a constant.
668-
maxBoundUinteger :: Int
669-
maxBoundUinteger = 2147483647

ghcide/ghcide.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ library
6565
lens,
6666
list-t,
6767
hiedb == 0.4.1.*,
68-
lsp-types >= 1.3.0.1 && < 1.4,
69-
lsp == 1.2.*,
68+
lsp-types ^>= 1.4.0.0,
69+
lsp ^>= 1.4.0.0 ,
7070
monoid-subclasses,
7171
mtl,
7272
network-uri,

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ indexHieFile se mod_summary srcPath !hash hf = do
564564
done <- readTVar indexCompleted
565565
remaining <- HashMap.size <$> readTVar indexPending
566566
pure (done, remaining)
567+
let
568+
progressFrac :: Double
569+
progressFrac = fromIntegral done / fromIntegral (done + remaining)
570+
progressPct :: LSP.UInt
571+
progressPct = floor $ 100 * progressFrac
567572

568573
whenJust (lspEnv se) $ \env -> whenJust tok $ \tok -> LSP.runLspT env $
569574
LSP.sendNotification LSP.SProgress $ LSP.ProgressParams tok $
@@ -572,7 +577,7 @@ indexHieFile se mod_summary srcPath !hash hf = do
572577
Percentage -> LSP.WorkDoneProgressReportParams
573578
{ _cancellable = Nothing
574579
, _message = Nothing
575-
, _percentage = Just (100 * fromIntegral done / fromIntegral (done + remaining) )
580+
, _percentage = Just progressPct
576581
}
577582
Explicit -> LSP.WorkDoneProgressReportParams
578583
{ _cancellable = Nothing

0 commit comments

Comments
 (0)