/// <summary> /// Sets up a limited service provider which can be used for testing. /// /// This will not include many of the services which are typically available in /// VS but is suitable for simple test cases which need just some base functionality. /// </summary> public static MockServiceProvider CreateMockServiceProvider() { var serviceProvider = new MockServiceProvider(); serviceProvider.ComponentModel.AddExtension( typeof(IErrorProviderFactory), () => new MockErrorProviderFactory() ); serviceProvider.ComponentModel.AddExtension( typeof(IContentTypeRegistryService), () => new MockClassificationTypeRegistryService() ); #if DEV14_OR_LATER serviceProvider.ComponentModel.AddExtension( typeof(IInteractiveWindowCommandsFactory), () => new MockInteractiveWindowCommandsFactory() ); #endif serviceProvider.AddService(typeof(ErrorTaskProvider), CreateTaskProviderService, true); serviceProvider.AddService(typeof(CommentTaskProvider), CreateTaskProviderService, true); serviceProvider.AddService(typeof(UIThreadBase), new MockUIThread()); var optionsService = new MockPythonToolsOptionsService(); serviceProvider.AddService(typeof(IPythonToolsOptionsService), optionsService, true); var ptvsService = new PythonToolsService(serviceProvider); serviceProvider.AddService(typeof(PythonToolsService), ptvsService); return(serviceProvider); }
public UserSpecifiedCondaLocator( [Import(typeof(SVsServiceProvider), AllowDefault = true)] IServiceProvider site = null ) { _site = site; _pythonToolsService = site?.GetPythonToolsService(); }
/// <summary> /// Sets up a limited service provider which can be used for testing. /// /// This will not include many of the services which are typically available in /// VS but is suitable for simple test cases which need just some base functionality. /// </summary> public static MockServiceProvider CreateMockServiceProvider() { var serviceProvider = new MockServiceProvider(); var errorProvider = new MockErrorProviderFactory(); serviceProvider.AddService(typeof(MockErrorProviderFactory), errorProvider, true); serviceProvider.AddService(typeof(SComponentModel), new MockComponentModel()); serviceProvider.AddService( typeof(ErrorTaskProvider), (container, type) => new ErrorTaskProvider(serviceProvider, null, errorProvider), true ); serviceProvider.AddService( typeof(CommentTaskProvider), (container, type) => new CommentTaskProvider(serviceProvider, null, errorProvider), true ); serviceProvider.AddService(typeof(IUIThread), new MockUIThread()); var optionsService = new MockPythonToolsOptionsService(); serviceProvider.AddService(typeof(IPythonToolsOptionsService), optionsService, true); var ptvsService = new PythonToolsService(serviceProvider); serviceProvider.AddService(typeof(PythonToolsService), ptvsService); return(serviceProvider); }
public PythonExperimentalGeneralOptionsSetter( PythonToolsService pyService, bool?noDatabaseFactory = null, bool?autoDetectCondaEnvironments = null, bool?useCondaPackageManager = null ) { _pyService = pyService; var options = _pyService.ExperimentalOptions; if (noDatabaseFactory.HasValue) { _noDatabaseFactory = options.NoDatabaseFactory; options.NoDatabaseFactory = noDatabaseFactory.Value; } if (autoDetectCondaEnvironments.HasValue) { _autoDetectCondaEnvironments = options.AutoDetectCondaEnvironments; options.AutoDetectCondaEnvironments = autoDetectCondaEnvironments.Value; } if (useCondaPackageManager.HasValue) { _useCondaPackageManager = options.UseCondaPackageManager; options.UseCondaPackageManager = useCondaPackageManager.Value; } }
public void Initialize() { // Specifiy PythonTools\NoInterpreterFactories to suppress loading // all providers in tests. var settings = (IVsSettingsManager)_serviceContainer.GetService(typeof(SVsSettingsManager)); IVsWritableSettingsStore store; ErrorHandler.ThrowOnFailure(settings.GetWritableSettingsStore((uint)SettingsScope.Configuration, out store)); ErrorHandler.ThrowOnFailure(store.CreateCollection(@"PythonTools\NoInterpreterFactories")); _serviceContainer.AddService(typeof(IPythonToolsOptionsService), new MockPythonToolsOptionsService()); var errorProvider = new MockErrorProviderFactory(); _serviceContainer.AddService(typeof(MockErrorProviderFactory), errorProvider, true); _serviceContainer.AddService(typeof(IClipboardService), new MockClipboardService()); UIThread.EnsureService(_serviceContainer); _serviceContainer.AddService(typeof(ErrorTaskProvider), CreateTaskProviderService, true); _serviceContainer.AddService(typeof(CommentTaskProvider), CreateTaskProviderService, true); var pyService = new PythonToolsService(_serviceContainer); _onDispose.Add(() => ((IDisposable)pyService).Dispose()); _serviceContainer.AddService(typeof(PythonToolsService), pyService, true); _serviceContainer.AddService(typeof(IPythonLibraryManager), (object)null); // register our project factory... var regProjectTypes = (IVsRegisterProjectTypes)_serviceContainer.GetService(typeof(SVsRegisterProjectTypes)); uint cookie; var guid = Guid.Parse(PythonConstants.ProjectFactoryGuid); regProjectTypes.RegisterProjectType( ref guid, new PythonProjectFactory(_serviceContainer), out cookie ); }
protected override void OnCreate() { base.OnCreate(); _site = (IServiceProvider)this; _pyService = _site.GetPythonToolsService(); #if DEV14_OR_LATER // TODO: Get PYEnvironment added to image list BitmapImageMoniker = KnownMonikers.DockPanel; #else BitmapResourceID = PythonConstants.ResourceIdForReplImages; BitmapIndex = 0; #endif Caption = SR.GetString(SR.Environments); _service = _site.GetComponentModel().GetService<IInterpreterOptionsService>(); _outputWindow = OutputWindowRedirector.GetGeneral(_site); Debug.Assert(_outputWindow != null); _statusBar = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar; var list = new ToolWindow(); list.ViewCreated += List_ViewCreated; list.CommandBindings.Add(new CommandBinding( EnvironmentView.OpenInteractiveWindow, OpenInteractiveWindow_Executed, OpenInteractiveWindow_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentView.OpenInteractiveOptions, OpenInteractiveOptions_Executed, OpenInteractiveOptions_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentPathsExtension.StartInterpreter, StartInterpreter_Executed, StartInterpreter_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentPathsExtension.StartWindowsInterpreter, StartInterpreter_Executed, StartInterpreter_CanExecute )); list.CommandBindings.Add(new CommandBinding( ApplicationCommands.Help, OnlineHelp_Executed, OnlineHelp_CanExecute )); list.CommandBindings.Add(new CommandBinding( ToolWindow.UnhandledException, UnhandledException_Executed, UnhandledException_CanExecute )); list.Service = _service; Content = list; }
public TemplateCompletionControllerProvider([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, ICompletionBroker completionBroker, IQuickInfoBroker quickInfoBroker, ISignatureHelpBroker signatureHelpBroker) { _completionBroker = completionBroker; _quickInfoBroker = quickInfoBroker; _signatureHelpBroker = signatureHelpBroker; _pyService = (PythonToolsService)serviceProvider.GetService(typeof(PythonToolsService)); }
private static IEnumerable <string> GetGlobalDebuggerOptions( PythonToolsService pyService, bool allowPauseAtEnd = true, bool alwaysPauseAtEnd = false ) { var options = pyService.DebuggerOptions; if (alwaysPauseAtEnd || allowPauseAtEnd && options.WaitOnAbnormalExit) { yield return(AD7Engine.WaitOnAbnormalExitSetting + "=True"); } if (alwaysPauseAtEnd || allowPauseAtEnd && options.WaitOnNormalExit) { yield return(AD7Engine.WaitOnNormalExitSetting + "=True"); } if (options.TeeStandardOutput) { yield return(AD7Engine.RedirectOutputSetting + "=True"); } if (options.BreakOnSystemExitZero) { yield return(AD7Engine.BreakSystemExitZero + "=True"); } if (options.DebugStdLib) { yield return(AD7Engine.DebugStdLib + "=True"); } }
private EditFilter( IVsTextView vsTextView, ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider, IComponentModel model, IOleCommandTarget next ) { _vsTextView = vsTextView; _textView = textView; _editorOps = editorOps; _serviceProvider = serviceProvider; _componentModel = model; _pyService = _serviceProvider.GetPythonToolsService(); _entryService = _componentModel.GetService <AnalysisEntryService>(); _next = next; BraceMatcher.WatchBraceHighlights(textView, _componentModel); if (_next == null) { ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next)); } }
public PythonServiceGeneralOptionsSetter( PythonToolsService pyService, bool?updateSearchPathsWhenAddingLinkedFiles = null, bool?unresolvedImportWarning = null, bool?invalidEncodingWarning = null, bool?clearGlobalPythonPath = null ) { _pyService = pyService; var options = _pyService.GeneralOptions; if (updateSearchPathsWhenAddingLinkedFiles.HasValue) { _updateSearchPathsWhenAddingLinkedFiles = options.UpdateSearchPathsWhenAddingLinkedFiles; options.UpdateSearchPathsWhenAddingLinkedFiles = updateSearchPathsWhenAddingLinkedFiles.Value; } if (unresolvedImportWarning.HasValue) { _unresolvedImportWarning = options.UnresolvedImportWarning; options.UnresolvedImportWarning = unresolvedImportWarning.Value; } if (invalidEncodingWarning.HasValue) { _invalidEncodingWarning = options.InvalidEncodingWarning; options.InvalidEncodingWarning = invalidEncodingWarning.Value; } if (clearGlobalPythonPath.HasValue) { _clearGlobalPythonPath = options.ClearGlobalPythonPath; options.ClearGlobalPythonPath = clearGlobalPythonPath.Value; } }
public PythonVisualStudioApp(DTE dte = null) : base(dte) { var shell = (IVsShell)ServiceProvider.GetService(typeof(SVsShell)); var pkg = new Guid("6dbd7c1e-1f1b-496d-ac7c-c55dae66c783"); IVsPackage pPkg; ErrorHandler.ThrowOnFailure(shell.LoadPackage(ref pkg, out pPkg)); System.Threading.Thread.Sleep(1000); PythonToolsService = ServiceProvider.GetPythonToolsService_NotThreadSafe(); Assert.IsNotNull(PythonToolsService, "Failed to get PythonToolsService"); // Disable AutoListIdentifiers for tests var ao = PythonToolsService.AdvancedOptions; Assert.IsNotNull(ao, "Failed to get AdvancedOptions"); var oldALI = ao.AutoListIdentifiers; ao.AutoListIdentifiers = false; var orwoodProp = Dte.Properties["Environment", "ProjectsAndSolution"].Item("OnRunWhenOutOfDate"); Assert.IsNotNull(orwoodProp, "Failed to get OnRunWhenOutOfDate property"); var oldOrwood = orwoodProp.Value; orwoodProp.Value = 1; OnDispose(() => { ao.AutoListIdentifiers = oldALI; orwoodProp.Value = oldOrwood; }); }
internal void SyncPageWithControlSettings(PythonToolsService pyService) { pyService.DebugInteractiveOptions.ReplSmartHistory = _smartReplHistory.Checked; pyService.DebugInteractiveOptions.PrimaryPrompt = _priPrompt.Text; pyService.DebugInteractiveOptions.SecondaryPrompt = _secPrompt.Text; pyService.DebugInteractiveOptions.LiveCompletionsOnly = _liveCompletionsOnly.Checked; pyService.DebugInteractiveOptions.UseInterpreterPrompts = !_useUserDefinedPrompts.Checked; }
public PythonVisualStudioApp(IServiceProvider site) : base(site) { var shell = (IVsShell)ServiceProvider.GetService(typeof(SVsShell)); var pkg = new Guid("6dbd7c1e-1f1b-496d-ac7c-c55dae66c783"); IVsPackage pPkg; ErrorHandler.ThrowOnFailure(shell.LoadPackage(ref pkg, out pPkg)); System.Threading.Thread.Sleep(1000); PythonToolsService = ServiceProvider.GetPythonToolsService_NotThreadSafe(); Assert.IsNotNull(PythonToolsService, "Failed to get PythonToolsService"); // Disable AutoListIdentifiers for tests var ao = PythonToolsService.AdvancedOptions; Assert.IsNotNull(ao, "Failed to get AdvancedOptions"); var oldALI = ao.AutoListIdentifiers; ao.AutoListIdentifiers = false; var orwoodProp = Dte.Properties["Environment", "ProjectsAndSolution"].Item("OnRunWhenOutOfDate"); Assert.IsNotNull(orwoodProp, "Failed to get OnRunWhenOutOfDate property"); var oldOrwood = orwoodProp.Value; orwoodProp.Value = 1; OnDispose(() => { ao.AutoListIdentifiers = oldALI; orwoodProp.Value = oldOrwood; }); }
/// <summary> /// Sets up a limited service provider which can be used for testing. /// /// This will not include many of the services which are typically available in /// VS but is suitable for simple test cases which need just some base functionality. /// </summary> public static MockServiceProvider CreateMockServiceProvider() { var serviceProvider = new MockServiceProvider(); serviceProvider.ComponentModel.AddExtension( typeof(IErrorProviderFactory), () => new MockErrorProviderFactory() ); serviceProvider.ComponentModel.AddExtension( typeof(IContentTypeRegistryService), CreateContentTypeRegistryService ); serviceProvider.ComponentModel.AddExtension( typeof(IInteractiveWindowCommandsFactory), () => new MockInteractiveWindowCommandsFactory() ); serviceProvider.AddService(typeof(ErrorTaskProvider), CreateTaskProviderService, true); serviceProvider.AddService(typeof(CommentTaskProvider), CreateTaskProviderService, true); serviceProvider.AddService(typeof(UIThreadBase), new MockUIThread()); var optionsService = new MockPythonToolsOptionsService(); serviceProvider.AddService(typeof(IPythonToolsOptionsService), optionsService, true); var ptvsService = new PythonToolsService(serviceProvider); serviceProvider.AddService(typeof(PythonToolsService), ptvsService); return serviceProvider; }
public LanguagePreferences(PythonToolsService service, Guid languageGuid) { _service = service; _service.Site.AssertShellIsInitialized(); _textMgr = (IVsTextManager)service.Site.GetService(typeof(SVsTextManager)); if (_textMgr == null) { throw new NotSupportedException(""); } var langPrefs = new LANGPREFERENCES[1]; langPrefs[0].guidLang = languageGuid; ErrorHandler.ThrowOnFailure(_textMgr.GetUserPreferences(null, null, langPrefs, null)); _preferences = langPrefs[0]; var guid = typeof(IVsTextManagerEvents2).GUID; IConnectionPoint connectionPoint = null; (_textMgr as IConnectionPointContainer)?.FindConnectionPoint(ref guid, out connectionPoint); if (connectionPoint != null) { connectionPoint.Advise(this, out _cookie); } }
public DefaultPythonLauncher(IServiceProvider serviceProvider, PythonToolsService pyService, IPythonProject/*!*/ project) { Utilities.ArgumentNotNull("project", project); _serviceProvider = serviceProvider; _pyService = pyService; _project = project; }
public void Initialize() { // Specifiy PythonTools\NoInterpreterFactories to suppress loading // all providers in tests. var settings = (IVsSettingsManager)_serviceContainer.GetService(typeof(SVsSettingsManager)); IVsWritableSettingsStore store; ErrorHandler.ThrowOnFailure(settings.GetWritableSettingsStore((uint)SettingsScope.Configuration, out store)); ErrorHandler.ThrowOnFailure(store.CreateCollection(@"PythonTools\NoInterpreterFactories")); _serviceContainer.AddService(typeof(IPythonToolsOptionsService), new MockPythonToolsOptionsService()); var errorProvider = new MockErrorProviderFactory(); _serviceContainer.AddService(typeof(MockErrorProviderFactory), errorProvider, true); _serviceContainer.AddService(typeof(IClipboardService), new MockClipboardService()); UIThread.EnsureService(_serviceContainer); _serviceContainer.AddService( typeof(Microsoft.PythonTools.Intellisense.ErrorTaskProvider), new ServiceCreatorCallback((container, type) => { var p = new Microsoft.PythonTools.Intellisense.ErrorTaskProvider(_serviceContainer, null, errorProvider); lock (_onDispose) { _onDispose.Add(() => p.Dispose()); } return(p); }), true ); _serviceContainer.AddService( typeof(Microsoft.PythonTools.Intellisense.CommentTaskProvider), new ServiceCreatorCallback((container, type) => { var p = new Microsoft.PythonTools.Intellisense.CommentTaskProvider(_serviceContainer, null, errorProvider); lock (_onDispose) { _onDispose.Add(() => p.Dispose()); } return(p); }), true ); var pyService = new PythonToolsService(_serviceContainer); _serviceContainer.AddService(typeof(PythonToolsService), pyService, true); _serviceContainer.AddService(typeof(IPythonLibraryManager), (object)null); // register our project factory... var regProjectTypes = (IVsRegisterProjectTypes)_serviceContainer.GetService(typeof(SVsRegisterProjectTypes)); uint cookie; var guid = Guid.Parse(PythonConstants.ProjectFactoryGuid); regProjectTypes.RegisterProjectType( ref guid, new PythonProjectFactory(_serviceContainer), out cookie ); }
internal SmartIndentProvider( [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, PythonEditorServices editorServices ) { _pyService = serviceProvider.GetPythonToolsService(); _editorServices = editorServices; }
internal void SyncPageWithControlSettings(PythonToolsService pyService) { pyService.DebuggerOptions.PromptBeforeRunningWithBuildError = _promptOnBuildError.Checked; pyService.DebuggerOptions.WaitOnAbnormalExit = _waitOnAbnormalExit.Checked; pyService.DebuggerOptions.WaitOnNormalExit = _waitOnNormalExit.Checked; pyService.DebuggerOptions.TeeStandardOutput = _teeStdOut.Checked; pyService.DebuggerOptions.BreakOnSystemExitZero = _breakOnSystemExitZero.Checked; pyService.DebuggerOptions.DebugStdLib = _debugStdLib.Checked; }
internal PythonInteractiveOptions(PythonToolsService pyService, string category) { _pyService = pyService; _category = category; _completionMode = ReplIntellisenseMode.DontEvaluateCalls; _smartHistory = true; _scripts = string.Empty; Load(); }
internal void SetPythonToolsService(PythonToolsService service) { if (_python != null) { throw new InvalidOperationException("Multiple services created"); } _python = service; }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _smartReplHistory.Checked = pyService.DebugInteractiveOptions.ReplSmartHistory; ReplIntellisenseMode = pyService.DebugInteractiveOptions.ReplIntellisenseMode; _priPrompt.Text = pyService.DebugInteractiveOptions.PrimaryPrompt; _secPrompt.Text = pyService.DebugInteractiveOptions.SecondaryPrompt; EnableUserDefinedPrompts(!pyService.DebugInteractiveOptions.UseInterpreterPrompts); _liveCompletionsOnly.Checked = pyService.DebugInteractiveOptions.LiveCompletionsOnly; }
public DefaultPythonLauncher(IServiceProvider serviceProvider, PythonToolsService pyService, IPythonProject /*!*/ project) { Utilities.ArgumentNotNull("project", project); _serviceProvider = serviceProvider; _pyService = pyService; _project = project; }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _promptOnBuildError.Checked = pyService.DebuggerOptions.PromptBeforeRunningWithBuildError; _waitOnAbnormalExit.Checked = pyService.DebuggerOptions.WaitOnAbnormalExit; _waitOnNormalExit.Checked = pyService.DebuggerOptions.WaitOnNormalExit; _teeStdOut.Checked = pyService.DebuggerOptions.TeeStandardOutput; _breakOnSystemExitZero.Checked = pyService.DebuggerOptions.BreakOnSystemExitZero; _debugStdLib.Checked = pyService.DebuggerOptions.DebugStdLib; }
internal void SyncPageWithControlSettings(PythonToolsService pyService) { pyService.DebugInteractiveOptions.ReplSmartHistory = _smartReplHistory.Checked; pyService.DebugInteractiveOptions.PrimaryPrompt = _priPrompt.Text; pyService.DebugInteractiveOptions.SecondaryPrompt = _secPrompt.Text; pyService.DebugInteractiveOptions.LiveCompletionsOnly = _liveCompletionsOnly.Checked; pyService.DebugInteractiveOptions.UseInterpreterPrompts = !_useUserDefinedPrompts.Checked; }
internal PythonInteractiveOptions(PythonToolsService pyService, string category) { _pyService = pyService; _category = category; _completionMode = ReplIntellisenseMode.DontEvaluateCalls; _smartHistory = true; _scripts = string.Empty; }
protected override void OnCreate() { base.OnCreate(); _site = (IServiceProvider)this; _pyService = _site.GetPythonToolsService(); // TODO: Get PYEnvironment added to image list BitmapImageMoniker = KnownMonikers.DockPanel; Caption = Strings.Environments; _service = _site.GetComponentModel().GetService <IInterpreterOptionsService>(); _outputWindow = OutputWindowRedirector.GetGeneral(_site); Debug.Assert(_outputWindow != null); _statusBar = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar; var list = new ToolWindow(); list.Site = _site; list.ViewCreated += List_ViewCreated; list.CommandBindings.Add(new CommandBinding( EnvironmentView.OpenInteractiveWindow, OpenInteractiveWindow_Executed, OpenInteractiveWindow_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentView.OpenInteractiveOptions, OpenInteractiveOptions_Executed, OpenInteractiveOptions_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentPathsExtension.StartInterpreter, StartInterpreter_Executed, StartInterpreter_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentPathsExtension.StartWindowsInterpreter, StartInterpreter_Executed, StartInterpreter_CanExecute )); list.CommandBindings.Add(new CommandBinding( ApplicationCommands.Help, OnlineHelp_Executed, OnlineHelp_CanExecute )); list.CommandBindings.Add(new CommandBinding( ToolWindow.UnhandledException, UnhandledException_Executed, UnhandledException_CanExecute )); list.Service = _service; Content = list; }
public ProfiledProcess(PythonToolsService pyService, string exe, string args, string dir, Dictionary <string, string> envVars) { var arch = NativeMethods.GetBinaryType(exe); if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(Strings.UnsupportedArchitecture.FormatUI(arch)); } dir = PathUtils.TrimEndSeparator(dir); if (string.IsNullOrEmpty(dir)) { dir = "."; } _pyService = pyService; _exe = exe; _args = args; _dir = dir; _arch = arch; ProcessStartInfo processInfo; string pythonInstallDir = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("VsPyProf.dll", typeof(ProfiledProcess).Assembly)); string dll = _arch == ProcessorArchitecture.Amd64 ? "VsPyProf.dll" : "VsPyProfX86.dll"; string arguments = string.Join(" ", ProcessOutput.QuoteSingleArgument(Path.Combine(pythonInstallDir, "proflaun.py")), ProcessOutput.QuoteSingleArgument(Path.Combine(pythonInstallDir, dll)), ProcessOutput.QuoteSingleArgument(dir), _args ); processInfo = new ProcessStartInfo(_exe, arguments); if (_pyService.DebuggerOptions.WaitOnNormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_NORMAL_EXIT"] = "1"; } if (_pyService.DebuggerOptions.WaitOnAbnormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_ABNORMAL_EXIT"] = "1"; } processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.WorkingDirectory = _dir; if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } _process = new Process(); _process.StartInfo = processInfo; }
private async Task AddDropDownBarAsync(PythonToolsService service) { var prefs = await _pyService.GetLangPrefsAsync(); if (prefs.NavigationBar) { AddDropDownBar(false); } }
internal void SyncPageWithControlSettings(PythonToolsService pyService) { pyService.DebuggerOptions.PromptBeforeRunningWithBuildError = _promptOnBuildError.Checked; pyService.DebuggerOptions.WaitOnAbnormalExit = _waitOnAbnormalExit.Checked; pyService.DebuggerOptions.WaitOnNormalExit = _waitOnNormalExit.Checked; pyService.DebuggerOptions.TeeStandardOutput = _teeStdOut.Checked; pyService.DebuggerOptions.BreakOnSystemExitZero = _breakOnSystemExitZero.Checked; pyService.DebuggerOptions.DebugStdLib = _debugStdLib.Checked; }
public LibraryNodeVisitor(PythonToolsService pyService, PythonNavigateToItemProvider itemProvider, INavigateToCallback navCallback, string searchValue) { _pyService = pyService; _itemProvider = itemProvider; _navCallback = navCallback; _searchValue = searchValue; _path.Push(null); _comparer = new FuzzyStringMatcher(_pyService.AdvancedOptions.SearchMode); _regexComparer = new FuzzyStringMatcher(FuzzyMatchMode.RegexIgnoreCase); }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _promptOnBuildError.Checked = pyService.DebuggerOptions.PromptBeforeRunningWithBuildError; _waitOnAbnormalExit.Checked = pyService.DebuggerOptions.WaitOnAbnormalExit; _waitOnNormalExit.Checked = pyService.DebuggerOptions.WaitOnNormalExit; _teeStdOut.Checked = pyService.DebuggerOptions.TeeStandardOutput; _breakOnSystemExitZero.Checked = pyService.DebuggerOptions.BreakOnSystemExitZero; _debugStdLib.Checked = pyService.DebuggerOptions.DebugStdLib; }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _smartReplHistory.Checked = pyService.DebugInteractiveOptions.ReplSmartHistory; ReplIntellisenseMode = pyService.DebugInteractiveOptions.ReplIntellisenseMode; _priPrompt.Text = pyService.DebugInteractiveOptions.PrimaryPrompt; _secPrompt.Text = pyService.DebugInteractiveOptions.SecondaryPrompt; EnableUserDefinedPrompts(!pyService.DebugInteractiveOptions.UseInterpreterPrompts); _liveCompletionsOnly.Checked = pyService.DebugInteractiveOptions.LiveCompletionsOnly; }
internal void SyncPageWithControlSettings(PythonToolsService pyService) { pyService.GeneralOptions.ShowOutputWindowForVirtualEnvCreate = _showOutputWindowForVirtualEnvCreate.Checked; pyService.GeneralOptions.ShowOutputWindowForPackageInstallation = _showOutputWindowForPackageInstallation.Checked; pyService.GeneralOptions.PromptForEnvCreate = _promptForEnvCreate.Checked; pyService.GeneralOptions.PromptForPackageInstallation = _promptForPackageInstallation.Checked; pyService.GeneralOptions.PromptForTestFrameWorkInfoBar = _promptForPytestEnableAndInstall.Checked; pyService.GeneralOptions.ElevatePip = _elevatePip.Checked; pyService.GeneralOptions.ClearGlobalPythonPath = _clearGlobalPythonPath.Checked; }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _showOutputWindowForVirtualEnvCreate.Checked = pyService.GeneralOptions.ShowOutputWindowForVirtualEnvCreate; _showOutputWindowForPackageInstallation.Checked = pyService.GeneralOptions.ShowOutputWindowForPackageInstallation; _promptForEnvCreate.Checked = pyService.GeneralOptions.PromptForEnvCreate; _promptForPackageInstallation.Checked = pyService.GeneralOptions.PromptForPackageInstallation; _promptForPytestEnableAndInstall.Checked = pyService.GeneralOptions.PromptForTestFrameWorkInfoBar; _elevatePip.Checked = pyService.GeneralOptions.ElevatePip; _clearGlobalPythonPath.Checked = pyService.GeneralOptions.ClearGlobalPythonPath; }
public LibraryNodeVisitor(PythonToolsService pyService, PythonNavigateToItemProvider itemProvider, INavigateToCallback navCallback, string searchValue) { _pyService = pyService; _itemProvider = itemProvider; _navCallback = navCallback; _searchValue = searchValue; _path.Push(null); _comparer = new FuzzyStringMatcher(_pyService.AdvancedOptions.SearchMode); _regexComparer = new FuzzyStringMatcher(FuzzyMatchMode.RegexIgnoreCase); }
public TemplateCompletionController( PythonToolsService pyService, ITextView textView, IList<ITextBuffer> subjectBuffers, ICompletionBroker completionBroker, IQuickInfoBroker quickInfoBroker, ISignatureHelpBroker signatureBroker) : base(textView, subjectBuffers, completionBroker, quickInfoBroker, signatureBroker) { _pyService = pyService; }
internal PythonInteractiveCommonOptions(PythonToolsService pyService, string category, string id) { _pyService = pyService; _category = category; _id = id; _priPrompt = DefaultPrompt; _secPrompt = DefaultSecondaryPrompt; _interpreterPrompts = true; _replIntellisenseMode = ReplIntellisenseMode.DontEvaluateCalls; _smartHistory = true; }
public EditFilter(ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider) { _textView = textView; _textView.Properties[typeof(EditFilter)] = this; _editorOps = editorOps; _serviceProvider = serviceProvider; _componentModel = _serviceProvider.GetComponentModel(); _pyService = _serviceProvider.GetPythonToolsService(); BraceMatcher.WatchBraceHighlights(textView, _componentModel); }
/// <summary> /// Sets up a limited service provider which can be used for testing. /// /// This will not include many of the services which are typically available in /// VS but is suitable for simple test cases which need just some base functionality. /// </summary> public static MockServiceProvider CreateMockServiceProvider( bool suppressTaskProvider = true ) { var serviceProvider = new MockServiceProvider(); serviceProvider.ComponentModel.AddExtension( typeof(IErrorProviderFactory), () => new MockErrorProviderFactory() ); serviceProvider.ComponentModel.AddExtension( typeof(IContentTypeRegistryService), CreateContentTypeRegistryService ); serviceProvider.ComponentModel.AddExtension( typeof(IInteractiveWindowCommandsFactory), () => new MockInteractiveWindowCommandsFactory() ); var optService = new Lazy <MockInterpreterOptionsService>(() => new MockInterpreterOptionsService()); serviceProvider.ComponentModel.AddExtension <IInterpreterRegistryService>(() => optService.Value); serviceProvider.ComponentModel.AddExtension <IInterpreterOptionsService>(() => optService.Value); var editorServices = CreatePythonEditorServices(serviceProvider, serviceProvider.ComponentModel); serviceProvider.ComponentModel.AddExtension(() => editorServices); var analysisEntryServiceCreator = new Lazy <AnalysisEntryService>(() => new AnalysisEntryService(new Lazy <PythonEditorServices>(() => editorServices))); serviceProvider.ComponentModel.AddExtension <IAnalysisEntryService>(() => analysisEntryServiceCreator.Value); serviceProvider.ComponentModel.AddExtension(() => analysisEntryServiceCreator.Value); if (suppressTaskProvider) { serviceProvider.AddService(typeof(ErrorTaskProvider), null, true); serviceProvider.AddService(typeof(CommentTaskProvider), null, true); } else { serviceProvider.AddService(typeof(ErrorTaskProvider), CreateTaskProviderService, true); serviceProvider.AddService(typeof(CommentTaskProvider), CreateTaskProviderService, true); } serviceProvider.AddService(typeof(UIThreadBase), new MockUIThread()); var optionsService = new MockPythonToolsOptionsService(); serviceProvider.AddService(typeof(IPythonToolsOptionsService), optionsService, true); var ptvsService = new PythonToolsService(serviceProvider); serviceProvider.AddService(typeof(PythonToolsService), ptvsService); return(serviceProvider); }
internal void SyncControlWithPageSettings(PythonToolsService pyService) { _enterCommits.Checked = pyService.AdvancedOptions.EnterCommitsIntellisense; _intersectMembers.Checked = pyService.AdvancedOptions.IntersectMembers; _filterCompletions.Checked = pyService.AdvancedOptions.FilterCompletions; _completionCommitedBy.Text = pyService.AdvancedOptions.CompletionCommittedBy; _newLineAfterCompleteCompletion.Checked = pyService.AdvancedOptions.AddNewLineAtEndOfFullyTypedWord; _outliningOnOpen.Checked = pyService.AdvancedOptions.EnterOutliningModeOnOpen; _pasteRemovesReplPrompts.Checked = pyService.AdvancedOptions.PasteRemovesReplPrompts; _colorNames.Checked = pyService.AdvancedOptions.ColorNames; _autoListIdentifiers.Checked = pyService.AdvancedOptions.AutoListIdentifiers; }
internal void SyncPageWithControlSettings(PythonToolsService pyService) { pyService.AdvancedOptions.EnterCommitsIntellisense = _enterCommits.Checked; pyService.AdvancedOptions.IntersectMembers = _intersectMembers.Checked; pyService.AdvancedOptions.FilterCompletions = _filterCompletions.Checked; pyService.AdvancedOptions.CompletionCommittedBy = _completionCommitedBy.Text; pyService.AdvancedOptions.AddNewLineAtEndOfFullyTypedWord = _newLineAfterCompleteCompletion.Checked; pyService.AdvancedOptions.EnterOutliningModeOnOpen = _outliningOnOpen.Checked; pyService.AdvancedOptions.PasteRemovesReplPrompts = _pasteRemovesReplPrompts.Checked; pyService.AdvancedOptions.ColorNames = _colorNames.Checked; pyService.AdvancedOptions.AutoListIdentifiers = _autoListIdentifiers.Checked; }
internal PythonInteractiveCommonOptions(PythonToolsService pyService, string category, string id) { _pyService = pyService; _category = category; _id = id; _priPrompt = DefaultPrompt; _secPrompt = DefaultSecondaryPrompt; _interpreterPrompts = true; _replIntellisenseMode = ReplIntellisenseMode.DontEvaluateCalls; _smartHistory = true; }
public ProfiledProcess(PythonToolsService pyService, string exe, string args, string dir, Dictionary <string, string> envVars, ProcessorArchitecture arch) { if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } if (dir.EndsWith("\\")) { dir = dir.Substring(0, dir.Length - 1); } if (String.IsNullOrEmpty(dir)) { dir = "."; } _pyService = pyService; _exe = exe; _args = args; _dir = dir; _arch = arch; ProcessStartInfo processInfo; string pythonInstallDir = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("VsPyProf.dll")); string dll = _arch == ProcessorArchitecture.Amd64 ? "VsPyProf.dll" : "VsPyProfX86.dll"; string arguments = "\"" + Path.Combine(pythonInstallDir, "proflaun.py") + "\" " + "\"" + Path.Combine(pythonInstallDir, dll) + "\" " + "\"" + dir + "\" " + _args; processInfo = new ProcessStartInfo(_exe, arguments); if (_pyService.DebuggerOptions.WaitOnNormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_NORMAL_EXIT"] = "1"; } if (_pyService.DebuggerOptions.WaitOnAbnormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_ABNORMAL_EXIT"] = "1"; } processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.WorkingDirectory = _dir; if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } _process = new Process(); _process.StartInfo = processInfo; }
public TemplateCompletionController( PythonToolsService pyService, ITextView textView, IList <ITextBuffer> subjectBuffers, ICompletionBroker completionBroker, IAsyncQuickInfoBroker quickInfoBroker, ISignatureHelpBroker signatureBroker) : base(textView, subjectBuffers, completionBroker, quickInfoBroker, signatureBroker) { _pyService = pyService; }
public PythonWebLauncher( IServiceProvider serviceProvider, LaunchConfiguration runConfig, LaunchConfiguration debugConfig, LaunchConfiguration defaultConfig ) { _serviceProvider = serviceProvider; _pyService = _serviceProvider.GetPythonToolsService(); _runConfig = runConfig; _debugConfig = debugConfig; _defaultConfig = defaultConfig; }
public PythonDebugReplEvaluator(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _pyService = serviceProvider.GetPythonToolsService(); AD7Engine.EngineAttached += new EventHandler<AD7EngineEventArgs>(OnEngineAttached); AD7Engine.EngineDetaching += new EventHandler<AD7EngineEventArgs>(OnEngineDetaching); var dte = _serviceProvider.GetDTE(); if (dte != null) { // running outside of VS, make this work for tests. _debuggerEvents = dte.Events.DebuggerEvents; _debuggerEvents.OnEnterBreakMode += new EnvDTE._dispDebuggerEvents_OnEnterBreakModeEventHandler(OnEnterBreakMode); } }
public ProfiledProcess(PythonToolsService pyService, string exe, string args, string dir, Dictionary<string, string> envVars) { var arch = NativeMethods.GetBinaryType(exe); if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } dir = PathUtils.TrimEndSeparator(dir); if (string.IsNullOrEmpty(dir)) { dir = "."; } _pyService = pyService; _exe = exe; _args = args; _dir = dir; _arch = arch; ProcessStartInfo processInfo; string pythonInstallDir = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("VsPyProf.dll", typeof(ProfiledProcess).Assembly)); string dll = _arch == ProcessorArchitecture.Amd64 ? "VsPyProf.dll" : "VsPyProfX86.dll"; string arguments = string.Join(" ", ProcessOutput.QuoteSingleArgument(Path.Combine(pythonInstallDir, "proflaun.py")), ProcessOutput.QuoteSingleArgument(Path.Combine(pythonInstallDir, dll)), ProcessOutput.QuoteSingleArgument(dir), _args ); processInfo = new ProcessStartInfo(_exe, arguments); if (_pyService.DebuggerOptions.WaitOnNormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_NORMAL_EXIT"] = "1"; } if (_pyService.DebuggerOptions.WaitOnAbnormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_ABNORMAL_EXIT"] = "1"; } processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.WorkingDirectory = _dir; if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } _process = new Process(); _process.StartInfo = processInfo; }
public ProfiledProcess(PythonToolsService pyService, string exe, string args, string dir, Dictionary<string, string> envVars, ProcessorArchitecture arch) { if (arch != ProcessorArchitecture.X86 && arch != ProcessorArchitecture.Amd64) { throw new InvalidOperationException(String.Format("Unsupported architecture: {0}", arch)); } if (dir.EndsWith("\\")) { dir = dir.Substring(0, dir.Length - 1); } if (String.IsNullOrEmpty(dir)) { dir = "."; } _pyService = pyService; _exe = exe; _args = args; _dir = dir; _arch = arch; ProcessStartInfo processInfo; string pythonInstallDir = Path.GetDirectoryName(PythonToolsInstallPath.GetFile("VsPyProf.dll")); string dll = _arch == ProcessorArchitecture.Amd64 ? "VsPyProf.dll" : "VsPyProfX86.dll"; string arguments = "\"" + Path.Combine(pythonInstallDir, "proflaun.py") + "\" " + "\"" + Path.Combine(pythonInstallDir, dll) + "\" " + "\"" + dir + "\" " + _args; processInfo = new ProcessStartInfo(_exe, arguments); if (_pyService.DebuggerOptions.WaitOnNormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_NORMAL_EXIT"] = "1"; } if (_pyService.DebuggerOptions.WaitOnAbnormalExit) { processInfo.EnvironmentVariables["VSPYPROF_WAIT_ON_ABNORMAL_EXIT"] = "1"; } processInfo.CreateNoWindow = false; processInfo.UseShellExecute = false; processInfo.RedirectStandardOutput = false; processInfo.WorkingDirectory = _dir; if (envVars != null) { foreach (var keyValue in envVars) { processInfo.EnvironmentVariables[keyValue.Key] = keyValue.Value; } } _process = new Process(); _process.StartInfo = processInfo; }
public PythonWebLauncher(IServiceProvider serviceProvider, PythonToolsService pyService, IPythonProject project) { _pyService = pyService; _project = project; _serviceProvider = serviceProvider; var project2 = project as IPythonProject2; if (project2 != null) { // The provider may return its own object, but the web launcher only // supports instances of CustomCommand. _runServerCommand = project2.FindCommand(RunWebServerCommand); _debugServerCommand = project2.FindCommand(DebugWebServerCommand); } var portNumber = _project.GetProperty(PythonConstants.WebBrowserPortSetting); int portNum; if (Int32.TryParse(portNumber, out portNum)) { _testServerPort = portNum; } }
public LanguagePreferences(PythonToolsService service, Guid languageGuid) { _service = service; _service.Site.AssertShellIsInitialized(); _textMgr = (IVsTextManager)service.Site.GetService(typeof(SVsTextManager)); if (_textMgr == null) { throw new NotSupportedException(""); } var langPrefs = new LANGPREFERENCES[1]; langPrefs[0].guidLang = languageGuid; ErrorHandler.ThrowOnFailure(_textMgr.GetUserPreferences(null, null, langPrefs, null)); _preferences = langPrefs[0]; var guid = typeof(IVsTextManagerEvents2).GUID; IConnectionPoint connectionPoint = null; (_textMgr as IConnectionPointContainer)?.FindConnectionPoint(ref guid, out connectionPoint); if (connectionPoint != null) { connectionPoint.Advise(this, out _cookie); } }
private static IEnumerable<string> GetGlobalDebuggerOptions( PythonToolsService pyService, bool allowPauseAtEnd = true, bool alwaysPauseAtEnd = false ) { var options = pyService.DebuggerOptions; if (alwaysPauseAtEnd || allowPauseAtEnd && options.WaitOnAbnormalExit) { yield return AD7Engine.WaitOnAbnormalExitSetting + "=True"; } if (alwaysPauseAtEnd || allowPauseAtEnd && options.WaitOnNormalExit) { yield return AD7Engine.WaitOnNormalExitSetting + "=True"; } if (options.TeeStandardOutput) { yield return AD7Engine.RedirectOutputSetting + "=True"; } if (options.BreakOnSystemExitZero) { yield return AD7Engine.BreakSystemExitZero + "=True"; } if (options.DebugStdLib) { yield return AD7Engine.DebugStdLib + "=True"; } }
private ReplEditFilter( IVsTextView vsTextView, ITextView textView, IEditorOperations editorOps, IServiceProvider serviceProvider, IOleCommandTarget next ) { _vsTextView = vsTextView; _textView = textView; _editorOps = editorOps; _serviceProvider = serviceProvider; _componentModel = _serviceProvider.GetComponentModel(); _pyService = _serviceProvider.GetPythonToolsService(); _interactive = _textView.TextBuffer.GetInteractiveWindow(); _next = next; if (_interactive != null) { _selectEval = _interactive.Evaluator as SelectableReplEvaluator; } if (_selectEval != null) { _selectEval.EvaluatorChanged += EvaluatorChanged; _selectEval.AvailableEvaluatorsChanged += AvailableEvaluatorsChanged; } var mse = _interactive?.Evaluator as IMultipleScopeEvaluator; if (mse != null) { _scopeListVisible = mse.EnableMultipleScopes; mse.AvailableScopesChanged += AvailableScopesChanged; mse.MultipleScopeSupportChanged += MultipleScopeSupportChanged; } if (_next == null && _interactive != null) { ErrorHandler.ThrowOnFailure(vsTextView.AddCommandFilter(this, out _next)); } }
internal VsProjectAnalyzer( IServiceProvider serviceProvider, IPythonInterpreter interpreter, IPythonInterpreterFactory factory, IPythonInterpreterFactory[] allFactories, bool implicitProject = true ) { _errorProvider = (ErrorTaskProvider)serviceProvider.GetService(typeof(ErrorTaskProvider)); _commentTaskProvider = (CommentTaskProvider)serviceProvider.GetService(typeof(CommentTaskProvider)); _unresolvedSquiggles = new UnresolvedImportSquiggleProvider(serviceProvider, _errorProvider); _queue = new ParseQueue(this); _analysisQueue = new AnalysisQueue(this); _analysisQueue.AnalysisStarted += AnalysisQueue_AnalysisStarted; _allFactories = allFactories; _interpreterFactory = factory; _implicitProject = implicitProject; if (interpreter != null) { _pyAnalyzer = PythonAnalyzer.Create(factory, interpreter); ReloadTask = _pyAnalyzer.ReloadModulesAsync().HandleAllExceptions(SR.ProductName, GetType()); ReloadTask.ContinueWith(_ => ReloadTask = null); interpreter.ModuleNamesChanged += OnModulesChanged; } _projectFiles = new ConcurrentDictionary<string, IProjectEntry>(StringComparer.OrdinalIgnoreCase); _pyService = serviceProvider.GetPythonToolsService(); _serviceProvider = serviceProvider; if (_pyAnalyzer != null) { _pyAnalyzer.Limits.CrossModule = _pyService.GeneralOptions.CrossModuleAnalysisLimit; // TODO: Load other limits from options } _userCount = 1; }
internal PythonAutomation(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _pyService = serviceProvider.GetPythonToolsService(); Debug.Assert(_pyService != null, "Did not find PythonToolsService"); }
internal PythonInteractiveOptions(IServiceProvider serviceProvider, PythonToolsService pyService, string category, string id) : base(pyService, category, id) { _serviceProvider = serviceProvider; }
public IronPythonLauncher(IServiceProvider serviceProvider, PythonToolsService pyService, IPythonProject project) { _serviceProvider = serviceProvider; _pyService = pyService; _project = project; }
internal AdvancedEditorOptions(PythonToolsService service) { _service = service; Load(); }
public CodeWindowManager(IServiceProvider serviceProvider, IVsCodeWindow codeWindow) { _serviceProvider = serviceProvider; _window = codeWindow; _pyService = _serviceProvider.GetPythonToolsService(); }
public DefaultLauncherProvider([Import(typeof(SVsServiceProvider))]IServiceProvider serviceProvider) { _serviceProvider = serviceProvider; _pyService = serviceProvider.GetPythonToolsService(); }