Commit Graph

552 Commits

Author SHA1 Message Date
Sam Rawlins 843a31fe45 Prefer string interpolations; other small fixes for lints 2.0.0
Change-Id: Ie66c42ac738adbcf07d0b7c5ccc77e34975008c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237801
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-18 22:13:21 +00:00
Sam Rawlins d5cc53a1b8 Prefer for-loop over forEach; other little fixes
These linter fixes help prepare analyzer for lints 2.0.0

Change-Id: Ic942fa367965edac479b917cbbb601b30da8b53c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237766
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-18 03:37:47 +00:00
Johnni Winther fa05359f2f [cfe] Support augmentation library imports
This adds support for the `import augment <uri>` import syntax when
the 'macros' experiment is enabled.

The CL also include propagation of the augment modifier on class methods
which was missed in a previous CL.

Change-Id: Ic843e7e34559bcac728c810590f34b727b5f7090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-28 11:42:34 +00:00
Parker Lougheed edc352030c [pkg/analyzer] Fix some minor diagnostic message issues
Change-Id: I7eb437eda9eb1683274ba302148759553c68af5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-02-27 18:41:33 +00:00
Brian Wilkerson 2f9d45b8bf Add new diagnostic documentation
This also adds links for some annotation in `meta` that were in existing
tests.

Change-Id: I8260e0d4f40f88228c953ead19b77680c2f69ef4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234449
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-02-26 21:20:24 +00:00
Devon Carew 150df0637f [analyzer] remove the dep on package:cli_util
Change-Id: Ie5b0c29ae443588c501dd2012e645618aff17ca4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231846
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-02-06 05:26:40 +00:00
Konstantin Shcheglov 0962b173d6 Replace 'enumeration' with 'enum' in messages.yaml
Change-Id: I62d389bb9462a15f2b08d2fb313fc1a3fca74379
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231742
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-04 22:00:41 +00:00
Konstantin Shcheglov 14bead484c Report more enum hierarchy errors for enums.
Change-Id: I9ffc41ce9cbc9a51b059dc8a891e59420232d047
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231536
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-04 18:51:39 +00:00
Konstantin Shcheglov 22a8295295 Report INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR instead of INSTANTIATE_ENUM when enhanced-enums.
Change-Id: I634b3e50641b2b696b4d9e164266b43fdc72f137
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231063
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-01 23:58:45 +00:00
Brian Wilkerson 7272aadca4 Add diagnostic documentation for most of the ffi diagnostics
Change-Id: I37ba1852dea9c7e53966050eafaed9bb61cffbb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229580
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-01-24 20:02:27 +00:00
Konstantin Shcheglov 6d5543e01b [analyzer] Update generated experiments
experimental_features.yaml was updated in
https://dart-review.googlesource.com/c/sdk/+/219789
but unfortunately the analyzer code wasn't regenerated.

This CL updates the generated files and adds capability of checking
consistency to the generator. A check of consistency is add next to
the check for consistency used in presubmit for the CFE counterpart.

Was: https://dart-review.googlesource.com/c/sdk/+/224520
Change-Id: I59be4335ee81743aca5dc48eaa0df278d64d3692
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229020
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-01-20 00:07:36 +00:00
Brian Wilkerson 3fbe18b612 Replace "field formal" with "initializing formal" in diagnostic documentation
This appears to be the more widely used term for formal parameters of the
form `this.x`, and the docs ought to reflect common usage.

Also, fixes a typo in one other message.

Change-Id: I261d05e78f813db91a1df072bd72356a5e366226
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/228600
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-01-18 23:18:45 +00:00
Sam Rawlins a1d5eba2ae analyzer: do not use leading underscores in local variable names
This is not yet enforced in analysis_options.yaml due to a just-closed
bug in linter.

Change-Id: I450ed2a24f1de7657b2f535a1dcdabdb1f9afbbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226321
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-01-05 18:00:44 +00:00
Brian Wilkerson ccc1656eb0 Improve the message when the required keyword needs to replace the required annotation
Fixes https://github.com/dart-lang/sdk/issues/46841

Change-Id: If318064a901f3cf1cbcf117ad392d72a9cf004fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-01-05 16:38:25 +00:00
Sam Rawlins b16b0322b9 Reland "analyzer: Report missing return for nullable return types"
This is a reland of 93bcdf0329

Original change's description:
> analyzer: Report missing return for nullable return types
>
> This is implemented as a new HintCode, but it could be a new Warning, if
> we'd like to stop adding new Hints.
>
> There is also a dartfix available in this change.
>
> Fixes https://github.com/dart-lang/sdk/issues/46656
>
> Change-Id: I8e93e576d2bd09a8ff02d52c12bbb9ec6adff9c2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220803
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

Change-Id: I369b2dc38db0dc278f50b55aab67da53a5a63a8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-12-22 18:46:14 +00:00
Alexander Thomas 3b5d06e449 Revert "analyzer: Report missing return for nullable return types"
This reverts commit 93bcdf0329.

Reason for revert: Broke google3 rolls.

Original change's description:
> analyzer: Report missing return for nullable return types
>
> This is implemented as a new HintCode, but it could be a new Warning, if
> we'd like to stop adding new Hints.
>
> There is also a dartfix available in this change.
>
> Fixes https://github.com/dart-lang/sdk/issues/46656
>
> Change-Id: I8e93e576d2bd09a8ff02d52c12bbb9ec6adff9c2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220803
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

TBR=scheglov@google.com,brianwilkerson@google.com,srawlins@google.com

Change-Id: I122be4cb1d07f7f95334d2d5cbac1de4bd597d15
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224950
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-12-22 08:38:52 +00:00
Sam Rawlins 93bcdf0329 analyzer: Report missing return for nullable return types
This is implemented as a new HintCode, but it could be a new Warning, if
we'd like to stop adding new Hints.

There is also a dartfix available in this change.

Fixes https://github.com/dart-lang/sdk/issues/46656

Change-Id: I8e93e576d2bd09a8ff02d52c12bbb9ec6adff9c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220803
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-12-21 18:22:03 +00:00
Sam Rawlins f370d5c5ca analyzer: Wrap error message and correction message strings
This just adds a wrapping step to message generation to generate
Dart strings that are wrapped at (or before) 80 characters.

Change-Id: I55b2e307c73beac567cf15492fcca733e1c61a12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223442
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-12-14 00:01:53 +00:00
Chloe Stefantsova 312eb812c8 [parser][analyzer][cfe] Add parsing support for enhanced enums
Part of https://github.com/dart-lang/sdk/issues/47453.

Change-Id: I3a722cbcca6323b751eb3b2429bb9ffb642972b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217011
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2021-12-03 17:05:39 +00:00
Chloe Stefantsova 46cf1b9dd6 [parser][analyzer][cfe] Add parsing support for super-parameters
Part of https://github.com/dart-lang/sdk/issues/47525

Change-Id: I7b824e5e3fc9dbb2c6416dfd15df274037a8e9e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219521
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-11-19 16:56:07 +00:00
Brian Wilkerson 0d6df5a1f1 Use contractions in the docs in a couple more places
Change-Id: Ic685ba6d74f3f495d740b3396663aa9ad25df768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220221
Reviewed-by: Kathy Walrath <kathyw@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-11-17 18:22:48 +00:00
pq b403d4bf73 Reland "hints for text_direction_code_points"
This is a reland of 39008c8243

Original change's description:
> hints for text_direction_code_points
>
> Fixes: https://github.com/dart-lang/sdk/issues/47611
>
> Related: https://github.com/flutter/flutter/pull/93034
>
>
> Change-Id: Ia6bac44e1c9a7ef25f01683b8414b9818822cb7f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219123
> Commit-Queue: Phil Quitslund <pquitslund@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Kathy Walrath <kathyw@google.com>

Change-Id: Ib200aa2e6f1a323a6d01cc3c051657fd48f41251
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219750
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
2021-11-10 00:09:33 +00:00
Siva Annamalai 90749574b6 Revert "hints for text_direction_code_points"
This reverts commit 39008c8243.

Reason for revert: breaks G3 builds please see https://ci.chromium.org/p/dart/builders/ci.sandbox/google

Original change's description:
> hints for text_direction_code_points
>
> Fixes: https://github.com/dart-lang/sdk/issues/47611
>
> Related: https://github.com/flutter/flutter/pull/93034
>
>
> Change-Id: Ia6bac44e1c9a7ef25f01683b8414b9818822cb7f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219123
> Commit-Queue: Phil Quitslund <pquitslund@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Kathy Walrath <kathyw@google.com>

