Commit Graph

8012 Commits

Author SHA1 Message Date
Keerti Parthasarathy a46b4bb4c6 Collect analytics on type of workpace and number of packages for contexts.
Change-Id: I2274536383f92f21912bd39dc5a6796dd2177fd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456800
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-23 12:21:55 -07:00
FMorschel bbc2fa4598 [DAS] Fixes occurrences for error and stacktrace in try catch
Fixes: https://github.com/dart-lang/sdk/issues/61769
Change-Id: Icd7cc87bb9789f6ec697653be1b76e1cf52b52a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456360
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-10-23 08:48:46 -07:00
Jens Johansen 820a1ec5a5 [analysis server] Don't allocate on each compare when sorting in semanticTokens/full
Upon a `textDocument/semanticTokens/full` request the analysis server
sorts the "tokens" via `sort` on List giving it a compare method.
The method, though, created a map literal for each comparison.
This CL "inlines" the map (it only had one entry anyway) and adds a
benchmark, where I note these changes:

```
1000:
Difference at 95.0% confidence
        -0.0274151 +/- 0.0135978
        -33.1981% +/- 16.4662%
        (Student's t, pooled s = 0.0181832)

2000:
Difference at 95.0% confidence
        -0.027344 +/- 0.0096196
        -20.9529% +/- 7.3712%
        (Student's t, pooled s = 0.0128635)

4000:
Difference at 95.0% confidence
        -0.108847 +/- 0.0196627
        -35.3172% +/- 6.37987%
        (Student's t, pooled s = 0.0262932)

8000:
Difference at 95.0% confidence
        -0.20647 +/- 0.0272577
        -34.4932% +/- 4.55371%
        (Student's t, pooled s = 0.0364494)

16000:
Difference at 95.0% confidence
        -0.384931 +/- 0.0401393
        -31.4809% +/- 3.28272%
        (Student's t, pooled s = 0.0536748)
```
Change-Id: Ibacce056cd3f154afc9377805bbccfd8c5ca9ea9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456341
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-10-22 23:42:19 -07:00
Sam Rawlins a2e9153029 DAS: Tidy map literals and constant names in protocol.dart
We rename constant names to use lowerCamelCase, and append
"AttributeName" in most cases, as most constants refer to a (as it is
documented) "JSON attribute."

Additionally the `toJson` methods can be simplified by returning
Map literals, instead of setting key/value pairs in individual
statements.

Change-Id: I5f0adabfa3c4d274407ae8a5b5684dce22f9b5fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-22 14:32:11 -07:00
FMorschel b15fb0ee61 [DAS] Fixes FunctionType.call completion
Bug: https://github.com/dart-lang/sdk/issues/61319
Change-Id: Id757b79f46bacb071ccf60f08080c621229313e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451544
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-10-22 11:09:39 -07:00
Konstantin Shcheglov ad73b67f0d CQ. Fix NPE in DartUnitOccurrencesComputerVisitor when unresolved import prefix.
Saw a crash in logs:

  Null check operator used on a null value

  package:analysis_server/src/domains/analysis/occurrences_dart.dart 253:32  DartUnitOccurrencesComputerVisitor.visitImportPrefixReference
  package:analyzer/src/dart/ast/ast.dart 13353:15                            ImportPrefixReferenceImpl.accept
  package:analyzer/src/dart/ast/ast.dart 16897:19                            NamedTypeImpl.visitChildren
  package:analyzer/dart/ast/visitor.g.dart 474:10                            GeneralizingAstVisitor.visitNode
  package:analyzer/dart/ast/visitor.g.dart 687:50                            GeneralizingAstVisitor.visitTypeAnnotation
  package:analyzer/dart/ast/visitor.g.dart 456:40                            GeneralizingAstVisitor.visitNamedType
  package:analysis_server/src/domains/analysis/occurrences_dart.dart 282:11  DartUnitOccurrencesComputerVisitor.visitNamedType
Change-Id: I2b06026dad093187c74b4e1b6c7371aaf648a480
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456121
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-10-20 16:32:15 -07:00
Paul Berry 07669ab650 [messages] Remove HintCode.deprecatedMemberUseFromSamePackage*.
Removes the diagnostic codes
`HintCode.deprecatedMemberUseFromSamePackage` and
`HintCode.deprecatedMemberUseFromSamePackageWithMessage`, and the
logic for reporting them. These hint codes have been replaced with
lints.

Removing these diagnostic codes avoids an ambiguity between
`HintCode.deprecatedMemberUseFromSamePackageWithMessage` and
`LinterLintCode.deprecatedMemberUseFromSamePackageWithMessage`.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

To avoid this change causing `ignore:` comments to become unnecessary
(which would break bots), I've enabled the lint
`deprecated_member_use_from_same_package` in `pkg/analysis_server`,
`pkg/analyzer`, `pkg/compiler`, and `pkg/linter`. After this change
lands, I will work with the owners of those packages to determine
whether it's better to keep the lint enabled or to remove the
`ignore:` comments.

Change-Id: I6a6a6964aa7f69a41b9b815e0f50fc638898f104
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455541
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-20 06:49:30 -07:00
FMorschel b243e6aae5 [DAS] Fixes semantic token for FunctionType.call
Bug: https://github.com/dart-lang/sdk/issues/61319
Change-Id: I4b42c410ff8e901da546d71658e37a5da6a410aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451620
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-17 09:47:27 -07:00
FMorschel b5113c2c23 [DAS] Review create fixes for if-null expressions
Fixes: https://github.com/dart-lang/sdk/issues/61575
Change-Id: If5232574ebe9cb352628eac0f6c07c39c964a110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452240
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-17 09:15:48 -07:00
Paul Berry 3e23d1d4dd [messages] Disambiguate recordLiteralOnePositionalNoTrailingCommaByType.
Renames the diagnostic code
`CompileTimeErrorCode.recordLiteralOnePositionalNoTrailingComma` to
`CompileTimeErrorCode.recordLiteralOnePositionalNoTrailingCommaByType`. This
avoids an ambiguity between this message and
`ParserErrorCode.recordLiteralOnePositionalNoTrailingComma`.

The two messages need to stay distinct, because one is reported during
parsing, and the other is reported during type analysis. Only
`ParserErrorCode.recordLiteralOnePositionalNoTrailingComma` should
prevent the formatter from running.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

Note that the `sharedName` of the renamed diagnostic remains
`RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA`, so there will be no
change in how the error is presented to the user.

Change-Id: I6a6a6964c1d4e28c6db71072252abf95fbc13206
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455562
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-17 07:56:50 -07:00
Paul Berry 081f93dc67 [messages] Remove redundant ScannerErrorCode.expectedToken.
Removes the analyzer error code `ScannerErrorCode.expectedToken` and
replaces usages of it with `ParserErrorCode.expectedToken`. This
avoids an ambiguity between the two messages.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

Change-Id: I6a6a696491a41a9d220a4502bfa9b96410580a19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455561
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-10-17 07:48:54 -07:00
Paul Berry 9dd0f99b2c [messages] Remove redundant ScannerErrorCode.missingIdentifier.
Removes the analyzer error code `ScannerErrorCode.missingIdentifier`
and replaces usages of it with
`ParserErrorCode.missingIdentifier`. This avoids an ambiguity between
the two messages.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

Change-Id: I6a6a696467b91740c152278f538b9fed763e258f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-17 07:45:07 -07:00
Paul Berry 5b07a0d551 [messages] Rename TransformSetErrorCode.unexpectedToken.
Renames `TransformSetErrorCode.unexpectedToken` to
`TransformSetErrorCode.unexpectedTransformSetToken`. This avoids an
ambiguity between this message and `ParserErrorCode.unexpectedToken`.

Avoiding ambiguities like these is important, because in many cases
the user only sees the diagnostic name; they don't see the class it's
in. For example, `ignore:` comments just give the diagnostic name, and
the web page https://dart.dev/tools/diagnostics only shows diagnostic
names.

