Commit Graph

8505 Commits

Author SHA1 Message Date
Konstantin Shcheglov b5b4cf872f Move more AnalysisDriver tests to DriverEventCollector.
Change-Id: I52715322580c36090104f295276cd071733d6e6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344945
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-08 17:38:39 +00:00
Samuel Rawlins aa6b6470e3 Revert "analyzer: Do not overwrite an original exception when a plugin crashes"
This reverts commit 7784cf3f94.

Reason for revert: broke windows bot

Original change's description:
> analyzer: Do not overwrite an original exception when a plugin crashes
>
> Maybe related to https://github.com/dart-lang/sdk/issues/38629. These tests have been skipped for so long, enabling them took some work, to migrate them from '.packages' files to package config files.
>
> Some other tidying in the test file:
>
> * inline `byteStorePath`, only used once.
> * simplify `_packagesFileContent` and `_getPackagesFileContent`
>   into a static getter.
> * simplify `_defaultPluginContent` into a const String, so it can
>   be used as a function parameter default value
>
> The diff is way bigger than the functional changes, because we sort
> elements.
>
> Change-Id: I193316316750e80268b684fdc1abe558a77994fe
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344601
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

Change-Id: Ibeb761afebad4fb4166cec756743dbb35d323e7d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345143
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-05 23:49:57 +00:00
Sam Rawlins 7784cf3f94 analyzer: Do not overwrite an original exception when a plugin crashes
Maybe related to https://github.com/dart-lang/sdk/issues/38629. These tests have been skipped for so long, enabling them took some work, to migrate them from '.packages' files to package config files.

Some other tidying in the test file:

* inline `byteStorePath`, only used once.
* simplify `_packagesFileContent` and `_getPackagesFileContent`
  into a static getter.
* simplify `_defaultPluginContent` into a const String, so it can
  be used as a function parameter default value

The diff is way bigger than the functional changes, because we sort
elements.

Change-Id: I193316316750e80268b684fdc1abe558a77994fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344601
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-01-05 00:27:30 +00:00
Danny Tuppeny 9e1dbb8be2 [analysis_server] Remove duplicate declaration tracking from LSP server
This code appears redundant. It was adding contexts to the declarations tracker as contexts changed, but this was also being done once at the end (in the method "addContextsToDeclarationsTracker" mentioned in the comment).

Apparently at some point I added a TODO suspecting this was unnecessary but didn't realise the performance implications of it on a large project.

There are existing tests that ensure the declarations are tracked correctly (although we don't use them for completions, they're still used to resolve macros in dartdocs).

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

Change-Id: Ibdb7d00c288e78fc44c48a4f9febff688e2db323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-01-04 17:51:58 +00:00
Konstantin Shcheglov 278f386c12 Rename AnalysisDriver.getResult() to getResolvedUnit()
Change-Id: I3262713dbc9736b7c4c6af9fbbc0b57d7f53d4d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-04 17:07:58 +00:00
pq a43ebbffd0 rename resolve2 to resolve
Not sure if there's a good reason to keep this as `resolve2` since there's no simpler `resolve` to be found. If there is, please let me know and I can revert this and add a doc to `resolve2` for clarification.


Change-Id: I67c3825e9db95ec3f3c618f08664ed655394c041
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-01-03 22:03:47 +00:00
Sam Rawlins cc8cc05819 analyzer: Improve text in diag pages: word-breaking, title-case, table
When looking at the Plugins page, I noticed it was not as friendly as the others.

"not running" text before: https://screenshot.googleplex.com/9Z2eMFSvVjKBjRv.png

Poor text wrapping before: https://screenshot.googleplex.com/BUaTxYxJ5W5yQti.png

Improved "Not running" text with better wrapping: https://screenshot.googleplex.com/69zoPfbGjYkeHD2.png

Improved path text, aligned as a table: https://screenshot.googleplex.com/6yKfbQo8BE7LHmp.png

