Beispiel #1
0
        internal static void GotoDefinition()
        {
            if (FrmMain == null)
            {
                ShowNppPIALexer2View();
            }

            string      tagName = NPP.GetCurrentWord2();
            List <ITag> lst     = TagCache.SearchTag(tagName, TagParser.GetDefaultLang(NPP.GetCurrentFile()));

            if (lst.Count == 0)
            {
                return;
            }

            if (lst.Count == 1)
            {
                Jump.Add(tagName, lst[0].SourceFile, lst[0].LineNo - 1);
                //NPP.GoToDefinition(lst[0].SourceFile, lst[0].LineNo - 1, lst[0].TagName);
                Jump.Cursor.Go();
            }
            else
            {
                if (_ctntGoToDefinition == null)
                {
                    _ctntGoToDefinition = new ContextMenuStrip();
                }

                Point pos = NPP.GetCurrentPoint();
                _ctntGoToDefinition.Items.Clear();
                foreach (ITag tag in lst)
                {
                    string            txt  = string.Format("{0}    [{1}] {2}", tag.FullName, tag.LineNo, tag.SourceFile);
                    ToolStripMenuItem item = new ToolStripMenuItem(txt);
                    item.Tag         = tag;
                    item.ToolTipText = tag.Signature;
                    _ctntGoToDefinition.Items.Add(item);
                    item.Click += new EventHandler(delegate(object src, EventArgs ex)
                    {
                        ToolStripMenuItem i = src as ToolStripMenuItem;
                        if (i != null)
                        {
                            var t = item.Tag as ITag;
                            Jump.Add(t.TagName, t.SourceFile, t.LineNo - 1);
                            Jump.Cursor.Go();
                            //NPP.GoToDefinition(t.SourceFile, t.LineNo - 1, t.TagName);
                        }
                    });
                }
                _ctntGoToDefinition.Show(pos);
            }
        }