Beispiel #1
0
        public static String populateGraphWithTreeNode(ref int iEdgeId, Graph gGraphToPopulate, TreeNode tnTreeNode,
                                                       bool bOrder, bool bFilterName, bool bOnlyShowClasses,
                                                       Int32 iShowClassesLevel,
                                                       bool bShowParameters, bool bShowReturnClass, bool bShowNamespace,
                                                       int iNamespaceDepth)
        {
            String sNormalizedName = FilteredSignature.filterName(tnTreeNode.Text, bShowParameters, bShowReturnClass,
                                                                  bShowNamespace, iNamespaceDepth, bFilterName,
                                                                  bOnlyShowClasses, iShowClassesLevel);

            if (sNormalizedName == "")
            {
                sNormalizedName = "[***Empty***]";
            }
            var nNode = (Node)gGraphToPopulate.AddNode(sNormalizedName);

            nNode.UserData   = tnTreeNode;
            nNode.Attr.Shape = Shape.Plaintext;

            String sNodeText_From = tnTreeNode.Text;

            foreach (TreeNode tnChild in tnTreeNode.Nodes)
            {
                String sNodeText_To = FilteredSignature.filterName(tnChild.Text, bShowParameters, bShowReturnClass,
                                                                   bShowNamespace, iNamespaceDepth, bFilterName,
                                                                   bOnlyShowClasses, iShowClassesLevel);
                if (sNodeText_From != sNodeText_To) // don't add edge if they are the same text
                {
                    addEdgeToGraph(gGraphToPopulate, sNodeText_From, sNodeText_To, (iEdgeId++).ToString());
                }
                sNodeText_From = populateGraphWithTreeNode(ref iEdgeId, gGraphToPopulate, tnChild, bOrder, bFilterName,
                                                           bOnlyShowClasses, iShowClassesLevel);

                // add the return value
                // need to find a way to not do this for sinks
                //         if (sNodeText_From != sNodeText_To)
                //         {
                //             addEdgeToGraph(gGraphToPopulate, sNodeText_From, sNodeText_To, (iEdgeId++).ToString());
                //             sNodeText_From = sNodeText_To;
                //         }

                /*
                 * String sMethodA = Analysis_CallFlow.display.filterName(tnChild.Text    , bShowParameters, bShowReturnClass, bShowNamespace, bFilterName, bOnlyShowClasses, iShowClassesLevel);
                 * String sMethodB = Analysis_CallFlow.display.filterName(tnTreeNode.Text , bShowParameters, bShowReturnClass, bShowNamespace, bFilterName, bOnlyShowClasses, iShowClassesLevel);
                 * if (bOrder)
                 *  addEdgeToGraph(gGraphToPopulate,sMethodA,sMethodB,true);
                 * else
                 *  addEdgeToGraph(gGraphToPopulate,sMethodB,sMethodA,false);
                 */
            }
            return(sNodeText_From);
        }
Beispiel #2
0
        //DC this version was using the old QuickGraph MarkedEdge
        public static void createGraphWizDotFile(AdjacencyGraph <String, TaggedEdge <String, String> > gGraphWizToPopulate,
                                                 TreeNode tnTreeNode, bool bOrder, bool bFilterName, bool bFilterClass,
                                                 int iFilterClassLevel)
        {
            if (bFilterClass)
            {
                tnTreeNode.Text = FilteredSignature.filterName(tnTreeNode.Text, false, false, true, 0, true, true,
                                                               iFilterClassLevel);
            }
            TaggedEdge <String, string> meTemp;

            if (gGraphWizToPopulate.ContainsVertex(tnTreeNode.Text))
            {
            }
            else
            {
                gGraphWizToPopulate.AddVertex(tnTreeNode.Text);
            }

            foreach (TreeNode tnChild in tnTreeNode.Nodes)
            {
                if (bFilterClass)
                {
                    tnChild.Text = FilteredSignature.filterName(tnChild.Text, false, false, true, 0, true, true,
                                                                iFilterClassLevel);
                }
                createGraphWizDotFile(gGraphWizToPopulate, tnChild, bOrder, bFilterName, bFilterClass, iFilterClassLevel);
                if (bOrder)
                {
                    if (false == gGraphWizToPopulate.TryGetEdge(tnTreeNode.Text, tnChild.Text, out meTemp))
                    {
                        gGraphWizToPopulate.AddEdge(new TaggedEdge <String, string>(tnTreeNode.Text, tnChild.Text,
                                                                                    "marker"));
                    }
                }
                else if (false == gGraphWizToPopulate.TryGetEdge(tnChild.Text, tnTreeNode.Text, out meTemp))
                {
                    gGraphWizToPopulate.AddEdge(new TaggedEdge <String, string>(tnChild.Text, tnTreeNode.Text, "marker"));
                }

                //gGraphToPopulate.AddEdge(tnTreeNode.Text, tnChild.Text);
                //    gGraphToPopulate.AddEdge(Analysis_CallFlow.display.filterName(tnChild.Text, false, false, false), Analysis_CallFlow.display.filterName(tnTreeNode.Text, false, false, false));
                //else
            }
        }
Beispiel #3
0
        public static void applyStylesAndFiltersToGraph(Graph gGraph, Shape sShape, O2AssessmentData_OunceV6 fadAssessmentDataOunceV6,
                                                        bool bLDDB_ShowInsideNode_MethodName, bool bGLEE_ShowParameters,
                                                        bool bGLEE_ShowReturnClass,
                                                        bool bGLEE_ShowNamespace, Int32 iNamespaceDepth,
                                                        bool bLDDB_ShowInsideNode_Context,
                                                        bool bLDDB_ShowInsideNode_SourceCode,
                                                        bool bGLEE_onlyShowDataForSourcesAndSinks)
        {
            Hashtable htNodes = gGraph.NodeMap;

            foreach (DictionaryEntry deNode in htNodes)
            {
                var nNode = (Node)deNode.Value;
                nNode.Attr.Shape = sShape;
                nNode.NodeAttribute.LabelMargin = 6; // give it some margin
                nNode.NodeAttribute.Fillcolor   = Color.White;
                if (bLDDB_ShowInsideNode_MethodName)
                {
                    nNode.Attr.Label = FilteredSignature.filterName(nNode.Attr.Label, bGLEE_ShowParameters,
                                                                    bGLEE_ShowReturnClass, bGLEE_ShowNamespace,
                                                                    iNamespaceDepth);
                }
                else
                {
                    if (false == bLDDB_ShowInsideNode_Context && false == bLDDB_ShowInsideNode_SourceCode)
                    {
                        makeEmptyNode(nNode);
                    }
                    else
                    {
                        nNode.Attr.Label = "";
                    }
                }

                var tnNodeData = (TreeNode)nNode.UserData;
                if (tnNodeData != null && tnNodeData.Tag != null)
                {
                    switch (tnNodeData.Tag.GetType().Name)
                    {
                    case "CallInvocation":
                        var ciCallInvocation = (CallInvocation)tnNodeData.Tag;


                        if (ciCallInvocation.cxt_id > 0)
                        {
                            // add context
                            if (bLDDB_ShowInsideNode_Context)
                            {
                                nNode.Attr.Label += Environment.NewLine + Environment.NewLine +
                                                    fadAssessmentDataOunceV6.arAssessmentRun.StringIndeces[
                                    ciCallInvocation.cxt_id - 1].value;
                            }
                            if (bLDDB_ShowInsideNode_SourceCode)
                            {
                                // add source code
                                AssessmentRunFileIndex arfiFile =
                                    fadAssessmentDataOunceV6.arAssessmentRun.FileIndeces[ciCallInvocation.fn_id - 1];
                                List <String> lsSourceCode = Files.loadSourceFileIntoList(arfiFile.value);
                                if (lsSourceCode.Count > 0 && lsSourceCode.Count > ciCallInvocation.line_number)
                                {
                                    nNode.Attr.Label += Environment.NewLine + Environment.NewLine +
                                                        getSourceCodeSnippet(lsSourceCode,
                                                                             (int)ciCallInvocation.line_number);
                                }
                            }
                            nNode.Attr.Label = nNode.Attr.Label.Trim();
                        }


                        if (nNode.Attr.Fontcolor != Color.Red)
                        {
                            switch (ciCallInvocation.trace_type)
                            {
                            case 1:         // Analysis.TraceType.Root_Call:
                                if (bGLEE_onlyShowDataForSourcesAndSinks)
                                {
                                    makeEmptyNode(nNode);
                                }
                                if (nNode.Attr.Fontcolor == Color.Black)
                                {
                                    // only change it if it has not been mapped before
                                    nNode.Attr.Fontcolor = nNode.Attr.Color = Color.DarkBlue;
                                }
                                break;

                            case 5:         // Analysis.TraceType.Lost_Sink:
                                nNode.Attr.Fontcolor = nNode.Attr.Color = Color.DarkOrange;
                                break;

                            case 2:         // Analysis.TraceType.Source:
                                nNode.Attr.Fontcolor = nNode.Attr.Color = Color.DarkRed;
                                break;

                            case 3:         // Analysis.TraceType.Known_Sink:
                                nNode.Attr.Fontcolor = nNode.Attr.Color = Color.Red;
                                break;

                            case 4:         // Analysis.TraceType._type_4:
                                if (bGLEE_onlyShowDataForSourcesAndSinks)
                                {
                                    makeEmptyNode(nNode);
                                }
                                nNode.Attr.Fontcolor = nNode.Attr.Color = Color.Green;
                                break;

                            default:
                                if (bGLEE_onlyShowDataForSourcesAndSinks)
                                {
                                    makeEmptyNode(nNode);
                                }
                                break;
                            }
                        }
                        break;

                    default:
                        //                        nNode.Attr.Label += " ***";
                        break;
                    }
                }
            }
        }