Description:
Currently we expose a public Diagnostic API to represent diagnostics, and a DiagnosticLog API as a convenient way to log errors.
However, the DiagnosticLog doesn't have a default/common implementation. Hence every compiler extension needs to implement their own DiagnosticLog, in-order to log errors. This not only adds extra work to the extension developer, but also results in a lot of duplicate codes, as well as inconsistency in the errors.
Suggestion is to:
With this, to log errors from a compiler extension, the developer only needs to:
As part of this, we should also look at the possibility of exposing some of the fine-grained APIs in the BLangDiagnosticLog from the DiagnosticLog as well.
For the compiler plugins, we are passing a diagnostic logger instance to its init() method though?
@pubudu91 the problem is, if they wants to add any extension-specific errors, then they have to add those to compiler's error messages template (compiler.properties file). Ideally error templates should be maintained by each extension.
I think we need to expose some APIs at the DiagnosticLog as well. This would be a cleaner approach when it comes to the extensions with custom Error codes and etc. As @SupunS has suggested these should be extendable.