Skip to content
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

Server Not Initialized Error #12

Closed
LucasBullen opened this issue Sep 12, 2017 · 70 comments
Closed

Server Not Initialized Error #12

LucasBullen opened this issue Sep 12, 2017 · 70 comments

Comments

@LucasBullen
Copy link

I am attempting to add your language server within Eclipse. When starting the server I only receive the following message back:
{"protocolVersion":"2.0","message":{"code":-32002,"message":"Server Not Initialized"}}

To confirm, I am meant to launch the LS by following the build instructions then executing /out/language-server/MSBuildProjectTools.LanguageServer.Host.dll?

Are there any dependencies that would stop the server from initializing? Am I unaware of a required step?

@tintoy
Copy link
Owner

tintoy commented Sep 12, 2017

Hi - I shouldn't have thought so, normally if you see any LSP message at all, then I think the server is running.

There's an extended logging facility that currently sends log entries to a server called Seq which I can send you instructions for enabling. That may shed some more light on the problem. Otherwise, you might be able to attach the Visual Studio debugger to the language server process once it has been started and turn on "break on all exceptions" to see if there's some unhandled error somewhere that's crashing the server...

Are you able to use your locally-built version of the language server from within VS Code (i.e. follow instructions to run the extension by hitting F5)? If it works from within VS Code, but when called from Eclipse then perhaps there's some sort of difference in how it implements LSP (I'm using OmniSharp's LSP implementation, BTW). Until now, I've treated the LSP implementation as a black box because it simply worked for my use-case but if it's not working elsewhere then perhaps some more investigation is needed :)

@tintoy
Copy link
Owner

tintoy commented Sep 12, 2017

Ah, ok. Looking through the LSP code it sounds like the language server is being sent a request before it has been sent an Initialize request:

https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#initialize

@tintoy
Copy link
Owner

tintoy commented Sep 12, 2017

I'm not sure how the Eclipse LSP client works, but there might be some method you have to call to send the Initialize message to the language server before sending any other requests...

@LucasBullen
Copy link
Author

Ok thanks, I will take another crack at it.

@tintoy
Copy link
Owner

tintoy commented Sep 12, 2017

Ah - is this related to aCute? If so, be aware that OmniSharp itself does not actually speak LSP (it was built before LSP was a thing) and so if you're trying to use OmniSharp client library to talk to the MSBuild service then they won't communicate correctly.

I think there's an LSP client called LSP4J that might do the trick though.

@tintoy
Copy link
Owner

tintoy commented Sep 13, 2017

BTW, if you're still having problems and have some repro code I could use, I'd be happy to try running it and capturing more detailed diagnostics from the language service.

@LucasBullen
Copy link
Author

I have my .csproj file editor code here. Opening a .csproj file in the Generic Editor will begin the LS.

In the console you can see that an Initialize message is sent to the language server. There is also a document highlight request sent after the initialize message. This is when we get the Server Not Initialized message.

Do requests get queued or could it be that the second request is processed before the server finishes initializing?

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

I believe the protocol says the client is supposed to wait for the server's response to Initialize before sending anything else but I could be wrong. Let me have a look at the LSP implementation library to see what the expected behaviour should be. Just out of curiosity, if you stuck a pause of, say, 5 seconds in there (to allow for start-up time) does the problem go away? Just trying to establish whether it works at all or whether there is something else at play.

@LucasBullen
Copy link
Author

Bad news, added a 5 second delay and same result, so not a queuing problem

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

Ok - I'll be at work in around 60 mins - will capture a trace of the messages that occur when it works correctly. Does LSP4J have a facility to trace messages?

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

Then we can compare :)

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

In the meanwhile would you mind passing a writer to the "trace" parameter of the Launcher and posting the resulting output? Would be good to get an idea of the exact sequence of messages being exchanged...

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

Ok, here's the sequence of messages I see:

[Trace - 02:16:44] Received request 'client/registerCapability - (0)'.
Params: {
    "registrations": [
        {
            "id": "e5a39b0c-ddbc-483b-a911-7370caaf10f4",
            "method": "textDocument/completion",
            "registerOptions": {
                "triggerCharacters": [
                    "<"
                ],
                "resolveProvider": false,
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "0bcde790-0574-44e4-acd9-af121a3fffc1",
            "method": "textDocument/didChange",
            "registerOptions": {
                "syncKind": 1,
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "bc0249b4-d69c-46e8-9ec3-ccee5f6d280a",
            "method": "textDocument/didOpen",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "3cf33804-fa2b-4169-8084-ea79ef9e8a95",
            "method": "textDocument/didClose",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "4ba0578e-b6c1-474e-a6a1-859518df18e1",
            "method": "textDocument/didSave",
            "registerOptions": {
                "includeText": true,
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "15029003-4d94-4935-8737-f63b76f13754",
            "method": "textDocument/documentSymbol",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "9e0bbd2b-8ea9-4325-8d9d-820a416fc66b",
            "method": "textDocument/definition",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "3f4105b1-efe0-4d78-94c5-152224dbb736",
            "method": "textDocument/hover",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        }
    ]
}


[Trace - 02:16:44] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/tintoy/Desktop/temp.csproj",
        "languageId": "xml",
        "version": 1,
        "text": "<Project Sdk=\"Microsoft.NET.Sdk\">\r\n    <PropertyGroup>\r\n        <TargetFramework>netstandard1.3</TargetFramework>\r\n        <SomePackage>MyPackage</SomePackage>\r\n        <SomePackage>AnotherPackage</SomePackage>\r\n        <AnotherPackage> '$(SomePackage)' </AnotherPackage>\r\n        <AnotherPackage> $(SomePackage) </AnotherPackage>\r\n        <YetAnotherProperty>false</YetAnotherProperty>\r\n        <AnotherProperty Condition=\" '$(YetAnotherProperty)' == 'true' \">Hello</AnotherProperty>\r\n    </PropertyGroup>\r\n\r\n    <Target Name=\"SomeTarget\" BeforeTargets=\"AfterBuild;AfterClean;;AfterPublish\">\r\n        \r\n    </Target>\r\n    \r\n    \r\n    <ItemGroup>\r\n        <PackageReference Include=\"Newtonsoft.Json\" Version=\"10.0.3\" />\r\n        <PackageReference Include=\"$(SomePackage)\" Version=\"1.0.0\" />\r\n        <Foo Include=\"A;B;C;D;E;F\" Diddly=\"Hello%(Identity)\" Mo=\"$(AllowUnsafeBlocks)\" />\r\n        <Foo Include=\"G;H;I;J\" Diddly=\"Dee\" Mo=\"\" />\r\n        <Foo Include=\"K;L;M\" Diddly=\"Dee\" ExtensionsPath=\"$(MSBuildExtensionsPath)\" Condition=\" '$(AnotherProperty)' == 'Hello' \" />\r\n        <Bar Include=\"A;@(Foo->'%(Diddly)')\">\r\n            \r\n        </Bar>\r\n        <Compile Include=\"Mo.cs\">\r\n            \r\n        </Compile>\r\n    </ItemGroup>\r\n</Project>"
    }
}


[Trace - 02:16:44] Sending response 'client/registerCapability - (0)'. Processing request took 2ms
[Trace - 02:16:44] Received notification 'msbuild/busy'.
Params: {
    "isBusy": true,
    "message": "Loading project..."
}


[Trace - 02:16:47] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///c%3A/Users/tintoy/Desktop/temp.csproj",
    "diagnostics": []
}


[Trace - 02:16:47] Received notification 'msbuild/busy'.
Params: {
    "isBusy": false,
    "message": "Project loaded."
}


[Trace - 02:16:47] Received notification 'window/logMessage'.
Params: {
    "type": 3,
    "message": "Successfully loaded project \"c:\\Users\\tintoy\\Desktop\\temp.csproj\"."
}

Unfortunately, it doesn't show the initialize message or its response which is slightly annoying. I've been treating the LSP library I'm using as a bit of a black-box so far because it just works for my use-case, but I can see that perhaps I should extend it with server-side tracing :-/

@LucasBullen
Copy link
Author

The output of the input/output from the MSBuildStreamConnectionProvider. Is this what you are looking for / expected?

13:22:26 Output:Content-Length: 674

13:22:26 Output:Content-Length: 674

13:22:26 Output:{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"initialize",
  "params":{
    "rootPath":"/home/lbullen/runtime-EclipseApplication(1)/NewDotnetProject1",
    "rootUri":"file:///home/lbullen/runtime-EclipseApplication(1)/NewDotnetProject1/",
    "capabilities":{
      "workspace":{
        "applyEdit":true,
        "symbol":{ },
        "executeCommand":{ }
      },
      "textDocument":{
        "synchronization":{
          "willSave":true,
          "willSaveWaitUntil":true,
          "didSave":true
        },
        "completion":{
          "completionItem":{
            "snippetSupport":true
          }
        },
        "hover":{ },
        "signatureHelp":{ },
        "references":{ },
        "documentHighlight":{ },
        "documentSymbol":{ },
        "formatting":{ },
        "rangeFormatting":{ },
        "definition":{ },
        "codeAction":{ },
        "codeLens":{ },
        "documentLink":{ },
        "rename":{ }
      }
    },
    "clientName":"Eclipse SDK"
  }
}

