Exemple #1
0
        private void btnStartLongTimeAction_Click(object sender, EventArgs e)
        {
            var       progressDlg = AsynchronousWaitDialog.ShowWaitDialog("已开启长时间耗时处理,请耐心等待...");
            ThreadArg tArg        = new ThreadArg(progressDlg);

            TestThread(tArg);
        }
Exemple #2
0
        public override void Run()
        {
            ICollection <ResourceItem> unusedKeys;

            // Allow the menu to close
            Application.DoEvents();
            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:Hornung.ResourceToolkit.FindUnusedResourceKeys}")) {
                unusedKeys = ResourceRefactoringService.FindUnusedKeys(monitor);
            }

            if (unusedKeys == null)
            {
                return;
            }

            if (unusedKeys.Count == 0)
            {
                MessageService.ShowMessage("${res:Hornung.ResourceToolkit.UnusedResourceKeys.NotFound}");
                return;
            }

            IWorkbench workbench = WorkbenchSingleton.Workbench;

            if (workbench != null)
            {
                UnusedResourceKeysViewContent vc = new UnusedResourceKeysViewContent(unusedKeys);
                workbench.ShowView(vc);
            }
        }
        public override void Run()
        {
            var selectedItem = GetSelectedItems().FirstOrDefault();

            if (selectedItem == null)
            {
                return;
            }

            ITypeDefinition c = GetClassFromName(selectedItem.FullyQualifiedClassName);

            if (c == null)
            {
                return;
            }

            IMember member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters);

            if (member == null)
            {
                return;
            }

            string memberName = member.DeclaringType.Name + "." + member.Name;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}"))
            {
                FindReferencesAndRenameHelper.RunFindReferences(member);
            }
        }
Exemple #4
0
        void FindReferences(object sender, EventArgs e)
        {
            MenuCommand cmd = sender as MenuCommand;

            if (cmd == null)
            {
                return;
            }

            ResourceResolveResult result = cmd.Tag as ResourceResolveResult;

            if (result == null)
            {
                return;
            }

            // Allow the menu to close
            Application.DoEvents();
            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog(ResourceService.GetString("SharpDevelop.Refactoring.FindReferences"))) {
                FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:Hornung.ResourceToolkit.ReferencesToResource}", new string[, ] {
                    { "ResourceFileName", System.IO.Path.GetFileName(result.FileName) }, { "ResourceKey", result.Key }
                }),
                                                                  ResourceRefactoringService.FindReferences(result.FileName, result.Key, monitor));
            }
        }
        public override void Run()
        {
            var selectedItem = GetSelectedItems().FirstOrDefault();

            if (selectedItem == null)
            {
                return;
            }

            IClass c = GetClassFromName(selectedItem.FullyQualifiedClassName);

            if (c == null)
            {
                return;
            }

            IMember member = GetMemberFromName(c, selectedItem.MethodName, selectedItem.Parameters);

            if (member == null)
            {
                return;
            }

            string memberName = member.DeclaringType.Name + "." + member.Name;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}"))
            {
                FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}",
                                                                                     new string[, ] {
                    { "Name", memberName }
                }),
                                                                  RefactoringService.FindReferences(member, monitor));
            }
        }
        public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(OpenedFile file)
        {
            ProfilingDataSQLiteProvider provider;

            try {
                provider = ProfilingDataSQLiteProvider.FromFile(file.FileName);
            } catch (IncompatibleDatabaseException e) {
                if (e.ActualVersion == new Version(1, 0))
                {
                    if (MessageService.AskQuestion("Upgrade DB?"))
                    {
                        using (AsynchronousWaitDialog.ShowWaitDialog("Upgrading database...")) {
                            provider = ProfilingDataSQLiteProvider.UpgradeFromOldVersion(file.FileName);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    MessageService.ShowErrorFormatted("${res:AddIns.Profiler.DatabaseTooNewError}", e.ActualVersion.ToString(), e.ExpectedVersion.ToString());
                    return(null);
                }
            }
            return(new WpfViewer(file, provider));
        }
Exemple #7
0
        /// <summary>
        /// 当前调用线程中执行任务处理。
        /// </summary>
        public void StartTask()
        {
            var       progressDlg = AsynchronousWaitDialog.ShowWaitDialog("已开启长时间耗时处理,请耐心等待...");
            ThreadArg tArg        = new ThreadArg(progressDlg);

            TestThread(tArg);
        }
Exemple #8
0
        void FinishSession()
        {
            try {
                using (AsynchronousWaitDialog dlg = AsynchronousWaitDialog.ShowWaitDialog(StringParser.Parse("${res:AddIns.Profiler.Messages.PreparingForAnalysis}"), true)) {
                    profiler.Dispose();

                    WorkbenchSingleton.SafeThreadAsyncCall(() => { controlWindow.AllowClose = true; this.controlWindow.Close(); });
                    if (database != null)
                    {
                        database.WriteTo(writer, progress => {
                            dlg.Progress = progress;
                            return(!dlg.CancellationToken.IsCancellationRequested);
                        });
                        writer.Close();
                        database.Close();
                    }
                    else
                    {
                        writer.Close();
                    }

                    if (!dlg.CancellationToken.IsCancellationRequested)
                    {
                        OnRunFinished(EventArgs.Empty);
                    }
                }
            } catch (Exception ex) {
                MessageService.ShowException(ex);
            }
        }
Exemple #9
0
        public override void Run(ResolveResult symbol)
        {
            var entity = GetSymbol(symbol);

            if (entity != null)
            {
                var project = GetProjectFromSymbol(entity);
                if (project != null)
                {
                    var languageBinding = project.LanguageBinding;

                    RenameSymbolDialog renameDialog = new RenameSymbolDialog(name => CheckName(name, languageBinding))
                    {
                        Owner         = SD.Workbench.MainWindow,
                        OldSymbolName = entity.Name,
                        NewSymbolName = entity.Name
                    };
                    if ((bool)renameDialog.ShowDialog())
                    {
                        AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation(
                            "${res:SharpDevelop.Refactoring.Rename}",
                            progressMonitor =>
                            FindReferenceService.RenameSymbol(entity, renameDialog.NewSymbolName, progressMonitor)
                            .ObserveOnUIThread()
                            .Subscribe(error => SD.MessageService.ShowError(error.Message), ex => SD.MessageService.ShowException(ex), () => {}));
                    }
                }
            }
        }
        void OnPropertyGridPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (propertyGridView.PropertyGrid.ReloadActive)
            {
                return;
            }
            if (e.PropertyName == "Name")
            {
                if (!propertyGridView.PropertyGrid.IsNameCorrect)
                {
                    return;
                }

                // get the XAML file
                OpenedFile file = this.Files.FirstOrDefault(f => f.FileName.ToString().EndsWith(".xaml", StringComparison.OrdinalIgnoreCase));
                if (file == null)
                {
                    return;
                }

                // parse the XAML file
                ParseInformation info = SD.ParserService.Parse(file.FileName);
                if (info == null)
                {
                    return;
                }
                ICompilation compilation   = SD.ParserService.GetCompilationForFile(file.FileName);
                var          designerClass = info.UnresolvedFile.TopLevelTypeDefinitions[0]
                                             .Resolve(new SimpleTypeResolveContext(compilation.MainAssembly))
                                             .GetDefinition();
                if (designerClass == null)
                {
                    return;
                }
                var reparseFileNameList = designerClass.Parts.Select(p => new ICSharpCode.Core.FileName(p.UnresolvedFile.FileName)).ToArray();

                // rename the member
                ISymbol controlSymbol = designerClass.GetFields(f => f.Name == propertyGridView.PropertyGrid.OldName, GetMemberOptions.IgnoreInheritedMembers)
                                        .SingleOrDefault();
                if (controlSymbol != null)
                {
                    AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation(
                        "${res:SharpDevelop.Refactoring.Rename}",
                        progressMonitor =>
                        FindReferenceService.RenameSymbol(controlSymbol, propertyGridView.PropertyGrid.Name, progressMonitor)
                        .ObserveOnUIThread()
                        .Subscribe(error => SD.MessageService.ShowError(error.Message), // onNext
                                   ex => SD.MessageService.ShowException(ex),           // onError
                                                                                        // onCompleted
                                   () => {
                        foreach (var fileName in reparseFileNameList)
                        {
                            SD.ParserService.ParseAsync(fileName).FireAndForget();
                        }
                    }
                                   )
                        );
                }
            }
        }
        void FindReferences(object sender, EventArgs e)
        {
            MenuCommand item   = (MenuCommand)sender;
            IMember     member = (IMember)item.Tag;
            string      memberName;

            if (member is IProperty && ((IProperty)member).IsIndexer)
            {
                // The name of the default indexer is always "Indexer" in C#.
                // Add the type name to clarify which indexer is referred to.
                memberName = member.Name + " of " + member.DeclaringType.Name;
            }
            else
            {
                memberName = member.Name;
            }
            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}"))
            {
                FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}",
                                                                                     new string[, ] {
                    { "Name", memberName }
                }),
                                                                  RefactoringService.FindReferences(member, monitor));
            }
        }
		/// <summary>
		/// Shows a wait dialog.
		/// </summary>
		/// <param name="titleName">Title of the wait dialog</param>
		/// <param name="taskName">Name of the current task</param>
		/// <returns>WaitHandle object - you can use it to access the wait dialog's properties.
		/// To close the wait dialog, call Dispose() on the WaitHandle</returns>
		public static AsynchronousWaitDialog ShowWaitDialog(string titleName)
		{
			if (titleName == null)
				throw new ArgumentNullException("titleName");
			AsynchronousWaitDialog h = new AsynchronousWaitDialog(titleName);
			h.Start();
			return h;
		}
Exemple #13
0
 void Analyse(string[] fileNames)
 {
     context.AddAssemblyFiles(fileNames);
     using (context.progressMonitor = AsynchronousWaitDialog.ShowWaitDialog("Analysis"))
     {
         list = context.Analyze();
     }
 }
Exemple #14
0
 /// <summary>
 /// 后台线程执行任务处理。
 /// </summary>
 public void StartTaskByThread()
 {
     AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation("已开启线程处理,请耐心等待...", progressMonitor =>
     {
         ThreadArg tArg = new ThreadArg(progressMonitor);
         Task task      = new Task(TestThread, tArg);
         task.Start();
     });
 }
Exemple #15
0
 public static void Run(SearchScope scope)
 {
     // Allow the menu to close
     Application.DoEvents();
     using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:Hornung.ResourceToolkit.FindMissingResourceKeys}")) {
         FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:Hornung.ResourceToolkit.ReferencesToMissingKeys}"),
                                                           ResourceRefactoringService.FindReferencesToMissingKeys(monitor, scope));
     }
 }
Exemple #16
0
 private void btnStartThread_Click(object sender, EventArgs e)
 {
     AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation("已开启线程处理,请耐心等待...", progressMonitor =>
     {
         ThreadArg tArg = new ThreadArg(progressMonitor);
         Task task      = new Task(TestThread, tArg);
         task.Start();
     });
 }
Exemple #17
0
 public static void RunFindReferences(IClass c)
 {
     using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}", true)) {
         FindReferencesAndRenameHelper.ShowAsSearchResults(
             StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}",
                                new StringTagPair("Name", c.Name)),
             RefactoringService.FindReferences(c, monitor)
             );
     }
 }
        public static void Rename(ResourceResolveResult rrr)
        {
            string newKey = MessageService.ShowInputBox("${res:SharpDevelop.Refactoring.Rename}", "${res:Hornung.ResourceToolkit.RenameResourceText}", rrr.Key);

            if (!String.IsNullOrEmpty(newKey) && !newKey.Equals(rrr.Key))
            {
                using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.Rename}")) {
                    Rename(rrr, newKey, monitor);
                }
            }
        }
Exemple #19
0
        public static void RunFindReferences(IMember member)
        {
            string memberName = member.DeclaringType.Name + "." + member.Name;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}", true)) {
                FindReferencesAndRenameHelper.ShowAsSearchResults(
                    StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}",
                                       new StringTagPair("Name", memberName)),
                    RefactoringService.FindReferences(member, monitor));
            }
        }
        void OpenSolutionInternal(FileName fileName)
        {
            ISolution solution;

            using (var progress = AsynchronousWaitDialog.ShowWaitDialog("Loading Solution...")) {
                solution = LoadSolutionFile(fileName, progress);

                this.CurrentSolution = solution;
            }
            OnSolutionOpened(solution);
        }
        public override void Execute(object parameter)
        {
            SearchForIssuesDialog dlg = new SearchForIssuesDialog();

            dlg.Owner = SD.Workbench.MainWindow;
            if (dlg.ShowDialog() == true)
            {
                string title     = "Issue Search";
                var    providers = dlg.SelectedProviders.ToList();
                var    fileNames = GetFilesToSearch(dlg.Target).ToList();
                if (dlg.FixIssues)
                {
                    int fixedIssueCount = 0;
                    IReadOnlyList <SearchResultMatch> remainingIssues = null;
                    AsynchronousWaitDialog.RunInCancellableWaitDialog(
                        title, null,
                        monitor => {
                        remainingIssues = FindAndFixIssues(fileNames, providers, monitor, out fixedIssueCount);
                    });
                    if (remainingIssues == null)
                    {
                        return;                         // can happen if issue search is cancelled
                    }
                    string message = string.Format(
                        "{0} issues were fixed automatically." +
                        "{1} issues are remaining (no automatic fix available).",
                        fixedIssueCount, remainingIssues.Count);
                    SearchResultsPad.Instance.ShowSearchResults(title, remainingIssues);
                    MessageService.ShowMessage(message, title);
                }
                else if (Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Alt | ModifierKeys.Shift))
                {
                    // Ctrl+Alt+Shift => run issue search on main thread,
                    // this helps debugging as exceptions don't get caught and passed from one thread to another
                    List <SearchResultMatch> issues = new List <SearchResultMatch>();
                    AsynchronousWaitDialog.RunInCancellableWaitDialog(
                        title, null,
                        monitor => SearchForIssues(fileNames, providers, f => issues.AddRange(f.Matches), monitor)
                        );
                    SearchResultsPad.Instance.ShowSearchResults(title, issues);
                }
                else
                {
                    var monitor    = SD.StatusBar.CreateProgressMonitor();
                    var observable = ReactiveExtensions.CreateObservable <SearchedFile>(
                        (m, c) => SearchForIssuesAsync(fileNames, providers, c, m),
                        monitor);
                    SearchResultsPad.Instance.ShowSearchResults(title, observable);
                }
            }
        }
        public static void RenameClass(IClass c)
        {
            string newName = MessageService.ShowInputBox("${res:SharpDevelop.Refactoring.Rename}", "${res:SharpDevelop.Refactoring.RenameClassText}", c.Name);

            if (!FindReferencesAndRenameHelper.CheckName(newName, c.Name))
            {
                return;
            }

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.Rename}"))
            {
                RenameClass(c, newName);
            }
        }
Exemple #23
0
        void FindReferences(object sender, EventArgs e)
        {
            MenuCommand item       = (MenuCommand)sender;
            IMember     member     = (IMember)item.Tag;
            string      memberName = member.DeclaringType.Name + "." + member.Name;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}"))
            {
                FindReferencesAndRenameHelper.ShowAsSearchResults(StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}",
                                                                                     new string[, ] {
                    { "Name", memberName }
                }),
                                                                  RefactoringService.FindReferences(member, monitor));
            }
        }
        void FindReferences(object sender, EventArgs e)
        {
            MenuCommand item = (MenuCommand)sender;
            IClass      c    = (IClass)item.Tag;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.FindReferences}"))
            {
                FindReferencesAndRenameHelper.ShowAsSearchResults(
                    StringParser.Parse("${res:SharpDevelop.Refactoring.ReferencesTo}",
                                       new string[, ] {
                    { "Name", c.Name }
                }),
                    RefactoringService.FindReferences(c, monitor)
                    );
            }
        }
Exemple #25
0
        void PerformConversion(string translatedTitle, MSBuildBasedProject sourceProject, string targetProjectDirectory)
        {
            IProject targetProject;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog(translatedTitle, "Converting", true)) {
                Directory.CreateDirectory(targetProjectDirectory);
                targetProject = CreateProject(targetProjectDirectory, sourceProject);
                CopyProperties(sourceProject, targetProject);
                conversionLog.AppendLine();
                CopyItems(sourceProject, targetProject, monitor);
                monitor.CancellationToken.ThrowIfCancellationRequested();
                conversionLog.AppendLine();
                AfterConversion(targetProject);
                conversionLog.AppendLine(ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.ConversionComplete"));
                targetProject.Save();
                targetProject.Dispose();
            }

            TreeNode node = ProjectBrowserPad.Instance.SelectedNode;

            if (node == null)
            {
                node = ProjectBrowserPad.Instance.SolutionNode;
            }
            while (node != null)
            {
                if (node is ISolutionFolderNode)
                {
                    AddExitingProjectToSolution.AddProject((ISolutionFolderNode)node, targetProject.FileName);
                    ProjectService.SaveSolution();
                    break;
                }
                node = node.Parent;
            }
            IViewContent newFileWindow;

            newFileWindow = FileService.NewFile(ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.ConversionResults"), conversionLog.ToString());
            if (newFileWindow != null)
            {
                newFileWindow.PrimaryFile.IsDirty = false;
            }
        }
        void ConvertToAutomaticProperty(ITextEditor editor, IProperty property, IField fieldDef, Ast.PropertyDeclaration astProp)
        {
            CodeGenerator codeGen = property.DeclaringType.ProjectContent.Language.CodeGenerator;

            int fieldStartOffset = editor.Document.PositionToOffset(fieldDef.Region.BeginLine, fieldDef.Region.BeginColumn);
            int fieldEndOffset   = editor.Document.PositionToOffset(fieldDef.Region.EndLine, fieldDef.Region.EndColumn);

            int startOffset = editor.Document.PositionToOffset(property.Region.BeginLine, property.Region.BeginColumn);
            int endOffset   = editor.Document.PositionToOffset(property.BodyRegion.EndLine, property.BodyRegion.EndColumn);

            ITextAnchor startAnchor = editor.Document.CreateAnchor(startOffset);
            ITextAnchor endAnchor   = editor.Document.CreateAnchor(endOffset);

            if (astProp.HasGetRegion)
            {
                astProp.GetRegion.Block = null;
            }

            if (!astProp.HasSetRegion)
            {
                astProp.SetRegion          = new Ast.PropertySetRegion(null, null);
                astProp.SetRegion.Modifier = CodeGenerator.ConvertModifier(fieldDef.Modifiers, new ClassFinder(fieldDef))
                                             & (Ast.Modifiers.Private | Ast.Modifiers.Internal | Ast.Modifiers.Protected | Ast.Modifiers.Public);
            }

            Ast.FieldDeclaration f = ParseMember <Ast.FieldDeclaration>(Path.GetExtension(editor.FileName),
                                                                        GetMemberText(fieldDef, editor));
            astProp.Initializer = f.Fields.First().Initializer;

            if (astProp.HasSetRegion)
            {
                astProp.SetRegion.Block = null;
            }
            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.ConvertToAutomaticProperty}")) {
                var refs = RefactoringService.FindReferences(fieldDef, monitor);
                using (editor.Document.OpenUndoGroup()) {
                    FindReferencesAndRenameHelper.RenameReferences(refs, property.Name);
                    editor.Document.Remove(fieldStartOffset, fieldEndOffset - fieldStartOffset);
                    editor.Document.Replace(startAnchor.Offset, endAnchor.Offset - startAnchor.Offset, codeGen.GenerateCode(astProp, ""));
                }
            }
        }
