Revert "analyzer: separate unused_element_parameter from unused_element"

This reverts commit c1976b097d.

Reason for revert: It seems this change caused failures on Flutter
HHH bot. Example log can be found at [0]:
```
| lib/src/super_reader/super_reader.dart:615:14: Error: Final field 'showDebugLeaderBounds' is not initialized.
| Try to initialize the field in the declaration or in every constructor.
|   final bool showDebugLeaderBounds;
|              ^^^^^^^^^^^^^^^^^^^^^

```
Looking at the sources it seems that may be related to the
`// ignore: unused_element` analyzer directive:

```
   602	/// A [SuperReaderDocumentLayerBuilder] that builds a [SelectionLeadersDocumentLayer], which positions
   603	/// leader widgets at the base and extent of the user's selection, so that other widgets
   604	/// can position themselves relative to the user's selection.
   605	class _SelectionLeadersDocumentLayerBuilder implements SuperReaderDocumentLayerBuilder {
   606	  const _SelectionLeadersDocumentLayerBuilder({
   607	    required this.links,
   608	    // ignore: unused_element
   609	    this.showDebugLeaderBounds = false,
   610	  });
   611
   612	  /// Collections of [LayerLink]s, which are given to leader widgets that are
   613	  /// positioned at the selection bounds, and around the full selection.
   614	  final SelectionLayerLinks links;
   615
   616	  /// Whether to paint colorful bounds around the leader widgets, for debugging purposes.
   617	  final bool showDebugLeaderBounds;
```

So tentatively reverting this CL.

[0] https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8739650477551803313/+/u/Run_customer_testing_tests/stdout

Original change's description:
> analyzer: separate unused_element_parameter from unused_element
>
> Fixes https://github.com/dart-lang/sdk/issues/49025
>
> 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.
>
> Tested: Presubmit CI
> Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
> Change-Id: I4844a6a0e0a67cd5e37ed8735b1526e174deb950
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378500
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Phil Quitslund <pquitslund@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: Ibbba75fe56601c7c4b5535c9142cf94c2dd80b91
Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380460
Commit-Queue: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
Martin Kustermann
2024-08-14 08:05:37 +00:00
committed by Commit Queue
parent 3d083d2720
commit b888da751e
5 changed files with 19 additions and 40 deletions
@@ -348,7 +348,7 @@ base class E {
class _E {
static const _E c = _E();
// ignore: unused_element_parameter, recursive_constant_constructor
// ignore: unused_element, recursive_constant_constructor
const _E({_E e = const _E()});
}
''');
+3 -1
View File
@@ -7585,9 +7585,11 @@ class WarningCode extends AnalyzerErrorCode {
/// Parameters:
/// 0: the name of the parameter that is declared but not used
static const WarningCode UNUSED_ELEMENT_PARAMETER = WarningCode(
'UNUSED_ELEMENT_PARAMETER',
'UNUSED_ELEMENT',
"A value for optional parameter '{0}' isn't ever given.",
correctionMessage: "Try removing the unused parameter.",
hasPublishedDocs: true,
uniqueName: 'UNUSED_ELEMENT_PARAMETER',
);
/// Parameters:
+10 -20
View File
@@ -27308,6 +27308,8 @@ WarningCode:
kinds of declarations are analyzed:
- Private top-level declarations and all of their members
- Private members of public declarations
- Optional parameters of private functions for which a value is never
passed
Not all references to an element will mark it as "used":
- Assigning a value to a top-level variable (with a standard `=`
@@ -27327,26 +27329,6 @@ WarningCode:
class [!_C!] {}
```
#### Common fixes
If the declaration isn't needed, then remove it.
If the declaration is intended to be used, then add the code to use it.
UNUSED_ELEMENT_PARAMETER:
problemMessage: "A value for optional parameter '{0}' isn't ever given."
correctionMessage: Try removing the unused parameter.
hasPublishedDocs: false
comment: |-
Parameters:
0: the name of the parameter that is declared but not used
documentation: |-
#### Description
The analyzer produces this diagnostic when a value is never passed for an
optional parameter declared within a private declaration.
#### Example
Assuming that no code in the library passes a value for `y` in any
invocation of `_m`, the following code produces this diagnostic:
@@ -27371,6 +27353,14 @@ WarningCode:
```
If the declaration is intended to be used, then add the code to use it.
UNUSED_ELEMENT_PARAMETER:
sharedName: UNUSED_ELEMENT
problemMessage: "A value for optional parameter '{0}' isn't ever given."
correctionMessage: Try removing the unused parameter.
hasPublishedDocs: true
comment: |-
Parameters:
0: the name of the parameter that is declared but not used
UNUSED_FIELD:
problemMessage: "The value of the field '{0}' isn't used."
correctionMessage: Try removing the field, or using it.
+4 -17
View File
@@ -23183,6 +23183,8 @@ void f() {
### unused_element
_A value for optional parameter '{0}' isn't ever given._
_The declaration '{0}' isn't referenced._
#### Description
@@ -23192,6 +23194,8 @@ referenced in the library that contains the declaration. The following
kinds of declarations are analyzed:
- Private top-level declarations and all of their members
- Private members of public declarations
- Optional parameters of private functions for which a value is never
passed
Not all references to an element will mark it as "used":
- Assigning a value to a top-level variable (with a standard `=`
@@ -23211,23 +23215,6 @@ produces this diagnostic:
class [!_C!] {}
```
#### Common fixes
If the declaration isn't needed, then remove it.
If the declaration is intended to be used, then add the code to use it.
### unused_element_parameter
_A value for optional parameter '{0}' isn't ever given._
#### Description
The analyzer produces this diagnostic when a value is never passed for an
optional parameter declared within a private declaration.
#### Example
Assuming that no code in the library passes a value for `y` in any
invocation of `_m`, the following code produces this diagnostic:
@@ -2942,7 +2942,7 @@ class DebuggerConsoleElement extends CustomElement implements Renderable {
DebuggerConsoleElement.created() : super.created('debugger-console');
/// Is [container] scrolled to the within [threshold] pixels of the bottom?
// ignore: unused_element_parameter
// ignore: unused_element
static bool _isScrolledToBottom(DivElement? container, [int threshold = 2]) {
if (container == null) {
return false;