Commit Graph

7807 Commits

Author SHA1 Message Date
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
Brian Wilkerson b402fac6fa Adds library cycle data to the analytics.
The two pieces of information we're tracking are
- the number of libraries in each library cycle
- the number of lines of code in each library cycle

The data is reported in terms of percentage.

This doesn't give us any way to correlate the two values. Knowing that
there is a library cycle with M libraries and a cycle with N lines of
code, doesn't tell us whether it's the same library cycle in both cases.
Still, I think it will help us understand the nature of the code that
we need to be able to analyze quickly.

Change-Id: I36a8bf11c4c6fdced6c524225be7a633062351ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437126
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-26 14:54:52 -07:00
Jens Johansen 1530dcc679 [analyzer] Return null faster in _getDocumentation on DocumentationPreference.none
For some requests this seems to be ~3.5-4.5% faster.

Change-Id: Ifff8656dc1237e1d0014305efa31906be9120d05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-26 01:38:49 -07:00
Jens Johansen 2910b812fc [analyzer] Fix wrong .run call in lsp completion handler; add timing to sendResponse
E.g. when sending 2000 results to a completion request, sending (json
and utf8 encoding) can be a very big part of the cost and it's very
confusing having it attributed to "self" in "request".
Also `mapSuggestions` looked much cheaper than it was because it used
`run` instead of `runAsync`.

Change-Id: Ifd219adb25fa658930548536eb8eb46276acd4a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436922
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-26 01:38:02 -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
Brian Wilkerson 8f1a2b39ea Bump tools to 7bf22c951019f860aa52a8b7dc97fba5880aa9ba
Changes:
```
> git log --format="%C(auto) %h %s" 1e110fc..7bf22c9
 https://dart.googlesource.com/tools.git/+/7bf22c95 [unified_analytics]Add library cycle info to analysis server data (2117)

```

Diff: https://dart.googlesource.com/tools.git/+/1e110fcf8da4fbd423e22ae7d14f04c908d7c139..7bf22c951019f860aa52a8b7dc97fba5880aa9ba/
Change-Id: I0cd6893dc35fd4dc938070afb4ec1c2f45054dea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436943
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-25 15:08:46 -07:00
Sam Rawlins 04e11b83c0 DAS: Make CreateMethodOrFunction.fixKind final
With this change, CreateMethodOrFunction complies with the contract
that `fixKind` not change before/after `compute()` is called.

This change includes some tidying to simplify the code:

* The decision of whether to use `DartFixKind.CREATE_METHOD` or
  `DartFixKind.CREATE_FUNCTION` is solely based on whether the
  "target element" is an InterfaceElement. So in the new factory
  constructor, we compute the "target element", and save that in a
  final field, as well as the fixKind.
* `isStatic` was computed eagerly with other variables in a nest of
  else-if bodies. But it is only needed when creating a _method_, and
  so it's value can be computed nearer to where it is used.
* `compute()` was ~100 lines long, and a lot of that code was dedicated
  to computing the parameter type. Intermediate values like `argument`
  and `parameterElement` sort of clutter the local variables; all of
  that code can be moved to a function that just computes the
  parameter type.

Change-Id: Ibd5d96b752e7e03e52f585bb594c34331b08cdf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-25 12:15:41 -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
Fedor Shcheglov c913e9dd6f Add test and implementation for replacing final with var in for loops.
Change-Id: If32b0f77cae3f1e3d3b8880b70d161fc22a973b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436541
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-24 12:35:50 -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
Jens Johansen b79056a0bb [analyzer] Don't calculate add-late assists for other files
The "add late" assist was broadened in
https://dart-review.googlesource.com/c/sdk/+/176900 with a link to
https://github.com/dart-lang/sdk/issues/44440 where the example is
adding `late` to a field in the same class the user is currently editing
the constructor for.

That makes sense.

The code could also add the `late` keyword to other files which is - I
think - bad for at least two reasons:

  1) It's confusing being given the option to "add late" to something,
     then when trying it nothing seemingly happen, except something does
     happen: another - possibly not open - file has changed.
  2) It requests the resolved unit for another - possibly not open -
     file, which is slow. This means that, at least in VSCode, just
     moving the cursor over something can send requests that takes a
     long time. In practise I've experienced up to ~1.5 seconds, and in
     benchmarks I can make this arbitrarily large by increasing the
     size of the file. Shown below, having 16,000 small classes takes
     around 4 seconds (vs less than 10 ms with this CL).

This CL restricts this to the same file, adds a few tests and updates
a few existing tests.

