Implement SemanticContext.FilterPrecedencePredicates

This commit is contained in:
Sam Harwell 2013-02-19 18:46:02 -06:00
parent 0c97547a7e
commit 115b4736ed
1 changed files with 6 additions and 20 deletions

View File

@ -386,27 +386,13 @@ namespace Antlr4.Runtime.Atn
} }
private static IList<SemanticContext.PrecedencePredicate> FilterPrecedencePredicates private static IList<SemanticContext.PrecedencePredicate> FilterPrecedencePredicates
<_T0>(ICollection<_T0> collection) where _T0:SemanticContext (ISet<SemanticContext> collection)
{ {
List<SemanticContext.PrecedencePredicate> result = null; if (!collection.OfType<PrecedencePredicate>().Any())
for (IEnumerator<SemanticContext> iterator = collection.GetEnumerator(); iterator Collections.EmptyList<PrecedencePredicate>();
.HasNext(); )
{ List<PrecedencePredicate> result = collection.OfType<PrecedencePredicate>().ToList();
SemanticContext context = iterator.Next(); collection.ExceptWith(result);
if (context is SemanticContext.PrecedencePredicate)
{
if (result == null)
{
result = new List<SemanticContext.PrecedencePredicate>();
}
result.Add((SemanticContext.PrecedencePredicate)context);
iterator.Remove();
}
}
if (result == null)
{
return Collections.EmptyList<PrecedencePredicate>();
}
return result; return result;
} }
} }