rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.31k stars 1.62k forks source link

no `additionalTextEdits` information in `completionItem/resolve` anymore #18496

Closed ensc closed 1 day ago

ensc commented 1 week ago

Recent rust-analyzer versions do not seem to output additionalTextEdits information anymore. Neither in textDocument/completion nor the corresponding completionItem/resolve request.

E.g. when asking for completion of HashMap in

Image

I expect that use std::collections::HashMap is also added to the code. This happened with previous rust-analyzer versions (e.g. rust-analyzer 1.83.0-nightly (55a22d2 2024-10-06) but stopped with the recent ones.

The i/o logs show empty "additionalTextEdits": [], fields in the completion and resolve response.

initialize

request
{
  "processId": 94364,
  "rootPath": "/tmp/test1",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0)\n of 2024-10-10"
  },
  "rootUri": "file:///tmp/test1",
  "capabilities": {
    "general": {
      "positionEncodings": [
        "utf-32",
        "utf-16"
      ]
    },
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true,
      "codeLens": {
        "refreshSupport": true
      },
      "diagnostics": {
        "refreshSupport": false
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": true,
        "willRename": true,
        "didDelete": false,
        "willDelete": false
      }
    },
    "textDocument": {
      "declaration": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "definition": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "references": {
        "dynamicRegistration": true
      },
      "implementation": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "typeDefinition": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "symbolKind": {
          "valueSet": [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "onTypeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "detail",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true,
        "dynamicRegistration": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        },
        "dynamicRegistration": true
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ],
        "dynamicRegistration": true
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "selectionRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "typeHierarchy": {
        "dynamicRegistration": true
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "diagnostic": {
        "dynamicRegistration": false,
        "relatedDocumentSupport": false
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showDocument": {
        "support": true
      }
    },
    "experimental": {
      "snippetTextEdit": true,
      "commands": {
        "commands": [
          "rust-analyzer.runSingle",
          "rust-analyzer.debugSingle",
          "rust-analyzer.showReferences",
          "rust-analyzer.triggerParameterHints"
        ]
      }
    }
  },
  "initializationOptions": {
    "diagnostics": {
      "enable": true,
      "enableExperimental": false,
      "disabled": [],
      "warningsAsHint": [],
      "warningsAsInfo": []
    },
    "imports": {
      "granularity": {
        "enforce": false,
        "group": "crate"
      },
      "group": true,
      "merge": {
        "glob": true
      },
      "prefix": "plain"
    },
    "lruCapacity": null,
    "checkOnSave": {
      "enable": true,
      "command": "check",
      "extraArgs": [],
      "allTargets": true,
      "overrideCommand": []
    },
    "highlightRelated": {
      "breakPoints": {
        "enable": true
      },
      "closureCaptures": {
        "enable": true
      },
      "exitPoints": {
        "enable": true
      },
      "references": {
        "enable": true
      },
      "yieldPoints": {
        "enable": true
      }
    },
    "files": {
      "exclude": [],
      "watcher": "client",
      "excludeDirs": []
    },
    "cargo": {
      "allFeatures": false,
      "noDefaultFeatures": false,
      "features": [],
      "extraArgs": [],
      "extraEnv": [],
      "target": null,
      "runBuildScripts": true,
      "loadOutDirsFromCheck": true,
      "autoreload": true,
      "useRustcWrapperForBuildScripts": true,
      "unsetTest": []
    },
    "rustfmt": {
      "extraArgs": [],
      "overrideCommand": [],
      "rangeFormatting": {
        "enable": false
      }
    },
    "lens": {
      "debug": {
        "enable": true
      },
      "enable": true,
      "implementations": {
        "enable": true
      },
      "references": {
        "adt": {
          "enable": false
        },
        "enumVariant": {
          "enable": false
        },
        "method": {
          "enable": false
        },
        "trait": {
          "enable": false
        }
      },
      "run": {
        "enable": true
      }
    },
    "inlayHints": {
      "bindingModeHints": {
        "enable": false
      },
      "chainingHints": {
        "enable": false
      },
      "closingBraceHints": {
        "enable": true,
        "minLines": 25
      },
      "closureCaptureHints": {
        "enable": false
      },
      "closureReturnTypeHints": {
        "enable": "never"
      },
      "closureStyle": "impl_fn",
      "discriminantHints": {
        "enable": "never"
      },
      "expressionAdjustmentHints": {
        "enable": "never",
        "hideOutsideUnsafe": false,
        "mode": "prefix"
      },
      "implicitDrops": {
        "enable": false
      },
      "lifetimeElisionHints": {
        "enable": "never",
        "useParameterNames": false
      },
      "maxLength": null,
      "parameterHints": {
        "enable": false
      },
      "reborrowHints": {
        "enable": "never"
      },
      "renderColons": true,
      "typeHints": {
        "enable": false,
        "hideClosureInitialization": false,
        "hideNamedConstructor": false
      }
    },
    "completion": {
      "addCallParenthesis": true,
      "addCallArgumentSnippets": true,
      "postfix": {
        "enable": true
      },
      "autoimport": {
        "enable": true
      },
      "autoself": {
        "enable": true
      }
    },
    "callInfo": {
      "full": true
    },
    "procMacro": {
      "enable": true
    },
    "rustcSource": null,
    "linkedProjects": [],
    "highlighting": {
      "strings": true
    },
    "experimental": {
      "procAttrMacros": true
    }
  },
  "workDoneToken": "1"
}
response
{
  "capabilities": {
    "positionEncoding": "utf-32",
    "textDocumentSync": {
      "openClose": true,
      "change": 2,
      "save": null
    },
    "selectionRangeProvider": true,
    "hoverProvider": true,
    "completionProvider": {
      "resolveProvider": true,
      "triggerCharacters": [
        ":",
        ".",
        "'",
        "("
      ],
      "completionItem": {
        "labelDetailsSupport": null
      }
    },
    "signatureHelpProvider": {
      "triggerCharacters": [
        "(",
        ",",
        "<"
      ]
    },
    "definitionProvider": true,
    "typeDefinitionProvider": true,
    "implementationProvider": true,
    "referencesProvider": true,
    "documentHighlightProvider": true,
    "documentSymbolProvider": true,
    "workspaceSymbolProvider": true,
    "codeActionProvider": {
      "codeActionKinds": [
        "",
        "quickfix",
        "refactor",
        "refactor.extract",
        "refactor.inline",
        "refactor.rewrite"
      ],
      "resolveProvider": true
    },
    "codeLensProvider": {
      "resolveProvider": true
    },
    "documentFormattingProvider": true,
    "documentRangeFormattingProvider": null,
    "documentOnTypeFormattingProvider": {
      "firstTriggerCharacter": "=",
      "moreTriggerCharacter": [
        ".",
        ">",
        "{",
        "(",
        "<"
      ]
    },
    "renameProvider": {
      "prepareProvider": true
    },
    "foldingRangeProvider": true,
    "declarationProvider": true,
    "workspace": {
      "workspaceFolders": {
        "supported": true,
        "changeNotifications": true
      },
      "fileOperations": {
        "willRename": {
          "filters": [
            {
              "scheme": "file",
              "pattern": {
                "glob": "**/*.rs",
                "matches": "file"
              }
            },
            {
              "scheme": "file",
              "pattern": {
                "glob": "**",
                "matches": "folder"
              }
            }
          ]
        }
      }
    },
    "callHierarchyProvider": true,
    "semanticTokensProvider": {
      "legend": {
        "tokenTypes": [
          "comment",
          "decorator",
          "enumMember",
          "enum",
          "function",
          "interface",
          "keyword",
          "macro",
          "method",
          "namespace",
          "number",
          "operator",
          "parameter",
          "property",
          "string",
          "struct",
          "typeParameter",
          "variable",
          "angle",
          "arithmetic",
          "attributeBracket",
          "attribute",
          "bitwise",
          "boolean",
          "brace",
          "bracket",
          "builtinAttribute",
          "builtinType",
          "character",
          "colon",
          "comma",
          "comparison",
          "constParameter",
          "const",
          "deriveHelper",
          "derive",
          "dot",
          "escapeSequence",
          "formatSpecifier",
          "generic",
          "invalidEscapeSequence",
          "label",
          "lifetime",
          "logical",
          "macroBang",
          "parenthesis",
          "procMacro",
          "punctuation",
          "selfKeyword",
          "selfTypeKeyword",
          "semicolon",
          "static",
          "toolModule",
          "typeAlias",
          "union",
          "unresolvedReference"
        ],
        "tokenModifiers": [
          "async",
          "documentation",
          "declaration",
          "static",
          "defaultLibrary",
          "associated",
          "attribute",
          "callable",
          "constant",
          "consuming",
          "controlFlow",
          "crateRoot",
          "injected",
          "intraDocLink",
          "library",
          "macro",
          "mutable",
          "procMacro",
          "public",
          "reference",
          "trait",
          "unsafe"
        ]
      },
      "range": true,
      "full": {
        "delta": true
      }
    },
    "inlayHintProvider": {
      "resolveProvider": true
    },
    "diagnosticProvider": {
      "interFileDependencies": true,
      "workspaceDiagnostics": null
    },
    "experimental": {
      "externalDocs": true,
      "hoverRange": true,
      "joinLines": true,
      "matchingBrace": true,
      "moveItem": true,
      "onEnter": true,
      "openCargoToml": true,
      "parentModule": true,
      "runnables": {
        "kinds": [
          "cargo"
        ]
      },
      "ssr": true,
      "workspaceSymbolScopeKindFiltering": true
    }
  },
  "serverInfo": {
    "name": "rust-analyzer",
    "version": "1.84.0-nightly (b91a3a0 2024-11-07)"
  }
}

