Пример #1
0
        //root - class body with fields and methods; node - class itself; src - whole source (with namespace)
        private void get_node_info_get_subnodes_and_methods(ParseTreeNode root, node_info node, string src)
        {
            List<node_field_info> subnodes = new List<node_field_info>();
            List<method_info> methods = new List<method_info>();

            var lines = src.Split('\n');
            var nodes = new List<node_info>();
            nodes.AddRange(node_gen.all_nodes.Cast<node_info>());

            for (int i = 0; i < root.ChildNodes.Count; i++)
            {
                HelpContext help_context = null;
                if (root.ChildNodes[i].Term.Name == "field_declaration")
                {
                    var subnode_type = get_node_info_get_subnode_type(root.ChildNodes[i], src);
                    var subnode = nodes.Find(x => x.node_name == subnode_type);

                    if (subnode == null)
                        subnodes.Add(new extended_simple_element()
                        {
                            val_field_type_name = subnode_type,
                            field_name = get_node_info_get_subnode_name(root.ChildNodes[i]),
                            create_var = get_node_info_has_constructor(root.ChildNodes[i]) // lines[root.ChildNodes[i].Span.Location.Line].Contains("new List")
                        });
                    else
                        subnodes.Add(new node_field_info()
                        {
                            field_name = get_node_info_get_subnode_name(root.ChildNodes[i]),
                            field_type = subnode
                        });

                    help_context = node_gen.help_storage.get_help_context(node.node_name + "." + subnodes[subnodes.Count - 1].field_name);
                }
                else
                    if (root.ChildNodes[i].Term.Name == "constructor_declaration" || root.ChildNodes[i].Term.Name == "method_declaration")
                    {
                        methods.Add(new method_info(src.Substring(root.ChildNodes[i].Span.Location.Position, root.ChildNodes[i].Span.Length)));
                        help_context = node_gen.help_storage.get_help_context(node.node_name + "." + methods[methods.Count - 1].method_header);
                    }
                else continue;

                //help context
                help_context.help_context = "";
                int help_cur_line = root.ChildNodes[i].Span.Location.Line - 1;
                while (lines[help_cur_line].Length > 2 && lines[help_cur_line].Substring(0, 2) == "//")
                {
                    help_context.help_context = lines[help_cur_line].Substring(2, lines[help_cur_line].Length - 2).Trim() + help_context.help_context;
                    help_cur_line--;
                }
            }

            node.set_subnodes(subnodes);
            node.set_methods(methods);
        }