Creating VS debugger add-in for viewing DataSet/DataTable

  • Thread starter Thread starter MuZZy
  • Start date Start date
M

MuZZy

Hi,

I'm developing an add-in for Visual Studio which works like Quick Watch in debug mode for viewing
datasets/datatables as tables.

I already have a working add-in, but there is one problem i can't find solution for:

When i select a dataset object and from context menu choose "DSWatch" (my add-in), it shows
correctly, but i need to add functionality to just put cursor on the variable instead of electing it.

What i have is:

public class Connect : Object, Extensibility.IDTExtensibility2, IDTCommandTarget,ICallback
{

public void Exec(string commandName, EnvDTE.vsCommandExecOption executeOption, ref object varIn, ref
object varOut, ref bool handled)
{
string str="";
DatasetWatchFrm _DatasetWatchFrm = null;
try
{
EnvDTE.Debugger debugger;
debugger = applicationObject.Debugger;
applicationObject.ActiveDocument.MarkText;

TextSelection _TextSelection;
applicationObject.ActiveDocument._TextSelection =
(TextSelection)applicationObject.ActiveDocument.Selection;
str=_TextSelection.Text ;

if ( commandName != "DSWatch.Connect.DSWatchNode")
{
m_bDataTable = true;
}

_DatasetWatchFrm =new DatasetWatchFrm(str);
string strValue = this.GetExp(str);
_DatasetWatchFrm.m_strValue = strValue;
_DatasetWatchFrm.SetParent(this);
_DatasetWatchFrm.getXml(strValue);
_DatasetWatchFrm.Show();
}
catch(Exception e)
{
_DatasetWatchFrm.Show();
System.Windows.Forms.MessageBox.Show(e.Message );
}
}

}

So i can get the selected text from IDE and then get the dataset itself,\but how do i get the text
under cursor?

Any suggestions would be highly appreciated!

Thank you in advance,
Andrey
 
To get the text under the cursor, even if there is no selected text, you use
TextSelection.ActivePoint, create an EditPoint and then get the text with
EditPoint.GetText or EditPoint.GetLines. You will have to parse the text to
the left and to the right until finding a blank character.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 
Carlos said:
To get the text under the cursor, even if there is no selected text, you use
TextSelection.ActivePoint, create an EditPoint and then get the text with
EditPoint.GetText or EditPoint.GetLines. You will have to parse the text to
the left and to the right until finding a blank character.

Thanks a lot! I will give it a try!

By the way, do you know any good tutorial/website dedicated to creating debugger add-ins?

Thank you
Andrey
 
Carlos said:
To get the text under the cursor, even if there is no selected text, you use
TextSelection.ActivePoint, create an EditPoint and then get the text with
EditPoint.GetText or EditPoint.GetLines. You will have to parse the text to
the left and to the right until finding a blank character.


If i use EditPoint.GetText, i need to specify number of characters.
So do i just set a big number of characters?
Like:

string strBefore = EditPoint.GetText(-100);
string strAfter = EditPoint.GetText(100);

and then look for space in strBefore starting from end and in strAfter starting from start?
Is it the right way?

Also, for c++ document case, should i include '->' or shoud i replace them by '.'?

Thanks a lot!
Andrey
 
Back
Top