Note that the existing tests that verified the behavior of adding `late`
to other files was added in
https://dart-review.googlesource.com/c/sdk/+/180087 with a link to
https://github.com/dart-lang/sdk/issues/44534
where the issue discusses a bug where it is applied in the wrong file
and says that it should either be applied to the right file or be
disallowed. The option of allowing it was picked in that instance,
but now at least there's data to show that it comes at a cost.

For an ad-hoc test where I programmatically asks for assists at every
position in `pkg/front_end/lib/src/kernel/body_builder.dart` I go from
1875 positions that takes >= 100 ms to answer to 0 such positions.

For the added benchmark I get this data:

Before this CL:

```
size 1000:
Initial analysis: 0.188291
Action call on 4:11 : 0.308514
Action call on 4:12 : 0.319540
Action call on 4:13 : 0.274678
peak virtual memory size: 2363 MB
total program size (virtual): 2292 MB
peak resident set size ("high water mark"): 258 MB
size of memory portions (rss): 244 MB

size 2000:
Initial analysis: 0.387643
Action call on 4:11 : 0.649877
Action call on 4:12 : 0.550778
Action call on 4:13 : 0.474030
peak virtual memory size: 2325 MB
total program size (virtual): 2325 MB
peak resident set size ("high water mark"): 279 MB
size of memory portions (rss): 277 MB

size 4000:
Initial analysis: 0.753913
Action call on 4:11 : 1.086648
Action call on 4:12 : 1.015921
Action call on 4:13 : 0.915511
peak virtual memory size: 2335 MB
total program size (virtual): 2304 MB
peak resident set size ("high water mark"): 363 MB
size of memory portions (rss): 334 MB

size 8000:
Initial analysis: 1.235531
Action call on 4:11 : 1.880335
Action call on 4:12 : 1.824658
Action call on 4:13 : 1.771081
peak virtual memory size: 2414 MB
total program size (virtual): 2386 MB
peak resident set size ("high water mark"): 436 MB
size of memory portions (rss): 411 MB

size 16000:
Initial analysis: 2.618666
Action call on 4:11 : 3.991542
Action call on 4:12 : 3.775863
Action call on 4:13 : 4.094692
peak virtual memory size: 2576 MB
total program size (virtual): 2516 MB
peak resident set size ("high water mark"): 667 MB
size of memory portions (rss): 611 MB
```

With this CL:

```
size 1000:
Initial analysis: 0.202665
Action call on 4:11 : 0.005730
Action call on 4:12 : 0.003086
Action call on 4:13 : 0.002743
peak virtual memory size: 2174 MB
total program size (virtual): 2170 MB
peak resident set size ("high water mark"): 256 MB
size of memory portions (rss): 247 MB

size 2000:
Initial analysis: 0.433420
Action call on 4:11 : 0.005353
Action call on 4:12 : 0.002116
Action call on 4:13 : 0.002156
peak virtual memory size: 2226 MB
total program size (virtual): 2226 MB
peak resident set size ("high water mark"): 290 MB
size of memory portions (rss): 240 MB

size 4000:
Initial analysis: 0.674376
Action call on 4:11 : 0.004219
Action call on 4:12 : 0.002138
Action call on 4:13 : 0.001625
peak virtual memory size: 2392 MB
total program size (virtual): 2328 MB
peak resident set size ("high water mark"): 306 MB
size of memory portions (rss): 286 MB

size 8000:
Initial analysis: 1.244688
Action call on 4:11 : 0.005225
Action call on 4:12 : 0.002104
Action call on 4:13 : 0.002729
peak virtual memory size: 2349 MB
total program size (virtual): 2338 MB
peak resident set size ("high water mark"): 385 MB
size of memory portions (rss): 366 MB

size 16000:
Initial analysis: 2.776680
Action call on 4:11 : 0.008848
Action call on 4:12 : 0.002854
Action call on 4:13 : 0.002327
peak virtual memory size: 2423 MB
total program size (virtual): 2405 MB
peak resident set size ("high water mark"): 505 MB
size of memory portions (rss): 489 MB
```

It's interesting how the action calls for sizes >= 4000 was slower than
the initial analysis, but I haven't looked into it.

Change-Id: Icefe02073cdf1ad442a37de2030fd7e53f5013b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-24 00:43:29 -07:00
Fedor Shcheglov ab004f3bcc Write tests and implementation for conditional expression remove_comparison quickfix.
Change-Id: Ifc3373895b8c96e610e9515e0cae92be85e8d0b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436161
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-23 14:51:30 -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 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 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
Keerti Parthasarathy 307b2644c6 [Completion]Add a few more checks when suggesting keywords.
Change-Id: I23a3984673ae64cedb1bd5cc24cdb60c57ff620e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-20 14:04:20 -07:00
Brian Wilkerson a1ea2b589b Ensure that the scheduler flushes the event queue
There was only one place that wasn't using a future with a zero length
duration, but that's now been fixed. I haven't been able to observe any
performance improvement from this change, but it does have the benefit
that the code is now consistent.

Change-Id: I232728ef2ef9a1000938d0117f611a96c17e9f38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435662
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-06-20 11:03:33 -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
FMorschel 91a3c73e87 [DAS] Fixes type completion for switch expression, function declaration and async function body
Fixes: https://github.com/dart-lang/sdk/issues/60808
Change-Id: Ia6cc2cbad3206f62c9149a5e326dc8333aca556f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434124
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-06-18 15:41:54 -07:00
FMorschel 2175df077f [DAS] Adds new create operator fix
Fixes: https://github.com/dart-lang/sdk/issues/60954
Change-Id: I933e45ddd950b798e87595f4de8a5cadabddf898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435660
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-18 15:24:03 -07:00
FMorschel 27ff4116cc [DAS] Removes Create Class fix at instance method invocation
Fixes: https://github.com/dart-lang/sdk/issues/60955
Change-Id: I1be7564e71edb919c56c6c1fbc282f901f96bab4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435560
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-18 15:03:16 -07:00
Sam Rawlins 712d77637f analyzer: Deprecate AnalysisResultWithErrors in favor of AnalysisResultWithDiagnostics
Change-Id: Iddad83a42a22cef32c0e36d01a9232b71862cb98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435360
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-18 11:45:20 -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
Keerti Parthasarathy 9c5ef8985f [Completion]Fix for adding duplicate rethrow keyword
Change-Id: Ia6b48b7e7058d856e4e28725327ecdfc6508b407
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435300
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-17 14:50:29 -07:00
Sam Rawlins 73d2e85e73 Deprecate RangeFactory.error in favor of RangeFactory.diagnostic
Change-Id: I1d4c75ea58f9bdd763665ce009cb15f34b94240e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434983
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-17 14:45:27 -07:00
Kallen Tu 1df157bf50 [analysis_server] Dot shorthands: Code completion for property accesses.
Code completion for property accesses.
When typing `.`, code completion will suggest static members based on the context type at that location.

Added unit tests with and without prefixes.

I'll follow up with additional tests and changes for invocations. I wanted to make sure I wasn't missing anything here.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: Ib488bd02cdc66bacd6fa527b983a215f2e16b442
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434144
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-17 14:42:26 -07:00
Danny Tuppeny b0d4ab8ef9 [analysis_server] Move test/integration to integration_test
This was mostly a rename/move of the folder (and the analysis server updated all references), but I also had to:

- add `integration_test/analysis_options.yaml` to import from `../test` to get the same lint ignores
- update paths of exclusions in `verify_sorted_test.dart`

By moving all of the tests that start the server out-of-process out of test, we can:

1. Use "dart test" to just run the faster tests ("dart test test") and get functionality of the pkg:test runner (for example running tests concurrently and JSON output)
2. Allow VS Code to spawn different debug sessions for the "test" and "integration_test" folder, which means we can use a `preLaunchTask` to trigger compilation of the analysis server from source whenever running integration tests (avoiding having to compile manually, or run from source in a way that compiles a new server for each test suite)

Change-Id: I37cc03dc32d08c5b51a2eab79f6338bb079b32ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434801
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-17 12:54:41 -07:00
Danny Tuppeny 86456d1bab [analysis_server] Fix link to element model page in diagnostics
This URL for this page was recently updated, but this link still had the old value.

Change-Id: I4fe3366105040b64813803b0300d2837c7c1bd4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435200
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-17 10:54:39 -07:00
Jens Johansen 70c65ff53f [analysis_server] Only include dart files on status pages
Before this CL (introduced in 816b974c15)
every file was attempted fetched as a dart file when collecting a report
and when opening the "context" page - so if you had other files, say,
several 100MB+ text files from the the computer language benchmarks
game, it would both take quite a while and eat up a good chunk of
memory.

This filteres to only dart files (as it's done in other places that
calls `contextRoot.analyzedFiles()`) but leaves the functionality.

As for the functionality, while I understand that the information can be
useful it potentially force-loads a lot of data (even if only actual
dart files) which I'm not sure is a good idea. A happy user likely won't
visit this page, and an unhappy user is probably not getting any happier
by the memory usage increasing. Anyway. Food for thought.

Change-Id: I0c9f690b9b275cb1970920cdb55e14b1a1429aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434700
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-16 23:43:48 -07:00
Jens Johansen dbc16b3ace [analysis_server] Fix collect report returning 500 because of a crash on json convert
After 816b974c15 the download report on
"Analysis Server Diagnostics" did not work.

Change-Id: I14f2525730772f7cf72a7a9c622ae3094602766a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-16 23:39:08 -07:00
Keerti Parthasarathy e0a91d5304 [Completion]Remove duplicate addition of default keyword
Change-Id: Ief8584a90c69c4b049b0eb28224d745576e1a374
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-16 17:28:03 -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
Danny Tuppeny a54c46c68f [analysis_server] Include declared identifiers and destructed variables in inline values
Fixes https://github.com/Dart-Code/Dart-Code/issues/5547

Change-Id: I3ccf2d500d704a44fc96ba802837c11893e7f3eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-16 13:31:49 -07:00
Keerti Parthasarathy 265a970813 [Completion] Fix adding duplicate const keyword suggestions for variables.
Change-Id: I31d354c32720d46f9b6041d04c6f62de26031551
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434121
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-13 12:07:21 -07:00
Brian Wilkerson d9c681e748 Provide better hovers for super formal parameters
Change-Id: I9131eb0ee516e79580f530e6279ec1da08dde7e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-11 14:41:38 -07:00
Brian Wilkerson 3cc8940b30 Make inline-method not inline references in combinators
An earlier CL fixed a bug where an inline-method refactor could be
initiated at a reference to a top-level function in an import
combinator.

This CL makes the corresponding change to prevent such references from
being changed when the refactor is initiated at the declaration site.

Change-Id: I769ff83ce946d971780474a9908e1ac63bd1e02d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434180
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-11 13:36:03 -07:00
Kallen Tu beca727904 [analysis_server] Dot shorthands: Syntactic and semantic highlighting.
Added additional logic for handling highlighting for dot shorthands.

New semantic tokens and highlights tests passing.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I2e242732aade9471675731473532d6d3c6558281
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433102
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-11 12:16:41 -07:00
Sam Rawlins dadef9bfab DAS: Rename CorrectionProducer.errorLength and errorOffset to diagnostic names
Change-Id: I7578da7f1be1f996474b22621885e45ab3e86428
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434100
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-11 11:06:31 -07:00
Sam Rawlins 2bd5128b2d analyzer: Rename AstNodeExtension.withParents to withAncestors
Change-Id: I7554db51356bef19cacad1359399d2c44e6aff7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-11 10:10:45 -07:00
Danny Tuppeny f717a0ef7e [analysis_server] Fix line endings in snippets
This removes `useLineEndingsForPlatform=false` from the Snippets tests and updates them to use a shared method that correctly handles normalization of the `expected` result.

It turned out that we had bugs here, with the correct line endings not being used, so it also fixes that by passing `eol` to the `ChangeBuilder`s created by the snippet producers.

Progress towards https://github.com/dart-lang/sdk/issues/60234

Change-Id: I851fee987dda52f329d110878e10593cbced8c6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433780
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-11 07:40:42 -07:00
Brian Wilkerson b67482d6bc Stop inlining methods in a combinator
Fixes https://github.com/dart-lang/sdk/issues/28253

Change-Id: I186f36c107b11dcfdefb2aa56420b607e80aa69e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434021
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-10 21:08:49 -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
Danny Tuppeny ec8864f4e5 [analysis_server] Combine the containing class + library into a single line in LSP hovers
Change-Id: I21a285eddcf855cf0ebfd59e6d6178ee6bfa1c59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433481
Auto-Submit: Danny Tuppeny <danny@tuppeny.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-10 09:31:21 -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
FMorschel bc4e201375 [DAS] Fixes missing case for create class
This also adds a new priority for mixins when the written type name starts with lowercase letters (to match the class existing ones) and tests the priority between it, create class and import fixes.

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

Change-Id: Ie451db6a273fe8eb52df21725276068b1980e7f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433500
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-09 15:10:50 -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 b0adb4185e Convert upper snake case fields to lower camel case
There are no semantic changes in this CL, just renames.

The one unfortunate rename was from `DEFAULT` to `default_`. It can't be
`default` because that's a built-in identifier. If you have a better
convention to follow here I'm happy to change it.

Change-Id: Idf70621ad577dbea6c1c161aac17e9e200aac2d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433440
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-09 07:35:37 -07:00