13:22:26 Output:{
  "jsonrpc":"2.0",
  "id":"1",
  "method":"initialize",
  "params":{
    "rootPath":"/home/lbullen/runtime-EclipseApplication(1)/NewDotnetProject1",
    "rootUri":"file:///home/lbullen/runtime-EclipseApplication(1)/NewDotnetProject1/",
    "capabilities":{
      "workspace":{
        "applyEdit":true,
        "symbol":{ },
        "executeCommand":{ }
      },
      "textDocument":{
        "synchronization":{
          "willSave":true,
          "willSaveWaitUntil":true,
          "didSave":true
        },
        "completion":{
          "completionItem":{
            "snippetSupport":true
          }
        },
        "hover":{ },
        "signatureHelp":{ },
        "references":{ },
        "documentHighlight":{ },
        "documentSymbol":{ },
        "formatting":{ },
        "rangeFormatting":{ },
        "definition":{ },
        "codeAction":{ },
        "codeLens":{ },
        "documentLink":{ },
        "rename":{ }
      }
    },
    "clientName":"Eclipse SDK"
  }
}

13:22:28 Output:Content-Length: 234

13:22:28 Output:Content-Length: 234

13:22:28 Output:{
  "jsonrpc":"2.0",
  "id":"2",
  "method":"textDocument/documentHighlight",
  "params":{
    "textDocument":{
      "uri":"file:///home/lbullen/runtime-EclipseApplication(1)/NewDotnetProject1/NewDotnetProject1.csproj"
    },
    "position":{
      "line":0,
      "character":0
    }
  }
}

13:22:28 Output:{
  "jsonrpc":"2.0",
  "id":"2",
  "method":"textDocument/documentHighlight",
  "params":{
    "textDocument":{
      "uri":"file:///home/lbullen/runtime-EclipseApplication(1)/NewDotnetProject1/NewDotnetProject1.csproj"
    },
    "position":{
      "line":0,
      "character":0
    }
  }
}

13:22:40 Input:{
  "protocolVersion":"2.0",
  "message":{
    "code":-32002,
    "message":"Server Not Initialized"
  }
}

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

Thanks - ok, so it looks to me like the server hasn't sent the response to the initial initialize request (yet?)...

Let me add a little logging to the server to capture that stuff. Give me 10 or 15 minutes?

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

Ok, @LucasBullen, would you mind pulling the latest code from master? If you then republish the language server, you can enable logging-to-file by setting the MSBUILD_PROJECT_TOOLS_LOG_FILE environment variable to the full path of the desired log file before starting the server. I've added some extra diagnostic stuff, but if this still doesn't shed enough light I may need to create a custom build of the LSP library that is capable of logging raw requests and responses.

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

BTW, if you are able to put your client code into a console app, I can run it and attach a debugger to the language service to see if anything is causing the server to die (since it looks like you never receive any responses from it at all).

@LucasBullen
Copy link
Author

Another question, on the build instructions it says
dotnet publish src/LanguageServer/LanguageServer.Host.csproj -o $PWD/out/language-server
Is the Host supposed to be there or is that a mistake as there is no LanguageServer.Host.csproj?

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

Oops! Sorry, I renamed that project to just LanguageServer\LanguageServer.csproj. I'll fix the readme.

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

