public RoslynTextViewCreationListener(SVsServiceProvider serviceProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, ICompletionBroker completionBroker, MefProviderOptions mefProviderOptions)
 {
     _serviceProvider = serviceProvider;
     _editorAdaptersFactoryService = editorAdaptersFactoryService;
     _completionBroker = completionBroker;
     _mefProviderOptions = mefProviderOptions;
 }
        public GoToDefinitionTextViewCreationListener(SVsServiceProvider serviceProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService, IClassifierAggregatorService classifierAggregatorService, MefProviderOptions mefProviderOptions)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            if (editorAdaptersFactoryService == null)
            {
                throw new ArgumentNullException("editorAdaptersFactoryService");
            }
            if (textStructureNavigatorSelectorService == null)
            {
                throw new ArgumentNullException("textStructureNavigatorSelectorService");
            }
            if (classifierAggregatorService == null)
            {
                throw new ArgumentNullException("classifierAggregatorService");
            }
            if (mefProviderOptions == null)
            {
                throw new ArgumentNullException("mefProviderOptions");
            }

            ServiceProvider = serviceProvider;
            _editorAdaptersFactoryService         = editorAdaptersFactoryService;
            TextStructureNavigatorSelectorService = textStructureNavigatorSelectorService;
            ClassifierAggregatorService           = classifierAggregatorService;
            MefProviderOptions = mefProviderOptions;
        }
        /// <summary>
        /// This is overridden to validate the option values
        /// </summary>
        /// <param name="e">The event arguments</param>
        protected override void OnDeactivate(CancelEventArgs e)
        {
            base.OnDeactivate(e);

            if (!e.Cancel && control != null)
            {
                e.Cancel = !control.IsValid;

                // We must apply changes here if valid or they don't stick
                if (!e.Cancel)
                {
                    this.MSHelpViewerPath            = control.MSHelpViewerPath;
                    this.AspNetDevelopmentServerPort = control.AspNetDevelopmentServerPort;
                    this.VerboseLogging             = control.VerboseLogging;
                    this.OpenLogViewerOnFailedBuild = control.OpenLogViewerOnFailedBuild;
                    this.OpenHelpAfterBuild         = control.OpenHelpAfterBuild;
                    this.UseExternalWebBrowser      = control.UseExternalWebBrowser;

                    // MEF provider options are stored separately to avoid loading the entire package just to
                    // access these options.
                    var mefOptions = new MefProviderOptions(this.Site);

                    mefOptions.EnableExtendedXmlCommentsCompletion = control.EnableExtendedXmlCommentsCompletion;
                    mefOptions.EnableGoToDefinition          = control.EnableGoToDefinition;
                    mefOptions.EnableCtrlClickGoToDefinition = control.EnableCtrlClickGoToDefinition;
                    mefOptions.EnableGoToDefinitionInCRef    = control.EnableGoToDefinitionInCRef;

                    mefOptions.SaveConfiguration();
                }
                ;
            }
        }
 public RoslynTextViewCreationListener(SVsServiceProvider serviceProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, ICompletionBroker completionBroker, MefProviderOptions mefProviderOptions)
 {
     _serviceProvider = serviceProvider;
     _editorAdaptersFactoryService = editorAdaptersFactoryService;
     _completionBroker             = completionBroker;
     _mefProviderOptions           = mefProviderOptions;
 }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
#pragma warning disable VSTHRD010
            // Disable this in VS 2019 for now as it causes problems and non-async completions aren't supported
            // anyway.
            if (typeof(ITextBuffer).Assembly.GetName().Version.Major < 16)
            {
                var options = new MefProviderOptions(_serviceProvider);

                if (options.EnableExtendedXmlCommentsCompletion)
                {
                    ITextView textView = _editorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

                    if (textView != null)
                    {
                        textView.Properties.AddProperty(typeof(RoslynKeyboardFilter),
                                                        new RoslynKeyboardFilter(_completionBroker, textViewAdapter, textView)
                        {
                            Enabled = true
                        });
                    }
                }
            }
#pragma warning restore VSTHRD010
        }
Esempio n. 6
0
        public ToolTipProvider(SVsServiceProvider serviceProvider)
        {
            _serviceProvider = serviceProvider;

            var options = new MefProviderOptions(_serviceProvider);

            enableExtendedCompletion = options.EnableExtendedXmlCommentsCompletion;
        }
        /// <inheritdoc />
        public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
        {
            var options = new MefProviderOptions(serviceProvider);

            if(!options.EnableExtendedXmlCommentsCompletion)
                return null;

            return new CSharpDocumentationCompletionSource(textBuffer, this);
        }
        /// <inheritdoc />
        public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
        {
            var options = new MefProviderOptions(GlobalServiceProvider);

            if(!options.EnableGoToDefinition)
                return null;

            return new MamlLinkQuickInfoSource(GlobalServiceProvider, textBuffer, this,
                options.EnableCtrlClickGoToDefinition);
        }
        public KeyProcessor GetAssociatedProcessor(IWpfTextView view)
        {
            var options = new MefProviderOptions(serviceProvider);

            if(!options.EnableGoToDefinition || !options.EnableCtrlClickGoToDefinition)
                return null;

            return view.Properties.GetOrCreateSingletonProperty(typeof(GoToDefinitionKeyProcessor),
                () => new GoToDefinitionKeyProcessor(CtrlKeyState.GetStateForView(view)));
        }
        /// <inheritdoc />
        public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
        {
            var options = new MefProviderOptions(serviceProvider);

            if (!options.EnableExtendedXmlCommentsCompletion)
            {
                return(null);
            }

            return(new CSharpDocumentationCompletionSource(textBuffer, this));
        }
Esempio n. 11
0
        /// <inheritdoc />
        public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
        {
            var options = new MefProviderOptions(GlobalServiceProvider);

            if (!options.EnableGoToDefinition)
            {
                return(null);
            }

            return(new MamlLinkQuickInfoSource(GlobalServiceProvider, textBuffer, this,
                                               options.EnableCtrlClickGoToDefinition));
        }
        public KeyProcessor GetAssociatedProcessor(IWpfTextView view)
        {
            var options = new MefProviderOptions(serviceProvider);

            if (!options.EnableGoToDefinition || !options.EnableCtrlClickGoToDefinition)
            {
                return(null);
            }

            return(view.Properties.GetOrCreateSingletonProperty(typeof(GoToDefinitionKeyProcessor),
                                                                () => new GoToDefinitionKeyProcessor(CtrlKeyState.GetStateForView(view))));
        }
        /// <inheritdoc />
        public IMouseProcessor GetAssociatedProcessor(IWpfTextView view)
        {
            var options = new MefProviderOptions(GlobalServiceProvider);

            if(!options.EnableGoToDefinition || !options.EnableCtrlClickGoToDefinition)
                return null;

            var buffer = view.TextBuffer;

            return new XmlGoToDefinitionMouseProcessor(view, GlobalServiceProvider,
                AggregatorFactory.GetClassifier(buffer), NavigatorService.GetTextStructureNavigator(buffer),
                CtrlKeyState.GetStateForView(view));
        }
        /// <inheritdoc />
        public IMouseProcessor GetAssociatedProcessor(IWpfTextView view)
        {
            var options = new MefProviderOptions(GlobalServiceProvider);

            if (!options.EnableGoToDefinition || !options.EnableCtrlClickGoToDefinition)
            {
                return(null);
            }

            var buffer = view.TextBuffer;

            return(new CSharpGoToDefinitionMouseProcessor(view, GlobalServiceProvider, AggregatorFactory.GetClassifier(buffer),
                                                          NavigatorService.GetTextStructureNavigator(buffer), CtrlKeyState.GetStateForView(view)));
        }
Esempio n. 15
0
        //=====================================================================

        /// <inheritdoc />
        public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            var options = new MefProviderOptions(serviceProvider);

            if (textView.TextBuffer != buffer || !options.EnableGoToDefinition || !options.EnableCtrlClickGoToDefinition)
            {
                return(null);
            }

            if (UnderlineClassification == null)
            {
                UnderlineClassification = ClassificationRegistry.GetClassificationType(UnderlineClassifier.UnderlineClassifierType);
            }

            return(GetClassifierForView(textView) as ITagger <T>);
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var options = new MefProviderOptions(_serviceProvider);

            // only hook when necessary
            if((!RoslynUtilities.IsRoslynInstalled(_serviceProvider) ?? true) || !options.EnableExtendedXmlCommentsCompletion)
                return;

            ITextView textView = _editorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if(textView == null)
                return;

            RoslynKeyboardFilter filter = new RoslynKeyboardFilter(_completionBroker, textViewAdapter, textView);
            filter.Enabled = true;
            textView.Properties.AddProperty(typeof(RoslynKeyboardFilter), filter);
        }
        //=====================================================================

        /// <summary>
        /// This is used to update the controls with the current property values
        /// </summary>
        /// <param name="optionsPage">The options page</param>
        public void SetValues(SandcastleBuilderOptionsPage optionsPage)
        {
            txtHxSViewerPath.Text             = optionsPage.HxsViewerPath;
            txtMSHelpViewerPath.Text          = optionsPage.MSHelpViewerPath;
            udcASPNetDevServerPort.Value      = optionsPage.AspNetDevelopmentServerPort;
            chkVerboseLogging.Checked         = optionsPage.VerboseLogging;
            chkOpenLogViewerOnFailure.Checked = optionsPage.OpenLogViewerOnFailedBuild;
            chkOpenHelpAfterBuild.Checked     = optionsPage.OpenHelpAfterBuild;
            chkUseExternalBrowser.Checked     = optionsPage.UseExternalWebBrowser;

            // MEF provider options are stored separately to avoid loading the entire package just to access
            // these options.
            MefProviderOptions mefProviderOptions = GetMefProviderOptions(optionsPage.Site);

            chkEnableExtendedXmlComments.Checked  = mefProviderOptions.EnableExtendedXmlCommentsCompletion;
            chkEnableGoToDefinition.Checked       = mefProviderOptions.EnableGoToDefinition;
            chkEnableGoToDefinitionInCRef.Checked = mefProviderOptions.EnableGoToDefinitionInCRef;
        }
        public GoToDefinitionTextViewCreationListener(SVsServiceProvider serviceProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService, IClassifierAggregatorService classifierAggregatorService, MefProviderOptions mefProviderOptions)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");
            if (editorAdaptersFactoryService == null)
                throw new ArgumentNullException("editorAdaptersFactoryService");
            if (textStructureNavigatorSelectorService == null)
                throw new ArgumentNullException("textStructureNavigatorSelectorService");
            if (classifierAggregatorService == null)
                throw new ArgumentNullException("classifierAggregatorService");
            if (mefProviderOptions == null)
                throw new ArgumentNullException("mefProviderOptions");

            ServiceProvider = serviceProvider;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            TextStructureNavigatorSelectorService = textStructureNavigatorSelectorService;
            ClassifierAggregatorService = classifierAggregatorService;
            MefProviderOptions = mefProviderOptions;
        }
        //=====================================================================

        /// <summary>
        /// Set the current control values
        /// </summary>
        public void SetValues()
        {
            if (control != null)
            {
                control.MSHelpViewerPath            = this.MSHelpViewerPath;
                control.AspNetDevelopmentServerPort = this.AspNetDevelopmentServerPort;
                control.VerboseLogging             = this.VerboseLogging;
                control.OpenLogViewerOnFailedBuild = this.OpenLogViewerOnFailedBuild;
                control.OpenHelpAfterBuild         = this.OpenHelpAfterBuild;
                control.UseExternalWebBrowser      = this.UseExternalWebBrowser;

                // MEF provider options are stored separately to avoid loading the entire package just to access
                // these options.
                var mefOptions = new MefProviderOptions(this.Site);

                control.EnableExtendedXmlCommentsCompletion = mefOptions.EnableExtendedXmlCommentsCompletion;
                control.EnableGoToDefinition          = mefOptions.EnableGoToDefinition;
                control.EnableCtrlClickGoToDefinition = mefOptions.EnableCtrlClickGoToDefinition;
            }
        }
        //=====================================================================

        /// <inheritdoc />
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var options = new MefProviderOptions(ServiceProvider);

            if (options.EnableGoToDefinition)
            {
                var textView = editorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

                if (textView != null)
                {
                    var filter = new GoToDefinitionCommandTarget(textView, this);

                    if (ErrorHandler.Succeeded(textViewAdapter.AddCommandFilter(filter, out IOleCommandTarget nextTarget)))
                    {
                        filter.NextTarget = nextTarget;
                        textView.Properties.GetOrCreateSingletonProperty(() => filter);
                    }
                }
            }
        }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var options = new MefProviderOptions(_serviceProvider);

            // only hook when necessary
            if ((!RoslynUtilities.IsRoslynInstalled(_serviceProvider) ?? true) || !options.EnableExtendedXmlCommentsCompletion)
            {
                return;
            }

            ITextView textView = _editorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            RoslynKeyboardFilter filter = new RoslynKeyboardFilter(_completionBroker, textViewAdapter, textView);

            filter.Enabled = true;
            textView.Properties.AddProperty(typeof(RoslynKeyboardFilter), filter);
        }
        /// <summary>
        /// This is called by the owning dialog page to validate the values and apply changes to the properties
        /// </summary>
        /// <param name="optionsPage">The options page</param>
        public void ApplyChanges(SandcastleBuilderOptionsPage optionsPage)
        {
            if (this.IsValid)
            {
                optionsPage.HxsViewerPath               = txtHxSViewerPath.Text;
                optionsPage.MSHelpViewerPath            = txtMSHelpViewerPath.Text;
                optionsPage.AspNetDevelopmentServerPort = (int)udcASPNetDevServerPort.Value;
                optionsPage.VerboseLogging              = chkVerboseLogging.Checked;
                optionsPage.OpenLogViewerOnFailedBuild  = chkOpenLogViewerOnFailure.Checked;
                optionsPage.OpenHelpAfterBuild          = chkOpenHelpAfterBuild.Checked;
                optionsPage.UseExternalWebBrowser       = chkUseExternalBrowser.Checked;

                // MEF provider options are stored separately to avoid loading the entire package just to access
                // these options.
                MefProviderOptions mefProviderOptions = GetMefProviderOptions(optionsPage.Site);
                mefProviderOptions.EnableExtendedXmlCommentsCompletion = chkEnableExtendedXmlComments.Checked;
                mefProviderOptions.EnableGoToDefinition       = chkEnableGoToDefinition.Checked;
                mefProviderOptions.EnableGoToDefinitionInCRef = chkEnableGoToDefinitionInCRef.Checked;

                mefProviderOptions.SaveConfiguration();
            }
        }
        //=====================================================================

        /// <inheritdoc />
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            GoToDefinitionCommandTarget filter;
            IOleCommandTarget nextTarget;

            var options = new MefProviderOptions(ServiceProvider);

            if(options.EnableGoToDefinition)
            {
                var textView = editorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

                if(textView != null)
                {
                    filter = new GoToDefinitionCommandTarget(textView, this, options.EnableGoToDefinitionInCRef,
                        !textView.TextBuffer.ContentType.IsOfType("xml"));

                    if(ErrorHandler.Succeeded(textViewAdapter.AddCommandFilter(filter, out nextTarget)))
                    {
                        filter.NextTarget = nextTarget;
                        textView.Properties.GetOrCreateSingletonProperty(() => filter);
                    }
                }
            }
        }
Esempio n. 24
0
 public ToolTipProvider(SVsServiceProvider serviceProvider, MefProviderOptions mefProviderOptions)
 {
     _serviceProvider    = serviceProvider;
     _mefProviderOptions = mefProviderOptions;
 }
        //=====================================================================

        /// <summary>
        /// This is used to update the controls with the current property values
        /// </summary>
        /// <param name="optionsPage">The options page</param>
        public void SetValues(SandcastleBuilderOptionsPage optionsPage)
        {
            txtMSHelpViewerPath.Text = optionsPage.MSHelpViewerPath;
            udcASPNetDevServerPort.Value = optionsPage.AspNetDevelopmentServerPort;
            chkVerboseLogging.Checked = optionsPage.VerboseLogging;
            chkOpenLogViewerOnFailure.Checked = optionsPage.OpenLogViewerOnFailedBuild;
            chkOpenHelpAfterBuild.Checked = optionsPage.OpenHelpAfterBuild;
            chkUseExternalBrowser.Checked = optionsPage.UseExternalWebBrowser;

            // MEF provider options are stored separately to avoid loading the entire package just to access
            // these options.
            var mefOptions = new MefProviderOptions(optionsPage.Site);

            chkEnableExtendedXmlComments.Checked = mefOptions.EnableExtendedXmlCommentsCompletion;
            chkEnableGoToDefinition.Checked = mefOptions.EnableGoToDefinition;
            chkEnableCtrlClickGoToDefinition.Checked = mefOptions.EnableCtrlClickGoToDefinition;
            chkEnableGoToDefinitionInCRef.Checked = mefOptions.EnableGoToDefinitionInCRef;
        }
        /// <summary>
        /// This is called by the owning dialog page to validate the values and apply changes to the properties
        /// </summary>
        /// <param name="optionsPage">The options page</param>
        public void ApplyChanges(SandcastleBuilderOptionsPage optionsPage)
        {
            if(this.IsValid)
            {
                optionsPage.MSHelpViewerPath = txtMSHelpViewerPath.Text;
                optionsPage.AspNetDevelopmentServerPort = (int)udcASPNetDevServerPort.Value;
                optionsPage.VerboseLogging = chkVerboseLogging.Checked;
                optionsPage.OpenLogViewerOnFailedBuild = chkOpenLogViewerOnFailure.Checked;
                optionsPage.OpenHelpAfterBuild = chkOpenHelpAfterBuild.Checked;
                optionsPage.UseExternalWebBrowser = chkUseExternalBrowser.Checked;

                // MEF provider options are stored separately to avoid loading the entire package just to access
                // these options.
                var mefOptions = new MefProviderOptions(optionsPage.Site);

                mefOptions.EnableExtendedXmlCommentsCompletion = chkEnableExtendedXmlComments.Checked;
                mefOptions.EnableGoToDefinition = chkEnableGoToDefinition.Checked;
                mefOptions.EnableCtrlClickGoToDefinition = chkEnableCtrlClickGoToDefinition.Checked;
                mefOptions.EnableGoToDefinitionInCRef = chkEnableGoToDefinitionInCRef.Checked;

                mefOptions.SaveConfiguration();
            }
        }