Skip to content

Cross type diagnostics#45

Open
mvoof wants to merge 24 commits intomainfrom
cross-type-diagnostics
Open

Cross type diagnostics#45
mvoof wants to merge 24 commits intomainfrom
cross-type-diagnostics

Conversation

@mvoof
Copy link
Owner

@mvoof mvoof commented Mar 2, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the Tauri LSP server by introducing robust cross-type diagnostics and improved type information extraction. It adds new modules for parsing generated TypeScript bindings and extracting Rust command schemas, enabling the server to validate invoke() call parameters and return types against their definitions. The changes also include a more reliable configuration-based discovery mechanism for generated files and enrich existing LSP features like hover and code actions with type-aware information.

Highlights

  • Cross-Type Diagnostics: Implemented new diagnostic checks for invoke() calls in TypeScript/JavaScript files, validating parameter keys and return types against command schemas.
  • Type Information Extraction: Introduced new modules (bindings_reader.rs, rust_type_extractor.rs) to parse generated TypeScript bindings (Specta, ts-rs, typegen) and extract command schemas directly from Rust #[tauri::command] functions.
  • Config-Based Generator Discovery: Added config_reader.rs to reliably discover generated binding file paths by parsing project configuration files, improving accuracy over content-based detection.
  • Enhanced LSP Features: Improved hover functionality to display command return types and added a code action to automatically add or fix generic return type arguments in invoke() calls.
  • Specta Call Support: Integrated parsing for commands.methodName() style calls (from tauri-specta) into the TypeScript Tree-sitter query, diagnostics, and hover features.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • lsp-server/src/bindings_reader.rs
    • Added new module for parsing generated TypeScript binding files.
  • lsp-server/src/capabilities/code_actions.rs
    • Modified to include code actions for fixing/adding invoke() return types.
  • lsp-server/src/capabilities/completion.rs
    • Added #[must_use] attribute to lsp_character_to_byte_index.
  • lsp-server/src/capabilities/definition.rs
    • Updated handle_goto_definition to include SpectaCall behavior.
  • lsp-server/src/capabilities/diagnostics.rs
    • Implemented new type-aware diagnostics for command parameters and return types.
  • lsp-server/src/capabilities/hover.rs
    • Refactored and enhanced hover information to include command return types and more detailed reference summaries.
  • lsp-server/src/capabilities/mod.rs
    • Reordered module imports.
  • lsp-server/src/capabilities/symbols.rs
    • Minor formatting change.
  • lsp-server/src/config_reader.rs
    • Added new module for discovering generator output paths from project configuration.
  • lsp-server/src/file_processor.rs
    • Modified to route generated binding files to specific parsers and prioritize schemas.
  • lsp-server/src/indexer.rs
    • Extended ProjectIndex to store command schemas and type aliases, and updated Finding and LocationInfo structs with new fields for type information.
  • lsp-server/src/lib.rs
    • Added new module imports.
  • lsp-server/src/main.rs
    • Added new module imports and integrated config-based generator discovery.
  • lsp-server/src/queries/rust.scm
    • Updated Rust Tree-sitter query to capture function items for #[tauri::command] detection.
  • lsp-server/src/queries/typescript.scm
    • Added TypeScript Tree-sitter query for SpectaCall patterns.
  • lsp-server/src/rust_type_extractor.rs
    • Added new module for extracting command schemas from Rust source.
  • lsp-server/src/scanner.rs
    • Added detect_generator_kind function and made find_tauri_config public.
  • lsp-server/src/syntax.rs
    • Added SpectaCall to Behavior enum.
  • lsp-server/src/tree_parser.rs
    • Modified to use rust_type_extractor for Rust command parsing and extract type arguments/parameter keys for frontend calls.
  • lsp-server/src/utils.rs
    • Added new module for utility functions like camel_to_snake.
  • lsp-server/tests/bindings_reader_tests.rs
    • Added new test file for bindings_reader and camel_to_snake functionality.
  • lsp-server/tests/diagnostics_tests.rs
    • Extended diagnostic tests to cover new type-aware checks.
  • lsp-server/tests/fixtures/bindings/specta_bindings.ts
    • Added new fixture file.
  • lsp-server/tests/fixtures/bindings/ts_rs_types.ts
    • Added new fixture file.
  • lsp-server/tests/fixtures/bindings/typegen_bindings.ts
    • Added new fixture file.
  • lsp-server/tests/fixtures/rust/multi_attr_command.rs
    • Added new fixture file.
  • lsp-server/tests/fixtures/rust/typed_commands.rs
    • Added new fixture file.
  • lsp-server/tests/fixtures/typescript/specta_calls.ts
    • Added new fixture file.
  • lsp-server/tests/indexer_tests.rs
    • Extended ProjectIndex tests for schema and type alias management.
  • lsp-server/tests/integration_tests.rs
    • Updated integration tests to reflect new parsing capabilities.
  • lsp-server/tests/parser_tests.rs
    • Updated parser tests for Rust and TypeScript to include new command attribute parsing and generic invoke call details.
  • lsp-server/tests/rust_type_extractor_tests.rs
    • Added new test file for rust_type_extractor functionality.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant and valuable feature: cross-type diagnostics between the Rust backend and TypeScript/JavaScript frontend. It achieves this by adding parsers for various binding generators (tauri-specta, ts-rs, tauri-typegen) and a system to extract type information from Rust source code. This new type information is then used to provide diagnostics for mismatched arguments and return types in invoke calls. The implementation is extensive, adding new modules for configuration reading, bindings parsing, and Rust type extraction. The changes are well-structured and include a good number of tests. My review focuses on improving the robustness of the parsing logic in a few edge cases.

