public bool FileContainsMemberName() { return(text.SearchForward(SearchedMemberName, 0).Any()); }
public void RunVisitor() { if (searchedMember == null) { return; } // search if the member name exists in the file (otherwise it doesn't make sense to search it) if (!text.SearchForward(searchedMemberName, 0).Any()) { return; } string parseText = text.Text; ICSharpCode.NRefactory.IParser parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.CSharp, new StringReader(parseText)); parser.Lexer.EvaluateConditionalCompilation = true; parser.Parse(); resolver.SetupParsedCompilationUnit(parser.CompilationUnit); VisitCompilationUnit(parser.CompilationUnit, null); List <HashSet <string> > usedIdentifiers = GetUsedDefineCombinations(parser); for (int i = 0; i < usedIdentifiers.Count; i++) { parser.Lexer.ConditionalCompilationSymbols.Clear(); foreach (string define in usedIdentifiers[i]) { parser.Lexer.ConditionalCompilationSymbols.Add(define, true); } parser.Dispose(); parser = ICSharpCode.NRefactory.ParserFactory.CreateParser(ICSharpCode.NRefactory.SupportedLanguage.CSharp, new StringReader(parseText)); parser.Parse(); VisitCompilationUnit(parser.CompilationUnit, null); } if (IncludeXmlDocumentation) { if (searchedMember is IParameter) { IParameter parameter = (IParameter)searchedMember; var docComments = from ICSharpCode.NRefactory.Comment cmt in (from ISpecial s in parser.Lexer.SpecialTracker.CurrentSpecials where s is ICSharpCode.NRefactory.Comment && s.StartPosition.Line <= parameter.DeclaringMember.Location.Line select s) select cmt; ICSharpCode.NRefactory.Comment lastComment = null; foreach (ICSharpCode.NRefactory.Comment curComment in docComments.Reverse()) { if (lastComment != null && Math.Abs(lastComment.StartPosition.Line - curComment.StartPosition.Line) > 1) { break; } // Concat doesn't work on MatchCollections foreach (var matchCol in new [] { paramRegex.Matches(curComment.CommentText), paramRefRegex.Matches(curComment.CommentText) }) { foreach (Match match in matchCol) { if (match.Groups[1].Value == searchedMemberName) { AddUniqueReference(curComment.StartPosition.Line, curComment.StartPosition.Column + match.Groups[1].Index, searchedMemberName); } } } lastComment = curComment; } } else if (searchedMember is IMember) { IMember member = (IMember)searchedMember; var docComments = from ICSharpCode.NRefactory.Comment cmt in (from ISpecial s in parser.Lexer.SpecialTracker.CurrentSpecials where s is ICSharpCode.NRefactory.Comment select s) select cmt; string fullName = member.FullName; foreach (ICSharpCode.NRefactory.Comment curComment in docComments) { // Concat doesn't work on MatchCollections foreach (var matchCol in new [] { seeRegex.Matches(curComment.CommentText), seeAlsoRegRegex.Matches(curComment.CommentText) }) { foreach (Match match in matchCol) { if (match.Groups[1].Value.StartsWith(fullName)) { AddUniqueReference(curComment.StartPosition.Line, curComment.StartPosition.Column + match.Groups[1].Index + fullName.Length - searchedMemberName.Length, searchedMemberName); } } } } } } parser.Dispose(); }