Skip to content

Tests: introduce resolve and code completion contexts #18647

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

auduchinok
Copy link
Member

@auduchinok auduchinok commented Jun 2, 2025

This PR replaces the manual context creation with locating a {caret} mark in the source in more tests. It makes it much easier to write new editor-related tests and should also prevent mistakes that are easy to make when providing the context by hand. It continues the work started in #18524 and #18609.

To make it easier to use the FCS APIs it introduces several new types:

  • SourceContext: contains info about the cursor position and the line text
  • ResolveContext: contains data needed for resolve-related features (getting a symbol, tooltip, overloads, etc)
  • CodeCompletionContext: similar to ResolveContext but has code completion-specific differences

It also introduces new Checker module that provides test helpers for working with these new contexts. We may evolve these helpers into a newer FCS API in future, as it makes it significantly easier to work with these contexts than to provide things like the cursor coordinates separately.

Copy link
Contributor

github-actions bot commented Jun 2, 2025

✅ No release notes required

@auduchinok auduchinok force-pushed the fcs-tests-checker branch 3 times, most recently from 5434a63 to bba05f3 Compare June 2, 2025 21:05
@auduchinok auduchinok force-pushed the fcs-tests-checker branch from bba05f3 to 7aa0c5c Compare June 2, 2025 21:23
@auduchinok
Copy link
Member Author

It's ready 🙂

Copy link
Member

@T-Gro T-Gro left a comment

Choose a reason for hiding this comment

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

I love this.

I only ever had to do a handful of a new completion/tooltip tests, but the test setup with the repetitive line of code entry, and having to manually adjust coordinates, was very annoying and hard to one-shot correctly.

I also believe the {caret} DSL now with the boilerplate removed will be easier for use also for non-humans :))

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Jun 3, 2025
@T-Gro T-Gro merged commit ffc3f46 into dotnet:main Jun 3, 2025
39 checks passed
@auduchinok auduchinok deleted the fcs-tests-checker branch June 3, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants