Check all dependencies for an assembly before throwing an exception (if any is required)

This commit is contained in:
Sam Harwell 2013-03-11 22:39:22 -05:00
parent 8048f58b57
commit 451e562a34
1 changed files with 8 additions and 7 deletions

View File

@ -57,15 +57,16 @@ namespace Antlr4.Runtime.Misc
{ {
return; return;
} }
IList<Type> typesToCheck = GetTypesToCheck(assembly); IList<Type> typesToCheck = GetTypesToCheck(assembly);
List<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>> dependencies = new List<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>();
foreach (Type clazz in typesToCheck) foreach (Type clazz in typesToCheck)
{ {
IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>> dependencies = GetDependencies(clazz dependencies.AddRange(GetDependencies(clazz));
); }
if (dependencies.Count == 0)
{ if (dependencies.Count > 0)
continue; {
}
IDictionary<Type, IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>> recognizerDependencies IDictionary<Type, IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>> recognizerDependencies
= new Dictionary<Type, IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>>(); = new Dictionary<Type, IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>>();
foreach (Tuple<RuleDependencyAttribute, ICustomAttributeProvider> dependency in dependencies) foreach (Tuple<RuleDependencyAttribute, ICustomAttributeProvider> dependency in dependencies)
@ -79,13 +80,13 @@ namespace Antlr4.Runtime.Misc
} }
list.Add(dependency); list.Add(dependency);
} }
foreach (KeyValuePair<Type, IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>> entry foreach (KeyValuePair<Type, IList<Tuple<RuleDependencyAttribute, ICustomAttributeProvider>>> entry
in recognizerDependencies) in recognizerDependencies)
{ {
//processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, String.format("ANTLR 4: Validating {0} dependencies on rules in {1}.", entry.getValue().size(), entry.getKey().toString())); //processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, String.format("ANTLR 4: Validating {0} dependencies on rules in {1}.", entry.getValue().size(), entry.getKey().toString()));
CheckDependencies(entry.Value, entry.Key); CheckDependencies(entry.Value, entry.Key);
} }
CheckDependencies(dependencies, dependencies[0].Item1.Recognizer);
} }
MarkChecked(assembly); MarkChecked(assembly);