Change-Id: I4a4cee23a93bf3c2f16d504a7b11cb9f29c7333c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344602
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-01-03 21:59:49 +00:00
Konstantin Shcheglov 8898abbc7e Issue 54485. Report error when external constructor has a field formal parameter.
Bug: https://github.com/dart-lang/sdk/issues/54485
Change-Id: Id2cec10b1c8bdb7bba5d608f28a3b55b8f4146ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344180
Reviewed-by: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-01-03 19:59:53 +00:00
Sam Rawlins 3da0eaf1bd analyzer: Remove strictInference field from abstract correction producer
The `strictInference` field on GenericInferrer is only used to report
additional warnings. We do not want to report additional warnings
while calculating applicable extensions in correction producers.

Change-Id: I19ebaa7928b9ff631374b1f17bd1b5ca42037388
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344220
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2024-01-02 18:25:53 +00:00
Ilya Yanok d1717197ec Revert "analyzer: Remove unnecessary FixContributor and DartFixContributor classes"
This reverts commit c69f4321e6.

Reason for revert: `DartFixContributor` is used by Dart LSC tool, see b/318016861

Original change's description:
> analyzer: Remove unnecessary FixContributor and DartFixContributor classes
>
> I'm not sure what purpose they used to have or why they
> "are long-lived". But today they only serve as unnecessary object
> allocations.
>
> Change-Id: Icf73ddd42f540ae956dfeeb676de2f04bfca39d5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343240
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

Change-Id: Ic71e337399e263b899b0ffcbe388986d6011f6f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344000
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-12-29 09:47:08 +00:00
Sam Rawlins c69f4321e6 analyzer: Remove unnecessary FixContributor and DartFixContributor classes
I'm not sure what purpose they used to have or why they
"are long-lived". But today they only serve as unnecessary object
allocations.

Change-Id: Icf73ddd42f540ae956dfeeb676de2f04bfca39d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-27 23:48:32 +00:00
Konstantin Shcheglov 40dfd1befe Report HighlightRegionType.IMPORT_PREFIX for import prefix in NamedType.
Change-Id: I05ce7fb0010dafe69c6b5926a368350a3486332e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343541
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-25 20:29:03 +00:00
Brian Wilkerson 3e09072221 [code completion] Integrate RedirectingComputer into the new code path
Change-Id: Ic8cd8bf338e6561e9f2bd9bf4ce464ea554a6ec4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343340
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-22 00:37:15 +00:00
Konstantin Shcheglov 7a4d85ecd1 Don't consider type names used with import prefixes as shadowed by local.
Change-Id: I9e1fad5effa5bb598c01a3acce49b84b1176bea6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342727
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-20 18:04:09 +00:00
Keerti Parthasarathy 1a11cfd12a Remove just the declaration for unused variable for method invocations.
fixes https://github.com/dart-lang/sdk/issues/53820

Change-Id: I38d99c6f3afcbba609d150291f1dc0ad79f8c6b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342725
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-19 23:03:27 +00:00
Brian Wilkerson bf22c59509 [code complpletion] Convert argument list suggestion generation
Change-Id: I88fb8e3ce89b4ce0b5698e4436814ac4524767ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342701
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-19 21:54:18 +00:00
Parker Lougheed f49c786443 [cfe/analyzer] Report error on invalid abstract final class modifier combinations
Fixes https://github.com/dart-lang/sdk/issues/54143

Bug: https://github.com/dart-lang/sdk/issues/54143
Change-Id: I5710a8524dfea94b8e42595c8907b1ebf738405c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-19 08:35:33 +00:00
Keerti Parthasarathy 3e73f10de0 Disable fixes for unawaited_futures in cascades.
Fixes https://github.com/dart-lang/sdk/issues/54105.

Change-Id: Ibf69c9c52d7d514d709ebc43a8d9a2d363e85e55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342382
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-18 21:19:48 +00:00
Keerti Parthasarathy 95e049c7e2 Add a test case for #52233
Bug:
Change-Id: I1d98420ce20ec6d52baef5683ae1ab83b21066e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342103
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-18 18:30:01 +00:00
Parker Lougheed 691ae80cd5 [analysis_server] Allow rethrow partial completion in catch clause
Fixes https://github.com/dart-lang/sdk/issues/54384

