Skip to content

Rename _fe_analyzer_shared's ErrorCode #60635

Open
@srawlins

Description

@srawlins

The different "types" of diagnostics that the analyzer (and CFE?) can report exist as classes (like LintCode, ParserErrorCode, TodoCode, StaticWarningCode, CompileTimeErrorCode, WarningCode, ScannerErrorCode, AnalysisOptionsErrorCode, AnalysisOptionsWarningCode, etc), which all have a common super-class: ErrorCode.

This name is potentially confusing, as we can say, for example "using a @visibleForTesting element outside of a test does not yield an error; it yields a warning." But warning is a subclass of error? For years this confusion would only hamper the developers of the analyzer (and CFE?). But the new analyzer plugin system uses LintCode and WarningCode, and we need a better name for the shared super-class, for function signatures, etc.

I propose DiagnosticCode. It's longer, more syllables, but it is not a name that will be used often.

We can do a gentle incremental migration, and there is no rush to delete ErrorCode:

  1. Add a type alias, typedef DiagnosticCode = ErrorCode.
  2. Change function signatures in API that will become public for analyzer plugins.

Then, as needed, as time permits:

  1. Migrate internal usage to DiagnosticCode.
  2. Deprecate ErrorCode.
  3. In a major version release, without any rush, rename ErrorCode to DiagnosticCode and remove the type alias.

Metadata

Metadata

Assignees

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-code-healthInternal changes to our tools and workflows to make them cleaner, simpler, or more maintainable

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions