Commit Graph

3511 Commits

Author SHA1 Message Date
Konstantin Shcheglov 53bf3ff846 Elements. Rename to ClassElementImpl2, etc.
Change-Id: I94119f60b5bf01e52cf348a7c67f2b4a5ba62900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393583
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-05 18:42:21 +00:00
Konstantin Shcheglov 1a0273672a Elements. Build TopLevelFunctionElementImpl during building elements.
Give it a reference.

Change-Id: Ie1189a18e9d2794d37e530cbbb01ddd86b78a16e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393164
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-01 22:21:00 +00:00
Konstantin Shcheglov 2d0eedc100 Elements. Keep only AugmentedInstanceElementImpl and subclasses.
Having single implementation of `ClassElement2` (and other elements like it) makes the implementation easier now, and simplifies future changes.

Change-Id: Ifd38a8738fff99b7ac0b387140fdd623be18be01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-01 14:58:14 +00:00
Danny Tuppeny 27b52a3f82 Add languageVersion to CompilationUnit and make non-null
Change-Id: Ice6f866929f1f028d9b4e64685c2e815a08279f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-31 18:49:03 +00:00
Sam Rawlins 97871aeab5 analyzer: Use less AnalysisOptionsImpl
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>
2024-10-29 14:22:58 +00:00
Konstantin Shcheglov 106489ae1c Elements. Add reference for enum, extension, extension type elements.
Change-Id: I1b204a256bf8845959ccde1de5a755994b3ff105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392101
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-28 21:21:29 +00:00
Sam Rawlins bc58f69e53 analyzer: Move AnalysisOptionsImpl out of the generated directory
None of the code in AnalysisOptionsImpl or AnalysisOptionsBuilder is
changed.

Change-Id: I0d3253d80fdcd624c73720c35ece9d23a2582071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392180
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-28 21:03:33 +00:00
Konstantin Shcheglov 74a2bc7af4 Elements. Add reference for MixinElement2.
Change-Id: I8cce4acc8f499754ff8d5e96930ae1b5d86943a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392061
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-25 20:13:48 +00:00
Konstantin Shcheglov 9e1ac08817 Elements. Add 'ElementImpl2.reference', implement for ClassElement2.
Change-Id: Ie555b0032bba93f9c3d0dcd4cdef819eec6e1187
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391841
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-25 00:02:48 +00:00
Parker Lougheed 701dfa233a [linter] Follow-up clean up for lint name and code generation
- 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>
2024-10-10 14:29:08 +00:00
Brian Wilkerson 450c1962d0 Make members a subtype of element rather than fragment
Change-Id: I4fce1d1a3a63b79dcfc1b61903e5dcabd7771bfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388066
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-04 18:42:33 +00:00
Parker Lougheed a409a1c07d [analyzer/linter] Use shared enumeration for lint names
This helps to avoid any accidental mispellings, enables find usages, and potentially makes future renames easier.

The primary goal is to make future work in https://github.com/dart-lang/sdk/issues/56835 easier.

Change-Id: I684630a4d6cb145031de0dabc221f247246ea00c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-03 21:36:49 +00:00
Konstantin Shcheglov 4fe2944776 Parts. Consider 'part' of 'part of lib.name' as an error.
Maybe? https://github.com/dart-lang/co19/issues/2907

Change-Id: If64ba74bf8d3ad3f5e1b926f19705ae469c76a5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387820
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-02 18:16:14 +00:00
Sam Rawlins f84a81002c linter rules: tidy up test support
Just little things:

* Convert the class AnalysisOptionsFileConfig and it's `toContent`
  method into a single function.
* Convert the class PubspecYamlFileConfig and it's `toContent` method
  into a single function.
* Privatize ExpectedDiagnostic fields `diagnosticMatcher`, `offset`,
  `length`, `messageContains`,
  ExpectedError field `codes`,
  ExpectedLint field `lintName`,
  LintRuleTest field `collectionIncludedPaths`,
  _ContextResolutionTest field `sdkRoot`.
* Privatize `writeTestPackageAnalysisOptionsFile` and
  `writeTestPackagePubspecYamlFile`
* Start doc comments with a single-sentence summary (https://dart.dev/effective-dart/documentation#do-start-doc-comments-with-a-single-sentence-summary and https://dart.dev/effective-dart/documentation#do-separate-the-first-sentence-of-a-doc-comment-into-its-own-paragraph)
* Document with third-person verbs (https://dart.dev/effective-dart/documentation#prefer-starting-function-or-method-comments-with-third-person-verbs)

Change-Id: I7d584810cd339f8184fe14c3151b55988bf2cfff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-26 14:33:04 +00:00
Konstantin Shcheglov b07eb3b325 Parts. Report PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER in parts.
This also moves the target to be the import prefix, not the declaration.
This is how the specification describes it, and scope lookup works.

Change-Id: Ic0f60a6b57bd8760589b1a91be8885fafb5c90c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-09-24 21:45:12 +00:00
Konstantin Shcheglov 09e3261127 Elements. Write FormalParameterElementImpl.
Change-Id: Icb61913fe0a195271e507c61e500a3f2be0ec689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-23 16:05:32 +00:00
Konstantin Shcheglov 6e0f03fd5e Elements. Print new elements for resolved AST.
Change-Id: I629151c61fafea61b4fe8cd1ff94a828d2a99754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-19 12:12:28 +00:00
Konstantin Shcheglov 35bbfb2314 Parts. Move changes to prepare for removing deprecated 'enclosingElement'.
Change-Id: I79804b8907627e54d993a905c62ffc36e6d348b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384963
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-12 20:33:20 +00:00
Johnni Winther cd236ece98 [parser] Add enclosingDeclarationName to beginMethod
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>
2024-09-05 07:40:09 +00:00
Fedor Shcheglov f3413b0ebf Remove tests that use import augment directive.
Change-Id: I9626aa0219aaff2884a8cd2e5fffee4dee5784ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383100
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-04 18:49:50 +00:00
Konstantin Shcheglov 8de1422a0e Parts. Deprecate Element.enclosingElement, use enclosingElement3.
Change-Id: Iadc4ed02d4bda3b882e65dc6f4d263a6a938e0fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-01 18:50:29 +00:00
Johnni Winther bf3c716f36 [cfe] Create FunctionTypeParameterBuilder for function types
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>
2024-08-22 08:23:05 +00:00
Sam Rawlins 5ce0cc571c analyzer: correct wording of "always null" and "never null" warning
Fixes https://github.com/dart-lang/sdk/issues/53670

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I5e890e990d128754b8d9a89e8e940c756779a602
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-08-19 16:14:28 +00:00
Konstantin Shcheglov 37540885ec Parts. Compress '::@fragment::libraryUri' into '::<fragment>'.
Example:
-      base: package:test/a.dart::@fragment::package:test/a.dart::@class::A::@constructor::new
+      base: package:test/a.dart::<fragment>::@class::A::@constructor::new
Change-Id: I85cc401f8b4c39eeadf295c89bab7872c80143f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378023
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-07-31 16:56:40 +00:00
Konstantin Shcheglov 9fefc36afa Parts. Use '@fragment' instead of '@unit', start compressing.
Change-Id: I9fd054d78c303fa1853bec9673f64deb620afd29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-07-30 17:19:29 +00:00
Sam Rawlins f4423e61ec Remove 4 old HintCodes, all replaced with WarningCodes
* UNNECESSARY_CAST
* UNUSED_ELEMENT
* UNUSED_ELEMENT_PARAMETER
* UNUSED_LOCAL_VARIABLE

Work towards https://github.com/dart-lang/sdk/issues/50796

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I15c74e5ebc626f7e513c04013aa2f81b36ca39a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377762
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-07-29 18:55:49 +00:00
Sam Rawlins c93e385975 analyzer: Improve support for ignoring all static warnings in a file
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>
2024-07-29 17:46:09 +00:00
Konstantin Shcheglov b7d3cdb5a7 Parts. Add 'libraryOrAugmentationElement', use as 'CompilationUnitElement.enclosingElement' for now.
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>
2024-07-24 23:07:35 +00:00
Konstantin Shcheglov 5dc0334b48 Parts. Use longer, more detailed reference strings.
Change-Id: I2fad120784b5c02f65af75f4c6c1a65fbf7c7b77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-07-23 18:46:19 +00:00
Konstantin Shcheglov 86e5463c37 Parts. Support for parsing and (not) reporting errors.
Change-Id: I4f352b7cc0c782eba96cd63e5b4a605657fd5c5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375541
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-07-15 20:43:17 +00:00
Jens Johansen 5d352e6627 [parser] Add begin and/or end to endElseStatement, endIfStatement, endThenStatement, endTryStatement
Change-Id: I27b7241665042a7fae6dc4c7d4192da9ce141b3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-06-19 06:12:00 +00:00
Sam Rawlins 4f5dc5603f analyzer: Deprecate dead properties on Comment
Work towards https://github.com/dart-lang/sdk/issues/56038

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If7ae2738fec598f16756c524b6bd6c258ee5609e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-18 18:27:25 +00:00
Konstantin Shcheglov 617f99700a Issue 52363. Check that the current name scope is LocalScope.
PatternAssignment is a strange expression that syntactcally can have
declared variables inside.

Bug: https://github.com/dart-lang/sdk/issues/52363
Change-Id: Id6132be26581112941b7b4828c8e232143ed59b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369505
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-06-04 16:47:14 +00:00
Jens Johansen 81f5879ca0 [parser] Rename firstToken to beginToken in beginSwitchCase/endSwitchCases
This makes it more consistent with other listener calls.

Change-Id: Iae98ae4c37078c15ea785faef1cb21b2ea85bb48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-06-04 08:23:36 +00:00
Sam Rawlins 030b79dc1c analyzer: Report bare 'super' expression as ExpressionFunctionBody
Fixes https://github.com/dart-lang/sdk/issues/55525

Change-Id: Id6e1321d093b4b77f0504748e931db8f460c1b45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369122
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-06-03 17:24:26 +00:00
Konstantin Shcheglov 1b9cc28879 CQ. Make FileSource API, move to lib/source.
Change-Id: I981d3f0904917ada322ca06448f03ff33ae1f095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369360
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-06-03 00:36:59 +00:00
Konstantin Shcheglov f69ac337ca CQ. Stop using File.createSource() in analyzer/.
This mixes layers, which I believe one of the ways that cause large
library cycles.

Change-Id: Ie1cf991bcd40b19127a6ade7efc5ad5fd69d0018
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368942
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-31 20:06:28 +00:00
pq 643b9ae8f7 remove unused parser error codes
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>
2024-05-22 15:08:18 +00:00
pq cf65fa73dd remove AstBuilder.enableNonNullable
Change-Id: Ifb7e049115297a34ed95a974b0a1e71540b54ce8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367148
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-05-20 20:08:25 +00:00
Konstantin Shcheglov 52999d58b6 Augment. Parse 'augment' for typedef.
Change-Id: I3d8c583bd5a20ded9e8004574314f0d3a076d649
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364940
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-30 15:51:25 +00:00
Konstantin Shcheglov 4432585051 Augment. Store 'augmentationTargetAny', check type in 'augmentationTarget'.
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>
2024-04-26 19:25:23 +00:00
Jens Johansen fc67d31862 [parser] Listener calls should not be on the next (unrelated) token
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>
2024-04-26 06:59:23 +00:00
Konstantin Shcheglov e90a6a7e61 Augment. Move primaryConstructor, representation, typeErasure into AugmentedExtensionTypeElement.
Change-Id: I7683c84ab4cbef22d559564f3cf4839a394b05d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363961
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-04-23 22:41:33 +00:00
Sam Rawlins 0895727c59 analyzer: allow trailing whitespace in ignore comments
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>
2024-04-22 16:53:42 +00:00
Konstantin Shcheglov b65887829e Augment. Report enums without constants after parsing.
Change-Id: I5af7fbc398bfa4ad2463fb9f37cef3757dd42151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-22 15:22:32 +00:00
Konstantin Shcheglov 4bb644ce3e Augment. Parse enum constant augmentations, allow just ';' before methods.
I was unable to update the parser to avoid requirement for ';' at all.
Ideally we should be able to parse:
```
enum E {
  void foo()
}
```

Change-Id: I7edba99454b965407c3fb402642933b3d8d6bb7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363106
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-17 15:26:31 +00:00
Konstantin Shcheglov 0ef8f05c6c Fix 'unnecessary_final' in analyzer/.
But don't enable it yet, pending https://github.com/dart-lang/linter/issues/4938

Change-Id: I42df6e5c2699b08d729518c0565165d81e07ad3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-16 21:46:15 +00:00
Konstantin Shcheglov 9844985cc4 Augment. Support for augmenting extensions, element model.
Change-Id: I2eaa5e14d0148710a15052cfee8dbf71d8e33237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-15 22:30:45 +00:00
Chloe Stefantsova 8aa400bf5f [analyzer][cfe] Share the implementation of the Variance class
Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: Ie406b59baf3efdeaac577f5181320b28c5076068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361781
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-04-10 13:08:55 +00:00
Konstantin Shcheglov ad345495ad Augment. Parse 'augment' for enum declaration.
Change-Id: I8360b86d675e423fe1a4e8d501b29a2b30f20fee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360781
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-04-03 15:59:49 +00:00