Commit Graph

8487 Commits

Author SHA1 Message Date
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
Danny Tuppeny b1620d1ba0 [analyzer] Drop return type from element display for setters
Change-Id: Id580f2c5796b3024b127464ffffdb420511a5632
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339540
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-04 06:16:26 +00:00
Konstantin Shcheglov 0bc9815ad0 Migrate all 'fileSystem_' tests of analysis domain to assertNotificationsText.
Change-Id: If6dd1553e2a0bbc9fbe8f42740c1c0f0fef13c1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339232
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-03 17:42:05 +00:00
Danny Tuppeny 51d46fd27b Update watcher and remove related failingTest() annotation
This updates the watcher package to include a fix for the `ready` Future not completing for non-existent folders on Windows:

https://github.com/dart-lang/watcher/pull/157

This fixes a bug where the analyzer would wait indefinitely during initialisation if the workspace contained a folder that did not existing on disk (such as if you have a .code-workspace containing folders and one was subsequently deleted).

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

Change-Id: If283403681080477e497fe7e17f2faa217a5a643
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-02 16:42:01 +00:00
Konstantin Shcheglov 60e8519402 Rewrite test_fileSystem_changeFile_buildFile_legacy
Change-Id: Idb764aa7b2aa36a9191e10d68cb6a2351f986d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339343
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-01 23:27:30 +00:00
Konstantin Shcheglov fba1416943 Macro. Report diagnostics during resolution.
Change-Id: I23095ad18f7289c1df3463c0d835f76976e09118
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339223
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-01 23:01:48 +00:00
Keerti Parthasarathy 48fd851fad Remove unnecessary ignore comment
Change-Id: I34f2ef4244f3d665c361d15c7466201a413af6de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339226
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-01 19:51:20 +00:00
Keerti Parthasarathy 9cf01a3bee Reland changes to PubWorkspace support for multiple packages
- reworked logic for `findPackageFor` to be more cognizant of generated paths and indices.
- added more test cases for `findPackageFor`.

Change-Id: Ic8b123c8156921574873737b57415465dbf8f53b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339042
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-01 15:43:29 +00:00
Konstantin Shcheglov ebf05be9b8 Macro. Add isMacroAugmentation to FileResult.
Change-Id: I5aa887212338bfc80a3f6cb15310f06ad1b2b48f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339107
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-30 21:30:23 +00:00
Brian Wilkerson 8b03d7e024 Fix a comment in code completion support
Change-Id: I3e87e8f3f78002d8b29cc32e92a0a052d84f414e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339202
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-30 19:02:30 +00:00
Brian Wilkerson 3ef27cc0fd Remove a missed piece of the test support for older legacy code completion support
Change-Id: I49a547ccfea531866a57da83691b21bcd7118b80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339203
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-30 18:40:38 +00:00
Brian Wilkerson 0915f6e053 Remove the tests related to the deprecated completion protocol
I left the mixin structure because Danny and I plan to use the same
structure to start adding LSP-specific test coverage.

Change-Id: I2eefc05c01eadb67f2c95fcaed3e5a963df7d69b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-11-30 05:27:39 +00:00
Konstantin Shcheglov b22025d5c3 Macro. Fix for 'add constructor', 'augment constructor' sequence.
Change-Id: If9a5a07cefc7dcd782db636ada2dfa02d7b26e4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339044
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-11-30 01:56:14 +00:00
Sam Rawlins 9de396953f analyzer: Track fixes in YAML files
This may seem to be a silly change, adding these lists only for the
error fix status file, but I claim this is a very pragmatic solution:

* It is important and beneficial to correctly track error fix
  statuses; I was recently confused about these fix statuses because
  the text in the fix status file was a lie.
* When fixes are added for more errors, you cannot forget to update
  the codesWithFixes list because the fix won't apply (and no test
  asserting the fix works would pass).
* Overhauling these FixGenerators to use maps like the others is maybe
  a good change in the long run, but at this point might be
  over-engineering; we only have fixes for 2-3 codes for each file
  type.

Change-Id: Iaa902acf2401f97ff722e222910f5d6fcd00a5ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-11-29 23:19:54 +00:00
Danny Tuppeny 7f9099e75a [analysis_server] Fix static type on hovers for non-synthetic getters/setters
Fixes https://github.com/Dart-Code/Dart-Code/issues/4863

Change-Id: Ie4272b77e81fcee282e22002a8cc3f58611af969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338821
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-11-29 23:18:09 +00:00
pq 6864496d2b Update EditFormatIfEnabledResult to anticipate multiple options in a contextRoot
I'm not crazy about the re-constitution of `File`s (see the TODO) but I'm not sure this is a yak we want to shave now (especially since this handler is not yet in use).

Larger context: https://github.com/dart-lang/sdk/issues/53876

Change-Id: I4b9814842525ed4440aa39a7d14baa75f526f72a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/339043
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-29 22:16:38 +00:00
Keerti Parthasarathy a7e402df46 Add more test cases to test pubspec fixes for missing dependencies.
- Use YamlNode to access spans and offsets instead of casting.
- Add logic to merge conflicting edits when removing multiple entries
from dev_dependencies.

Change-Id: I1f20b5a4691c37e9f56293acbaf870a489380b9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338592
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-11-29 19:34:49 +00:00
Daco Harkes 019efc9c65 [analyzer] Add dart:typed_data to mock sdk
Split off https://dart-review.googlesource.com/c/sdk/+/338620 which
starts testing FFI analyzer logic that uses Typed Data objects.

Change-Id: I65f98a0f0074b9eaedf7dd6fb0dee57532d41d71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-11-29 18:03:52 +00:00
pq 7d64b343c0 get enabled plugin names from the analysis driver
See discussion: https://discord.com/channels/608014603317936148/1171510601655275612/1179140354004492369

Change-Id: I3447f633e810bb3b4942142eeaa4a0e7504bec0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338646
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-11-28 23:51:29 +00:00