-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use haskell-lsp for lsp types #696
Conversation
@@ -413,13 +417,18 @@ hazel_repositories( | |||
hazel_hackage("shake", "0.17.8", "ade4162f7540f044f0446981120800076712d1f98d30c5b5344c0f7828ec49a2") + | |||
hazel_hackage("filepattern", "0.1.1", "f7fc5bdcfef0d43a793a3c64e7c0fd3b1d35eea97a37f0e69d6612ab255c9b4b") + | |||
hazel_hackage("terminal-progress-bar", "0.4.0.1", "c5a9720fcbcd9d83f9551e431ee3975c61d7da6432aa687aef0c0e04e59ae277") + | |||
hazel_hackage("rope-utf16-splay" , "0.2.0.0", "83d1961bf55355da49a6b55d6f58d02483eff1f8e6df53f4dccdab1ac49e101d") + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a ticket to add this to stackage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, on that now
@@ -17,6 +17,7 @@ import Development.IDE.Functions.Compile (TcModuleResult, | |||
import qualified Development.IDE.Functions.Compile as Compile | |||
import Development.IDE.Functions.FindImports (Import(..)) | |||
import Development.IDE.Functions.DependencyInformation | |||
import Development.IDE.State.Shake |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move this import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I have moved it
@@ -36,44 +36,44 @@ import Development.IDE.Types.SpanInfo | |||
-- Foo* means Foo for me and Foo+ | |||
|
|||
-- | Kick off things | |||
type instance RuleResult OfInterest = IdeResult () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why rename IdeResult?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't, IdeResult is what you produce from the rules and IdeReturn is what you get back when you return a rule. Better name suggestions would be welcome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you!
WORKSPACE
Outdated
pkgs = packages, | ||
) + | ||
# This is a special version of Haskell LSP without GPL dependencies | ||
[ ("haskell-lsp", {"url": "https://github.com/DavidM-D/haskell-lsp/archive/{}.zip".format(HASKELL_LSP_COMMIT), "sha256": "7d706fbc1beb49a9345083d3eadb5e311936a2a8449e7765a65aa7d298dff9d6", "stripPrefix": "haskell-lsp-{}".format(HASKELL_LSP_COMMIT)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What needs to happen for us to switch to upstream apart from haskell/lsp#70 being merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR needs to be resolved haskell/lsp#70, there's some LSP discussion going on, perhaps it could be resolved by the release of ropey, but our patches are pretty tiny at the moment. I think I'm also going to try and upstream our instances to make the diff even smaller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fork this to the digital-asset namespace please, and use it from there.
@@ -74,18 +76,19 @@ srcSpanToFilename (UnhelpfulSpan fs) = FS.unpackFS fs | |||
srcSpanToFilename (RealSrcSpan real) = FS.unpackFS $ srcSpanFile real | |||
|
|||
srcSpanToLocation :: SrcSpan -> Location | |||
srcSpanToLocation src = Location (srcSpanToFilename src) (srcSpanToRange src) | |||
srcSpanToLocation src = | |||
Location (LSP.filePathToUri $ srcSpanToFilename src) (srcSpanToRange src) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should hopefully fix URIs on Windows 👍
@@ -134,8 +133,10 @@ instance Hashable Key where | |||
-- not propagate diagnostic errors through multiple phases. | |||
type IdeResult v = ([Diagnostic], Maybe v) | |||
|
|||
type IdeReturn v = Maybe v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a pretty confusing type synonym, especially given the fact that we already have IdeResult
. I would just inline this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is something that you'd reasonably want to change at a later date and it's all over the place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tat would be true if we hadn't just introduced IdeReturn but reused IdeResult. Since we are changing it everywhere, might as well change it to the end result.
LSP.Diagnostic | ||
addLocation loc d = | ||
d { | ||
LSP._relatedInformation = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LSP._relatedInformation = | |
LSP._relatedInformation = Just $ LSP.List (rel loc : maybe [] toList (_relatedInformation d)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be a moving of invariants and types around IdeResult
vs IdeReturn
, so what was once encoded as ([Diagnostic], Maybe a)
now gets moved to Maybe a
through the type alias. Is that a necessary change? Or an unrelated change?
@@ -134,8 +133,10 @@ instance Hashable Key where | |||
-- not propagate diagnostic errors through multiple phases. | |||
type IdeResult v = ([Diagnostic], Maybe v) | |||
|
|||
type IdeReturn v = Maybe v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tat would be true if we hadn't just introduced IdeReturn but reused IdeResult. Since we are changing it everywhere, might as well change it to the end result.
Map.lookup (filePathToUri fp) | ||
|
||
-- | These functions live in the test framework rather that further down the stack because | ||
-- you really should be deconstructing LSP diagnostic stores in this manner bar when testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't?
-- | These functions live in the test framework rather that further down the stack because | ||
-- you really should be deconstructing LSP diagnostic stores in this manner bar when testing | ||
fromStore :: D.StoreItem -> [D.Diagnostic] | ||
fromStore (D.StoreItem _ ds) = join $ map toList $ Map.elems ds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concatMap?
fromStore (D.StoreItem _ ds) = join $ map toList $ Map.elems ds | ||
|
||
allDiagnostics :: D.DiagnosticStore -> [D.Diagnostic] | ||
allDiagnostics = join . map fromStore . Map.elems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
concatMap?
... require and what they return
It's (somewhat) necessary. We no longer store errors in the shake graph, we now store them the haskell-lsp data structure. I was going to write some code to handle this, but I realised that we weren't actually using the error return values, so I got rid of them. |
That makes sense, but it feels like we're in an odd middle ground. Before IdeResult captured and abstracted over two levels of type constructor - now it abstracts over one, and is more complex than what it abstracts. I'd suggest: Ditch |
hasSeriousErrors (List a) = any ((/=) uri . _uri . _location) a | ||
uri = LSP.filePathToUri fp | ||
|
||
addDiagnostics :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the semantics of this function? How does it remove old diagnostics that are no longer required? What if the Parser had a warning, and then that warning goes away - what's the flow?
I sliced off a chunk of this commit and simplified it in #708 |
First step to pulling out our custom LSP implementation
Pull Request Checklist
NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with
/AzurePipelines run
totrigger the build.