Exemplo n.º 1
0
        private void method10()
        {
            try
            {
                DirectoryInfo directoryInfo           = new DirectoryInfo(Path);
                int           minSimilarityLineLength = Options.MinSimilarityLineLength;
                FileInfo[]    files          = directoryInfo.GetFiles(Options.FileSearchPattern, SearchOption.AllDirectories);
                int           num            = 0;
                List <Regex>  excludeRegexes = Options.GetExcludeRegexes();
                FileInfo[]    array          = files;
                int           i = 0;
IL_98:

                while (i < array.Length)
                {
                    FileInfo fileInfo = array[i];
                    bool     flag     = false;

                    for (int j = 0; j < excludeRegexes.Count; j++)
                    {
                        if (excludeRegexes[j].IsMatch(fileInfo.FullName))
                        {
                            flag = true;
                            //IL_87:
                            if (!flag)
                            {
                                num++;
                            }
                            i++;
                            goto IL_98;
                        }
                    }
                    //goto IL_87;
                }

                if (num == 0)
                {
                    AlertAction("No " + Options.FileSearchPattern + " Files Found");
                    Done();
                }
                else
                {
                    UpdateProgressAction(0, num, "Loading Files...");
                    CodeDir codeDir = method4(directoryInfo, Options.MinSimilarityLineLength, "");
                    RootDirectories.Add(codeDir);
                    ObservableCollection <CodeFile> codeFiles = Files;
                    UpdateProgressAction(0, codeFiles.Count * codeFiles.Count / 2, "Comparing Files...");
                    int           num2          = 0;
                    StringBuilder stringBuilder = new StringBuilder();

                    for (int j = 0; j < codeFiles.Count; j++)
                    {
                        CodeFile codeFile = codeFiles[j];

                        for (int k = j; k < codeFiles.Count; k++)
                        {
                            num2++;

                            if (num2 % 500 == 0)
                            {
                                this.UpdateProgressValue(num2);
                            }

                            try
                            {
                                CodeFile     codeFile_    = codeFiles[k];
                                AllSequences allSequences = Analysis.smethod1(codeFile, codeFile_, minSimilarityLineLength);

                                foreach (Sequence sequence in allSequences.Sequences)
                                {
                                    Analysis.smethod4(codeFile, codeFile_, sequence);
                                }
                                goto IL_24D;
                            }
                            catch (Exception ex)
                            {
                                stringBuilder.AppendLine(codeFile.Name + " - " + codeFiles[k].Name);
                                goto IL_24D;
                            }
                            break;
                            IL_24D :;
                        }

                        codeFile.method1();
                        codeFile.Similarities.Sort(new Comparison <Similarity>(Analysis.CompareSimilarities));
                    }

                    method2(codeDir);
                    method3();
                    method7();

                    if (stringBuilder.Length > 0)
                    {
                        this.AlertAction("Atomiq experienced an error with the following file combinations: " + stringBuilder.ToString());
                    }

                    bool0 = true;
                    Done();
                }
            }
            catch (Exception ex)
            {
                if (!(ex is ThreadAbortException))
                {
                    CaughtException = ex;
                }

                Done();
            }
        }
Exemplo n.º 2
0
        private CodeDir method4(DirectoryInfo directoryInfo, int int2, string string1)
        {
            CodeDir codeDir = new CodeDir
            {
                Path = directoryInfo.FullName,
                Name = directoryInfo.Name
            };

            string1 = string1 + "\\" + directoryInfo.Name;
            DirectoryInfo[] directories = directoryInfo.GetDirectories();

            for (int i = 0; i < directories.Length; i++)
            {
                DirectoryInfo directoryInfo_ = directories[i];
                CodeDir       codeDir2       = method4(directoryInfo_, int2, string1);

                if (codeDir2 != null)
                {
                    codeDir2.DirectParent = codeDir;
                    codeDir.Directories.Add(codeDir2);
                    codeDir.ItemCollection.Add(codeDir2);
                }
            }

            List <Regex> excludeRegexes = Options.GetExcludeRegexes();

            FileInfo[] files = directoryInfo.GetFiles(Options.FileSearchPattern, SearchOption.TopDirectoryOnly);

            for (int i = 0; i < files.Length; i++)
            {
                FileInfo fileInfo = files[i];
                bool     flag     = false;

                for (int j = 0; j < excludeRegexes.Count; j++)
                {
                    if (excludeRegexes[j].IsMatch(fileInfo.FullName))
                    {
                        flag = true;
                    }
                }

                if (!flag)
                {
                    IncrementProgressValue();
                    string code = null;

                    using (StreamReader streamReader = new StreamReader(fileInfo.FullName))
                    {
                        code = streamReader.ReadToEnd();
                    }

                    CodeFile codeFile = new CodeFile(fileInfo.FullName, code, codeDir);
                    codeFile.ShortPath = string1;
                    Files.Add(codeFile);
                    codeDir.Files.Add(codeFile);
                    codeDir.ItemCollection.Add(codeFile);
                }
            }

            CodeDir result;

            if (codeDir.GetAllFilesCount() == 0)
            {
                result = null;
            }
            else
            {
                result = codeDir;
            }

            return(result);
        }