Frage

Im writing a policy plugin for VS which checks several issues with the code. If an issue occurs it will be displayed in the policy warnings tab. Now I want to jump to the line where the issue occurs in the editor when I double click it in the policy warning tab. How can I do that?

namespace PolicyPlugin
{
    [Serializable]
    public class MyPolicyPlugin : PolicyBase
    {
        //...

        //called if the user clicks on a policy warning
        public override void Activate(PolicyFailure failure)
        {
            // make jump to line x
        }
    }
}

Thanks!

War es hilfreich?

Lösung

You could try to get DTE automation object first:

EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));

or use alternative ways to get it.

An then execute standard command (that's what happens when you press CTRL+G in Visual Studio)

DTE.ExecuteCommand("Edit.Goto", "1234")

Note: I'm not sure about exact ExecuteCommand method signature. Also you can manipulate IDE the same way for other commands.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top