Solargraph: Autocomplete stopped working for specific class

Created on 20 Jul 2019  路  39Comments  路  Source: castwide/solargraph

1

I have no idea why this happens. I already sent you the project file with reproducible sample via Email (_due to its private_).

Most helpful comment

The fix for documentation generation is published in v0.37.2.

All 39 comments

There's a minor issue with type inference during active editing. A fix is in the master branch and will be released in v0.35.0 tomorrow.

Hmm, it looks like there might be something else going on here. With the latest version, I still don't get type inference for the cnt variable. I'll keep looking.

It looks like the type inference problem was an artifact from another feature branch. I released gem 0.35.0 today. The reproducible sample works correctly in my tests.

@castwide I couldn't test this until now. No, unfortunately, not working. I installed 0.35.0 gem directly via bundler (not master branch) and also tested against master branch and both are not working for my case.

Is it possible you're not opening the folder that contains the files? If you open individual files but not their underlying workspace, completion will still work, but each file won't have access to the other's code.

(A future update should make it possible for main.rb to see container.rb through the require_relative call.)

I realized too it's not completing new keyword.

I realized too it's not completing new keyword.

Not just new. Lets say you have an acceptable sze of but large project. And you're working on a single but large class. its members get autocomplete lately. i had to trigger few times to get popup list properly.

I think I found the root cause. When a variable assignment's method call has arguments without parentheses, its type gets inferred from the wrong node. It should work if you put parentheses around the arguments:

cnt = Container.new(param1, param2)

I'm working on a fix. It's a little tricky due to a related issue with method calls that yield blocks, but I should be able to include it in the next patch release.

I realized too it's not completing new keyword.

Not just new. Lets say you have an acceptable sze of but large project. And you're working on a single but large class. its members get autocomplete lately. i had to trigger few times to get popup list properly.

I mean in all classes it's not completing keyword new.
@castwide I think that this is not hard to be done to make the extension detect classes ands adds new keyword to the list.

@minkir014 Please open a new issue and provide an example. The bug you're describing is unrelated to this one, and I'm not able to reproduce it.

@castwide I will wait for a fix on master branch because there are thousands of declarations like this. I cannot wrap them all at once :/

@gencer The fix is in the master branch. I'll probably release it in v0.35.1 this Friday.

Works here.
Thank you so much for quick fix.

Released in v0.35.1.

@castwide, Auto complete is so slow. Lets say I wrote;

class Abc
  def a_method
    return 1
  end

  def b_method
    a_ # <-- at this point if project is large, autocomplete does not shows up. I have to manually trigger via Ctrl+Space. I'm doing this always, because autocomplete is horribly slow.
  end
end

On small projects no problem at all. This happens on a large project (Especially the project files i already sent to you before.)

It was fast. It was working. Since last few release, its not.

At first I thought it might be an issue with type inference, but your example wouldn't trigger it at that point. I'll try to profile for bottlenecks.

One thing that might help, if you haven't done it, is limiting which files you include in your .solargraph.yml. More information: https://solargraph.org/guides/performance

I'll be glad if you can track it down.

As you can see there is also folder variable. Not just a method starts with folder_. And both not get listed.

1

When you see those snippets scroll down I think you will find variables you want. As I remember this happened to me with JavaScript and when I scrolled down and found my variables.

Nope.

Is that failed or no I don't understand you?

It does not list my variables and functions until I do Ctrl+space or wait for longer.

Issue here is not "Not listing". Issue here we are talking at the moment is slow response.

I get my variables and functions but with a huge delay and sometimes, I need to poke via ctrl+space.

Are you using more than one language server or completion provider?

Ruby (Solargraph) and TypeScript (internal) language servers are used and active on this workspace. I also disabled some rails auto-complete helpers. (And will disable more related and test)

1

I pressed Ctrl+space here. Not wait. If you wait there will be no auto-complete. So need to poke.

