Commit Graph

7853 Commits

Author SHA1 Message Date
Danny Tuppeny 453647022f [analysis_server] Don't fail on invalid/complex setters in LSP code completion
Fixes https://github.com/dart-lang/sdk/issues/52050.

Change-Id: I6cf5420d5e017b501481cb436a7d1b17f46c0e44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295542
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-17 17:11:03 +00:00
Konstantin Shcheglov b78d89ce0c Fix DynamicTypeImpl to InterfaceTypeImpl cast exception in AddTypeAnnotation, when ambiguous SetOrMapLiteral.
Saw it in crash logs.

Change-Id: I631e4da816b689ec017f44ecd2a5dc70122ceec1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295501
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-17 16:34:37 +00:00
Brian Wilkerson 2197c81060 Add documentation for data-driven fixes
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>
2023-04-14 21:33:50 +00:00
Konstantin Shcheglov 36caf084b9 Issue 51953. Quick fix for ParserErrorCode.DEFAULT_IN_SWITCH_EXPRESSION
Bug: https://github.com/dart-lang/sdk/issues/51953
Change-Id: I21d7abdda8b7197cffb87a359c97f12e54cf427a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295390
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-14 21:15:18 +00:00
pq cae0bfa66f assist to destructure local record variable assignments
First, basic cut.

See: https://github.com/dart-lang/sdk/issues/52025

Change-Id: I3388f5ec96a45211669e3ac8a5975ff39feea4bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295381
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-04-14 21:04:20 +00:00
Keerti Parthasarathy 90c434254f Add support for patterns for Add type quick fix
Bug: 51866
Change-Id: Id38d0c8405931cad057ec3db1e0c0e3d297d7b4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-04-14 20:09:52 +00:00
Konstantin Shcheglov 0d6067232b Issue 51980. Reduce relevance of 'break' inside 'switch'.
Bug: https://github.com/dart-lang/sdk/issues/51980
Change-Id: Ic3a365c85a36a18739b20482c8c7c136210b12b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295387
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-14 19:37:38 +00:00
Konstantin Shcheglov 1925041a31 Issue 52019. Late instance field is not a static context.
Bug: https://github.com/dart-lang/sdk/issues/52019
Change-Id: I6416a2e65c93b08ad145c2e64129873ae414ccfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-14 17:58:24 +00:00
Janice Collins 1abf129bf8 Enable crash reporting via the unified_analytics consent mechanism.
This pulls in the `okToSend` method from https://github.com/dart-lang/tools/pull/79 in the tools repository.

Bug: https://github.com/dart-lang/sdk/issues/28633
Change-Id: I512d041750050338699d3635ba426cc0acdd5a20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
Auto-Submit: Janice Collins <jcollins@google.com>
2023-04-14 17:29:28 +00:00
Konstantin Shcheglov 9a6b637444 Issue 51989. Add 'Convert to switch statement' assist.
Bug: https://github.com/dart-lang/sdk/issues/51989
Change-Id: I297cbc077604d0c750dc0d78d8480b33852f3a64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295201
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-14 17:19:25 +00:00
Simon Binder a42a163f3b [analysis_server] Handle missing null in missing enum case fix
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>
2023-04-13 21:55:57 +00:00
Konstantin Shcheglov 63fd5aa364 Issue 52014. Make an implicit name of a named PatternField explicit when the pattern variable is renamed.
Bug: https://github.com/dart-lang/sdk/issues/52014
Change-Id: Ifcc8ba255cb536cba11360ef4326525c1e037b44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-13 21:02:37 +00:00
Sam Rawlins 2f30f88916 Mark deprecated Hints with Warning aliases as deprecated
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>
2023-04-13 20:07:36 +00:00
Konstantin Shcheglov f70238a83b Issue 52015. Extract local variable into SwitchCase / SwitchPatternCase.
Bug: https://github.com/dart-lang/sdk/issues/52015
Change-Id: I069ecfbd2be5375bdba9977872bc9e0c88431f62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-13 19:18:38 +00:00
Kallen Tu 2954986a7e [parser] Add errors for using class modifiers on enums.
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>
2023-04-13 14:59:57 +00:00
pq a45fc0f3c2 TokenType extension
See also: https://github.com/dart-lang/linter/pull/4272

