Commit Graph

10700 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
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
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 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 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
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
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
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 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
Konstantin Shcheglov c0bca2c210 Elements. Build all fragments first, then build elements.
Main changes:

1. Separating `FragmentBuilder` and `ElementBuilder`. I removed
`augmentation.dart` and its builders, because now it is implemented in
the new `ElementBuilder`.

2. Fragments are not given actual `Reference` objects anymore, there
might be some in the current state, but I will go over this in the
future and remove them completely.

3. Writing and reading elements also happens in two stages: first
fragments, then elements. Each fragment in the summary is given unique
ID, and during writing / reading elements we use these ID to locate
fragments and create elements around them.

4. Lazy loading of `ClassElement` members is simplified and generalized,
could be potentially applied to any `InstanceElement`. Maybe use also in
mixins, which are used somewhat often in Flutter.

5. There are slight changes to tests, mostly to the better, sometime a
bit reordering, a couple of new tests.

There is some dirty code added, especially around patching types for
getters, setters, and their fragments. I plan to clean this in future
CLs as I move toward better implementation, and from using fragments
where this is wrong.

Change-Id: I1e4bf2a3b7ff45f1dba133797e85cd70aa729c11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-18 11:16:28 -07:00
Konstantin Shcheglov 69e98d3b21 Elements. Update test expectations format for future element / fragment changes.
Most significant changes:
1. Don't write "reference" for fragments, they will not have it.
2. Write `#F<num>` for fragments as unique identifiers instead.
3. Where we used to write "xyz#element", pretend that there is actual element reference, because the next CL will give it to all non-local elements.

Change-Id: I2ff0416ca904544de3b01c7657b4e9872b14df17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434744
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-17 12:43:29 -07:00
Sam Rawlins 97c49e7514 Deprecate errorCodeValues for diagnosticCodeValues
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ieea525a3f7260ea50e766feff0a0647fc0c33b4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434526
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-16 16:18:15 -07:00
Fedor Shcheglov 8020e36f29 Rename XyzElementImpl2 to XyzElementImpl.
Change-Id: Id88c171a3cd11a478521fe5c0aefaa8767dfcec6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434743
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-16 15:49:51 -07:00
Kallen Tu 4431536776 [analyzer] Dot shorthands: Report extra deprecation and @literal warnings.
Update the BestPracticesVerifier to report warnings on deprecated member usage and calling a `@literal` constructor without const.

Added unit tests and updated the AST.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I15aff72c00e9bead386f83c3a6f1054ca8324dc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434881
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-06-16 15:27:10 -07:00
Konstantin Shcheglov ce32e04c45 Elements. Fix for reference of unnamed constructor of extension type.
Change-Id: Id01fd9bdaad84e31622e220d0ecc9b3b73f48287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434941
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-16 15:23:21 -07:00
Fedor Shcheglov 1435ab6111 Rename all XyzElementImpl into XyzFragmentImpl.
Change-Id: I65b55925fbdccc0c22dc1f8243db4152ccae0ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434742
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-16 11:51:45 -07:00
Sam Rawlins ff19bdba8a Rename AnalysisOptionsimpl.unignorableNames to .unignorableDiagnosticCodeNames
'unignorableNames' is ambiguous.

Change-Id: Ieb42d7cb612c27eb285f1eabdaa7a7584b63e96b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434521
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-12 20:20:10 -07:00
Jens Johansen 4d1955e3c9 [analyzer] Report duplicate getter also if setter occurs first
Fixes https://github.com/dart-lang/sdk/issues/59977.

Change-Id: I83ea36ff6f30c33625e50628a3bb2392caac9400
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434061
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-11 23:58:14 -07:00
Sam Rawlins 69cd0ee5f6 analyzer: Deprecate "errorCode" parameters in Diagnostic constructors
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ifc173ec6e5924057fee3c420c8916f0abb257428
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434141
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-11 14:19:09 -07:00
Sam Rawlins f51d37e9b1 analyzer: Rename ErrorReporter to DiagnosticReporter
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I84b095199773040fc0444364964654c4373a9d77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433740
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-10 12:24:34 -07:00
Sam Rawlins 5c7cb4fdbd analyzer: Deduplicate some code around lists of diagnostics into shared helpers
Change-Id: I233977c08c071c6280b2eefc086f3f6fb2964a54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433640
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-10 09:47:42 -07:00
Sam Rawlins 7b42aae99f analyzer: Deprecate AnalysisResultWithErrors.errors in favor of .diagnostics
Also rename UnitAnalysisResult.errors (package-private API) to .diagnostics

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

Change-Id: I0bdd7c9c19cff3bff9ee61fe4689564a7b5b727b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433581
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-09 15:51:01 -07:00
Sam Rawlins c219974ecf analyzer: Deprecate Diagnostic.errorCode in favor of diagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I2c7d64a81bc214e64fbc3ac95cf1fe2363a6ebd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-09 09:22:22 -07:00
Brian Wilkerson 3502a35cf7 Add a context message to not_a_type diagnostics
Fixes https://github.com/dart-lang/sdk/issues/55947

