Commit Graph

90 Commits

Author SHA1 Message Date
Sam Rawlins ef300f558c analyzer: allow LintCode instances to set their own severity
Work towards https://github.com/dart-lang/sdk/issues/53402

Letting plugin authors set the default severity of a lint code is a
top request. Users can still customize severities with analysis
options.

Change-Id: Id0a360f4a96ca9627f00d63d3487bfde554b74e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-22 12:51:30 -07:00
Sam Rawlins 87f5185577 analyzer: Rename NodeLintRegistry to RuleVisitorRegistry, provide alias
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: Id0053b4721ca0517e315d5118ae48839dfaa3027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429465
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-22 10:03:19 -07:00
Sam Rawlins f16cd980ce DAS: Deprecate CorrectionProducer.inheritanceManager
Change-Id: Id1772d47617a98ffc15d700a9bd7de58a04d745e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430020
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-21 14:42:21 -07:00
Sam Rawlins a3b1b4f172 analyzer: Deprecate AbstractAnalysisRule.lintCodes
Work towards https://github.com/dart-lang/sdk/issues/50986

Change-Id: I4c86dbf806964c98f4a1c5854eb53c6c8cfe002b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428624
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 11:04:43 -07:00
Brian Wilkerson 5f75bb8ba2 Replace change builder copying with a transactional model
Copying change builders in order to enable reverting changes from a
single correction producer when there's an exception is expensive.

This CL replaces that implementation with a transactional model.
Clients are not required to start a transaction (that happens
automatically), but are required to signal the end of a transaction by
invoking either `commit` or `revert`. (Actually, `commit` is assumed
if neither method is invoked before computing the `SourceChange`.)

There is some information in the Dart file edit builder related to
imports that isn't correctly handled. The reason for this is that too
much of the import computation is done up-front. I don't think this
will be a problem in practice (or at least not often), but we should
come back at some point to change the implementation so that we retain
abstract data longer and perform more processing at the very end (where
we'll have complete information and probably be able to do a better
job anyway).

This CL improved the performance of the benchmark that adds and applies
fixes for 10,000 lint violations.

  Before it took an average of 11216.0 ms.
  After it took an average of 4200.2 ms.

Which is about a 62% improvement.

Change-Id: I12710606455a04e34a82308ede5d9fba1c68b972
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428060
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-15 10:12:20 -07:00
Sam Rawlins 0d1fe0fc3a analyzer: Remove unnecessary InheritanceManager3 from LinterContext
Work towards https://github.com/dart-lang/sdk/issues/50986

At the same time, migrate `redeclare_verifier` from InheritanceManager3,
so that the impl is the same as the `annotate_redeclares` lint rule.

Change-Id: I9c5c77dcf50aa54820473874327bc3a7b93fd987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428380
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-13 15:21:52 -07:00
Sam Rawlins abd4e7754c Introduce two subclasses of 'LintRule' for handling multiple lint codes
Before this change, we had an enforcement that either 'get lintCode' or
'get lintCodes' is implemented, but it was a runtime enforcement. And it
was a little roundabout.

The new system is simpler and more typical:
* `AbstractLintRule` is the parent type, and it's sealed. It provides
  `get lintCodes` as an interface. Code outside of the lint rules
  requires this getter, in registering codes, etc.
* `LintRule` is the new subclass which is the "90% case." It declares
  a `get lintRule`, and offers simpler reporting methods for reporting
  a single code everywhere.
* `MultiLintRule` is the new subclass which represents that last
  "10% case." It only declares the reporting methods which all require
  a LintCode parameter, since there is no concept of a "default lint
  code among all my lint codes."

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

Change-Id: I63cbbfc1d936bb4428aa0b8f5fb0638c9b61b3dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426284
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-08 16:10:57 -07:00
Jens Johansen ad3e20a2be [analyzer] Skip repeated equal yaml edit calculations
For `lsp_many_prefer_single_quotes_violations_benchmark.dart --sizes=3200`:

Before:
Initial analysis: 0.115672
First code action call: 2.577159
Subsequent action call 1: 2.154116
Subsequent action call 2: 2.321183
Select all code action call: 6.890875

After:
Initial analysis: 0.114040
First code action call: 2.585689
Subsequent action call 1: 2.099005
Subsequent action call 2: 2.229051
Select all code action call: 4.695931

