Skip to content

feat: add Rust language to seed list - #24

Merged
mattiacerutti merged 2 commits into
mattiacerutti:mainfrom
Sparticle62ops:feature/add-rust-language
Aug 3, 2026
Merged

feat: add Rust language to seed list#24
mattiacerutti merged 2 commits into
mattiacerutti:mainfrom
Sparticle62ops:feature/add-rust-language

Conversation

@Sparticle62ops

@Sparticle62ops Sparticle62ops commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

I really want Rust in code typer 🙏🙏

Adds Rust to the supported languages list so the seeder can fetch and populate Rust snippets from GitHub. This enables Rust in the language picker and game.

Summary by CodeRabbit

  • New Features
    • Added Rust language support, including .rs file recognition, syntax highlighting, and improved parsing of Rust syntax.
  • Bug Fixes
    • Duplicate files encountered during setup are now skipped so processing can continue.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Changes

Rust language support

Layer / File(s) Summary
Rust runtime and language wiring
prisma/seed/languages.ts, package.json, next.config.ts, lib/snippets/parsing/parser-factory.ts
Adds Rust language metadata, the tree-sitter-rust dependency, server external configuration, and parser-factory dispatch.
Rust-specific range extraction
src/features/snippets/logic/parsing/snippet-parser.server.ts
Adds dedicated extraction for Rust comments, lifetimes, loop labels, and string or character literals.

Seed duplicate handling

Layer / File(s) Summary
Duplicate file insertion handling
prisma/seed/files.ts
Skips duplicate file records with a warning, bypasses file-version creation when insertion is skipped, and rethrows other database errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • mattiacerutti/code-typer#11: Adds Tree-sitter support for another language through similar metadata, dependency, external-package, and parser-factory updates.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding Rust to the supported language seed list.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mattiacerutti
mattiacerutti merged commit 528e5f6 into mattiacerutti:main Aug 3, 2026
3 of 4 checks passed
@mattiacerutti

Copy link
Copy Markdown
Owner

Thanks for the PR!

@mattiacerutti mattiacerutti mentioned this pull request Aug 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/features/snippets/logic/parsing/snippet-parser.server.ts (1)

23-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression tests for the Rust disabled ranges.

Cover line comments, block comments, lifetimes, loop labels, normal strings, raw strings, byte-prefixed literals, character literals, escaped delimiters, and empty literals. Include exact startIndex/endIndex expectations with delimiter exclusion and the same endpoint convention used by getRandomSnippets().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/snippets/logic/parsing/snippet-parser.server.ts` around lines 23
- 42, Add regression tests for the Rust-specific range handling in the parser
around the existing getRandomSnippets() behavior. Cover line_comment,
block_comment, lifetime, loop_label, string_literal, raw_string_literal,
byte-prefixed literals, char_literal, escaped delimiters, and empty literals,
asserting exact startIndex/endIndex values with delimiters excluded and matching
getRandomSnippets()’s endpoint convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@prisma/seed/files.ts`:
- Around line 75-81: Update the file seeding flow around fileVersion.create and
the final summary log to track successfully seeded files separately from
files.length. Initialize a counter before processing, increment it only after
fileVersion.create succeeds, and report that counter so duplicate files
returning null are excluded.

---

Nitpick comments:
In `@src/features/snippets/logic/parsing/snippet-parser.server.ts`:
- Around line 23-42: Add regression tests for the Rust-specific range handling
in the parser around the existing getRandomSnippets() behavior. Cover
line_comment, block_comment, lifetime, loop_label, string_literal,
raw_string_literal, byte-prefixed literals, char_literal, escaped delimiters,
and empty literals, asserting exact startIndex/endIndex values with delimiters
excluded and matching getRandomSnippets()’s endpoint convention.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ea0112f2-f2bd-491d-9f64-93ce898cabdc

📥 Commits

Reviewing files that changed from the base of the PR and between 473e095 and 262a02c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • lib/snippets/parsing/parser-factory.ts
  • next.config.ts
  • package.json
  • prisma/seed/files.ts
  • src/features/snippets/logic/parsing/snippet-parser.server.ts

Comment thread prisma/seed/files.ts
Comment on lines +75 to +81
console.warn(`Skipping duplicate file: ${file.repository}/${file.path}`);
return null;
}
throw error;
});

if (!insertedFile) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Report the number of files that were actually seeded.

When a duplicate returns null, this branch skips the file. The final log at Line 92 still reports files.length, so it counts skipped files as seeded files. Track a counter and increment it only after fileVersion.create succeeds.

Proposed fix
+  let seededCount = 0;
   for (const file of files) {
     ...
     await prisma.fileVersion.create({
       ...
     });
+    seededCount += 1;
   }

-  console.log(`Seeded ${files.length} files for language: ${language.name}`);
+  console.log(`Seeded ${seededCount} files for language: ${language.name}`);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@prisma/seed/files.ts` around lines 75 - 81, Update the file seeding flow
around fileVersion.create and the final summary log to track successfully seeded
files separately from files.length. Initialize a counter before processing,
increment it only after fileVersion.create succeeds, and report that counter so
duplicate files returning null are excluded.

@Sparticle62ops

Copy link
Copy Markdown
Contributor Author

Thanks for adding it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants