예제 #1
0
        private void перейтиККодуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (tvAspects.SelectedNode == null)
                {
                    return;
                }
                PointOfInterest pt = Adapter.GetPointByNode(tvAspects.SelectedNode);
                if ((pt?.Context?.Count ?? 0) == 0)
                {
                    return;
                }
                string           fileName = Manager.GetFullFilePath(pt.FileName);
                PointOfInterest  Tree     = ide.IsDocumentOpen(fileName) ? treeManager.GetTree(fileName, ide.GetDocument(fileName)) : treeManager.GetTree(fileName);
                TreeSearchResult Search   = TreeSearchEngine.FindPointInTree2(Tree, pt, treeManager.GetText(fileName));
                if (Search.Count == 0)
                {
                    SetStatus(string.Format(Strings.CannotFindPoint, pt.Title));
                }
                else if (Search.Singular && (ModifierKeys != Keys.Control))
                {
                    //update point anchor if similarity != 1
                    string path = Manager.GetFullFilePath(pt.FileName);
                    ide.NavigateToFileAndPosition(path, Search[0].Location.StartLine, Search[0].Location.StartColumn);
                    SetStatus("");
                }
                else
                {
                    if (Search.Count >= 2)
                    {
                        int d1 = TreeSearchOptions.Equility - Search.GetTotalMatch(0);
                        int d2 = TreeSearchOptions.Equility - Search.GetTotalMatch(1);
                        //float near = Math.Max(pt.NearG, pt.NearL);
                        //float threshold = ((near + 4) / 5 + 1) / 2; //hardcoded
                        //if (Search._result[0].TotalMatch > threshold*TreeSearchOptions.Equility && Search._result[1].TotalMatch < threshold * TreeSearchOptions.Equility)
                        if (d2 != 0 && d2 >= d1 * 2 && (ModifierKeys != Keys.Control))
                        {
                            string path = Manager.GetFullFilePath(pt.FileName);
                            ide.NavigateToFileAndPosition(path, Search[0].Location.StartLine, Search[0].Location.StartColumn);
                            SetStatus("");
                            return;
                        }
                    }

                    fmSelectPoint.Launch(Search, pt);
                    SetStatus("");
                }
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
예제 #2
0
        private void tvParsedPoints_AfterSelect(object sender, TreeViewEventArgs e)
        {
            PointOfInterest p = tvAdapter.GetPointByNode(e.Node);

            if (p != null)
            {
                SetCursor(AspectManager.GetFullFilePath(p.FileName), p.Location);
            }
        }