Commit Graph

53 Commits

Author SHA1 Message Date
pq d21fd1ff4b [PE] document registerFixForRule
Change-Id: Ie0f2f9bd85207ec6a25d881fbd8182c6506620f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408884
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-02-10 15:01:19 -08:00
Jake Macdonald f4cfbf9cdc Update create function fix to create an async function for await expressions
Bug: https://github.com/dart-lang/sdk/issues/59990
Change-Id: I9e89089ca5c60bea190060bc0c8e869c7e78e32e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/408361
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-02-06 14:25:39 -08:00
Sam Rawlins 2ac59922d2 DAS plugins: Support fixes to ignore diagnostics
Change-Id: I71ae995d1a4a94ecfeafd187c5674c41b6d928d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-02-04 08:24:23 -08:00
Sam Rawlins 052e03c829 DAS plugins: Support plugin-namespaced inline ignore comments
Fixes https://github.com/dart-lang/sdk/issues/59647

Change-Id: I303c83c3a486d6eb495e890007127215357e2864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406686
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-02-04 07:53:02 -08:00
Konstantin Shcheglov 2946ea71d5 Macro. Remove more from analyzer/ and analysis_seever/.
Change-Id: Id5426cce73395d3d95657cf1e0b5f9d85fe3f574
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-31 11:35:10 -08:00
Sam Rawlins ca31648dbb Support 'new' analyzer plugins in dart analyze.
This change allows the LegacyAnalysisServer to understand when the
plugin isolate (if there is one) is analyzing or not. There are a few
primary concepts:

* The plugin isolate (PluginServer) notifies the analysis server, when
  analyzing all files in a context collection, and analyzing changed
  files, that it is analyzing, and later that it isn't.
* The NotificationManager tracks whether the plugin isolate is analyzing
  or not, based on the last status.
* The PluginManager tracks whether new plugins are initialized or not.
  This is determined by the work done by the PluginWatcher. If no
  plugins are configured, then plugins are declared to be "initialized".
  Otherwise, the AnalysisServer sets their status to be "initialized"
  after receiving the first status notification from the plugin isolate.
* The LegacyAnalysisServer now uses the additional "are plugins
  analyzing" signal, held in NotificationManager, and the "are plugins
  initializing" signal, held in PluginManager, to determine whether to
  notify the client that analysis is complete.


Change-Id: Ie2b6a6048f074d7a26d7d5d07622a17c30fcab96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405444
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-31 10:44:36 -08:00
Sam Rawlins f5d01eb734 DAS plugins: Remove direct dependency on _fe_analyzer_shared
Change-Id: If498173f3d37ab6798a1e05070274c197948ab0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406687
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-01-31 09:27:59 -08:00
pq 876752e40f [CQ] add feature isEnabled utility
Change-Id: I267aee8da50ec073a28bdb22ebe5379d31b1dc91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403265
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-07 13:18:28 -08:00
Konstantin Shcheglov a5468363c6 CQ. Remove unnecessary 'async' where no 'await'.
Change-Id: I58f56c098c9cec753325ab56d0aad37e1fde0ec6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403082
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-01-07 10:08:11 -08:00
Brian Wilkerson 7041cda56d [Migrate] CorrectionProducer
Change-Id: Ia8fba6d745d04cef88d1beb7e6da7ed15d23fcb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402588
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-01-03 09:50:10 -08:00
pq 8a08c1bc56 [element model] migrate session_helper API
Change-Id: Ia2717bb24c83a409e853fb5271a3d5ed91cd3306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402142
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-20 13:56:49 -08:00
Danny Tuppeny 11904ed387 [analyzer] Add LinterContext.currentUnit and use it for content in eol_at_end_of_file
... instead of potentially reading the file from disk.

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

Change-Id: Id5939dce4d11429a929a4b63611ff1823449b64c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401424
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-12-17 10:19:59 -08:00
Konstantin Shcheglov af2527723b Elements. Migrate lib/src/cider/fixes.dart
Change-Id: I01867f48ac6d39c65a9a21961079232399e05c1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399029
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-12-06 23:59:55 +00:00
Konstantin Shcheglov 7e1721dfab Elements. Migrate ImportLibrary.
Change-Id: I127e0f0b31e6b0d05727ae518b54971287e37008
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398950
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-12-05 05:04:08 +00:00
Konstantin Shcheglov 6f992aea0d Elements. Migrate lib/src/utilities/extensions/element.dart
Change-Id: Ibcf9d2449411413210e1d363ced4acdcfeede8d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398948
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-12-04 23:19:17 +00:00
Sam Rawlins db021faa0c DAS plugins: Simplify the set of analyzed paths with Sets
Change-Id: I1d7bd2e1935d8daa455315c04adcff01d037934c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397181
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-22 22:30:19 +00:00
Sam Rawlins 046c968b14 DAS plugins: minor adjustments regarding the PluginIsolateChannel
It looks like PluginCommunicationChannel.listen cannot do anything
with `onError`, so don't pass anything as if it did.

See ReceivePort.listen docs as well: https://api.dart.dev/dev/latest/dart-isolate/ReceivePort/listen.html

Change-Id: Iaaf1169a1f05774f63bdcea4c91a82dfb9e47227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396526
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-20 19:36:02 +00:00
FMorschel 6dac184012 Adds library result
R=scheglov@google.com

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

Change-Id: I125c53e138c97e57fc22d69b2362351ddcbb6b4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395420
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Felipe Morschel <fmorschel.dev@gmail.com>
2024-11-19 15:50:42 +00:00
Sam Rawlins 922847af5f DAS plugins: Only analyze (and hence visit) .dart files
In it's current form, the lint rules are given _every_ file in the
context root, including things like CHANGELOG.md, YAML files, etc, and
it tries to parse them as Dart source.

Change-Id: I0bd5a682fa4f22b857520bb99e7a3d8990c93e37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396041
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-18 17:53:10 +00:00
Sam Rawlins f27e78af6b DAS plugins: Support priority files
Change-Id: I0c0106bc573250a6d4a4d2d11dbb96c4178dde93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395681
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-11-15 22:53:09 +00:00
Sam Rawlins e227ed2621 DAS plugins: onError must accept one parameter
It's awkward that PluginCommunicationChannel.listen accepts a
`Function?` for the `onError` parameter, but it _must_ be a
`void Function(Object)` or a `void Function(Object, StackTrace)`. I
wish we had static analysis for this...

Change-Id: Id91a8172c7ef20e35bb8ff21736649d1501aff42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395082
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-11-13 19:45:38 +00:00
Sam Rawlins c1e535031d analyzer: Simplyify propagating lint rule exceptions
I found that the `propagateLinterExceptions` analysis option was
being passed to the AnalysisRuleExceptionHandler class at
approximately the same point where the exception handler is called, and
also that the AnalysisRuleExceptionHandler class's `logException`
method did not _use_ the `propagateLinterExceptions` value; it just
_unconditionally_ returned it. So it gave it back to nearly the same
code that passed it in.

So we can simplify all of this by removing the `propagateExceptions`
field in AnalysisRuleExceptionHandler. But then that class has zero
fields and one method. _And_ that one method is _the only_ ,method
that is ever passed in to AnalysisRuleVisitor as the exception
handler. So remove the class altogether, and inline the method in
AnalysisRuleVisitor.

AnalysisRuleVisitor instead takes the bool value,
`shouldPropagateExceptions`, and does the right thing with it.

Additionally:
* Privatize AnalysisRuleVisitor `registry` property.
* Make AnalysisOptionsImpl `propagateLinterExceptions` property final.

Change-Id: Ia438881a3eccb3e26ebed294a7b7b8329d7961ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393902
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-12 17:03:39 +00:00
Brian Wilkerson 15cdbc5eab Migrate five correction producers
Change-Id: I3289e0862797947fadf76d78a2ce27c0cf249dd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394321
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-11-08 21:08:18 +00:00
Sam Rawlins 082c71062b analyzer: Move enableTiming out of AnalysisOptionsImpl to AnalysisDriver.
It has seemed disingenuous to me that `enableTiming` has been a
property of AnalysisOptionsImpl, when it cannot be specified in an
analysis options file. Additionally, it is used in exactly _one_
place: the linter package's `benchmark.dart` script.

Instead, it makes more sense to think of this "flag" as a process-wide
flag. It is not something that may be set one way for some files, and
another for another set of files. And it is not something that can be
set to one value early during an analysis process, and then change; it
never changes.

So instead this change makes it a _final_, _private_ field on
AnalysisDriver, and on LibraryAnalyzer. LibraryAnalyzer gets its value
from AnalysisDriver, and AnalysisDriver gets its value from the
AnalysisContextCollectionImpl constructor.

Change-Id: I347605775680a8ea1c1237f0ee20bd4bbe2c6216
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393961
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-07 18:49:01 +00:00
Sam Rawlins 0ed2082654 analyzer plugins: change rules options key to diagnostics
Also allow warning diagnostics to be disabled.

In many places, the RuleConfig is unchanged because currently the
`linter/rules` section parsing is shared with the `plugin/<plugin-name>/diagnostics` section parsing.

They will probably diverge at some point, but as long as they are the
same, we can use the same Registry class to identify enabled and
disabled rules/diagnostics.

Change-Id: I9c00770af14d3b753532bcf1bc6bff62624d99ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-04 23:50:29 +00:00
Sam Rawlins 784af8f704 DAS plugins: track lint rule configuration by name
* PluginConfiguration.ruleConfigs is now a Map instead of a List,
  mapping analysis rule names to each RuleConfig. This makes it more
  straightforward (and theoretically more performant) for the Registry
  to determine the set of enabled analysis rules. The primary parsing
  code, `parseLinterSection`, also returns a mapping now.
* This merges seamlessly into `AnalysisOptionsImpl`'s call to
  `parseLinterSection`.

This is most of the refactoring work found in
https://dart-review.googlesource.com/c/sdk/+/392981, but without the
change to allow warnings to be disabled.

Change-Id: I4d1e6791da83ad370c18a15e9e3bb85b1daed58d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-11-01 16:28:30 +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
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
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
Brian Wilkerson 505e2367f2 Migrate one file in plugin_server
There are two other files that need to be migrated, but the unmigrated
portions are being used by other unmigrated files, so they can't be
migrated yet.

Change-Id: I1f0d029c16734b1599783149ade5a0d6ec29d349
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390924
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-10-18 19:59:59 +00:00
Konstantin Shcheglov 3c5bdb63cf Elements. Migrate CreateMethod.
Change-Id: I7e631dd63baf74060a94bd413f5ccdd527fd21f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387352
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-30 16:56:50 +00:00
Konstantin Shcheglov c1bce1be15 Elements. Migrate CreateMethodOrFunction.
Change-Id: I623534c22c6ed9fa793bd11cdb0ae2d4c8575ef1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387350
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2024-09-29 23:56:50 +00:00
Konstantin Shcheglov 49654fb991 Elements. Migrate CreateField.
Change-Id: I5f014789fe1cfb6882ed75bbb3f7fa8d0e308ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387349
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-29 21:30:14 +00:00
Konstantin Shcheglov dadc46dd4d Elements. Migrate AddKeyToConstructors.
Change-Id: I498becb67634a05507b009a32a96c2d1b699d47e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386975
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-27 20:27:32 +00:00
FMorschel a0374dd70c Fix create method/function inside conditional operator
Closes https://github.com/dart-lang/sdk/pull/56722

GitOrigin-RevId: 9a861d4078b326754b8855e833c52ede03f0e28d
Change-Id: Ia7535ff48c16836b0e7d3a32005051c7defc3766
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-25 20:51:54 +00:00
Fedor Shcheglov 9f4bb0d654 Issue 56559. Remove @override from private field, add to getter/setter.
Bug: https://github.com/dart-lang/sdk/issues/56559
Change-Id: I57e9c5e286af520499ddddeee5818f1c22a94ee8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-09-23 18:13:45 +00:00
Sam Rawlins ce3b7c2b9c DAS plugins: support overlay changes
This adds and tests support for adding file overlays, changing them, and
removing them.

Work towards https://github.com/dart-lang/sdk/issues/53402

Change-Id: I7939f8199639f7e336cd97515c2f7d48b1d777a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384305
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-09 22:12:19 +00:00
Sam Rawlins 42a6ac4315 DAS plugins: Run plugin code zoned
In this CL, I run plugin code that responds to a request in an error
zone. The bulk of this change though is the tests that verify how we
handle asynchronous and synchronous thrown errors.

I separate some shared code from plugin_server_test into a shared lint
rules file and a base class. Then a second test is introduced with a
few error cases.

Change-Id: I4e252ae0d3bec0cf6625c0044681677fba3132bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-09-09 14:46:18 +00:00
Konstantin Shcheglov d90bb7321a Parts. Remove support for library augmentations.
Change-Id: I04f076ea6917bd4597b79c75db16207ccf387c9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383702
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-09-05 22:21:33 +00:00
Sam Rawlins 895093e9f9 Initial PluginServer implementation
This is the core implementation of the "plugin server" that will support the API described at https://docs.google.com/document/d/1T8P323DJxsc3YPzveNIaSKWFkrJp9ydTR4jp_XFb7XQ/edit?resourcekey=0-f8Ue29KMUizqXNGhATp1tg#heading=h.23fjh5hfm2is

This is heavily curbed from the ServerPlugin class at
`package:analyzer_plugin/plugin/plugin.dart`, but does not depend on it.
It depends on two concepts from the analyzer_plugin package: (1) the
protocol used for de/serializing requests, responses, etc. And (2) the
`PluginCommunicationChannel` class. This is also just a utility for
communicating between the analysis server and the plugin server.

This plugin server is capable of "registering" individual "plugins",
which allows plugins to register individual (maybe multiple) lint rules,
and individual (maybe multiple) quick fixes.

The plugin server for now only responds essentially to three requests:

* `ANALYSIS_REQUEST_SET_CONTEXT_ROOTS`
* `EDIT_REQUEST_GET_FIXES`
* `PLUGIN_REQUEST_VERSION_CHECK`

All files are analyzed during `handleAnalysisSetContextRoots`, and
quick fixes are calculated during `handleEditGetFixes`.

There are many TODOs, but the included test shows that this plugin
server can notify the analysis server of lint diagnostics to be
reported, and can respond to a query for quick fixes.

Change-Id: Ibc93332319220a2caf49d20ab480940041a15049
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-08-29 16:03:42 +00:00
Sam Rawlins ed622c5300 DAS: Move FixInFileProcessor to analysis_server_plugin
Also move the top-level `computeFixes` convenience function.

The `computeFixes` function is the main entrypoint that various code
uses to, well, compute all fixes with a FixProcessor and a
FixInFileProcessor. In order for plugin code to call `computeFixes`,
we need that function and FixInFileProcessor in the
analysis_server_plugin package.

Work towards https://github.com/dart-lang/sdk/issues/53402

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Id5f02864762eeefb92055a3534e91b60b76dfeb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-31 19:16:27 +00:00
Sam Rawlins 34ad8e075e Move FixProcessors and registeredFixGenerators to analysis_server_plugin
These two are needed in the shared package so that plugins can run
CorrectionProducers. They go in 'src' because plugin developers do not
need to see this code.

Work towards https://github.com/dart-lang/sdk/issues/53402

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Iee5b5dd063d5b0a9b00c58b91a3e50328c8b5fc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-30 21:17:13 +00:00
Sam Rawlins 4e6d8115cd DAS: Move DartFixKindPriority, and rename values as lowerCamelCase.
FixProcessor has to be part of the analysis_server_plugin package, so
it cannot have any dependencies on the analysis_server package. This moves one.

The word 'default' is reserved, so I changed to 'standard'.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I1ee21c800203fac758f10a6fde0ea7d07eee5e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374742
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-18 21:23:14 +00:00
Konstantin Shcheglov d2ff2d1925 Parts. Visit 'configurations' child, update visitors.
Change-Id: Ifaa33b9d0c92f6677e1f100d45d5edbce11e765f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375744
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-07-15 21:53:50 +00:00
Sam Rawlins 1e84b64a0e DAS: Move DartChangeWorkspace to the analysis_server_plugin package
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: I79f43d06b48149b1d9dec30c5f5a77fdfd57ce4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373143
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-26 02:17:59 +00:00
Sam Rawlins 8c918ffda3 analyzer: Fix resolution of private extension members
Fixes https://github.com/dart-lang/sdk/issues/45240

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Idc054d968c5884dcf6bc876d996c741e8300cab0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Sam Rawlins <srawlins@google.com>
2024-06-17 18:28:21 +00:00
Sam Rawlins e5f3a50a7a DAS: Support Parse-only correction producers
This brings the soft static enforcement that we had before: a producer
that extends ParsedCorrectionProducer cannot access the
ResolvedUnitResult of a ParsedUnitResult.

Also we add some runtime enforcement that the producers used for parse-
only lint rules are ParsedCorrectionProducer.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If77fa66ae6fc070de1c7e931eb992a4adc14b68a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369561
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-06-03 23:13:18 +00:00
Konstantin Shcheglov 2628bfe733 QuickFix. Issue 55805. Create extension method.
Bug: https://github.com/dart-lang/sdk/issues/55805
Change-Id: Ifbe1420413ebe20e6e5e28c49da6c1cde6f801ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-31 20:07:31 +00:00
Sam Rawlins ebd8c46b85 DAS: Make _AbstractCorrectionProducer._context non-late, final.
We do this by passing a CorrectionProducerContext up each of the
constructors. We can then remove all `configure` methods. This
requires a few changes and allows a few changes:

* Remove ParsedCorrectionProducer. It does not seem to have served a
  purpose.
* CorrectionProducerContext no longer needs to be generic.
* Add a public getter for `MultiCorrectionProducer._context`, so that
  a multi correction producer can pass along its context to child
  correction producers.
* Introduce a `CorrectionProducerContext.instance` dummy variable,
  used when we need to check if a correction producer can be applied
  in bulk.
* Make `CorrectionProducerContext._node` public, so that it can be
  used in factory constructors.
* `BulkFixProcesor.correctionContext()` return type is non-nullable.
* Add a factory constructor for AddMissingParameter, and move the
  `configure` logic there.
* Add a factory constructor for ConvertAddAllToSpread, and move the
  `configure` logic there. Then make `_isInlineInvocation` and
  `_invocation` final.
* Add a factory constructor for ReplaceFinalWithVar, and move the
  `configure` logic there. Then make `_removeFinal` and
  `_finalKeyword` final.
* Add a factory constructor for ReplaceWithIsEmpty, and move the
  `configure` logic there. Then make `fixKind`, `multiFixKind`,
  `_binary`, and `_replacement` final.
* Rename `_AddMissingParameter.context` to `_executableParameters`,
  and make it final.


Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: If0e9bc1cbf5c8e656938bc6cd4eb32a9d4f06b38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-05-30 22:49:39 +00:00