コード例 #1
0
        private static void collectEntitiesByType(SourceCodeEntitiesFile scef,
                                                  XPathNavigator navigator, string srcml_name, SourceCodeEntityType type,
                                                  string name_xpath, Dictionary <string, string> parent_names)
        {
            XPathNodeIterator iterator = (XPathNodeIterator)navigator.Evaluate(
                "//*[local-name() = '" + srcml_name + "']");

            while (iterator.MoveNext())
            {
                XPathNavigator     element  = iterator.Current;
                EntityPositionInfo position = getEntityPosition(element);

                string            name        = "";
                XPathNodeIterator search_name = (XPathNodeIterator)
                                                element.Evaluate(name_xpath);
                if (search_name.MoveNext())
                {
                    name = search_name.Current.Value;
                }

                Stack <string> fully_qualified_name = new Stack <string>();
                while (element.MoveToParent())
                {
                    if (parent_names.ContainsKey(element.Name))
                    {
                        search_name =
                            (XPathNodeIterator)element.Evaluate(parent_names[element.Name]);
                        if (search_name.MoveNext())
                        {
                            fully_qualified_name.Push(search_name.Current.Value);
                        }
                    }
                }

                SourceCodeEntity sce = new SourceCodeEntity();
                sce.LineStart   = position.line_start;
                sce.LineEnd     = position.line_end;
                sce.ColumnStart = position.col_start;
                sce.ColumnEnd   = position.col_end;
                sce.Type        = type;
                sce.Name        = name;
                while (fully_qualified_name.Count > 0)
                {
                    sce.FullyQualifiedName.Add(fully_qualified_name.Pop());
                }

                sce.parent_file = scef;
                scef.Add(sce);
            }
        }