Commit Graph

2019 Commits

Author SHA1 Message Date
Parker Lougheed a409a1c07d [analyzer/linter] Use shared enumeration for lint names
This helps to avoid any accidental mispellings, enables find usages, and potentially makes future renames easier.

The primary goal is to make future work in https://github.com/dart-lang/sdk/issues/56835 easier.

Change-Id: I684630a4d6cb145031de0dabc221f247246ea00c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-03 21:36:49 +00:00
Konstantin Shcheglov 4fe2944776 Parts. Consider 'part' of 'part of lib.name' as an error.
Maybe? https://github.com/dart-lang/co19/issues/2907

Change-Id: If64ba74bf8d3ad3f5e1b926f19705ae469c76a5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387820
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-02 18:16:14 +00:00
Konstantin Shcheglov c58d9319be Completion. Issue 56783. Suggest non-assignable members when not in LHS of assignment.
Bug: https://github.com/dart-lang/sdk/issues/56783
Change-Id: I5e190bd0ebf59e5771d394eb5a72600d40a02a90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386683
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-27 17:55:31 +00:00
Sam Rawlins f84a81002c linter rules: tidy up test support
Just little things:

* Convert the class AnalysisOptionsFileConfig and it's `toContent`
  method into a single function.
* Convert the class PubspecYamlFileConfig and it's `toContent` method
  into a single function.
* Privatize ExpectedDiagnostic fields `diagnosticMatcher`, `offset`,
  `length`, `messageContains`,
  ExpectedError field `codes`,
  ExpectedLint field `lintName`,
  LintRuleTest field `collectionIncludedPaths`,
  _ContextResolutionTest field `sdkRoot`.
* Privatize `writeTestPackageAnalysisOptionsFile` and
  `writeTestPackagePubspecYamlFile`
* Start doc comments with a single-sentence summary (https://dart.dev/effective-dart/documentation#do-start-doc-comments-with-a-single-sentence-summary and https://dart.dev/effective-dart/documentation#do-separate-the-first-sentence-of-a-doc-comment-into-its-own-paragraph)
* Document with third-person verbs (https://dart.dev/effective-dart/documentation#prefer-starting-function-or-method-comments-with-third-person-verbs)

Change-Id: I7d584810cd339f8184fe14c3151b55988bf2cfff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-26 14:33:04 +00:00
pq ecbf9ee568 [enhanced-parts] test "Sort Members" in a part w/ imports
Fixes: https://github.com/dart-lang/sdk/issues/56684

Change-Id: I259090327e82926d1c01dae1ce11b328e3f2e7cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384309
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-10 16:57:11 +00:00
Danny Tuppeny 80057b98d2 [analysis_server] Take prefixes into account when determining the visibility of completions
A prefixed identifier like `a.Foo` should not hide a prefixed identifier like `b.Foo` not an unprefixed identifier (and vice-versa).

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

Change-Id: I8be8b3260f2a9f4333d38bba7ffe309cd3817932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383641
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-09-09 14:42:29 +00:00
Danny Tuppeny 803537682f [analysis_server] Provide LSP ClientCapabilities to LSP handlers reflecting the calling client instead of always the server
Prior to this change, all LSP handlers would ask the server for the client capabilities when they would affect their output. For callers over DTD, this could result in the same requests getting different results depending on the capabilities of the editor.

This change adds LspClientCapabilities to the MessageInfo that goes along with each message (usually a request) and then passes in the servers clientCapabilities for requests originating from the editor client, and a fixed set of capabilities for requests that come from DTD.

Most handlers will now use the callers capabilities, however there are a few handlers that build edits to send to the editor (instead of _returning_ the edits), which will use the editors capabilities.

This is essentially a no-op for now, because we're just providing the same capabilities via a different route - but when we come to supporting LSP handlers over DTD (that are affected by client capabilities), they will get consisted results based on our fixed set of capabilities (which as of yet is probably incomplete and may be updated a little as that progresses).

Change-Id: I5bcef8c3ebb7b94c83d85e56a303333d302abdee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-09-04 17:04:46 +00:00
Konstantin Shcheglov 2aa54ab42c Parts. Fix unnecessary_import before landing the reporting CL.
https://dart-review.googlesource.com/c/sdk/+/382901 will start
reporting it in more cases.

Change-Id: I3ae1d407f37a317f33cb98977b0e6eb08de75065
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383221
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-09-03 03:51:29 +00:00
Konstantin Shcheglov 8de1422a0e Parts. Deprecate Element.enclosingElement, use enclosingElement3.
Change-Id: Iadc4ed02d4bda3b882e65dc6f4d263a6a938e0fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382920
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-09-01 18:50:29 +00:00
Fedor Shcheglov a5cfca1b48 Issue 56572. Fix suggesting extension methods on record types.
Bug: https://github.com/dart-lang/sdk/issues/56572
Change-Id: I47e4b07270843ffb53ab90963e04f01b3b105043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382261
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-08-26 21:18:56 +00:00
pq 2df7d1a751 [wildcards] find reference tests
See: https://github.com/dart-lang/sdk/issues/55681

Change-Id: Ia1f8cc08d7a79fe66fce9ac108543cb2a6aebd34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381943
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-08-23 21:38:39 +00:00
pq 6413386f29 [wildcards] improve _ type param handling
See: https://github.com/dart-lang/sdk/issues/56361

Change-Id: Ic3be09014afc095490d9332bd124843b5a65e1cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381385
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-08-20 17:07:33 +00:00
Konstantin Shcheglov 4cea10fbf0 Parts. Report PART_OF_NAME when Feature.enhanced_parts is enabled.
Change-Id: I85925218b37a7cb65a7b50da6cc968155fd4789e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380043
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-08-12 20:11:06 +00:00
pq 4ec57e26b6 [wildcards] catch clause completion tests
See: https://github.com/dart-lang/sdk/issues/56361

Change-Id: I681e3b5ebfd2dcce3f377b8d45a492d44bf058a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378569
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-08-02 22:32:14 +00:00
pq 3b09a49ce5 [wildcards] ensure bound __ underscores are suggested in completions
See: https://github.com/dart-lang/sdk/issues/56361

Change-Id: Ia1b1a0fef17fb68f476d2ade96a0b5761152336b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378720
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-08-02 17:17:59 +00:00
pq 6b16fab819 [wildcards] completion suggestion support
See: https://github.com/dart-lang/sdk/issues/56361

To follow, a bunch of tests to make sure `__`, `___`, etc are not incorrectly getting special cased.

Change-Id: I3d35a5344e09011460c074fdd43eccdac452a8ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378623
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-08-02 14:51:14 +00:00
pq 60c0933f34 [wildcards] completion tests
See: https://github.com/dart-lang/sdk/issues/56361

Change-Id: Ib69a64b17a890c6cec0e1bddfd25f6fa7834b1cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378620
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-08-01 21:21:39 +00:00
Danny Tuppeny c18b84d6d2 [analysis_server] Fix handling of "Do not show again" on Dart fix prompt
A recent change to support in-editor "dart fix" changed the switch expression here in a way that the handling of "Do not show again" no longer matched and apparently this case had no test 😔

This fixes the check and adds the missing test.

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

Change-Id: I4fe182824a103d77b88e3a84d941f722f071f117
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377940
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-07-30 19:58:57 +00:00
Konstantin Shcheglov 9fefc36afa Parts. Use '@fragment' instead of '@unit', start compressing.
Change-Id: I9fd054d78c303fa1853bec9673f64deb620afd29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-07-30 17:19:29 +00:00
Konstantin Shcheglov 4475e6ca7a CQ. Use shared ByteStore for ContextResolutionTest (legacy).
Specifically this speeds up code completion tests.
Before: 4m40.792s
After:  3m16.520s

So, 84 seconds faster :-)

Change-Id: I75194ecf9a622c108ddb8913337b9137fd9edee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-07-23 23:34:11 +00:00
Danny Tuppeny 96a7c6ab24 [analysis_server] Fix context type for function expressions with implicit returns
Fixes https://github.com/Dart-Code/Dart-Code/issues/5162

Change-Id: I86148b3d847fc2a743307703390ff98c93b4c142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-07-10 14:46:49 +00:00
Brian Wilkerson 8b8a15059c Improve completion at the beginning of an index expression
This is almost identical to the fix for completing at the beginning of a
method invocation. There's probably a more consistent way to do this,
but I'm not sure what that is at the moment. (I think we used to do this
in `completionNode` but were skipping some nodes we shouldn't have been.)

Change-Id: I3f220e0e79a91721b0c1235fdfc0f511ee7400a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373902
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-07-02 16:32:40 +00:00
Keerti Parthasarathy 9f27bdeaf6 Use completionLocation from SuggestionCollector when computing relevance
Change-Id: I2446b8596ce35f53f6370b3a3590e7fd2a2b4974
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373767
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-07-01 16:51:27 +00:00
Brian Wilkerson 29d2913e2d Code complete before a method invocation
While the completion scenario is valid, it's probably an unlikely case.
I discovered the issue because it's one of the cases that was frequently
reporting failures in the completion metrics tool. With this change,
the failure count is now down to 249 (1.96% of attempted completions).

Change-Id: I1c9104352c14eb758040e3e0e3a2d2fafc4f909d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373780
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-07-01 14:44:56 +00:00
Keerti Parthasarathy ee5881bd58 Suggest static members when visiting contructor name.
Fixes https://github.com/dart-lang/sdk/issues/56056.

Change-Id: I97cded39b83f70305a9ceec8af7b1f07b63e43de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-06-25 18:48:55 +00:00
Brian Wilkerson e159bfee64 Improve the computation of the completion prefix
There are a couple of tests where the new code fails to produce a
prefix, but in those cases the prefixes are `""` and `{`, which are
not useful for filtering (and wrong for replacing). The new code does,
however, now find prefixes that the old code missed, which improves the
filtering. The changes to the tests reflect the improved filtering.

Change-Id: I3d48162ee56de1b94ecb3a88d11e8a2167fb8f2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372860
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-24 16:04:53 +00:00
Danny Tuppeny a42ae0c906 [analysis_server] Include types in closure completions when always_specify_types is enabled
Fixes https://github.com/Dart-Code/Dart-Code/issues/5149

Change-Id: Ic212e13d9fe90b4c728f92ecdf8fd5ca519047ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372426
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-21 20:43:37 +00:00
Brian Wilkerson 1e5f96514c Remove type cast in completion to prevent exception
Change-Id: If97adc54523894a3b9df241ffb0308ee1299d03d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372020
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-18 14:14:19 +00:00
Keerti Parthasarathy 627cd3047d Hide nonVirtual elements in override completions.
Fixes https://github.com/dart-lang/sdk/issues/55628

Change-Id: I70dcf5b47dae2faef30a47a4e3f811e735a1eeec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371742
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-06-14 23:45:19 +00:00
Brian Wilkerson 80ba2a9524 Produce completion locations where previously produced
There are many places where the code is producing a different location
than OpType is, but those can be handled is a separate CL.

Change-Id: Idea7529a3e64ddb25a9b15bb68f7537abd3d19e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371202
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-13 16:44:48 +00:00
Brian Wilkerson aa3f144f1c Remove unnecessary code from some tests
Change-Id: If3ab5e836a1977ab1089cdefdeb661d8992543ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371183
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-13 16:06:09 +00:00
Brian Wilkerson 2c97c6949e Include an empty body when suggesting a name for a top-level declaration that does not have a body
Change-Id: I92875fdb80b0541eaa5505b507e822915181ee52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370980
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-12 00:26:59 +00:00
Sam Rawlins 500a8c0a72 linter: Make some allowances in avoid_catches_without_on_clauses
Fixes https://github.com/dart-lang/linter/issues/3023

This fix is a little unusually large because I have to add some
elements to both the mock flutter package, and the mock SDK. This
affects some completion tests.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I44b68754f756cfe1cf99518957d74c4af56043f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-28 18:36:58 +00:00
Sam Rawlins cf7a697aa5 DAS: Run the shadowing test
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Ie7ab482018ecc6c74ac8fd9f3bb533f33ed3bd62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368240
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-25 05:31:18 +00:00
Brian Wilkerson 9c20217638 Compute locations for more completions
There are more places where a completionLocation isn't being correctly
produced by the in-scope pass, but this moves us closer to the goal.

Change-Id: I4aef61358d410f44dee2d48131bbf1fa605518e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366967
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-05-17 22:12:39 +00:00
Konstantin Shcheglov 017bed7b9a CQ. Enable unnecessary_final in analysis_server/
Change-Id: Ieb62a1c774a5e8f5a22deaa8e8e5fff6f9f849dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366960
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-05-16 21:20:28 +00:00
Devenik7 c37ccccae4 Fixed _writeSuperMemberInvocation in DartEditBuilderImpl to properly suggest completions when super member has named parameters
Closes https://github.com/dart-lang/sdk/pull/55697

GitOrigin-RevId: 8a43d8595921a271eb54e7c8aa9966fe559e1fd4
Change-Id: I393b17fc26eda821615f2d2d29cb386ab5f98406
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-05-14 16:01:33 +00:00
Brian Wilkerson 5af5089262 Convert the not-yet-imported contributor
There's plenty of clean-up that can still be done, but this puts us in a
place where it's now possible.

Change-Id: If9d6c4052108aef74a2dea20fb18e0279a3e830c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366021
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-05-13 20:59:36 +00:00
Konstantin Shcheglov 3a35eeac88 Macro. Report a diagnostic if not allowed declaration, ignore the code.
Change-Id: I0b8ca91ed2f242e5d0fda8a90dd493e5d68af983
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365869
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-10 15:42:25 +00:00
Srujan Gaddam b0a34dbccb [linter/analyzer] Add lint for runtime type tests of JS types
Closes https://github.com/dart-lang/linter/issues/4841

Adds a lint to verify and report whether an is check or a cast
may result in platform-inconsistent behavior. In order to do so,
adds necessary additions to canBeSubtypeOf and extends the mock
SDK. Also adds this to the list of default rules.

Change-Id: I7f235ee698419d9f253cc96f08322bedca271825
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361722
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-05-08 20:57:59 +00:00
pq 126ca0fc8c fix pubspec analysis for multi-options contexts
Fixes: https://github.com/dart-lang/sdk/issues/55580


Change-Id: I34ef0c9bca50d333ed2b058ddeb2ffdc1a4eaba9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365542
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-05-06 23:41:32 +00:00
Konstantin Shcheglov 013d5d72b9 Completion. Issue 55614. Suggestions for types in WildcardPattern.
Bug: https://github.com/dart-lang/sdk/issues/55614
Change-Id: I2228ac24f7802865cecdf28757b65a6a9339495a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365284
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-02 20:23:09 +00:00
Konstantin Shcheglov 15c3434efe Completion. Issue 55576. Support for completion in IndexExpression.
Bug: https://github.com/dart-lang/sdk/issues/55576
Change-Id: I30369fa9259e6852204acd8ad2d130617f2b8e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364581
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-04-26 20:08:41 +00:00
Danny Tuppeny 8d5794aa70 [analysis_server] Fix missing types on factory constructor arguments in LSP completion
There are two fixes here, either of which solve the problem but it seemed like both should exist:

1. Always set "element" on an argument suggestion, not only if it's a field formal
2. In LSP mapping, use the "parameterType" from a suggestion in addition to other fields to find the type

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

Change-Id: Iba21c94a157bfca4d53daad203d518d9fa765a59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-04-24 15:12:10 +00:00
Sam Rawlins 1b400ed68d DAS plugins: Move CorrectionUtils to analysis_server_plugin
* Move the only 3 files from server_plugin to analysis_server_plugin.
* Copy some test infra into analysis_server_plugin. This is temporary,
  as we need some shared test infra location.

Change-Id: If2b41d436c9d3051e590f60ae2eb7ab31e529321
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364161
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-04-24 14:12:24 +00:00
Brian Wilkerson 0a1cad1947 Add a pass for suggesting elements that are not yet imported
This CL makes 3 different changes. I'm happy to split them out into
smaller CLs if you'd like me to.

The first is to add the class `NotImportedCompletionPass`, which is the
proposed replacement for the `NotImportedContributor`. I believe that
the pass is complete, but it currently doesn't contribute any
suggestions because the methods invoked by the two "operations" aren't
yet implemented.

That said, it does do real work in terms of searching through the
libraries that aren't imported. That work is currently duplicated by
the contributor, which would likely cause a performance degredation.
As a result, I've commented out the invocation of the pass (but have
verified that every test passes when it's not commented out).

The second is to start suggesting extension members from local
extensions. I'm not sure why, but prior to this CL they appear to have
only been suggested by the `NotImportedContributor`, which isn't
always run. I'm not sure where members from imported extensions are
currently being imported, but I'll figure that out before I remove
the `NotImportedContributor`.

The third is to change the element being compared against when
computing the inheritance distance. We were previously using the
container of the element being suggested, which caused the inheritance
distance to always be the same, no matter what the type hierarchy
looks like. We need better tests for relevance, but I didn't add any
in this CL.

Change-Id: Ic82a15cab5d022f89da234a8b31bc6bca34ccb5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363760
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-04-19 21:38:56 +00:00
Konstantin Shcheglov e12b3d0ee5 Completion. Issue 55505. Fix for completion in property access target in assignment begin.
Bug: https://github.com/dart-lang/sdk/issues/55505
Change-Id: I26bde2ab84d7216218ba9aed75b7561ed30c9c30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-18 23:13:16 +00:00
Sam Rawlins 5c79627e08 Move CorrectionUtils addLibraryImports to ExtractMethod
`_getInsertionLocationTop` and `addLibraryImports` are each moved to
extract_method.dart, as the only location where they were used.

We get to delete the `_InsertionLocation` class.

The tests are also moved, unchanged, and CorrectionUtilsTest is very
much simplified.

Bug: https://github.com/dart-lang/sdk/issues/53402
Change-Id: Ia410f04a837d85a0e06ec523d156c6c6c8bf6a3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363402
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-04-17 22:12:28 +00:00
Konstantin Shcheglov 5c07c89a35 Enable 'unnecessary_final' in analysis_server/.
Change-Id: I71ee934b915d4aff924cf5925f87bcc9adc6c015
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362901
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-04-16 20:04:15 +00:00
Danny Tuppeny e588c8b379 [anaysis_server] Move ErrorOr class from LSP package to analysis_server
ErrorOr is not related to (or used by) the spec or generated spec classes. It's a utility class for the server implementations of LSP handlers.

I'd like to extend this class and add some extensions (that require access to private fields) and don't feel it belongs in `package:language_server_protocol`.

(note: `package:language_server_protocol` is not published so I believe removing it from there is not a breaking change)

Change-Id: I06799b18d61d123364711a549231134c792e70e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-04-04 18:51:27 +00:00