In the future I intend to add an error check to the analyzer
diagnostic code generator, to ensure that there are no ambiguities
like these. This CL is a prerequisite for adding the error check.

Change-Id: I6a6a69644ac250b0add9a5f70ec1fd4839ebdef3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455468
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-17 07:32:47 -07:00
Paul Berry 11140abcce [messages] Clean up sharing of FieldInitializerOutsideConstructor.
Changes the shared error code `FieldInitializerOutsideConstructor` so
that it generates
`CompileTimeErrorCode.fieldInitializerOutsideConstructor` rather than
`ParserErrorCode.fieldInitializerOutsideConstructor`, replacing the
old analyzer-only
`CompileTimeErrorCode.fieldInitializerOutsideConstructor`. This
eliminates unnecessary code duplication between
`pkg/analyzer/messages.yaml` and
`pkg/_fe_analyzer_shared/messages.yaml`.

Removes logic from `pkg/analyzer/lib/src/fasta/ast_builder.dart` that
previously reported
`ParserErrorCode.fieldInitializerOutsideConstructor`. This logic was
unreliable (it only triggered for method parameters and local function
declarations) and unnecessary (because it duplicated logic in the
`ErrorVerifier`). This improves the user experience by eliminating
duplicate errors.

Change-Id: I6a6a69648a9958db531bb0c84bc604358dd0af6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455466
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-17 07:29:00 -07:00
Paul Berry f5567f7a02 [messages] Use fully qualified constant ref in withArguments.
Modifies the analyzer diagnostic message code generator so that when
generating `withArguments` methods, it uses a fully qualified
reference to the diagnostic constant rather than a bare identifier.

Previously, if one of the named parameters of the `withArguments`
method had the same name as the (camelCase) diagnostic constant, the
parameter would shadow the diagnostic constant, so this would cause a
compile-time error in the genrated code.

Note that although this increases the size of the generated code, it
should still compile to the same machine instructions, so there should
be no performance impact.

Thanks to Brian for discovering this issue!

Change-Id: I6a6a6964c0bd33f06a47a12387a2956b018a8fea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455467
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-17 07:23:00 -07:00
Johnni Winther 49eb514005 [parser] Support primary constructor on classes, enums and extension types
This adds simple support for primary constructors in class, enum and extension type declarations. Declaring formals are not supported yet.

Change-Id: I2fb2cb3a819e38ec4ffe961da4713a871ac29a0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-10-17 01:52:11 -07:00
khoadng 897d42c2ab DAS: Fix noop_primitive_operations message
Closes https://github.com/dart-lang/sdk/pull/61705

GitOrigin-RevId: 4c509dbd05b47ce0cfebd44c983a65d51444ecf6
Change-Id: Ifa553ecd9a08869af1af48a28510bb0fe4a49ffd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454181
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-10-16 15:05:09 -07:00
Danny Tuppeny 7fe858192c [analysis_server] Skip _refreshAnalysisRoots on open/close of files unless onlyAnalyzeProjectsWithOpenFiles is enabled
No functional change, this just skips some work when opening/closing files if we have explicit analysis roots (`onlyAnalyzeProjectsWithOpenFiles=false`, which is the default). In this case, opening and closing files never changes the analysis roots so we don't need to do any of this work.

Change-Id: I052cca6a9b8cbb4d8f936787e83d453f302159c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455500
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-10-16 13:23:24 -07:00
Sam Rawlins b33e10be26 DAS: Make postfix completion descriptors constant
While renaming SCREAMING_SNAKE constants, I noticed this local variable
which is computed from a static constant, so I decided it could also
be a static field. A static field is lazily computed. (It could even
be static constant, but PostfixTemplateDescriptor is not constant; it
could be, but I don't think our code-generation code has a facility
for making constant constructors.

Also make things camelCase.

Change-Id: I6f5da4e5cecee347b44bb3ad3d8fdcde7632986c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454420
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-10-16 10:07:16 -07:00
FMorschel 99be510768 [DAS] Fixes completion for other static members when at the end of constructor name
Fixes: https://github.com/dart-lang/sdk/issues/61722
Change-Id: Ib45542198b09df7aa7e57f311c603b626fc0dbb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455160
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-10-16 09:58:17 -07:00
Danny Tuppeny ceb6b5f797 [analysis_server] Fix folding ranges when nested ranges end on the same line
When the client only supports folding by-line (VS Code), we truncate ranges that intersect but allow nested ranges as long as they don't.

This code was performing truncation if the outer range ended on the same line as the inner range, but this is perfectly fine and didn't need to truncate.

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

Change-Id: I05e2307574481a7a53ee01ef76bd8a26bfde09c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454920
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-10-16 09:57:04 -07:00
Sam Rawlins 174c15212a DAS: Comply with unintended_html_in_doc_comment
Change-Id: Ic96bb851e4f18d11badb3e429f5601e652f89b1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454162
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-15 13:43:58 -07:00
Sam Rawlins 278ea48c7e DAS: Tidy the MemberSorter code, mostly renaming constants
The primary change here is to rename constants from SCREAMING_SNAKE
case. Also:

* Make the fields private, as a best practice, which also highlights
  that the `endOfLine` field is unused.
* In `sortUnitMembers`, use a switch since `CompilationUnitMember` is
  a sealed class. This highlights, via the necessary `default` case,
  that the switch is non-exhaustive.

Change-Id: I41a9ebdec651402e3e894321a9d6e72b1cbbb66a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454421
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-13 09:11:35 -07:00
Sam Rawlins 26738fe09d DAS: Use null-aware elements
Change-Id: I15e3b9f8867de3ef651e844cc474119d6c3aea81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454323
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-10 11:30:11 -07:00
Danny Tuppeny 4c01a9ca26 [analysis_server] Fix handling of optional and differently-ordered arguments in Extract Widget
This code made assumptions about the list of (method) parameters and arguments being the same (length and order). This caused a RangeError if there were optional parameters that weren't provided, and the wrong argument names if the order was different.

We now look up the arguments based on the corresponding parameter names instead, don't try to write them if there isn't an argument, and write optional parameters into the new constructor if the original method parameters with optional.

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

Change-Id: Id000c122535f85daed0437d3bc271db9d6e818ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453704
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-10 11:17:38 -07:00
FMorschel bf2fc7d8e5 [DAS] Fixes part file handling for some create fixes
Bug: https://github.com/dart-lang/sdk/issues/61192
Change-Id: I8aa765fca2d2948ab6fe1b47a6bff6bf58de3cd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447341
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-08 11:40:11 -07:00
Sam Rawlins 793aeaee01 DAS protocol: Update comments to use markdown codeblocks
One can see that we have bare HTML in these signature-in-comments,
like:

  "contextMessages": optional List<DiagnosticMessage>

These are flagged by the unintended_html_in_doc_comment lint rule.

This CL solves this by indenting these signatures 4 spaces, making
them Markdown indented code blocks. Alternatively we could use
backticks. Backticks would make the comments taller; indenting makes
them wider. I would prioritize whichever style is less intrusive when
reading them in plain text, which I think would be to use
indentation.

Change-Id: I019d9073e994a505325194ceeac3c6e0635d947e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453642
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-08 09:16:20 -07:00
Brian Wilkerson e2d0d10f24 Rename the rest of the DartFixKind constants
Appologies for the size of the CL. The only changes are renames and the
deletion of a couple of blank lines.

Change-Id: Id1ed85bc9d96b6e06faac3f6c6912bfe86f60283
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453840
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-10-07 11:35:52 -07:00
Danny Tuppeny 25f86fe0ff [analysis_server] Fix syntax highlighting for a function's "call" method
+ some additional Hover tweaks

See https://github.com/dart-lang/sdk/issues/61319

Change-Id: Ia1ab56ed4f186a820ce1b36402e1c7042ed23068
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449802
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-07 11:09:38 -07:00
Sam Rawlins cff98f605b DAS: Tidy the code around watch events / plugins in the server
* Rename `PluginSession.interestingFiles` to `.interestingFileGlobs`.
  This confused me for a bit, though the doc comment is accurate.
* `PluginManager.broadcastWatchEvent` was needlessly async and
  needlessly returned a Future. It can just return the List of Futures.
* In addition, the implementation of this method is made simpler; the
  previous very long if-condition is broken into a series of
  `if (foo) continue` statements, which allows for nice promotion and
  allows the large comment to sit next to the condition to which it is
  referring.

Change-Id: I77e8f7476b38d21f4c1a991045333d1e19a54143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452200
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-07 09:08:54 -07:00
Danny Tuppeny aeb3a5884d Introduce variables for non-simple parameters when inlining methods
When inlining a method call, if a parameter is using multiple times then (except in the case of variables) we should capture the argument value in a variable to avoid potential side-effects (or worsened performance) of evaluating the expression multiple times.

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

Change-Id: Icc52e478fd27cedfb68a032af19cc58bb1444167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452780
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-06 14:39:09 -07:00
FMorschel 4d76a3cca0 [DAS] Fixes add digit separator false-positive
Fixes: https://github.com/dart-lang/sdk/issues/61639
Change-Id: I7d4a0eace646c790b7610a13be11d3ae9fdbc2af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452942
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-10-06 14:37:58 -07:00
Sam Rawlins 451e7ef7a6 DAS: Remove unused _MatchShadowedByLocal class
Change-Id: I4392b8ee583405f48aae15bc46c000e90b3938c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453105
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-06 08:32:21 -07:00
Konstantin Shcheglov 661d4a6aed Fine. Send analysis_statistics events to analytics.
Change-Id: Idd2350803bf20b2cc59cfe98a8053d235d1ae108
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453104
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-10-05 09:34:13 -07:00
Brian Wilkerson 477b4ca669 Start renaming the DartFixKind constants
The two typedefs are because those two fix kinds are used internally.

Change-Id: I4124bcb0c4def4339cefc4add47d4e309f3d9588
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453403
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-04 13:00:23 -07:00
FMorschel 64f28995b7 [analyzer] Adds new message for INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR
Fixes: https://github.com/dart-lang/sdk/issues/61680
Change-Id: I3f5e0e722125a05bcc0f7ff4f9f785c584b7d94b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453360
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-10-03 13:14:44 -07:00
Konstantin Shcheglov 602bd276d8 Issue 61676. Fix sorting by relevance in SuggestionCollector.
Bug: https://github.com/dart-lang/sdk/issues/61676
Change-Id: I713a664f4399bee9baa52a1f69b02483acc9f344
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-10-03 11:14:31 -07:00
Sam Rawlins 006751327d DAS plugins: properly throw and catch when a plugin cannot start
I noticed, when running `dart analyze`, that when `pub upgrade` could
not be run in a plugin directory, we would get the "An error occurred
while setting up ..." message (good), but then the plugin would still
be executed! And this message would get printed:

> An unexpected error was encountered by the Analysis Server.
> Please file an issue at https://github.com/dart-lang/sdk/issues/new/choose with the following details:
>
> Internal error: Issue stopping a plugin
> Bad state: Cannot stop a plugin that is not running.

The reason is that a PluginException was _only_ thrown, on line 560,
if the package config file was still _missing_. But in my case, the
plugin directory was pre-existing, from an earlier, successful run,
and so the package config file existed! So no exception was thrown,
and the server still attempted to run the plugin.

So this CL makes that whole situation much simpler, and in particular
removes the erroneous "An unexpected error was encountered by the
Analysis Server" message that we do not want to show to users, and an
extra stack trace.

Change-Id: I9be39d10b687e055392f9b81285c99cca4c57534
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-03 08:48:39 -07:00
Konstantin Shcheglov d952c3ec48 Fine. Add WITH_FINE_DEPENDENCIES flag to analytics.
Change-Id: I7fda6bc37a5bbc5021e31b12f9b190bd089c5753
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453180
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-03 08:20:00 -07:00
Konstantin Shcheglov 1dc08ea5eb Make AnalysisDriver.discoverAvailableFiles() synchronous.
Change-Id: Ida5ed3a8e464070075de48c22b156babe975c122
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452900
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-10-01 12:55:38 -07:00
Paul Berry 6924418203 [analyzer] Fix translation of Encoding errors.
Adds a translation of the scanner error code `Encoding` to the
`translateErrorToken` function. Previously, this error was unhandled,
so if the scanner encountered invalid unicode, the analyzer would
crash.

Change-Id: I6a6a696433016dddd2cbc0660922ea5248d54419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452901
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-01 11:42:31 -07:00
Danny Tuppeny 8a68f1ba02 [analysis_server] Allow await expressions when inlining methods
Fixes https://github.com/dart-lang/sdk/issues/59958

Change-Id: I570f4a4739401276c53fb526858475b20cd943d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452121
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-10-01 09:08:51 -07:00
Konstantin Shcheglov 9c84348646 Fine. Increase fileCacheSize in DAS to 4 GB.
In my tests with fine-grained dependencies the on-disk cache size
after analyzer/ + friends, and Flutter repository is at or a litlle
over the upper about 1 GB + 12%, which causes cache evictions, so when
I switch between these two sets, I saw analysis without changes.

Change-Id: Ief3344746177388b9e8a83df1474cc6f9aa821d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452481
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-09-30 10:14:39 -07:00
Konstantin Shcheglov 0e9e3597e6 Fine. Increase memoryCacheSize in DAS to 256 MB.
With fine-grained dependencies aggressively unloading deserialized
objects from memory, and probing cache for previous blobs, it becomes
necessary to have access to these blobs without hitting the file system.
This new size is enough to keep the Flutter repository fast.

Change-Id: Ief507cddc6da3493896db3fedd9f0938c7ccd030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452225
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-09-30 09:07:03 -07:00
Danny Tuppeny 2585deee0a [analysis_server] Remove non-null assertion in TypeHierarchy
Fixes https://github.com/dart-lang/sdk/issues/61420

Change-Id: I1d9863a1e42c7d80ab742d3cc9648b281fba56a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-09-29 12:47:00 -07:00
Paul Berry 9a6fc48d51 [linter/analyzer_public_api] Report experimental inconsistencies.
Modifies the `analyzer_public_api` lint so that it reports
`analyzer_public_api_experimental_inconsistency` if an element in the
analyzer public API that is _not_ marked experimental has a type that
refers to an element in the analyzer public API that _is_ marked
experimental.

Such references are problematic because they can cause a client of the
analyzer public API to make use of an experimental type without
receiving a warning.

Change-Id: I6a6a6964fd5f1d37e163dc27a1cb4e605efd2d76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451550
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-09-29 11:06:59 -07:00
FMorschel 421a9683a4 [DAS] Fixes Add missing Switch cases not importing src libraries
Fixes: https://github.com/dart-lang/sdk/issues/60531
Change-Id: I6ca063aeaad2b6ce994c8637da653561231b1fdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451340
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-09-26 12:41:09 -07:00
Sigurd Meldgaard 82ce96ca3a New lint: RemoveDeprecationsInBreakingVersion
Helps reminding to remove deprecated members in a timely fashion.

Might not be universally applicable, still it could probably provide value to
many projects.

Bug: https://github.com/dart-lang/pub/issues/2914
Change-Id: I7356a2ca3372e786897d0fea475c9b134d212505
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2025-09-26 06:48:27 -07:00
FMorschel 443e8ccb42 [DAS] Fixes multiple commas by Add missing required arguments
This also refactors the correction producer so that it is a bit easier to read and maintain.

Fixes: https://github.com/dart-lang/sdk/issues/61531
Change-Id: I54656f3e917764881bc4817f7b9692bb9fd973b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450360
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <git@fmorschel.dev>
2025-09-25 15:18:54 -07:00
Brian Wilkerson 7a372bb21f Remove support for diagnostics related to the required annotation
The annotation has been marked as deprecated for a long time now, and
the annotation hasn't been useful since 2.12.

Change-Id: Ia3bb019ef3fc6b1f9bb406cb268dcc6b78bf1159
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451403
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-09-24 17:53:11 -07:00