Skip to content

Add a new public API exposed from the extension#5583

Merged
DanTup merged 10 commits intomasterfrom
new-extension-api
Jul 8, 2025
Merged

Add a new public API exposed from the extension#5583
DanTup merged 10 commits intomasterfrom
new-extension-api

Conversation

@DanTup
Copy link
Member

@DanTup DanTup commented Jul 7, 2025

This exposes a new API from the extension that provides access to the SDK paths/versions and DTD URI, including events that fire if/when they might change.

Fixes #5008

This exposes a new API from the extension that provides access to the SDK paths/versions and DTD URI, including events that fire if/when they might change.

Fixes #5008
@DanTup DanTup added this to the v3.116.0 milestone Jul 7, 2025
@DanTup DanTup added is enhancement An enhancement or improvement that should be listed in release notes but is not a bug fix. in api Relates to the API exported by the Dart-Code extension for use by other extensions. labels Jul 7, 2025
@DanTup DanTup requested a review from Copilot July 7, 2025 13:59

This comment was marked as outdated.

Well spotted, Copilot!
@DanTup
Copy link
Member Author

DanTup commented Jul 7, 2025

This assertion checks extApi.dtdUri immediately after activation, but the DTD URI is set asynchronously; the test may fail intermittently. Consider waiting for the onDtdUriChanged event or using waitForResult before asserting extApi.dtdUri.

Good spot, fixed in ef85a18.

@DanTup
Copy link
Member Author

DanTup commented Jul 7, 2025

/gemini review

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 new version of the public API to expose SDK paths and DTD URI, along with events for when they change. The implementation is clean and includes new tests. I've identified a potential unintended breaking change where a function from the previous API version was removed, and an outdated code comment. My feedback includes suggestions to address these points.

DanTup and others added 5 commits July 7, 2025 16:41
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This allows the exports to still work after an internal restart.
@DanTup DanTup requested a review from Copilot July 8, 2025 09:17
@DanTup
Copy link
Member Author

DanTup commented Jul 8, 2025

/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

Adds a new public API surface to expose SDK paths/versions and the DTD URI (with change‐notification events) from the Dart Code extension.

  • Introduces PublicDartExtensionApi interface and implementation to emit SDK and DTD URI data/events
  • Updates activate to set up and return the new public API object
  • Extends existing tests to import and verify the public API, and refines tooling‐daemon error messaging

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/test/helpers.ts Import and export extApi for accessing the public API in tests
src/test/flutter_bazel/daemon.test.ts Switch to named commands import and add reload command arg
src/test/flutter/extension.test.ts Import extApi and assert public‐API SDK properties
src/test/dart/extension_api.test.ts New tests for DTD URI and SDK‐change notifications
src/test/dart/extension.test.ts Import extApi and assert public‐API SDK properties
src/shared/vscode/interfaces.ts Allow toolingDaemon to be undefined in internal API
src/shared/services/tooling_daemon.ts Improve error messages and refine send method behavior
src/extension/extension.ts Initialize, update, and return the public API from activation
src/extension/api/interfaces.ts Define the public API interfaces for SDKs and DTD URI
src/extension/api/extension_api.ts Implement data‐backing and event emitters for the public API
Comments suppressed due to low confidence (1)

src/test/dart/extension_api.test.ts:3

  • [nitpick] Consider adding an assertion for extApi.version to ensure the public API version is covered by tests.
import { activateWithoutAnalysis, extApi, waitForResult } from "../helpers";

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 new public API for accessing SDK paths and the DTD URI, which is a great addition for other extensions to build upon. The implementation is well-structured, separating the internal data management from the public-facing API.

The changes to make DartToolingDaemon.send synchronous and throw on error is a nice simplification. The test coverage for the new API is also good.

I have one suggestion regarding a comment in extension_api.ts that seems to be out of sync with the implementation, which could cause confusion for future maintainers.

@DanTup DanTup merged commit d1c50ed into master Jul 8, 2025
21 checks passed
@DanTup DanTup deleted the new-extension-api branch July 8, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in api Relates to the API exported by the Dart-Code extension for use by other extensions. is enhancement An enhancement or improvement that should be listed in release notes but is not a bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose APIs for other VS Code extensions to use functionality from the Dart extension

2 participants