Beispiel #1
0
 private void ChangedEventHandler(CodeElement Element, vsCMChangeKind Change)
 {
     if (Change == vsCMChangeKind.vsCMChangeKindRename || Change == vsCMChangeKind.vsCMChangeKindUnknown)
     {
         SolutionNavigator.AddElement(Element);
     }
 }
 public static void RemoveElement(CodeElement toRemove)
 {
     if (SolutionNavigator.getInstance().Elements.Contains(toRemove))
     {
         SolutionNavigator.getInstance().Elements.Remove(toRemove);
     }
 }
 public static void AddElement(CodeElement toAdd)
 {
     if (!SolutionNavigator.getInstance().BlackList.Contains(toAdd.Kind))
     {
         SolutionNavigator.getInstance().Elements.Add(toAdd);
     }
 }
 public static SolutionNavigator getInstance()
 {
     if (singleton == null)
     {
         singleton = new SolutionNavigator();
     }
     return(singleton);
 }
 private void MenuItemCallback(object sender, EventArgs e)
 {
     if (SolutionNavigator.getInstance().IsNavigated&& _dte.ActiveDocument != null && _dte.ActiveDocument.Selection != null)
     {
         if (!(SolutionNavigator.getInstance().Elements.Count > 0))
         {
             SolutionNavigator.Navigate(_dte.Solution.Projects);
         }
         HackThatDef();
     }
 }
        private void HackThatDef()
        {
            string startWord       = Utilities.GetWordFromSelection((TextSelection)_dte.ActiveDocument.Selection);
            string currentDocument = _dte.ActiveDocument.Name;
            Window objectBrowser   = GetObjectBrowser();
            bool   OBWasOpen       = (objectBrowser != null && objectBrowser.Visible);

            _dte.ExecuteCommand("Edit.GoToDefinition");
            string      name          = _dte.ActiveDocument.ActiveWindow.Caption;
            string      elementPath   = String.Empty;
            CodeElement targetElement = null;

            if (name.Equals(currentDocument))   // VB to C# and some reference types
            {
                objectBrowser = GetObjectBrowser();
                if (objectBrowser != null && objectBrowser.Visible)
                {
                    _dte.ExecuteCommand("Edit.Copy");
                    elementPath = Clipboard.GetText();
                    elementPath = elementPath.Substring(0, elementPath.LastIndexOf('.'));

                    if (!OBWasOpen)
                    {
                        objectBrowser.Close();
                    }
                }

                targetElement = Utilities.ReduceResultSet(_dte, SolutionNavigator.getInstance().Elements, elementPath, startWord);

                if (targetElement != null)
                {
                    ChangeActiveDocument(targetElement);
                }
            }
            else if (name.Contains("from metadata"))    // C# to VB and the rest of the reference types
            {
                elementPath   = _dte.ActiveDocument.Name.Substring(0, _dte.ActiveDocument.Name.Length - 3);
                targetElement = Utilities.ReduceResultSet(_dte, SolutionNavigator.getInstance().Elements, elementPath, startWord);

                if (targetElement != null)
                {
                    _dte.ActiveWindow.Close();
                    ChangeActiveDocument(targetElement);
                }
            }
        }
Beispiel #7
0
 int IVsSolutionEvents.OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
 {
     SolutionNavigator.Navigate(_dte.Solution.Projects);
     AddCodeElementHandlers();
     return(VSConstants.S_OK);
 }
Beispiel #8
0
 int IVsSolutionEvents.OnAfterCloseSolution(object pUnkReserved)
 {
     SolutionNavigator.getInstance().IsNavigated = false;
     RemoveCodeElementHandlers();
     return(VSConstants.S_OK);
 }
Beispiel #9
0
 private void DeletedEventHandler(object Parent, CodeElement Element)
 {
     SolutionNavigator.RemoveElement(Element);
 }
Beispiel #10
0
 private void AddedEventHandler(CodeElement Element)
 {
     SolutionNavigator.AddElement(Element);
 }
 public static List <CodeElement> Navigate(Projects projects)
 {
     SolutionNavigator.getInstance().NavigateProjects(projects);
     SolutionNavigator.getInstance().IsNavigated = true;
     return(singleton.Elements);
 }