public VisualStudioWindowsLSPEditorFeatureDetector(AggregateProjectCapabilityResolver projectCapabilityResolver)
        {
            _projectCapabilityResolver = projectCapabilityResolver;
            _vsUIShellOpenDocument     = new Lazy <IVsUIShellOpenDocument>(() =>
            {
                var shellOpenDocument = (IVsUIShellOpenDocument)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShellOpenDocument));
                Assumes.Present(shellOpenDocument);

                return(shellOpenDocument);
            });

            _useLegacyEditor = new Lazy <bool>(() =>
            {
                var featureFlags = (IVsFeatureFlags)AsyncPackage.GetGlobalService(typeof(SVsFeatureFlags));
                var legacyEditorFeatureFlagEnabled = featureFlags.IsFeatureEnabled(LegacyRazorEditorFeatureFlag, defaultValue: false);
                if (legacyEditorFeatureFlagEnabled)
                {
                    return(true);
                }

                var settingsManager = (ISettingsManager)ServiceProvider.GlobalProvider.GetService(typeof(SVsSettingsPersistenceManager));
                Assumes.Present(settingsManager);

                var useLegacyEditor = settingsManager.GetValueOrDefault <bool>(UseLegacyASPNETCoreEditorSetting);
                return(useLegacyEditor);
            });
        }
Exemplo n.º 2
0
        public ExtensionStatusContainer(
            )
        {
            _dte = (AsyncPackage.GetGlobalService(typeof(EnvDTE.DTE)) as DTE2) !;

            ProcessStatus();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize Logger output window
        /// </summary>
        public static void Initialize()
        {
            _outputWindow = AsyncPackage.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
            var windowGuid  = new Guid(ProjectGuids.OutputWindowGuidString);
            var windowTitle = "Crm Publisher";

            _outputWindow.CreatePane(ref windowGuid, windowTitle, 1, 1);
        }
        /// <summary>
        /// Returns true if the client is a CodeSpace instance.
        /// </summary>
        protected virtual bool IsVSServer()
        {
            var shell  = AsyncPackage.GetGlobalService(typeof(SVsShell)) as IVsShell;
            var result = shell.GetProperty((int)__VSSPROPID11.VSSPROPID_ShellMode, out var mode);

            var isVSServer = ErrorHandler.Succeeded(result) && (int)mode == (int)__VSShellMode.VSSM_Server;

            return(isVSServer);
        }
Exemplo n.º 5
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            // Explicitly trigger the load of the CSharp package. This ensures that UI-bound services are appropriately prefetched. Ideally, we shouldn't need this but until Roslyn fixes it on their side, we have to live with it.
            var shellService = (IVsShell7)AsyncPackage.GetGlobalService(typeof(SVsShell));
            await shellService.LoadPackageAsync(new Guid(CSharpPackageGuidString));
        }
        private async System.Threading.Tasks.Task <int> ReadFullyLoadStatusAsync(
            CancellationToken token
            )
        {
            try
            {
                while (!token.WaitHandle.WaitOne(100))
                {
                    //await Task.Delay(100, token);

                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(token);

                    var solution = (AsyncPackage.GetGlobalService(typeof(SVsSolution)) as IVsSolution) !;

                    solution.GetProperty((int)__VSPROPID4.VSPROPID_IsSolutionFullyLoaded, out object asm);

                    await TaskScheduler.Default;

                    if (!(asm is bool))
                    {
                        continue;
                    }

                    //var context = Microsoft.VisualStudio.Shell.KnownUIContexts.SolutionExistsAndFullyLoadedContext;
                    //var contextActive = context.IsActive;

                    _isSolutionFullyLoaded = (bool)asm;
                    var solutionStatus = _isSolutionFullyLoaded && _esc.SolutionExists;

                    if (_solutionStatus != solutionStatus)
                    {
                        _solutionStatus = solutionStatus;

                        OnSolutionStatusChanged(solutionStatus);
                    }
                }
            }
            catch (OperationCanceledException oce)
            {
                //it's OK
            }
            catch (Exception excp)
            {
                LogVS(excp);
            }

            return(VSConstants.S_OK);
        }
Exemplo n.º 7
0
        public DefaultLSPEditorFeatureDetector(ProjectHierarchyInspector projectHierarchyInspector)
        {
            if (projectHierarchyInspector is null)
            {
                throw new ArgumentNullException(nameof(projectHierarchyInspector));
            }

            _projectHierarchyInspector = projectHierarchyInspector;
            _featureFlags          = (IVsFeatureFlags)AsyncPackage.GetGlobalService(typeof(SVsFeatureFlags));
            _vsUIShellOpenDocument = new Lazy <IVsUIShellOpenDocument>(() =>
            {
                var shellOpenDocument = (IVsUIShellOpenDocument)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShellOpenDocument));
                Assumes.Present(shellOpenDocument);

                return(shellOpenDocument);
            });
        }
