private static string GetLatestAvailableTypeScriptVersionFromSetup() { var setupCompositionService = (IVsSetupCompositionService)CommonPackage.GetGlobalService(typeof(SVsSetupCompositionService)); // Populate the package status uint count = 0; uint sizeNeeded = 0; IVsSetupPackageInfo[] packages = null; setupCompositionService.GetSetupPackagesInfo(count, packages, out sizeNeeded); if (sizeNeeded > 0) { packages = new IVsSetupPackageInfo[sizeNeeded]; count = sizeNeeded; setupCompositionService.GetSetupPackagesInfo(count, packages, out sizeNeeded); return(packages.Where(p => (__VsSetupPackageState)p.CurrentState == __VsSetupPackageState.INSTALL_PACKAGE_PRESENT) .Select(p => p.PackageId) .Where(p => p.StartsWith(tsSdkSetupPackageIdPrefix)) .Select(p => p.Substring(tsSdkSetupPackageIdPrefix.Length, p.Length - tsSdkSetupPackageIdPrefix.Length)) .OrderByDescending(v => v) .First()); } return(""); }
public PublishProject(CommonProjectNode node, PublishProjectOptions options) { _statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); _statusBar.SetText("Starting publish..."); _node = node; _options = options; }
private void UpdateStatusForIncompleteAnalysis() { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); var analyzer = _textView.GetAnalyzer(); if (analyzer != null && analyzer.IsAnalyzing) { statusBar.SetText("Node.js source analysis is not up to date"); } }
public void RedirectOutput() { var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; char[] buffer = new char[1024]; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowDebugPane, out pane))) { pane.Activate(); while (!_process.HasExited) { int bytesRead = _reader.Read(buffer, 0, buffer.Length); pane.OutputString(new string(buffer, 0, bytesRead)); } if (_reportExit) { if (_process.ExitCode != 0) { SetStatus("Submitting job failed."); } } } }
private void UpdateStatusForIncompleteAnalysis() { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); if (!IronPythonToolsPackage.Instance.Analyzer.IsAnalyzing) { statusBar.SetText("Python source analysis is not up to date"); } }
private static void EnsureGeneralPane() { if (!_createdGeneralPane) { var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); var guid = VSConstants.GUID_OutWindowGeneralPane; outWin.CreatePane(ref guid, "General", 1, 0); _createdGeneralPane = true; } }
/// <summary> /// Publishes the project as configured by the user in the Publish option page. /// /// If async is true this function begins the publishing and returns w/o waiting for it to complete. No errors are reported. /// /// If async is false this function waits for the publish to finish and raises a PublishFailedException with an /// inner exception indicating the underlying reason for the publishing failure. /// /// Returns true if the publish was succeessfully started, false if the project is not configured for publishing /// </summary> public bool Publish(PublishProjectOptions publishOptions, bool async) { string publishUrl = publishOptions.DestinationUrl ?? GetProjectProperty(CommonConstants.PublishUrl); bool found = false; if (!String.IsNullOrWhiteSpace(publishUrl)) { var url = new Url(publishUrl); var publishers = CommonPackage.ComponentModel.GetExtensions <IProjectPublisher>(); foreach (var publisher in publishers) { if (publisher.Schema == url.Uri.Scheme) { var project = new PublishProject(this, publishOptions); Exception failure = null; var frame = new DispatcherFrame(); var thread = new System.Threading.Thread(x => { try { publisher.PublishFiles(project, url.Uri); project.Done(); frame.Continue = false; } catch (Exception e) { failure = e; project.Failed(e.Message); frame.Continue = false; } }); thread.Start(); found = true; if (!async) { Dispatcher.PushFrame(frame); if (failure != null) { throw new PublishFailedException(String.Format("Publishing of the project {0} failed", Caption), failure); } } break; } } if (!found) { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); statusBar.SetText(String.Format("Publish failed: Unknown publish scheme ({0})", url.Uri.Scheme)); } } else { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); statusBar.SetText(String.Format("Project is not configured for publishing in project properties.")); } return(found); }
private static void OutputState(string state) { var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) { pane.Activate(); pane.OutputString(state + Environment.NewLine); } }
private static void ScheduleJob(ClusterEnvironment clusterEnv, ISchedulerJob job) { var jobPath = Path.Combine(Environment.GetEnvironmentVariable("CCP_HOME"), "Bin\\job.exe"); var info = new ProcessStartInfo(jobPath, "submit /id:" + job.Id + " /scheduler:" + clusterEnv.HeadNode); var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) { pane.Activate(); pane.OutputString("Submitting job using command " + info.FileName + " " + info.Arguments + Environment.NewLine); } LaunchRedirectedToVsOutputWindow(info); }
private static void AddJobStateStatusUpdate(ISchedulerJob job, ISchedulerTask[] tasks) { job.OnTaskState += (sender, args) => { if (args.NewState == TaskState.Failed || args.NewState == TaskState.Finished) { string output = tasks[0].Output; if (!String.IsNullOrWhiteSpace(output)) { var outWin = (IVsOutputWindow)CommonPackage.GetGlobalService(typeof(IVsOutputWindow)); IVsOutputWindowPane pane; if (ErrorHandler.Succeeded(outWin.GetPane(VSConstants.GUID_OutWindowGeneralPane, out pane))) { pane.Activate(); pane.OutputString(output); } } } }; }
/// <summary> /// Opens the find symbols dialog with a list of results. This is done by requesting /// that VS does a search against our library GUID. Our library then responds to /// that request by extracting the prvoided symbol list out and using that for the /// search results. /// </summary> private static void ShowFindSymbolsDialog(ExpressionAnalysis provider, IVsNavInfo symbols) { // ensure our library is loaded so find all references will go to our library //Package.GetGlobalService(typeof(IPythonLibraryManager)); if (provider.Expression != String.Empty) { var findSym = (IVsFindSymbol)NodejsPackage.GetGlobalService(typeof(SVsObjectSearch)); VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2(); searchCriteria.eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD; searchCriteria.pIVsNavInfo = symbols; searchCriteria.grfOptions = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES; searchCriteria.szName = provider.Expression; Guid guid = Guid.Empty; // new Guid("{a5a527ea-cf0a-4abf-b501-eafe6b3ba5c6}") ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria })); } else { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); statusBar.SetText("The caret must be on valid expression to find all references."); } }
private static void SetStatus(string text) { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); statusBar.SetText(text); }
public override void DoCommand(object sender, EventArgs args) { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); statusBar.SetText("Importing project..."); var dlg = new Microsoft.NodejsTools.Project.ImportWizard.ImportWizard(); int commandIdToRaise = (int)VSConstants.VSStd97CmdID.OpenProject; Microsoft.VisualStudio.Shell.OleMenuCmdEventArgs oleArgs = args as Microsoft.VisualStudio.Shell.OleMenuCmdEventArgs; if (oleArgs != null) { string projectArgs = oleArgs.InValue as string; if (projectArgs != null) { var argItems = projectArgs.Split('|'); if (argItems.Length == 3) { dlg.ImportSettings.ProjectPath = CommonUtils.GetAvailableFilename( argItems[1], argItems[0], ".njsproj" ); dlg.ImportSettings.SourcePath = argItems[1]; commandIdToRaise = int.Parse(argItems[2]); } } } if (dlg.ShowModal() ?? false) { var settings = dlg.ImportSettings; settings.CreateRequestedProjectAsync() .ContinueWith(t => { string path; try { path = t.Result; } catch (AggregateException ex) { if (ex.InnerException is UnauthorizedAccessException) { MessageBox.Show( "Some file paths could not be accessed." + Environment.NewLine + "Try moving your source code to a location where you " + "can read and write files.", SR.ProductName ); } else { string exName = String.Empty; if (ex.InnerException != null) { exName = "(" + ex.InnerException.GetType().Name + ") "; } MessageBox.Show( "An unexpected error " + exName + "occurred while creating your project.", SR.ProductName ); } return; } if (File.Exists(path)) { object outRef = null, pathRef = "\"" + path + "\""; NodejsPackage.Instance.DTE.Commands.Raise(VSConstants.GUID_VSStandardCommandSet97.ToString("B"), commandIdToRaise, ref pathRef, ref outRef); statusBar.SetText(String.Empty); } else { statusBar.SetText("An error occurred and your project was not created."); } }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); } else { statusBar.SetText(""); } }
public override void DoCommand(object sender, EventArgs args) { var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); statusBar.SetText(Resources.ImportingProjectStatusText); var dlg = new Microsoft.NodejsTools.Project.ImportWizard.ImportWizard(); int commandIdToRaise = (int)VSConstants.VSStd97CmdID.OpenProject; Microsoft.VisualStudio.Shell.OleMenuCmdEventArgs oleArgs = args as Microsoft.VisualStudio.Shell.OleMenuCmdEventArgs; if (oleArgs != null) { string projectArgs = oleArgs.InValue as string; if (projectArgs != null) { var argItems = projectArgs.Split('|'); if (argItems.Length == 3) { dlg.ImportSettings.ProjectPath = CommonUtils.GetAvailableFilename( argItems[1], argItems[0], ".njsproj" ); dlg.ImportSettings.SourcePath = argItems[1]; commandIdToRaise = int.Parse(argItems[2], CultureInfo.InvariantCulture); } } } if (dlg.ShowModal() ?? false) { var settings = dlg.ImportSettings; settings.CreateRequestedProjectAsync() .ContinueWith(t => { string path; try { path = t.Result; } catch (AggregateException ex) { if (ex.InnerException is UnauthorizedAccessException) { MessageBox.Show( string.Format(CultureInfo.CurrentCulture, Resources.ImportingProjectAccessErrorStatusText, Environment.NewLine), SR.ProductName); } else { string exName = String.Empty; if (ex.InnerException != null) { exName = "(" + ex.InnerException.GetType().Name + ")"; } MessageBox.Show( string.Format(CultureInfo.CurrentCulture, Resources.ImportingProjectUnexpectedErrorMessage, exName), SR.ProductName); } return; } if (File.Exists(path)) { object outRef = null, pathRef = "\"" + path + "\""; NodejsPackage.Instance.DTE.Commands.Raise(VSConstants.GUID_VSStandardCommandSet97.ToString("B"), commandIdToRaise, ref pathRef, ref outRef); statusBar.SetText(String.Empty); } else { statusBar.SetText(Resources.ImportingProjectErrorStatusText); } }, CancellationToken.None, TaskContinuationOptions.HideScheduler, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext()); } else { statusBar.SetText(""); } }