Skip to content

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Sep 23, 2025

Fixes #5718

@DanTup DanTup added this to the v3.120.0 milestone Sep 23, 2025
@DanTup DanTup added is enhancement in dtd Relates to integration with the Dart Tooling Daemon in flutter widget preview Relates to the embedded Flutter widget preview labels Sep 23, 2025
@DanTup DanTup requested a review from Copilot September 23, 2025 11:43
@DanTup
Copy link
Member Author

DanTup commented Sep 23, 2025

@codex review
/gemini review

Copy link

Copilot AI 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 implements support for the Editor.getActiveLocation() service method in the Dart Tooling Daemon (DTD), addressing issue #5718. The change allows external tools to query the current active location in the VS Code editor.

  • Adds the editorGetActiveLocation service method registration and implementation
  • Refactors active location handling to maintain state and support both events and queries
  • Updates type definitions to separate ActiveLocation interface from event-specific properties

Reviewed Changes

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

File Description
src/shared/services/tooling_daemon_services.ts Adds new service method enum and refactors ActiveLocation interface
src/shared/services/tooling_daemon.ts Updates method signatures and adds service registration overload
src/extension/dart/tooling_daemon.ts Implements the getActiveLocation service and maintains active location state
src/test/dart/tooling_daemon/tooling_daemon.test.ts Adds comprehensive tests for the new service method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gemini-code-assist
Copy link

Thanks for the review request, @DanTup! I've thoroughly reviewed the changes in this pull request.

This PR introduces a new service method, Editor.getActiveLocation(), to the Dart Tooling Daemon (DTD), which allows clients to query the currently active editor location. This addresses the issue mentioned in the PR description by providing a direct way to retrieve editor selection information.

Here's a summary of my findings:

General Feedback

Overall, the changes are well-structured and logically sound. The introduction of the ActiveLocation interface and the refactoring of ActiveLocationChangedEvent are good design decisions, promoting reusability and clarity. The new service method Editor.getActiveLocation is correctly implemented and thoroughly tested.

Detailed Review

src/extension/dart/tooling_daemon.ts

  • Type Imports: The import of ActiveLocation instead of ActiveLocationChangedEvent for type definition is correct and aligns with the new interface structure.
  • Debounce Refactoring: Removing the activeLocationDebounceTimeMs class member and directly using config.dtdEditorActiveLocationDelay simplifies the code and reduces redundancy.
  • Method Renaming: Renaming sendActiveLocationChange to updateActiveLocation improves clarity, as it better describes the method's role in preparing and then triggering the sending of location data.
  • Logic Extraction: Extracting the ActiveLocation object creation into a new private method getActiveLocation enhances modularity and readability by separating data retrieval from event handling.
  • EditorServices Update: Adding public activeLocation: ActiveLocation to EditorServices with an initial empty state correctly stores the latest active location for the new service method.
  • Service Registration: The registration of the new Editor.getActiveLocation service method is correctly implemented, returning the stored activeLocation with the appropriate type.

src/shared/services/tooling_daemon.ts

  • Type Consistency: Updating the sendActiveLocation parameter type from ActiveLocationChangedEvent to ActiveLocation and then wrapping it with kind: EventKind.activeLocationChanged before sending ensures type safety and consistency with the new definitions.
  • Service Overloads: The addition of specific overloads for registerService and callMethod for Editor.getActiveLocation provides stronger typing and better API definition.

src/shared/services/tooling_daemon_services.ts

  • ServiceMethod Enum: The addition of editorGetActiveLocation to the ServiceMethod enum correctly defines the new service method name.
  • Interface Design: Introducing the ActiveLocation interface to define the core data structure and having ActiveLocationChangedEvent extend it is a good design pattern, promoting clear separation of concerns.

src/test/dart/tooling_daemon/tooling_daemon.test.ts

  • Test Improvements: The addition of dtdDebounceMs and setConfigForTest to reduce debounce time makes the tests more reliable and efficient. The use of the simplify helper function improves test readability.
  • New Test Coverage: The new test suite for should return the current active location is a crucial addition, directly verifying the functionality of the Editor.getActiveLocation service method across single and multi-selection scenarios.

Conclusion

The pull request effectively implements the new Editor.getActiveLocation service method, adhering to good design principles and ensuring comprehensive test coverage. The changes are clean and enhance the DTD's capabilities. I recommend merging this PR.

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

@DanTup DanTup merged commit 942f118 into master Sep 23, 2025
17 checks passed
@DanTup DanTup deleted the add-get-active-location-dtd-service-method branch September 23, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in dtd Relates to integration with the Dart Tooling Daemon in flutter widget preview Relates to the embedded Flutter widget preview is enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement the getActiveLocation() Editor service over DTD

2 participants