Commit Graph

9440 Commits

Author SHA1 Message Date
Sam Rawlins e66a8a4fa3 analyzer plugins: parse version and path keys in YAML
This enables plugin sources to be specified in one of three ways:

* as a YamlScalar, like `plugin_name: ^1.2.3`
* with a 'version' key, like `plugin_name:\n  version: ^1.2.3`, which
  allows diagnostic configurations to be alongside.
* with a 'path' key, like `plugin_name:\n  path: foo/bar`, which
  allows diagnostic configurations to be alongside.

We introduce a PluginSource with a `toYaml` method to convert the
values back into YAML for the generates pubspec. We update
PluginPackageGenerator to use PluginSource.toYaml.

Change-Id: Ic5f372f0339edd6aa638dd9b568a83f41a023b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-06 19:41:00 +00:00
Robert Nystrom 732b07a42b Roll dart_style into the SDK.
I'm still chasing down a couple of google3 failures, but this is ready for review so that I can get it approved and land it once the last couple of failures are fixed. Here is who I think should review what:

athom@ for:

- DEPS

johnniwinther@ for:

- pkg/_fe_analyzer_shared
- pkg/front_end
- pkg/kernel

brianwilkerson@ for:

- pkg/analysis_server
- pkg/analyzer_plugin
- pkg/analyzer_utilities

kenzieschmoll@ for:

- pkg/dartdev

pquitslund@ for:

- pkg/linter/lib/src/lint_codes.g.dart

If you're not the right person, feel free to summon someone else.

Most of the changes here are re-running code generators that auto-format the code they generate. The changes are:

Roll in the latest dart_style commit:

- DEPS

Manually updated these test expectations to expect the new style:

- pkg/analysis_server/test/lsp/format_test.dart
- pkg/analysis_server/test/services/refactoring/agnostic/change_method_signature_test.dart
- pkg/analysis_server/test/src/domains/flutter/set_property_value_test.dart
- pkg/analysis_server/test/src/services/flutter/container_properties_test.dart
- pkg/analysis_server/test/src/services/flutter/widget_descriptions_test.dart
- pkg/analysis_server/test/src/services/refactoring/convert_selected_formal_parameters_to_named_test.dart
- pkg/analysis_server/test/src/services/refactoring/move_selected_formal_parameters_left_test.dart

This was auto-generated by something, but I'm not sure why it thinks there is a diff:

- pkg/analyzer_plugin/doc/api.html

Updated to require a version of dart_style that accepts a language version in DartFormatter():

- pkg/analyzer_plugin/pubspec.yaml

Updated to always use the latest language version (and thus new style) when invoking the formatter:

- pkg/analyzer_utilities/lib/tools.dart

Manually updated the formatting in the code templates so that they matched the formatting expected by the tests, which implicitly format using the latest language version:

- pkg/dartdev/lib/src/templates/...

The rest are all generated files that are formatted so re-generated using the new style:

- pkg/_fe_analyzer_shared/lib/src/experiments/flags.dart
- pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
- pkg/analysis_server_client/lib/handler/notification_handler.dart
- pkg/analysis_server_client/lib/src/protocol/...
- pkg/analysis_server/lib/protocol/protocol_generated.dart
- pkg/analysis_server/test/integration/support/integration_test_methods.dart
- pkg/analysis_server/test/integration/support/protocol_matchers.dart
- pkg/analyzer_plugin/lib/protocol/...
- pkg/analyzer_plugin/test/integration/support/integration_test_methods.dart
- pkg/analyzer_plugin/test/integration/support/protocol_matchers.dart
- pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
- pkg/analyzer/lib/src/dart/error/...
- pkg/analyzer/lib/src/error/codes.g.dart
- pkg/analyzer/lib/src/manifest/manifest_warning_code.g.dart
- pkg/analyzer/lib/src/pubspec/pubspec_warning_code.g.dart
- pkg/analyzer/lib/src/summary/format.dart
- pkg/analyzer/lib/src/wolf/ir/ir.g.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_000_1.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_001_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_010_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/less_simple/lib_100_0.dart
- pkg/compiler/test/tool/graph_isomorphizer/golden/simple/...
- pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart
- pkg/front_end/lib/src/codes/cfe_codes_generated.dart
- pkg/front_end/lib/src/util/parser_ast_helper.dart
- pkg/front_end/test/parser_test_listener.dart
- pkg/front_end/test/parser_test_parser.dart
- pkg/front_end/testcases/...
- pkg/kernel/lib/src/coverage.dart generated
- pkg/kernel/lib/src/equivalence.dart generated
- pkg/linter/lib/src/lint_codes.g.dart

Change-Id: Ice0141b763e63b84f54692cd19a442a0719673c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391263
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-06 18:42:25 +00:00
Keerti Parthasarathy c30f961f13 Delete unused code - RuntimeCompletionComputer
Change-Id: I4fd027998ce4f9fa847df2ddd0773c3a476e766a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393701
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-06 12:59:00 +00:00
Keerti Parthasarathy da1930ab6c Add cancellation token for legacy requests in message scheduler
Change-Id: I6b0837edbf373d2b8b72b16ed47d157c097347d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-11-06 12:58:02 +00:00
Parker Lougheed b47128dd64 [analysis server] Fix links in implementation docs
Change-Id: Ie40111a6bfed4a6f088f1e7bd3f365aa060a1b0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-05 19:25:00 +00:00
FMorschel 9d340db3e6 Fixes import prefix hover text as code
R=srawlins@google.com

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

Change-Id: I37fa39f385dd26dfcf55c024b9ca331ec83381f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393382
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-11-05 18:10:19 +00:00
Parker Lougheed 235a7157d5 [analysis_server] Don't repeatedly redetermine sort member order
Also complete some nearby cleanup. Mostly turning MemberKind into a normal enum.

Change-Id: I96f810c9f2197e5c748231f3d1fb5344e5ef528a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393680
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-11-05 17:29:29 +00:00
Danny Tuppeny facc712ec8 [analysis_server] Migrate LSP colors to new element model
Change-Id: Ib31793e2cc5b52cde46b76dee9da7ddc9047eee3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393322
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-05 16:05:46 +00:00
FMorschel 6eda5e2019 [DAS] Fixes add const for final variables and lint
R=srawlins@google.com

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

Change-Id: I75dd2c0063ea5d3a6ebbf4afb734d2cb5d98c1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392860
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-11-05 15:48:00 +00:00
Chloe Stefantsova 8a1c0203b4 [analyzer] Handle null-aware elements in code completion
Part of https://github.com/dart-lang/sdk/issues/56989

Change-Id: Id02c049d0afb5cb6c3f1d94ee5bebf7ca532e2e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392902
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-05 10:57:28 +00:00
Vyacheslav Egorov 729c1c01ce Fix Collect Report functionality
When language server is started through dartdev is gets
classified as a system isolate, but Collect Report
only looks at user isolates.

I have looked at various ways to fix this but it is
complicated because we are in the middle of rewiring
dartdev to work with AOT built tools.

I would like a trivial change that can be easily
cherry-picked into stable release. Thus I am opting in
to simply change data collection code to collect information
from both user and system isolates.

Change-Id: I00f9eb937153fc730feccf778e5cd2f69d222a18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-11-05 09:07:28 +00:00
Chloe Stefantsova 523ab95e64 [analyzer] Add call hierarchy tests for null-aware elements
Part of https://github.com/dart-lang/sdk/issues/56989

Change-Id: Ifd09b47fbb83519277fc6968a8edf8cdcdf76d6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393321
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-11-05 06:45:08 +00:00
Konstantin Shcheglov f02000e8d2 Elements. Use analyzer_use_new_elements.txt for opt-out, not opt-in.
So, we can see what is left to migrate.

Change-Id: I2440e23bf9f02401278f15adca91080e584a694f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393482
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-04 22:38:38 +00:00
Konstantin Shcheglov 4f6b07c25e CQ. Remove available declarations.
Bug: https://github.com/dart-lang/sdk/issues/55281
Change-Id: Ie8d2a7f3d5ea9408320312d49eb67561ca463289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393480
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-04 21:30:08 +00:00
Konstantin Shcheglov c054056146 Elements. Lint. Disallow 'declaredElement' from src/dart/element/element.dart
Also enable the lint for analyzer/.

Change-Id: I2c9e61c6427f5e59b936f1ee7f5f94d4584f2988
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392851
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-04 20:59:51 +00:00
Brian Wilkerson 48e67d1242 Add some files that are migrated but not reported as such
Change-Id: I2a6c4d4e8206c6238a8de43c389bb0de8cbf7dd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393160
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-11-01 20:27:30 +00:00
Konstantin Shcheglov a868303290 Elements. Remove FragmentName, inline as name2 / nameOffset2.
Change-Id: If238cd71867501a39e243261228d137f925db1dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-01 18:56:26 +00:00
FMorschel d5e19c60b7 Fix for completion inside late final fields
R=paulberry@google.com

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

Change-Id: Ib1a5ca0c27df2d19bca36f7385c30b02811c2e33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393043
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-01 16:34:58 +00:00
FMorschel 5e6a681445 Fix hover import prefix
Fixes https://github.com/dart-lang/sdk/issues/32735

Change-Id: I6830b61fe554065f9ec6e87f2ac24dfaffd67f35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390960
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
2024-11-01 14:16:58 +00:00
Brian Wilkerson 5ef250a2bf Rework the new element model so that all elements have fragments
Change-Id: Ic4fc0368cabc5fa8dfc21c958e1619777f2701b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392541
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-31 23:23:39 +00:00
Danny Tuppeny 3f6ff63774 [analysis_server] Use only Parsed AST for format in legacy protocol handler
+ clean up LSP version to use new `unit.languageVersion.effective`

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

Change-Id: Ia28f3ddb116427ecd8588f58adb7238a7204832a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391961
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-31 19:54:32 +00:00
Danny Tuppeny 6a94c6122f [analysis_server] Minor LSP refactors + fix
Some minor fixes/tweaks extracted from another CL

1. Fix tool/lsp_spec/codegen_dart to set `options` on `CodeStyleOptions` (a late field that needs to be set to the owning options file)
2. Fix a wrapped TODO to be indented so it's detected correctly
3. Move the custom `DartTextDocumentContentProviderHandler` handler into the `custom` folder
4. Merge `LspHandlerHelperMixin ` into `HandlerHelperMixin` since the APIs it uses are no longer LSP-specific and exist on the base server

Change-Id: Ie1b3a8057575346cf9bfb98465c0a3e330c28a82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392909
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-31 19:14:03 +00:00
Sam Rawlins 1033027175 Tidy some legacy plugin code
* Update comments to be modern and reference "package config files"
  rather than "packages files"
* Remove commented out code that we aren't going to uncomment.
* Rename PluginFiles.packages.
* Simplify `PluginManager._computeFiles` to use less nesting, and use
  early `throw` statements, rather than storing data in local
  and choosing late whether an exception should be thrown with the
  stored data.

Change-Id: I7d5da0e299962d8887f2222137478a2fd96671b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392960
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-31 19:12:30 +00:00
Danny Tuppeny 27b52a3f82 Add languageVersion to CompilationUnit and make non-null
Change-Id: Ice6f866929f1f028d9b4e64685c2e815a08279f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392000
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-31 18:49:03 +00:00
FMorschel df520c9ee3 [DAS] Import library with prefix
R=srawlins@google.com

Fixes https://github.com/dart-lang/sdk/issues/55863
Fixes https://github.com/dart-lang/sdk/issues/41515
Fixes https://github.com/dart-lang/sdk/issues/24338

