Пример #1
0
        protected override void DoSearch()
        {
            HashSet<LibClang.SourceLocation> uniqueResults = new HashSet<LibClang.SourceLocation>();

            ICodeLocation loc = FindSearchOrigin();
            

            //foreach(CppCodeBrowser.ISourceFile sf in _projectIndex.SourceFiles)
            foreach(var parseResult in _projectIndex.ParseResults)
            {
                TranslationUnit tu = parseResult.TranslationUnit;

                Cursor c = null;
                if(loc != null)
                    c = tu.GetCursorAt(loc.Path.Str, loc.Offset);
                else
                    c = tu.GetCursorAt(_location.Path.Str, _location.Offset);

                if (c != null)
                {
                    if (Summary == null)
                    {
                        Summary = "Find all references to: " + c.Spelling;
                    }
                    int before = uniqueResults.Count;
                    tu.FindAllReferences(c,
                                        delegate(Cursor cursor, SourceRange range)
                                        {
                                            if (uniqueResults.Add(cursor.Location))
                                            {
                                                ICodeLocation location = new CodeLocation(range.Start);
                                                ISearchResult result = new CodeSearchResult(10, location, range.Length);
                                                AddResult(result);
                                                Debug.WriteLine(result);
                                            }
                                            return true;
                                        });
                    int after = uniqueResults.Count;

                    Debug.WriteLine(string.Format("sf {0} added {1}", parseResult.Path.FileName, after - before));
                }
                else
                {
                    Debug.WriteLine(string.Format("sf {0} added 0", parseResult.Path.FileName));
                }
            }
            Debug.WriteLine(string.Format("sf total {0} ", uniqueResults.Count));
        }
Пример #2
0
        protected override void DoSearch()
        {
            if (_pattern == null)
                return;

            try
            {
                Regex regex = new Regex(_pattern);

                MatchCollection matches = Regex.Matches(_document.AvDoc.Text, _pattern);
                foreach (Match match in matches)
                {
                    ICodeLocation location = new CodeLocation(_document.File.Path.Str, match.Index);
                    ISearchResult result = new CodeSearchResult(10, location, match.Length);
                    AddResult(result);
                }
                _valid = true;
            }
            catch(Exception )
            {
                ClearResults();
                _valid = false;                
            }
        }