public Annotation(CodeFile file, Similarity sim, IEnumerable<Annotation> existingAnnotations)
		{
			Func<Annotation, bool> func = null;
			Left = 0.0;
			//base..ctor();
			CodeFile = file;
			Similarity = sim;
			Height = (double)sim.MyRange.Length * Annotation.TextHeight;
			Top = (double)sim.MyRange.Start * Annotation.TextHeight;
			double3 = Top + Height;

			if (file == sim.OtherFile)
			{
				Brush = Annotation.brush2;
			}
			else
			{
				Brush = Annotation.brush1;
			}

			if (func == null)
			{
				func = new Func<Annotation, bool>(method0);
			}

			List<Annotation> list = existingAnnotations.Where(func).ToList<Annotation>();

			if (list.Count == 0)
			{
				Left = Annotation.double2 + 2.0;
			}
			else
			{
				IEnumerable<Annotation> annotations = list;

				if (Annotation.func0 == null)
				{
					Annotation.func0 = new Func<Annotation, double>(Annotation.smethod0);
				}

				double num = annotations.Max(Annotation.func0);
				Left = num + Annotation.double2 + Annotation.double1;
			}

			Margin = new Thickness(Left, Top, 0.0, 0.0);
		}
		private void method0(CodeFile codeFile)
		{
			IEnumerable<char> shortPath = codeFile.ShortPath;

			if (WheelViewModel.func0 == null)
			{
				WheelViewModel.func0 = new Func<char, bool>(WheelViewModel.smethod0);
			}

			int num = shortPath.Count(WheelViewModel.func0);

			if (DeepestDir < num)
			{
				DeepestDir = num;
			}

			string text = codeFile.ShortPath.TrimStart(new char[]
			{
				'\\'
			});

			while (text.Length > 0)
			{
				if (!DirectoryToLoc.ContainsKey(text))
				{
					DirectoryToLoc.Add(text, 0);
					Dictionary<string, int> directoryToLevel = DirectoryToLevel;
					string arg_A3_1 = text;
					IEnumerable<char> textStr = text;

					if (WheelViewModel.func1 == null)
					{
						WheelViewModel.func1 = new Func<char, bool>(WheelViewModel.smethod1);
					}

					directoryToLevel.Add(arg_A3_1, textStr.Count(WheelViewModel.func1) + 1);
				}

				SortedDictionary<string, int> sortedDictionary;
				string key;
				(sortedDictionary = DirectoryToLoc)[key = text] = sortedDictionary[key] + codeFile.Hashes.Length;
				text = Path.GetDirectoryName(text);
			}
		}
		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;
		}
		internal void method_0(CodeFile codeFile_1)
		{
			if (this.codeFile_0 != codeFile_1)
			{
				this.codeFile_0 = codeFile_1;
				this.method_1("SelectedFile");
			}
		}
		public Annotation(CodeFile file, Similarity sim, IEnumerable<Annotation> existingAnnotations)
		{
			Func<Annotation, bool> func = null;
			this.double_5 = 0.0;
			base..ctor();
			this.codeFile_0 = file;
			this.similarity_0 = sim;
			this.double_3 = (double)sim.MyRange.Length * Annotation.TextHeight;
			this.double_4 = (double)sim.MyRange.Start * Annotation.TextHeight;
			this.double_2 = this.double_4 + this.double_3;
			if (file == sim.OtherFile)
			{
				this.brush_2 = Annotation.brush_1;
			}
			else
			{
				this.brush_2 = Annotation.brush_0;
			}
			if (func == null)
			{
				func = new Func<Annotation, bool>(this.method_0);
			}
			List<Annotation> list = existingAnnotations.Where(func).ToList<Annotation>();
			if (list.Count == 0)
			{
				this.double_5 = Annotation.double_1 + 2.0;
			}
			else
			{
				IEnumerable<Annotation> arg_EE_0 = list;
				if (Annotation.func_0 == null)
				{
					Annotation.func_0 = new Func<Annotation, double>(Annotation.smethod_0);
				}
				double num = arg_EE_0.Max(Annotation.func_0);
				this.double_5 = num + Annotation.double_1 + Annotation.double_0;
			}
			this.thickness_0 = new Thickness(this.double_5, this.double_4, 0.0, 0.0);
		}
		private string method1(CodeFile codeFile, HashIndexRange hashIndexRange)
		{
			StringBuilder stringBuilder = new StringBuilder();

			for (int i = hashIndexRange.Start; i < hashIndexRange.End; i++)
			{
				if (stringBuilder.Length != 0)
				{
					stringBuilder.AppendLine();
				}

				if (i >= codeFile.Hashes.Length)
				{
					break;
				}

				stringBuilder.Append(codeFile.Hashes[i].ToString().PadLeft(13, ' ') + "  " + codeFile.HashToLine[codeFile.Hashes[i]]);
			}

			return stringBuilder.ToString();
		}
		public string GetText(CodeFile file, LineRange range)
		{
			return GetText(file, range, true);
		}
