public List <ExclusionBlock> FindExcludedCode() { _excludedBlocks = new List <ExclusionBlock>(); while (_finderOutput.Count > 0) { FindableFO element = finderOutput.First(); finderOutput.Remove(element); FinderOutputFindable endElement; ExclusionBlock exclusionScope = new ExclusionBlock(); switch (element.Item) { case (Findable.LineComment): exclusionScope.SetAsLineType(element.Position); _finderOutput.RemoveAll(el => { return(el.Position.line == element.Position.line); }); break; case (Findable.MultiLineComment_Open): case (Findable.String): case (Findable.Char): endElement = _finderOutput.First(item => { return(item.Item == element.GetMatch()); }); exclusionScope.start = element.Position; exclusionScope.end = endElement.Position; _finderOutput.RemoveAll(el => { return(el.Position <= endElement.Position); }); break; } _excludedBlocks.Add(exclusionScope); } return(_excludedBlocks); }
private Position FindStartOfScope(Position toScope) { FindableFO startOfScope; List <FindableFO> braces = bracePositions.TakeWhile(item => { return(item.Position < toScope); }).ToList(); if (braces.Count == 0) { Position p = new Position(); p.InDocument = false; return(p); } startOfScope = braces.Last(item => item.Item == Findable.Brace_Open); while (startOfScope.Position != braces.Last().Position) { FindableFO c = braces.First(item => { return(item.Position > startOfScope.Position); }); braces.Remove(startOfScope); braces.Remove(c); if (braces.Count == 0) { startOfScope.Position.InDocument = false; break; } startOfScope = braces.Last(item => item.Item == Findable.Brace_Open); } return(startOfScope.Position); }
private Position FindEndOfScope(Position toScope) { List <FindableFO> braces = bracePositions.SkipWhile(item => { return(item.Position < toScope); }).ToList(); FindableFO endOfScope = braces.First(item => item.Item == Findable.Brace_Close); while (endOfScope.Position != braces.First().Position) { FindableFO c = braces.Last(item => { return(item.Position < endOfScope.Position); }); braces.Remove(endOfScope); braces.Remove(c); endOfScope = braces.First(item => item.Item == Findable.Brace_Close); } return(endOfScope.Position); }