Exemple #27
0
 public static void RunRename(ISymbol symbol, string newName = null)
 {
     if ((symbol is IMember) && ((symbol.SymbolKind == SymbolKind.Constructor) || (symbol.SymbolKind == SymbolKind.Destructor)))
     {
         // Don't rename constructors/destructors, rename their declaring type instead
         symbol = ((IMember)symbol).DeclaringType.GetDefinition();
     }
     if (symbol != null)
     {
         var project = GetProjectFromSymbol(symbol);
         if (project != null)
         {
             var languageBinding = project.LanguageBinding;
             if (newName == null)
             {
                 RenameSymbolDialog renameDialog = new RenameSymbolDialog(name => CheckName(name, languageBinding))
                 {
                     Owner         = SD.Workbench.MainWindow,
                     OldSymbolName = symbol.Name,
                     NewSymbolName = symbol.Name
                 };
                 if (renameDialog.ShowDialog() == true)
                 {
                     newName = renameDialog.NewSymbolName;
                 }
                 else
                 {
                     return;
                 }
             }
             AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation(
                 "${res:SharpDevelop.Refactoring.Rename}",
                 progressMonitor =>
                 FindReferenceService.RenameSymbol(symbol, newName, progressMonitor)
                 .ObserveOnUIThread()
                 .Subscribe(error => SD.MessageService.ShowError(error.Message), ex => SD.MessageService.ShowException(ex), () => {}));
         }
     }
 }
        public static bool RenameMember(IMember member, string newName)
        {
            List <Reference> list;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.Rename}"))
            {
                list = RefactoringService.FindReferences(member, monitor);
                if (list == null)
                {
                    return(false);
                }
                FindReferencesAndRenameHelper.RenameReferences(list, newName);
            }

            if (member is IField)
            {
                IProperty property = FindProperty((IField)member);
                if (property != null)
                {
                    string newPropertyName = member.DeclaringType.ProjectContent.Language.CodeGenerator.GetPropertyName(newName);
                    if (newPropertyName != newName && newPropertyName != property.Name)
                    {
                        if (MessageService.AskQuestionFormatted("${res:SharpDevelop.Refactoring.Rename}", "${res:SharpDevelop.Refactoring.RenameFieldAndProperty}", property.FullyQualifiedName, newPropertyName))
                        {
                            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog("${res:SharpDevelop.Refactoring.Rename}"))
                            {
                                list = RefactoringService.FindReferences(property, monitor);
                                if (list != null)
                                {
                                    FindReferencesAndRenameHelper.RenameReferences(list, newPropertyName);
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemple #29
0
        protected override void OnComponentRename(object component, string oldName, string newName)
        {
            base.OnComponentRename(component, oldName, newName);
            if (oldName != newName)
            {
                var primaryParseInfo = context.GetPrimaryFileParseInformation();
                var compilation      = context.GetCompilation();

                // Find designer class
                ITypeDefinition designerClass = FormsDesignerSecondaryDisplayBinding.GetDesignableClass(primaryParseInfo.UnresolvedFile, compilation, out primaryPart);

                ISymbol controlSymbol;
                if (DesignerLoaderHost != null && DesignerLoaderHost.RootComponent == component)
                {
                    controlSymbol = designerClass;
                }
                else
                {
                    controlSymbol = designerClass.GetFields(f => f.Name == oldName, GetMemberOptions.IgnoreInheritedMembers)
                                    .SingleOrDefault();
                }
                if (controlSymbol != null)
                {
                    AsynchronousWaitDialog.ShowWaitDialogForAsyncOperation(
                        "${res:SharpDevelop.Refactoring.Rename}",
                        progressMonitor =>
                        FindReferenceService.RenameSymbol(controlSymbol, newName, progressMonitor)
                        .ObserveOnUIThread()
                        .Subscribe(error => SD.MessageService.ShowError(error.Message), // onNext
                                   ex => SD.MessageService.ShowException(ex),           // onError
                                                                                        // onCompleted - force refresh of the DesignerCodeFile's parse info, because the code generator
                                                                                        // seems to work with an outdated version, when the document is saved.
                                   () => SD.ParserService.Parse(new FileName(context.DesignerCodeFileDocument.FileName), context.DesignerCodeFileDocument)
                                   )
                        );
                }
            }
        }
Exemple #30
0
        public static void HandleNotifications(SvnClientWrapper client)
        {
            client.Notify += delegate(object sender, NotificationEventArgs e) {
                AppendLine(e.Kind + e.Action + " " + e.Path);
            };
            AsynchronousWaitDialog waitDialog = null;

            client.OperationStarted += delegate(object sender, SubversionOperationEventArgs e) {
                if (waitDialog == null)
                {
                    waitDialog = AsynchronousWaitDialog.ShowWaitDialog("svn " + e.Operation);
//					waitDialog.Cancelled += delegate {
//						client.Cancel();
//					};
                }
            };
            client.OperationFinished += delegate {
                if (waitDialog != null)
                {
                    waitDialog.Dispose();
                    waitDialog = null;
                }
            };
        }
Exemple #31
0
        public override void Run()
        {
            conversionLog = new StringBuilder();
            string translatedTitle = ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.ProjectConverter");

            conversionLog.AppendLine(translatedTitle);
            conversionLog.Append('=', translatedTitle.Length);
            conversionLog.AppendLine();
            conversionLog.AppendLine();
            MSBuildBasedProject sourceProject = ProjectService.CurrentProject as MSBuildBasedProject;
            string targetProjectDirectory     = sourceProject.Directory + ".ConvertedTo" + TargetLanguageName;

            if (Directory.Exists(targetProjectDirectory))
            {
                MessageService.ShowMessageFormatted(translatedTitle, "${res:ICSharpCode.SharpDevelop.Commands.Convert.TargetAlreadyExists}", targetProjectDirectory);
                return;
            }
            conversionLog.Append(ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.SourceDirectory")).Append(": ");
            conversionLog.AppendLine(sourceProject.Directory);
            conversionLog.Append(ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.TargetDirectory")).Append(": ");
            conversionLog.AppendLine(targetProjectDirectory);

            IProject targetProject;

            using (AsynchronousWaitDialog monitor = AsynchronousWaitDialog.ShowWaitDialog(translatedTitle)) {
                Directory.CreateDirectory(targetProjectDirectory);
                targetProject = CreateProject(targetProjectDirectory, sourceProject);
                CopyProperties(sourceProject, targetProject);
                conversionLog.AppendLine();
                CopyItems(sourceProject, targetProject, monitor);
                if (monitor.IsCancelled)
                {
                    return;
                }
                conversionLog.AppendLine();
                AfterConversion(targetProject);
                conversionLog.AppendLine(ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.ConversionComplete"));
                targetProject.Save();
                targetProject.Dispose();
            }

            TreeNode node = ProjectBrowserPad.Instance.SelectedNode;

            if (node == null)
            {
                node = ProjectBrowserPad.Instance.SolutionNode;
            }
            while (node != null)
            {
                if (node is ISolutionFolderNode)
                {
                    AddExitingProjectToSolution.AddProject((ISolutionFolderNode)node, targetProject.FileName);
                    ProjectService.SaveSolution();
                    break;
                }
                node = node.Parent;
            }
            IViewContent newFileWindow;

            newFileWindow = FileService.NewFile(ResourceService.GetString("ICSharpCode.SharpDevelop.Commands.Convert.ConversionResults"), conversionLog.ToString());
            if (newFileWindow != null)
            {
                newFileWindow.PrimaryFile.IsDirty = false;
            }
        }