Change-Id: I3f20b9fe7c0a5cf6d9f4e5ca74193fc1f0668af2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-05-07 22:21:20 -07:00
Brian Wilkerson 5d6dc673dc Make nodeCovering a method on CompilationUnitImpl rather than an extension method
This allows us to traverse the children without needing to create lists.
It also allows us to iterate over lists of nodes more efficiently.

Tested against the script that computes fixes for 10,000 diagnostics,
I'm seeing the following result.

  Before this CL the average time was 10692.4 ms.
  After this CL the average time was 1900.0 ms.

That's just over an 82% improvement.

Change-Id: Ideff745288c8990e9948b22c5204d176af3cac6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426904
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-07 09:05:52 -07:00
Jens Johansen a01d47d5e2 [analyzer] Cache/reuse CorrectionUtils
For `lsp_many_prefer_single_quotes_violations_benchmark.dart --sizes=3200`:

Before:
Initial analysis: 0.119093
First code action call: 2.632948
Subsequent action call 1: 2.176926
Subsequent action call 2: 2.316560
Select all code action call: 8.269120

Now:
Initial analysis: 0.105622
First code action call: 2.629498
Subsequent action call 1: 2.240760
Subsequent action call 2: 2.354467
Select all code action call: 6.873468

Change-Id: Ic967e54592d96057e20a8d70355e47d5232653a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426180
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-06 23:14:28 -07:00
Sam Rawlins c6658d01c7 analysis_server_plugin: Use Diagnostic instead of deprecated AnalysisError
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Icf4186098ed04f15395aaf06c18772f8fd6ec4b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-05 13:55:28 -07:00
Jens Johansen cddee72854 [analyzer] Don't find the same "fixes for all" multiple times
Before this CL, if one has a file like

```
Map<String, String> foo = {
  "1": "1",
  "2": "2",
  "3": "3",
[...]
```

with many violations of the prefer_single_quotes lint, using VSCode and
selecting all would lock up the analysis server, e.g. in
https://dart-review.googlesource.com/c/sdk/+/425503 I showed 400 such
lines taking ~36 seconds on my machine (and 800 such lines taking ~247
seconds).

This is because for each error (lint) in range (i.e. all of them) it
calculates fixes for all of them. Once it's done with that it
deduplicates and throws most of the data away again.

This CL instead only calculates the "fixes for all" for each
combination of error-type and generator, skipping lots of work,
making the whole thing be much faster.

In the data send to the client (VSCode in this instance) the
"diagnostics" for
"Convert to single quoted strings everywhere in file"
contains fewer elements (only 1, vs all before), but it's unclear when
(or if) this is used. Note that the "edit"s does contain all, and
applying it still changes all instances.

I now get these runtimes for the select all case (via the benchmark)
(with cpu governor "performance" which likely wasn't the case for
the ~36 seconds and ~247 seconds above, although it doesn't matter
much with these differences):

400: 0.736783
800: 1.502978
1600: 3.704314
3200: 10.701988

Change-Id: I2b69a77525c0e1ed720c2b3d1de70ccc1fc5e94c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-05-05 01:50:25 -07:00
Sam Rawlins 992cfb13bc analyzer: Deprecate AnalysisError.correction; simplify other final fields
Work towards https://github.com/dart-lang/sdk/issues/60635

* `AnalysisError._contextMessages` unnecessarily backed the public
  `contextMessages` getter; the field is final so it can be public
  itself.
* `AnalysisError._correctionMessage` unnecessarily backed the public
  `correctionMessage` getter; the field is final so it can be public
  itself.

Change-Id: If269d4ed590ef7df81d9b9e3be03766601526d7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425620
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-30 16:06:19 -07:00
Sam Rawlins 508ad1359b analysis_server_plugin: Use new DiagnosticCode name
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ia021bc5a80f1e53407393454ab058f6b7c8a633a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-30 09:35:02 -07:00
FMorschel dbd0be6b7e [DAS] Fixes Create getter and Create mixin quick-fixes trigger
Fixes: https://github.com/dart-lang/sdk/issues/60613
Change-Id: Ie8661ae57f4fb3d8e9702fb67fc900530ba10632
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424560
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-04-29 11:31:19 -07:00
Konstantin Shcheglov b2fdd8a345 Elements. Rename XyzElement2 into XyzElement.
The CL was done with rename + adding typedef for each class.