Exemple #8
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);
        }
		private void method9(CodeFile codeFile, AllSequences allSequences)
		{
			if (allSequences.Sequences.Count != 0)
			{
				int i = 0;
				IL_A1:

				while (i < codeFile.Similarities.Count)
				{
					Similarity similarity = codeFile.Similarities[i];
					bool flag = false;
					int j = 0;

					while (j < allSequences.Sequences.Count)
					{
						Sequence sequence = allSequences.Sequences[j];

						if (sequence.FirstCoord.J < similarity.MyHashIndexRange.Start || sequence.LastCoord.J > similarity.MyHashIndexRange.End)
						{
							j++;
						}
						else
						{
							codeFile.Similarities.Remove(similarity);
							flag = true;
							//IL_9A:

							if (!flag)
							{
								i++;
								goto IL_A1;
							}
							goto IL_A1;
						}
					}
					//goto IL_9A;
				}
			}
		}
Exemple #10
0
        internal void method_0()
        {
            this.double_0        = this.double_4 + (double)(this.wheelViewModel_0.DeepestDir + 1) * this.double_2;
            this.double_1        = this.double_0;
            base.Height          = this.double_1 * 2.0;
            base.Width           = this.double_0 * 2.0;
            this.canvas_0.Width  = base.Width;
            this.canvas_0.Height = base.Height;
            Color.FromRgb(0, 102, 255);
            Color.FromRgb(255, 0, 0);
            Dictionary <CodeFile, PiePiece> dictionary  = new Dictionary <CodeFile, PiePiece>();
            Dictionary <CodeDir, PiePiece>  dictionary2 = new Dictionary <CodeDir, PiePiece>();
            Dictionary <PiePiece, double>   dictionary3 = new Dictionary <PiePiece, double>();

            this.double_5 = this.double_4 + this.double_2;
            Ellipse element = new Ellipse
            {
                Height          = base.Height * 2.0,
                Width           = base.Width * 2.0,
                StrokeThickness = base.Width - this.double_4,
                Stroke          = Brushes.Black
            };

            Canvas.SetTop(element, -1.0 * base.Height / 2.0);
            Canvas.SetLeft(element, -1.0 * base.Width / 2.0);
            Panel.SetZIndex(element, 5);
            this.canvas_0.Children.Add(element);
            double num  = 0.0;
            double num2 = 360.0 / this.wheelViewModel_0.TotalLineSize;

            foreach (CodeFile current in this.wheelViewModel_0.CodeFiles)
            {
                PiePiece piePiece = new PiePiece();
                piePiece.Style = this.style_0;
                int num3 = this.wheelViewModel_0.DeepestDir - current.DirectParent.Depth;
                piePiece.method_11(this.double_0);
                piePiece.method_13(this.double_1);
                piePiece.method_1(this.double_5 + (double)num3 * this.double_2);
                piePiece.method_5(this.double_4);
                piePiece.method_9(num);
                piePiece.method_7(num2 * (double)current.ProcessedLines);
                num += piePiece.method_6();
                piePiece.DataContext = current;
                piePiece.Tag         = current;
                piePiece.Stroke      = Brushes.Black;
                piePiece.Fill        = WheelView.smethod_0(piePiece);
                Panel.SetZIndex(piePiece, 10);
                piePiece.Cursor = Cursors.Hand;
                this.canvas_0.Children.Add(piePiece);
                dictionary.Add(current, piePiece);
                dictionary3.Add(piePiece, 0.0);
                this.method_1(piePiece, System.IO.Path.GetFileNameWithoutExtension(current.Name), 1.0);
            }
            double[] array = new double[this.wheelViewModel_0.DeepestDir + 1];
            foreach (CodeDir current2 in this.codeDir_0.GetAllDirectories())
            {
                int      processedLines = current2.ProcessedLines;
                int      num3           = this.wheelViewModel_0.DeepestDir - current2.Depth + 1;
                PiePiece piePiece       = new PiePiece();
                piePiece.Style = this.style_1;
                piePiece.method_11(this.double_0);
                piePiece.method_13(this.double_1);
                piePiece.method_1(this.double_5 + (double)num3 * this.double_2);
                piePiece.method_5(this.double_4 + (double)num3 * this.double_2);
                CodeFile firstDeepestFile = current2.FirstDeepestFile;
                PiePiece piePiece2        = dictionary[firstDeepestFile];
                piePiece.method_9(piePiece2.method_8());
                piePiece.method_7(num2 * (double)processedLines);
                if (piePiece.method_6() >= 360.0)
                {
                    piePiece.method_7(359.999);
                }
                array[num3]         += piePiece.method_6();
                piePiece.DataContext = current2;
                piePiece.Tag         = current2;
                piePiece.Stroke      = Brushes.Black;
                piePiece.Fill        = WheelView.smethod_0(piePiece);
                Panel.SetZIndex(piePiece, 10);
                piePiece.Cursor = Cursors.Hand;
                this.canvas_0.Children.Add(piePiece);
                dictionary2.Add(current2, piePiece);
                this.method_1(piePiece, System.IO.Path.GetFileName(current2.Name), 0.8);
            }
            IEnumerable <Similarity> enumerable = this.wheelViewModel_0.method_1();

            foreach (Similarity current3 in enumerable)
            {
                CanonicalSpline canonicalSpline = new CanonicalSpline();
                canonicalSpline.Tolerance   = 1.5;
                canonicalSpline.DataContext = current3;
                canonicalSpline.Points      = new PointCollection();
                canonicalSpline.Cursor      = Cursors.Hand;
                Panel.SetZIndex(canonicalSpline, 0);
                canonicalSpline.StrokeThickness = (double)current3.MyHashIndexRange.Length * (num2 / 360.0 * this.double_4 * 2.0 * 3.14159);
                canonicalSpline.Stroke          = (current3.SameFile ? WheelView.brush_1 : WheelView.brush_0);
                PiePiece piePiece3 = dictionary[current3.MyFile];
                PiePiece piePiece4 = dictionary[current3.OtherFile];
                double   num4      = piePiece3.method_8() + dictionary3[piePiece3] + (double)current3.MyHashIndexRange.Length * num2 / 2.0;
                Point    point     = Utils.ComputeCartesianCoordinate(num4, this.double_4, this.double_0, this.double_1);
                Point    value     = Utils.ComputeCartesianCoordinate(num4, this.double_4 + this.double_4 / 3.0, this.double_0, this.double_1);
                Dictionary <PiePiece, double> dictionary4;
                PiePiece key;
                (dictionary4 = dictionary3)[key = piePiece3] = dictionary4[key] + (double)current3.MyHashIndexRange.Length * num2;
                double num5   = piePiece4.method_8() + dictionary3[piePiece4] + (double)current3.OtherHashIndexRange.Length * num2 / 2.0;
                Point  point2 = Utils.ComputeCartesianCoordinate(num5, this.double_4, this.double_0, this.double_1);
                Point  value2 = Utils.ComputeCartesianCoordinate(num5, this.double_4 + this.double_4 / 3.0, this.double_0, this.double_1);
                (dictionary4 = dictionary3)[key = piePiece4] = dictionary4[key] + (double)current3.OtherHashIndexRange.Length * num2;
                double num6 = this.method_3(num4, num5);
                double num7 = this.double_4 - num6 / 180.0 * this.double_4;
                if (num7 > this.double_4 / 1.2)
                {
                    num7 = this.double_4 / 1.2;
                }
                double angle  = this.method_2(num4, num5);
                Point  value3 = Utils.ComputeCartesianCoordinate(angle, num7, this.double_0, this.double_1);
                canonicalSpline.Points.Add(value);
                canonicalSpline.Points.Add(point);
                canonicalSpline.Points.Add(value3);
                canonicalSpline.Points.Add(point2);
                canonicalSpline.Points.Add(value2);
                canonicalSpline.Stroke = new LinearGradientBrush(((SolidColorBrush)piePiece4.Fill).Color, ((SolidColorBrush)piePiece3.Fill).Color, point, point2)
                {
                    MappingMode = BrushMappingMode.Absolute
                };
                this.canvas_0.Children.Add(canonicalSpline);
            }
        }
Exemple #11
0
 private static int GetHashesLength(CodeFile codeFile)
 {
     return(codeFile.Hashes.Length);
 }
Exemple #12
0
 private static bool smethod7(CodeFile codeFile)
 {
     return(codeFile.Similarities.Count == 0);
 }
Exemple #13
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();
            }
        }
Exemple #14
0
        internal static AllSequences smethod1(CodeFile codeFile1, CodeFile codeFile2, int int2)
        {
            AllSequences result;

            if (codeFile1 == codeFile2)
            {
                result = Analysis.smethod2(codeFile1, int2);
            }
            else
            {
                int[]        hashes       = codeFile1.Hashes;
                int[]        hashes2      = codeFile2.Hashes;
                AllSequences allSequences = new AllSequences();

                if (hashes.Intersect(hashes2).Count <int>() == 0)
                {
                    Analysis.int0++;
                    result = allSequences;
                }
                else if (hashes.Length == 0 || hashes2.Length == 0)
                {
                    result = allSequences;
                }
                else
                {
                    int[] array  = new int[hashes2.Length];
                    int[] array2 = new int[hashes2.Length];

                    for (int i = 0; i < hashes.Length; i++)
                    {
                        for (int j = 0; j < hashes2.Length; j++)
                        {
                            if (hashes[i] != hashes2[j])
                            {
                                array2[j] = 0;
                            }
                            else
                            {
                                if (i == 0 || j == 0)
                                {
                                    array2[j] = 1;
                                }
                                else
                                {
                                    array2[j] = 1 + array[j - 1];
                                }

                                if (array2[j] > int2)
                                {
                                    allSequences.AddCoordToAppropriateSequence(new Coord
                                    {
                                        I    = i,
                                        J    = j,
                                        Size = array2[j]
                                    });
                                }
                            }
                        }

                        int[] array3 = array;
                        array  = array2;
                        array2 = array3;
                    }

                    result = allSequences;
                }
            }

            return(result);
        }
		private static AllSequences smethod2(CodeFile codeFile, int int2)
		{
			int[] hashes = codeFile.Hashes;
			int[] hashes2 = codeFile.Hashes;
			AllSequences allSequences = new AllSequences();
			AllSequences result;

			if (hashes.Length == 0)
			{
				result = allSequences;
			}
			else
			{
				int[] array = new int[hashes2.Length];
				int[] array2 = new int[hashes2.Length];

				for (int i = 0; i < hashes.Length; i++)
				{
					for (int j = i; j < hashes2.Length; j++)
					{
						if (i != j)
						{
							if (hashes[i] != hashes2[j])
							{
								array2[j] = 0;
							}
							else
							{
								if (i == 0 || j == 0)
								{
									array2[j] = 1;
								}
								else
								{
									array2[j] = 1 + array[j - 1];
								}

								if (array2[j] > int2)
								{
									allSequences.AddCoordToAppropriateSequence(new Coord
									{
										I = i,
										J = j,
										Size = array2[j]
									});
								}
							}
						}
					}

					int[] array3 = array;
					array = array2;
					array2 = array3;
				}

				result = allSequences;
			}

			return result;
		}
		private static void smethod4(CodeFile myFile, CodeFile otherFile, Sequence sequence)
		{
			Similarity similarity = new Similarity();
			similarity.MyFile = myFile;
			similarity.OtherFile = otherFile;
			similarity.MyHashIndexRange = new HashIndexRange
			{
				Start = sequence.FirstCoord.I,
				End = sequence.LastCoord.I + 1
			};
			similarity.OtherHashIndexRange = new HashIndexRange
			{
				Start = sequence.FirstCoord.J,
				End = sequence.LastCoord.J + 1
			};
			similarity.SetLineRanges();
			similarity.UniqueId = Analysis.int1;
			myFile.Similarities.Add(similarity);
			Similarity similarity2 = new Similarity();
			similarity2.MyFile = otherFile;
			similarity2.OtherFile = myFile;
			similarity2.OtherHashIndexRange = new HashIndexRange
			{
				Start = sequence.FirstCoord.I,
				End = sequence.LastCoord.I + 1
			};
			similarity2.MyHashIndexRange = new HashIndexRange
			{
				Start = sequence.FirstCoord.J,
				End = sequence.LastCoord.J + 1
			};
			similarity2.SetLineRanges();
			similarity.UniqueId = Analysis.int1;
			otherFile.Similarities.Add(similarity2);
			similarity.CorrespondingSimilarity = similarity2;
			similarity2.CorrespondingSimilarity = similarity;
			Analysis.int1++;
		}
 protected virtual CodeFile OnCoerceCodeFile(CodeFile value)
 {
     return(value);
 }
		private static int GetHashesLength(CodeFile codeFile)
		{
			return codeFile.Hashes.Length;
		}
 protected virtual void OnCodeFileChanged(CodeFile oldValue, CodeFile newValue)
 {
     this.annotatedTextViewModel_0.CodeFile = newValue;
 }
		private static object smethod0(DependencyObject dependencyObject, CodeFile codeFile)
		{
			AnnotatedTextBox annotatedTextBox = dependencyObject as AnnotatedTextBox;
			object result;

			if (annotatedTextBox != null)
			{
				result = annotatedTextBox.OnCoerceCodeFile((CodeFile)codeFile);
			}
			else
			{
				result = codeFile;
			}

			return result;
		}
		private static int smethod_2(CodeFile codeFile_0)
		{
			return codeFile_0.Similarities.Count<Similarity>();
		}
		public string GetText(CodeFile file, LineRange range, bool includeLineNumbers)
		{
			StringBuilder stringBuilder = new StringBuilder();
			int num = 1000;

			for (int i = range.Start; i < range.End; i++)
			{
				if (!Similarity.regex_0.IsMatch(file.Lines[i]))
				{
					string text = file.Lines[i];
					int num2 = 0;

					while (num2 < text.Length && text[num2] == ' ')
					{
						num2++;
					}

					if (num > num2)
					{
						num = num2;
					}
				}
			}

			for (int i = range.Start; i < range.End; i++)
			{
				if (stringBuilder.Length != 0)
				{
					stringBuilder.AppendLine();
				}

				if (includeLineNumbers)
				{
					if (file.Lines[i].Length <= num)
					{
						stringBuilder.Append(i.ToString().PadLeft(4, ' '));
					}
					else
					{
						stringBuilder.Append(i.ToString().PadLeft(4, ' ') + "\t" + file.Lines[i].Substring(num));
					}
				}
				else if (file.Lines[i].Length <= num)
				{
					stringBuilder.Append("");
				}
				else
				{
					stringBuilder.Append("\t" + file.Lines[i].Substring(num));
				}
			}

			return stringBuilder.ToString();
		}
		private static int smethod_3(CodeFile codeFile_0)
		{
			return codeFile_0.Hashes.Length;
		}
		private LineRange method0(CodeFile codeFile, HashIndexRange hashIndexRange, LineRange lineRange)
		{
			lineRange.Start = codeFile.HashIndexToLineIndex[hashIndexRange.Start];

			if (codeFile.HashIndexToLineIndex.Length <= hashIndexRange.End)
			{
				lineRange.End = codeFile.HashIndexToLineIndex[codeFile.HashIndexToLineIndex.Length - 1];
			}
			else
			{
				lineRange.End = codeFile.HashIndexToLineIndex[hashIndexRange.End];
			}

			return lineRange;
		}
		private static IEnumerable<Similarity> smethod_4(CodeFile codeFile_0)
		{
			return codeFile_0.Similarities;
		}
		public WheelFile(CodeFile file, WheelViewModel wheelViewModel)
		{
			_wheelViewModel = wheelViewModel;
		}
		private static int GetRawLines(CodeFile codeFile)
		{
			return codeFile.RawLines;
		}
		private static IEnumerable<int> smethod_2(CodeFile codeFile_1)
		{
			IEnumerable<Similarity> arg_23_0 = codeFile_1.Similarities;
			if (MainViewModel.func_3 == null)
			{
				MainViewModel.func_3 = new Func<Similarity, int>(MainViewModel.smethod_3);
			}
			return arg_23_0.Select(MainViewModel.func_3);
		}
		private static int GetProcessedLines(CodeFile codeFile)
		{
			return codeFile.ProcessedLines;
		}
		internal static AllSequences smethod1(CodeFile codeFile1, CodeFile codeFile2, int int2)
		{
			AllSequences result;

			if (codeFile1 == codeFile2)
			{
				result = Analysis.smethod2(codeFile1, int2);
			}
			else
			{
				int[] hashes = codeFile1.Hashes;
				int[] hashes2 = codeFile2.Hashes;
				AllSequences allSequences = new AllSequences();

				if (hashes.Intersect(hashes2).Count<int>() == 0)
				{
					Analysis.int0++;
					result = allSequences;
				}
				else if (hashes.Length == 0 || hashes2.Length == 0)
				{
					result = allSequences;
				}
				else
				{
					int[] array = new int[hashes2.Length];
					int[] array2 = new int[hashes2.Length];

					for (int i = 0; i < hashes.Length; i++)
					{
						for (int j = 0; j < hashes2.Length; j++)
						{
							if (hashes[i] != hashes2[j])
							{
								array2[j] = 0;
							}
							else
							{
								if (i == 0 || j == 0)
								{
									array2[j] = 1;
								}
								else
								{
									array2[j] = 1 + array[j - 1];
								}

								if (array2[j] > int2)
								{
									allSequences.AddCoordToAppropriateSequence(new Coord
									{
										I = i,
										J = j,
										Size = array2[j]
									});
								}
							}
						}

						int[] array3 = array;
						array = array2;
						array2 = array3;
					}

					result = allSequences;
				}
			}

			return result;
		}
		private static int GetSimilaritiesCount(CodeFile codeFile)
		{
			return codeFile.Similarities.Count<Similarity>();
		}
		private static void smethod3(CodeFile myFile, CodeFile otherFile, int int2, List<int> sequenceBuilder, int myEnd, int otherEnd, int[,] int5)
		{
			if (sequenceBuilder.Count > int2)
			{
				int sequencesCount = sequenceBuilder.Count;
				int start = myEnd - int5[myEnd, otherEnd] + 1;
				int start2 = otherEnd - int5[myEnd, otherEnd] + 1;
				Similarity similarity = new Similarity();
				similarity.MyFile = myFile;
				similarity.OtherFile = otherFile;
				similarity.MyHashIndexRange = new HashIndexRange
				{
					Start = start,
					End = myEnd
				};
				similarity.OtherHashIndexRange = new HashIndexRange
				{
					Start = start2,
					End = otherEnd
				};
				similarity.SetLineRanges();

				myFile.Similarities.Add(similarity);

				if (myFile != otherFile)
				{
					Similarity similarity2 = new Similarity();
					similarity2.MyFile = otherFile;
					similarity2.OtherFile = myFile;
					similarity2.OtherHashIndexRange = new HashIndexRange
					{
						Start = start,
						End = myEnd
					};
					similarity2.MyHashIndexRange = new HashIndexRange
					{
						Start = start2,
						End = otherEnd
					};
					similarity2.SetLineRanges();
					otherFile.Similarities.Add(similarity2);
				}
			}
		}
		private static IEnumerable<Similarity> GetSimilarities(CodeFile codeFile)
		{
			return codeFile.Similarities;
		}
		private List<CodeFile> method8(string str)
		{
			string[] array = Regex.Split(str, "~~CPK\\sCode\\sChunk\\sDelimiter~~", RegexOptions.IgnoreCase);
			string arg = Options.FileSearchPattern.Substring(1, Options.FileSearchPattern.Length - 1);
			List<CodeFile> list = new List<CodeFile>();

			for (int i = 0; i < array.Length; i++)
			{
				if (!(array[i].Trim() == ""))
				{
					CodeFile item = new CodeFile("ignoreChunk" + i + arg, array[i], null);
					list.Add(item);
				}
			}

			IEnumerable<CodeFile> codeFiles = list;

			if (Analysis.func3 == null)
			{
				Analysis.func3 = new Func<CodeFile, int>(Analysis.GetHashesLength);
			}

			return codeFiles.OrderByDescending(Analysis.func3).ToList<CodeFile>();
		}
		protected virtual CodeFile OnCoerceCodeFile(CodeFile value)
		{
			return value;
		}
		private static bool smethod7(CodeFile codeFile)
		{
			return codeFile.Similarities.Count == 0;
		}
		protected virtual CodeFile OnCoerceCodeFile(CodeFile codeFile)
		{
			return codeFile;
		}
		protected virtual void OnCodeFileChanged(CodeFile oldValue, CodeFile newValue)
		{
			_annotatedTextViewModel.CodeFile = newValue;
		}
Exemple #39
0
 public WheelFile(CodeFile file, WheelViewModel wheelViewModel)
 {
     _wheelViewModel = wheelViewModel;
 }