Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ruby: add support for extracting overlay databases#19684

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nickrolfe merged 5 commits intomainfromnickrolfe/ruby-overlay-extraction
Jun 25, 2025

Conversation

nickrolfe
Copy link
Contributor

There will need to be followup changes on the QL side before querying will work, but this is enough to be able to build an overlay database for Ruby.

@github-actionsgithub-actionsbot added QL-for-QL RustPull requests that update Rust code labelsJun 6, 2025
@nickrolfenickrolfeforce-pushed thenickrolfe/ruby-overlay-extraction branch 2 times, most recently from33c2550 tofb89f22CompareJune 6, 2025 14:03
@nickrolfenickrolfe marked this pull request as ready for reviewJune 10, 2025 16:45
@CopilotCopilotAI review requested due to automatic review settingsJune 10, 2025 16:45
@nickrolfenickrolfe requested review froma team ascode ownersJune 10, 2025 16:45
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR adds support for overlay database extraction in Ruby by introducing a newdatabaseMetadata relation and path‐prefix transformation logic.

  • Introduces a--add-metadata-relation flag to the shared extractor generator and implementscreate_database_metadata().
  • AddsPathTransformer andnormalize_and_transform_path in the shared extractor for prefix rewrites.
  • Updates the Ruby extractor to skip unchanged files, load overlay changes, apply path transformations, and emit an empty base‐metadata file.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
shared/tree-sitter-extractor/src/generator/mod.rsAddedadd_metadata_relation flag andcreate_database_metadata
shared/tree-sitter-extractor/src/file_paths.rsImplementedPathTransformer,load_path_transformer, and path normalization with transformation
shared/tree-sitter-extractor/src/extractor/*.rsPropagated transformer through file population and trap writing
ruby/ql/lib/ruby.dbschemeAdded newdatabaseMetadata relation definition
config/dbscheme-fragments.jsonRegistered theDatabase metadata fragment
ruby/extractor/src/extractor.rsAdded overlay‐change filtering, transformer usage, and metadata output
ruby/extractor/src/generator.rsEnabled metadata relation in the Ruby generator
Comments suppressed due to low confidence (1)

ruby/extractor/src/extractor.rs:347

  • [nitpick] Newget_overlay_changed_files logic andload_path_transformer are not covered by existing tests. Consider adding unit tests for parsing the JSON changes file and path transformation behavior.
fn get_overlay_changed_files() -> Option<HashSet<PathBuf>> {

Comment on lines 364 to 370
.map(|change| {
change
.as_str()
.map(|s| PathBuf::from(s).canonicalize().ok())
.flatten()
})
.collect()
Copy link
Preview

CopilotAIJun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Collecting an iterator ofOption<PathBuf> will not produceHashSet<PathBuf>. You should usefilter_map to dropNone entries and wrap the resultingHashSet inSome(...) before returning.

Suggested change
.map(|change|{
change
.as_str()
.map(|s|PathBuf::from(s).canonicalize().ok())
.flatten()
})
.collect()
.filter_map(|change|{
change
.as_str()
.and_then(|s|PathBuf::from(s).canonicalize().ok())
})
.collect::<HashSet<PathBuf>>()
.into()

Copilot uses AI. Check for mistakes.

@nickrolfenickrolfeforce-pushed thenickrolfe/ruby-overlay-extraction branch 2 times, most recently from576f0d2 to4029b89CompareJune 11, 2025 11:45
@nickrolfe
Copy link
ContributorAuthor

@aibaars do you have capacity to review this?

Copy link
Contributor

@aibaarsaibaars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks fine to me. A few comments though. I think it would be fine to add the new features to all extractors .

@@ -32,6 +33,16 @@ pub fn generate(

writeln!(dbscheme_writer, include_str!("prefix.dbscheme"))?;

// Eventually all languages will have the metadata relation (for overlay support), at which
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we can just shove the metadata tables directly inprefix.dbscheme. An unused table shouldn't hurt.

@@ -212,7 +212,7 @@ impl TrapFile {
);
}
pub fn emit_file(&mut self, absolute_path: &Path) -> Label<generated::File> {
let untyped = extractor::populate_file(&mut self.writer, absolute_path);
let untyped = extractor::populate_file(&mut self.writer, absolute_path, None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would just add support for path transformers to the Rust extractor.

@@ -15,7 +15,7 @@ impl Archiver {
}

fn try_archive(&self, source: &Path) -> std::io::Result<()> {
let dest = file_paths::path_for(&self.root, source, "");
let dest = file_paths::path_for(&self.root, source, "", None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would just add support for path transformers to the Rust extractor.

.filter(|line| !line.is_empty())
.collect::<Vec<String>>();

if lines.len() != 2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How hard would it be to just implement path transformers completely?

@nickrolfenickrolfeforce-pushed thenickrolfe/ruby-overlay-extraction branch from4029b89 tofa24ee6CompareJune 19, 2025 14:57
@nickrolfe
Copy link
ContributorAuthor

I've force-pushed a couple of the suggested fixes. Regarding the others:

  • prefix.dbscheme: since this will change the QL-for-QL dbscheme, I'll do it as a quick follow-up PR. That way, if any issues arise, it can be reverted without affecting Ruby overlay support.
  • similarly, I'll add the Rust path-transformer support as a separate PR.
  • for implementing full path-transformer support, I don't think it would be anenormous amount of work to port either the existing Java or C++ implementations, along with their unit tests, but it's probably enough work that we discussed within our team and decided not to do it (since it's not on the critical path for overlay support).

This is required for overlay support.
Supports only a minimal subset of the project layout specification;enough to work with the transformers produced by the CLI when buildingan overlay database.
@nickrolfenickrolfeforce-pushed thenickrolfe/ruby-overlay-extraction branch fromfa24ee6 to665df4bCompareJune 19, 2025 15:34
aibaars
aibaars previously approved these changesJun 23, 2025
The previous implementation returned None if any of the paths in thechanges JSON couldn't be canonicalized. This could happen for files thatwere deleted in the diff. Now, it just ignores paths for whichcanonicalize() fails.
@nickrolfenickrolfe merged commit1bbba2f intomainJun 25, 2025
67 checks passed
@nickrolfenickrolfe deleted the nickrolfe/ruby-overlay-extraction branchJune 25, 2025 10:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@aibaarsaibaarsaibaars approved these changes

Assignees

@aibaarsaibaars

Labels
QL-for-QLRubyRustPull requests that update Rust code
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@nickrolfe@aibaars

[8]ページ先頭

©2009-2025 Movatter.jp