diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-02-23 00:13:32 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-02-23 17:21:26 +0100 |
commit | 03486df4053ec75bce0ec4b6e5f16ceafcbf66e9 (patch) | |
tree | c8e93e6f96b0ae543a880c5c818ff980342423c7 /src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala | |
parent | 9d24583b44e4b59d07d61c5f051c8e9a8a832148 (diff) | |
download | dotty-03486df4053ec75bce0ec4b6e5f16ceafcbf66e9.tar.gz dotty-03486df4053ec75bce0ec4b6e5f16ceafcbf66e9.tar.bz2 dotty-03486df4053ec75bce0ec4b6e5f16ceafcbf66e9.zip |
ConsoleReporter: handling of non-sensical messages is now reusable
This is now handled by a separate trait HideNonSensicalMessages that can
be mixed in, similar to UniqueMessagePositions. This way we'll be able
to reuse this functionality for other kind of Reporters.
This also means that we don't need `doReport` to return a Boolean
anymore, so we change it to return a Unit as it did before
065a0026924f722e9844c8e314180bb4cebca236
Diffstat (limited to 'src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala')
-rw-r--r-- | src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala b/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala new file mode 100644 index 000000000..a325fe9f7 --- /dev/null +++ b/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala @@ -0,0 +1,20 @@ +package dotty.tools +package dotc +package reporting + +import core.Contexts.Context + +/** + * This trait implements `isHidden` so that we avoid reporting non-sensical messages. + */ +trait HideNonSensicalMessages extends Reporter { + /** Hides non-sensical messages, unless we haven't reported any error yet or + * `-Yshow-suppressed-errors` is set. + */ + override def isHidden(d: Diagnostic)(implicit ctx: Context): Boolean = + super.isHidden(d) || { + d.isNonSensical && + hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical + !ctx.settings.YshowSuppressedErrors.value + } +} |