Skip to content

Better nomenclature for literate diagnostic reporting in analyzer #61389

@stereotype441

Description

@stereotype441

In the code review discussions for https://dart-review.googlesource.com/c/sdk/+/445803, some concerns were raised about the nomenclature used. We decided to go ahead with the CL as is, but keep the discussion about nomenclature open and adjust the names later. I'm opening this issue as a place to have the nomenclature discussion. Once we reach a conclusion I'll make a CL changing the names to whatever we agree on.

For reference, the new API for diagnostic reporting looks like this:

    diagnosticReporter.report(
      diagnosticCode
          .withArguments(...) // omitted if diagnostic takes no arguments
          .withContextMessages(contextMessages) // may be omitted
          .at(astNode),
    );

For comparison, the old API looks like this:

    diagnosticReporter.atNode(
      astNode,
      diagnosticCode,
      arguments: [...], // omitted if diagnostic takes no arguments
      contextMessages: contextMessages, // may be omitted
    );

The names introduced in the CL that we might want to reconsider are:

  • report: extension method on DiagnosticReporter that reports a diagnostic using the new API
  • withArguments: getter implemented by some diagnostic codes that allows specifying template arguments.
    • A suggested alternative was invoke, since we might want some of the parameters to be things other than template arguments (e.g. context messages for diagnostics that should always have them).
  • LocatableDiagnosticImpl: type returned by withArguments.
    • A suggested alternative was DiagnosticCodeCallHasArguments.
  • DiagnosticWithoutArguments: mixin for diagnostic codes that don't take arguments.
    • A suggested alternative was DiagnosticCodeCallNoArguments.
  • LocatableDiagnostic: interface shared by LocatableDiagnosticImpl and DiagnosticWithoutArguments.
    • A suggested alternative was DiagnosticCodeCall.
  • withContextMessages: method on LocatableDiagnostic that attaches context messages.
  • atOffset: method on LocatableDiagnostic that attaches an offset and length.
  • at: method on LocatableDiagnostic that attaches an offset and length based on an AstNode or Token.
  • LocatedDiagnostic: type returned by atOffset and at, and accepted by report.

@scheglov, @bwilkerson, @johnniwinther, @srawlins, what do you think?

Metadata

Metadata

Assignees

Labels

analyzer-technical-debtarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-packageIssues related to package:analyzer

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions