Commit Graph

556 Commits

Author SHA1 Message Date
Konstantin Shcheglov 32124f25a0 API. Deprecate 'VariableDeclaration.declaredElement', use 'VariableDeclaration.declaredFragment'.
This makes API consistent.

Bug: https://github.com/dart-lang/sdk/issues/61231
Change-Id: I841dc10cd2ef4b28286d374af26c079dcf69179e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444863
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-08-12 14:30:49 -07:00
Kallen Tu b2f2dc01a3 [analysis_server] Dot shorthands: Update AddEnumConstant fix.
Update `AddEnumConstant` fix to handle dot shorthands. Added some relevant unit tests.

This revealed a bug in `change_builder_dart` where we'd crash with an enum with no constants. Added some tests for that in `create_field_test`.

Bug: https://github.com/dart-lang/sdk/issues/60994
Change-Id: Id75b79b8717305ddca3092fc35cadec7677177df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-08-06 14:44:20 -07:00
Kallen Tu c5eba84538 [analysis_server] Dot shorthands: Code completion for methods and constructors.
Update code completion to handle completing static methods and (non-const) constructors.

Additionally, I noticed that we weren't suggesting any completion for extension types? I added the case for it and a few tests.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: Ib677cd99e51b8a641aa1bfbad5ffc8a8cbdc38c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-08-05 15:36:57 -07:00
Danny Tuppeny 784fdb4a1f [analysis_server] Move EOL from ChangeBuilder to FileEditBuilder
Because ChangeBuilder can be used to modify multiple files, the EOL should come from an individual files edit builder and not from the overall ChangeBuilder.

This change renames `eol` on ChangeBuilder to `defaultEol` (since it's still useful to supply a custom default, for example when moving a class from an existing file to a new file, we want to default to the same EOL as the source file), and adds an EOL to file edit builders which is computed from the file content (and falls back to the default from ChangeBuilder if there are none).

My intention here is to not introduce any breaking changes (yet) so the ChangeBuilder constructor interface still has the "eol" named parameter (marked as deprecated) as well as the new `defaultEol` parameter.

I added a new `StringExtension` for `endOfLine` to both analyzer_plugin and analysis_server_plugin as we need this in both places (but I expect one of those projects will ultimately be dropped). This slightly differs from `CorrectionUtils.endOfLine` because it can return `null` which is a signal to fall back to the ChangeBuilder default instead of forcing its own default. (CorrectionUtils.endOfLine now uses that extension, although because of the null/default, it's likely that some - if not all - uses of this should migrate to the new extension and fall back to a default from a ChangeBuilder).

Change-Id: Ie2e6eaba78c96a1cbd79eba881e12bbeef724aa8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443122
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-08-04 14:56:40 -07:00
Konstantin Shcheglov 6311478193 Elements. Add documentationComment and metadata to Element and Fragment.
Bug: https://github.com/dart-lang/sdk/issues/61216
Change-Id: I46ee0dfe2a720d61b3b4576634cf623b8817d0ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443149
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-08-01 09:04:47 -07:00
Fedor Shcheglov f47cc4487b Remove Xyz2 suffix getters from /analysis
Change-Id: I10221b86f63ee8a2d74938ef0438945b43e11f6b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441990
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-24 05:54:30 -07:00
Konstantin Shcheglov 3c60075478 Elements. Switch away from TypeAliasElement.aliasedElement
Change-Id: I2ddc4c1a850871d63c0b12f0a14293fff888d523
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-21 09:15:04 -07:00
Fedor Shcheglov 6a5c577465 Rename / deprecate more getters and methods.
* Deprecate `DirectiveUriWithLibrary.library2`, use `library` instead.
* Deprecate `ElementAnnotation.element2`, use `element` instead.
* Deprecate `LibraryImport.prefix2`, use `prefix` instead.
* Deprecate `MultiplyDefinedElement.conflictingElements2`, use `conflictingElements` instead.
* Deprecate `ScopeLookupResult.getter2`, use `getter` instead.
* Deprecate `ScopeLookupResult.setter2`, use `setter` instead.

Change-Id: I523eb21d194b661eed5bcbbfc923e9a7de87c962
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440361
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-15 15:10:55 -07:00
Fedor Shcheglov 8cfa901c6e Rename nameOffset2 to nameOffset
Change-Id: I3c8051840122b6046bc89ed48ec329c825607fe5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440180
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-07-13 20:44:49 -07:00
Fedor Shcheglov 238cd4c20a Deprecate constants2, lookUpInheritedMethod2, lookUpInheritedMethod2, classes2, classes2, extensionTypes2, extensions2, functions2, libraryExports2, libraryImports2, libraryImports2, mixins2, topLevelVariables2, typeAliases2, join2, isNonSubtypableClass2, and typeParameters2.
Change-Id: Ia4b5504d91548b561e2e2434e711c40b2dc5e495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/440100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-12 16:23:12 -07:00
Fedor Shcheglov 7218145cd2 Deprecate appendToWithoutDelimiters2, correspondingSetter2, unnamedConstructor2, getNamedConstructor2, entryPoint2, exportedLibraries2, getClass2, getEnum2, getMixin2, exportedLibrary2, accessibleExtensions2, importedLibraries2, importedLibrary2, isImplementableIn2, join2, variable3, getter2, setter2, correspondingGetter2, superConstructorParameter2, aliasedElement2, typeParameters2, constantInitializer2, and isNonSubtypableClass2
Change-Id: I091804b9f200f525baf3979773dd489e3be17697
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439640
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-07-09 20:34:14 -07:00
Danny Tuppeny 077f16021f [analysis_server] Include DocumentLinks to Pub for dependency_overrides
+ a small refactor to stop using a Map to verify links because we can have multiple instances of the same package name in the file now, so mark up the ranges in the file and verify against them.

Fixes https://github.com/Dart-Code/Dart-Code/issues/5588

Change-Id: I83d452be37c7eeb8579adc488b0a59a366c9fe5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-07-09 11:20:49 -07:00
Fedor Shcheglov 933f3da0f7 Deprecate appendToWithoutDelimiters, correspondingSetter2, unnamedConstructor2, getNamedConstructor2, and typeParameters2
Change-Id: I42dcff17c5bb0c9d6c3ae55dcdd4df85d83cd076
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-09 11:13:07 -07:00
Fedor Shcheglov 1a88edceb7 Deprecate redirectedConstructor2, superConstructor2, children2, displayString2, getExtendedDisplayName2, isAccessibleIn2, thisOrAncestorMatching2, thisOrAncestorOfType2, constants2, field2, typeParameters2, children3, asInstanceOf2, instantiateInterfaceToBounds2, and instantiateTypeAliasToBounds2.
Change-Id: I82004d5d1c758aae51ec8c97645aa53ed8cc52bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-07-09 07:13:51 -07:00
Fedor Shcheglov 247ae2364f Deprecate Element.name3, use name instead.
Change-Id: I24a5e4a519b9f3bf755912f21a5c192edd1dd4ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439381
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-08 14:13:49 -07:00
Fedor Shcheglov 14de1522e1 Deprecate Fragment.name2, use name instead.
Change-Id: Ic0506f50e9dc752b7e8e28f4299426be47407d4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439081
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-07-08 09:17:39 -07:00
Fedor Shcheglov ab49c6e912 Deprecate getters and methods within analyzer/lib/src/dart/ast
Change-Id: I100b713897275e0a76bca5e669f73786a2a94ab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437641
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-30 14:28:51 -07:00
Fedor Shcheglov 9975ed32e0 Deprecate InstantiatedTypeAliasElement.element2, use element instead.
Change-Id: I7d702ec2c1df143c3dd4d28586796498fc9ec819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435747
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-06-27 12:06:40 -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 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
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
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
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
FMorschel 9d6c5d40d0 [DAS] Fixes "Go to declaration" for undefined new constructor
Fixes: https://github.com/dart-lang/sdk/issues/60773
Change-Id: I7ee7cec371fbf0d0f9de1a4fe2b946929ba80d61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-06-05 12:08:44 -07:00
Konstantin Shcheglov e724547892 Elements. Deprecate Annotatable.metadata2, use 'metadata' instead.
Change-Id: Ic4a7d8f19cb1793031951aadeb340e5dadf4744c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430261
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-30 11:09:40 -07:00
Brian Wilkerson 2545c3eb31 Remove three more uses of NodeLocator2
Change-Id: I3e8fba0516bb0988ca0794991e980157dacb7231
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430860
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-23 10:22:17 -07:00
Konstantin Shcheglov 64baa393e5 Elements. Deprecate JoinPatternVariableElement.variables2, use 'variables' instead.
Change-Id: Ie896718aa19a5867be1a05a210ffb28a0daaa79e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429824
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-21 13:59:30 -07:00
FMorschel 37edff79b1 [DAS] Adds new Remove async assist
Fixes: https://github.com/dart-lang/sdk/issues/59814
Fixes: https://github.com/dart-lang/sdk/issues/23962

Change-Id: I8121da0106f4f81b93bfcdc0908b0977210fa3c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425602
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-05-20 12:56:40 -07:00
Sam Rawlins 08c541aa9c analyzer_plugin: support library_private_types_in_public_api lint rule
Luckily, the two cases which were reported could both be remedied by
making more things private.

* `DartFileEditBuilderImpl.librariesToImport` exposed `_LibraryImport`,
  but could be made private anyhow. Also, it's package-private code,
  so this is not a breaking change.
* `CodegenVisitor.generateConstant` accepted a private type as an
  argument, but the whole class can be made private.

Change-Id: I8613812385ed0e9a7e36922d86889dad4cedf3cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428924
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-16 13:45:57 -07:00
Jens Johansen 0d4b08caaa [analyzer] Use QueueList by default in SourceFileEdit
Adding edits (e.g. via `dart fix --apply` are often done with
`List.insert(0, whatnot)` which takes O(n) time.
Here QueueList that can insert fast at both ends is used instead
(and we use `addFirst` instead of `insert(0)`.

On the example from
https://github.com/feinstein/google-i18n-address-dart.git we go from:

```
$ time dart fix --use-aot-snapshot --apply
[...]
249517 fixes made in 255 files.

real    3m55.810s
user    4m1.209s
sys     0m3.714s

(resetting)
$ time dart fix --use-aot-snapshot --apply
[...]
249517 fixes made in 255 files.

real    3m33.966s
user    3m37.588s
sys     0m2.058s

(resetting)
$ time dart fix --use-aot-snapshot --apply
[...]
249517 fixes made in 255 files.

real    3m36.525s
user    3m40.083s
sys     0m1.907s
```

to:

```
$ time dart fix --use-aot-snapshot --apply
[...]
249517 fixes made in 255 files.

real    0m9.970s
user    0m12.676s
sys     0m2.100s

(resetting)
$ time dart fix --use-aot-snapshot --apply
[...]
249517 fixes made in 255 files.

real    0m9.862s
user    0m12.926s
sys     0m1.797s

(resetting)
$ time dart fix --use-aot-snapshot --apply
[...]
249517 fixes made in 255 files.

real    0m9.612s
user    0m12.712s
sys     0m1.834s
```

Statistics on the `real` runtime:

```
    N           Min           Max        Median           Avg        Stddev
x   3       213.966        235.81       216.525     222.10033     11.941664
+   3         9.612          9.97         9.862     9.8146667    0.18363369
Difference at 95.0% confidence
        -212.286 +/- 19.1415
        -95.581% +/- 8.61838%
        (Student's t, pooled s = 8.44503)
```

For `lsp_many_prefer_single_quotes_violations_benchmark.dart --sizes=3200`:

Before from something like:

```
Initial analysis: 0.115654
First code action call: 0.835152
Subsequent action call 1: 0.538592
Subsequent action call 2: 0.561636
Select all code action call: 1.564402
```

After to something like:
```
Initial analysis: 0.086985
First code action call: 0.411660
Subsequent action call 1: 0.171566
Subsequent action call 2: 0.193708
Select all code action call: 1.107339
```

Statistics on 5 runs gives:

First code action call:

```
Difference at 95.0% confidence
        -0.44381 +/- 0.0261597
        -52.4602% +/- 3.09218%
        (Student's t, pooled s = 0.0179367)
```

Subsequent action call 1:

```
Difference at 95.0% confidence
        -0.381012 +/- 0.0195618
        -69.9139% +/- 3.5895%
        (Student's t, pooled s = 0.0134128)
```

Subsequent action call 2:

```
Difference at 95.0% confidence
        -0.360077 +/- 0.0265277
        -64.634% +/- 4.76173%
        (Student's t, pooled s = 0.0181891)
```

Select all code action call:

```
Difference at 95.0% confidence
        -0.405855 +/- 0.027662
        -26.7277% +/- 1.82169%
        (Student's t, pooled s = 0.0189668)
```

Change-Id: I3868afaa8c32a24c01c3a52bd8a53d5e8e4e3afe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427401
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-16 00:45:34 -07:00
Konstantin Shcheglov 05da3e1f22 Elements. Deprecate Element.enclosingElement2, use enclosingElement.
Change-Id: I055b1f9dd1c00605d813effcbbadb9cea874129a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-05-15 13:47:32 -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
Konstantin Shcheglov 93f453912a Make 'token' a required named formal parameter of SimpleIdentifierImpl constructor.
For consistency.

Change-Id: I1b391353cffc0ad41cb81df51cd5a57fb9207c5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428080
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-12 09:28:18 -07:00
Konstantin Shcheglov 7eea262f06 Deprecate NamedType.name2, use 'name' instead.
Change-Id: I27725e1530c60a6aa2e197b97e027de1238c964a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427980
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-12 08:35:59 -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
Sam Rawlins 126def2b08 analyzer_plugin: Use Diagnostic instead of deprecated AnalysisError
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Icf62987d6de7cafb6f6e92076a5fcc2bd48772c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426522
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-05 11:34:00 -07:00
Brian Wilkerson 24cae8a684 Improve the performance of applying edits
I wrote a test that generates 10,000 lines of code, each containing one
violation of `prefer_single_quotes`, computes the fixes for all of the
diagnostics, and applies the 20,000 edits, measuring how long the
application takes.

Before this change the average was 3355.0 ms.

After this change the average is 3.8 ms.

The change was inspired by Jens.

Change-Id: Icd54a81ca3848fd5f0168934f713a7be8caec359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425601
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-05-01 15:59:59 -07:00
Brian Wilkerson a676b7f700 Improve the performance of the bulk fix processor
This improvement was found by Jens.

The bulk fix processor needs to be able to revert a partial set of edits
that can't be completed because of a conflicting pre-existing edit. In
order to do that efficiently it needs to know whether there are any
edits to be reverted, which it used to do by computing a hash from the
edits both before and after running a correction producer. Computing
the hashes is expensive.

This CL changes the detection to use a modification counter that's
incremented any time new edits are added, removing the computation of
the hash values.

I don't yet have a benchmark for the case that uncovered the issue,
but I do have code that generates a file containing 10,000 violations
of the prefer_single_quotes lint, requests bulk fix results 5 times
to warm up the VM, then requests fixes 5 more times and prints an
average (the times between runs are fairly close, so the standard
deviation is small). The code uses the legacy protocol to request the
fixes, but it doesn't execute any of the code in dartdev.)

    Before this change the average was 20670.6 ms.

    After this change the average ise 13979.0 ms.

This represents a 32% improvement.

Change-Id: I74c079bef8e095acf4ad36de6d0c0241934f79a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425221
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-04-29 07:29:01 -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
Sam Rawlins 52f965e217 Analyzer: Remove outdated NodeLocator class
Change-Id: If8cff437d35452af5a19b4d414352228f899a94f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423216
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-21 10:11:30 -07:00
Sam Rawlins bc230b73aa Deprecate the unused importPrefixGenerator parameter of ChangeBuilder.addDartFileEdit
Change-Id: Ic8bad9999359d3670ea58fe9594e744d6560a030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2025-03-31 09:53:57 -07:00
Sam Rawlins d592a7eb26 DAS: Remove dead DartFileEditBuilderImpl code
* Privatize `DartEditBuilderImpl.dartFileEditBuilder`.
* Rename the `toAdd` parameter on `_addAll` to `items`.
* Remove the unused `required` argument on `_canWriteType`.
* Privatize `DartFileEditBuilderImpl.createEditsForImports`,
  `.codeStyleOptions`, and `ensureShown`.
* Remove the unused `useShow` parameter on
  `DartFileEditBuilderImpl.importElementLibrary`.

Change-Id: I473788d9d566a2982914c374fce2429909466381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418703
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-03-31 08:46:20 -07:00
FMorschel 35f84de658 [DAS] Fixes navigation to pattern variable with multiple declarations
Bug: https://github.com/dart-lang/sdk/issues/60398
Change-Id: Ibdb1681075c4a097a50483628af50da055cc751d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417905
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-03-27 11:11:16 -07:00
Konstantin Shcheglov bb676ba1f5 Elements. ElementImpl is not Element2.
Change-Id: Ia8885018d3e23875e53dfa0d3cf470bdd28eef29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-03-17 08:46:49 -07:00
FMorschel 48943ce460 [DAS] Provides DocumentLinks for lints in analysis_options.yaml
R=pquitslund@google.com

Fixes: https://github.com/dart-lang/sdk/issues/60185
Change-Id: I109ccba725af08cb037ac2b3ffa8d108926d15bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/411280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-03-11 12:26:00 -07:00
Sam Rawlins 68d05068aa analyzer: Extract out two common utilities for URIs
* Uri.isSamePackageAs(Uri) and Uri.isImplementation are each used a
  few times. Not as much as I would expect, but this still simplifies
  some code.

Change-Id: Ie9020916c793852a0df9d04154420948d942d951
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-03-10 08:26:12 -07:00
Sam Rawlins 4ee4acc93c DAS: Tidy docs and API in import_library.dart
Change-Id: I2e18a9113ec96ec33fbf71e656ab0045496599c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413721
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-03-05 10:42:30 -08:00
FMorschel 4aa8b10978 [DAS] Makes "Add type annotation" consider explicit type arguments
R=scheglov@google.com

Fixes: https://github.com/dart-lang/sdk/issues/60080
Change-Id: I88bb6c3ece6f6a95bc22aa57e34aa16afa34bc7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412540
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-03-03 07:46:28 -08:00
FMorschel 58ff654dd5 [DAS] Adds 'Create extension method/operator' fixes
R=srawlins@google.com

Fixes: https://github.com/dart-lang/sdk/issues/60203
Change-Id: I2527c130dd68cf678ac4529eda42397ef80ca53c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412060
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-02-28 14:20:16 -08:00