OmniSharp / csharp-language-server-protocol

Language Server Protocol in C#
MIT License
512 stars 103 forks source link

Issue trying to implement codeAction/resolve in omnisharp-roslyn #511

Open razzmatazz opened 3 years ago

razzmatazz commented 3 years ago

I am sure I am missing something (maybe I just don't understand dynamic registration) but I am not able to implement codeAction/resolve in omnisharp-roslyn.

The first thing that makes me confused is why omnisharp-roslyn reports no codeActionProvider as response to initialize, as evidenced by this log:

[Trace - 01:25:24 PM] Received response 'initialize - (19)' in 768ms.
Result: {
  "serverInfo": {
    "version": "1.0.0+c802f8ea91d8ab24d07564c917d0bab8326b3f71",
    "name": "OmniSharp"
  },
  "capabilities": {
    "workspace": {
      "fileOperations": {
      },
      "workspaceFolders": {
        "changeNotifications": true,
        "supported": true
      }
    },
    "implementationProvider": {
    },
    "experimental": {
    },
    "executeCommandProvider": {
      "commands": [
        "omnisharp/executeCodeAction",
        "omnisharp/executeCodeAction"
      ]
    },
    "documentOnTypeFormattingProvider": {
      "moreTriggerCharacter": [
        "}",
        ")"
      ],
      "firstTriggerCharacter": ";"
    },
    "codeLensProvider": {
      "resolveProvider": true
    },
    "workspaceSymbolProvider": {
    },
    "documentSymbolProvider": {
    },
    "referencesProvider": {
    },
    "definitionProvider": {
    },
    "signatureHelpProvider": {
      "triggerCharacters": [
        ".",
        "?",
        "["
      ]
    },
    "completionProvider": {
      "triggerCharacters": [
        "."
      ]
    },
    "hoverProvider": {
    },
    "textDocumentSync": {
      "save": {
        "includeText": true
      },
      "change": 1,
      "openClose": true
    }
  }

Then I tried to implement codeAction/resolve support here:

But I really not sure if I am dabbling in the right direction, do we really need separate OmniSharpCodeActionResolveHandler or not -- and can I use data on CodeAction? -- it seems to be serialized properly though so I assume it is.

david-driscoll commented 3 years ago

So the registrations that is reported at initialization are static registrations only. If we return the registration data there, and then dynamically register as well, we end up with two registrations.

Some of the newer features support the ability to define the dynamic registrations statically and give them an id, that is not yet supported.