Change-Id: Ia25cc581d2e42cf7d12a85a3579af952d5c232ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424687
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 13:27:18 -07:00
Konstantin Shcheglov 49599e06cc Elements. Deprecated element2.dart library.
Change-Id: I2be38df49e6f242d9fe59f34164549da4a0f41b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424683
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-04-25 11:23:18 -07:00
FMorschel ae6bdae111 [DAS] Fixes create method for enums and extension types
Fixes: https://github.com/dart-lang/sdk/issues/60562
Change-Id: I8bbc92205f5900c025e9dc31110f3e1cb2343643
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-18 16:52:11 -07:00
Sam Rawlins 91e682940c analyzer: Move coveringNode to public API
NodeLocator and NodeLocator2 are being deprecated in favor of this
extension method. We move it to the public API here and start using it
in the analysis_server_plugin package.

Change-Id: I4783bb1f511b798e52b3383dd600b154dccc6d5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-17 09:41:40 -07:00
Jens Johansen a9d2363f08 [analyzer] Don't collect analytics if not using it; cache getTopLevelDeclarations results in DartFixContext
Sometimes - on responding to `edit.getFixes` requests, the method
`getTopLevelDeclarations` is called several times with the same
parameter and caching has then sometimes sped things up.

I then also noticed that it caused `reportAnalysisAnalytics` to be
called many times (e.g. 73 times for one `edit.getFixes` request)
each time spending time collecting data which - on passing to
`analyticsManager.analysisComplete` - was just thrown away because it
only saves the first one.

Combined these changes have been observed to reduce the response time
on `edit.getFixes` by up (down?) to ~20% (e.g. from 5 seconds
to 1 second).

In response to http://b/407797012 where more data is also available.

Unfortunately I haven't been able to reproduce this is a benchmark
(yet anyway). I don't know if it needs slower slower reads, an extreme
amount of files, several contexts or something else entirely.

Change-Id: Id214b0e1b7d8bbef7f6d956408f17fab45618b78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420323
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-07 05:36:53 -07:00
Sam Rawlins 6838dabc15 DAS: make add_null_check fixKind final
A few statements around the package read:

> Producers used in bulk fixes must not modify the FixKind during
> computation.

In fact, this `add_null_check` correction producer seems to be the
_only_ remaining producer that violates this statement. In order to
fix it, such that `fixKind` is set during constructor initialization,
we must do some poking around the AST.

So we convert `_computeTarget` to be static (and change it to also
compute and return any possible null-aware token, renaming it to
`_computeTargetAndNullAwareToken`). We also convert `_isNullAware` to
be static. Then the two public constructors are converted into
factory constructors that determine the fix kind, and store the
`_target` and `_nullAwareToken` in fields, so as to avoid re-computing
them during `compute()`.

Change-Id: Ic66319ef764dd9bd69f0e1059347acf174debb25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-03 23:51:44 -07:00
Sam Rawlins 6253555a2c DAS: Only yield libraries that provide an extension member with a given name
The `DartFixContext.librariesWithExtensions` utility function accepts
a `memberName` parameter but never did anything with it. This change
adds filtering in that function based on the member name.

This code depends on the set of exported extensions, which is provided
in an extension (`LibraryElementExtensions.exportedExtensions`) in the
analysis_server package, which must be moved to the analyzer package.

Change-Id: I06c8a9a0e11ceb70e75517b30c0b048321d6b024
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418641
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-04-02 08:06:25 -07:00
Sam Rawlins 4a96dd122c DAS plugins: Respond to real assist requests
Change-Id: I1f1afca0dc746948410a56e29cf13bebef234ed7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-01 16:43:54 -07:00
Sam Rawlins b0c3f4ef1f DAS plugins: Move two files to be in the public API
Change-Id: I7230dead69b8c82ea758e48a0a3fbc56902cb05d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417945
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-28 13:09:21 -07:00
Sam Rawlins 7f5485d23a DAS plugins: report early when a fix or assist does not have a fixKind or assistKind
Change-Id: I83a147adc4740d1a8891faa06d35c4901cf568b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417943
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-28 12:12:49 -07:00
FMorschel 90c0aa6aaa [DAS] Fixes create method/function return type
Fixes: https://github.com/dart-lang/sdk/issues/60306
Change-Id: Iba6222bbb5d0b63ca94920cad6d6abfd571ed830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417780
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-03-25 15:30:23 -07:00
Sam Rawlins ff75aeb6af DAS plugins: Support assists in plugins
To support this feature:

