Commit Graph

16356 Commits

Author SHA1 Message Date
Jens Johansen e656fec1ee [CFE/Analyzer/parser] Fix crash upon double with separators and missing number after e
E.g. the user typing "1_234e" (and having yet to type a number) would
crash the analyzer.

Change-Id: Iff71c274a5e4719b3c8877ddbc9775d8d091c42f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-27 02:29:33 -07:00
Konstantin Shcheglov d79ebc6165 Elements. Remove ExecutableElementOrMember.
Change-Id: I1a48c337a3b74058bd9c62cf8b95e3eabfd8f4b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437263
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-27 00:50:19 -07:00
Konstantin Shcheglov 28d25e437e Elements. Remove 'variable' and 'toFunctionValue' from DartObjectImpl.
Change-Id: Ia696347266cb4b54f5248fb1f9f0f73290fddc5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437380
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 17:23:01 -07:00
Konstantin Shcheglov 0e12390e63 Elements. Remove PropertyAccessorElementOrMember.
Change-Id: I3882b02140021fbb2733ff8f5ff2ae575ab129fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437361
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-26 17:16:13 -07:00
Konstantin Shcheglov 7505e450f5 Elements. Remove 'get identifier' from ElementImpl and FragmentImpl.
We used it to construct `ElementLocation`, and we already removed it.

Change-Id: Ie88ba3aae24f094c6eb2c5b656cc64398e5ba91b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437360
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 16:47:12 -07:00
Fedor Shcheglov c8f8ba6875 Deprecate Element.accept2, use accept instead.
Change-Id: I4ec0389663164b8dde0b0321e4457f2ae655785a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435745
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-26 15:02:22 -07:00
Parker Lougheed 873a88bd6d [analyzer/linter] Mark a few diagnostic docs as published
Also regenerate the diagnostic codes and (deprecated) lint rules.json file.

Change-Id: Id50dfe81a7bc3a62fee9d6b99f0e045804e95685
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436960
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-06-26 13:38:04 -07:00
Konstantin Shcheglov 4d36ef3a37 Elements. Remove MethodElementOrMember.
Change-Id: I062e1a55867ba541290ed948081cf4ea26dab2cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437320
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 12:47:53 -07:00
Konstantin Shcheglov 56536ba054 Elements. Remove ConstructorElementMixin.
Change-Id: I4a5391d4a886f6d69c7bec35c86bd6b4e82d9c03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437261
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 12:46:59 -07:00
Patt O'Brien c537260fab fix: Typos in element model migration guide.
Closes https://github.com/dart-lang/sdk/pull/60998

GitOrigin-RevId: bae0908f7b5a956b2ffd2f0fcd8fda64af60cc55
Change-Id: Iea1879bfc62016e0f70bc442a197aae321e17b61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437125
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-26 11:56:11 -07:00
Konstantin Shcheglov bdc01d108e Elements. Stop using ConstructorElementMixin in constants evaluation.
Change-Id: I54e22bd9a0068ffa8de5a7ded932131327f672fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437105
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-26 10:44:39 -07:00
Kallen Tu 78b27083c9 [analyzer] Dot shorthand: Update constant verification for default parameter values.
The constant visitor was missing an extra check that we had for instance creation expressions, but not for dot shorthand constructor invocations. It's definitely a little funky because of how we've chained up the ConstantVisitor + ConstantVerifier, but this is how we currently handle this error.

Added a unit test.

Fixes: https://github.com/dart-lang/sdk/issues/60962
Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I76489a425c5e01c4d9edb34ac6dc62f109e6a32a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436821
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-26 10:43:40 -07:00
Kallen Tu c7765a8205 [analyzer/linter] Dot shorthands: Update ConstantVerifier for dot shorthand constructor invocations.
Updates the `ConstantVerifier` so we're checking the dot shorthand constructor invocation is a constant constructor call and that its arguments are constant expressions.

Tweaked the constant error handling a little bit to handle dot shorthands. It's always a little funky, but needed to prevent duplicate errors.

Added a few unit tests from the example in the bug.

Fixes: https://github.com/dart-lang/sdk/issues/60963
Bug: https://github.com/dart-lang/sdk/issues/60893
Change-Id: I77b2dff4a274241b2c98b3e6cd34c620d08435a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436742
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-26 09:52:12 -07:00
Fedor Shcheglov 86df26dd2f Consolidate fragment writing into _writeTemplateFragment.
Migrate hand-rolled _writeXxxFragment helpers to the shared _writeTemplateFragment. This eliminates duplicated serialization logic  (ID / name / offset / modifiers), shrinks the code base, and makes it easier to add new fragment types without boiler-plate.

Removed flags from `bundle_reader` and `bundle_writer`, will remove flag classes in the future as they will be replaced with reading/writing modifiers.

Change-Id: I79aabd1e94bfa831d6718bb2889a6a00e6561112
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-26 06:10:31 -07:00
Fedor Shcheglov 98f233bfa7 Deprecate InterfaceType.constructors2, use constructors instead.
Change-Id: I2d63bc1b61acb781ad0b8a45f15a05d36ee3a304
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435748
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-25 17:38:01 -07:00
Konstantin Shcheglov 9270f0fad0 Elements. Stop implementing ConstantEvaluationTarget by ElementAnnotation.
This is an internal interface that should not have been exposed.

Change-Id: I92ddc64766e3b9d183750a3406d03215275a58a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-25 15:20:10 -07:00
Fedor Shcheglov b017489312 Removed ElementModelWriter due to it being unused.
Change-Id: Ib2bb8b877e23fdff884bd03b208ea4d077c6e927
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437120
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-25 15:04:34 -07:00
Konstantin Shcheglov 3e6edd36e1 Elements. Remove deprecated methods from InheritanceManager3.
With mockito migrated off of them, we can now remove them.

Change-Id: Ib5e3d354cdf2d9b44d0d3a87e4dfa024b8fdb29f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437040
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-25 15:00:43 -07:00
Fedor Shcheglov a801e69e26 Consolidate fragment reading into _readTemplateFragment
Replace eight bespoke implementations for reading fragments with the existing `_readTemplateFragment()` method.

This enforces the consistent use of the template method design pattern, reduces code duplication, and makes future maintenance easier.

Change-Id: If213b146e4b055523432c6d12f36994cac8f38c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436820
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-25 14:36:12 -07:00
Sam Rawlins ee69f45a1f analyzer: rework AnalysisErrorListener deprecation
Work towards #60635

In this change, we rework the AnalysisErrorListener deprecation to
better support users who have their own class that implements
AnalysisErrorListener. This change introduces a sealed supertype,
DiagnosticOrErrorListener, with the old implementation,
AnalysisErrorListener, and the new implementation, DiagnosticListener,
as its sole direct subclasses. Users who have implemented
AnalysisErrorListener should be able to instead implement
DiagnosticListener, and their class is an acceptable instance of
DiagnosticOrErrorListener, wherever that is needed.

In a breaking change we can drop AnalysisErrorListener and deprecate
DiagnosticOrErrorListener, and in the next breaking change, we can drop
DiagnosticOrErrorListener.

For reference, see the first API difference when deprecating AnalysisErrorListener and introducing DiagnosticListener: https://github.com/dart-lang/sdk/commit/903d77cc8229972a424941dcb7b7b79741e833eb#diff-dec15868961d7eadcd009f49d129bebcdb747aaa8dbfde5f5a08884e0cf11e32

Change-Id: I3ccf11d54b41fbca98d020d89978d250c16b4c04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436480
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-25 06:54:20 -07:00
Fedor Shcheglov ade10f4afb Deprecate 'Element.library2', use 'library' instead.
Deprecate `LibraryElement.loadLibraryFunction2`, use `loadLibraryFunction` instead.


Change-Id: I117fb182e6bb62c1a76b3d578c0a6d4b6f32b9c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435920
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-24 17:23:11 -07:00
Konstantin Shcheglov e389ceeb85 Elements. Migrate ConstructorElementToInfer to ConstructorElementMixin2 only.
Change-Id: I4a7f1dea4abbdb439dedb9e2019c42732b798e58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436720
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-24 12:43:40 -07:00
Konstantin Shcheglov 05026eb7d2 Elements. Stop implementing V1 interfaces in MethodMember and PropertyAccessorMember.
Change-Id: I93e5d7b12c8f830cbeaf0dc15c8c6b31d044b9ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436681
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-24 12:35:37 -07:00
Konstantin Shcheglov 9773f56b6e Elements. Move 'redirectedConstructor' property into 'ConstructorElementImpl'.
Change-Id: I9e39d5ae78c14d184bbdb22fe979b5c419d78c62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436660
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-24 12:27:12 -07:00
Konstantin Shcheglov 9425a79b06 Elements. Move superConstructor property into ConstructorElementImpl.
Use ConstructorElementMixin2 as its type.

All resolution is always base on element, so here we stop using fragments, and stop storing this information in fragments.

Change-Id: Ide073eb3f5efd3fa1afaac855beb092c114e304f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436162
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-24 10:30:06 -07:00
Danny Tuppeny 2285b68ae6 [analyzer] Exclude nested analysis roots from their parents contexts
Fixes https://github.com/Dart-Code/Dart-Code/issues/5548

Change-Id: Ifb6eb52bf6589ebb5d7d60a8a3d4910d06e5be88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435161
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-24 07:57:37 -07:00
Fedor Shcheglov 318aeb322b Deprecate DartType.element3, use element instead.
Change-Id: Idef9da09c565a05fa84869f7433df3c24c6fbb5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435521
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-24 07:23:11 -07:00
Konstantin Shcheglov a868039f59 Elements. Remove PropertyAccessorFragment.variable3 and PropertyInducingFragment.getter2/setter2.
It is getter / setter elements that know that they form a
PropertyInducingElement, and the other way around,
PropertyInducingElement that has getter and setter. Fragments OTOH, just
dangle from the elements.

Change-Id: Ide8ece5cb318c75093b0173c661b01f564d1a55a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435746
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-23 13:31:03 -07:00
Konstantin Shcheglov 4217306f88 Elements. Stop storing V1 ExecutableElementOrMember in InheritanceManager3.
Change-Id: I78cbf2497118364f792b58f7efb9d1c5ce68a6d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436361
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-23 13:09:07 -07:00
Fedor Shcheglov 6ba80184f0 Remove PropertyAccessorFragmentImplImplicitGetter, PropertyAccessorFragmentImplImplicitSetter, and FormalParameterFragmentImplOfImplicitSetter, replace with GetterFragmentImpl, and SetterFragmentImpl.
Change-Id: Iaf8066a5f04635616b18a7c7cfb890f6b2d46df8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436100
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-23 12:44:35 -07:00
Fedor Shcheglov 22a74f5580 Format analyzer/ and analysis_server/ to dart format.
When running cl upload, I noticed that there were a lot of existing format issues, which this fixes.

Change-Id: I01611562c907dbc4151e28eceee4a1f5a51644dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435522
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-23 10:42:23 -07:00
Konstantin Shcheglov bc9344870f Elements. Don't include PropertyInducingFragment.getter/setter and PropertyAccessorFragment.variable2 into text expectations.
I'm removing these getters in the next CL.

Change-Id: I17d44db3c6c4242dbeeb35e4bed58662dd5ae900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435749
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-23 09:34:23 -07:00
Konstantin Shcheglov 48d495ba92 Elements. Remove FragmentImpl.nonSynthetic
This request is useful only for elements. We can create a synthetic
element, and by necessity a fragment for it, but we never create a
synthetic fragment just by itself, for a non-synthetic element.

Change-Id: Ia8fee5e12e7b2c915c72276a402e164b9b30dc1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-23 08:37:47 -07:00
Fedor Shcheglov 4ce44bf940 Deprecated getGetter2, getMethod2, getSetter2, lookUpConstructor2, lookUpGetter3, lookUpMethod3, and lookUpSetter3
Change-Id: I677b5fbf061946b5be10eea6873c959c4681c4a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436022
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-23 08:26:46 -07:00
Konstantin Shcheglov e6e16b4ea3 Elements. Migrate more InheritanceManager3.
Change-Id: Ie48b0f588d4b530ed0cc36b88e5fb87bec518fd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435981
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-22 09:17:34 -07:00
Brian Wilkerson 21f0f4ed9c Add documentation for a few warnings
Change-Id: I10ad9f7a980b6559e5e906028741ea7fbde814ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433960
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Amanda Fitch <afitch@google.com>
2025-06-21 07:22:47 -07:00
Fedor Shcheglov 842ed5606c Deprecate/rename primaryConstructor2 and representation2 from ExtensionTypeElement.
Change-Id: I3699157f4b8d640449e2dba307d2bf587b243e60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-20 14:36:32 -07:00
Konstantin Shcheglov 183d0ad872 Elements. Remove a few v1 methods from InheritanceManager3.
Replace `getInheritedMap()` with v2 version.
Remove `getMember()`, operations should go thought elements, not types.
Remove `getMember2()`.
Rename v2 `getMember4()` into `getMember()`.

A few internal methods are duplicated for now, will be de-duplicated
when migration of InheritanceManager3 is finished. For now I'd like to
do smaller steps than migrating it fully.

Change-Id: Ib5d9d28e91d77330e41480fcb7176f93d867728a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435663
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-20 10:18:04 -07:00
Konstantin Shcheglov c6abc1efbd Elements. Rename _writeReference2() to _writeReference(), and fix
the nullability of `_indexOfReference()` formal parameter. It turns out that no code paths
ever pass null to it.

Also reuse _writeVariableGetterSetterLinking() for top-level variables.

Change-Id: Ia031ca5097fadaa28ea52a47fb18ebbc06d76c4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435722
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-20 10:11:35 -07:00
Konstantin Shcheglov 38ac87f64d Elements. Pull implementations out of ConstructorElementMixin, leave only declarations.
ConstructorMember uses baseElement to implement, as every other method.

