tintoy / msbuild-project-tools-vscode

VS Code extension for MSBuild intellisense (including PackageReference completion).
MIT License
82 stars 17 forks source link

Server Not Initialized Error #12

Closed LucasBullen closed 6 years ago

LucasBullen commented 6 years ago

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 commented 6 years ago

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

LucasBullen commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Cheers, that'd be great.

tintoy commented 6 years ago

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 commented 6 years ago

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

LucasBullen commented 6 years ago

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

tintoy commented 6 years ago

Cheers - I have tests that are ready for Unix line endings but haven't added non-Windows test data yet.

On Wed, 20 Sep. 2017, 10:10 pm Lucas Bullen notifications@github.com wrote:

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

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/tintoy/msbuild-project-tools-vscode/issues/12#issuecomment-330832144, or mute the thread https://github.com/notifications/unsubscribe-auth/ABkezPv7FEFP8kQNVvu0H_Am9ZcZf56_ks5skQDJgaJpZM4PU_8s .

LucasBullen commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago
<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 commented 6 years ago

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

tintoy commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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."
        }
    ]
}