Пример #1
0
        public static void Show(Context context, SelectMethodDialog form)
        {
            string selectedProject = form.ComboBox1.SelectedItem.ToString();

            CodeFunctionProject cfp = null;

            for (int i = 0; i < form.CodeFunctions.Count; i++)
            {
                cfp = (CodeFunctionProject)form.CodeFunctions[i];
                if (cfp.Project.Equals(selectedProject))
                {
                    break;
                }
            }
            context.markMethod(cfp.Function);
            form.Activate();
        }
Пример #2
0
        public static void Load(SelectMethodDialog form)
        {
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.MinimizeBox     = false;
            form.MaximizeBox     = false;
            form.ShowButton.Focus();
            form.Label1.Text = "The method " + '"' + form.MethodName + '"' + " was found " + form.CodeFunctions.Count + " times in the current solution";
            for (int i = 0; i < form.CodeFunctions.Count; i++)
            {
                CodeFunctionProject cfp = (CodeFunctionProject)form.CodeFunctions[i];
                form.ComboBox1.Items.Add(cfp.Project);
            }
            form.ComboBox1.SelectedIndex = 0;
            string link = "http://www.dynatrace.com";

            form.LinkLabel1.Links.Add(0, link.Length, link);
        }
Пример #3
0
        internal bool goToMethod(Lookup lookup)
        {
            try
            {
                log(String.Format(Context.LOG_INFO + "goToMethod({0})", lookup.ToString()));

                // fetch projects also from Solution Folders
                List <Project> projects = GetProjects(dte.Solution);

                ArrayList hits = getMethod(lookup, projects);
                if (hits.Count == 1)
                {
                    CodeFunctionProject cfp          = (CodeFunctionProject)hits[0];
                    CodeFunction        codeFunction = cfp.Function;
                    if (codeFunction != null)
                    {
                        markMethod(codeFunction);
                        return(true);
                    }
                }
                else if (hits.Count > 1)
                {
                    SelectMethodDialog cf = new SelectMethodDialog(this, hits, lookup.methodName);
                    cf.ShowDialog();
                    return(true);
                }
                else
                {
                    return(markType(lookup, dte.Solution.Projects));
                }
                return(false);
            }
            catch (Exception e)
            {
                log(Context.LOG_ERROR + e.ToString());
                return(false);
            }
        }
Пример #4
0
        /// <summary>scan every project of the solution about the search method, and returned ArrayList which contains every hit, returns an empty ArrayList if nothing is found</summary>
        /// <param term='lookup'>is a wrapper for all lookup informations.</param>
        /// <param term='projects'>a list of all projects in the solution.</param>
        public ArrayList getMethod(Lookup lookup, List <Project> projects)
        {
            log(String.Format(Context.LOG_INFO + "getMethod called on {0} projects", projects == null ? 0 : projects.Count));

            CodeFunction        codeFunction  = null;
            ArrayList           codeFunctions = new ArrayList();
            CodeClass2          codeClass     = null;
            CodeFunctionProject cfp           = null;

            foreach (Project p in projects)
            {
                log(String.Format(Context.LOG_INFO + "getMethod working on project {0} - ProjectType is {1}", p.Name, DynaTrace.CodeLink.Context.DecodeProjectKind(p.Kind)));
                try
                {
                    if (p.CodeModel != null)
                    {
                        try
                        {
                            // search in the complete codeModel of the project after the required class

                            codeClass = (CodeClass2)p.CodeModel.CodeTypeFromFullName(lookup.typeName);

                            log(String.Format(Context.LOG_INFO + "getMethod CodeTypeFromFullName({0}) returns {1}", lookup.typeName, codeClass == null ? "null" : codeClass.Name));

                            if (codeClass != null)
                            {
                                codeFunction = getMethod(codeClass, lookup.parameters, false, lookup.methodName);
                                // if the codeFunction is null maybe we can find it in the partial class
                                if (codeFunction == null)
                                {
                                    try
                                    {
                                        if ((codeClass.Parts != null) && (codeClass.Parts.Count != 0))
                                        {
                                            codeFunction = getMethod(codeClass, lookup.parameters, true, lookup.methodName);
                                        }
                                    }
                                    catch (System.Runtime.InteropServices.COMException)
                                    {
                                        // access to codeClass.Parts.Count may throw COMException
                                    }
                                }

                                if (codeFunction != null)
                                {
                                    // Check, if the codeFunction returned can also be opened.
                                    try
                                    {
                                        object test = codeClass.ProjectItem;
                                        test = codeFunction.ProjectItem;
                                        cfp  = new CodeFunctionProject(p.Name, codeFunction);
                                        codeFunctions.Add(cfp);
                                    }
                                    catch (System.Runtime.InteropServices.COMException) { }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            log(Context.LOG_ERROR + e.ToString());
                        }
                    }
                    else
                    {
                        log(String.Format(Context.LOG_INFO + "Project {0} has no CodeModel - ProjectType is {1}", p.Name, DynaTrace.CodeLink.Context.DecodeProjectKind(p.Kind)));
                        if (p != null)
                        {
                            logProjectData(p);
                        }
                    }
                }
                catch (NotImplementedException)
                {
                    log(String.Format(Context.LOG_INFO + "Project {0} - No CodeModel Implemented - ProjectType is {1}", p.Name, DynaTrace.CodeLink.Context.DecodeProjectKind(p.Kind)));
                    if (p != null)
                    {
                        logProjectData(p);
                    }
                }
            }
            return(codeFunctions);
        }