ballerina-platform / lsp4intellij

This language client library provides language server protocol support for IntelliJ IDEA and other Jetbrains IDEs.
Apache License 2.0
428 stars 104 forks source link

Fix for null resolveProvider in codeAction #375

Closed fsommar closed 1 month ago

fsommar commented 1 month ago

The resolveProvider field doesn't need to be present even if the codeAction param is.

From the specification:

export interface CodeActionOptions extends WorkDoneProgressOptions {
    /**
     * CodeActionKinds that this server may return.
     *
     * The list of kinds may be generic, such as `CodeActionKind.Refactor`,
     * or the server may list out every specific kind they provide.
     */
    codeActionKinds?: CodeActionKind[];

    /**
     * The server provides support to resolve additional
     * information for a code action.
     *
     * @since 3.16.0
     */
    resolveProvider?: boolean;
}
CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.

nixel2007 commented 1 month ago

BTW why the left part of Either is not checked?

fsommar commented 1 month ago

BTW why the left part of Either is not checked?

I think it's fair to assume that the resolve provider is false if no options are being passed; either codeAction is enabled with a boolean for the most basic support, or options are provided where additional functionality like codeAction.resolve can be enabled.

Specification https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionOptions

nixel2007 commented 1 month ago

But it can be disabled with the boolean as well

fsommar commented 1 month ago

But it can be disabled with the boolean as well

I'll use examples to illustrate how I'm thinking:

  1. {
    "codeAction": true
    }
  2. {
    "codeAction": {
    "resolveProvider": true
    }
    }
  3. {
    "codeAction": {
    "resolveProvider": false
    }
    }
  4. {
    "codeAction": {}
    }
  5. {
    "codeAction": false
    }
  6. {}

# codeAction codeAction.resolve
1 true false
2 true true
3 true false
4 true false
5 false false
6 false false

If you're referring to 5., it will be false for codeAction.resolve since provider != null && provider.isRight() will be false.

nixel2007 commented 1 month ago

Oh, sorry, I missed that this method is about codeActionResolve and not codeAction itself. Yes, you are right and everything is correct