Beispiel #1
0
        internal List <PointOfInterest> ParseAndBuildList(string FileName, string BaseDirectory, float Ratio = 1)
        {
            List <PointOfInterest> result = new List <PointOfInterest>();

            try
            {
                PointOfInterest TreeRoot = Parse(FileName);
                foreach (PointOfInterest pt in TreeRoot.Items)
                {
                    FillListFromTree(pt, ref result, Ratio);
                }

                string SourceText = File.ReadAllText(FileName, Encoding.Default);
                Parallel.For(0, result.Count, (i) =>
                             //for (int i=0; i< result.Count; ++i)
                {
                    TreeSearchEngine.SetNearLG(TreeRoot, result[i], SourceText, out result[i].NearL, out result[i].NearG);
                    result[i].FileName = "\\" + GetRelativePath(result[i].FileName, BaseDirectory);
                    result[i]          = result[i].ClonePointWithoutItems();
                }
                             );
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(result);
        }
        /// <summary>
        /// Поиск точки в текущем документе в позиции курсора
        /// Документ должен быть открыт.
        /// </summary>
        /// <param name="dte"></param>
        /// <param name="Wrapper"></param>
        /// <param name="Manager"></param>
        /// <returns></returns>
        public static List <PointOfInterest> FindPointUnderCursor(IDEInterop ide, TreeManager treeManager)
        {
            string                 SourceText = ide.GetCurrentTextDocument();
            PointOfInterest        root       = treeManager.GetTree(ide.GetCurrentDocumentFileName(), SourceText);
            LexLocation            loc        = ide.GetCursorPosition();
            string                 Text       = ide.GetLine(loc.StartLine);
            List <PointOfInterest> Points     = TreeSearchEngine.FindPointByLocation(root, loc.StartLine, loc.StartColumn);

            if (Points == null || Points.Count == 0)
            {
                return(null);
            }

            List <PointOfInterest> Result = new List <PointOfInterest>();

            foreach (PointOfInterest pt in Points)
            {
                PointOfInterest p2 = pt.ClonePointAssignItems();
                p2.ApplyInnerContext();
                p2.Items = new List <PointOfInterest>();
                Result.Add(p2);
                TreeSearchEngine.SetNearLG(root, pt, SourceText, out p2.NearL, out p2.NearG);
            }

            int len = loc.StartLine == loc.EndLine ? loc.EndColumn - loc.StartColumn : Text.Length - loc.StartColumn;

            Result[0].Title = GetCurrentWord(Text, loc.StartColumn, len);
            return(Result);
        }
        private void lbCandidates_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lbCandidates.SelectedIndex < 0)
            {
                return;
            }
            PointOfInterest currentPoint = _search[lbCandidates.SelectedIndex];
            PointOfInterest TreeRoot     = _treeManager.GetTree(currentPoint.FileName, true);

            TreeSearchEngine.SetNearLG(TreeRoot, currentPoint, _treeManager.GetText(currentPoint.FileName), out _point.NearL, out _point.NearG);
            _point.Context      = currentPoint.Context;
            _point.InnerContext = currentPoint.InnerContext;
            _point.Text         = _ide.GetCurrentLine().Trim();
            Hide();
        }