Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

[S] Change in dart/sdk[main]: [cq] Using `TestCode` and `normalizeSource` for quick-fix tests

0 views
Skip to first unread message

Felipe Morschel (Gerrit)

unread,
Mar 13, 2025, 11:16:28 AMMar 13
to dart-analys...@google.com, rev...@dartlang.org

Felipe Morschel has uploaded the change for review

Commit message

[cq] Using `TestCode` and `normalizeSource` for quick-fix tests

This change introduces `TestCode` and `normalizeSource` into the tests for quick fixes. The goal is to add these capabilities to `AbstractSingleUnitTest`, allowing a future update to replace offsets in tests with markers.
Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64

Change information

Files:
  • M pkg/analysis_server/test/abstract_single_unit.dart
  • M pkg/analysis_server/test/services/refactoring/legacy/extract_local_test.dart
  • M pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
Change size: S
Delta: 3 files changed, 10 insertions(+), 4 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 13, 2025, 2:24:31 PMMar 13
to Felipe Morschel, Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Phil Quitslund

Brian Wilkerson added 1 comment

File pkg/analysis_server/test/abstract_single_unit.dart
Line 23, Patchset 1 (Latest): late List<TestCodePosition> testCodePositions;
Brian Wilkerson . unresolved

I think it would be better to just keep the `TestCode` instance around rather than to destructure it. In other code I've been calling it the `parsedTestCode` to prevent a name conflict.

There is one other issue: this is not the only place that `testCode` is assigned a value. I think we need a way to ensure that `testCode` and `parsedTestCode` are always either both `null` or both non`null`. I tried doing that by wrapping the field in a getter and setter, but that doesn't work either (and is how I know that there are other places where a value is assigned to `testCode`.

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 1
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Thu, 13 Mar 2025 18:24:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 14, 2025, 8:32:13 AMMar 14
to Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

File pkg/analysis_server/test/abstract_single_unit.dart
Line 23, Patchset 1: late List<TestCodePosition> testCodePositions;
Brian Wilkerson . resolved

I think it would be better to just keep the `TestCode` instance around rather than to destructure it. In other code I've been calling it the `parsedTestCode` to prevent a name conflict.

There is one other issue: this is not the only place that `testCode` is assigned a value. I think we need a way to ensure that `testCode` and `parsedTestCode` are always either both `null` or both non`null`. I tried doing that by wrapping the field in a getter and setter, but that doesn't work either (and is how I know that there are other places where a value is assigned to `testCode`.

Felipe Morschel

I've refactored more things and ran locally all analyzer tests from test_all. It seems fine now, WDYT?

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 2
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Fri, 14 Mar 2025 12:32:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 14, 2025, 3:12:19 PMMar 14
to Felipe Morschel, Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Phil Quitslund

Brian Wilkerson added 2 comments

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Brian Wilkerson . resolved

I think the changes related to adding `TestCode` mostly look good, but I think the bigger issue with our test framework is the fact that it assigns to `testCode` in places where it shouldn't.

The base class (`AbstractSingleUnitTest`) was designed with the assumption that there would be a single compilation unit in the tests. That assumption allows the code in a single test method to be shorter and cleaner than it otherwise would be, but at some point the assumption was violated (by getting tests added that used multiple compilation units). In order to make those tests work some hacks were added that are making it harder to do the cleanup that this CL is aimed to facilitate.

But I think that the larger cleanup will be easier if we address the underlying issue first. I've put together a CL that mostly cleans up the code (https://dart-review.googlesource.com/c/sdk/+/415700). It doesn't completely address the issues in `getResolvedUnit`. I decided to save those for a later CL in order to keep this first CL smaller.

File pkg/analysis_server/test/abstract_single_unit.dart
Line 34, Patchset 2 (Latest): String get parsedTestCode => _parsedTestCode;
Brian Wilkerson . unresolved

I wasn't very clear in the issue, in part because I was expecting that I'd do the work. I don't mind that you took it on, I just didn't add more detail because I wasn't expecting you to. My plan is to add
```dart
late TestCode parsedTestCode;

String get testCode => parsedTestCode.code;
```

In other code I've been using `parseTestCode` to mean the instance of `TestCode`, not the version of the test code that has the markdown removed.

Also, I'd like to do more unification, and having the same name for the code being tested will probably simplify that.

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 2
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Fri, 14 Mar 2025 19:12:16 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 14, 2025, 4:04:45 PMMar 14
to Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

