Esempio n. 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);
            }
        }
Esempio n. 2
0
        public override bool Equals(Object o)
        {
            SourceCodeEntity e = o
                                 as SourceCodeEntity;

            if (e == null)
            {
                return(false);
            }
            else
            {
                // Compare fieldwise.
                return((Type == e.Type) &&
                       (DotFullyQualifiedName == e.DotFullyQualifiedName));
            }
        }
Esempio n. 3
0
 private static bool isInEntity(GazeData gd, SourceCodeEntity sce)
 {
     if (gd.line > sce.LineStart && gd.line < sce.LineEnd)
     {
         return(true);
     }
     else if (gd.line == sce.LineStart)
     {
         return(gd.col >= sce.ColumnStart);
     }
     else if (gd.line == sce.LineEnd)
     {
         return(gd.col <= sce.ColumnEnd);
     }
     else
     {
         return(false);
     }
 }