* Remove `DartAssistContextImpl` as it has no differences from
  `DartAssistContext`. Thus the getters `DartAssistContext` are made
  into fields, and all callers now call `DartAssistContext()`.
* Add a top level `computeAssists` function, similar to the top-level
  `computeFixes` function.

Change-Id: I3ef5fd9ee9430150004b29c11ab972939b85b214
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-25 15:27:59 -07:00
Sam Rawlins ffd08a344b DAS: Do not repeatedly compute a null value for coveringNode
The field may be set to `null`, so it's nullity is not a signal of whether it needs to be computed.

Change-Id: If19eb1f77ad601e744e41bde45a30d393ab8726f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417327
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-25 13:57:39 -07:00
Sam Rawlins 05b2e7b28f DAS: only attempt to compute assists for assist-supporting producers
This is hopefully a no-op in practice, but if any non-assist-supporting
correction producers make it into the list, it will reduce the work we
do.

Change-Id: I265b5c4f6e8b8b4647a3dbfb0cadb369dc30cdcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417325
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-24 15:11:21 -07:00
pq 5f96af3d4c [cq] fix ProducerRequestPerformance to properly set operation name
Change-Id: Ib45821959837c6eaaa572601fa08d727d824d42e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417101
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-20 19:32:41 -07:00
Sam Rawlins 331c700f33 DAS plugins: Move Assist code to analysis_server_plugin package
The PluginServer class needs access to AssistProcessor in order to
compute assists. That class needs access to a few other classes, which
then must also be moved:

* assist_core.dart - the Assist class
* assist_dart.dart - the DartAssistContext class
* assist_generators.dart - the registeredAssistGenerators variable
* assist_performance.dart - the AssistPerformance and
  GetAssistsPerformance classes
* assist_processor.dart - the AssistProcessor class with it's
  singular API, `compute()`
* performance.dart - the ProducerRequestPerformance class
* the `addCaretAtOffset` helper function, refactored into a
  `withCaretAt` extension method

This change is functionally a no-op.

Change-Id: Ic883d21e9cc8c3db1f6093f830f01ec6eb9a0976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416680
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-19 13:44:51 -07:00
pq a098bf3dae [analytics] performance tracking for getAssists
Bug: https://github.com/dart-lang/sdk/issues/60258
Change-Id: Iffc42602680786b93de877fb581fb8248a970c8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-03-14 07:28:09 -07:00
pq bc9def5da7 [analytics] track time in fix producer compute()s
Adds some insight into fix producer `compute` calls to the `GetFixes` diagnostics page.

See updated screenshot in https://github.com/dart-lang/sdk/issues/60258.

Bug: https://github.com/dart-lang/sdk/issues/60258
Change-Id: I5d8c1911e86ef02b8d543fcda367b3e9aa6544f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414341
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-03-07 12:36:59 -08:00
pq 76be1bcded [analytics] add getFixes timings to diagnostics/reports
See: https://github.com/dart-lang/sdk/issues/60258


Change-Id: I756cb04d3968ca02dbef332f45a6fbea5b1b8c3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414180
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-06 11:19:58 -08:00
Konstantin Shcheglov b3ca203e8f Elements. Start deprecating V1 elements.
This updates `analyzer_use_new_elements` lint to stop reporting inside
deprecated declarations. So, we can deprecated and prepare for removal.

Apply deprecation dart/analysis/results.dart

Deprecate `ElementDeclarationResult`, add `FragmentDeclarationResult` instead.

Change `getFragmentDeclaration` (not yet published) return type to `FragmentDeclarationResult` to better correspond to the method name.

Rename `getElementDeclaration` from `AnalysisSessionHelper` to
`getFragmentDeclaration`, to better reflect on what it operates.