Exemplo n.º 8
0
        // Private protected virtual for testing
        private protected virtual bool IsVSServer()
        {
            var shell  = AsyncPackage.GetGlobalService(typeof(SVsShell)) as IVsShell;
            var result = shell.GetProperty((int)__VSSPROPID11.VSSPROPID_ShellMode, out var mode);

            if (!ErrorHandler.Succeeded(result))
            {
                return(false);
            }

            // VSSPROPID_ShellMode is set to VSSM_Server when /server is used in devenv command
            if ((int)mode != (int)__VSShellMode.VSSM_Server)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 9
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            // Explicitly trigger the load of the CSharp package. This ensures that UI-bound services are appropriately prefetched. Ideally, we shouldn't need this but until Roslyn fixes it on their side, we have to live with it.
            var shellService = (IVsShell7)AsyncPackage.GetGlobalService(typeof(SVsShell));
            await shellService.LoadPackageAsync(new Guid(CSharpPackageGuidString));

            _editorFactory = new RazorEditorFactory(this);
            RegisterEditorFactory(_editorFactory);

            var componentModel = (IComponentModel)AsyncPackage.GetGlobalService(typeof(SComponentModel));

            // This type listens to ITextDocumentFactoryService created and disposed events. We want to tie into these as soon as possible to ensure we don't miss
            // and relevant Razor documents.
            _ = componentModel.GetService <RazorLSPTextDocumentCreatedListener>();
        }
Exemplo n.º 10
0
        private void AsyncStartScanInternal()
        {
            try
            {
                var taskStatusCenterService = AsyncPackage.GetGlobalService(typeof(SVsTaskStatusCenterService)) as IVsTaskStatusCenterService;
                if (taskStatusCenterService == null)
                {
                    return;
                }

                var options = default(TaskHandlerOptions);
                options.Title = "Scanning solution for Dpdt clusters and its bindings...";
                options.ActionsAfterCompletion = CompletionActions.None;

                _data = default(TaskProgressData);
                _data.CanBeCanceled = false;

                var handler = taskStatusCenterService.PreRegister(options, _data);


                _backgroundScanner = new BackgroundScanner(
                    _outputPane !,
                    _buildStatusContainer
                    );

                CodeLensConnectionHandler.RefreshAllCodeLensDataPointsAsync()
                .FileAndForget(nameof(CodeLensConnectionHandler.RefreshAllCodeLensDataPointsAsync))
                ;

                _backgroundScanner.AsyncStart();

                handler.RegisterTask(
                    Task.Run(
                        async() => await ShowProgressAsync(handler)
                        )
                    );
            }
            catch (Exception excp)
            {
                LogVS(excp);
            }
        }
        // Private protected virtual for testing
        private protected virtual bool IsVSServer()
        {
            if (!_isVSServer.HasValue)
            {
                var shell  = AsyncPackage.GetGlobalService(typeof(SVsShell)) as IVsShell;
                var result = shell.GetProperty((int)__VSSPROPID11.VSSPROPID_ShellMode, out var mode);

                if (ErrorHandler.Succeeded(result))
                {
                    // VSSPROPID_ShellMode is set to VSSM_Server when /server is used in devenv command
                    _isVSServer = ((int)mode == (int)__VSShellMode.VSSM_Server);
                }
                else
                {
                    _isVSServer = false;
                }
            }

            return(_isVSServer.Value);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SarifExplorerWindow"/> class.
        /// </summary>
        public SarifExplorerWindow()
            : base(null)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            this.Caption = Resources.SarifExplorerCaption;

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            this.Content           = new SarifToolWindowControl();
            this.Control.Loaded   += this.Control_Loaded;
            this.Control.Unloaded += this.Control_Unloaded;

            var componentModel = (IComponentModel)AsyncPackage.GetGlobalService(typeof(SComponentModel));

            if (componentModel != null)
            {
                this.sarifErrorListEventSelectionService = componentModel.GetService <ISarifErrorListEventSelectionService>();
                this.textViewCaretListenerService        = componentModel.GetService <ITextViewCaretListenerService <ITextMarkerTag> >();
            }
        }
Exemplo n.º 13
0
 public ExtensionManagerShim(object extensionManager, Action <string> errorHandler)
 {
     InitializeTypes(errorHandler);
     _extensionManager = extensionManager ?? AsyncPackage.GetGlobalService(_sVsExtensionManagerType);
 }
        public RazorEditorFactory(AsyncPackage package) : base(package)
        {
            var componentModel = (IComponentModel)AsyncPackage.GetGlobalService(typeof(SComponentModel));

            _lspEditorFeatureDetector = componentModel.GetService <LSPEditorFeatureDetector>();
        }
Exemplo n.º 15
0
 public BuildStatusContainer(
     )
 {
     _dte         = (AsyncPackage.GetGlobalService(typeof(EnvDTE.DTE)) as DTE2) !;
     _buildEvents = _dte.Events.BuildEvents;
 }