Task IService.Initialize(ServiceProvider serviceProvider) { //keep nav points up to date serviceProvider.WhenServiceInitialized <RootWorkspace> (s => { workspace = s; workspace.LastWorkspaceItemClosed += Workspace_LastWorkspaceItemClosed; workspace.FileRenamedInProject += FileRenamed; }); serviceProvider.WhenServiceInitialized <DocumentManager> (s => { documentManager = s; documentManager.DocumentOpened += DocumentManager_DocumentOpened; documentManager.DocumentClosing += DocumentManager_DocumentClosing; documentManager.ActiveDocumentChanged += ActiveDocChanged; }); return(Task.CompletedTask); }
protected override async Task OnInitialize(ServiceProvider serviceProvider) { IntitializeTrackedProjectHandling(); serviceProvider.WhenServiceInitialized <CompositionManager> (s => { miscellaneousFilesWorkspace = CompositionManager.Instance.GetExportedValue <MiscellaneousFilesWorkspace> (); serviceProvider.WhenServiceInitialized <DocumentManager> (dm => { documentManager = dm; }); }); serviceProvider.WhenServiceInitialized <RootWorkspace> (s => { rootWorkspace = s; rootWorkspace.ActiveConfigurationChanged += HandleActiveConfigurationChanged; }); RoslynServices.RoslynService.Initialize(); CleanupCache(); #pragma warning disable CS0618, 612 // Type or member is obsolete parsers = AddinManager.GetExtensionNodes <TypeSystemParserNode> ("/MonoDevelop/TypeSystem/Parser"); bool initialLoad = true; AddinManager.AddExtensionNodeHandler("/MonoDevelop/TypeSystem/Parser", delegate(object sender, ExtensionNodeEventArgs args) { //refresh entire list to respect insertbefore/insertafter ordering if (!initialLoad) { parsers = AddinManager.GetExtensionNodes <TypeSystemParserNode> ("/MonoDevelop/TypeSystem/Parser"); } }); #pragma warning restore CS0618, 612 // Type or member is obsolete initialLoad = false; try { compositionManager = await serviceProvider.GetService <CompositionManager> ().ConfigureAwait(false); emptyWorkspace = new MonoDevelopWorkspace(compositionManager.HostServices, null, this); await emptyWorkspace.Initialize().ConfigureAwait(false); } catch (Exception e) { LoggingService.LogFatalError("Can't create roslyn workspace", e); } FileService.FileChanged += FileService_FileChanged; desktopService = await serviceProvider.GetService <DesktopService> (); await serviceProvider.GetService <HelpService> (); }
public override int GetHashCode() { unchecked { int hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CreatedBy != null ? CreatedBy.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ LastUpdated.GetHashCode(); hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0); hashCode = (hashCode * 397) ^ VersionCounter.GetHashCode(); hashCode = (hashCode * 397) ^ (RootWorkspace != null ? RootWorkspace.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Components != null ? Components.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (References != null ? References.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { int hashCode = (CreatedBy != null ? CreatedBy.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ LastUpdated.GetHashCode(); hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0); hashCode = (hashCode * 397) ^ VersionCounter.GetHashCode(); hashCode = (hashCode * 397) ^ (RootWorkspace != null ? RootWorkspace.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Source != null ? Source.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Target != null ? Target.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Type; hashCode = (hashCode * 397) ^ Order; hashCode = (hashCode * 397) ^ (ReturnValue != null ? ReturnValue.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { int hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Model != null ? Model.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (State != null ? State.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CreatedBy != null ? CreatedBy.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ LastUpdated.GetHashCode(); hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0); hashCode = (hashCode * 397) ^ VersionCounter.GetHashCode(); hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (RootWorkspace != null ? RootWorkspace.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Children != null ? Children.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Parent != null ? Parent.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Type != null ? Type.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TypeId != null ? TypeId.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0); return(hashCode); } }
public static void Initialize (IProgressMonitor monitor) { Counters.Initialization.Trace ("Creating Workbench"); workbench = new Workbench (); Counters.Initialization.Trace ("Creating Root Workspace"); workspace = new RootWorkspace (); Counters.Initialization.Trace ("Creating Services"); projectOperations = new ProjectOperations (); helpOperations = new HelpOperations (); commandService = new CommandManager (); ideServices = new IdeServices (); CustomToolService.Init (); AutoTestService.Start (commandService, Preferences.EnableAutomatedTesting); commandService.CommandTargetScanStarted += CommandServiceCommandTargetScanStarted; commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished; KeyBindingService.LoadBindingsFromExtensionPath ("/MonoDevelop/Ide/KeyBindingSchemes"); KeyBindingService.LoadCurrentBindings ("MD2"); commandService.CommandError += delegate (object sender, CommandErrorArgs args) { MessageService.ShowException (args.Exception, args.ErrorMessage); }; FileService.ErrorHandler = FileServiceErrorHandler; monitor.BeginTask (GettextCatalog.GetString("Loading Workbench"), 5); Counters.Initialization.Trace ("Loading Commands"); commandService.LoadCommands ("/MonoDevelop/Ide/Commands"); monitor.Step (1); Counters.Initialization.Trace ("Initializing Workbench"); workbench.Initialize (monitor); monitor.Step (1); InternalLog.EnableErrorNotification (); monitor.Step (1); Counters.Initialization.Trace ("Restoring Workbench State"); workbench.Show ("SharpDevelop.Workbench.WorkbenchMemento"); monitor.Step (1); Counters.Initialization.Trace ("Flushing GUI events"); DispatchService.RunPendingEvents (); Counters.Initialization.Trace ("Flushed GUI events"); MessageService.RootWindow = workbench.RootWindow; commandService.EnableIdleUpdate = true; // Default file format MonoDevelop.Projects.Services.ProjectServiceLoaded += delegate(object sender, EventArgs e) { ((ProjectService)sender).DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat; }; IdeApp.Preferences.DefaultProjectFileFormatChanged += delegate { IdeApp.Services.ProjectService.DefaultFileFormatId = IdeApp.Preferences.DefaultProjectFileFormat; }; // Perser service initialization MonoDevelop.Projects.Dom.Parser.ProjectDomService.TrackFileChanges = true; MonoDevelop.Projects.Dom.Parser.ProjectDomService.ParseProgressMonitorFactory = new ParseProgressMonitorFactory (); // Startup commands Counters.Initialization.Trace ("Running Startup Commands"); AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged); monitor.EndTask (); // Set initial run flags Counters.Initialization.Trace ("Upgrading Settings"); if (PropertyService.Get("MonoDevelop.Core.FirstRun", false)) { isInitialRun = true; PropertyService.Set ("MonoDevelop.Core.FirstRun", false); PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion); PropertyService.Set ("MonoDevelop.Core.LastRunVersion", CurrentRevision); PropertyService.SaveProperties (); } string lastVersion = PropertyService.Get ("MonoDevelop.Core.LastRunVersion", "1.9.1"); int lastRevision = PropertyService.Get ("MonoDevelop.Core.LastRunRevision", 0); if (lastRevision != CurrentRevision && !isInitialRun) { isInitialRunAfterUpgrade = true; if (lastRevision == 0) { switch (lastVersion) { case "1.0": lastRevision = 1; break; case "2.0": lastRevision = 2; break; case "2.2": lastRevision = 3; break; case "2.2.1": lastRevision = 4; break; } } upgradedFromRevision = lastRevision; PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildVariables.PackageVersion); PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties (); } // The ide is now initialized isInitialized = true; if (isInitialRun) { try { OnInitialRun (); } catch (Exception e) { LoggingService.LogError ("Error found while initializing the IDE", e); } } if (isInitialRunAfterUpgrade) { try { OnUpgraded (upgradedFromRevision); } catch (Exception e) { LoggingService.LogError ("Error found while initializing the IDE", e); } } if (initializedEvent != null) initializedEvent (null, EventArgs.Empty); // load previous combine if ((bool)PropertyService.Get("SharpDevelop.LoadPrevProjectOnStartup", false)) { RecentOpen recentOpen = Workbench.RecentOpen; if (recentOpen.RecentProjectsCount > 0) { IdeApp.Workspace.OpenWorkspaceItem(recentOpen.RecentProjects.First ().ToString()).WaitForCompleted (); } } commandService.CommandSelected += OnCommandSelected; commandService.CommandDeselected += OnCommandDeselected; //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS MonoDevelop.Projects.HelpService.AsyncInitialize (); UpdateInstrumentationIcon (); IdeApp.Preferences.EnableInstrumentationChanged += delegate { UpdateInstrumentationIcon (); }; AutoTestService.NotifyEvent ("MonoDevelop.Ide.IdeStart"); }
public static bool GetIsWorkspaceOpen(this RootWorkspace workspace) { return(workspace.GetAllSolutions().Count > 0); }
public static bool GetIsDocumentOpen(this RootWorkspace workspace) { return(IdeApp.Workbench.ActiveDocument != null); }
private static void WriteSolution() { AddinManager.Initialize(Option.AddinConfigFolder); AddinManager.Registry.Update(); DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Test")); if (!directoryInfo.Exists) { directoryInfo.Create(); } RootWorkspace workspace = Services.Workspace; Solution parentSolution = new Solution(); parentSolution.SetLocation((FilePath)AppDomain.CurrentDomain.BaseDirectory, "Game"); Services.ProjectOperations.CurrentSelectedSolution = parentSolution; ResourceGroup resourceGroup = new ResourceGroup(parentSolution); ResourceFile resourceFile1 = new ResourceFile((FilePath)TestHelp.GetFullPath("CocoStudio.Basic.pdb")); resourceGroup.RootFolder.Items.Add((ResourceItem)resourceFile1); ResourceFolder resourceFolder1 = new ResourceFolder((FilePath)TestHelp.GetFullPath("EditorDefaultRes")); resourceGroup.RootFolder.Items.Add((ResourceItem)resourceFolder1); ResourceFile resourceFile2 = new ResourceFile((FilePath)TestHelp.GetFullPath("EditorDefaultRes/Test.xml")); resourceFolder1.Items.Add((ResourceItem)resourceFile2); ResourceFolder resourceFolder2 = new ResourceFolder((FilePath)TestHelp.GetFullPath("Test")); resourceGroup.RootFolder.Items.Add((ResourceItem)resourceFolder2); ResourceFile resourceFile3 = new ResourceFile((FilePath)TestHelp.GetFullPath("Test/1.txt")); resourceFolder2.Items.Add((ResourceItem)resourceFile3); ImageFile imageFile1 = new ImageFile((FilePath)TestHelp.GetFullPath("Test/1.png")); resourceFolder2.Items.Add((ResourceItem)imageFile1); ImageFile imageFile2 = new ImageFile((FilePath)TestHelp.GetFullPath("Test/2.png")); resourceFolder2.Items.Add((ResourceItem)imageFile2); ImageFile imageFile3 = new ImageFile((FilePath)TestHelp.GetFullPath("Test/3.png")); resourceFolder2.Items.Add((ResourceItem)imageFile3); ImageFile imageFile4 = new ImageFile((FilePath)TestHelp.GetFullPath("Test/4.png")); resourceFolder2.Items.Add((ResourceItem)imageFile4); Project project1 = Services.ProjectsService.CreateProject("Node", new ProjectCreateInformation((FilePath)TestHelp.GetFullPath("Test/1.csd"), (IProjectContent) new GameProjectContent() { Content = new GameProjectData() }, (IList <ResourceItem>)null, 0.0f, 0.0f)); resourceFolder2.Items.Add((ResourceItem)project1); Project project2 = Services.ProjectsService.CreateProject("Node", new ProjectCreateInformation((FilePath)TestHelp.GetFullPath("Test/2.csd"), (IProjectContent) new GameProjectContent() { Content = new GameProjectData() }, (IList <ResourceItem>)null, 0.0f, 0.0f)); resourceFolder2.Items.Add((ResourceItem)project2); parentSolution.RootFolder.Items.Add((SolutionEntityItem)resourceGroup); workspace.Items.Add((WorkspaceItem)parentSolution); SimpleProgressMonitor simpleProgressMonitor = new SimpleProgressMonitor(); workspace.Save((IProgressMonitor)simpleProgressMonitor); }
public static void Initialize (ProgressMonitor monitor) { // Already done in IdeSetup, but called again since unit tests don't use IdeSetup. DispatchService.Initialize (); Counters.Initialization.Trace ("Creating Workbench"); workbench = new Workbench (); Counters.Initialization.Trace ("Creating Root Workspace"); workspace = new RootWorkspace (); Counters.Initialization.Trace ("Creating Services"); projectOperations = new ProjectOperations (); helpOperations = new HelpOperations (); commandService = new CommandManager (); ideServices = new IdeServices (); CustomToolService.Init (); commandService.CommandTargetScanStarted += CommandServiceCommandTargetScanStarted; commandService.CommandTargetScanFinished += CommandServiceCommandTargetScanFinished; commandService.KeyBindingFailed += KeyBindingFailed; KeyBindingService.LoadBindingsFromExtensionPath ("/MonoDevelop/Ide/KeyBindingSchemes"); KeyBindingService.LoadCurrentBindings ("MD2"); commandService.CommandError += delegate (object sender, CommandErrorArgs args) { LoggingService.LogInternalError (args.ErrorMessage, args.Exception); }; FileService.ErrorHandler = FileServiceErrorHandler; monitor.BeginTask (GettextCatalog.GetString("Loading Workbench"), 5); Counters.Initialization.Trace ("Loading Commands"); commandService.LoadCommands ("/MonoDevelop/Ide/Commands"); monitor.Step (1); Counters.Initialization.Trace ("Initializing Workbench"); workbench.Initialize (monitor); monitor.Step (1); MonoDevelop.Ide.WelcomePage.WelcomePageService.Initialize (); MonoDevelop.Ide.WelcomePage.WelcomePageService.ShowWelcomePage (); monitor.Step (1); Counters.Initialization.Trace ("Restoring Workbench State"); workbench.Show ("SharpDevelop.Workbench.WorkbenchMemento"); monitor.Step (1); Counters.Initialization.Trace ("Flushing GUI events"); DispatchService.RunPendingEvents (); Counters.Initialization.Trace ("Flushed GUI events"); MessageService.RootWindow = workbench.RootWindow; commandService.EnableIdleUpdate = true; // Perser service initialization TypeSystemService.TrackFileChanges = true; if (Customizer != null) Customizer.OnIdeInitialized (); // Startup commands Counters.Initialization.Trace ("Running Startup Commands"); AddinManager.AddExtensionNodeHandler ("/MonoDevelop/Ide/StartupHandlers", OnExtensionChanged); monitor.Step (1); monitor.EndTask (); // Set initial run flags Counters.Initialization.Trace ("Upgrading Settings"); if (PropertyService.Get("MonoDevelop.Core.FirstRun", false)) { isInitialRun = true; PropertyService.Set ("MonoDevelop.Core.FirstRun", false); PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildInfo.Version); PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties (); } string lastVersion = PropertyService.Get ("MonoDevelop.Core.LastRunVersion", "1.9.1"); int lastRevision = PropertyService.Get ("MonoDevelop.Core.LastRunRevision", 0); if (lastRevision != CurrentRevision && !isInitialRun) { isInitialRunAfterUpgrade = true; if (lastRevision == 0) { switch (lastVersion) { case "1.0": lastRevision = 1; break; case "2.0": lastRevision = 2; break; case "2.2": lastRevision = 3; break; case "2.2.1": lastRevision = 4; break; } } upgradedFromRevision = lastRevision; PropertyService.Set ("MonoDevelop.Core.LastRunVersion", BuildInfo.Version); PropertyService.Set ("MonoDevelop.Core.LastRunRevision", CurrentRevision); PropertyService.SaveProperties (); } // The ide is now initialized isInitialized = true; if (isInitialRun) { try { OnInitialRun (); } catch (Exception e) { LoggingService.LogError ("Error found while initializing the IDE", e); } } if (isInitialRunAfterUpgrade) { try { OnUpgraded (upgradedFromRevision); } catch (Exception e) { LoggingService.LogError ("Error found while initializing the IDE", e); } } if (initializedEvent != null) { initializedEvent (null, EventArgs.Empty); initializedEvent = null; } //FIXME: we should really make this on-demand. consumers can display a "loading help cache" message like VS MonoDevelop.Projects.HelpService.AsyncInitialize (); UpdateInstrumentationIcon (); IdeApp.Preferences.EnableInstrumentation.Changed += delegate { UpdateInstrumentationIcon (); }; AutoTestService.Start (commandService, Preferences.EnableAutomatedTesting); AutoTestService.NotifyEvent ("MonoDevelop.Ide.IdeStart"); Gtk.LinkButton.SetUriHook ((button, uri) => Xwt.Desktop.OpenUrl (uri)); }