emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.8k stars 893 forks source link

lsp-python-ms uses xref-find-references error: The path is empty. (Parameter ’path’) #1547

Closed lyjdwh closed 4 years ago

lyjdwh commented 4 years ago

Describe the bug When using lsp-python-ms, I run the command xref-find-references emacs shows: eror The path is empty. (Parameter ’path’) When using pyls, it 's all ok.

To Reproduce In a python file, use lsp-python-ms and run the command xref-find-references or lsp-ui-peek-find-references

Expected behavior list all the references

Which Language Server did you use lsp-python-ms-20200223.2136 languageServer.0.5.45

OS manjaro kde spacemacs

Error callstack

Debugger entered--Lisp error: (error "The path is empty. (Parameter ’path’)")
  signal(error ("The path is empty. (Parameter ’path’)"))
  error("The path is empty. (Parameter 'path')")
  lsp-request("textDocument/references" (:textDocument (:uri "file:///home/liuyan/test/test.py") :position (:line 43 :character 0) :context (:includeDeclaration :json-false)))
  #f(compiled-function (backend identifier) #<bytecode 0x3af4e6d>)(xref-lsp #("hello" 0 5 (fontified t identifier-at-point t)))
  apply(#f(compiled-function (backend identifier) #<bytecode 0x3af4e6d>) xref-lsp #("hello" 0 5 (fontified t identifier-at-point t)))
  xref-backend-references(xref-lsp #("hello" 0 5 (fontified t identifier-at-point t)))
  xref--find-xrefs(#("hello" 0 5 (fontified t identifier-at-point t)) references #("hello" 0 5 (fontified t identifier-at-point t)) nil)
  xref-find-references(#("hello" 0 5 (fontified t identifier-at-point t)))
  funcall-interactively(xref-find-references #("hello" 0 5 (fontified t identifier-at-point t)))
  call-interactively(xref-find-references record nil)
  command-execute(xref-find-references record)
  counsel-M-x-action("xref-find-references")
  ivy-call()
  ivy-read("M-x " ("xref-find-references" "lsp-ui-peek-find-references" "toggle-debug-on-error" "lsp-ui-peek-jump-forward" "lsp-ui-peek-find-implementation" "lsp-ui-peek-enable" "lsp-describe-session" "lsp-ui-peek-find-workspace-symbol" "package-install" "zilongshanren/counsel-imenu" "company-tabnine" "lsp" "org-protocol-create" "helm-filtered-bookmarks" "link-hint-open-link" "eaf-open-browser" "eaf-open-bookmark" "eaf-open-external" "eaf-open-camera" "eaf-kill-process" "eaf-mode" "eaf-edit-buffer-switch-to-org-mode" "snails" "configuration-layer/describe-package" "spacemacs/deft" "terminal-here-project-launch" "terminal-here-launch" "terminal-here" "my-git-timemachine" "flyspell-mode" "ivy-yasnippet" "counsel-imenu" "flycheck-mode" "customize-group" "flycheck-verify-setup" "counsel-load-theme" "pdf-view-mode" "rotate-text" "company-mode" "eaf-open-demo" "eaf-open" "evilmi-select-items" "align-regexp" "eaf--kill-python-process" "markdown-preview" "eaf-open-terminal" "markdown-live-preview-mode" "grep-mode" "edebug-defun" "flymake-mode" ...) :predicate #f(compiled-function (x) #<bytecode 0x2a85c61>) :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)
yyoncho commented 4 years ago

Can you provide file to reproduce the issue with?

lyjdwh commented 4 years ago

Can you provide file to reproduce the issue with?

Any python file that has function/variable/class references in my case!

lyjdwh commented 4 years ago

When I set lsp-log-io to t and run the command lsp-find-references ,then I get this! It seems the argument that lsp sends to Microsoft LanguageServer is not right!

[Trace - 07:50:17 下午] Sending request 'textDocument/references - (215)'.
Params: {
  "textDocument": {
    "uri": "file:///home/liuyan/test/test.py"
  },
  "position": {
    "line": 9,
    "character": 3
  },
  "context": {
    "includeDeclaration": false
  }
}

[Trace - 07:50:17 下午] Received notification 'telemetry/event'.
Params: {
  "Measurements": {
    "elapsedMs": 1.3763
  },
  "Properties": {
    "plsVersion": "0.5.45.0",
    "method": "textDocument/references"
  },
  "EventName": "python_language_server/rpc.request"
}

[Trace - 07:50:17 下午] Received notification 'telemetry/event'.
Params: {
  "Measurements": {
  },
  "Properties": {
    "plsVersion": "0.5.45.0",
    "method": "textDocument/references",
    "stackTrace": "   at System.IO.Path.GetFullPath(String path)\n   at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)\n   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)\n   at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)\n   at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)\n   at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)\n   at Microsoft.Python.Core.IO.FileSystem.GetFiles(String path, String pattern, SearchOption option) in E:\\A\\_work\\1\\s\\src\\Core\\Impl\\IO\\FileSystem.cs:line 58\n   at Microsoft.Python.LanguageServer.Sources.ReferenceSource.ScanClosedFiles(String name, CancellationToken cancellationToken) in E:\\A\\_work\\1\\s\\src\\LanguageServer\\Impl\\Sources\\ReferenceSource.cs:line 117\n   at Microsoft.Python.LanguageServer.Sources.ReferenceSource.FindAllReferencesAsync(String name, IPythonModule declaringModule, ILocatedMember rootDefinition, SourceLocation location, DefinitionSource definitionSource, CancellationToken cancellationToken) in E:\\A\\_work\\1\\s\\src\\LanguageServer\\Impl\\Sources\\ReferenceSource.cs:line 82\n   at Microsoft.Python.LanguageServer.Sources.ReferenceSource.FindAllReferencesAsync(Uri uri, SourceLocation location, ReferenceSearchOptions options, CancellationToken cancellationToken) in E:\\A\\_work\\1\\s\\src\\LanguageServer\\Impl\\Sources\\ReferenceSource.cs:line 75\n   at Microsoft.Python.LanguageServer.Implementation.LanguageServer.FindReferences(JToken token, CancellationToken cancellationToken) in E:\\A\\_work\\1\\s\\src\\LanguageServer\\Impl\\LanguageServer.cs:line 210",
    "name": "ArgumentException"
  },
  "EventName": "python_language_server/rpc.exception"
}

[Trace - 07:50:17 下午] Received response 'textDocument/references - (215)' in 9ms.
Result: null

[Trace - 07:50:17 下午] Sending notification '$/cancelRequest'.
Params: {
  "id": 215
}
lyjdwh commented 4 years ago

After I reinstall my spacemacs, the problem disappears!