mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 22:02:00 +01:00
Improve the error message for a global member conflict (#762)
This commit is contained in:
parent
c0f51c292a
commit
e454647d27
@ -717,9 +717,11 @@ class AsyncEnvironment {
|
|||||||
for (var module in _globalModules) {
|
for (var module in _globalModules) {
|
||||||
var valueInModule = callback(module);
|
var valueInModule = callback(module);
|
||||||
if (valueInModule != null && value != null) {
|
if (valueInModule != null && value != null) {
|
||||||
// TODO(nweiz): List the module URLs.
|
|
||||||
throw SassScriptException(
|
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;
|
value = valueInModule;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// DO NOT EDIT. This file was generated from async_environment.dart.
|
// DO NOT EDIT. This file was generated from async_environment.dart.
|
||||||
// See tool/grind/synchronize.dart for details.
|
// See tool/grind/synchronize.dart for details.
|
||||||
//
|
//
|
||||||
// Checksum: fe68ec0b099d3f2992af03dbdaeff0b3e8392808
|
// Checksum: 23da0a0dca141c7ac432dc64958c4240eeceb23d
|
||||||
//
|
//
|
||||||
// ignore_for_file: unused_import
|
// ignore_for_file: unused_import
|
||||||
|
|
||||||
@ -722,9 +722,11 @@ class Environment {
|
|||||||
for (var module in _globalModules) {
|
for (var module in _globalModules) {
|
||||||
var valueInModule = callback(module);
|
var valueInModule = callback(module);
|
||||||
if (valueInModule != null && value != null) {
|
if (valueInModule != null && value != null) {
|
||||||
// TODO(nweiz): List the module URLs.
|
|
||||||
throw SassScriptException(
|
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;
|
value = valueInModule;
|
||||||
|
@ -10,6 +10,7 @@ import 'package:charcode/charcode.dart';
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:source_span/source_span.dart';
|
import 'package:source_span/source_span.dart';
|
||||||
import 'package:stack_trace/stack_trace.dart';
|
import 'package:stack_trace/stack_trace.dart';
|
||||||
|
import 'package:term_glyph/term_glyph.dart' as glyph;
|
||||||
|
|
||||||
import 'ast/node.dart';
|
import 'ast/node.dart';
|
||||||
import 'util/character.dart';
|
import 'util/character.dart';
|
||||||
@ -38,6 +39,15 @@ String pluralize(String name, int number, {String plural}) {
|
|||||||
return '${name}s';
|
return '${name}s';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a bulleted list of items in [bullets].
|
||||||
|
String bulletedList(Iterable<String> 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].
|
/// Returns the number of times [codeUnit] appears in [string].
|
||||||
int countOccurrences(String string, int codeUnit) {
|
int countOccurrences(String string, int codeUnit) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user