-
Notifications
You must be signed in to change notification settings - Fork 222
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
Fix string view index in UpdateFileContents() #2079
Fix string view index in UpdateFileContents() #2079
Conversation
When updating the parse buffers, make sure the old ones don't disappear while we still call the callbacks for everyone interested in the changes. They might've hold on to some data and expect the old one to be still viable when they get the update call. Add a unit test. Issues: #2078 While at it: update and refine documentation.
... needed later in verilog_project to unregeister string-view ranges. Issues: #2078
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2079 +/- ##
==========================================
+ Coverage 92.95% 92.99% +0.03%
==========================================
Files 358 358
Lines 26446 26465 +19
==========================================
+ Hits 24583 24611 +28
+ Misses 1863 1854 -9 ☔ View full report in Codecov by Sentry. |
verilog/analysis/verilog_project.h
Outdated
@@ -289,7 +291,7 @@ class VerilogProject { | |||
absl::string_view referenced_filename); | |||
|
|||
// Adds an already opened file by directly passing its content. | |||
// TODO(refactor): is this needed ? | |||
// TODO(refactor): is this needed ? (probaly yes in external kythe backends) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can drop TODO & "probably". This is indeed needed for the external Kythe backends
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
verilog/analysis/verilog_project.h
Outdated
// This can come from the .begin() of any entry in string_view_map_. | ||
std::map<absl::string_view::const_iterator, file_set_type::const_iterator> | ||
buffer_to_analyzer_map_; | ||
std::unique_ptr<ContentToFileIndex> content_index_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::optional
might be a better fit here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, done.
When files are updated and old ones removed, make sure that the corresponding index for the substring ranges is also updated. Move the data and logic needed for the substring index into its own class ContentToFileIndex. Since we _can_ removed string ranges now, we don't really have to choose anymore if we want to populate string view maps; still providing this feature for now, but calling it provide_lookup_file_origin, as this is what it provides. Make ParsedVerilogSourceFile take an Analyzer instead of a TextStructureView to better emphasize that this is essentially the same as the other VerilogSourceFiles, just with a non-owned Analyzer. This also allows to return the parse absl::Status instead of a potentially non-truthful ok(). Updating plumbing needed for the passing-an-analyzer. Add test for updating the project and verify that no stale string view index is kept (the original issue in #2078). Fixes: #2078
This fixes #2078.
Since some changes are somewhat independent, they are in three different commits.
This also fixes the misfeature that the string view index had to be disabled in cases the
VerilogProject
is used where it needs to remove files. So instead of a fractured class use, this is now merely a feature that can be enabled.