Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ICommand FindAllToolsCommand
- => _findAllToolsCommand ?? (_findAllToolsCommand = new RelayCommand<object>(() =>
- {
- Regex toolSearchRegex = new Regex(ToolRegex);
- Regex commentRegex = new Regex(CommentRegex);
- string firstComment = "";
- string secondComment = "";
- string thirdComment = "";
- ProgramToolList.Clear();
- foreach (Match match in toolSearchRegex.Matches(CurrentEditor.Text))
- {
- var line = CurrentEditor.Document.GetLineByOffset(match.Index);
- if (CheckForComments(line,match.Index))
- {
- continue;
- }
- secondComment = SearchInLine(GetLineText(line.Offset), commentRegex);
- if (line.PreviousLine != null)
- {
- firstComment = SearchInLine(GetLineText(line.PreviousLine.Offset), commentRegex);
- }
- if (line.NextLine != null)
- {
- thirdComment = SearchInLine(GetLineText(line.NextLine.Offset), commentRegex);
- }
- ProgramToolList.Add(new ToolLine(match.Index, match.Value, string.Concat(firstComment,secondComment,thirdComment)));
- }
- }));
- private bool CheckForComments(DocumentLine line, int toolOffset)
- {
- var lineText = GetLineText(toolOffset);
- var leftBracketIndex = lineText.IndexOf("(");
- if (leftBracketIndex<0)
- {
- return false;
- }
- if (leftBracketIndex + line.Offset < toolOffset)
- {
- if (lineText.IndexOf(")") + line.Offset > toolOffset)
- {
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement