Commit Graph

14934 Commits

Author SHA1 Message Date
Konstantin Shcheglov 6655f50989 Prepare to publish analyzer 6.10.0 and _fe_analyzer_shared 75.0.0
Change-Id: I05c4b308b8ca8f700cd4e135a999041db6271de8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-08 17:19:40 +00:00
Danny Tuppeny 5d84439f5d [analyzer] Add support for "formatter" in analysis_options + use page_width in LSP
This adds support for validation + completion for `formatter/page_width` in analysis_options, and uses this value in preference to the client-supplied value in the LSP server.

It does not yet add support for the legacy protocol, and there are a few questions in https://github.com/dart-lang/sdk/issues/56864#issuecomment-2399289974.

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

Change-Id: I7844e3abd1191beb9cc24197bbc8aa7c9e9ad4fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388822
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-08 16:37:54 +00:00
Kallen Tu c8ee0e78a5 [flow] Pipe the language feature flag inference-update-4 through flow analysis.
Weaves the flag `inference-update-4` through to `FlowAnalysis` and updating both the analyzer and CFE point-of-entry to include the flag.

This flag will be used in `flow_analysis.dart` to hide upcoming bug fixes to flow analysis.

Change-Id: Ib0004eb4bcf0b6e579116632b5973fe969e51e90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388582
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-10-08 16:32:24 +00:00
Paul Berry be17dc6d7a Remove unnecessary state restoring logic from analyzer constraint generation.
The `TypeConstraintGatherer` methods `trySubtypeMatch`,
`_functionType`, `_functionType0`, and `_recordType` have the
convention that if they do not find a match, they leave the set of
gathered constraints in the same state it was in at the time of the
call. The shared methods they invoke
(`performSubtypeConstraintGenerationForFutureOr`,
`performSubtypeConstraintGenerationForTypeDeclarationTypes`, and
`performSubtypeConstraintGenerationForFunctionTypes`) all follow the
same convention.

Because of this convention, much of the logic in `trySubtypeMatch` for
restoring the state of gathered constraints was actually redundant;
this CL removes the redundant logic. It also adds some comments to try
to clarify the calling conventions.

Change-Id: Ie11e4bc3edd3249191a09d9b93ae5844d5bf511c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388664
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-10-08 16:26:28 +00:00
Alexander Thomas d4aa30a3ba Revert "analyzer: Write out qualified extension names in error messages"
This reverts commit 10c1d883df.

Reason for revert: g/dart-sdk-rolls/MOLCzv4S-kQ

Original change's description:
> analyzer: Write out qualified extension names in error messages
>
> Fixes https://github.com/dart-lang/sdk/issues/56269
>
> Change-Id: I025966fd4aa3d7c5b71175321f21f95e8c41f086
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388580
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I613695e90c96e5ffdb4dc56e729dc34be385f5fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388823
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Alexander Thomas <athom@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-10-08 15:07:38 +00:00
Reid Baker e1dc36994a Bump dart version to 3.7
Change-Id: I9fec9765abfb46b2a3753367c20ac807fbdd487e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388600
Commit-Queue: Reid Baker <reidbaker@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2024-10-08 13:17:47 +00:00
Brian Wilkerson 5fab16aca2 Fix two tests in InheritanceManger3
There are still two failing tests, but I wanted to get these in before
some code started depending on the broken behavior.

Change-Id: I50f0e282293e756409064491e74c64311fbdf707
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388666
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-07 22:57:21 +00:00
Konstantin Shcheglov a17969b5c2 Parts. Deprecate also LibraryOrAugmentationElementImpl.scope
Missed it in the previous CL.

Change-Id: Ib887b8423ead76907c7302036a3d2089ba85dbfb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388720
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-07 22:02:13 +00:00
Konstantin Shcheglov 164777e2cd Part. Deprecate LibraryElement.scope
Change-Id: I85a24d0f1d0b4251415644fe1438503e41710436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-07 20:43:10 +00:00
Sam Rawlins 10c1d883df analyzer: Write out qualified extension names in error messages
Fixes https://github.com/dart-lang/sdk/issues/56269

Change-Id: I025966fd4aa3d7c5b71175321f21f95e8c41f086
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388580
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-07 18:01:54 +00:00
Konstantin Shcheglov 49e6c6da96 Parts. Inline LibraryOrAugmentationElementImpl.children into LibraryElementImpl
Change-Id: I52c6a6eb31ba8b01a3b1c0bdb1b545346bb7d8ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388581
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-07 17:08:22 +00:00
Konstantin Shcheglov 54c244b936 Test also search for CompilationUnitElement referenced in 'export' and 'part'.
Change-Id: I272de045d5e8d3287c568c108cf559955d32a091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388243
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-07 16:28:59 +00:00
pq 420d213904 [element model] migrate avoid_type_to_string
Bug: https://github.com/dart-lang/linter/issues/5099
Change-Id: Id13597e0e0bc09f9486b663b0f3337fa6314867a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388070
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-07 16:16:30 +00:00
Konstantin Shcheglov 3b8eca821c Elements. Export LocalVariableElementImpl2.wrappedElement
Change-Id: I8742dc8cf82c7144e501afbbf0755651f414b00f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388072
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-05 01:25:18 +00:00
Konstantin Shcheglov 95a2ddc688 Parts. Deprecate LibraryElement.parts
Change-Id: I4175fa8425728510d6179a0132a56f20af6bf57e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388424
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-04 21:02:45 +00:00
Konstantin Shcheglov eba5e1a619 Parts. Deprecate LibraryElement.prefixes
Change-Id: I0bf170dfde143c60c6e69b331ca3e1a8bc2f6448
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388422
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-04 19:10:45 +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
Konstantin Shcheglov 13a052e0e7 Parts. Deprecate LibraryElement.libraryImports
Change-Id: I9e3455fda9943123cc0aa0d95617f532bcec670f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-04 18:41:14 +00:00
Konstantin Shcheglov 7a62038143 Elements. Use LibraryFragment.libraryImports for PrefixElement2.imports
Change-Id: I797d7b8e38d2ca4d325dab425552b1b370fb84af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388420
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-04 18:05:12 +00:00
Konstantin Shcheglov 9e4817cca1 Parts. Move shouldIgnoreUndefined() to CompilationUnitElementImpl.
Change-Id: I79921f0e28e7f89165a01f143a92b6d49b7f4af5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388264
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-04 17:19:00 +00:00
Kallen Tu e872e360cf Add experiment flag for more flow analysis updates.
Working on a few bugs for flow analysis and I'll be putting them under this feature flag until we're ready to release.

Change-Id: I2bf01856d8d9cf0a8600a67c20df1a9b1c42e296
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388052
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-10-04 17:18:49 +00:00
Konstantin Shcheglov 4e0fe817fd Parts. Deprecate LibraryElement.libraryExports
Change-Id: I5d06bc1a2ce20a275f54f2185f437382ef659a14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388055
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-04 14:34:23 +00:00
Paul Berry 57bec7fedd [analyzer] Change some if/else chains to switch statements.
These if/else chains were selecting a behavior based on the type of a
collection element. Changing them to switch statements, and making use
of `CollectionElementImpl` (which is a sealed type), ensures that if
more kinds of collection elements are added in the future, we won't
forget to update the switches.

Change-Id: Iedd5d14aa22b7690902868ba15d9127d79bcad27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-10-04 14:15:08 +00:00
Konstantin Shcheglov a4124616c9 Parts. Deprecate LibraryElement.importedLibraries
Change-Id: I3407e7fe0aa92218346d8376854a6e4a639e8013
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-03 21:54:07 +00:00
Konstantin Shcheglov c87b93c6f1 Add withTokenPreviousNext to AST printer.
Bug: https://github.com/dart-lang/sdk/issues/56355
Change-Id: I0cd58070853cfe0fa59788b3ed4586fc156e27d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388054
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-03 21:50:31 +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 5f7e2b1b60 Parts. Deprecate LibraryElement.exportedLibraries
Change-Id: Ieb542d5c7241f31ebae389badb9fd99c560cfd48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388144
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-03 19:49:51 +00:00
Konstantin Shcheglov 331ca05414 Elements. Implement PrefixElement2 and PrefixFragment.
Change-Id: I547049096efa1ecf56f7b4adb77d21908d2da4db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388121
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-03 19:18:48 +00:00
Konstantin Shcheglov d5d8dc6224 Elements. Add overrides for 'firstElement' to provide more specific types.
Instead of https://dart-review.googlesource.com/c/sdk/+/388020

Change-Id: I74ab8f7c9733b57aafb0f2697fd738b445cfcc9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388023
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-03 16:11:00 +00:00
Chloe Stefantsova b2e282ad31 [analyzer] Implement inference for null-aware elements in Analyzer
This CL implements type inference for null-aware colletion elements
and map entires in the Analyzer. The new functionality is dependent on
the `null-aware-elements` feature flag, since only when the flag is
enable, can the `keyQuestion` and `valueQuestion` properties of the
MapEntryLiteralEntry class be not null and the objects of the
`NullAwareElement` be created.

Part of https://github.com/dart-lang/sdk/issues/56836

Change-Id: I9243b01d5de097ae0d2ca3376807c6209ef0f830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387980
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2024-10-03 16:09:32 +00:00
pq 7b3718c48f [element model] fix no_wildcard_variable_uses migration
Bug: https://github.com/dart-lang/linter/issues/5099

Change-Id: Ibde9394aa21fd4d81242e51cfad3f6166c1b2653
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388044
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-03 14:32:19 +00:00
Parker Lougheed a4a7af74df [linter] Deprecate the LintRule#categories property
The field is no longer specified or used as categories are now specified in the messages.yaml file.

Change-Id: I0b9e005c1af75629c61e9e02db4bafdd15af9320
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387823
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
2024-10-02 23:14:30 +00:00
Paul Berry 62da5477e0 Make some FunctionTypeImpl methods more efficient.
With the changes to `FunctionTypeImpl` landed in
https://dart-review.googlesource.com/c/sdk/+/386322, it's now possible
to implement a few methods more efficiently:

- `namedParameterTypes` can be accomplished by simply iterating
  through `sortedNamedParameters` once.

- `normalParameterTypes` and `optionalParameterTypes` can be
  accomplished by calling `sublist` on `positionalParameterTypes`.

Change-Id: Ia4e6132fab3a9b5b6792ecad0cf893f9c3e74ad3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388022
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-02 22:29:28 +00:00
Paul Berry a602b9ae20 Fix FunctionTypeImpl.hashCode.
This change addresses several drawbacks that previously existed in
FunctionTypeImpl.hashCode:

- The hash computation was complex and not cached, potentially slowing
  down performance.

- The hash computation failed to differentiate between optional
  positional parameters and required positional parameters, leading to
  a greater risk of hash collisions.

- The hash computation failed to differentiate between optional named
  parameters and required named parameters, leading to a greater risk
  of hash collisions.

- The hash computation failed to differentiate between named
  parameters based on their names, leading to a greater risk of hash
  collisions.

- The hash computation failed to account for the presence or absence
  of a nullability suffix, leading to a greater risk of hash
  collisions.

- The hash computation distinguished between equivalent types that had
  different type formal names, leading to a situation where two
  function types might compare equal but have different hash codes.

Of these drawbacks, only the last is a serious issue, since it
violates the implied contract of hash codes; the others are only
potential performance issues.

Change-Id: I9fbe4dd4751e7a070934e5d86de529765e135ac9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388100
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-02 21:55:59 +00:00
FMorschel 2fd313b62a fix renaming prefix
Fixes https://github.com/dart-lang/sdk/issues/56809

R=srawlins@google.com

Change-Id: I3df1f42923e7cb6382f7d6ad9875af6bb91a62a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387381
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-10-02 20:58:13 +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
Konstantin Shcheglov 69b358ec81 Parts. Test reusing import prefix, skip a file.
Change-Id: I807c15a807c1c8c789e9c4dfcc502278ee0bd98a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-02 16:23:49 +00:00
Konstantin Shcheglov bbb72e6eed Cider. Clear parsed unit cache after analysis operations.
Change-Id: I047112d8e9de19c45c10cdd82df8c9357ceedba4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-10-02 14:21:49 +00:00
Konstantin Shcheglov 1ae08e9b5e Elements. Include analyzer_use_new_elements.txt into the resolved unit signature.
So, when we update this file and restart DAS, we recompute diagnostics.
To prevent stale lint about using old element model.

Change-Id: I4e27231d4fb4d40c181c13e4fa9b81de395b3232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387609
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-01 17:12:31 +00:00
Konstantin Shcheglov 4ac6c5cdf3 Elements. Make Fragmented public, migrate ExecutableParameters.
Change-Id: I1d9dbe7d1a74e82e4e4b5486399d4478674b6f50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387610
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-01 16:49:17 +00:00
Paul Berry e9e761644d [analyzer][cfe] Share constraint generation for non-generic function types
This change combines function-handling logic from the analyzer's
`TypeConstraintGatherer._functionType0` and the CFE's
`TypeConstraintGatherer._isNullabilityAwareSubtypeMatch` methods into
`TypeConstraintGenerator.performSubtypeConstraintGenerationForFunctionTypes`,
which is in `_fe_analyzer_shared`.

The CFE and the analyzer have some pretty significant differences in
how they represent function types:

- In the analyzer, all function parameters are in a single
  `parameters` list; each element of this list (of type
  `ParameterElement`) can be queried to find out if it is named or
  unnamed, and if it is required or optional. A convention enforced
  partially by the `FunctionType` constructor is that the `parameters`
  list stores reqired unnamed parameters first, then either optional
  unnamed parameters or named parameters; named parameters are sorted
  by name. The analyzer provides additional getters
  `namedParameterTypes`, `normalParameterNames`,
  `normalParameterTypes`, `optionalParameterNames`, and
  `optionalParameterTypes`, which provide other views of this
  information (for example, `namedParameterTypes` contains just the
  named parameters, as a map from name to `ParameterElement`).

