/// <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 FillListFromTree(PointOfInterest TreeRoot, ref List <PointOfInterest> result, float Ratio) { if (TreeRoot == null) { return; } if (R.NextDouble() <= Ratio) { PointOfInterest pt = TreeRoot;//.ClonePointAssignItems(); pt.ApplyInnerContext(); pt.Title = string.Join(" ", pt.Context[0]?.Name); pt.ApplyInnerContext(); result.Add(pt); } foreach (PointOfInterest subnode in TreeRoot.Items) { FillListFromTree(subnode, ref result, Ratio); } }