File pkg/analysis_server/test/abstract_single_unit.dart
Line 34, Patchset 2: String get parsedTestCode => _parsedTestCode;
Brian Wilkerson . resolved

I wasn't very clear in the issue, in part because I was expecting that I'd do the work. I don't mind that you took it on, I just didn't add more detail because I wasn't expecting you to. My plan is to add
```dart
late TestCode parsedTestCode;

String get testCode => parsedTestCode.code;
```

In other code I've been using `parseTestCode` to mean the instance of `TestCode`, not the version of the test code that has the markdown removed.

Also, I'd like to do more unification, and having the same name for the code being tested will probably simplify that.

Felipe Morschel

Ohh, I see. It's fine. This also helped me find all the calls to the original setter. Renaming them accordingly.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 2
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Fri, 14 Mar 2025 20:04:42 +0000
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 14, 2025, 4:05:55 PMMar 14
to Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

File pkg/analysis_server/test/abstract_single_unit.dart
Line 34, Patchset 2: String get parsedTestCode => _parsedTestCode;
Brian Wilkerson . resolved

I wasn't very clear in the issue, in part because I was expecting that I'd do the work. I don't mind that you took it on, I just didn't add more detail because I wasn't expecting you to. My plan is to add
```dart
late TestCode parsedTestCode;

String get testCode => parsedTestCode.code;
```

In other code I've been using `parseTestCode` to mean the instance of `TestCode`, not the version of the test code that has the markdown removed.

Also, I'd like to do more unification, and having the same name for the code being tested will probably simplify that.

Felipe Morschel

Ohh, I see. It's fine. This also helped me find all the calls to the original setter. Renaming them accordingly.

Felipe Morschel

Did you mean `parseTestCode` or `parsedTestCode`? You used both names on the comment. Just to be sure.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 3
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Fri, 14 Mar 2025 20:05:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Felipe Morschel <g...@fmorschel.dev>
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 14, 2025, 4:19:04 PMMar 14
to Felipe Morschel, Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Phil Quitslund

Brian Wilkerson added 1 comment

File pkg/analysis_server/test/abstract_single_unit.dart
Line 34, Patchset 2: String get parsedTestCode => _parsedTestCode;
Brian Wilkerson . resolved

I wasn't very clear in the issue, in part because I was expecting that I'd do the work. I don't mind that you took it on, I just didn't add more detail because I wasn't expecting you to. My plan is to add
```dart
late TestCode parsedTestCode;

String get testCode => parsedTestCode.code;
```

In other code I've been using `parseTestCode` to mean the instance of `TestCode`, not the version of the test code that has the markdown removed.

Also, I'd like to do more unification, and having the same name for the code being tested will probably simplify that.

Felipe Morschel

Ohh, I see. It's fine. This also helped me find all the calls to the original setter. Renaming them accordingly.

Felipe Morschel

Did you mean `parseTestCode` or `parsedTestCode`? You used both names on the comment. Just to be sure.

Brian Wilkerson

Sorry for the typo. I meant `parsedTestCode`.

This also helped me find all the calls to the original setter. Renaming them accordingly.

All of the calls to the original setter (except one) will be gone after my CL lands, so I'm a bit confused as to why you'd rename them.

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 3
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Fri, 14 Mar 2025 20:19:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 14, 2025, 4:28:25 PMMar 14
to Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel added 1 comment

File pkg/analysis_server/test/abstract_single_unit.dart
Line 34, Patchset 2: String get parsedTestCode => _parsedTestCode;
Brian Wilkerson . resolved

I wasn't very clear in the issue, in part because I was expecting that I'd do the work. I don't mind that you took it on, I just didn't add more detail because I wasn't expecting you to. My plan is to add
```dart
late TestCode parsedTestCode;

String get testCode => parsedTestCode.code;
```

In other code I've been using `parseTestCode` to mean the instance of `TestCode`, not the version of the test code that has the markdown removed.

Also, I'd like to do more unification, and having the same name for the code being tested will probably simplify that.

Felipe Morschel

Ohh, I see. It's fine. This also helped me find all the calls to the original setter. Renaming them accordingly.

Felipe Morschel

Did you mean `parseTestCode` or `parsedTestCode`? You used both names on the comment. Just to be sure.

Brian Wilkerson

Sorry for the typo. I meant `parsedTestCode`.

This also helped me find all the calls to the original setter. Renaming them accordingly.

All of the calls to the original setter (except one) will be gone after my CL lands, so I'm a bit confused as to why you'd rename them.

Felipe Morschel

