예제 #1
0
        ToolStripMenuItem MakeItemForUnknownClass(IClass callingClass, string unknownClassName, TextArea textArea)
        {
            if (callingClass == null)
            {
                return(null);
            }
            IProjectContent pc = callingClass.ProjectContent;

            if (!pc.Language.RefactoringProvider.IsEnabledForFile(callingClass.CompilationUnit.FileName))
            {
                return(null);
            }
            ToolStripMenuItem item          = MakeItemInternal(unknownClassName, ClassBrowserIconService.GotoArrowIndex, callingClass.CompilationUnit, DomRegion.Empty);
            List <IClass>     searchResults = new List <IClass>();

            SearchAllClassesWithName(searchResults, pc, unknownClassName, pc.Language);
            foreach (IProjectContent rpc in pc.ReferencedContents)
            {
                SearchAllClassesWithName(searchResults, rpc, unknownClassName, pc.Language);
            }
            if (searchResults.Count == 0)
            {
                return(null);
            }
            foreach (IClass c in searchResults)
            {
                string            newNamespace = c.Namespace;
                ToolStripMenuItem subItem      = new ToolStripMenuItem("using " + newNamespace, ClassBrowserIconService.ImageList.Images[ClassBrowserIconService.NamespaceIndex]);
                item.DropDownItems.Add(subItem);
                subItem.Click += delegate {
                    NamespaceRefactoringService.AddUsingDeclaration(callingClass.CompilationUnit, textArea.Document, newNamespace, true);
                    ParserService.StartAsyncParse(callingClass.CompilationUnit.FileName, textArea.Document.TextContent);
                    textArea.MotherTextEditorControl.Refresh();
                };
            }
            return(item);
        }
예제 #2
0
 public void Execute()
 {
     NamespaceRefactoringService.AddUsingDeclaration(CompilationUnit, Editor.Document, NewNamespace, true);
     ParserService.BeginParse(Editor.FileName, Editor.Document);
 }