Change-Id: I2839c9a7e21ed2e5b34035fc8c3ec88fd23df1b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-02-28 08:19:21 -08:00
Brian Wilkerson a59bae3f37 Cleanup code in analysis_server_plugin
Change-Id: I596a5a516136b4bd024b8f72b11df6eb641075ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412680
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-02-27 11:44:14 -08:00
Konstantin Shcheglov 2ad1b56534 Elements. Use TypeImpl in more places.
Change-Id: I68fd3ca29f4059d9772233978da9391245097207
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412000
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-02-25 09:56:20 -08:00
pq d21fd1ff4b [PE] document registerFixForRule
Change-Id: Ie0f2f9bd85207ec6a25d881fbd8182c6506620f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408884
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-02-10 15:01:19 -08:00
Jake Macdonald f4cfbf9cdc Update create function fix to create an async function for await expressions
Bug: https://github.com/dart-lang/sdk/issues/59990
Change-Id: I9e89089ca5c60bea190060bc0c8e869c7e78e32e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408361
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-02-06 14:25:39 -08:00
Sam Rawlins 2ac59922d2 DAS plugins: Support fixes to ignore diagnostics
Change-Id: I71ae995d1a4a94ecfeafd187c5674c41b6d928d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-02-04 08:24:23 -08:00
Sam Rawlins 052e03c829 DAS plugins: Support plugin-namespaced inline ignore comments
Fixes https://github.com/dart-lang/sdk/issues/59647

Change-Id: I303c83c3a486d6eb495e890007127215357e2864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406686
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-02-04 07:53:02 -08:00
Konstantin Shcheglov 2946ea71d5 Macro. Remove more from analyzer/ and analysis_seever/.
Change-Id: Id5426cce73395d3d95657cf1e0b5f9d85fe3f574
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-31 11:35:10 -08:00
Sam Rawlins ca31648dbb Support 'new' analyzer plugins in dart analyze.
This change allows the LegacyAnalysisServer to understand when the
plugin isolate (if there is one) is analyzing or not. There are a few
primary concepts:

* The plugin isolate (PluginServer) notifies the analysis server, when
  analyzing all files in a context collection, and analyzing changed
  files, that it is analyzing, and later that it isn't.
* The NotificationManager tracks whether the plugin isolate is analyzing
  or not, based on the last status.
* The PluginManager tracks whether new plugins are initialized or not.
  This is determined by the work done by the PluginWatcher. If no
  plugins are configured, then plugins are declared to be "initialized".
  Otherwise, the AnalysisServer sets their status to be "initialized"
  after receiving the first status notification from the plugin isolate.
* The LegacyAnalysisServer now uses the additional "are plugins
  analyzing" signal, held in NotificationManager, and the "are plugins
  initializing" signal, held in PluginManager, to determine whether to
  notify the client that analysis is complete.


Change-Id: Ie2b6a6048f074d7a26d7d5d07622a17c30fcab96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405444
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-31 10:44:36 -08:00
Sam Rawlins f5d01eb734 DAS plugins: Remove direct dependency on _fe_analyzer_shared
Change-Id: If498173f3d37ab6798a1e05070274c197948ab0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406687
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-01-31 09:27:59 -08:00
pq 876752e40f [CQ] add feature isEnabled utility
Change-Id: I267aee8da50ec073a28bdb22ebe5379d31b1dc91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403265
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-07 13:18:28 -08:00
Konstantin Shcheglov a5468363c6 CQ. Remove unnecessary 'async' where no 'await'.
Change-Id: I58f56c098c9cec753325ab56d0aad37e1fde0ec6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403082
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-01-07 10:08:11 -08:00
Brian Wilkerson 7041cda56d [Migrate] CorrectionProducer
Change-Id: Ia8fba6d745d04cef88d1beb7e6da7ed15d23fcb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402588
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-03 09:50:10 -08:00
pq 8a08c1bc56 [element model] migrate session_helper API
Change-Id: Ia2717bb24c83a409e853fb5271a3d5ed91cd3306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402142
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-20 13:56:49 -08:00
Danny Tuppeny 11904ed387 [analyzer] Add LinterContext.currentUnit and use it for content in eol_at_end_of_file
... instead of potentially reading the file from disk.

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

Change-Id: Id5939dce4d11429a929a4b63611ff1823449b64c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401424
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-12-17 10:19:59 -08:00
Konstantin Shcheglov af2527723b Elements. Migrate lib/src/cider/fixes.dart
Change-Id: I01867f48ac6d39c65a9a21961079232399e05c1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399029
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-12-06 23:59:55 +00:00