I renamed them because I misunderstood your comment on the issue.

confused as to why

The reason (of why) it helped me, was that I could then open all of the files one by one to review (easier than by reference). This helped me find `pkg/analysis_server/test/src/computer/type_hierarchy_computer_test.dart` for example. But its all fine now. renamed as you asked.

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 3
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Fri, 14 Mar 2025 20:28:23 +0000
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 18, 2025, 2:01:06 PMMar 18
to Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

Patchset-level comments
File-level comment, Patchset 4 (Latest):
Felipe Morschel . resolved

Can I get a review here, please @brianwi...@google.com? Thanks a lot!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 4
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Tue, 18 Mar 2025 18:01:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 18, 2025, 2:34:06 PMMar 18
to Felipe Morschel, Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Phil Quitslund

Brian Wilkerson added 2 comments

File pkg/analysis_server/test/abstract_single_unit.dart
Line 31, Patchset 4 (Latest): String _testCode = '';
Brian Wilkerson . unresolved

I don't think there's any value to keeping a cached copy of `parsedTestCode.code` in a field. The getter can just return the value from `parsedTestCode`. Not having the field would prevent anyone from attempting to set `_testCode` directly, reducing the change of bugs in the test framework.

Line 35, Patchset 4 (Latest): if (value == testCode) {
Brian Wilkerson . unresolved

I thought about adding a test like this, but decided that it would be better to fail the test if we ever try to set the contents of the test file more than once (rather than allowing it to happen as long as the content hasn't changed). (And also, the `value` is expected to be the pre-parsed source, not the source after markup has been removed, so I think the test is wrong.)

I was planning on doing that by making `parsedTestCode` be nullable (instead of late) and failing here if it was non-null when this method is called.

Doing what I had planned would have the unfortunate effect of requiring null checks in lots of places, so I also considered making `parsedTestCode` be a getter backed by a nullable field (`_parsedTestCode`) that throws if the field hasn't been assigned. That might be cleaner.

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 4
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Tue, 18 Mar 2025 18:34:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 18, 2025, 3:51:35 PMMar 18
to Phil Quitslund, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel voted and added 2 comments

Votes added by Felipe Morschel

Auto-Submit+1

2 comments

File pkg/analysis_server/test/abstract_single_unit.dart
Line 31, Patchset 4: String _testCode = '';
Brian Wilkerson . resolved

I don't think there's any value to keeping a cached copy of `parsedTestCode.code` in a field. The getter can just return the value from `parsedTestCode`. Not having the field would prevent anyone from attempting to set `_testCode` directly, reducing the change of bugs in the test framework.

Felipe Morschel

Done

Line 35, Patchset 4: if (value == testCode) {
Brian Wilkerson . resolved

I thought about adding a test like this, but decided that it would be better to fail the test if we ever try to set the contents of the test file more than once (rather than allowing it to happen as long as the content hasn't changed). (And also, the `value` is expected to be the pre-parsed source, not the source after markup has been removed, so I think the test is wrong.)

I was planning on doing that by making `parsedTestCode` be nullable (instead of late) and failing here if it was non-null when this method is called.

Doing what I had planned would have the unfortunate effect of requiring null checks in lots of places, so I also considered making `parsedTestCode` be a getter backed by a nullable field (`_parsedTestCode`) that throws if the field hasn't been assigned. That might be cleaner.

Felipe Morschel

And also, the value is expected to be the pre-parsed source, not the source after markup has been removed, so I think the test is wrong

This was before your change to `getResolvedUnit` sometimes the resolved unit was brought from the file and it was written without the markdown on disc so this would be it.

Refactored. Care to run the bots again please? Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 4
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Tue, 18 Mar 2025 19:51:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Brian Wilkerson <brianwi...@google.com>
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 18, 2025, 4:08:22 PMMar 18
to Felipe Morschel, Brian Wilkerson, Phil Quitslund, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Phil Quitslund

Brian Wilkerson voted

Code-Review+1
Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Phil Quitslund
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 5
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Tue, 18 Mar 2025 20:08:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Felipe Morschel (Gerrit)

unread,
Mar 18, 2025, 7:21:24 PMMar 18
to Commit Queue, Brian Wilkerson, Phil Quitslund, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Phil Quitslund

Felipe Morschel voted and added 1 comment

Votes added by Felipe Morschel

Auto-Submit+1

1 comment

Patchset-level comments
File-level comment, Patchset 6 (Latest):
Felipe Morschel . resolved

The left over late I removed makes the tests pass. Completely missed it when I used `Encapsulate Field`. Now the tests pass. Can I please get your review now here too @pquit...@google.com? Thanks a lot!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Phil Quitslund
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 6
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Tue, 18 Mar 2025 23:21:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Phil Quitslund (Gerrit)

unread,
Mar 19, 2025, 12:32:14 PMMar 19
to Felipe Morschel, Commit Queue, Brian Wilkerson, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Brian Wilkerson and Felipe Morschel

Phil Quitslund voted and added 1 comment

Votes added by Phil Quitslund

Code-Review+1
Commit-Queue+2

1 comment

Patchset-level comments
Phil Quitslund . resolved

Nice. Thanks for the cleanup!

Open in Gerrit

Related details

Attention is currently required from:
  • Brian Wilkerson
  • Felipe Morschel
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 6
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Brian Wilkerson <brianwi...@google.com>
Gerrit-Comment-Date: Wed, 19 Mar 2025 16:32:08 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 19, 2025, 5:10:02 PMMar 19
to Felipe Morschel, Samuel Rawlins, Brian Wilkerson, Phil Quitslund, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel, Phil Quitslund and Samuel Rawlins

Brian Wilkerson voted and added 1 comment

Votes added by Brian Wilkerson

Code-Review+1
Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 7 (Latest):
Brian Wilkerson . resolved

Note that this should fix the failures on the Windows bot, so we'd like to get it landed fairly quickly.

Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Phil Quitslund
  • Samuel Rawlins
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 7
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Phil Quitslund <pquit...@google.com>
Gerrit-Comment-Date: Wed, 19 Mar 2025 21:09:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Phil Quitslund (Gerrit)

unread,
Mar 19, 2025, 5:52:28 PMMar 19
to Felipe Morschel, Samuel Rawlins, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel and Samuel Rawlins

Phil Quitslund voted

Code-Review+1
Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
  • Samuel Rawlins
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 7
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Attention: Samuel Rawlins <sraw...@google.com>
Gerrit-Comment-Date: Wed, 19 Mar 2025 21:52:21 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Samuel Rawlins (Gerrit)

unread,
Mar 19, 2025, 6:12:41 PMMar 19
to Felipe Morschel, Phil Quitslund, Brian Wilkerson, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Felipe Morschel

Samuel Rawlins voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Felipe Morschel
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 7
Gerrit-Owner: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Brian Wilkerson <brianwi...@google.com>
Gerrit-Reviewer: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Reviewer: Phil Quitslund <pquit...@google.com>
Gerrit-Reviewer: Samuel Rawlins <sraw...@google.com>
Gerrit-Attention: Felipe Morschel <g...@fmorschel.dev>
Gerrit-Comment-Date: Wed, 19 Mar 2025 22:12:29 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Brian Wilkerson (Gerrit)

unread,
Mar 19, 2025, 8:35:28 PMMar 19
to Felipe Morschel, Brian Wilkerson, Samuel Rawlins, Phil Quitslund, Commit Queue, dart-analys...@google.com, rev...@dartlang.org

Brian Wilkerson submitted the change

Change information

Commit message:
[cq] Using `TestCode` and `normalizeSource` for quick-fix tests

This change introduces `TestCode` and `normalizeSource` into the tests for quick fixes. The goal is to add these capabilities to `AbstractSingleUnitTest`, allowing a future update to replace offsets in tests with markers.
Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Reviewed-by: Phil Quitslund <pquit...@google.com>
Auto-Submit: Felipe Morschel <g...@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwi...@google.com>
Reviewed-by: Samuel Rawlins <sraw...@google.com>
Files:
  • M pkg/analysis_server/test/abstract_single_unit.dart
  • M pkg/analysis_server/test/services/completion/statement/statement_completion_test.dart
  • M pkg/analysis_server/test/services/correction/organize_directives_test.dart
  • M pkg/analysis_server/test/services/refactoring/legacy/extract_local_test.dart
  • M pkg/analysis_server/test/src/computer/call_hierarchy_computer_test.dart
  • M pkg/analysis_server/test/src/computer/type_hierarchy_computer_test.dart
  • M pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
Change size: L
Delta: 7 files changed, 194 insertions(+), 100 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Samuel Rawlins, +1 by Phil Quitslund, +1 by Brian Wilkerson
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I760e6b5fb13b37d4e35278073a78f4d755deda64
Gerrit-Change-Number: 415260
Gerrit-PatchSet: 8
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages