コード例 #1
0
        public static void GotoDefinition(IVsTextView vsTextView)
        {
            int    line, column;
            string text;

            TextSpan[] span = new TextSpan[1];

            Parser  parser  = new Parser(LuaGrammar.Instance);
            Scanner scanner = parser.Scanner;

            vsTextView.GetCaretPos(out line, out column);
            vsTextView.GetSelectedText(out text);

            vsTextView.GetWordExtent(line, column, (uint)WORDEXTFLAGS.WORDEXT_CURRENT, span);
            vsTextView.SetSelection(span[0].iStartLine, span[0].iStartIndex, span[0].iEndLine, span[0].iEndIndex);
            string word;

            vsTextView.GetTextStream(span[0].iStartLine, span[0].iStartIndex, span[0].iEndLine, span[0].iEndIndex, out word);

            TextSpan?res = _model.GetDeclarationLocation(word, span[0]);

            if (res != null)
            {
                vsTextView.SetCaretPos(res.Value.iStartLine, res.Value.iStartIndex);
            }
        }