Exemplo n.º 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);
        }
Exemplo n.º 2
0
 protected override void Run(TextEditorControl textEditor, RefactoringProvider provider)
 {
     NamespaceRefactoringService.ManageUsings(textEditor.FileName, textEditor.Document, true, true);
 }
Exemplo n.º 3
0
 protected override void Run(ITextEditor textEditor, RefactoringProvider provider)
 {
     using (var pm = Gui.AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.RemoveUnusedImports}")) {
         NamespaceRefactoringService.ManageUsings(pm, textEditor.FileName, textEditor.Document, true, true);
     }
 }
Exemplo n.º 4
0
 public void Execute()
 {
     NamespaceRefactoringService.AddUsingDeclaration(CompilationUnit, Editor.Document, NewNamespace, true);
     ParserService.BeginParse(Editor.FileName, Editor.Document);
 }