private static ClassHierarchyProto.Node NewClassNode(String name, String fullName, bool isInjectionCandidate, bool isExternalConstructor, bool isUnit, IList <ClassHierarchyProto.ConstructorDef> injectableConstructors, IList <ClassHierarchyProto.ConstructorDef> otherConstructors, IList <String> implFullNames, IList <ClassHierarchyProto.Node> children) { ClassHierarchyProto.ClassNode classNode = new ClassHierarchyProto.ClassNode(); classNode.is_injection_candidate = isInjectionCandidate; foreach (var ic in injectableConstructors) { classNode.InjectableConstructors.Add(ic); } foreach (var oc in otherConstructors) { classNode.OtherConstructors.Add(oc); } foreach (var implFullName in implFullNames) { classNode.impl_full_names.Add(implFullName); } ClassHierarchyProto.Node n = new ClassHierarchyProto.Node(); n.name = name; n.full_name = fullName; n.class_node = classNode; foreach (var c in children) { n.children.Add(c); } return(n); }
private void WireUpInheritanceRelationships(ClassHierarchyProto.Node n) { if (n.class_node != null) { ClassHierarchyProto.ClassNode cn = n.class_node; IClassNode iface = null; try { iface = (IClassNode)GetNode(n.full_name); } catch (NameResolutionException e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new IllegalStateException("When reading protocol buffer node " + n.full_name + " does not exist. Full record is " + n, e); Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } foreach (String impl in cn.impl_full_names) { try { iface.PutImpl((IClassNode)GetNode(impl)); } catch (NameResolutionException e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); var ex = new IllegalStateException("When reading protocol buffer node " + n + " refers to non-existent implementation:" + impl); Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } catch (InvalidCastException e) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, LOGGER); try { var ex = new IllegalStateException( "When reading protocol buffer node " + n + " found implementation" + GetNode(impl) + " which is not a ClassNode!"); Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } catch (NameResolutionException ne) { Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Caught(ne, Level.Error, LOGGER); var ex = new IllegalStateException( "Got 'cant happen' exception when producing error message for " + e); Org.Apache.Reef.Utilities.Diagnostics.Exceptions.Throw(ex, LOGGER); } } } } }
private static void ParseSubHierarchy(INode parent, ClassHierarchyProto.Node n) { INode parsed; if (n.package_node != null) { parsed = new PackageNodeImpl(parent, n.name, n.full_name); } else if (n.named_parameter_node != null) { ClassHierarchyProto.NamedParameterNode np = n.named_parameter_node; parsed = new NamedParameterNodeImpl(parent, n.name, n.full_name, np.full_arg_class_name, np.simple_arg_class_name, np.is_set, np.documentation, np.short_name, np.instance_default.ToArray()); } else if (n.class_node != null) { ClassHierarchyProto.ClassNode cn = n.class_node; IList <IConstructorDef> injectableConstructors = new List <IConstructorDef>(); IList <IConstructorDef> allConstructors = new List <IConstructorDef>(); foreach (ClassHierarchyProto.ConstructorDef injectable in cn.InjectableConstructors) { IConstructorDef def = ParseConstructorDef(injectable, true); injectableConstructors.Add(def); allConstructors.Add(def); } foreach (ClassHierarchyProto.ConstructorDef other in cn.OtherConstructors) { IConstructorDef def = ParseConstructorDef(other, false); allConstructors.Add(def); } IConstructorDef[] dummy = new ConstructorDefImpl[0]; parsed = new ClassNodeImpl(parent, n.name, n.full_name, cn.is_unit, cn.is_injection_candidate, cn.is_external_constructor, injectableConstructors, allConstructors, cn.default_implementation); } else { throw new IllegalStateException("Bad protocol buffer: got abstract node" + n); } foreach (ClassHierarchyProto.Node child in n.children) { ParseSubHierarchy(parsed, child); } }
private void WireUpInheritanceRelationships(ClassHierarchyProto.Node n) { if (n.class_node != null) { ClassHierarchyProto.ClassNode cn = n.class_node; IClassNode iface; try { iface = (IClassNode)GetNode(n.full_name); } catch (NameResolutionException e) { throw new IllegalStateException("When reading protocol buffer node " + n.full_name + " does not exist. Full record is " + n, e); } foreach (String impl in cn.impl_full_names) { try { iface.PutImpl((IClassNode)GetNode(impl)); } catch (NameResolutionException e) { throw new IllegalStateException("When reading protocol buffer node " + n + " refers to non-existent implementation:" + impl); } catch (InvalidCastException e) { try { throw new IllegalStateException( "When reading protocol buffer node " + n + " found implementation" + GetNode(impl) + " which is not a ClassNode!"); } catch (NameResolutionException e2) { throw new IllegalStateException( "Got 'cant happen' exception when producing error message for " + e); } } } } }
private static ClassHierarchyProto.Node NewClassNode(String name, String fullName, bool isInjectionCandidate, bool isExternalConstructor, bool isUnit, IList<ClassHierarchyProto.ConstructorDef> injectableConstructors, IList<ClassHierarchyProto.ConstructorDef> otherConstructors, IList<String> implFullNames, IList<ClassHierarchyProto.Node> children) { ClassHierarchyProto.ClassNode classNode = new ClassHierarchyProto.ClassNode(); classNode.is_injection_candidate = isInjectionCandidate; foreach (var ic in injectableConstructors) { classNode.InjectableConstructors.Add(ic); } foreach (var oc in otherConstructors) { classNode.OtherConstructors.Add(oc); } foreach (var implFullName in implFullNames) { classNode.impl_full_names.Add(implFullName); } ClassHierarchyProto.Node n = new ClassHierarchyProto.Node(); n.name = name; n.full_name = fullName; n.class_node = classNode; foreach (var c in children) { n.children.Add(c); } return n; }