Skip to content

Commit 83fab8a

Browse files
authored
Merge branch 'master' into bug-fix/pragma-before-shebang
2 parents 833c6a8 + 64e9525 commit 83fab8a

File tree

173 files changed

+3735
-3321
lines changed

Some content is hidden

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

173 files changed

+3735
-3321
lines changed

.github/mergify.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pull_request_rules:
77
conditions:
88
- status-success=bench-example (8.10.4, ubuntu-latest, Cabal-3.0.0.0)
99
- status-success=bench-example (8.10.4, ubuntu-latest, lsp-types-1.0.0.1)
10+
# disabled (too slow, ~4h) until hie-bios >0.7.2 is released
11+
# - status-success=bench-example (8.10.4, ubuntu-latest, bench_example_HLS)
1012

1113
- status-success=nix (default, ubuntu-latest)
1214
- status-success=nix (default, macOS-latest)

.github/workflows/bench.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
os: [ubuntu-latest]
1313

1414
steps:
15+
# Cancel queued workflows from earlier commits in this branch
16+
- uses: fkirc/skip-duplicate-actions@master
17+
1518
- uses: actions/checkout@v2
1619
- run: git fetch origin master # check the master branch for benchmarking
1720
- uses: haskell/actions/setup@v1
@@ -78,9 +81,12 @@ jobs:
7881
matrix:
7982
ghc: ['8.10.4']
8083
os: [ubuntu-latest]
81-
example: ['Cabal-3.0.0.0', 'lsp-types-1.0.0.1']
84+
example: ['Cabal-3.0.0.0', 'lsp-types-1.0.0.1', 'bench_example_HLS']
8285

8386
steps:
87+
# Cancel queued workflows from earlier commits in this branch
88+
- uses: fkirc/skip-duplicate-actions@master
89+
8490
- uses: haskell/actions/setup@v1
8591
with:
8692
ghc-version: ${{ matrix.ghc }}

cabal.project

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ packages:
1212
./plugins/hls-retrie-plugin
1313
./plugins/hls-haddock-comments-plugin
1414
./plugins/hls-splice-plugin
15-
1615
tests: true
1716

1817
package *
@@ -25,7 +24,7 @@ package ghcide
2524

2625
write-ghc-environment-files: never
2726

28-
index-state: 2021-02-08T19:11:03Z
27+
index-state: 2021-02-15T19:11:03Z
2928

3029
allow-newer:
3130
active:base,

fmt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22
set -eou pipefail
3-
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s ghcide/src ghcide/exe ghcide/bench shake-bench/src ghcide/test/exe --with-group=extra --hint=ghcide/.hlint.yaml
3+
curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s ghcide/src ghcide/exe ghcide/bench/lib ghcide/bench/exe ghcide/bench/hist shake-bench/src ghcide/test/exe --with-group=extra --hint=ghcide/.hlint.yaml

ghcide/.hlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
- default: false
9999
- {name: [-Wno-missing-signatures, -Wno-orphans, -Wno-overlapping-patterns, -Wno-incomplete-patterns, -Wno-missing-fields, -Wno-unused-matches]}
100100
- {name: [-Wno-dodgy-imports,-Wno-incomplete-uni-patterns], within: [Main, Development.IDE.GHC.Compat, Development.Benchmark.Rules]}
101+
- {name: [-Wno-deprecations, -Wno-unticked-promoted-constructors], within: [Main, Experiments]}
101102
# - modules:
102103
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
103104
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely

ghcide/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 0.7.5 (2021-02-??)
2+
* Added Development.IDE.Main (#1338) - Pepe Iborra
3+
14
### 0.7.4 (2021-02-08)
25
* Support for references via hiedb (#704) - wz1000
36
* Fix space leak on cradle reloads (#1316) - Pepe Iborra

ghcide/bench/config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ examples:
2323
modules:
2424
- src/Language/LSP/VFS.hs
2525
- src/Language/LSP/Types/Lens.hs
26+
# Small but heavily multi-component example
27+
- path: bench/example/HLS
28+
modules:
29+
- hls-plugin-api/src/Ide/Plugin/Config.hs
30+
- ghcide/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs
31+
# Things get too slow with more than 2 components, hie-bios 0.7.3 will help here
32+
# - ghcide/bench/hist/Main.hs
33+
# - ghcide/bench/lib/Experiments/Types.hs
34+
# - ghcide/test/exe/Main.hs
35+
# - exe/Plugins.hs
2636

2737
# The set of experiments to execute
2838
experiments:

ghcide/bench/example/HLS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../..

ghcide/bench/lib/Experiments.hs

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{-# LANGUAGE ConstraintKinds #-}
2+
{-# LANGUAGE GADTs #-}
23
{-# LANGUAGE ExistentialQuantification #-}
34
{-# LANGUAGE ImplicitParams #-}
45
{-# LANGUAGE ImpredicativeTypes #-}
6+
{-# OPTIONS_GHC -Wno-deprecations -Wno-unticked-promoted-constructors #-}
57

68
module Experiments
79
( Bench(..)
@@ -20,19 +22,19 @@ module Experiments
2022
, exampleToOptions
2123
) where
2224
import Control.Applicative.Combinators (skipManyTill)
23-
import Control.Exception.Safe
25+
import Control.Exception.Safe (IOException, handleAny, try)
2426
import Control.Monad.Extra
2527
import Control.Monad.IO.Class
26-
import Data.Aeson (Value(Null))
28+
import Data.Aeson (Value(Null), toJSON)
2729
import Data.List
2830
import Data.Maybe
2931
import qualified Data.Text as T
3032
import Data.Version
3133
import Development.IDE.Plugin.Test
3234
import Experiments.Types
33-
import Language.Haskell.LSP.Test
34-
import Language.Haskell.LSP.Types
35-
import Language.Haskell.LSP.Types.Capabilities
35+
import Language.LSP.Test
36+
import Language.LSP.Types
37+
import Language.LSP.Types.Capabilities
3638
import Numeric.Natural
3739
import Options.Applicative
3840
import System.Directory
@@ -41,6 +43,7 @@ import System.FilePath ((</>), (<.>))
4143
import System.Process
4244
import System.Time.Extra
4345
import Text.ParserCombinators.ReadP (readP_to_S)
46+
import Development.Shake (cmd_, CmdOption (Cwd, FileStdout))
4447

4548
charEdit :: Position -> TextDocumentContentChangeEvent
4649
charEdit p =
@@ -78,13 +81,13 @@ experiments =
7881
isJust <$> getHover doc (fromJust identifierP),
7982
---------------------------------------------------------------------------------------
8083
bench "getDefinition" $ allWithIdentifierPos $ \DocumentPositions{..} ->
81-
not . null <$> getDefinitions doc (fromJust identifierP),
84+
either (not . null) (not . null) . toEither <$> getDefinitions doc (fromJust identifierP),
8285
---------------------------------------------------------------------------------------
8386
bench "getDefinition after edit" $ \docs -> do
8487
forM_ docs $ \DocumentPositions{..} ->
8588
changeDoc doc [charEdit stringLiteralP]
8689
flip allWithIdentifierPos docs $ \DocumentPositions{..} ->
87-
not . null <$> getDefinitions doc (fromJust identifierP),
90+
either (not . null) (not . null) . toEither <$> getDefinitions doc (fromJust identifierP),
8891
---------------------------------------------------------------------------------------
8992
bench "documentSymbols" $ allM $ \DocumentPositions{..} -> do
9093
fmap (either (not . null) (not . null)) . getDocumentSymbols $ doc,
@@ -147,7 +150,7 @@ experiments =
147150
( \docs -> do
148151
Just hieYaml <- uriToFilePath <$> getDocUri "hie.yaml"
149152
liftIO $ appendFile hieYaml "##\n"
150-
sendNotification WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
153+
sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
151154
List [ FileEvent (filePathToUri "hie.yaml") FcChanged ]
152155
forM_ docs $ \DocumentPositions{..} ->
153156
changeDoc doc [charEdit stringLiteralP]
@@ -162,7 +165,7 @@ experiments =
162165
(\docs -> do
163166
Just hieYaml <- uriToFilePath <$> getDocUri "hie.yaml"
164167
liftIO $ appendFile hieYaml "##\n"
165-
sendNotification WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
168+
sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
166169
List [ FileEvent (filePathToUri "hie.yaml") FcChanged ]
167170
flip allWithIdentifierPos docs $ \DocumentPositions{..} -> isJust <$> getHover doc (fromJust identifierP)
168171
)
@@ -358,7 +361,9 @@ waitForProgressDone :: Session ()
358361
waitForProgressDone = loop
359362
where
360363
loop = do
361-
void (skipManyTill anyMessage message :: Session WorkDoneProgressEndNotification)
364+
~() <- skipManyTill anyMessage $ satisfyMaybe $ \case
365+
FromServerMess SProgress (NotificationMessage _ _ (ProgressParams _ (End _))) -> Just ()
366+
_ -> Nothing
362367
done <- null <$> getIncompleteProgressSessions
363368
unless done loop
364369

@@ -392,8 +397,9 @@ runBench runSess b = handleAny (\e -> print e >> return badRun)
392397
else do
393398
output (showDuration t)
394399
-- Wait for the delayed actions to finish
395-
waitId <- sendRequest (CustomClientMethod "test") WaitForShakeQueue
396-
(td, resp) <- duration $ skipManyTill anyMessage $ responseForId waitId
400+
let m = SCustomMethod "test"
401+
waitId <- sendRequest m (toJSON WaitForShakeQueue)
402+
(td, resp) <- duration $ skipManyTill anyMessage $ responseForId m waitId
397403
case resp of
398404
ResponseMessage{_result=Right Null} -> do
399405
loop (userWaits+t) (delayedWork+td) (n -1)
@@ -423,19 +429,24 @@ setup :: HasConfig => IO SetupResult
423429
setup = do
424430
-- when alreadyExists $ removeDirectoryRecursive examplesPath
425431
benchDir <- case example ?config of
426-
UsePackage{..} -> return examplePath
432+
UsePackage{..} -> do
433+
let hieYamlPath = examplePath </> "hie.yaml"
434+
alreadyExists <- doesFileExist hieYamlPath
435+
unless alreadyExists $
436+
cmd_ (Cwd examplePath) (FileStdout hieYamlPath) ("gen-hie"::String)
437+
return examplePath
427438
GetPackage{..} -> do
428439
let path = examplesPath </> package
429440
package = exampleName <> "-" <> showVersion exampleVersion
441+
hieYamlPath = path </> "hie.yaml"
430442
alreadySetup <- doesDirectoryExist path
431443
unless alreadySetup $
432444
case buildTool ?config of
433445
Cabal -> do
434446
let cabalVerbosity = "-v" ++ show (fromEnum (verbose ?config))
435447
callCommandLogging $ "cabal get " <> cabalVerbosity <> " " <> package <> " -d " <> examplesPath
436-
writeFile
437-
(path </> "hie.yaml")
438-
("cradle: {cabal: {component: " <> exampleName <> "}}")
448+
let hieYamlPath = path </> "hie.yaml"
449+
cmd_ (Cwd path) (FileStdout hieYamlPath) ("gen-hie"::String)
439450
-- Need this in case there is a parent cabal.project somewhere
440451
writeFile
441452
(path </> "cabal.project")
@@ -464,9 +475,7 @@ setup = do
464475
]
465476
)
466477

467-
writeFile
468-
(path </> "hie.yaml")
469-
("cradle: {stack: {component: " <> show (exampleName <> ":lib") <> "}}")
478+
cmd_ (Cwd path) (FileStdout hieYamlPath) ("gen-hie"::String) ["--stack"::String]
470479
return path
471480

472481
whenJust (shakeProfiling ?config) $ createDirectoryIfMissing True
@@ -498,22 +507,21 @@ setupDocumentContents config =
498507

499508
-- Find an identifier defined in another file in this project
500509
symbols <- getDocumentSymbols doc
501-
case symbols of
502-
Left [DocumentSymbol{_children = Just (List symbols)}] -> do
503-
let endOfImports = case symbols of
504-
DocumentSymbol{_kind = SkModule, _name = "imports", _range } : _ ->
505-
Position (succ $ _line $ _end _range) 4
506-
DocumentSymbol{_range} : _ -> _start _range
507-
[] -> error "Module has no symbols"
508-
contents <- documentContents doc
509-
510-
identifierP <- searchSymbol doc contents endOfImports
511-
512-
return $ DocumentPositions{..}
513-
other ->
514-
error $ "symbols: " <> show other
515-
516-
510+
let endOfImports = case symbols of
511+
Left symbols | Just x <- findEndOfImports symbols -> x
512+
_ -> error $ "symbols: " <> show symbols
513+
contents <- documentContents doc
514+
identifierP <- searchSymbol doc contents endOfImports
515+
return $ DocumentPositions{..}
516+
517+
findEndOfImports :: [DocumentSymbol] -> Maybe Position
518+
findEndOfImports (DocumentSymbol{_kind = SkModule, _name = "imports", _range} : _) =
519+
Just $ Position (succ $ _line $ _end _range) 4
520+
findEndOfImports [DocumentSymbol{_kind = SkFile, _children = Just (List cc)}] =
521+
findEndOfImports cc
522+
findEndOfImports (DocumentSymbol{_range} : _) =
523+
Just $ _start _range
524+
findEndOfImports _ = Nothing
517525

518526
--------------------------------------------------------------------------------------------
519527

@@ -559,7 +567,7 @@ searchSymbol doc@TextDocumentIdentifier{_uri} fileContents pos = do
559567
checkDefinitions pos = do
560568
defs <- getDefinitions doc pos
561569
case defs of
562-
[Location uri _] -> return $ uri /= _uri
570+
(InL [Location uri _]) -> return $ uri /= _uri
563571
_ -> return False
564572
checkCompletions pos =
565573
not . null <$> getCompletions doc pos

0 commit comments

Comments
 (0)