예제 #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 BuildList()
        {
            lbCandidates.SelectedIndexChanged -= lbCandidates_SelectedIndexChanged;
            //if (System.Threading.Thread.CurrentThread.CurrentCulture.Name == "en") //hardcoded
            //    label1.Text = string.Format(Pattern, _dist, _typeEn, _nameEn);
            //else
            label1.Text        = string.Format(Pattern, _dist, _type, _name);
            lOldPointInfo.Text = string.Format(Pattern, 1.ToString("F2"), _point.Context[0].Type, string.Join(" ", _point.Context[0].Name));

            lbCandidates.Items.Clear();
            for (int i = 0; i < _search.Count; ++i)
            {
                //foreach (TreeSearchResultNode node in _search._result)
                lbCandidates.Items.Add(string.Format(Pattern, ((float)_search.GetTotalMatch(i) / TreeSearchOptions.Equility).ToString("F2"), _search._result[i].TreeNode.Context[0].Type, string.Join(" ", _search._result[i].TreeNode.Context[0].Name)));
            }
            lbCandidates.SelectedIndexChanged += lbCandidates_SelectedIndexChanged;
        }