Change-Id: I3d6e5f16e83e6c601691cfdd0c254b861ffd9a68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435960
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-20 10:10:00 -07:00
Fedor Shcheglov 1dc17b9a22 Deprecate Element.nonSynthetic2, use nonSynthetic instead.
Change-Id: Ie47d5f1e1fbaa7473747c5b43333a9c0cd689f74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435664
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-20 08:57:19 -07:00
Jens Johansen dc7c6cadea [analyzer] Fix analysis_context_collection_test on Windows (2nd try)
This fixes some randomeness caused by HashSet which seemingly triggered
different sorting on Windows than in Linux.

Change-Id: I54fffdbd2e056ec87958533aeafc327164808046
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435861
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-20 01:09:49 -07:00
Paul Berry 5fc5f3678a [analyzer] Simplify and clean up duplicate declaration checking.
This change reworks
`MemberDuplicateDefinitionVerifier._checkConflictingConstructorAndStatic`
and `MemberDuplicateDefinitionVerifier._checkDuplicateIdentifier` into
a form that is easier to reason about and has slightly faster
performance (measured by instruction count).

In the previous design, two maps were maintained for each scope in
which getters and setters might appear:

- one called `getterScope`, which (confusingly) held getters, setters,
  and method declarations,

- and one called `setterScope` which only held setters.

This was difficult to reason about. In particular, it had a
longstanding bug that was only recently fixed (see
https://dart-review.googlesource.com/c/sdk/+/434061): if a setter was
encountered first, it was stored in `getterScope`, but if a getter was
encountered next, it was necessary to move the setter to `setterScope`
in order to store the getter in `getterScope`.

It was also inefficient, since in many cases, two map lookups were
needed in order to check for both getter and setter conflicts.

In the new design, there is a single map, whose values point to either
a `_ScopeEntryFragment` (in the case where just one declaration of the
given name has been seen) or a `_ScopeEntryGetterSetterPair` (in the
case where both a getter and a setter have been seen).

The new design has modestly better performance when measured by
front_end/tool/benchmarker.dart:

     Comparing snapshot #1 (before.aot) with snapshot #2 (after.aot)
     instructions:u: -0.0192% +/- 0.0131% (-6291379.67 +/- 4292101.91) (32692292436.33 -> 32686001056.67)

Change-Id: Ia6675fa4d3579779e6066db3760d2cc38a2c859e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435602
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-19 11:13:27 -07:00
Jens Johansen 6d6da849ba [analyzer] Fix analysis_context_collection_test on Windows
https://dart-review.googlesource.com/c/sdk/+/434802
(0677fcac83) introduced a few new tests
that didn't work on Windows.

Change-Id: I841cb479b6782a83d8472ee4c074ef2b3b51709a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-19 06:13:05 -07:00
Jens Johansen 0677fcac83 [analyze] When opening several folders with "resolution: workspace" try to merge them by workspace root
Use-case: I have 20+ folders from the sdk that I have open
(front_end, _fe_analyzer_shared, vm, analyzer, analysis_server etc) and
before this CL that meant I had 20+ contexts, despite them having
`resolution: workspace` and being specified in the roots pubspec.yaml
under `workspace`. Opening, for instance, `pkg` directly would
successfully give me only 1 context, but also include lots of stuff I
don't want to clutter neither my screen nor my mind.

This CL merges such folders as possible meaning I with this CL only have
1 context.

* If not using the workspace resolution this should change nothing.
* If opening only the root of a workspace this should change nothing.
* If opening a sub folder that itself isn't a package (say `pkg` in the
  sdk) this should change nothing.

Change-Id: Ia38fa6636b02fa95ed274ebf72d424cae7d4da66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434802
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-19 02:49:24 -07:00
Konstantin Shcheglov b37d8c2093 Elements. Simplify FieldFragmentImpl creation.
Change-Id: Ic69ded5b9edf747b0bfcb5b90d093fbb85113b8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435721
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-18 16:05:31 -07:00
Konstantin Shcheglov 6321756124 Elements. Rename Reference.element2 to element.
Change-Id: I613e48e8df803ceed19871e2724dccbe5ea34859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435720
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-18 14:20:45 -07:00
Konstantin Shcheglov 98a1b63b11 Elements. Consistently use addTopFragment().
Change-Id: I23bcbd31de28e7c9478fc63406b8f1c13c6cdbae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435701
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-18 14:06:15 -07:00
Konstantin Shcheglov fcddbffbc1 Elements. Remove Reference.element (misnomer now), now FragmentImpl cannot have reference.
Change-Id: I928abfe136bda2bc49884f9ec79a8bcae772ac13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435446
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-18 13:17:10 -07:00
Konstantin Shcheglov c58e180287 Elements. Remove FragmentImpl.reference
Change-Id: If586b6f365770c752b7e6c3bd2ae39cd8bf394f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435601
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-18 13:15:49 -07:00