Can you give me a list of your extensions? (The issue is still likely to be in Solargraph itself, but I'd like to see if some other feature is exacerbating it.)

Sure, here:

aki77.rails-partial
aki77.rails-routes # disabled in workspace
alefragnani.project-manager
angryobject.react-pure-to-class-vscode
austin.code-gnu-global
bierner.markdown-preview-github-styles
bung87.rails # disabled in workspace
bung87.vscode-gemfile
bungcip.better-toml
capaj.vscode-exports-autocomplete
castwide.solargraph
ccimage.jsonviewer
christian-kohler.npm-intellisense
codezombiech.gitignore
dannymidnight.vscode-buildkite
dbaeumer.vscode-eslint
donjayamanne.githistory
eamodio.gitlens
eg2.vscode-npm-script
emilast.LogFileHighlighter
Equinusocio.vsc-material-theme
felixfbecker.php-debug
felixfbecker.php-intellisense
felixfbecker.php-pack
formulahendry.code-runner
gamunu.vscode-yarn
gencer.buildkite-ci-status
gencer.html-slim-scss-css-class-completion
GitHub.vscode-pull-request-github
golang.gopls
gottfired.css2react
hangxingliu.vscode-nginx-conf-hint
Hridoy.rails-snippets # disabled in workspace
IBM.output-colorizer
jduponchelle.rainbow-end
jpoissonnier.vscode-styled-components
kaiwood.endwise
karunamurti.haml
Kasik96.latte
kevinkyang.auto-comment-blocks
kodetech.electron-debug
mariusschulz.yarn-lock-syntax
mbessey.vscode-rufo
mblode.twig-language-2
michelemelluso.code-beautifier
mikestead.dotenv
mjmcloug.vscode-elixir
mkloubert.vscode-deploy-reloaded
mrmlnc.vscode-scss
ms-azuretools.vscode-docker
ms-mssql.mssql
ms-python.python
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-ssh-explorer
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remote-extensionpack
ms-vscode.cpptools
ms-vscode.github-issues-prs
ms-vscode.Go
ms-vscode.powershell
ms-vscode.vscode-typescript-tslint-plugin
msjsdiag.vscode-react-native
paulmolluzzo.convert-css-in-js
pavlitsky.yard
PKief.material-icon-theme
pranaygp.vscode-css-peek
quicktype.quicktype
raynigon.nginx-formatter
rebornix.ruby
redhat.vscode-yaml
robinbentley.sass-indented
rubbersheep.gi
rust-lang.rust
shanehofstetter.rails-i18n
shanoor.vscode-nginx
shinnn.stylelint
sianglim.slim
TheNouillet.symfony-vscode
wwm.better-align
yzhang.markdown-all-in-one

I've marked extensions that disabled. Also all extensions related to PHP also disabled.

I also disabled many extensions that "might" be affect responsiveness. Still slow.

Thanks. I'll see what profiling tells me.

One of the changes since 0.35 was to the library that Solargraph uses to convert documentation to Markdown. I didn't expect that to be the problem here, but now I think it might be. I ran some tests on a few different codebases and several of them encountered problems generating the Markdown.

The current master branch replaces the old conversion with a simpler one. As a result, sometimes unexpected markup will get rendered as plain text, such as these HTML tags in the String.new documentation:

image

I'd much prefer to convert them to Markdown, but it's easier said than done. There doesn't even appear to be a definitive standard for how Markdown should be rendered in LSP clients (e.g., discussion here and here). For the time being, I'd rather display the markup than sacrifice performance or reliability.

@castwide, there is a huge difference now. When I type something and press Ctrl+Space to get intellisense popup list, it list immediately -instantly-. Before your changes, even ctrl+space was so slow to list my autocomplete popup.

However, I still do not get anything when i write a local variable or local method. I discovered that it only happens on local items. For calling outside classes or methods are instant. Let me show you local variables and methods then i will call them on another file (class). See the difference.

  1. Local variable and method completion:

1

  1. Call variables and methods from other class. (and call other classes)

2
3

Could it be an issue with your editor.quickSuggestions setting? This is mine (which I think is also the default):

"editor.quickSuggestions": {
  "other": true,
  "comments": false,
  "strings": false
}

When other is false, autocompletion is triggered by dots, but not by letters. ctrl+space works as expected either way.

Nope. I do not use that option. But tried yours. No difference. Anything local is not triggered by letters. I need to do Ctrl+Space. Or dot ., underscore _ or starts with Uppercase (Like Rails, SecureRandom, Cont...).

I think not just local but anything starts with lowercase is not working. Even @ triggers.

See:

4

I hit Ctrl+Space at end of abort.


If I move that file to a new project (a workspace), it works. But with my current workspace, its not. Im gone crazy.

Does that workspace have a .vscode/settings.json file?

Yes, it only contains deploy related tasks.

Found it! This guy: https://github.com/shanehofstetter/rails-i18n-vscode

I will open an issue there.


Fred, I am so sorry for the trouble I made. I deeply sorry for taking your time on this.

Once again, I confirm that this is issue of rails-i18n-vscode related (or maybe solargraph do something i don't know). But disabling that extension solved all problems.

@castwide, may i ask just one simple more question regarding to autocomplete?

IntelliJ successfully shows me the correct suggestions but Solargraph fails to do that. You can try this on any environment:

SecureRandom.uu #> This should suggest "uuid"
SecureRandom.byt #> This should suggest "bytes" and methods starts with "bytes...".

This is just an example, there are more samples like this but this SecureRandom is the first thing that came to my mind. Is there a specific reason for this to not get listed?

And yeah, I did solargraph bundle

The problem is how the Ruby core composes the SecureRandom module. It should be extended with another module called Random::Formatter, but YARD doesn't find it.

If you add this code, it works:

require 'securerandom'
# @!parse
#   module SecureRandom
#     extend Random::Formatter
#   end

I should be able to fix it automatically from the gem. I'll look into it.

The fix for documentation generation is published in v0.37.2.

The fix for documentation generation is published in v0.37.2.

Thanks!

The problem is how the Ruby core composes the SecureRandom module. It should be extended with another module called Random::Formatter, but YARD doesn't find it.

If you add this code, it works:

require 'securerandom'
# @!parse
#   module SecureRandom
#     extend Random::Formatter
#   end

I should be able to fix it automatically from the gem. I'll look into it.

I put this to rails.rb on my workspace and worked very well. But there are more like this so internal fix will be great.

And congrats! This is 100th release :)

The latest versions of the core documentation include Random::Formatter in the SecureRandom module, so autocompletion finds the uuid method.

I'll close this issue since the original problem was resolved. If you run into any new issues with the updated documentation, please post a comment in #259.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

megalithic picture megalithic  路  3Comments

siumennel picture siumennel  路  5Comments

dewetblomerus picture dewetblomerus  路  5Comments

Sam-Killgallon picture Sam-Killgallon  路  5Comments

PyvesB picture PyvesB  路  4Comments