BTW, sorry about this but you may need to fetch the master branch again (it's now 5am here, but was 3am when I made the change, and I forgot to push one of the changes required to make logging work). Last time, I promise :)

@LucasBullen
Copy link
Author

Thanks for all the help you are putting in.

@tintoy
Copy link
Owner

tintoy commented Sep 14, 2017

No worries - I'd love to see it being used in other editors; the more people find it useful, the better

@LucasBullen
Copy link
Author

Got the logging output:

2017-09-19 09:48:31.293 -04:00 [Verbose/] Logger initialised.
2017-09-19 09:48:32.661 -04:00 [Verbose/] Logger initialised.
2017-09-19 09:48:34.169 -04:00 [Verbose/] Logger initialised.

Not too much going on, but at least we can see that the logger was initialised.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

Heh, ok - I've been writing an LSP client over the last couple of days and have fully instrumented versions of the LSP assemblies lying around somewhere (they dump the STDIN and STDOUT streams to the log). Give me an hour or so and I'll dig them up and post them here.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

Even better I have a (simplified) dummy language server with extended logging - will dig that up, too.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

Ok, @LucasBullen, would you mind trying to build and use this language server instead? It has lots of extended logging and a simplified design (but is built using the same LSP framework):

https://github.com/tintoy/dotnet-language-client

To get it running:

  1. dotnet restore
  2. dotnet build

Then use samples/Server/bin/Debug/netcoreapp2.0/Server.dll instead of the MSBuild server assembly.

You'll need to set the LSP_LOG_FILE environment variable to the full path of the desired log file, and set LSP_VERBOSE_LOGGING to 1.

Here's a sample of what the log should contain:

2017-09-20 02:19:39.618 +10:00 [Information] Initialising language server...
2017-09-20 02:19:39.681 +10:00 [Information] Starting language server...
2017-09-20 02:19:39.683 +10:00 [Information] Opening LSP connection...
2017-09-20 02:19:39.684 +10:00 [Information] Starting input handler...
2017-09-20 02:19:39.684 +10:00 [Information] Starting output handler...
2017-09-20 02:19:39.688 +10:00 [Information] Started output handler.
2017-09-20 02:19:39.693 +10:00 [Information] Started input handler.
2017-09-20 02:19:39.693 +10:00 [Information] LSP connection is open.
2017-09-20 02:19:39.695 +10:00 [Information] Language server initialised; waiting for shutdown.
2017-09-20 02:19:40.178 +10:00 [Information] Handle request "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"processId\":null,\"rootPath\":\"C:/Foo\",\"rootUri\":\"file://C:\\Foo\",\"initializationOptions\":null,\"capabilities\":{\"workspace\":{\"applyEdit\":false,\"workspaceEdit\":false,\"didChangeConfiguration\":false,\"didChangeWatchedFiles\":false,\"symbol\":false,\"executeCommand\":false},\"textDocument\":{\"synchronization\":false,\"completion\":false,\"hover\":false,\"signatureHelp\":false,\"references\":false,\"documentHighlight\":false,\"documentSymbol\":false,\"formatting\":false,\"rangeFormatting\":false,\"onTypeFormatting\":false,\"definition\":false,\"codeAction\":false,\"codeLens\":false,\"documentLink\":false,\"rename\":false},\"experimental\":{}},\"trace\":\"off\"}}"
2017-09-20 02:19:40.228 +10:00 [Information] Schedule "initialize" request 1.
2017-09-20 02:19:40.476 +10:00 [Information] Sending item from output queue...
2017-09-20 02:19:40.530 +10:00 [Information] Sending content "{\"protocolVersion\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"textDocumentSync\":{\"openClose\":false,\"change\":0,\"willSave\":false,\"willSaveWaitUntil\":false,\"save\":{\"includeText\":false}},\"hoverProvider\":false,\"definitionProvider\":false,\"referencesProvider\":false,\"documentHighlightProvider\":false,\"documentSymbolProvider\":false,\"workspaceSymbolProvider\":false,\"codeActionProvider\":false,\"documentFormattingProvider\":false,\"documentRangeFormattingProvider\":false,\"renameProvider\":false,\"experimental\":{}}}}" with headers "Content-Length: 498

" from output queue...
2017-09-20 02:19:40.530 +10:00 [Information] Sent item from output queue (498 bytes).
2017-09-20 02:19:40.643 +10:00 [Information] Handle request "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"dummy\",\"params\":{\"message\":\"Hello, world!\"}}"
2017-09-20 02:19:40.643 +10:00 [Information] Schedule "dummy" request 2.
2017-09-20 02:19:40.652 +10:00 [Information] DummyHandler got request DummyParams { Message: "Hello, world!" }
2017-09-20 02:19:40.653 +10:00 [Information] Sending item from output queue...
2017-09-20 02:19:40.655 +10:00 [Information] Sending content "{\"protocolVersion\":\"2.0\",\"method\":\"dummy/notify\",\"params\":{\"message\":\"Hello, world!\"}}" with headers "Content-Length: 86

" from output queue...
2017-09-20 02:19:40.655 +10:00 [Information] Sent item from output queue (86 bytes).
2017-09-20 02:19:40.655 +10:00 [Information] Sending item from output queue...
2017-09-20 02:19:40.655 +10:00 [Information] Sending content "{\"protocolVersion\":\"2.0\",\"id\":2,\"result\":null}" with headers "Content-Length: 46

" from output queue...
2017-09-20 02:19:40.655 +10:00 [Information] Sent item from output queue (46 bytes).
2017-09-20 02:19:40.752 +10:00 [Information] Handle request "{\"jsonrpc\":\"2.0\",\"id\":null,\"method\":\"shutdown\",\"params\":{}}"
2017-09-20 02:19:40.752 +10:00 [Information] Schedule "shutdown" request null.

@LucasBullen
Copy link
Author

From the Server log:

2017-09-19 14:50:54.851 -04:00 [Information] Initialising language server...
2017-09-19 14:50:54.882 -04:00 [Information] Starting language server...
2017-09-19 14:50:54.886 -04:00 [Information] Language server initialised; waiting for shutdown.

To get it working I did have to download JsonRpc.1.0.0.nupkg and Lsp.1.0.0.nupkg and replace the dependencies to 1.0.0 instead of 1.0.1 if you think that is what caused the issue.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

1.0.1 did not work? Or was the package missing?

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

Ok, sorry for wasting your time - I'm a moron, the packages were excluded by .gitignore. Give me 5 and I'll add them :)

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

