Exemplo n.º 1
0
 private void ChangedEventHandler(CodeElement Element, vsCMChangeKind Change)
 {
     if (Change == vsCMChangeKind.vsCMChangeKindRename || Change == vsCMChangeKind.vsCMChangeKindUnknown)
     {
         SolutionNavigator.AddElement(Element);
     }
 }
Exemplo n.º 2
0
 public static void RemoveElement(CodeElement toRemove)
 {
     if (SolutionNavigator.getInstance().Elements.Contains(toRemove))
     {
         SolutionNavigator.getInstance().Elements.Remove(toRemove);
     }
 }
Exemplo n.º 3
0
 public static void AddElement(CodeElement toAdd)
 {
     if (!SolutionNavigator.getInstance().BlackList.Contains(toAdd.Kind))
     {
         SolutionNavigator.getInstance().Elements.Add(toAdd);
     }
 }
Exemplo n.º 4
0
 public static SolutionNavigator getInstance()
 {
     if (singleton == null)
     {
         singleton = new SolutionNavigator();
     }
     return(singleton);
 }
Exemplo n.º 5
0
 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();
     }
 }
Exemplo n.º 6
0
        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);
                }
            }
        }
Exemplo n.º 7
0
 int IVsSolutionEvents.OnAfterOpenSolution(object pUnkReserved, int fNewSolution)
 {
     SolutionNavigator.Navigate(_dte.Solution.Projects);
     AddCodeElementHandlers();
     return(VSConstants.S_OK);
 }
Exemplo n.º 8
0
 int IVsSolutionEvents.OnAfterCloseSolution(object pUnkReserved)
 {
     SolutionNavigator.getInstance().IsNavigated = false;
     RemoveCodeElementHandlers();
     return(VSConstants.S_OK);
 }
Exemplo n.º 9
0
 private void DeletedEventHandler(object Parent, CodeElement Element)
 {
     SolutionNavigator.RemoveElement(Element);
 }
Exemplo n.º 10
0
 private void AddedEventHandler(CodeElement Element)
 {
     SolutionNavigator.AddElement(Element);
 }
Exemplo n.º 11
0
 public static List <CodeElement> Navigate(Projects projects)
 {
     SolutionNavigator.getInstance().NavigateProjects(projects);
     SolutionNavigator.getInstance().IsNavigated = true;
     return(singleton.Elements);
 }