@@ -85,7 +85,7 @@ int byFeatureOrdering(String a, String b) {
8585 return compareAsciiLowerCaseNatural (a, b);
8686}
8787
88- final RegExp _locationSplitter = new RegExp (r"(package:|[\\/;.])" );
88+ final RegExp locationSplitter = new RegExp (r"(package:|[\\/;.])" );
8989
9090/// Mixin for subclasses of ModelElement representing Elements that can be
9191/// inherited from one class to another.
@@ -2152,6 +2152,7 @@ ModelElement resolveMultiplyInheritedElement(
21522152/// ModelElement will reference itself as part of the "wrong" [Library]
21532153/// from the public interface perspective.
21542154abstract class ModelElement extends Nameable
2155+ with Warnable
21552156 implements Comparable , Documentable {
21562157 final Element _element;
21572158 final Library _library;
@@ -2325,14 +2326,6 @@ abstract class ModelElement extends Nameable
23252326 return library.package.libraryElementReexportedBy[this .element.library];
23262327 }
23272328
2328- Set <String > get locationPieces {
2329- return new Set ()
2330- ..addAll (element.location
2331- .toString ()
2332- .split (_locationSplitter)
2333- .where ((s) => s.isNotEmpty));
2334- }
2335-
23362329 // Use components of this element's location to return a score for library
23372330 // location.
23382331 ScoredCandidate scoreElementWithLibrary (Library lib) {
@@ -3318,7 +3311,7 @@ abstract class Nameable {
33183311 String get name;
33193312
33203313 Set <String > get namePieces => new Set ()
3321- ..addAll (name.split (_locationSplitter ).where ((s) => s.isNotEmpty));
3314+ ..addAll (name.split (locationSplitter ).where ((s) => s.isNotEmpty));
33223315}
33233316
33243317class Operator extends Method {
@@ -3379,7 +3372,7 @@ class Operator extends Method {
33793372 String get typeName => 'operator' ;
33803373}
33813374
3382- class Package extends Nameable implements Documentable {
3375+ class Package extends Nameable with Documentable , Warnable {
33833376 // Library objects serving as entry points for documentation.
33843377 final List <Library > _libraries = [];
33853378
@@ -3483,10 +3476,30 @@ class Package extends Nameable implements Documentable {
34833476 extendedDebug: extendedDebug);
34843477 }
34853478
3479+ final Set <Tuple3 <Element , PackageWarning , String >> _warnAlreadySeen =
3480+ new Set ();
34863481 void warnOnElement (Warnable warnable, PackageWarning kind,
34873482 {String message,
34883483 Iterable <Locatable > referredFrom,
34893484 Iterable <String > extendedDebug}) {
3485+ var newEntry = new Tuple3 (warnable? .element, kind, message);
3486+ if (_warnAlreadySeen.contains (newEntry)) {
3487+ return ;
3488+ }
3489+ // Warnings can cause other warnings. Queue them up via the stack but
3490+ // don't allow warnings we're already working on to get in there.
3491+ _warnAlreadySeen.add (newEntry);
3492+ _warnOnElement (warnable, kind,
3493+ message: message,
3494+ referredFrom: referredFrom,
3495+ extendedDebug: extendedDebug);
3496+ _warnAlreadySeen.remove (newEntry);
3497+ }
3498+
3499+ void _warnOnElement (Warnable warnable, PackageWarning kind,
3500+ {String message,
3501+ Iterable <Locatable > referredFrom,
3502+ Iterable <String > extendedDebug}) {
34903503 if (warnable != null ) {
34913504 // This sort of warning is only applicable to top level elements.
34923505 if (kind == PackageWarning .ambiguousReexport) {
0 commit comments