public List<ISet> Examine(IEnumerable<Set> sets) { // For every block, find the next closest following (can't come before) block. List<BlockPair> pairs = new List<BlockPair>(); foreach (Set set in sets) { foreach (Block block in set.Blocks) { Block closest = FindClosestBlock(sets, block); if (closest != null) pairs.Add(new BlockPair(block, closest)); } } // Do any closest block pairs have their top set and bottom set the same? // That is, the diff between the two is their middles. foreach (BlockPair pair in pairs) { foreach (BlockPair pair1 in pairs) { if (pair != pair1) { if (pair.Top.Set == pair1.Top.Set && pair.Bottom.Set == pair1.Bottom.Set) { Set set = new Set(); IProjectFile project_file = pair.Top.ProjectFile;// they are both in the same file set.Blocks.Add(MakeBlock(pair, set, project_file)); set.Blocks.Add(MakeBlock(pair1, set, project_file)); return new List<ISet> ( new ISet[] {set} ); } } } } return new List<ISet>(); }
private bool Equals(Set s1) { IBlock block1 = Blocks[0]; IBlock block2 = s1.blocks[0]; return block1.SharesSourceFile(block2) && block1.StartLineNumber == block2.StartLineNumber && block1.EndLineNumber == block2.EndLineNumber; }
public static ISet ToIste(Set input) { return input; }
private Block MakeBlock(BlockPair pair, Set set, IProjectFile project_file) { int startLineNumber = pair.Top.EndLineNumber + 1; int endLineNumber = pair.Bottom.StartLineNumber - 1; DocumentRange range = SimianResultsParser.GetDocumentRange(project_file, startLineNumber, endLineNumber, Solution); return new Block(startLineNumber, endLineNumber, project_file, set, range); }
private Set ReadSet() { int lineCount = Convert.ToInt32(xr.GetAttribute("lineCount")); Set set = new Set(lineCount); if (xr.ReadToDescendant("block")) { do { string sourceFile = xr.GetAttribute("sourceFile"); int startLineNumber = Convert.ToInt32(xr.GetAttribute("startLineNumber")); int endLineNumber = Convert.ToInt32(xr.GetAttribute("endLineNumber")); IList<IProjectItem> projectFiles = solution.FindProjectItemsByLocation(new FileSystemPath(sourceFile)).ToArray(); if (projectFiles.Count > 1) throw new ApplicationException("Expected exactly one file corresponding to " + sourceFile); IProjectFile projectFile = (IProjectFile) projectFiles[0]; DocumentRange? range = GetDocumentRange2(sourceFile, projectFile, startLineNumber, endLineNumber); set.AddBlock(sourceFile, startLineNumber, endLineNumber, projectFile, range); } while (xr.ReadToNextSibling("block")); } return set; }