Change-Id: Ie12b5d6a214bd085e12acf3b0c3745278aa7a8f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294881
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-12 22:50:27 +00:00
pq 05965ef720 + fix dangling library comments
Change-Id: Ia857fec46ddf83d307cd19450cea88aab8c86a38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294430
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-11 20:17:38 +00:00
pq 68ef7530d7 switch expression conversions (and unnecessary breaks removed)
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>
2023-04-11 19:56:05 +00:00
Jens Johansen 99395b2b0c [parser] Recover differently from mixin with clause
Fixes #50838 (https://github.com/dart-lang/sdk/issues/50838)

Change-Id: Ib0f0c01a07ab6232732a2be6c3aec34cb4bfdd29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-11 16:29:53 +00:00
pq f37e85049e Support bulk fixing dangling library doc comments
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>
2023-04-11 00:37:30 +00:00
Konstantin Shcheglov 9a6335fe14 Add "Unwrap 'if' body" assist.
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>
2023-04-10 23:51:55 +00:00
Devon Carew b603d4c4ac [deps] rev tools, web_socket_channel, webdev
Revisions updated by `dart tools/rev_sdk_deps.dart`.

tools (https://github.com/dart-lang/tools/compare/cd799be..58d9147):
  58d9147  2023-04-07  Christopher Fujino  [unified_analytics] Add NoOpAnalytics (#77)

web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/40eb236..b28bae6):
  b28bae6  2023-04-07  Rexios  Allow passing through custom http client in IO socket connect (#259)
  1064b47  2023-04-07  Nate Bosch  Fix deprecated_new_in_comment_reference (#262)

webdev (https://github.com/dart-lang/webdev/compare/22b34e3..7546291):
  75462913  2023-04-07  Elliott Brooks  Run mono_repo generate (#2081)
  9964ebab  2023-04-07  dependabot[bot]  Bump actions/labeler from 4.0.2 to 4.0.3 (#2067)
  3dee56b5  2023-04-07  Anna Gringauze  Remove eval error message on async frames (#2073)
  d6b3e9ce  2023-04-07  Elliott Brooks  Dart Code Metrics follow-up (#2072)
  48e3211a  2023-04-07  Elliott Brooks  Update the release script to take into account `pubspec_overrides.yaml` (#2080)
  fd75f511  2023-04-06  Elliott Brooks  Reset Webdev to 3.0.5-dev (#2077)

Change-Id: Iac863f7c4822fe6b9585e80e95d69467e8d60b6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294364
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
2023-04-10 17:44:36 +00:00
Danny Tuppeny cf8aaebc4a [analysis_server] Prevent colon from automatically triggering completion in switch statements
See https://github.com/dart-lang/sdk/issues/51980.

Change-Id: I66d52018f22442241a3203c08e3a58d5f1c2fbff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-08 16:17:20 +00:00
Brian Wilkerson 9b1798e081 Finish evaluating the status of fixes
Change-Id: Ie9a6709eb50f16771a340109bbd3e37918b8743e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294260
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-07 23:50:37 +00:00
Konstantin Shcheglov b1c0f16a51 Issue 51961. Suggest getter names inside pattern of named PatternField without name, inside RecordPattern.
Bug: https://github.com/dart-lang/sdk/issues/51961
Change-Id: I33b499829887dc221c2d18fe4586ec08207c026f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293863
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-06 19:55:08 +00:00
Danny Tuppeny da1898e0c7 [analysis_server] Prevent "dart fix" prompts if do-not-show preferences cannot be persisted
See https://github.com/dart-lang/sdk/issues/51968.

Change-Id: I67e0a85f171b9ff5c508063458fc92491c8e5c70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-06 15:59:07 +00:00
Konstantin Shcheglov ef79407d04 Enable language 3.0 for analysis_server/.
Change-Id: I6237a9ecfa95438ad1a5959183722cf95fe1cbba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-06 00:27:09 +00:00
Konstantin Shcheglov 7ba94c9202 Issue 51961. Suggest getter names inside pattern of named PatternField without name, inside ObjectPattern.
Bug: https://github.com/dart-lang/sdk/issues/51961
Change-Id: Ibd6f762f4e363f26daaca21515a9c23c748f8cc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293901
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 22:47:19 +00:00
Janice Collins b6cf3f9c22 Fix npe in UserPromptPreferences
Bug: https://github.com/dart-lang/sdk/issues/51968
Change-Id: I7bcaee7266b6c39ca21e11d3cc5e4eed94981294
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293920
Reviewed-by: Jacob Richman <jacobr@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-05 22:31:06 +00:00
Konstantin Shcheglov 2427527612 Suggest type names during completion in CaseClause and SwitchExpression body.
Change-Id: Iea7c2c3d0879191265c368b5e79fbf2cfaab0dd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293821
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 20:48:24 +00:00
Konstantin Shcheglov 006c60690e Increase timeout for SelectionCoverageTest.
Change-Id: Ic1e88478b500f87744dec64f3990f2681351a178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293742
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-05 18:34:08 +00:00
Janice Collins 17dd6d27cc Enable analytics support for VSCode.
Change-Id: Iea17bf917deccadb26a78470fabfb6fe5f4ada71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2023-04-05 18:19:21 +00:00
Keerti Parthasarathy a02f252ef1 Revert "Add support for patterns for Add type quick fix"
This reverts commit f4773e49c0.

Reason for revert: Breaks server tests
Original change's description:
> Add support for patterns for Add type quick fix
>
> Bug:51866
> Change-Id: I42d4443c38fc7708a2b174a80b689adfc0a37aaa
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293460
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Bug: 51866
Change-Id: I5d1f933fa7b88495f941b30001873c33206975f0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293820
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 18:13:37 +00:00
Keerti Parthasarathy f4773e49c0 Add support for patterns for Add type quick fix
Bug:51866
Change-Id: I42d4443c38fc7708a2b174a80b689adfc0a37aaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-05 17:53:59 +00:00
Brian Wilkerson 7bcc913ef1 Evaluate the remaining compilation errors
Change-Id: I9506c550598410533523e96d4ebd634589720725
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293387
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-04-05 16:21:41 +00:00
Kallen Tu b565a2f4c7 [analysis_server] Fix code completion for mixin declarations and class
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>
2023-04-05 16:05:35 +00:00
Sam Rawlins 7d6ab9bdfd Allow dead code in completion_metrics script.
Change-Id: I16751bcbb25f09c3a897de82c06ab424abcfcf1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293005
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-04-04 23:15:31 +00:00
Sam Rawlins 23b73d7ca4 ignore unreachable constructors in reflective tests
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>
2023-04-04 21:37:18 +00:00
Konstantin Shcheglov d47cd99310 Report NOT_NAMED_FIELD_IN_OBJECT_PATTERN
Change-Id: Iea58d3cef38c07f5fbac0dcbc8984ea727ffd93e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-04 21:36:38 +00:00
Konstantin Shcheglov 784998da98 Fix for EXPECTED_TOKEN, replace ':' with '=>' in SwitchExpressionCase.
Change-Id: I38080d8ec445bb6466c26c0233ac6dc719ba6f40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293084
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-04 19:14:25 +00:00
Paul Berry a3f5cfdc7f Patterns parsing: recover when switch statement syntax used for switch expressions.
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>
2023-04-04 18:52:59 +00:00
Konstantin Shcheglov c399536c3f Remove print() from getProcessUsage() test.
Change-Id: I0209e96e933713fa04e87f7c41e4be19b81c4001
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293163
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-04-04 16:15:39 +00:00
Danny Tuppeny b7fbf1e4b2 [analysis_server] Fix completion snippet context for inside enum declarations
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>
2023-04-04 15:08:41 +00:00
Paul Berry 8aa48712be Patterns parsing: recover from patternVariableDeclaration non-statement.
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>
2023-04-04 14:55:00 +00:00
Johnni Winther 5518abf1c7 [_fe_analyzer_shared] Update non-exhaustive message
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>
2023-04-04 09:44:59 +00:00
Keerti Parthasarathy 5c5f4ef65e Add a timer to send analytics data periodically.
Change-Id: Iaf58e3b7f45868579892ded8c005843d2f45b443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289402
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-04-04 03:27:27 +00:00
Konstantin Shcheglov 525376cc88 Fix ConvertToSwitchExpression when SwitchStatement is empty.
Change-Id: Id7ab8319ff5a9e41b353ed1363ce0d5159fe4ff2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292984
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 23:44:48 +00:00
Konstantin Shcheglov 4cb8bd0c37 Issue 51931. Fix for LATE_PATTERN_VARIABLE_DECLARATION.
Bug: https://github.com/dart-lang/sdk/issues/51931
Change-Id: I2b3c42389a5184086e66a1fc35c045d2581a2d8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293004
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 22:35:58 +00:00
Brian Wilkerson 40973edbb5 Handle type arguments when replacing an empty map pattern
Change-Id: I4c917d60d93a316459f2478cc21a7845af46781b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292920
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 21:02:18 +00:00
Brian Wilkerson aa1f415e4f Add a fix for invalid_inside_unary_pattern
Closes 51915

Change-Id: I378f66d70c083dd5852a9c8a04e3ddf59aff66d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-04-03 20:56:10 +00:00