- In the CFE, unnamed and named parameters are in two separate lists
  (`positionalParameters`, of type `List<DartType>`, and
  `namedParameters`, of type `List<NamedType>`); in
  `positionalParameters`, required parameters come before optional
  ones. A single integer (`requiredParameterCount`) indicates how many
  elements of `positionalParameters` are required, and by convention,
  `namedParameters` is sorted by name.

In order to share logic between these representations, I had to come
up with a common API that these two representations could be easily
adapted to. The analyzer's representation proved to be easier to
adapt, so I based the common API mostly on the CFE's representation,
but with some name changes for clarity. The shared API is:

- `positionalParameterTypes` gets a list of positional parameter types

- `requiredPositionalParameterCount` tells how many entries in
  `positionalParameterTypes` are required.

- `returnType` gets the function type's return type.

- `sortedNamedParameters` gets a list of information about named
  parameters. The list elements are sorted by name, and each element
  of this list is of type `FunctionParameterStructure` (a common
  interface implemented both by the analyzer's `ParameterElement` and
  the CFE's `NamedType`).

- `typeFormals` gets a list of the function type's formal type
  parameters.

To minimize the performance impact of adapting the analyzer to this
API, the analyzer computes `positionalParameterTypes`,
`requiredPositionalParameterCount`, and `sortedNamedParameters` at the
time a `FunctionType` is constructed. Hopefully this should not be too
much of a performance hit, since doing so does not take too much more
effort than checking that the named parameters are sorted (which the
`FunctionType` constructor was already doing).

This is based on previous work by Chloe Stefantsova in
https://dart-review.googlesource.com/c/sdk/+/386480.

Change-Id: Iefe18d72771146399d81747ceab9c929516b0523
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386322
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-10-01 16:08:52 +00:00
Devon Carew 1f8aea0c81 Bump lints to a97011b4b031b1df94765dbacd7d92b0b765c8b9
Changes:
```
> git log --format="%C(auto) %h %s" af68bf0..a97011b
 https://dart.googlesource.com/lints.git/+/a97011b add unintended_html_in_doc_comment; rev to 5.1.0 (211)

```

Diff: https://dart.googlesource.com/lints.git/+/af68bf0cbad88002a2ae19ee8db37b64eb120c32..a97011b4b031b1df94765dbacd7d92b0b765c8b9/
Change-Id: I998d73f5f72e94d5f2922b0751d31620a837555e
Tested: analysis only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387601
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-09-30 21:48:03 +00:00
Sam Rawlins 9f9e98893f analyzer: allow visibleForOverride combined with others
`_checkForOtherInvalidAccess` first checks whether an access is
explicitly _allowed_, and then goes back through the annotations to
see if something needs to be reported. The `visibleForOverriding` check
was not implemented correctly in this function, to allow combining
annotations.

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

Change-Id: I64b6757e000c29dcf0e0a1559f9d89c0f3855b28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387521
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-30 19:26:29 +00:00
FMorschel 83c26333a2 [DAS] Consider two lint rules when offering "add import" refactorings
Taking into consideration `prefer_relative_imports` and `always_use_package_imports` for adding import options to the assists list.

When neither is set, both will appear always showing package imports first. If both are set we will treat this as if only `always_use_package_imports` is and show only package imports.

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

R=scheglov@google.com

Change-Id: If2353479de91f50c6c44eb7a17487fb6d0d6f681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387500
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-30 19:17:36 +00:00
Sam Rawlins 94f7a5af2c analyzer: Consider nullability when checking identical function types
Fixes https://github.com/dart-lang/sdk/issues/54584

Change-Id: I7bc2af3c3c6bc84a1ef13e65dc6ac90977a31c66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386974
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-09-30 18:44:51 +00:00
Konstantin Shcheglov 3c5bdb63cf Elements. Migrate CreateMethod.
Change-Id: I7e631dd63baf74060a94bd413f5ccdd527fd21f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387352
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-30 16:56:50 +00:00
Sam Rawlins 4038b97713 analyzer: track used calls to 'call' on an extension
Fixes https://github.com/dart-lang/sdk/issues/55781

Change-Id: I34eb02d4c0f6a44afe98c0224bed779972a415e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387560
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-30 16:44:26 +00:00
Konstantin Shcheglov 345bfb9c3d Elements. Migrate RemoveLeadingUnderscore.
Change-Id: I09535fc1fc2a65e2ed370e3fabe75a81a8f579fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387411
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-30 15:00:41 +00:00
Paul Berry 2a6d9cbb98 Introduce a shared base class for type parameters.
Change-Id: I341097643b6d6cec3c83c398a84aebbdf7500d09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386736
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-09-30 14:40:36 +00:00
Konstantin Shcheglov 8a77fa05ac Elements. Migrate EncapsulateField.
Change-Id: I505623f21211f1e529962b563f1898919f080537
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387401
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-30 14:28:29 +00:00