textDocument/completion request

request
{
  "textDocument": {
    "uri": "file:///tmp/test1/src/main.rs"
  },
  "position": {
    "line": 1,
    "character": 11
  },
  "context": {
    "triggerKind": 3
  }
}
response
{
  "isIncomplete": true,
  "items": [
    {
      "label": "HashMap (use std::collections::HashMap)",
      "kind": 22,
      "deprecated": null,
      "sortText": "80000000",
      "filterText": "HashMap",
      "textEdit": {
        "newText": "HashMap",
        "insert": {
          "start": {
            "line": 1,
            "character": 4
          },
          "end": {
            "line": 1,
            "character": 11
          }
        },
        "replace": {
          "start": {
            "line": 1,
            "character": 4
          },
          "end": {
            "line": 1,
            "character": 11
          }
        }
      },
      "additionalTextEdits": [],
      "data": {
        "position": {
          "textDocument": {
            "uri": "file:///tmp/test1/src/main.rs"
          },
          "position": {
            "line": 1,
            "character": 11
          }
        },
        "imports": [
          {
            "full_import_path": "std::collections::HashMap",
            "imported_name": "HashMap"
          }
        ],
        "version": 60,
        "trigger_character": null
      }
    },
    ...
  ]
}

completionItem/resolve request

request
{
  "label": "HashMap (use std::collections::HashMap)",
  "kind": 22,
  "deprecated": null,
  "sortText": "80000000",
  "filterText": "HashMap",
  "textEdit": {
    "newText": "HashMap",
    "insert": {
      "start": {
        "line": 1,
        "character": 4
      },
      "end": {
        "line": 1,
        "character": 11
      }
    },
    "replace": {
      "start": {
        "line": 1,
        "character": 4
      },
      "end": {
        "line": 1,
        "character": 11
      }
    }
  },
  "additionalTextEdits": [],
  "data": {
    "position": {
      "textDocument": {
        "uri": "file:///tmp/test1/src/main.rs"
      },
      "position": {
        "line": 1,
        "character": 11
      }
    },
    "imports": [
      {
        "full_import_path": "std::collections::HashMap",
        "imported_name": "HashMap"
      }
    ],
    "version": 14,
    "trigger_character": null
  }
}
response
{
  "label": "HashMap (use std::collections::HashMap)",
  "kind": 22,
  "sortText": "80000000",
  "filterText": "HashMap",
  "textEdit": {
    "newText": "HashMap",
    "insert": {
      "start": {
        "line": 1,
        "character": 4
      },
      "end": {
        "line": 1,
        "character": 11
      }
    },
    "replace": {
      "start": {
        "line": 1,
        "character": 4
      },
      "end": {
        "line": 1,
        "character": 11
      }
    }
  },
  "additionalTextEdits": []
}

rust-analyzer version: rust-analyzer 1.84.0-nightly (b91a3a0 2024-11-07)

rustc version: rustc 1.84.0-nightly (b91a3a056 2024-11-07)

editor or extension: emacs + lsp-mode

relevant settings: none; seen with lsp-start-plain

filipwiech commented 1 week ago

Paging @SomeoneToIgnore. 😉

SomeoneToIgnore commented 1 week ago

I believe this should be fixed by https://github.com/rust-lang/rust-analyzer/pull/18503 as my tests during that PR had brought the imports.

Can you please retest a newer r-a nightly and see if it had improved things for you?

ensc commented 1 day ago

solved in recent r-a; thx