@mvoof mvoof force-pushed the cross-type-diagnostics branch from 165c3b1 to 89e8cd4 Compare March 2, 2026 14:27
@mvoof mvoof self-assigned this Mar 2, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a substantial and impressive pull request that adds a whole new layer of type-aware diagnostics and intelligence to the language server. The introduction of parsers for generated bindings, schema extraction from Rust source, and the integration into diagnostics, code actions, and hovers is a significant feature enhancement. The code is generally well-structured, with new responsibilities cleanly separated into new modules. I have one major point of feedback regarding the manual parsing of TOML configuration, which should be addressed to improve robustness.

Note: Security Review is unavailable for this PR.

@mvoof mvoof added roadmap New feature or request new featute request New feature labels Mar 3, 2026
@mvoof mvoof added this to tarus Mar 3, 2026
@github-project-automation github-project-automation bot moved this to Backlog in tarus Mar 3, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an impressive pull request that introduces comprehensive cross-language type diagnostics for Tauri commands and events. The implementation is robust, leveraging tree-sitter for accurate parsing and a new configuration reader to automatically detect generated bindings from various tools like tauri-specta, ts-rs, and tauri-typegen. The code is well-structured with new features organized into dedicated modules and is accompanied by extensive tests, which is great to see. I have one suggestion to further enhance the new diagnostics by adding validation for the number of arguments in Specta-style command calls, which seems to be a missing piece in the current implementation.

Note: Security Review did not run due to the size of the PR.

mvoof added 15 commits March 3, 2026 22:08
Parse event schemas from tauri-specta (__makeEvents__ blocks) and  tauri-typegen (listen<T>('event-name') patterns) binding files, with
Rust source as optional fallback. Emit HINT for missing <T> on emit/listen calls and WARNING for payload type mismatches, with quick-fix code actions to insert or replace the generic type argument
discover_specta looked for .export( and the path in the window to the first ), but in a multi-line call, the first ) was inside BigIntExportBehavior::Number), not the closing
paren of .export(...)
…ties

  - Fix stale RustSource schemas: clear command_schemas and event_schemas
    before re-extracting when a Rust file changes (bug: renamed/deleted
    commands left orphaned entries forever)
  - Targeted diagnostic_info_cache invalidation: replace full .clear()
    with per-key removal on file changes (perf: avoid wiping entire cache
    every 300ms during typing)
  - Unified Rust parse pass: new parse_rust_full() creates one Parser +
    one tree, then runs findings/command/event queries sequentially
    (perf: 3 parse calls → 1 per Rust file change)
  - Consolidate LSP utilities: move point_to_position,
    is_position_in_range, lsp_character_to_byte_index into utils.rs
  - Deduplicate bracket matchers: replace 4 specialized functions with
    generic find_matching_bracket() and find_matching_paren_with_generics()
…s, enforce clippy

- Move utils tests from src/ #[cfg(test)] to tests/utils_tests.rs per project rules
- Replace manual .contains("ts-rs") Cargo.toml check with proper toml crate parsing
- Replace unwrap_promise_result/extract_ok_type bracket tracking with tree-sitter node walking
- Extract 8 inline tree-sitter queries to dedicated .scm files loaded via include_str!
- Remove 11 crate-level #![allow(clippy::...)] from main.rs; fix warnings or add item-level allows
@mvoof mvoof force-pushed the cross-type-diagnostics branch from 0ac5c70 to bc1bd1b Compare March 3, 2026 17:09
mvoof added 4 commits March 3, 2026 23:58
Add parser support for tauri-specta's typed event
Converts camelCase event property names to kebab-case using new
camel_to_kebab utility. Uses standard Emit/Listen behaviors so all
existing capabilities (CodeLens, navigation, hover, references,
diagnostics) work automatically.
  - Remove `detect_generator_kind()` fallback — binding files are now
    discovered exclusively via config-based parsing
  - Add `discover_specta_typescript()` for standalone specta-typescript
    crate (`Typescript::default().export_to("path", &types)`)
  - Add tree-sitter query pattern for `export_to` (path as first arg)
  - Update tests to use `set_generator_bindings()` instead of fallback
  - Simplify README type generation section
@mvoof mvoof moved this from Backlog to In progress in tarus Mar 6, 2026
@mvoof mvoof removed the roadmap New feature or request label Mar 6, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an impressive and substantial pull request that introduces cross-language type diagnostics, a major new feature. The implementation is well-structured, introducing new modules for parsing bindings, reading configurations, and extracting type information from Rust code. The use of tree-sitter has been expanded and made more robust, and the core indexer is thoughtfully updated to support the new schemas. The addition of comprehensive tests is also commendable. I've found a couple of areas for improvement: a potential bug in the manual parsing of Rust generic types and a minor performance optimization opportunity in the indexing logic. Overall, this is a high-quality contribution.

Note: Security Review did not run due to the size of the PR.

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

Labels

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

1 participant