Improve performance of NormalizedFilePath (#3067)

* upgrade lsp

* modify default benchmark config

* upgrade lsp

* use lsp master

* temp: compare benchmark with previous commit

* use text in NormalizedFilePath

* upgrade to lsp master

* fix stack config

* remove obsolete dir form ghcide.cabal

* run pre-commit without args

* Revert "run pre-commit without args"

This reverts commit 1c2a11df9d.

* remove unnecessary tests
This commit is contained in:
Kobayashi 2022-09-09 03:54:24 +08:00 committed by GitHub
parent aad896cdc5
commit 3fb4082f80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 92 additions and 93 deletions

View File

@ -76,7 +76,7 @@ versions:
# - 1.8.0.0
# - upstream: origin/master
- upstream: origin/master
# - HEAD~1
- HEAD
@ -95,26 +95,28 @@ configurations:
# The implicitly included plugins are:
# - ghcide-core
# - ghcide-hover-and-symbols
- None: []
- Core:
- callHierarchy
- codeRange
- eval
- ghcide-code-actions-bindings
- ghcide-code-actions-fill-holes
- ghcide-code-actions-imports-exports
- ghcide-code-actions-type-signatures
- ghcide-completions
- ghcide-type-lenses
- pragmas
- Ghcide:
- ghcide-completions
- ghcide-type-lenses
- Refactor:
- ghcide-code-actions-bindings
- ghcide-code-actions-fill-holes
- ghcide-code-actions-imports-exports
- ghcide-code-actions-type-signatures
# Uncomment below sections if needed
# - None: []
# - Core:
# - callHierarchy
# - codeRange
# - eval
# - ghcide-code-actions-bindings
# - ghcide-code-actions-fill-holes
# - ghcide-code-actions-imports-exports
# - ghcide-code-actions-type-signatures
# - ghcide-completions
# - ghcide-type-lenses
# - pragmas
# - Ghcide:
# - ghcide-completions
# - ghcide-type-lenses
# - Refactor:
# - ghcide-code-actions-bindings
# - ghcide-code-actions-fill-holes
# - ghcide-code-actions-imports-exports
# - ghcide-code-actions-type-signatures
- All:
- alternateNumberFormat
- callHierarchy
@ -141,36 +143,36 @@ configurations:
- refineImports
- rename
- stylish-haskell
- alternateNumberFormat
# - brittany
- callHierarchy
- changeTypeSignature
- class
- codeRange
- eval
- explicitFixity
# - floskell
# - fourmolu
- gadt
- ghcide-code-actions-bindings
- ghcide-code-actions-fill-holes
- ghcide-code-actions-imports-exports
- ghcide-code-actions-type-signatures
- ghcide-completions
# - ghcide-core # implicitly included in all configurations
# - ghcide-hover-and-symbols # implicitly included in all configurations
- ghcide-type-lenses
- haddockComments
- hlint
- importLens
- moduleName
# - ormolu
- pragmas
- qualifyImportedNames
- refineImports
- rename
- retrie
- splice
- stan
# - stylish-haskell
- tactics
# - alternateNumberFormat
# # - brittany
# - callHierarchy
# - changeTypeSignature
# - class
# - codeRange
# - eval
# - explicitFixity
# # - floskell
# # - fourmolu
# - gadt
# - ghcide-code-actions-bindings
# - ghcide-code-actions-fill-holes
# - ghcide-code-actions-imports-exports
# - ghcide-code-actions-type-signatures
# - ghcide-completions
# # - ghcide-core # implicitly included in all configurations
# # - ghcide-hover-and-symbols # implicitly included in all configurations
# - ghcide-type-lenses
# - haddockComments
# - hlint
# - importLens
# - moduleName
# # - ormolu
# - pragmas
# - qualifyImportedNames
# - refineImports
# - rename
# - retrie
# - splice
# - stan
# # - stylish-haskell
# - tactics

View File

@ -81,13 +81,24 @@ source-repository-package
location: https://github.com/wz1000/hie-bios
tag: aa73d3d2eb89df0003d2468a105e326d71b62cc7
-- Needed for ghcide-bench until a new release of lsp-test is out
-- Remove me when a new version of lsp is released
source-repository-package
type:git
location: https://github.com/haskell/lsp
subdir: lsp
tag: b0f8596887088b8ab65fc1015c773f45b47234ae
source-repository-package
type:git
location: https://github.com/haskell/lsp
subdir: lsp-types
tag: b0f8596887088b8ab65fc1015c773f45b47234ae
source-repository-package
type:git
location: https://github.com/haskell/lsp
subdir: lsp-test
tag: c95eb06c70c35f1e13c37ed11a7d9e5b36bfa2e8
-- https://github.com/haskell/lsp/pull/450
tag: b0f8596887088b8ab65fc1015c773f45b47234ae
allow-newer:
-- ghc-9.4

View File

@ -378,7 +378,7 @@ test-suite ghcide-tests
record-hasfield
if impl(ghc < 9.3)
build-depends: ghc-typelits-knownnat
hs-source-dirs: test/cabal test/exe test/src bench/lib
hs-source-dirs: test/cabal test/exe test/src
ghc-options: -threaded -Wall -Wno-name-shadowing -O0 -Wno-unticked-promoted-constructors
main-is: Main.hs
other-modules:

View File

@ -50,11 +50,7 @@ toNormalizedFilePath' "" = emptyFilePath
toNormalizedFilePath' fp = LSP.toNormalizedFilePath fp
emptyFilePath :: LSP.NormalizedFilePath
#if MIN_VERSION_lsp_types(1,3,0)
emptyFilePath = LSP.normalizedFilePath emptyPathUri ""
#else
emptyFilePath = LSP.NormalizedFilePath emptyPathUri ""
#endif
emptyFilePath = LSP.emptyNormalizedFilePath
-- | We use an empty string as a filepath when we dont have a file.
-- However, haskell-lsp doesnt support that in uriToFilePath and given

View File

@ -218,10 +218,7 @@ fullRange s = Range startPos endPos
lastLine = fromIntegral $ length $ T.lines s
subRange :: Range -> Range -> Bool
subRange smallRange range = _start smallRange >= _start range && _end smallRange <= _end range
positionInRange :: Position -> Range -> Bool
positionInRange p (Range sp ep) = sp <= p && p < ep -- Range's end position is exclusive, see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range
subRange = isSubrangeOf
-- ---------------------------------------------------------------------

View File

@ -9,21 +9,5 @@ import Test.Tasty.HUnit
tests :: TestTree
tests = testGroup "PluginUtils"
[ positionInRangeTest
]
positionInRangeTest :: TestTree
positionInRangeTest = testGroup "positionInRange"
[ testCase "single line, after the end" $
positionInRange (Position 1 10) (Range (Position 1 1) (Position 1 3)) @?= False
, testCase "single line, before the begining" $
positionInRange (Position 1 0) (Range (Position 1 1) (Position 1 6)) @?= False
, testCase "single line, in range" $
positionInRange (Position 1 5) (Range (Position 1 1) (Position 1 6)) @?= True
, testCase "single line, at the end" $
positionInRange (Position 1 5) (Range (Position 1 1) (Position 1 5)) @?= False
, testCase "multiline, in range" $
positionInRange (Position 3 5) (Range (Position 1 1) (Position 5 6)) @?= True
, testCase "multiline, out of range" $
positionInRange (Position 3 5) (Range (Position 3 6) (Position 4 10)) @?= False
[
]

View File

@ -87,9 +87,12 @@ extra-deps:
- constraints-extras-0.3.0.2@sha256:013b8d0392582c6ca068e226718a4fe8be8e22321cc0634f6115505bf377ad26,1853
- some-1.0.1@sha256:26e5bab7276f48b25ea8660d3fd1166c0f20fd497dac879a40f408e23211f93e,2055
- unliftio-core-0.2.0.1@sha256:9b3e44ea9aacacbfc35b3b54015af450091916ac3618a41868ebf6546977659a,1082
- lsp-1.5.0.0
- lsp-types-1.5.0.0
- lsp-test-0.14.0.3
- git: git@github.com:haskell/lsp
commit: b0f8596887088b8ab65fc1015c773f45b47234ae
subdirs:
- lsp
- lsp-types
- lsp-test
- stm-containers-1.1.0.4
- stm-hamt-1.2.0.6@sha256:fba86ccb4b45c5706c19b0e1315ba63dcac3b5d71de945ec001ba921fae80061,3972
- primitive-extras-0.10.1

View File

@ -55,9 +55,12 @@ extra-deps:
- refinery-0.4.0.0@sha256:fe3a43add8ff1db5cfffee7e7694c86128b1dfe62c541f26e25a8eadf9585610,1663
- retrie-1.1.0.0
- stylish-haskell-0.14.2.0@sha256:fffe1c13ad4c2678cf28a7470cac5d3bf20c71c36f09969e3e5f186787cceb7c,4321
- lsp-1.5.0.0
- lsp-types-1.5.0.0
- lsp-test-0.14.0.3
- git: git@github.com:haskell/lsp
commit: b0f8596887088b8ab65fc1015c773f45b47234ae
subdirs:
- lsp
- lsp-types
- lsp-test
- co-log-core-0.3.1.0
configure-options:

View File

@ -41,9 +41,12 @@ extra-deps:
- hiedb-0.4.1.0@sha256:fb20c657d9ecc91701b00dffcf4bbd77cb83720a1f9d867badd77ea227973135,2875
- implicit-hie-0.1.2.7@sha256:82bbbb1a8c05f99c8af3c16ac53e80c8648d8bf047b25ed5ce45a135bd736907,3122
- implicit-hie-cradle-0.5.0.0@sha256:4276f60f3a59bc22df03fd918f73bca9f777de9568f85e3a8be8bd7566234a59,2368
- lsp-1.5.0.0
- lsp-test-0.14.0.3
- lsp-types-1.5.0.0
- git: git@github.com:haskell/lsp
commit: b0f8596887088b8ab65fc1015c773f45b47234ae
subdirs:
- lsp
- lsp-types
- lsp-test
- monad-dijkstra-0.1.1.3@sha256:d2fc098d7c122555e726830a12ae0423ac187f89de9228f32e56e2f6fc2238e1,1900
- retrie-1.2.0.1
- co-log-core-0.3.1.0