Bug: https://github.com/dart-lang/sdk/issues/54384
Change-Id: Id86f0e1b71d27921054e11f2fcbb8bb952f8161e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-18 17:20:27 +00:00
pq 40e5e46a54 migrate strict{Casts,Inference} from typeSystem
Another angle on removing tracking of `strictCasts` and `strictInference` from the type system, this time threading these configuration values individually to the functions that need them. (In contrast to the solution in https://dart-review.googlesource.com/c/sdk/+/341326).

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

Change-Id: I63d73fd81401ac03121831af5e8d4ca43200bb7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341336
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 19:45:09 +00:00
Brian Wilkerson ae15831811 [code completion] Move completion generation for initializing and super parameters
Change-Id: Ie9d09b323c7072c4fe375b6de12347a16065ac5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341823
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 17:41:32 +00:00
Sam Rawlins 07bba0a7d2 analyzer: Make new filesWithClientDiagnostics field private
Change-Id: I5ff762c54434fb81425275ef002b4186ceedc1dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341801
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-12-15 17:20:08 +00:00
Simon Binder 150e61a662 [vm/ffi] Support @Native fields
Allow annotating top-level or static fields with `@Native` to create
fields backed by native memory.
By using the `_addressOf` operator implemented in the VM, these fields
can be implemented in the CFE by replacing them with accessors looking
up the pointer and then using existing methods to load and store the
value.

Closes https://github.com/dart-lang/sdk/issues/50551

TEST=tests/ffi/native_assets/asset_*_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

CoreLibraryReviewExempt: VM & dart2wasm only feature
Change-Id: I61dccc88076723d6a6ba02d7fd848b18e4caf780
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338020
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-12-15 11:20:23 +00:00
Johnni Winther 8ca0aa23ea [cfe] Report error on covariant in extension type methods
Closes #53324

Change-Id: Iff86c4eb7c141f27c64de29459390ac395e1c4ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341487
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-15 09:13:07 +00:00
Sam Rawlins aad9e57674 Revert "Revert "[analyzer] new warning for nullable '==' parameter type""
This reverts commit 885457e1d3.

[analyzer] new warning for nullable '==' parameter type

This rule checks that a parameter to an `operator ==` implementation has
a non-nullable type.

I intentionally did not enforce, in this rule, that the parameter is
exactly `Object`. It is legal to narrow the parameter type to a
different non-nullable type, like `int`. I can't imagine doing it, but
it seems to be unrelated to whether the type should be nullable or not.

Fixes https://github.com/dart-lang/linter/issues/3441

Replaces https://github.com/dart-lang/linter/pull/3923

Change-Id: Ic0be2bfebaf59b0336e9a3a58e5b7f5359eb8646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-14 23:58:12 +00:00
Brian Wilkerson 441072ba57 [code completion] Convert CombinatorContributor
Change-Id: I3d3b0239c744a417455c45aca88fcc67fb121ccf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341392
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-14 16:00:33 +00:00
Keerti Parthasarathy 6c09ade242 Add a test for flutter use case: renaming enum value
https://github.com/dart-lang/sdk/issues/54188

Change-Id: I3c436a4055f0d99c9c7a00e852e16a798f14aeba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341389
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-13 18:32:28 +00:00
Brian Wilkerson 7a3df2c801 Move the last of the local reference contributor to the first pass
Change-Id: Ib345a5facef37e2d9d9fc8494b8df116d36c23f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341332
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-13 18:01:03 +00:00
pq f3be94a9ca deprecate singelton analysisOptions getter
Change-Id: I2c1e93ef16862b8f5cbe1fe69fd30947cc0a784a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341323
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-12 19:27:18 +00:00
pq 60c640fe4d fix accidental var introductions
Follow-up from https://dart-review.googlesource.com/c/sdk/+/341084 where I accidentally went w/ a `var` style despite surrounding use of `final`.

Change-Id: I60202b032ee867989f876b8746effe83ec202bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341104
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 03:45:47 +00:00
Sam Rawlins a2151474a5 linter: UBCS: require checking the correct 'mounted' property
Fixes https://github.com/dart-lang/linter/issues/4777

Change-Id: I0c50ab1a04b8f9c704a0cf787fcf414688cd61a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330561
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-12 01:34:11 +00:00
Brian Wilkerson d45080d365 Remove support for the older legacy completion protocol
This does not remove the computation of available declarations. This CL
seemed big enough without that, so I (or someone else) can get that in
the next CL.

Change-Id: I67ab49b75c8a415ccfaef16c4e49a00026a6091f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-12 00:54:48 +00:00
pq 12598e6b0f deprecate analysis options sdkVersionConstraint getter
Noteworthy:

* deprecates the `sdkVersionConstraint` getter and updates uses
* migrates tests for sdk contstraints in the absence of a pubspec from context_builder_test to analysis_context_collection_test
* makes `pubPackages` getter broadly visible

Next step: remove the code that sets the `sdkVersionConstraint` in the analysis options object and remove the getter.


Change-Id: I443cdd15ec8d28ac6fa6786e06c1e4b027eee747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341084
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-12-12 00:20:50 +00:00
Daco Harkes 40094c8cfd [vm/ffi] Unwrap typed data in FFI calls
Enables passing inner pointers to typed data in FFI leaf calls.

This works for typed data's in the Dart heap, external typed datas
(constructed from `Pointer.asTypedList`), and typed data views.

Notable implementation details:
1. The Dart signature is used in the Marshaller now. This means it
   needs to keep track of whether there's a pointer argument in the
   signature (`asFunction`) or not (`@Native`).
2. Unwrapping is done in `FfiCallInstr::EmitNativeCode` before moving
   the arguments to their native location. This ensures we can use
   the assembler logic to load the `TypedDataBase::data` field.
3. The `XXXList` user visible classes don't have predefined cids.
   So the implementation uses symbols for comparison.
4. The type checking logic takes `isLeaf` as input to reject typed
   data. This leads to an error message about the type not accepted.
   Alternatively, we could consider adding an error message that
   specifically says the function should be leaf.
5. To cover all calling convention variants, tests are generated with
   up to 20 arguments.

TEST=pkg/analyzer/test/src/diagnostics/ffi_unwrap_typed_data_test.dart
TEST=tests/ffi/unwrap_typeddata_generated_native_test.dart
TEST=tests/ffi/unwrap_typeddata_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_typeddata_test.dart

Closes: https://github.com/dart-lang/sdk/issues/44589
Change-Id: Ia78f18bf3238d42ac6882929b441f6dc432fcefe
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338620
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-12 00:05:02 +00:00
Danny Tuppeny 367b8fdc16 [analysis_server] Add inlay hints for for-in and for elements
Fixes https://github.com/Dart-Code/Dart-Code/issues/4891

Change-Id: I788008bca06f98b4308c897d41b2dc034579c6a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-12-11 22:48:27 +00:00
Konstantin Shcheglov 4d7938dfc2 Fix CONVERT_TO_SWITCH_STATEMENT for 'is NotInterfaceType'.
Change-Id: Ic5308541f279e5f23d8e90bee095bf8aa8aec3e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341083
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-11 21:46:13 +00:00
Ahmed Ashour d9962e5053 [analyzer] UNNECESSARY_SET_LITERAL to handle multiple expressions
Bug: https://github.com/dart-lang/sdk/issues/50900
Change-Id: Id09e102c2cc12c9043d3f6c22b3af3babf18920e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284021
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2023-12-11 21:24:59 +00:00
Brian Wilkerson 14a836f6f6 Move the generation of imported elements to the in-scope completion pass
Sorry for the long CL; once again I couldn't find a reasonable way to
split it up into smaller pieces.

This CL causes all of the elements from imports to be generated by the
new approach.

It does contain a new flag that is used to preserve the current
semantics when computing completions for Cider. I hope to be able to
make the new approach efficient enough that we can remove this flag,
but I can't realistically do that until more of the approach is
implemented.

I'm also not fond of the way it fails to handle conflicts in the import
scope. There's a TODO marking the places that would need to be changed,
but the current behavior is that if the same name N is imported from
two or more imports and they refer to different elements, the first one
found will be suggested and others won't. I don't think we want to
suggest any of them unless we also fix the imports so that the name
won't be conflicting. I'm not sure how we want to do that, but it needs
to work with whatever optimization approach we choose.

I think the changes to the tests are all positive, but please double
check that I haven't missed a good reason for the previous behavior.

Change-Id: I70d4514a67988f654984ac20f33b2d7a3cfc78e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340282
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2023-12-08 22:17:38 +00:00
Brian Wilkerson 9b26f56309 Register a deprecated lint
Change-Id: Ic42c145df751386134caf4067e537198f8631056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340582
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-08 19:28:22 +00:00
Brian Wilkerson a155e2b521 Remove the avoid_unstable_final_fields lint
Change-Id: I6835df32fc6c0d9a5f17b3b5344353ec061147d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340386
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-08 15:50:09 +00:00
Oleh Prypin 3f299c9174 Handle more cases in convert_to_null_aware fixer
This is done mainly by copying significant parts of the code from the prefer_null_aware_operators lint itself

Change-Id: I13fb7f52ee003924fd5e2f336cfde2bac6b6011a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2023-12-07 21:56:54 +00:00
Sam Rawlins eeb3ecb599 analyzer: Convert Flutter (utilities) into a static class.
This was a utility class with absolutely zero state. It almost protected
against unnecessary instantiation by providing a static `instance`
member, but the constructor was still public. Also, the instance was
passed around various objects as an instance field, even allowing for
the static instance to be nullable in a few cases. All of this can be
prevented by making the class `abstract final`, with all of its members
static.

(An argument can be made that all of the code in here could be made
top-level functions, but I'll leave that for a later refactoring, if it
is desired. Also the functions could be made into extension methods, but
many of them rely on promotion of a parameter, so until we get `this`
promotion in extensions, I won't advocate for that change.)

The main reason I was looking at this was to get Flutter out of `_AbstractCorrectionProducer`, so that we don't have to drag the flutter utils into analyzer_plugin (we still can if we want to, but we won't _have_ to).

I also modernized the code, following Effective Dart:

* https://dart.dev/effective-dart/documentation#do-start-doc-comments-with-a-single-sentence-summary
* https://dart.dev/effective-dart/documentation#do-separate-the-first-sentence-of-a-doc-comment-into-its-own-paragraph
* https://dart.dev/effective-dart/documentation#prefer-starting-function-or-method-comments-with-third-person-verbs
* https://dart.dev/effective-dart/documentation#prefer-starting-a-boolean-variable-or-property-comment-with-whether-followed-by-a-noun-or-gerund-phrase

Change-Id: I0d1896ae2d45a31e00f8a824e92d173469cc7eea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-07 02:03:26 +00:00
Danny Tuppeny 315d0b7fa7 [analysis_server] Prevent LSP formatting from adding \r to files formatted with \n if a previous file was formatted with \r\n
Caching the formatter (something we recently discussed removing) was causing issues if you formatted multiple files with different line endings.

It might be a VS Code bug that "\r\n" is being rendered with a blank line in between when the document was in LF mode, but I'll investigate that separately and file an issue there if required.

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

Change-Id: Ib5ec5355f078bc8dd2b30440fd253663727a2b66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-07 00:21:31 +00:00
Keerti Parthasarathy 30c5a535fb Add tests for dart:io migration
Change-Id: I901c8289e033d1bf83102b9fabaf7298cf34ff29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340304
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-06 23:51:31 +00:00
Sam Rawlins 6d909e51f5 analyzer: Remove the (unused) notion of data_driven transform overrides
Change-Id: If265b50226815fa835a85fc1cb64b4931b764b1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-06 23:42:21 +00:00
pq a354347178 Add PubWorkspacePackage.sdkVersionConstraint.
See: https://github.com/dart-lang/sdk/issues/54043.

In a follow-up, we'll:

* deprecate `AnalysisOptions.sdkVersionConstraint` and
* update all callers to use `PubWorkspacePackage`

Change-Id: Ie24861d50168de79e6a6db511887aea5148987f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340021
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-06 20:41:13 +00:00
Danny Tuppeny 23e1437f6a [analysis_server] Update generated code to match latest spec
This should have been a small change to keep us in-sync with small changes so when there are bigger changes (LSP 3.18.0) the change is less noisy.

However, it turns out the meta model is built from the latest version always, so it includes 3.18.0 proposed features.

So this change not only regenerates the code with the latest spec, it also adds some handling to exclude any types (and methods) marked as proposed.

It also includes a few minor fixes to things like re-wrapping of comments where there are references.

So, it should still essentially be a non-functional change, but the CL isn't as small as planned because of the cleanup.

- The lsp_meta_model.json file is downloaded and not changes I've made
- The protocol_generated.dart file is the output of the code-gen
- All other files are changes I made manually

Change-Id: I6380f86848d2799cf94d58a419ace0bf0d5a35ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-05 19:58:47 +00:00
Simon Binder a44a524bb0 [vm/ffi]: Add Native.addressOf
This adds the `Native.addressOf` function, which takes a constant tear-
off of a method annotated with `@Native` as a parameter and returns a
pointer to the underlying C function.

The CFE will resolve these calls in two steps: First, the existing
transformer for `@Native` methods adds a pragma describing the fully-
resolved native annotation (with the asset id inferred from the library
if not given explicitly). Then, the FFI use sites transformer rewrites
calls to `Native.addressOf` by searching for this pragma on the passed
function and passing the `Native` constants to `Native._addressOf`. The
latter method is implemented in the VM, which can re-use existing parts
already used for `@Native` calls.
An alternative implementation strategy would have been to forward
`addressOf` calls to `Native.ffi_resolver_function` directly without
any special consideration in the VM. However, the chosen approach makes
it easier to support static linking in the future, as this requires
unresolved symbols in the generated assembly.

Closes https://github.com/dart-lang/sdk/issues/50552

TEST=pkg/vm/testcases/transformations/ffi/ffinative.dart
TEST=tests/ffi/native_assets/asset_*_test.dart
TEST=tests/ffi/vmspecific_static_checks_ffinative_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-kernel-precomp-linux-release-x64-try
CoreLibraryReviewExempt: VM & dart2wasm only feature
Change-Id: Ic8e3a390146dffd44c95578f975a4472db79a0ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333920
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-05 13:10:36 +00:00
Sam Rawlins 3b648e4635 analyzer: Support more complex flutter assets declarations
Fixes https://github.com/dart-lang/sdk/issues/54038

The main feature is a small expansion to what is allowed in the `flutter / assets` field. We used to enforce that the `assets` field is a list, and that each value is a string. Now we enforce that:

* the `assets` field is a list
* an asset is either a string, or
* an asset is a map, with at least a 'path' key, with a string value.

This requires deprecating the `ASSET_NOT_STRING` code, and introducing
three others:

* ASSET_MISSING_PATH
* ASSET_NOT_STRING_OR_MAP
* ASSET_PATH_NOT_STRING

In addition I cleaned up a UX issue: Several codes referenced an 'asset' key, but it should be 'assets'. (In addition, the `ASSET_FIELD_NOT_LIST` code should be `ASSETS_FIELD_NOT_LIST` but I did not fix that.)

I also refactored all of the code to be more modern:

* Use `var` instead of types in declarations
* Short circuit error-and-return with `if (foo is! YamlMap)`. We didn't use to have promotion here, but this led to a wild amount of nesting (if, if, for, if, if, else, if!).

Change-Id: Ia489ea631f7d1027fdb84a9a682c831752c5835c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338593
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-04 21:10:31 +00:00