Exemple #1
0
        public List <TableRecord> ParseFileCodeModel()
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            List <TableRecord> tableList = new List <TableRecord>();

            foreach (CodeElement2 codeElement in sourceItem.CodeElements)
            {
                /*Class*/
                if (codeElement.Kind == vsCMElement.vsCMElementClass)
                {
                    CodeClass2 classItem = codeElement as CodeClass2 ?? throw new ArgumentNullException();

                    List <TableRecord> classTRec = parseClass(classItem);
                    tableList.AddRange(classTRec);
                }
                /*Parse struct functions*/
                else if (codeElement.Kind == vsCMElement.vsCMElementStruct)
                {
                    CodeStruct2 structItem = codeElement as CodeStruct2 ?? throw new ArgumentNullException();

                    debugPane.OutputString("Struct methods: " + structItem.FullName + "\n");
                    foreach (CodeElement2 field in structItem.Members)
                    {
                        if (field.Kind == vsCMElement.vsCMElementFunction)
                        {
                            TableRecord structTRec = parseFuntion(field as CodeFunction2);
                            tableList.Add(structTRec);
                        }
                    }
                }
                /*Parse single functions*/
                else if (codeElement.Kind == vsCMElement.vsCMElementFunction)
                {
                    TableRecord funRec = parseFuntion(codeElement as CodeFunction2);
                    tableList.Add(funRec);
                }
            }

            return(tableList);
        }
Exemple #2
0
        public List <TableRecord> parseClass(CodeClass2 classItem)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            Dictionary <string, int> methodsDictionary = collectMethods(classItem);
            Dictionary <string, int> fieldsDictionary  = collectFields(classItem);


            List <TableRecord> tRecList         = new List <TableRecord>();
            TableRecord        classTableRecord = new TableRecord();

            classTableRecord.ItemName           = "Class " + classItem.FullName;
            classTableRecord.ClassMethodsAmount = "+ " + methodsDictionary["public"].ToString() + " | " +
                                                  "- " + methodsDictionary["private"].ToString() + " | " +
                                                  "# " + methodsDictionary["protected"].ToString();

            classTableRecord.ClassFieldsAmount = "+ " + fieldsDictionary["public"].ToString() + " | " +
                                                 "- " + fieldsDictionary["private"].ToString() + " | " +
                                                 "# " + fieldsDictionary["protected"].ToString();
            classTableRecord.KeyWordsAmount             = "-";
            classTableRecord.LinesAmount                = "-";
            classTableRecord.LinesAmountWithoutComments = "-";

            tRecList.Add(classTableRecord);

            foreach (CodeElement2 item in classItem.Members)
            {
                if (item.Kind == vsCMElement.vsCMElementFunction)
                {
                    CodeFunction2 codeFunction = item as CodeFunction2 ?? throw new ArgumentException();

                    /* Add table record to list. */
                    TableRecord funTRec = parseFuntion(codeFunction);
                    tRecList.Add(funTRec);
                }
            }

            return(tRecList);
        }
Exemple #3
0
        public TableRecord parseFuntion(CodeFunction2 funItem)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            if (funItem == null)
            {
                throw new ArgumentNullException("CodeFunction2 == null in parseFuntion");
            }

            TableRecord functionTRec = new TableRecord();

            string[] functionItems = getItemSourceCode(funItem as CodeElement2);

            string prototype    = functionItems[0];
            string implemention = functionItems[1];

            debugPane.OutputString("Parsing ---> " + prototype + "\n");

            int allLines = linesAmount(implemention);

            deleteComments(ref implemention);
            deleteEmptyStrings(ref implemention);

            int clearLines = linesAmount(implemention);

            int keyWords = keyWordsAmount(functionItems[1]);

            functionTRec.ItemName    = prototype;
            functionTRec.LinesAmount = allLines.ToString();
            functionTRec.LinesAmountWithoutComments = clearLines.ToString();
            functionTRec.KeyWordsAmount             = keyWords.ToString();
            functionTRec.ClassMethodsAmount         = "-";
            functionTRec.ClassFieldsAmount          = "-";

            //debugPane.OutputString(implemention.ToString() + "\n");

            return(functionTRec);
        }