Change-Id: I8b8457488b55a468d4b3c6d34efffc7436a2ff18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389780
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-10-31 16:57:03 +00:00
Danny Tuppeny ca0cfad6bd [analysis_server] Add occurrences/document highlights for type aliases
Fixes https://github.com/dart-lang/sdk/issues/56994

Change-Id: I0721603b7b019ab09614265e412d3b9e76d26ad9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392660
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-10-30 20:27:54 +00:00
FMorschel 006caad390 [DAS] Inline enclosing else block assist
Fixes https://github.com/dart-lang/sdk/issues/56924

Change-Id: Ib697e7b29671331f4e5b87a2472e3be60f89ffa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391021
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-30 19:47:38 +00:00
Alex Wallen 901f356c1f chore: add actual vs. expected in error logging message
Closes https://github.com/dart-lang/sdk/pull/56988

GitOrigin-RevId: da1fceb6e01622ca3bc63ede831c983d77c2417e
Change-Id: I1bed7fcdfdbf891f3205fb7ffd3e104fa6528cc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392406
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-30 18:40:15 +00:00
Sam Rawlins 1db40b6eb8 analyzer: Add an AnalysisRule alias for LintRule
Since the LintRule class is the basis for writing both "lint rules"
(rules that must be explicitly enabled) and "warning rules" (rules that
are enabled by default), it is a misnomer to use 'LintRule' as a
supertype. This change adds an alias, 'AnalysisRule'. Additionally:

* Rename LinterVisitor to AnalysisRuleVisitor.
* Rename lintRuleTimers to AnalysisRuleTimers.
* Rename LinterExceptionHandler to AnalysisRuleExceptionHandler.
* Rename LintRuleExceptionHandler to _AnalysisRuleExceptionHandler.

* NodeLintRegistry is used in too many places, so I have left it for
  now.

Change-Id: I43340cca0f9b64502960d8f5e05c6c9b81c3dfd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392203
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-30 17:43:19 +00:00
FMorschel a40403e0fb [DAS] New assists for wrap with Expanded/Flexible
R=pquitslund@google.com

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

Change-Id: I34a697d914e3a480105a4388d77178a96425893a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390622
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-30 17:26:18 +00:00
Samuel Rawlins 81f4b71293 Reland "Reapply "analyzer: separate unused_element_parameter from unused_element""
This reverts commit b3f31a0440.

Reason for revert: Customer tests are now disabled.

Original change's description:
> Revert "Reapply "analyzer: separate unused_element_parameter from unused_element""
>
> This reverts commit b551690c56.
>
> Reason for revert: flutter customer tests failing: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8738601049545714785/+/u/run_test.dart_for_customer_testing_shard_and_subshard_None/stdout
>
> Original change's description:
> > Reapply "analyzer: separate unused_element_parameter from unused_element"
> >
> > Fixes #49025. Fixes #48401
> >
> > This allows users to blanket ignore unused_element_parameter without
> > ignoring unused_element. They are reported in distinct situations so it
> > is valid to separate them.
> >
> > This reverts commit b888da751e.
> >
> > Change-Id: I8ea52fcdcb491c140c1283602d6911c939e78d50
> > Tested: trybots
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381882
> > Reviewed-by: Ben Konyi <bkonyi@google.com>
> > Commit-Queue: Samuel Rawlins <srawlins@google.com>
> > Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
>
> Change-Id: Ie0df2f4be45e5db2fa255dcf8c30ddf8408c155b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382420
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Matan Lurey <matanl@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: Icbe69690e83daecc5a0649d2f632ffc33ba6394c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Matan Lurey <matanl@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-10-30 16:56:16 +00:00
FMorschel 9612b71707 [DAS] Update combinator - Use aliased import fix
R=scheglov@google.com

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

Change-Id: I1354e3cde559229d5167a27e51efb6d030e5f8bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392400
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-30 16:10:11 +00:00
Danny Tuppeny 37af167cc5 [analysis_server] Fix missing semantic token modifiers for dynamics
This removes `_addIdentifierRegion_dynamicLocal` and just inlines the region kind into the existing variable/name methods, that way the modifiers are still applied without having to duplicate them in `_addIdentifierRegion_dynamicLocal`.

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

Change-Id: I7f39ec828c916de0fb99d8c71baa78a2f690c94b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392582
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-30 15:31:14 +00:00
Danny Tuppeny 56fc83656a [analysis_server] Fix occurrences highlighting for prefixed identifiers
Fixes https://github.com/dart-lang/sdk/issues/56981

Change-Id: I817625962b5a4975ec5f597ab147fe7312cdf06f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392580
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-30 15:27:39 +00:00
Danny Tuppeny 8d845f63ae [analysis_server] Migrate signature computers to new element model
Change-Id: I72d5c9f841d9f85b7f9597a309b14ba4b7e0d3a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-30 14:49:21 +00:00
Danny Tuppeny 97dafd74f5 [analysis_server] Consider sort_constructors_first lint when sorting
Fixes https://github.com/Dart-Code/Dart-Code/issues/4934

Change-Id: Ic6c739a2aaf6f62ecf0c2488a32f90c3f19738a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-29 20:04:49 +00:00
Konstantin Shcheglov aec93bfaad Elements. Use 'firstFragment' instead of 'declaration' in AugmentedInstanceElement and subtypes.
Change-Id: Idc3812ebc51f0bf92f467f21d91f7f4ecb3171e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392241
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-29 20:02:00 +00:00
Keerti Parthasarathy e573f64f48 Create LSP CompletionItem from CandidateSuggestion, bypassing the SuggestionBuilder.
This eliminates the step of converting CandidateSuggestion to legacy completion item and then into LSP completion item. Also makes use of the SuggestionCollector to sort and truncate suggestions.

The utility functions/methods are in completion_utils.dart, these are based on the code in mapping.dart, modified to use CandidateSuggestions.

Change-Id: I1e44a5318575eeb3b89803e20a082f98b7bedd41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392082
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-29 15:16:43 +00:00
Sam Rawlins 97871aeab5 analyzer: Use less AnalysisOptionsImpl
In many cases, AnalysisOptions is sufficient.

* ResolvedCorrectionProducer will be public API for someone writing an
  analyzer plugin; it should not expose an AnalysisOptionsImpl. Luckily
  the only need for the Impl, today, is in the "ignore diagnostic" fixes
  so we can cast in there. (We could also expose the `file` and the
  `unignorableNames` fields.)
* Some other spots only cast in order to access one of the 'strict'
  fields, but all of those have been made public.
* AnalysisOptionsImpl.enabledLegacyPluginNames can be made final.
* Many other users don't need AnalysisOptionsImpl, or only need it to
  pass it to other code that _does_ need it. In many of those cases it
  makes sense to look at an object as an AnalysisOptions, and let the
  code that needs a field from Impl to do a cast.

Change-Id: I3640934fb9d93c9b95f15a22457af604e420c7a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-29 14:22:58 +00:00
Sam Rawlins bc58f69e53 analyzer: Move AnalysisOptionsImpl out of the generated directory
None of the code in AnalysisOptionsImpl or AnalysisOptionsBuilder is
changed.

Change-Id: I0d3253d80fdcd624c73720c35ece9d23a2582071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392180
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-28 21:03:33 +00:00
Danny Tuppeny 12d9554c5b [analysis_server] Don't treat non-existent files the same as empty files when checking if didOpen changes content
This code assumed `driver?.fsState.getExistingFromPath(path)?.content` would be null for files that didn't exist, but actually we can get a `FileState` with `exists=false` and an empty string for `content`. We should not consider this equal to an empty file that was just opened.

