Skip to content

contribute a fix_data.yaml file to enable 'dart fix' renames #141

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 6 commits into from
Jan 14, 2024

Conversation

devoncarew
Copy link
Member

@devoncarew devoncarew commented Jan 12, 2024

@keertip - can you review the fix_data.yaml file? I have some questions about it (in-line).
cc @bwilkerson and @jacob314 as we discussed this yesterday


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

@devoncarew devoncarew marked this pull request as draft January 12, 2024 16:41
- title: "Rename to 'HTMLAnchorElement'"
date: 2024-01-12
element:
uris: [ 'package:web/web.dart' ]
Copy link
Member Author

Choose a reason for hiding this comment

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

@keertip - should this be package:web/web.dart? web.dart? I see different things in the flutter package dart fix data.

Copy link
Member

Choose a reason for hiding this comment

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

Either ought to be fine. The shorter form is an "abbreviated URI". See https://github.com/flutter/flutter/wiki/Data-driven-Fixes#uri.

Copy link

Choose a reason for hiding this comment

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

Either should be fine. Though we do have this open issue - dart-lang/sdk#52233.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm - is that issue a blocker? Does it mean we should include both types of urls in the fix data file (web.dart and package:web/web.dart)? Is this is going to affect us it would be great to prioritize that fix for the next release.

@@ -5,6 +5,11 @@
import 'package:web/web.dart';

void main() {
final div = document.querySelector('div') as HTMLDivElement;
// ignore: unused_local_variable
final HtmlDocument foo = document;
Copy link
Member Author

Choose a reason for hiding this comment

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

This location does offer a quick fix, to rename to Document.

// ignore: unused_local_variable
final HtmlDocument foo = document;

final doc = document as HtmlDocument;
Copy link
Member Author

Choose a reason for hiding this comment

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

This location does not offer a quick fix. Should I define the fix data differently? Is the rename fix expected to cover this case?

cc @keertip

Copy link
Member

Choose a reason for hiding this comment

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

I would have expected the rename change to cover this case. It looks like a bug to me.

Copy link

Choose a reason for hiding this comment

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

As Brian said, it should, otherwise it is a bug. Could you open an issue to capture this?

Copy link
Member Author

Choose a reason for hiding this comment

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

@devoncarew
Copy link
Member Author

Somewhat related - and I can open a separate issue for this - quick fix will currently un-do the work of the dart fix fixes. When I open the quick fixes available at a ctor reference to an older symbol from dart:html (w/ just package:web in the imports, not dart:html):

Screenshot 2024-01-12 at 8 44 54 AM

The 3rd item above is what we want the user to select - to rename the older symbol name to the new (HTMLDivElement) name. However the first item suggested - adding an import for dart:html - will actually work against the migration, and will likely be confusing to casual users. We should probably stop suggesting adding imports for the legacy web libraries (eg, https://api.dart.dev/main/a5758a0dc373e137ee2cf486b5a537fbd5696a95/index.html).

@devoncarew
Copy link
Member Author

It would be great to be able to bump the 'rename' quick fix to be first in the list in any case - for it to be suggested ahead of the 'create new class' fix.

Copy link
Member

@bwilkerson bwilkerson left a comment

Choose a reason for hiding this comment

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

Consider defining tests for each of the transformations as per https://github.com/flutter/flutter/wiki/Data-driven-Fixes#testing. I strongly recommend having at least one .dart file per transform, even though the flutter team has chosen to put the tests for multiple transforms in a single file. I think it makes it much easier to debug problems when the test files are smaller.

// ignore: unused_local_variable
final HtmlDocument foo = document;

final doc = document as HtmlDocument;
Copy link
Member

Choose a reason for hiding this comment

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

I would have expected the rename change to cover this case. It looks like a bug to me.

- title: "Rename to 'HTMLAnchorElement'"
date: 2024-01-12
element:
uris: [ 'package:web/web.dart' ]
Copy link
Member

Choose a reason for hiding this comment

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

Either ought to be fine. The shorter form is an "abbreviated URI". See https://github.com/flutter/flutter/wiki/Data-driven-Fixes#uri.

@devoncarew
Copy link
Member Author

Consider defining tests for each of the transformations as per https://github.com/flutter/flutter/wiki/Data-driven-Fixes#testing.

Thanks for the feedback and the idea! I added content in a test_fixes/ dir. It did find 1/2 dozen quick fixes that were not taking effect - places where we had introduced typedefs to help w/ migrations.

@devoncarew devoncarew marked this pull request as ready for review January 12, 2024 20:40
@bwilkerson
Copy link
Member

Glad we found the bugs.

Copy link
Contributor

@srujzs srujzs left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for working on this! I commented on the other issue on why we might be missing some of the mappings. (I'm approving from my perspective - better to have some of the analyzer folks approve before submitting)

Copy link

@keertip keertip left a comment

Choose a reason for hiding this comment

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

LGTM for the fix_data.yaml file. Please do test that dart fix works if you change the uri from 'package:'.

@devoncarew
Copy link
Member Author

LGTM for the fix_data.yaml file. Please do test that dart fix works if you change the uri from 'package:'.

I did try updating the fix_data references to use web.dart (from package:web/web.dart). The fixes didn't work after that - either from the editor (in the example file) or via the cli testing (--compare-to-golden) technique. Keeping the longer form for now.

@devoncarew devoncarew merged commit d17fdd2 into main Jan 14, 2024
@devoncarew devoncarew deleted the fix_data.yaml branch January 14, 2024 19:25
srujzs added a commit to srujzs/web that referenced this pull request Jan 22, 2024
Generate extension type bindings

Generate extension types instead of classes

Refactors some code around overrides so we don't emit @js
unless they're needed.

Updates code_builder dep to 4.10.0 and dart_style to 2.3.4.

Clean up JS supertype generation

contribute a fix_data.yaml file to enable 'dart fix' renames (dart-lang#141)

contribute a fix_data.yaml file to enable 'dart fix' renames

collect MDN API information (dart-lang#130)

collect MDN info for use in API documentation

Redeprecate deprecated APIs in 0.4.1 (dart-lang#142)

Undeprecate some APIs and prepare for publish of 0.4.2 (dart-lang#140)

move bindings_generator/ to tool/generator/ (dart-lang#138)

rev to 0.4.1 in preparation for publishing (dart-lang#135)

Update generate copyright year to 2024 (dart-lang#136)

Change-Id: I0f90fc08fd7871f8331f42c158cb7ba34e6bf887
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.

4 participants