Esempio n. 1
0
    public static void Main(string[] args)
    {
        if (args.Length < 2)
        {
            Console.WriteLine("You must provide the source directory and at least " +
                              "one gaze file to run this program.");
            return;
        }

        string        source_directory = args[0];
        List <string> gaze_files       = new List <string>();

        for (int i = 1; i < args.Length; ++i)
        {
            gaze_files.Add(args[i]);
        }

        Config config = new Config();
        SourceCodeEntitiesFileCollection source_info = SrcMLCodeReader.run(
            config.src2srcml_path, source_directory);
        List <GazeResults> gaze_results = GazeReader.run(gaze_files);

        for (int i = 0; i < gaze_results.Count; ++i)
        {
            GazeResults cur_gaze_results = gaze_results[i];
            string      cur_filename     = gaze_files[i];

            GazeSourceRelationship gsr = GazeToSource.run(cur_gaze_results,
                                                          source_info);
            gsr.writeSqlite(cur_filename + ".sql");
        }
    }
Esempio n. 2
0
    public static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("USAGE: Provide a gaze file as the first argument.");
            return;
        }

        GazeResults gaze_results = GazeReader.run(new List <string> {
            args[0]
        })[0];

        Stack <string> source_filenames = new Stack <string>();

        foreach (GazeData gaze_data in gaze_results.gazes)
        {
            if (source_filenames.Count == 0)
            {
                source_filenames.Push(gaze_data.filename);
            }
            else
            {
                if (source_filenames.Peek() != gaze_data.filename)
                {
                    source_filenames.Push(gaze_data.filename);
                }
            }
        }

        Stack <string> backstack = new Stack <string>();

        while (source_filenames.Count > 0)
        {
            backstack.Push(source_filenames.Pop());
        }

        Console.WriteLine("Results:");
        while (backstack.Count > 0)
        {
            Console.WriteLine(" - " + backstack.Pop());
        }
    }
Esempio n. 3
0
    public static void Main(string[] args)
    {
        GazeResults gaze_results = GazeReader.run(
            new List <string> {
            "data/gazedata1.xml"
        })[0];

        foreach (GazeData gaze_data in gaze_results.gazes)
        {
            foreach (PropertyDescriptor descriptor in TypeDescriptor.
                     GetProperties(gaze_data))
            {
                Console.Write("{0}={1}; ", descriptor.Name,
                              descriptor.GetValue(gaze_data));
            }
            Console.WriteLine("");
        }

        Config config = new Config();
        SourceCodeEntitiesFileCollection collection = SrcMLCodeReader.run(
            config.src2srcml_path, "data/java/");

        foreach (SourceCodeEntitiesFile file in collection)
        {
            Console.WriteLine(file.FileName + ":");
            foreach (SourceCodeEntity entity in file)
            {
                Console.Write(" - ");
                foreach (PropertyDescriptor descriptor in TypeDescriptor.
                         GetProperties(entity))
                {
                    Console.Write("{0}={1}; ", descriptor.Name,
                                  descriptor.GetValue(entity));
                }
                Console.WriteLine("");
            }
        }
    }
Esempio n. 4
0
// 2013-11-08 TRS: First commit with basic functionality. Uses GraphViz
//   for rendering graphs to human-viewable form. Only minimal
//   processing is implemented, i.e. scale timestamp-based weights
//   into [0.0, 1.0] and remove links lighter than 1%.
// 2013-11-13 TRS: Adjusted processing so that new links are initialized
//   to t^2 and repeat links get t added. Postprocessing now scales and
//   applies a highpass filter at 90%. Also, filenames are now inlcuded
//   in the nodes; thanks Braden.
//   TODO:
//     - Make the DOT files prettier, e.g. different node styles for
//       different types.
//     - Improve/tune postprocessing.
//     - Add functional-style utilities (I love lisps).

    // Including classes tends to blow everyone else
    // away since classes contain everything but get
    // parsed in the same way; including comments and,
    // to a lesser extent, attributes makes the
    // graph noisy.
//	private static SourceCodeEntityType[] EXCLUDED_TYPES = {
//			SourceCodeEntityType.COMMENT,
//			SourceCodeEntityType.CLASS,
//			//SourceCodeEntityType.ATTRIBUTE,
//			//SourceCodeEntityType.METHOD,
//		};

    public static Dictionary <EntityLink, double> gen_graph(
        GazeResults gaze_results, SourceCodeEntitiesFileCollection collection)
    {
        Dictionary <EntityLink, double> src2src_links =
            new Dictionary <EntityLink, double> ();
        HashSet <SourceCodeEntity> previous = null;
        HashSet <SourceCodeEntity> current  = new HashSet <SourceCodeEntity>();

        foreach (GazeData gaze_data in gaze_results.gazes)
        {
            // find out which SourceCodeEntity the subject
            // was looking at for this GazeData
            foreach (SourceCodeEntitiesFile file in collection)
            {
                if (gaze_data.filename != file.FileName)
                {
                    continue;
                }
                foreach (SourceCodeEntity entity in file)
                {
                    // if this GazeData looks at an ignored type, skip
//					if (((IList<SourceCodeEntityType>) EXCLUDED_TYPES).Contains(
//							entity.Type)) {
//						continue;
//					}
                    // Sorry about the ugliness, but I hate code
                    // duplication more than this; i"1.0" encoding=t should be
                    // write-only, anyway.
                    if (((gaze_data.line > entity.LineStart) &&
                         (gaze_data.line < entity.LineEnd)) ||
                        ((gaze_data.line == entity.LineStart) &&
                         (gaze_data.col >= entity.ColumnStart)) ||
                        ((gaze_data.line == entity.LineEnd) &&
                         (gaze_data.col <= entity.ColumnEnd)))
                    {
                        current.Add(entity);
                        //break;
                    }
                }
            }
            // if there was a change of entity, make a note of it
            if ((current != previous) &&
                (previous != null) &&
                (previous.Count > 0) &&
                (current.Count > 0))
            {
                EntityLink link = new EntityLink();
                link.left  = new HashSet <SourceCodeEntity> (previous);
                link.right = new HashSet <SourceCodeEntity> (current);
                if (src2src_links.ContainsKey(link))
                {
                    //src2src_links [link] += Math.Pow (gaze_data.timestamp, 2.0);
                    src2src_links [link] += Math.Pow(100, gaze_data.timestamp);
                }
                else
                {
                    //src2src_links [link] = Math.Pow (gaze_data.timestamp, 2.0);
                    src2src_links [link] = Math.Pow(100, gaze_data.timestamp);
                }
            }
            previous = current;
            current  = new HashSet <SourceCodeEntity> ();
        }

        return(src2src_links);
    }