In a future CL I'd like to filter out whole libraries depending
on whether they could have a match. At this point the search, filtering,
and matching become entangled too much to bind them with outside
code in the server. Instead, it all will be the analyzer's concern.
Change-Id: Iefdadbf92046218b3a2607fbeadd37494522112e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304841
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This is work towards https://github.com/dart-lang/sdk/issues/47968. The fix processor may need to be called multiple times to fix all issues because some fixes may produce code that can be fixed by another (for example one inserting "final" and then another replacing it with "const").
In order to be able to provide multiple passes of edits to LSP, we need to merge them together because LSP's edits are not applied sequentially but must all represent valid locations in the original source file.
This class is currently unused (besides tests).
Change-Id: Ia006ff8044505c6d109f6480f7bcce4da4669cdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
I played with it some more, and found that the overhead of measuring
too fine grainly, when we have tens and hundreds thousands of relatively
inexpensive operations, is too high.
Change-Id: I4038e3972efff860d568c02008120092f99b8298
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304368
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The changes are:
* Use the current tear-off syntax for constuctors in the example
* Add references to the code where certain maps are defined.
Change-Id: I5710090c1ecb2939d74a3822b8c7b35090be378c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304323
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The actual removal will happen in (to be rebased on top of this):
https://dart-review.googlesource.com/c/sdk/+/303280
Fixing direct uses of the deprecated `Identifier get name` is apparently
only about a half of the work. I should have followed my own advice to
the clients and prepared better.
These changes are necessary because we will stop creating and
visiting `Identifier`, and so `NamedType` should be handled directly.
Change-Id: Ie07b75b15eab277ed6c9b29a838561a7eb71f588
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303425
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This also removes the tests converted in the previous CL because I
forgot to delete the file.
Change-Id: I306d64d227e2b5f632a9da9b547ce649e5d33767
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304142
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
When there's a parser error (like a missing semicolon) the 'add await' quick fix writes 'await' in the wrong place (right after 'async'). This CL simply writes 'await' in the correct place by using errorOffset.
Bug: #52390
Change-Id: I2f59433054826b492c448e2f35e2c2a00b2a775c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303240
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
+ some additional tests for extension operators.
Change-Id: I32b705c4e0fa96c785e55b41aba713c6026eecca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This reverts the changes to ResourceProviderMixin that made it possible
for a test to explicitly set the context type of the resource provider.
I don't believe that's necessary because we run all of the tests on the
windows bot with that context type anyway.
It also removed the windows-specific subclasses of the URI suggestion
tests. They were duplicates of the non-windows-specific tests that were
probably added before we had a windows bot.
Change-Id: I4547cc768992c4d272871032a6939cd216dc5e96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303422
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
The removal itself will happen in a separate CL, as a breaking change.
But we still had a few places that relied on `SimpleIdentifier` being visited.
Change-Id: I8f554cec77858cb8bc7deb29d98f0d6def8685ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303008
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
I am concerned about the tests marked with TODOs because I don't know
why the behavior changed. It's possible that the contributor is still
producing the suggestions but that they're being filtered out later.
I checked using the debugger, and they're not in the list of results
that we're getting back, so it seems likely that they represent real
bugs. If we just weren't detecting the bug before then we're good.
But I can't think how rewriting the tests could effect what the user
is seeing, so I think it's safe to make these changes.
Change-Id: If72042b7ec24b97994a12449c811213b8f708f72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303000
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Also includes https://dart-review.googlesource.com/c/sdk/+/302680
that was reverted because of adding extre diagnostics for Flutter.
Change-Id: I4cf7cedfcb67a5af226e609d279551fea0b0dee1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302844
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
I'm becoming concerned that the filtering is making it difficult to
verify the results. We can look at the textual output to see whether all
of the printed suggestions are valid, but we can't know what other
suggestions are being produced and whether they're valid, nor can we be
sure that suggestions that shouldn't be produced are not being produced.
Change-Id: Id131b9b53740b625ba74a9b5bdb690da21fcdbfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302901
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This reverts commit d2df7ce24a.
Reason for revert: https://dart-review.googlesource.com/c/sdk/+/291500 was reverted
Original change's description:
> Update comments and readmes to specify `dart run --no-pub` when necessary.
>
> Now that https://dart-review.googlesource.com/c/sdk/+/291500 has
> landed, `dart run` now tries to invoke `dart pub` before execution.
> This doesn't work when running scripts inside the SDK, because the SDK
> doesn't use pub to get its dependencies. So scripts in the SDK now
> need to be run with `--no-pub`.
>
> Change-Id: Ic320b717b2d45278cd26d373ae0823c2935ce102
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292720
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
Change-Id: I6c13510abde17f71694f362a8071c9c7fa519a88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302364
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Fix nits in documentation.
Add support for data driven fix for change parameter to non null.
Change-Id: I3120c74eb13e06640aa6ff0b9538e5552f7ae9f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298261
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
In https://dart-review.googlesource.com/c/sdk/+/299400, the parser was
adjusted so that it no longer accepts `when` and `as` as the names for
variable patterns in cases where there is a possible ambiguity
(e.g. `int when` is not accepted as a pattern because `int` is a
legitimate pattern, therefore `when` could introduce a guard
clause). This change further prohibits `when` and `as` from being the
names of variable patterns or identifier patterns even in the case
where there is no ambiguity. This is in line with the discussion at
https://github.com/dart-lang/sdk/issues/52199#issuecomment-1526297771,
and the spec change at
https://github.com/dart-lang/language/pull/3033.
Three new error codes are introduced, to cover the three circumstances
in which `when` or `as` might be used illegally: in a declared
variable pattern, in an assigned variable pattern, or in an identifier
pattern. I've also added analyzer tests to ensure that the parser
recovers from these errors nicely. Unfortunately, nice error recovery
is only feasible in the non-ambiguous cases.
I've also updated the language test expectations in
`tests/language/patterns/version_2_32_changes_error_test.dart` to
reflect the new error messages, and added a few more examples of uses
of `when` and `as` that are still permitted.
Fixes#52260.
Bug: https://github.com/dart-lang/sdk/issues/52260
Change-Id: I229f627aa639659c30b83c74895759207da279f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301482
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
I don't know how to write a test that ensures that we will attempt to
modify the collections after entering the for loop. Suggestions welcome.
Bug: https://github.com/dart-lang/sdk/issues/52263
Change-Id: Ifc13e80594bd08f6c485d8898eb7c75b31172992
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301780
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Using Identifier expression inside NamedType does not make sense.
Change-Id: I4a61d2b472fd66fb7c5e6e92a80cccb391b06d49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This change fixes parsing of case clauses such as:
case foo when !flag:
Constructions like this require some lookahead in order to parse
correctly, because the token `when` is valid both as an identifier and
as a part of the grammar for a case clause. Therefore, at the time
`foo` is encountered, the parser must decide whether it is looking at
a variable pattern (`foo when`, where `when` is the name of the
variable) or an identifier pattern (`foo`, where `when` begins the
case's guard clause). Previous to this fix, the algorithm for
disambiguating these two choices was as follows:
- If the token sequence starting at `foo` looked like a type, and the
token that follows was an identifier, the parser assumed it was
looking at a variable pattern with a type; otherwise it assumed it
was looking at an identifier pattern.
- EXCEPT that if the token that followed the supposed type was `when`
or `as` (both of which are valid identifiers), then it probed
further:
- If the token that followed `when` or `as` was a token that could
legitimately follow a pattern, then it assumed that it was looking
at a variable pattern with a type. (The tokens that could
legitimately follow a pattern are `,`, `:`, `||`, `&&`, `)`, `}`,
`]`, `as`, `when`, `?`, `!`).
- Otherwise it assumed that it was looking at an identifier pattern.
This didn't fully disambiguate, because the third bullet didn't
account for the fact that the tokens `as`, `when`, and `!` could
_either_ legitimately follow a pattern _or_ legitimately begin an
expression (or, in the case of `when`, a type), therefore constructs
like the following were incorrectly parsed:
- `case foo when as:` (where `as` is a local boolean variable)
- `case foo when when:` (where `when` is a local boolean variable)
- `case foo when !flag:` (where `flag` is a local boolean variable)
- `case foo as when:` (where `when` is the name of a type)
The solution is to simplify the disambiguation logic so that if if the
token that follows the supposed type is `when` or `as`, then the
parser assumes that it's looking at an identifier pattern, _not_ a
typed variable pattern.
The consequence of this is that the above four constructions are
parsed correctly; however it is no longer possible for a typed
variable pattern to name a variable `when` or `as`.
For consistency we would like to prohibit _any_ variable pattern from
naming a variable `when` or `as`, however to keep this change as small
as possible (and reduce the risk involved in a possible cherry-pick)
that will be postponed until a later CL.
Fixes#52199.
Bug: https://github.com/dart-lang/sdk/issues/52199
Change-Id: Ibab9b92f01e3e4020d7d64f1ff000a9b964a4564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299400
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Change-Id: I48dd729555861e87240be137d7a35d76dabeca6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299360
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
If the sender is not `null`, then we can send.
No need for a flag, and assert() in the sending method.
If the sender is `null`, then the sending code will not able to invoke it.
Types FTW :-)
Change-Id: I7d153ba014c578a73dce2eab28aceedbb8814711
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298440
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
- change forEachIndexed to `.indexed`
- remove `package:collection` imports for files only using `.firstOrNull`, `.singleOrNull`, `.lastOrNull` that is now available in `dart:core`
- switch from `Pair` to records
- use switch expressions
Change-Id: Id1ae22db427b4cd955f26e0d6c852944a540a05f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This is a reland of commit ccb02fa8fc
Original change's description:
> [analysis_server] Use fixDataYamlFolder constant instead of string literals
>
> Follow-up from https://dart-review.googlesource.com/c/sdk/+/296801.
>
> Change-Id: I72ea8a42ec64c4bd6c6cee021a1464167ec368e6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296862
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Change-Id: I202392de3444556dc2baa9ed9e1b82c3a1ede4aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This is a reland of commit bbacf39e9c
Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Change-Id: I571c1e4f87fdf0095d003d496f3c5d88e5cf0ff8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297940
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
I did not change any of the test cases. I did change the names of the
tests to be more consistent, and in the process I found a couple of
tests where the test code was identical, so I deleted the duplicates.
I expect that there will be more cleanup that we'll want to do after
all of the contributor tests have been converted and merged together,
but I wanted this CL to be as straightforward as possible given its
size.
Change-Id: I2cbb6b5c0718fbbc36da521ee3c4fc7d00c36dcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
No functional changes here but there have been some refactors inside the meta model that required some minor tweaks (URI moved from a type alias to string to a spec-defined base type).
I also improved the handling of some type references in the comments we bring in so they're clickable in more places.
Change-Id: I7c725d01b6d7bc0925979b8118dbfd8952f78724
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297482
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This reverts commit bbacf39e9c.
Reason for revert: Causing flutter/engine to fail to roll into flutter/flutter. See https://github.com/flutter/flutter/pull/125363.
Original change's description:
> [analysis_server] Analyze fix data in fix_data folder
>
> Fixes part of https://github.com/dart-lang/sdk/issues/52126.
>
> Change-Id: Ib4bd7830a2f644eacedccd375c7c8dc60f040d33
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296801
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Change-Id: I109a4b2c596ad22d73eaf0ac3e25f53a35ba5e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297320
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
The analyzer team has decided to adopt the convention of using `TODO`
comments to document long term issues that should persist in the
codebase, and `FIXME` comments to document short term issues that need
immediate attention. They may even consider adding a presubmit hook
to ensure that `FIXME` comments are only used during local
development.
Accordingly, it makes sense to suppress `TODO` comments from being
surfaced to the IDE "problems" view (since there are hundreds of them,
and they're not immediately actionable). This makes VSCode's
"problems" view much more usable in "tree" mode.
Change-Id: I11a0c59132fb98c1c86fb4adf22d1fdf3b547c80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295662
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
These dependency overrides prevent pub from getting confused about the
fact that our SDK development is in a mono-repo; that in turn will
allow unit tests to be run from inside vscode using the standard test
integration (see https://github.com/Dart-Code/Dart-Code/issues/4502).
Change-Id: I8ea709984b03927e67f119d147338203d7e80811
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
to handle a method with a diagnostic
Fixes#51198
Change-Id: I6a1921747912318d81121d58c88fccc35d1f809a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Other cases are outliers and nobody actually want it there.
Specifically, the way it works for if-then-elseIf does not make sense.
Change-Id: I8d16e689e057fa79ecfaa2c3155086cf36f1954c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296406
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
If the type checked expression is a local variable, it is useless.
The variable is already type promoted.
If the type checked expression is not a local variable, it produces
code that has a compile-time error because of downcard, which does
not work anymore with null safety.
Even generating `final x = expression as MyType` would be bad IMHO.
Unproven type casts are dangerous.
What the user should do, it to extract into a local variable, and
type check it. Or use patterns. But this is a different story.
Change-Id: Ifd3dc71894d17c5a07b7f1389a8143363697eda2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296384
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
(The last change was prematurely merged.)
Change-Id: Idc161ef596fa43927cf7eda223635a798d3292af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296402
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
I'll do some tidying up and restructuring when I add similar support for records...
Change-Id: I4124cdc5e6ecb12e54ab4570636e1f8cc9afa6c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296066
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
After using DAS with it for a few days, I find it more distracting
than useful.
Change-Id: I20da35e06958c79a6d458546937b616d45b0c909
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296281
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Let me know if any of this is unclear or if there's missing information.
Of course, you might not know that until you start trying to enhance the
support, but we can also refine the doc when issues are discovered. I'm
mostly just interested in helping you get started.
Change-Id: Ib48a8ce46af7b6cc37a27508c81df03bfd2093e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295040
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
When switching over a nullable expression, the `null` value should also
be handled for exhaustiveness.
The analyzer reports a lint for missing nulls, but the correction
producer was unable to fix the problem as it only adds missing enum
constants.
This change makes the fix producer add missing null cases.
Change-Id: I92065b36b6a370d5165e302d84391568894c5dc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This will help with any references to deprecated Hints in other
codebases, like nnbd_migraion or linter...
Change-Id: Iccd43d8e3113e6e3e0e458bf959c7f4d48185f35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294182
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Otherwise, in its current state, there's no clear error for any modifiers when used before an enum declaration.
This follows the same format to FINAL_MIXIN_CLASS and those groups of errors.
Bug: https://github.com/dart-lang/sdk/issues/51935
Change-Id: I8174b6894c95fef5c0f4704927b161942c19d3ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294122
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
All auto-converted. A bunch more will be convertible when we address: https://github.com/dart-lang/sdk/issues/52005
EDIT: updated w/ 64 fewer breaks
Change-Id: I9b6009e316341e7c9b9c2f2c651b6eada385960d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294423
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
We generally only test bulk fixes when we're worried about overlapping fixes. Since this can only be applied once per file I didn't feel it necessary to add any tests. Happy to if you feel otherwise!
Change-Id: Id74f8b2f9b1acd70bef789ad83406a71d5ddf391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294422
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Sometimes I realize that the `if` statement is not necessary, and
want to replace it with its `then` statement. With this Quick Assist
we can make the change without temporarily unbalancing `{` and `}`.
Change-Id: Icab454ad21e4babaada3cf58a4a3cccdb84c2ebe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294283
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
declarations with class modifiers.
Fixes what modifiers are suggested considering you can only use 'base'
on mixins and mixin classes.
Also fixes some existing bugs with classes suggesting 'sealed' after
'abstract'.
Change-Id: I3fcd1470dc015cb0c9c1c358041ca226aa298dc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
These were flagged as unused by `unreachable_from_main` but they are
used by `dart:mirrors`.
Change-Id: I3637b4b234f0bf7fe795977cb7ec6a1ca5449810
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293006
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This change ensure that if the user makes an erroneous switch
expression by imitating the syntax of case statements (i.e. using
`case`, `default`, `:` instead of `=>`, or `;` instead of `,`), error
recovery will understand the user's intent, avoiding follow-on errors.
Fixes#51886.
Bug: https://github.com/dart-lang/sdk/issues/51886, https://github.com/dart-lang/sdk/issues/51943
Change-Id: Icd405d4fd4ddfb1aadcf0867e5a51ba898d4cdbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Previously we'd fail to match anything here and end up using "top level", showing snippets for creating classes. This adds enums to "inClass" showing things like "function" snippets.
I didn't split class/enums because right now we don't have any snippets that would differ, though we might want to do this if that changes.
Fixes https://github.com/Dart-Code/Dart-Code/issues/4473.
Change-Id: I67c8e2a67698fb15136cba68b63549acf29ee596
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292884
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Previously, if a pattern variable declaration appeared outside of a
function or method, the parser would get very confused. Now it
recognizes the situation, issues a comprehensible error message, and
replaces the pattern with a synthetic identifier token so that the
analyzer AST is somewhat sensible.
Fixes#51322.
Bug: https://github.com/dart-lang/sdk/issues/51322
Change-Id: Ica5f060cb483a39c4e50942d639939b1fab40bea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293087
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This updates the message report for non-exhaustive switch statements
and expressions to include the witness in the problem message and
a reduced witness, which doesn't include properties that fully cover the
static type. The message is also split into two messages; one for
switch statements and one for switch expressions, allowing for a
better wording regarding the default/wildcard pattern case.
Change-Id: I17db657ef12ade5d47fa96bf69b8807e33ed5b8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293040
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
+ don't assume a semicolon on the end of a switch expression.
Change-Id: Ie141996bc79e3764c70dea66f570ca17046eecdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Now that https://dart-review.googlesource.com/c/sdk/+/291500 has
landed, `dart run` now tries to invoke `dart pub` before execution.
This doesn't work when running scripts inside the SDK, because the SDK
doesn't use pub to get its dependencies. So scripts in the SDK now
need to be run with `--no-pub`.
Change-Id: Ic320b717b2d45278cd26d373ae0823c2935ce102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
We use this pattern to find expectations to update.
Change-Id: Ibae370cfdf85dd83122b5571f3a05d86355c647f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290344
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The precedence-based pattern parser can understand a unary pattern
inside another unary pattern (e.g. `_ as int as num`) or a relational
pattern inside a unary pattern (e.g. `> 1?`), but the specification
prohibits these constructions because they're difficult to read and
not very useful.
This change updates the implementation to match the spec, by producing
the appropriate error. The offset and length of the error cover the
inner pattern, so it should be easy to construct an analysis server
quick fix that inserts the necessary parentheses.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I33e74d6d1f863e7162851d26fefbacd4fd17277c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
A `@reopen` annotation is invalid when it annotates a declaration which
does not reopen anything.
Fixes https://github.com/dart-lang/sdk/issues/51592
Also cleaned up some code around reporting other invalid annotations.
Change-Id: I5add39cf2ef553a3441d39dfc47bcd1ffdbeb8ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292140
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This will save me a lot of time because I keep forgetting where the
status file is.
Change-Id: I3ab6ad59f66c4e84515bad3a6b7689b6b47ecddf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292283
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This allows for users to dismiss a notification without taking any action (something that VS Code / LSP allows for but this API did not).
Change-Id: Icf384008cfcfde6f150c63d3f2889e81e79d1dc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
The listener API for variable patterns is split into three separate
functions, to handle the three separate behaviors:
- `handleAssignedVariablePattern` for variable names appearing in an
assignment context (these assign to an existing variable upon a
successful match).
- `handleDeclaredVariablePattern` for variable declarations appearing
in a declaration or matching context (these cause a new variable
name to come into scope).
- `handleWildcardPattern` for wildcards in any context (these don't
capture the matched value).
Also, responsibility is shifted to the parser for reporting the
following error conditions:
- VariablePatternKeywordInDeclarationContext (e.g.
`var (var x) = ...;`)
- PatternAssignmentDeclaresVariable (e.g. `[x, var y] = ...;`)
Previously these errors were detected by the implementations, and
weren't fully covering all possible error scenarios.
In the case of VariablePatternKeywordInDeclarationContext, the
listener method `handleDeclaredVariablePattern` is called instead of
`handleAssignedVariablePattern`. This ensures that no tokens are
dropped from the analyzer AST. The CFE uses the `inAssignmentPattern`
argument of `handleDeclaredVariablePattern` to distinguish this error
recovery case from a legitimate declared variable pattern.
Fixes#51868.
Bug: https://github.com/dart-lang/sdk/issues/51868
Change-Id: I28ec679b73d64033166721c6460be35f15e23171
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291583
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Added error messages for when users try to use invalid mixins + a language test that tests that (and tests in each of the front ends).
Removed the tokens from the parser listeners.
Removed all behaviours and error reporting related to these invalid mixins.
Change-Id: I558595826dae7e2c176bd1929e97caa2335c167c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290614
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>