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

[WIP] Add LSP communication layer #320

Open
wants to merge 20 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@Krzysztof-Cieslak
Copy link
Collaborator

Krzysztof-Cieslak commented Dec 31, 2018

This PR is adding communication layer implementing Language Server Protocol.

Implementation status

LSP messages

  • initialize - OK
  • initialized - OK
  • textDocument/hover - OK
  • textDocument/didOpen - OK
  • textDocument/didChange - OK
  • textDocument/completion - OK
  • completionItem/resolve - OK
  • textDocument/rename - OK
  • textDocument/definition - OK
  • textDocument/typeDefinition - OK
  • textDocument/implementation - ?
  • textDocument/codeAction - OK
  • textDocument/codeLens - OK
  • codeLens/resolve - OK
  • textDocument/references - OK
  • textDocument/documentHighlight - OK
  • textDocument/documentLink - In the future
  • documentLink/resolve - Nope
  • textDocument/signatureHelp - OK
  • textDocument/documentColor - Nope
  • textDocument/colorPresentation - Nope
  • textDocument/formatting - ?
  • textDocument/rangeFormatting - ?
  • textDocument/onTypeFormatting - ?
  • textDocument/willSave - Nope
  • textDocument/willSaveWaitUntil - Nope
  • textDocument/didSave - OK
  • textDocument/didClose - Nope
  • textDocument/documentSymbol - OK
  • workspace/didChangeWatchedFiles - OK
  • workspace/didChangeWorkspaceFolders - Nope
  • workspace/didChangeConfiguration - OK
  • workspace/symbol - OK
  • workspace/executeCommand - In the future (fsharp.generateDoc)
  • window/showMessage - OK
  • window/logMessage - OK
  • textDocument/publishDiagnostics - OK

Custom messages

  • fsharp/signature - OK
  • fsharp/signatureData - OK
  • fsharp/lineLens - OK
  • lineLens/resolve - OK
  • fsharp/workspaceLoad - OK
  • fsharp/compilerLocation - OK
  • fsharp/project - OK
  • fsharp/compile - OK
  • fsharp/notifyWorkspace - OK
  • fsharp/notifyWorkspacePeek - OK

Notes:

  • Current implementation was trying to do minimal changes in the other layers of FSAC to ensure it doesn't break other clients. As such, some implementations in LSP layer looks bit clunky. If we agree that LSP is way to go for all clients, we can deprecate other communication protocols, and do bigger refactoring of Core project.
  • Client is responsible for project loading/parsing/refreshing other than initial loading
  • Initial project loading is done automatically if and only if there exists single solution file in the workspace, or there is no solution files in the workspace (in such case all detected projects are loaded)
  • Custom endpoints are using (for messages body) PlainNotification type and string format serialized with exactly same serialization format as old JSON protocol
  • workspace/didChangeWatchedFiles should be used only for removing diagnostics from the files that were deleted.
  • Ionide's LineLenses needs to be implemented in client side using custom endpoints, it's too innovative for MSFT ;]

@Krzysztof-Cieslak Krzysztof-Cieslak changed the title Add LSP communication layer [WIP] Add LSP communication layer Dec 31, 2018

(__SOURCE_DIRECTORY__ </> "bin/release_netcore")
!!(__SOURCE_DIRECTORY__ </> "src/FsAutoComplete.SymbolCache.netcore/bin/Release/netcoreapp2.0/*.json")

let mainfestFile = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

This comment has been minimized.

@enricosada

enricosada Dec 31, 2018

Contributor

you can add that as Content in default.win32manifest in the FsAutoComplete.SymbolCache.netcore, so will be copied to output directory, removing this hack

build.fsx Outdated

CopyFiles
(__SOURCE_DIRECTORY__ </> "bin/release_netcore")
!!(__SOURCE_DIRECTORY__ </> "src/FsAutoComplete.SymbolCache.netcore/bin/Release/netcoreapp2.0/*.json")

This comment has been minimized.

@enricosada

enricosada Dec 31, 2018

Contributor

why it's copying theese stuff?

This comment has been minimized.

@Krzysztof-Cieslak

Krzysztof-Cieslak Dec 31, 2018

Author Collaborator

I believe there is some edge case (or I'm doing something wrong) when one Exe project is referencing another Exe project, in which case those JSON files (require to run referenced project) are not copied to the main output directory.

This comment has been minimized.

@enricosada

enricosada Dec 31, 2018

Contributor

why an exe reference another exe?
I'll check the branch code to understand better

This comment has been minimized.

@Krzysztof-Cieslak

Krzysztof-Cieslak Dec 31, 2018

Author Collaborator

Background symbol cache is running out-of-the process due to the fact that FSharpChecker (reactor queue, in particular) is singleton, and you can't create multiple instance of it in single process.

It's the same in the current branch - just the files are copied in Ionide build script, as no one else was using latest versions anyway.

@@ -103,9 +120,14 @@ let sendSymbols (serializer: Serializer) fn (symbols: FSharpSymbolUse[]) =

let getSymbols symbolName =
makePostRequest ("http://localhost:" + (string port) + "/getSymbols") symbolName
|> Async.map (fun n ->
try
Some <| JsonConvert.DeserializeObject<SymbolUseRange[]> n

This comment has been minimized.

@enricosada

enricosada Dec 31, 2018

Contributor

maybe

Some (JsonConvert.DeserializeObject<SymbolUseRange[]> n)

is easier to ready, too many pipes with the generic

@Krzysztof-Cieslak

This comment has been minimized.

Copy link
Collaborator Author

Krzysztof-Cieslak commented Jan 23, 2019

Wow, green. At least I haven't broken anything ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment