In many cases, AnalysisOptions is sufficient.
* ResolvedCorrectionProducer will be public API for someone writing an
analyzer plugin; it should not expose an AnalysisOptionsImpl. Luckily
the only need for the Impl, today, is in the "ignore diagnostic" fixes
so we can cast in there. (We could also expose the `file` and the
`unignorableNames` fields.)
* Some other spots only cast in order to access one of the 'strict'
fields, but all of those have been made public.
* AnalysisOptionsImpl.enabledLegacyPluginNames can be made final.
* Many other users don't need AnalysisOptionsImpl, or only need it to
pass it to other code that _does_ need it. In many of those cases it
makes sense to look at an object as an AnalysisOptions, and let the
code that needs a field from Impl to do a cast.
Change-Id: I3640934fb9d93c9b95f15a22457af604e420c7a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
- Add `.g` suffix to generated filenames and export from the base file.
- Rename `linter_lint_codes.dart` to just `lint_codes.dart` for simplicity.
- Export `lint_codes.dart` from `src/analyzer.dart` to avoid importing it in every rule file, as they all need it.
- Use pre-existing/shared `generateAll` method for generation.
- Add some explanatory docs and comments.
Bug: https://github.com/dart-lang/sdk/issues/56835
Change-Id: I605e39156bfcc5e3c19a01157426d26300eb877d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388058
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This adds the enclosingDeclarationName to the beginMethod of the
parser listener.
This enables the removal BuilderFactory.currentTypeParameterScopeBuilder.
Change-Id: Ie2bec9432c20b8bdbd62a14e8a65c272179d4698
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383182
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This changes the BodyBuilder to create FunctionTypeParameter instead
of FormalParameterBuilder for "parameters" in function types. This
avoids the creation of unnecessary VariableDeclaration nodes
function types.
The types of these VariableDeclarations where created before the type
variable scope was completed, introducing an artificial dependency on
the pending nullability computation.
Change-Id: Ie1203fa4c78a27f3e7a0dfad16725cbbde24a6a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381143
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Fixes https://github.com/dart-lang/sdk/issues/55331
Currently (I suppose accidentally), you can ignore all warnings with
'type=static_warning'. But that is not good UX; instead we can just
support 'type=hint', 'type=lint', and 'type=warning'. (Hints are on
their way out, but that is unrelated.)
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I82ea15a0601cb7bb962bd907406d83410dbd43f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377760
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Also, add separate 'get library'.
Medium term we will switch to `enclosingElement3` that will return
the unit element that includes this unit element (or null for defining).
Long term, with the new model, these will be fragments.
Change-Id: I999c99df610ad5792dbb3307c55e2b7577afacc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377271
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
The error codes are not being generated and the mapping to `EXTRANEOUS_MODIFIER` in tests is unnecessary.
This logic is likely a hold over from when the analyzer had it’s own parser with temporary conversion logic to align it with fasta. With only one parser, these bits are stale and should be safe to remove.
Change-Id: I5b29f0081953c61771b313025595910eef055c2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367540
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
So, we can distinguish "no target" from "invalid target".
If we augment a setter, and there is no target, we also probe getters
(and methods, constructors). Which theoretically is not the same as
augmenting e.g. a class with a mixin - they live in different names.
Not sure. Maybe don't look for `name` when `name=`?
The difference is that we will report "No augmentation target" vs
"It is wrong when a setter augments a method".
Change-Id: Ibee84b2d039cf16824cb367fefdcda72b99f54bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364603
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
When the parser sends events to the listener some events has a pair of
parameters, `beginToken` and `endToken`. Most of these are constructed
in such a way that the `beginToken` is the first token and the
`endToken` is the last token in that construct. This is for instance the
case with `endClassDeclaration`.
It was, however, not the case for `endMetadata` where `endToken` instead
was the next token *not* in the metadata.
In this CL I've found a changed the following to point to the last token
in the construct instead of the next token not in the construct and
renamed the parameter where it made sense:
* `endAssert` --- and renamed `semicolonToken` (which only pointed to
a semicolon for statements) to `endToken`.
* `endAwaitExpression`
* `endConstLiteral` --- and renamed `token` to `endToken`
* `endConstructorReference`
* `endFieldInitializer` --- and renamed `token` to `endToken`
* `endForIn`
* `endForInBody` --- and renamed `token` to `endToken`
* `endForStatement`
* `endForStatementBody` --- and renamed `token` to `endToken`
* `endFunctionExpression` --- and renamed `token` to `endToken`
* `endInitializer` --- and renamed `token` to `endToken`
* `endInitializers`
* `endInvalidAwaitExpression`
* `endMetadata`
* `endSwitchCase`
* `endTopLevelDeclaration` --- and renamed `nextToken` to `endToken`
* `endWhileStatement`
* `endWhileStatementBody` --- and renamed `token` to `endToken`
* `handleNoConstructorReferenceContinuationAfterTypeArguments`
In the few places in listeners where these values were used I've mostly
updated to do e.g. `endToken.text!` to retain the current behavior.
Change-Id: I25495e160d1eec5c75bcf1313b512cd04bcb1533
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364322
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Fixes https://github.com/dart-lang/sdk/issues/54247
The main piece of this CL is a rewrite of the `ignoredElements`
extension on CommentToken. This was a private extension getter, but
is made public now for two reasons: first is to reference it in tests,
and second is to make it available for a new lint rule in an upcoming
CL.
The new implementation drops all use of RegExp in order to more
precisely track when we may be at the end of a list of diagnostic
names and/or types. So the functional change here is that a diagnostic
name or type followed by whitespace instead of a comma marks the end
of the list. Any characters following that whitespace are not parsed,
as they are considered freeform comment text. While the new
implementation parses a comment code-unit-by-code-unit, it is still
a rather concise impl.
* Rename DiagnosticName and DiagnosticType to IgnoredDiagnosticName
and IgnoredDiagnosticType; these names make more sense to me,
specifically when they are used outside of the ignore_info.dart
file.
* I introduce a new test file, ignore_info_test, to capture these
various parsing particulars, that aren't specifically concerned with
matching an ignore comment with a diagnostic. A few test cases from
ErrorSuppressionTest are moved over here.
* A number of String (well, int, technically) helper functions are
moved to analyzer, along with their tests.
Fixes https://github.com/dart-lang/sdk/issues/54247
Change-Id: Ife08d448a4e03b8a55b183d88a3ea8d07812fbdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363820
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>