diff --git a/lib/src/async_environment.dart b/lib/src/async_environment.dart index 708f3592..bf88b148 100644 --- a/lib/src/async_environment.dart +++ b/lib/src/async_environment.dart @@ -717,9 +717,11 @@ class AsyncEnvironment { for (var module in _globalModules) { var valueInModule = callback(module); if (valueInModule != null && value != null) { - // TODO(nweiz): List the module URLs. throw SassScriptException( - 'Multiple global modules have a $type named "$name".'); + 'Multiple global modules have a $type named "$name":\n' + + bulletedList(_globalModules + .where((module) => callback(module) != null) + .map((module) => p.prettyUri(module.url)))); } value = valueInModule; diff --git a/lib/src/environment.dart b/lib/src/environment.dart index e728fa0e..059ed0e4 100644 --- a/lib/src/environment.dart +++ b/lib/src/environment.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_environment.dart. // See tool/grind/synchronize.dart for details. // -// Checksum: fe68ec0b099d3f2992af03dbdaeff0b3e8392808 +// Checksum: 23da0a0dca141c7ac432dc64958c4240eeceb23d // // ignore_for_file: unused_import @@ -722,9 +722,11 @@ class Environment { for (var module in _globalModules) { var valueInModule = callback(module); if (valueInModule != null && value != null) { - // TODO(nweiz): List the module URLs. throw SassScriptException( - 'Multiple global modules have a $type named "$name".'); + 'Multiple global modules have a $type named "$name":\n' + + bulletedList(_globalModules + .where((module) => callback(module) != null) + .map((module) => p.prettyUri(module.url)))); } value = valueInModule; diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 5bf5e60a..f48e753a 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -10,6 +10,7 @@ import 'package:charcode/charcode.dart'; import 'package:collection/collection.dart'; import 'package:source_span/source_span.dart'; import 'package:stack_trace/stack_trace.dart'; +import 'package:term_glyph/term_glyph.dart' as glyph; import 'ast/node.dart'; import 'util/character.dart'; @@ -38,6 +39,15 @@ String pluralize(String name, int number, {String plural}) { return '${name}s'; } +/// Returns a bulleted list of items in [bullets]. +String bulletedList(Iterable bullets) { + return bullets.map((element) { + var lines = element.split("\n"); + return "${glyph.bullet} ${lines.first}" + + (lines.length > 1 ? "\n" + indent(lines.skip(1).join("\n"), 2) : ""); + }).join("\n"); +} + /// Returns the number of times [codeUnit] appears in [string]. int countOccurrences(String string, int codeUnit) { var count = 0;