Esempio n. 1
0
 public OutliningTagger(PythonToolsService pyService, ITextBuffer buffer)
 {
     _pyService = pyService;
     _buffer    = buffer;
     _buffer.Properties[typeof(OutliningTagger)] = this;
     _enabled = _pyService.AdvancedOptions.EnterOutliningModeOnOpen;
     _timer   = new Timer(TagUpdate, null, Timeout.Infinite, Timeout.Infinite);
 }
Esempio n. 2
0
 public OutliningTagger(PythonToolsService pyService, ITextBuffer buffer)
 {
     _pyService = pyService;
     _buffer    = buffer;
     _buffer.Properties[typeof(OutliningTagger)] = this;
     _buffer.RegisterForParseTree(OnNewParseTree);
     _enabled = _pyService.AdvancedOptions.EnterOutliningModeOnOpen;
 }
Esempio n. 3
0
 internal PythonAutomation(IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
     _pyService       = serviceProvider.GetPythonToolsService();
     Debug.Assert(_pyService != null, "Did not find PythonToolsService");
 }
Esempio n. 4
0
 public OutliningTaggerProvider([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
 {
     _pyService = serviceProvider.GetPythonToolsService();
 }
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            var services = (IServiceContainer)this;

            // register our options service which provides registry access for various options
            var optionsService = new PythonToolsOptionsService(this);

            services.AddService(typeof(IPythonToolsOptionsService), optionsService, promote: true);

            services.AddService(typeof(IClipboardService), new ClipboardService(), promote: true);

            services.AddService(typeof(IPythonToolsToolWindowService), this, promote: true);

            // register our PythonToolsService which provides access to core PTVS functionality
            var pyService = _pyService = new PythonToolsService(services);

            services.AddService(typeof(PythonToolsService), pyService, promote: true);

            _autoObject = new PythonAutomation(this);

            services.AddService(
                typeof(ErrorTaskProvider),
                (container, serviceType) => {
                var errorList     = GetService(typeof(SVsErrorList)) as IVsTaskList;
                var model         = ComponentModel;
                var errorProvider = model != null ? model.GetService <IErrorProviderFactory>() : null;
                return(new ErrorTaskProvider(this, errorList, errorProvider));
            },
                promote: true);

            services.AddService(
                typeof(CommentTaskProvider),
                (container, serviceType) => {
                var taskList      = GetService(typeof(SVsTaskList)) as IVsTaskList;
                var model         = ComponentModel;
                var errorProvider = model != null ? model.GetService <IErrorProviderFactory>() : null;
                return(new CommentTaskProvider(this, taskList, errorProvider));
            },
                promote: true);

            var solutionEventListener = new SolutionEventsListener(this);

            solutionEventListener.StartListeningForChanges();

            services.AddService(
                typeof(SolutionEventsListener),
                solutionEventListener,
                promote: true
                );

#if DEV11_OR_LATER
            // Register custom debug event service
            var customDebuggerEventHandler = new CustomDebuggerEventHandler(this);
            services.AddService(customDebuggerEventHandler.GetType(), customDebuggerEventHandler, promote: true);

            // Enable the mixed-mode debugger UI context
            UIContext.FromUIContextGuid(DkmEngineId.NativeEng).IsActive = true;
#endif

            // Add our command handlers for menu (commands must exist in the .vsct file)
            RegisterCommands(new Command[] {
                new OpenDebugReplCommand(this),
                new ExecuteInReplCommand(this),
                new SendToReplCommand(this),
                new StartWithoutDebuggingCommand(this),
                new StartDebuggingCommand(this),
                new FillParagraphCommand(this),
                new SendToDefiningModuleCommand(this),
                new DiagnosticsCommand(this),
                new RemoveImportsCommand(this),
                new RemoveImportsCurrentScopeCommand(this),
                new OpenInterpreterListCommand(this),
                new ImportWizardCommand(this),
                new SurveyNewsCommand(this),
#if DEV11_OR_LATER
                new ShowPythonViewCommand(this),
                new ShowCppViewCommand(this),
                new ShowNativePythonFrames(this),
                new UsePythonStepping(this),
#endif
            }, GuidList.guidPythonToolsCmdSet);

#if FEATURE_AZURE_REMOTE_DEBUG
            try {
                RegisterCommands(new Command[] {
                    new AzureExplorerAttachDebuggerCommand(this)
                }, GuidList.guidPythonToolsCmdSet);
            } catch (NotSupportedException) {
            }
#endif


            RegisterCommands(GetReplCommands(), GuidList.guidPythonToolsCmdSet);

            RegisterProjectFactory(new PythonWebProjectFactory(this));

#if DEV11_OR_LATER
            // Enable the Python debugger UI context
            UIContext.FromUIContextGuid(AD7Engine.DebugEngineGuid).IsActive = true;
#endif

            var interpreterService = ComponentModel.GetService <IInterpreterOptionsService>();
            interpreterService.InterpretersChanged       += RefreshReplCommands;
            interpreterService.DefaultInterpreterChanged += RefreshReplCommands;

            var loadedProjectProvider = interpreterService.KnownProviders
                                        .OfType <LoadedProjectInterpreterFactoryProvider>()
                                        .FirstOrDefault();
            // Ensure the provider is available - if not, you probably need to
            // rebuild or clean your experimental hive.
            Debug.Assert(loadedProjectProvider != null, "Expected LoadedProjectInterpreterFactoryProvider");
            if (loadedProjectProvider != null)
            {
                loadedProjectProvider.SetSolution((IVsSolution)GetService(typeof(SVsSolution)));
            }

            // The variable is inherited by child processes backing Test Explorer, and is used in PTVS
            // test discoverer and test executor to connect back to VS.
            Environment.SetEnvironmentVariable("_PTVS_PID", Process.GetCurrentProcess().Id.ToString());
        }
Esempio n. 6
0
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Trace.WriteLine("Entering Initialize() of: {0}".FormatUI(this));
            base.Initialize();

            var services = (IServiceContainer)this;

            // register our options service which provides registry access for various options
            services.AddService(typeof(IPythonToolsOptionsService), PythonToolsOptionsService.CreateService, promote: true);

            services.AddService(typeof(IClipboardService), new ClipboardService(), promote: true);

            services.AddService(typeof(IPythonToolsToolWindowService), this, promote: true);

            // register our PythonToolsService which provides access to core PTVS functionality
            PythonToolsService pyService;

            try {
                pyService = _pyService = new PythonToolsService(services);
            } catch (Exception ex) when(!ex.IsCriticalException())
            {
                ex.ReportUnhandledException(services, GetType(), allowUI: false);
                throw;
            }

            services.AddService(typeof(PythonToolsService), pyService, promote: true);

            _autoObject = new PythonAutomation(this);

            services.AddService(
                typeof(ErrorTaskProvider),
                (container, serviceType) => {
                var errorList     = GetService(typeof(SVsErrorList)) as IVsTaskList;
                var model         = ComponentModel;
                var errorProvider = model != null ? model.GetService <IErrorProviderFactory>() : null;
                return(new ErrorTaskProvider(this, errorList, errorProvider));
            },
                promote: true);

            services.AddService(
                typeof(CommentTaskProvider),
                (container, serviceType) => {
                var taskList      = GetService(typeof(SVsTaskList)) as IVsTaskList;
                var model         = ComponentModel;
                var errorProvider = model != null ? model.GetService <IErrorProviderFactory>() : null;
                return(new CommentTaskProvider(this, taskList, errorProvider));
            },
                promote: true);


            var solutionEventListener = new SolutionEventsListener(this);

            solutionEventListener.StartListeningForChanges();

            services.AddService(
                typeof(SolutionEventsListener),
                solutionEventListener,
                promote: true
                );

            // Register custom debug event service
            var customDebuggerEventHandler = new CustomDebuggerEventHandler(this);

            services.AddService(customDebuggerEventHandler.GetType(), customDebuggerEventHandler, promote: true);

            // Enable the mixed-mode debugger UI context
            UIContext.FromUIContextGuid(DkmEngineId.NativeEng).IsActive = true;

            // Add our command handlers for menu (commands must exist in the .vsct file)
            RegisterCommands(new Command[] {
                new OpenReplCommand(this, (int)PkgCmdIDList.cmdidReplWindow),
                new OpenReplCommand(this, (int)PythonConstants.OpenInteractiveForEnvironment),
                new OpenDebugReplCommand(this),
                new ExecuteInReplCommand(this),
                new SendToReplCommand(this),
                new StartWithoutDebuggingCommand(this),
                new StartDebuggingCommand(this),
                new FillParagraphCommand(this),
                new DiagnosticsCommand(this),
                new RemoveImportsCommand(this, true),
                new RemoveImportsCommand(this, false),
                new OpenInterpreterListCommand(this),
                new ImportWizardCommand(this),
                new SurveyNewsCommand(this),
                new ImportCoverageCommand(this),
                new ShowPythonViewCommand(this),
                new ShowCppViewCommand(this),
                new ShowNativePythonFrames(this),
                new UsePythonStepping(this),
                new AzureExplorerAttachDebuggerCommand(this),
            }, GuidList.guidPythonToolsCmdSet);


            // Enable the Python debugger UI context
            UIContext.FromUIContextGuid(AD7Engine.DebugEngineGuid).IsActive = true;

            var interpreters       = ComponentModel.GetService <IInterpreterRegistryService>();
            var interpreterService = ComponentModel.GetService <IInterpreterOptionsService>();

            // The variable is inherited by child processes backing Test Explorer, and is used in PTVS
            // test discoverer and test executor to connect back to VS.
            Environment.SetEnvironmentVariable("_PTVS_PID", Process.GetCurrentProcess().Id.ToString());

            Trace.WriteLine("Leaving Initialize() of: {0}".FormatUI(this));
        }
Esempio n. 7
0
 public SurveyNewsService(PythonToolsService pyService)
 {
     _pyService = pyService;
 }