TBR=lrn@google.com,brianwilkerson@google.com,pquitslund@google.com,sra@google.com,kathyw@google.com

Change-Id: I82c2b471bc9566222db4616bba501534c35b4f9e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219747
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-11-08 22:48:43 +00:00
Sam Rawlins 8900608365 Report fewer duplicate errors for invalid superinitializers
Fixes https://github.com/dart-lang/sdk/issues/45958

Move check out of old checker.dart, into (less old) error_verifier.dart
and move test case out of old checker_test.dart. Add valid test case.

Rename INVALID_SUPER_INVOCATION to SUPER_INVOCATION_NOT_LAST, and
correct comment on that code (it has a parameter).

Do not duplicate report that code with MULTIPLE_SUPER_INVOCATIONS or
with SUPER_IN_REDIRECTING_CONSTRUCTOR.

Change-Id: I26e28b345fd8cef8ed2c9ec89ab12b56ea1c2f37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218982
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-11-08 18:53:42 +00:00
pq 39008c8243 hints for text_direction_code_points
Fixes: https://github.com/dart-lang/sdk/issues/47611

Related: https://github.com/flutter/flutter/pull/93034


Change-Id: Ia6bac44e1c9a7ef25f01683b8414b9818822cb7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219123
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
2021-11-08 18:38:28 +00:00
Sam Rawlins 2ad8673059 Add 'previousName' field to ErrorCodeInfo for renamed errors
Bug: https://github.com/dart-lang/site-www/issues/3652
Change-Id: I7172691217c5d9447505b1a953ca1dda1825443d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-11-04 17:06:34 +00:00
Paul Berry 7913e0fe16 Split analyzer and front end ErrorCodeInfo into two classes.
Although I eventually hope that the analyzer and front end
`messages.yaml` files can support exactly the same functionality, at
the moment there are differences, and I need to introduce a few
additional differences in upcoming CLs.  Having two classes to
represent analyzer and front end messages will make it easier to deal
with these differences.

Change-Id: I6148ed71a69d8e94b8c4f78d4168a04ec1c83cb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-11-01 17:59:01 +00:00
Sam Rawlins 930697a158 Improve messaging of invalid yield type
Fixes https://github.com/dart-lang/sdk/issues/47379

We use a separate message for yield expressions, so that the yielded
type can be used. In checking against the yielded type, we also stop
reporting in some cases, which removes duplicate errors.

Change-Id: I2ce036086ca06d5ff32531afd4b1812f17b908ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218745
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-11-01 15:28:51 +00:00
Paul Berry ad23a8e5eb Rework error handling in message decoding.
This should make the errors much more comprehensible if there is a
formatting error in one of the `messages.yaml` files.

Change-Id: Ic2593d7b86a8a405dfdfe7ed40d2e50fa4c2c6d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-20 17:08:01 +00:00
Ahmed Ashour d041cf0478 Remove extra the, be and of
Fixes #https://github.com/dart-lang/sdk/issues/47504

TEST=No tests needed, only comments affected.

Change-Id: Ie096307b5ce314d328fea6780f396aaa226ad3b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216182
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-10-20 09:29:01 +00:00
Paul Berry 04c8ef2bf1 Reduce the use of <unnamed> in analyzer error messages.
Two error messages are affected:

1. When the user tries to access a static member of an extension
through an instance of a class that mentions the extension's "on"
type, and that extension is unnamed, we now report
INSTANCE_ACCESS_TO_STATIC_MEMBER_OF_UNNAMED_EXTENSION instead of
INSTANCE_ACCESS_TO_STATIC_MEMBER.  The new error message is the same
as the old one (and uses the same sharedName), but it omits the
correction message suggesting to the user that they try accessing the
static method directly via the extension name, since this advice
doesn't apply.

2. When we report AMBIGUOUS_EXTENSION_MEMBER_ACCESS, if one of the
ambiguous members comes from an unnamed extension, we now report the
unnamed extension as "unnamed extension on '$type'" rather than
referring it to as an extension named `<unnamed>`.

Change-Id: I3ca3a1ccc9399b26b083040de20db8e4f691be32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217102
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-18 19:27:18 +00:00
Paul Berry 267323de7d Remove unnecessary declaration names from error codes.
The errors HintCode.INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION and
CompileTimeErrorCode.EXTENSION_CONFLICTING_STATIC_AND_INSTANCE didn't
really need to name the enclosing declaration, since the user can
easily find the enclosing declaration from the location of the error
message.  Without this change, there are some situations where an
error message would awkwardly refer to an unnamed extension as having
the name `<unnamed>`.

Change-Id: I4ddec389f18e78167464b1b5c35556e92dd1c15f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216860
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-18 18:26:04 +00:00
Paul Berry 72daafd70c Fix correction message for CompileTimeErrorCode.INSTANCE_ACCESS_TO_STATIC_MEMBER.
Previously, it assumed that the static member was always a class; it
could also be an extension or a mixin, and the extension could be
unnamed.  This change causes extensions (named and unnamed) to be
handled properly.

Handling mixins will be more complicated (since it will require
expanding ElementKind to include mixins), so that is not addressed
right now (see https://github.com/dart-lang/sdk/issues/47452).

Change-Id: Ie01a6abfdb560d97e545d36255909da19500b3c4
Bug: https://github.com/dart-lang/sdk/issues/47452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-14 22:13:55 +00:00
Brian Wilkerson d6936a5749 Make the use of Example and Examples more consistent
I think the headings are now 'correct' in the sense that they are
singular when there's a single example and plural when there is more
than one.

In the process I noticed that we have a similar problem with 'Common
fixes' in that sometimes there's one fix and sometimes multiple. I
don't think it would read well to say 'Common fix', so I'm disinclined
to change those, but it makes me wonder whether I should have just
used 'Examples' everywhere.

Change-Id: Idbfc3354b52cf1da677db51f4c626bb3269465b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215983
Commit-Queue: Kathy Walrath <kathyw@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
2021-10-13 21:41:17 +00:00
Konstantin Shcheglov aeb6767650 Issue 47407. Move USE_OF_NATIVE_EXTENSION to CompileTimeErrorCode.
Bug: https://github.com/dart-lang/sdk/issues/47407
Change-Id: I342579ecac391ffc013cf7f05e81584996a7eea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216268
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-12 16:13:30 +00:00
Konstantin Shcheglov c3b31a94d3 Return Uint8List from summary builders.
R=brianwilkerson@google.com

Change-Id: Ib8e71d9094049129b3c4c6d3d3dcbf3f055e2864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216271
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-12 01:20:44 +00:00
Paul Berry c52a4261c0 Modify analyzer documentation handling tools to read from messages.yaml.
Previously, `pkg/analyzer/test/verify_diagnostics_test.dart` and
`pkg/analyzer/tool/diagnostics/generate.dart` extracted documentation
from the code of the analyzer error classes.  However, since this code
is generated from `messages.yaml`, it's much cleaner to just extract
the documentation directly from the YAML.

Change-Id: I7dc3eb73abbf5d72f203abbf04e43856b60d2a89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215648
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-07 13:17:13 +00:00
Paul Berry a706779df1 Refactor additional logic for analyzer error message generation.
This change moves a lot of logic into `error_code_info.dart`.  In a
follow-up CL I'll make use of this code to re-work
`verify_diagnostics_test.dart` and the code generator for the
analyzer's `diagnostics.md` file.

Change-Id: I0dca7d30a9def771f03c6a51d26335aeab1c964c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215662
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-06 16:08:49 +00:00
Paul Berry 25532307c4 Clean up code for parsing analyzer documentation and extracting code samples.
Previously this logic was duplicated in two separate locations,
`verify_diagnostics_test.dart` and the code generator for
`diagnostics.md`.  Unifying it will pave the way for a follow-up CL in
which I intend to parse the documentation directly from the
`messages.yaml` files (rather than from comments in the analyzer
classes that are generated from those files).

I've also taken this opportunity to add some more checks to the
parsing logic, so that mistakes in the documentation (e.g. misspelling
a section header) will be reported as errors rather than causing a
silent loss of functionality.

Change-Id: Icfcb52229eb94bb06bc57334e265ef4d6db299de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215580
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-05 17:29:41 +00:00
Johnni Winther cf1591f935 [cfe] Refactor detection of instance type variable access in static context
NamedTypeBuilder is now created with a state that determines whether it
can validly be resolved to an instance type variable.

Change-Id: I1e7f5f8e05a5f68ec18a063476b6cda291a1aca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214643
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 11:58:04 +00:00
Paul Berry 757d179380 Update nomenclature in ErrorCode and related classes.
This change standardizes most of the analyzer to refer to problem
messages and correction messages using the names `problemMessage` and
`correctionMessage` (consistent with the naming convention used in the
analyzer and CFE `messages.yaml` files).

Change-Id: I72f078a368c65b346626f560cc721fcff4836452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215151
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-04 19:50:37 +00:00
Paul Berry 90cfd7afd0 Rename syntactic_errors.analyzer.g.dart to syntactic_errors.g.dart
Change-Id: Ibf80d44306313950c309af76122151086c7e7dc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215362
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-04 15:09:46 +00:00
Paul Berry b2c2acee09 Adjust front end nomenclature for error messages.
This change updates the classes Message, MessageCode, Template,
LocatedMessage, and FormattedMessage so that they uniformly refer to
error message text using the terminology `problemMessage` and to
correction suggestions using the terminology `correctionMessage`.
This brings them into alignment with the names we've decided to use to
unify the structure of front_end and analyzer, and makes them match
the names used in the anlayzer and front end's `messages.yaml` files.

Change-Id: Idcbb7ccfff6bb4e99ca22a3ef3c19d83880cf3c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215154
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-04 13:32:46 +00:00
Paul Berry 33f69b0ced Clean up documentation/comments handling for shared errors.
For errors that are shared between the front end and the analyzer, we
move the `documentation` and `comment` fields from
`pkg/analyzer/messages.yaml` to `pkg/front_end/messages.yaml` (where
the rest of the information about the error is).  This eliminates the
need to have any entries at all for these shared errors in the
`pkg/analyzer/messages.yaml` file, so we no longer need the boolean
flag `copyFromCfe` in this file.

This simplifies generation of analyzer error codes, so we go ahead and
take this opportuntity to remove the old `syntactic_errors.g.dart`
file, and instead code generate all the shared messages directly into
`syntactic_errors.analyzer.g.dart`.

In a follow-up CL I'll rename `syntactic_errors.analyzer.g.dart` back
to `syntactic_errors.g.dart` to reduce confusion.

Change-Id: I1e314e51c94ef595d9d6de8ba2b30e12a18382a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215155
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-04 13:03:26 +00:00
Paul Berry 67a119abe8 Update nomenclature in messages.yaml files.
Change the terms `template`/`tip` in the analyzer and front end's
`messages.yaml` files to `problemMessage`/`correctionMessage`.

Rationale: these terms were previously agreed on for unifying the
analyzer and front end, and they are currently used in the
`Diagnostic` class, which is part of the analyzer public API.
Change-Id: Ifaed92ab5176bba7b7f4c3bb915e9839520330f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215149
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-01 15:32:06 +00:00
Paul Berry 97255ff97e Code generate analyzer errors from the analyzer's messages.yaml file.
Change-Id: I1687acd7c777733caf93e20d703554c2a7da26cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214304
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-01 15:24:13 +00:00
Paul Berry bdbb4baea5 Create a YAML file to hold analyzer error text.
I've included both the YAML file (`messages.yaml`) and the script I
used to create it (`extract_errors_to_yaml.dart`), so that we can keep
the YAML file up to date until we finish writing logic that code
generates the analyzer errors from the YAML file.

Change-Id: Icbdcaf63a37105b666b11f7356e3fa246a8d65cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214133
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-01 13:04:39 +00:00
Paul Berry bbbd124c59 Create tables mapping CFE/analyzer error codes and indices.
Previously, these mappings were computed on the fly during generation
of syntactic_errors.g.dart.  Moving the mappings to their own data
structure makes the logic easier to re-use.

Change-Id: I1c38649b8c4aa4a42a6aa560faf67502d1c6560f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215001
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-29 18:16:30 +00:00
Konstantin Shcheglov 9826867fd0 Remove the macro prototype.
Our understanding improved, and out approach changed significantly.
So, this existing implementation is different enough to be not
very useful anymore. And it gets in my way while doing other changes.

Change-Id: If31c20a0a6f86c01a58d16390a989f77962396b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-27 23:07:53 +00:00
Paul Berry 15a028d5ec Fix SDK version associated with SDK_VERSION_GT_GT_GT_OPERATOR hint.
The `>>>` operator wasn't released until 2.14.0, not 2.3.2.

Change-Id: Ief7b7b3982109a290d229a1ede817e66bc10a6c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-27 16:17:43 +00:00