Commit Graph

4182 Commits

Author SHA1 Message Date
Danny Tuppeny 8f9cdb3b2f [analyzer] Remove LSP fix-all-in-file functionality
To be replaced by new functionality that works with LSP + original protocol.

Change-Id: I59627e2c4e99b0a6aa0eb850168c870e5390e03b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-22 19:53:39 +00:00
Brian Wilkerson 191e95fa3e Fix the replace_conditional_with_if_else assist in null safe libraries (issue 45030)
Bug: 45030
Change-Id: I2a0946a490a1e69cab7d1bbac6c9efdabd8926c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-22 18:20:59 +00:00
Konstantin Shcheglov 8d0a5dd6fa Fix AnalysisDomainTest on Windows.
TBR

Change-Id: I4920ef5bfcb60d652b286c04c58b4c30de13a2a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186041
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-20 01:24:25 +00:00
Konstantin Shcheglov c2195fcc14 Rewrite to use AnalysisContextCollection in analysis_server.
Change-Id: Iee6b392711790d17c25a3c18fa1e9bdfe8b8cc4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-19 23:01:25 +00:00
Keerti Parthasarathy dcf6b12270 Add CiderAssistComputer to compute assists for Cider.
Change-Id: I6087ccabda0c0749d0027b40ecad5050a2eb0431
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185492
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-02-19 15:08:34 +00:00
Konstantin Shcheglov 2e40e359e2 getElementDeclaration() can return null.
Change-Id: I2c8331d22191587991cd1782525d84f5044a79b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185721
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-19 08:21:37 +00:00
Konstantin Shcheglov 9bfd416c45 Add ContextRoot.workspace, deprecated AnalysisContext.workspace, support included excludes in ContextLocatorImpl
Change-Id: Iecd324ad45b926ca6b0626f8bea4f479409154e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185499
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-02-19 02:15:40 +00:00
Brian Wilkerson bfe3a31cd4 Add a failing test for issue 45030
Change-Id: I59e9db21ef97286c137e635b1c8bdbd2991b98a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185493
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-18 23:29:50 +00:00
Danny Tuppeny a6c14e8848 [analyzer] Insert imports after annotation of first import directive in file
Fixes https://github.com/Dart-Code/Dart-Code/issues/3104.

Change-Id: Ic91727c11cda1436662a52b737094ea87927047c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-16 21:32:50 +00:00
pq 4302f058dd disable legacy fix-all fix creation
Tests to be re-enabled when we wire-up `FixInFileProcessor`.  (Or maybe we want a different approach to testing fix all fixes entirely?  TBD.)

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

Change-Id: I66f83d06801a71143dcc770cc38d9e2f86782264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185180
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-02-16 20:50:20 +00:00
Danny Tuppeny c8c49c7cc8 [analyzer] Handle creating new files from code actions
Fixes https://github.com/Dart-Code/Dart-Code/issues/3141.

Change-Id: I44d7f20962512988ff1d54c7b38b6a144f973a58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-16 18:54:39 +00:00
Brian Wilkerson 77da201b19 Add a fix for unnecessary_nullable_for_final_variable_declarations
Change-Id: Ibd6570c05f3a289fba72c42f3fc30e88649a9004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185000
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-15 16:26:39 +00:00
Konstantin Shcheglov 51950ab881 Add Resource.parent2 that returns non-null Folder, add Folder.isRoot
A bigger version of than https://dart-review.googlesource.com/c/sdk/+/184381
This is breaking change, so we do this in steps.

Change-Id: I0c7212a073b605ade56657036543c604651810c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184581
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-02-12 19:09:20 +00:00
pq 2d27b34b06 appliedTogetherMessages for fixable in file fixes
Change-Id: I674f0e79c5d7ce5c44bcbddff8e6866106e860c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-02-12 17:10:23 +00:00
pq fbf07bc7b7 migrate towards a shared nonLintProducerMap
Introduces a new map datastructure and migrate BulkFixProcessor to use it.

Change-Id: I6294cce875ac5e5052b363282454af6dadf011f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-02-11 18:37:30 +00:00
Danny Tuppeny 235292605e [analyzer] Filter code actions returned from LSP server based on params.context.only
Fixes https://github.com/Dart-Code/Dart-Code/issues/2854.

Change-Id: If6036a4361b68ae2daa66b99755dfa9b9a8adcfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184464
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-11 18:16:20 +00:00
Danny Tuppeny ab8335b4fd [analyzer] Don't fail to initialize LSP server with non-file:// workspace folders/roots
Change-Id: I52fa0620ef563ff0362cb86b24ffc287e8e007c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-11 16:10:19 +00:00
Brian Wilkerson 1ee6459ded Fix a bug in addParameter handling
Change-Id: Id321108ce4fbd096ba79212f530486ec2318fba3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184205
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-10 22:49:33 +00:00
Devon Carew 3f8c508a94 [analyzer] don't analyze html files
Change-Id: I45fa266be055a7d6ca1c0ecb90dc8245fa8b4616
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-02-10 15:52:24 +00:00
Konstantin Shcheglov bcbebc8fd5 Fix for resolving package: URIs with space in BazelPackageUriResolver.
Change-Id: I0de91dcb2438205b476dea99fa2231dd189ef094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184042
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-09 22:26:59 +00:00
pq 7b2dcad078 improved fix in file computation
Follow-up from: https://dart-review.googlesource.com/c/sdk/+/183700

Change-Id: I6d15b25a2dc4664fd3743763fedd83bf39bba794
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184041
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-02-09 22:24:54 +00:00
Danny Tuppeny cc7bd35516 [analyzer] Support completing argument names in function expression invocations
Fixes https://github.com/dart-lang/sdk/issues/42064.

Change-Id: I186bef47771a56844833fc908c183358955e11ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-09 21:44:32 +00:00
pq db09afdd1f fix (all) in file processor
Change-Id: I092d99ab8dd7e16fe351cf475a7c935a2546d67c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-02-09 20:35:46 +00:00
Brian Wilkerson cf2e85f035 Generalize FeatureComputerTest to make writing more tests easier
Also, fixed a small bug found by updating the code used to find the node.

Change-Id: Id64e66f4d50f70aaadd3e56e37a83b257d119b9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183181
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-06 01:24:28 +00:00
Brian Wilkerson c723dae62f Add missed tests for noSuchMethod relevance
Also renamed other tests in this directory to not duplicate the
directory name.

Change-Id: I8aec73c6e44ca05f385f21b32f9c5feef1df67ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183121
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-05 18:33:57 +00:00
Lasse R.H. Nielsen 222b894d62 Change resolve for package:URIs to not remove package name.
A "package URI" is defined as one with a `package` scheme,
no authority, a first path segment terminated by `/` which
contains no escapes and is not all `.` characters.
This is the definition of package names accepted by .packages
as well: Valid path characters and not all dots.

Change-Id: I9a161d47732e8bf873d278774315c72a4a928823
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117542
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2021-02-05 18:31:48 +00:00
Keerti Parthasarathy 8f74a46b05 Use line number to compute fixes, Cider provides line and column number.
Change-Id: I134480f88b55893a1a397847902176a792dfb0ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2021-02-04 19:16:27 +00:00
Konstantin Shcheglov 3be5f7c356 Use Future<void> when extract an async method that returns nothing.
R=brianwilkerson@google.com

Change-Id: Ic148974ba587310c475795caf8ed0c8565d96909
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182664
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-03 22:25:39 +00:00
Konstantin Shcheglov 02d2b4fb8a Update CorrectionUtils.getTypeSource() to support any type aliases.
Change-Id: I6bb3ea6c60adc2efe071b58369296de4d63fd6d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182602
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-03 20:26:29 +00:00
Danny Tuppeny e8dce3a6f0 [analyzer] Support --verbose for LSP benchmarks
Change-Id: Ibad5b798e7f7a069bd5e1ce9758cfbbcaa8e3001
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182511
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-03 19:34:57 +00:00
Sam Rawlins f306f4c4d4 Analysis server: Remove unnecessary imports; standardize on prefix use
In a few files, an element is available twice: once without a prefix,
and once with a prefix, and the element is referenced in both ways. This
triggers an "unnecessary import" diagnostic, and changing all of the
references to be unified resolves the issue.

Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I3c5a3f397f0a3603624a2d23becfda2753cc9f8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-02-03 08:41:48 +00:00
Konstantin Shcheglov 5b227c8fbe getElementDeclaration() can return null.
Change-Id: I63207c55890d1c3b817bae1b57275ed37b9befa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182368
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-03 00:27:20 +00:00
Konstantin Shcheglov d1d8730472 Don't use part-of library that does not have the part file.
Bug: https://github.com/dart-lang/sdk/issues/44840
Change-Id: I7e7353472e5deaa3f63c6f461f547149b04d1fb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182366
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-02 23:54:16 +00:00
Danny Tuppeny 74d8cc9636 Extend analysis server benchmarks to run for LSP too
Change-Id: Ib6522b8faaa5be272d8f97043a7aa1c345ea182c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-02 22:09:54 +00:00
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00
Konstantin Shcheglov 7ee6952828 Test that hover works for typedef, including non-function.
R=brianwilkerson@google.com

Change-Id: I401e58e6121c55754e467aa25264997bf4082c3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182001
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-01 00:32:13 +00:00
Brian Wilkerson 1804309d9c Remove more dead code from server
Change-Id: I99c58e87b8cc6e02dc9beab0ba9244e63ae1557c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-01 00:32:03 +00:00
Brian Wilkerson d1882b6bea Remove the unused class DartContributionSorter
This was used by the ML support, which has been removed.

Change-Id: Idedb04e31c7b859f8ac0e590fd722958ce40d9ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181980
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-02-01 00:23:59 +00:00
Brian Wilkerson 388b6ff746 Add failing tests for suggesting else in an if element
Change-Id: I8e04fc190a598c812da68b328e5e5628afa01cb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-01-30 21:09:17 +00:00
Brian Wilkerson 53f5179b45 Improve the placement of added named parameters
Change-Id: I8ed588c14402a3d85d134dc75c324d9e3d96f532
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181820
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-01-29 19:33:56 +00:00
Konstantin Shcheglov 0c3696d76a Switch refactoring tests to 2.12 + non-function type aliases.
Change-Id: Iaf366ba1ee5f05d47a6ae102a9c5f2daeb8112c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181780
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-01-29 01:32:35 +00:00
Konstantin Shcheglov 7bbab07bea Outline for non-function type aliases.
Change-Id: I1a8ef42e700fa84ac7a249268cdbd3aa72921c1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181541
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-01-28 07:28:50 +00:00
Konstantin Shcheglov 5c426d8d43 Add Element.aliasedType to the protocol.
R=brianwilkerson@google.com

Change-Id: I95fb2c9d50096f90913c4d6670ce0841095fe6a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181443
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-01-27 23:27:21 +00:00
Konstantin Shcheglov 974926e468 Update StaticMemberContributor to support completion via non-function type alias.
Change-Id: Ic59fba42a8ddad52a55f0f323dc199d78597a9c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181460
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-01-27 23:23:05 +00:00
Danny Tuppeny 77353dc380 [Analyzer] Allow files inside .dart_tool to be analyzed when modified
These files were already analyzed at startup but not when modified. This meant code generated by flutter_gen would not update unless the analysis server was restarted/the project was reanalyzed.

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

Change-Id: If0c88c1e5ab7e796046e7e776a42c3d904944405
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179776
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-01-27 20:37:25 +00:00
Brian Wilkerson 00edf6fd13 Mark newly published docs as being published
Change-Id: I5663eaf6a6df94d279f15ca42364e96054c04987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180800
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-01-27 20:19:17 +00:00
Konstantin Shcheglov 3a5294c7e6 Fixes and tests for completion in non-function type aliases.
Change-Id: I69cf74380fc1c251e0f44334fdff17f327cafeaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181341
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-01-27 19:27:35 +00:00
Konstantin Shcheglov 83a72e18f3 Switch completion tests to WithNonFunctionTypeAliasesMixin, updates and tests for suggesting non-function type aliases.
Change-Id: I0066d479b23b46e0aaaae43aebdc1bbc58336ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181282
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-01-26 23:04:05 +00:00
Konstantin Shcheglov 79c35e872d Update messages for checking the name of a type alias.
R=brianwilkerson@google.com

Change-Id: I6a523d3b5f8db07f1f1e1e779c1e9aacf885b173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-01-26 23:03:55 +00:00
Konstantin Shcheglov e9fe25003b Issue 43166. Don't ignore changes to files excluded from reporting diagnostics.
Bug: https://github.com/dart-lang/sdk/issues/43166
Change-Id: I9d9f8cf77129ecd811f13876aa6e284f633f023a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-01-26 22:23:55 +00:00