Change-Id: I38b838c59d3c2983ac26efda7a5ab20f3d29485e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433362
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-06 14:23:32 -07:00
Sam Rawlins 903d77cc82 analyzer: Rename ErrorListener classes to DiagnosticListener
Work towards https://github.com/dart-lang/sdk/issues/60635

I tried to keep this minimal but still sensible:

* Rename AnalysisErrorListener and all subtypes to use 'Diagnostic'.
* Rename all instantiations of such classes if they previously
  contained the word 'error'.
* Rename `RecordingDiagnosticListener.errors` to `.diagnostics`.
* Rename some _testing_ instance members that had the word 'error'
  to instead use 'diagnostic'.

Change-Id: I3948e27ba28ac2494092e04f4e1d201a20cc1135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433004
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-05 14:05:40 -07:00
Sam Rawlins c4c3a72bd4 analyzer: Move error_supporession_test.dart
Work towards https://github.com/dart-lang/sdk/issues/60635

Also rename the test methods to use camelCase and to read more like
sentences.

Change-Id: If4ef85aeeefc5f1364ffbcba2e73df36981fc951
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432961
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-04 16:06:14 -07:00
Sam Rawlins 47f7c4fb87 analyzer: expose canBeConst and computeConstantValue as public API
Work towards https://github.com/dart-lang/sdk/issues/50986

These utilities are used by a handful of lint rules, and the analysis
server, which makes me think they could be offered as public API.

Change-Id: I12415c2b86ca6fb96b03def4a304da73c6fb4cae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430300
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-04 11:02:17 -07:00
Konstantin Shcheglov 8af392c657 Elements. Print FieldElementImpl references in text expectations.
Change-Id: I1f4aefbf0e1f24a5f7ffe1a7e44b83e78f186b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432822
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-03 14:45:08 -07:00
Sam Rawlins cb61cfa8fe linter: Use RuleContext over the deprecated alias, LinterContext
Change-Id: I3df38b96a0cb7756a9dbfbffc80d50c4c73337ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432723
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-03 14:11:02 -07:00
Konstantin Shcheglov 147ba501d7 Elements. Print ConstructorElementImpl references in text expectations.
Change-Id: I090dc6f9471dae969480caeba0204401dbf280e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432724
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-03 14:08:39 -07:00
Konstantin Shcheglov d116d50416 Elements. Add reference to FieldElementImpl2, write it.
Change-Id: Ia5f4c01aa46571c0a835f7e6408cd1af17fd75e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432781
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-03 13:26:29 -07:00
Sam Rawlins 31f8f4b522 analyzer: Make various AnalysisRule classes and their dependencies public
This is a big CL; no code is really "changed." We basically move 3
components into the public API, which can all be reviewed concisely
in the `api.txt` file.

* The AnalysisRule classes: `AbstractAnalysisRule` (which is good to
  make public as a lot of the public API is specified and documented
  here), `AnalysisRule`, `MultiAnalysisRule`.
* The Pubspec classes, available for linting pubspec files:
  `PubspecDependency`, `PubspecDependencyList`, `PubspecEntry`,
  `PubspecEnvironment`, `PubspecGitRepo`, `PubspecHost`, `PubspecNode`,
  `PubspecNodeList`, `PubspecVisitor`.
* The `RuleVisitorRegistry` class. This class is needed by analysis
  rule authors, and is part of the public API of AnalysisRule.

Change-Id: Ib1803180de9469f4ff39cf1778f96787f5f74b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-03 11:09:32 -07:00
Konstantin Shcheglov 018ad19e3e Elements. Make LibraryFragment not Annotatable.
Change-Id: I17e0a952b513cfdce81f8404d625f723f6dad95b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-02 16:28:22 -07:00
Konstantin Shcheglov c008be6c4a Elements. Remove FragmentImpl.name, pass name2 into constructors.
Change-Id: I2ef1a470de20ebc61b1e1178453cb609320ddd15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432462
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-02 16:07:16 -07:00
Konstantin Shcheglov 73a85ec195 Elements. Deprecate FragmentImpl.name
Next I will remove it completely.
And instead require `name2` as the constructor formal parameter.

Change-Id: Ib4afac3266fe36a7299d60a8b6d87c99349dd64c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432125
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-02 10:23:24 -07:00
Sam Rawlins 28fc6346eb analyzer: Move RuleContext and RuleContextUnit to public API
Change-Id: I9cca5ee27e623bfa5b878bb0277f5e12e84a745b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431982
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-30 15:42:10 -07:00
Konstantin Shcheglov b45d25ba1e Elements. Print MethodElementImpl references in text expectations.
Change-Id: Ib2c7f1dbc2479d9f0731b02558f939430a5ccee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431948
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-30 14:47:21 -07:00