Ready to go - can you pull down the latest source, re-run dotnet publish and then try again?

tintoy added a commit that referenced this issue Sep 19, 2017
@LucasBullen
Copy link
Author

Whoot!!!
screenshot from 2017-09-19 16-27-18

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

I'm waiting for the new colouriser API for LSP to stabilise and then I can give you syntax highlighting too :)

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

BTW are the line and column positions you're passing 0-based or 1-based? It looks like it thinks it's outside the quotes based on the completions but the cursor appears to be inside them.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

(for LSP, line and column are 0-based)

@LucasBullen
Copy link
Author

0-based: {"line":11,"character":31}
When I go outside the quotes it only shows Condition, Exclude, and Update

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

That's correct - what about inside the quotes for the Include attribute of a PackageReference item?

@LucasBullen
Copy link
Author

Inside the quotes at {"line":11,"character":31} is what is shown in the image above, outside the quotes at {"line":11,"character":30} shows only the three, and at the beginning of that line at {"line":11,"character":0} shows <PackageReference /> and <DotNetCliToolReference />

@LucasBullen
Copy link
Author

But that's great, currently using a TextMate language for syntax highlighting as well.

Thank you for all your help with getting this set up, especially with the time difference. I'd say we got this one figured out and should move the suggestion error to a different issue. I'll open up other issues if I find any.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

Cheers, that'd be great.

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

BTW, if you open a new issue, could you attach the project file you're testing with?

Also, are you using Windows-style or Unix-style line endings?

@tintoy
Copy link
Owner

tintoy commented Sep 19, 2017

(attach file rather than paste contents, in case line endings are the problem)

@LucasBullen
Copy link
Author

Will do, and Unix-style line endings (Testing on Fedora).

@tintoy
Copy link
Owner

tintoy commented Sep 20, 2017 via email

@LucasBullen
Copy link
Author

Another question for you, I am not getting the hover results that you show in the gif within the readme. I receive the following response from the initialize message and shows that there isn't hover capabilities:

{
  "protocolVersion":"2.0",
  "id":"1",
  "result":{
    "capabilities":{
      "textDocumentSync":{
        "openClose":true,
        "change":1,
        "willSave":true,
        "willSaveWaitUntil":false,
        "save":{
          "includeText":true
        }
      },
      "hoverProvider":false,
      "completionProvider":{
        "resolveProvider":false,
        "triggerCharacters":["<"]
      },
      "definitionProvider":false,
      "referencesProvider":false,
      "documentHighlightProvider":false,
      "documentSymbolProvider":false,
      "workspaceSymbolProvider":false,
      "codeActionProvider":false,
      "documentFormattingProvider":false,
      "documentRangeFormattingProvider":false,
      "renameProvider":false,
      "experimental":{
      }
    }
  }
}

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

That's odd - if it says there's a completion provider, it should say there's a hover provider (they're both registered at the same time). What response do you get from the server when you send a textDocument/hover request?

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

What's especially odd is that it looks like all server capabilities are marked as false in that response; I'm not sure what could do that. I'll have a go at capturing the local response to Initialize to see if it matches what you're seeing.

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

Ah, I think I understand - OmniSharp's LSP implementation relies on dynamic registration of server capabilities after the server has been initialised:

[Trace - 05:48:46] Received request 'client/registerCapability - (0)'.
Params: {
    "registrations": [
        {
            "id": "35fcd6f7-4c9c-4fd4-a098-6917e3eaffbb",
            "method": "textDocument/completion",
            "registerOptions": {
                "triggerCharacters": [
                    "<"
                ],
                "resolveProvider": false,
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "27a2eebe-dfc2-4aa8-aa25-27f7cc41362e",
            "method": "textDocument/didChange",
            "registerOptions": {
                "syncKind": 1,
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "ee62cc19-7730-4f14-88d8-9ac047b10511",
            "method": "textDocument/didOpen",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "1997a4a2-50b7-4d35-8090-a0c00dd8fe24",
            "method": "textDocument/didClose",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "f6082e9a-2e04-4a4f-89cb-ff0ae5813bf1",
            "method": "textDocument/didSave",
            "registerOptions": {
                "includeText": true,
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "eb559a9c-7021-4a60-b41d-d3063f743ea2",
            "method": "textDocument/documentSymbol",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "cdbe217c-b8f3-42f0-a56f-49ca3451b84e",
            "method": "textDocument/definition",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        },
        {
            "id": "65d8f92c-a737-4447-af49-3e5dd504e021",
            "method": "textDocument/hover",
            "registerOptions": {
                "documentSelector": [
                    {
                        "language": "msbuild",
                        "pattern": "**/*.*"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.*proj"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.props"
                    },
                    {
                        "language": "xml",
                        "pattern": "**/*.targets"
                    }
                ]
            }
        }
    ]
}

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

When you send the initialize request, are you indicating that you support dynamic capability registration? Unfortunately I don't think the OmniSharp LSP implementation is checking if the client actually supports dynamic capability registration before doing so :-/

I think I'm going to have to open a PR with the upstream repo to get that fixed. Either way, you should still be able to call textDocument/hover and get a response.

@LucasBullen
Copy link
Author

With "hover":{ }, "hover":{"dynamicRegistration":false}, and "hover":{ "dynamicRegistration":true } I receive "hoverProvider":false in the response. Unfortunately sending the hover request as follows returns a null response when hovering over PackageReference in the line <PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.0" />:

{
  "jsonrpc":"2.0",
  "id":"10",
  "method":"textDocument/hover",
  "params":{
    "textDocument":{
      "uri":"file:///home/lbullen/eclipse/runtime-EclipseApplication/NewDotnetProject/NewDotnetProject.csproj"
    },
    "uri":"file:///home/lbullen/eclipse/runtime-EclipseApplication/NewDotnetProject/NewDotnetProject.csproj",
    "position":{
      "line":7,
      "character":8
    }
  }
}

Response: {"protocolVersion":"2.0","id":"10","result":null}

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

Ah, that doesn't mean hover isn't supported (you'd get error response -32601: MethodNotFound if that was the case). It just means that it thinks there's nothing it can generate a hover tooltip for at that location.

Are you able to attach the file you're working with? I can run it through a couple of test suites I have to see what's going on. I remember we discussed before that it might be a line-endings problem (which could potentially make the line / column wrong).

@LucasBullen
Copy link
Author

LucasBullen commented Oct 5, 2017

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  
  <PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.0" />

</Project>

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

Any chance you could attach it as a file? Otherwise the line endings will probably wind up normalised...

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

Also, how much information is there in the log file - does it list the MSBuild objects it did find when the project was first loaded and parsed? Do those line and column numbers line up with your expectations?

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

Ah, just realised - that's not a valid project file, so you won't get some types of hover :)

Try this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.0" />
  </ItemGroup>

</Project>

@tintoy
Copy link
Owner

tintoy commented Oct 5, 2017

BTW, the server will publish diagnostics telling you if there's anything wrong with the project:

image

[Trace - 07:38:27] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///c%3A/Users/tintoy/Desktop/temp2.csproj",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 7,
                    "character": 2
                },
                "end": {
                    "line": 7,
                    "character": 2
                }
            },
            "severity": 1,
            "code": "MSB4067",
            "source": "c:\\Users\\tintoy\\Desktop\\temp2.csproj",
            "message": "The element <PackageReference> beneath element <Project> is unrecognized."
        }
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants