Skip to content

test(completion): PathKind fixtures and bibliography .yml coverage - #2388

Open
hongjr03 wants to merge 42 commits into
Myriad-Dreamin:mainfrom
hongjr03:split/05-path-kind-tests
Open

test(completion): PathKind fixtures and bibliography .yml coverage#2388
hongjr03 wants to merge 42 commits into
Myriad-Dreamin:mainfrom
hongjr03:split/05-path-kind-tests

Conversation

@hongjr03

Copy link
Copy Markdown
Contributor

Adds PathKind completion fixtures/snapshots and extends bibliography completion to include .yml. Test-only changes.

Depends on #2387.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @hongjr03, 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 path completion and type inference capabilities within the tinymist-query crate. It introduces sophisticated mechanisms to handle string concatenations for path resolution, expands support for bibliography file types, and refines how types are inferred in complex scenarios involving dynamic dictionary keys, collection destructuring, and contextual assignments. The changes are primarily test-driven, with numerous new fixtures ensuring the robustness of these improvements.

Highlights

  • Enhanced Path Completion: Introduced new logic to accurately resolve and complete paths within string concatenations (e.g., "dir/" + "file.typ") by analyzing prefixes and suffixes, and improved path type propagation through let bindings and destructuring patterns.
  • Expanded Bibliography Completion: Bibliography completion now supports .yml files in addition to existing formats, enhancing usability for users working with YAML-based bibliographies.
  • Improved Type Inference for Dynamic Keys and Collections: The type checker can now infer types for dynamically keyed dictionary items (e.g., dict.at("key") where 'key' is a constant string) and better propagates types for elements within arrays and tuples, especially in for loops and destructuring assignments.
  • Refined Contextual Type Checking: Contextual type checking has been made more robust, particularly for array and dictionary elements wrapped in parenthesized expressions, and for source paths in import and include statements.
  • New Test Fixtures and Snapshots: A comprehensive set of new test fixtures and snapshots has been added to validate the correctness and coverage of the improved path completion and type inference features across various scenarios.

🧠 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.

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.

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

Copy link
Copy Markdown
Contributor

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 significantly enhances completion capabilities, particularly for paths within string concatenations and various binding forms. It also extends bibliography completion to include .yml files and improves type inference for destructuring, for-loops, and dynamic dictionary keys. The changes are substantial and well-supported by a comprehensive set of new test fixtures and snapshots. My review includes a couple of suggestions to improve code clarity and style.

Comment on lines +124 to +127
let mut new_prefix = EcoString::new();
new_prefix.push_str(lhs.as_str());
new_prefix.push_str(prefix.as_str());
prefix = new_prefix;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic for prepending to the prefix string can be simplified. Using the + operator for EcoString concatenation is more idiomatic and concise.

Suggested change
let mut new_prefix = EcoString::new();
new_prefix.push_str(lhs.as_str());
new_prefix.push_str(prefix.as_str());
prefix = new_prefix;
prefix = lhs + prefix;

Comment on lines +495 to +524
let mut trailing_pos_after_spread = false;

for item in destructuring.items() {
match item {
ast::DestructuringItem::Pattern(pat) => {
if saw_spread {
trailing_pos_after_spread = true;
} else {
has_pos = true;
pos.push(pattern_binding_ty(this, pat));
}
}
ast::DestructuringItem::Named(named_item) => {
has_named = true;
let key = Interned::new_str(named_item.name().get().as_str());
let ty = pattern_binding_ty(this, named_item.pattern());
named.push((key, ty));
}
ast::DestructuringItem::Spread(..) => {
saw_spread = true;
}
}
}

// Spreads make trailing positional mapping ambiguous. Still keep a
// prefix mapping like `(a, ..rest)` and always keep named fields.
if trailing_pos_after_spread {
has_pos = false;
pos.clear();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The variable trailing_pos_after_spread and its associated logic appear to be unnecessary. In Typst, a spread (..) must be the last positional item in a destructuring pattern, so a positional pattern cannot appear after a spread. This means trailing_pos_after_spread will never be true, making the related code paths dead. The logic can be simplified by removing this check.

                    for item in destructuring.items() {
                        match item {
                            ast::DestructuringItem::Pattern(pat) => {
                                // According to Typst documentation, a spread must be the last
                                // positional item, so `saw_spread` is always false here.
                                has_pos = true;
                                pos.push(pattern_binding_ty(this, pat));
                            }
                            ast::DestructuringItem::Named(named_item) => {
                                has_named = true;
                                let key = Interned::new_str(named_item.name().get().as_str());
                                let ty = pattern_binding_ty(this, named_item.pattern());
                                named.push((key, ty));
                            }
                            ast::DestructuringItem::Spread(..) => {
                                saw_spread = true;
                            }
                        }
                    }

                    // Positional items after a spread are invalid syntax, so we don't need
                    // to handle ambiguous mappings.

@hongjr03
hongjr03 force-pushed the split/05-path-kind-tests branch from c7db407 to be4fbde Compare January 29, 2026 09:52
@hongjr03
hongjr03 force-pushed the split/05-path-kind-tests branch from be4fbde to 9758fc3 Compare January 29, 2026 10:39
@hongjr03
hongjr03 force-pushed the split/05-path-kind-tests branch from 9758fc3 to cf5f199 Compare January 29, 2026 11:55
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.

1 participant