Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index documents on modification #2941

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Nov 29, 2024

Motivation

Closes #1908

This PR starts indexing files upon modification in addition to on saves.

Implementation

The idea is to use the declaration listener together with all of the other listeners, so that we collect declaration changes within the same AST traversal. This allows us to catch any declaration modifications made before saving a file.

The biggest concern with this change is performance, but I think the next PR in this stack is doing a decent job at minimizing reindexes.

Automated Tests

Added tests.

Copy link
Member Author

vinistock commented Nov 29, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock added server This pull request should be included in the server gem's release notes enhancement New feature or request labels Nov 29, 2024 — with Graphite App
@vinistock vinistock marked this pull request as ready for review November 29, 2024 21:38
@vinistock vinistock requested a review from a team as a code owner November 29, 2024 21:38
@vinistock vinistock force-pushed the 11-29-index_documents_on_modification branch from 41cc250 to 826bd1a Compare November 29, 2024 21:51
lib/ruby_indexer/lib/ruby_indexer/index.rb Outdated Show resolved Hide resolved
lib/ruby_indexer/lib/ruby_indexer/index.rb Outdated Show resolved Hide resolved
lib/ruby_indexer/lib/ruby_indexer/index.rb Outdated Show resolved Hide resolved
lib/ruby_indexer/test/index_test.rb Show resolved Hide resolved
@vinistock vinistock force-pushed the 11-29-index_documents_on_modification branch from 826bd1a to 2251c9d Compare December 10, 2024 16:06
@vinistock vinistock requested a review from st0012 December 10, 2024 16:07
@andyw8
Copy link
Contributor

andyw8 commented Dec 10, 2024

Nice!

I did notice an issue while testing:

module Bar
  def abc
  end
end

class Foo
  extend Bar
end

Foo.abc

If you remove the extend, Foo will still offer completion with abc, even after saving. (On main it works correctly).

@vinistock vinistock force-pushed the 11-29-index_documents_on_modification branch from 2251c9d to e5b8c20 Compare December 10, 2024 19:55
Copy link
Member Author

@andyw8 good catch. I updated the code to handle ancestor invalidation too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make completions available for newly-added symbols in unsaved files
3 participants