Fixes https://github.com/Dart-Code/Dart-Code/issues/5269
Fixes https://github.com/dart-lang/sdk/issues/55318

Change-Id: I4334a002ef0fb9ff3a9423568faa6e0735369022
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392142
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-28 19:07:44 +00:00
Danny Tuppeny b1e740f316 [analysis_server] Migrate Overrides + DocumentationComputer
`DocumentComputer` currently makes use of `asElement2` to allow callers to still pass `Element`s so they can be migrated in separate CLs.

Change-Id: I44c49782498899d377defb90a8cd3813288c169e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391662
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-28 15:59:24 +00:00
Sam Rawlins 155a64c1b7 DAS plugins: Allow plugin rules to be disabled by default
This bumps the Registry class to be able to take "rules that are enabled  by default" and "rules that need to be explicitly enabled", "lint rules" and "warning rules". Next is to improve the classes.

Add parsing for the top-level `plugins` section, and
`PluginConfiguration` class to hold this data, and
`get pluginConfigurations` on AnalysisOptions.

Rename `parseLintRuleConfigs` to `parseLinterSection` to align better
with the other functions in engine.dart.

Rename `_ruleConfigs` function to `parseRulesSection`.

Change-Id: Ib93b7548bfb13cc94381971a5a2780a5dc81e9f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-10-28 01:42:02 +00:00
Robert Nystrom 38a3b2153c Don't pass a null language version to DartFormatter().
The DartFormatter() constructor call in edit_format.dart is passing in
a language version, which is good. But it was passing a nullable
Version because of the default case. That works in dart_style 2.3.7
where the Version is optional but fails in 3.0.0 because the Version
is non-nullable there.

This fixes that by defaulting to the latest version. I'm not sure under
what conditions this can fail to find an effectiveLanguageVersion so I
don't know if the latest version is the right default. Let me know if
there's something better I should do here.

Change-Id: I76477e5df9dcf2a78176207cff92c20c7f08a17b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391840
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2024-10-25 14:44:09 +00:00
Chloe Stefantsova 253e715f83 [analyzer] Report warnings on expressions with non-nullable types
Part of https://github.com/dart-lang/sdk/issues/56836

Change-Id: I3fcdceff667f371fcf4b66c12bd16e2f34e6446c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391621
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-10-25 10:08:04 +00:00
FMorschel b2bc791c81 [DAS] Convert related to cascade fix
R=scheglov@google.com

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

Change-Id: I64d81aaeb5286508e9b03869fd34fc592b0870e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390421
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-24 18:07:14 +00:00
David Morgan f06e37233e [analyzer] Return only relevant errors in sortDirectives.
Trying 3.7.0 I hit a case where this would succeed but return an error
"Doc directive 'code' is unknown." Per the doc comment it looks like
the error should not be returned.

R=scheglov@google.com

Change-Id: Id2d65adcf4ce59caa16040fcce9457b2c7f244a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391740
Auto-Submit: Morgan :) <davidmorgan@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-10-24 18:03:38 +00:00
Danny Tuppeny 93fda3ea7d [analysis_server] Use the correct language version for formatting in the LSP server
Fixes https://github.com/dart-lang/sdk/issues/56941

Change-Id: I675e732ceba98ab88904906c8076e805fcc9ca2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391663
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-23 23:52:13 +00:00
Konstantin Shcheglov 535bda9cd8 Elements. Change the return type of 'name3' implementations to nullable, update some bodies.
In particular, MethodElementImpl2, which can have a fragment without a
name, and can have a name without an actual fragment (when the fragment
is synthetic).

Change-Id: Ib3383867e4351e9a11ef39ce12bf5670a4db9ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391701
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-10-23 20:14:28 +00:00
FMorschel 10db3de794 [DAS] "Update library import" edit hide
R=srawlins@google.com

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

Change-Id: I2d16e18a3644333f57f77c1b2ead86c8734c2cd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390630
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-10-23 16:50:27 +00:00