Esempio n. 1
0
        private List<ChangedMethod> FindDeletedMethods(string[] updatedContents, FileContents originalContents)
        {
            List<ChangedMethod> originalMethods = new List<ChangedMethod>();
            for (int i = 0; i < originalContents.Contents.Length; i++)
            {
                string originalLine = originalContents.Contents[i].Trim();

                if (IsLineMethodDefinition(originalLine))
                {
                    ChangedMethod changedLine = GetNamespaceClassMethodOfChangedLine(i, originalContents.Contents);
                    changedLine.Status = ChangedContentStatus.Delete;
                    originalMethods.Add(changedLine);
                }
            }

            for (int i = 0; i < updatedContents.Length; i++)
            {
                string updatedLine = updatedContents[i].Trim();

                if (IsLineMethodDefinition(updatedLine))
                {
                    var definitionPart = GetNamespaceClassMethodOfChangedLine(i, updatedContents);

                    if (originalMethods.Contains(definitionPart))
                        originalMethods.Remove(definitionPart);
                }
            }

            return originalMethods;
        }
Esempio n. 2
0
        private IEnumerable<ChangedMethod> FindChangedLines(string[] updatedContents, FileContents originalContents)
        {
            List<ChangedMethod> list = new List<ChangedMethod>();
            for (int index = 0; index < originalContents.Contents.Length; index++)
            {
                if (updatedContents.Length == index)
                    break;

                var updatedContent = updatedContents[index];
                var originalContent = originalContents.Contents[index];

                if (updatedContent != originalContent)
                {
                    var changedContents = GetNamespaceClassMethodOfChangedLine(index, updatedContents);
                    if (changedContents != null)
                    {
                        changedContents.Status = ChangedContentStatus.Updated;
                        list.Add(changedContents);
                    }
                }
            }

            if (updatedContents.Length > originalContents.Contents.Length)
                list.AddRange(FindNewMethods(updatedContents, originalContents.Contents.Length));

            if (originalContents.Contents.Length > updatedContents.Length)
                list.AddRange(FindDeletedMethods(updatedContents, originalContents));

            return list;
        }