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

Merged
merged 1 commit into from
Jan 7, 2025

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.

@vinistock vinistock force-pushed the 11-29-index_documents_on_modification branch from e5b8c20 to 41fc7d4 Compare January 2, 2025 19:48
@andyw8
Copy link
Contributor

andyw8 commented Jan 6, 2025

Let's also update the docs to remove the part that begins "There is currently a technical limitation that code is only indexed when saved."

@vinistock vinistock force-pushed the 11-29-index_documents_on_modification branch from 41fc7d4 to d03faf8 Compare January 7, 2025 14:29
@vinistock vinistock merged commit cf1235e into main Jan 7, 2025
43 checks passed
Copy link
Member Author

Merge activity

  • Jan 7, 9:54 AM EST: A user merged this pull request with Graphite.

@vinistock vinistock deleted the 11-29-index_documents_on_modification branch January 7, 2025 14:54
vinistock added a commit that referenced this pull request Jan 9, 2025
…es (#3030)

### Motivation

One more bug fix to include in the next release 😅. In #2941, we started indexing unsaved files. However, we didn't fix the requests that were assuming the presence of a file path in entries with `T.must`.

We need to handle the possibility of there not being a file path, so that we can account for entries in unsaved files.

### Implementation

Fixed all of the occurrences I could find where we assumed the file path to be there.

### Automated Tests

Added tests that reproduce each one of the bugs.
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