linter icon indicating copy to clipboard operation
linter copied to clipboard

comment_references broken when using super parameters

Open kevmoo opened this issue 3 years ago • 2 comments
trafficstars

When migrating the below code to use_super_parameters, the references to ctor paramaters in doc comments are now flagged with the comment_references hint.

class PartBuilder extends _Builder {
  /// Wrap [generators] as a [Builder] that generates `part of` files.
  ///
  /// [generatedExtension] indicates what files will be created for each
  /// `.dart` input. The [generatedExtension] should *not* be `.g.dart`. If you
  /// wish to produce `.g.dart` files please use [SharedPartBuilder].
  ///
  /// If any generator in [generators] will create additional outputs through
  /// the [BuildStep] they should be indicated in [additionalOutputExtensions].
  ///
  /// [formatOutput] is called to format the generated code. Defaults to
  /// [DartFormatter.format].
  ///
  /// [header] is used to specify the content at the top of each generated file.
  /// If `null`, the content of [defaultFileHeader] is used.
  /// If [header] is an empty `String` no header is added.
  ///
  /// [allowSyntaxErrors] indicates whether to allow syntax errors in input
  /// libraries.
  ///
  /// If available, the `build_extensions` option will be extracted from
  /// [options] to allow output files to be generated into a different directory
  PartBuilder(
    super.generators,
    String generatedExtension, {
    super.formatOutput,
    super.additionalOutputExtensions,
    super.header,
    super.allowSyntaxErrors,
    super.options,
  }) : super(
          generatedExtension: generatedExtension,
        );
}

kevmoo avatar Jul 28 '22 18:07 kevmoo

@jcollins-g @srawlins – any idea if things still work w/ DartDoc here?

kevmoo avatar Jul 28 '22 18:07 kevmoo

I'm not sure.

srawlins avatar Jul 29 '22 22:07 srawlins

FYI: I just confirmed that dartdoc "does the right thing" here. So it's just lint weirdness, it seems!

kevmoo avatar Sep 27 '22 03:09 kevmoo

Also, here's a test case that should pass, but doesn't at current HEAD


class G {
  G({required int paramA, required int paramB});
}

/// [paramA] is better than [paramB].
///
/// At least to have a regression test for
/// https://github.com/dart-lang/linter/issues/3563.
class H extends G {
  H({required super.paramA, required super.paramB});
}

kevmoo avatar Sep 27 '22 03:09 kevmoo

Sounds like it might be an analyzer issue, where the comment reference is not being linked to its corresponding static element.

parlough avatar Sep 27 '22 03:09 parlough

Potentially blocking #3911

pq avatar Jan 05 '23 16:01 pq

Updated repro:

class G {
  G({required int p1, required int p2});
}

class H extends G {
  /// [p1] is better than [p2].
  H({required super.p1, required super.p2});
}

pq avatar Feb 28 '23 19:02 pq

Fixed by https://github.com/dart-lang/sdk/commit/80ad96837c207bb1d74c8c54e7387b9e6b7093df

parlough avatar Dec 12 '23 18:12 parlough

Woohoo!

pq avatar Dec 12 '23 20:12 pq