Exemplo n.º 1
0
        private Clusters PrettyClusters(Clusters cs, ROInvertedHistogram ih, Graph graph)
        {
            var cs1 = ElideStringClusters(cs, ih, graph);
            var cs2 = ElideWhitespaceClusters(cs1, ih, graph);

            return(cs2);
        }
Exemplo n.º 2
0
        private Clusters ElideStringClusters(Clusters cs, ROInvertedHistogram ih, Graph graph)
        {
            var output = new HashSet <ImmutableHashSet <AST.Address> >();

            foreach (ImmutableHashSet <AST.Address> c in cs)
            {
                if (!c.All(a => EntropyModelBuilder2.AddressIsStringValued(a, ih, graph)))
                {
                    output.Add(c);
                }
            }

            return(output.ToImmutableHashSet());
        }
Exemplo n.º 3
0
        private void RegularityMap_Click(object sender, RibbonControlEventArgs e)
        {
            if (currentWorkbook.Analyze_Enabled)
            {
                // disable annoying OLE warnings
                Globals.ThisAddIn.Application.DisplayAlerts = false;

                // get dependence graph
                var graph = new Graph(Globals.ThisAddIn.Application, (Worksheet)Globals.ThisAddIn.Application.ActiveSheet);

                // get active sheet
                Worksheet activeWs = (Worksheet)Globals.ThisAddIn.Application.ActiveSheet;

                // get cells
                var cells = graph.allCells();

                // config
                var conf = getConfig();

                // get fingerprints
                // I am hard-coding the one feature here for now, since
                // I have removed all of the other ExceLint features
                var ns = CommonFunctions.runEnabledFeatures(cells, graph, conf, Progress.NOPProgress());
                var fs = ns["ShallowInputVectorMixedFullCVectorResultantOSI"];

                // cluster
                var cs = ClusterFingerprints(fs);

                // get inverted histogram
                var histo = CommonFunctions.invertedHistogram(ns, graph, conf);


                // filter out whitespace and string clusters
                var cs_filtered = PrettyClusters(cs, histo, graph);

                // in case we've run something before, restore colors
                currentWorkbook.restoreOutputColors();

                // save colors
                CurrentWorkbook.saveColors(activeWs);

                // paint formulas
                var colormap = currentWorkbook.DrawImmutableClusters(cs_filtered, histo, activeWs, graph, this.analyzeFormulas.Checked);

                // if checked, analyze data
                if (this.enableDataHighlight.Checked)
                {
                    // get formula usage for data cells
                    var referents = Vector.getReferentDict(graph);

                    // paint data
                    currentWorkbook.ColorDataWithMap(referents, colormap, graph);

                    // add data comments
                    currentWorkbook.labelReferents(referents);
                }

                // set UI state
                setUIState(currentWorkbook);
            }
            else
            {
                // clear
                currentWorkbook.restoreOutputColors();

                // set UI state
                setUIState(currentWorkbook);
            }
        }