Example #1
0
        private static IEnumerable <InterpreterConfiguration> TestTriggerDiscovery(
            IVsFolderWorkspaceService workspaceService,
            Action triggerDiscovery,
            bool useDiscoveryStartedEvent = false
            )
        {
            using (var evt = new AutoResetEvent(false))
                using (var provider = new WorkspaceInterpreterFactoryProvider(workspaceService)) {
                    // This initializes the provider, discovers the initial set
                    // of factories and starts watching the filesystem.
                    var configs = provider.GetInterpreterConfigurations();

                    if (useDiscoveryStartedEvent)
                    {
                        provider.DiscoveryStarted += (sender, e) => {
                            evt.Set();
                        };
                    }
                    else
                    {
                        provider.InterpreterFactoriesChanged += (sender, e) => {
                            evt.Set();
                        };
                    }

                    triggerDiscovery();
                    Assert.IsTrue(evt.WaitOne(5000), "Failed to trigger discovery.");
                    return(provider.GetInterpreterConfigurations());
                }
        }
Example #2
0
        public RemoteLanguageServiceWorkspace(
            ExportProvider exportProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IVsFolderWorkspaceService vsFolderWorkspaceService,
            SVsServiceProvider serviceProvider,
            IDiagnosticService diagnosticService,
            ITableManagerProvider tableManagerProvider,
            IGlobalOptionService globalOptions,
            IThreadingContext threadingContext)
            : base(VisualStudioMefHostServices.Create(exportProvider), WorkspaceKind.CloudEnvironmentClientWorkspace)
        {
            _serviceProvider = serviceProvider;

            _remoteDiagnosticListTable = new RemoteDiagnosticListTable(serviceProvider, this, globalOptions, diagnosticService, tableManagerProvider);

            var runningDocumentTable = (IVsRunningDocumentTable)serviceProvider.GetService(typeof(SVsRunningDocumentTable));

            _runningDocumentTableEventTracker = new RunningDocumentTableEventTracker(threadingContext, editorAdaptersFactoryService, runningDocumentTable, this);
            _threadingContext = threadingContext;

            _vsFolderWorkspaceService = vsFolderWorkspaceService;

            _remoteWorkspaceRootPaths = ImmutableHashSet <string> .Empty;
            _registeredExternalPaths  = ImmutableHashSet <string> .Empty;
        }
 public SvelteLanguageClient(
     [Import] IVsFolderWorkspaceService workspaceService,
     [Import] TsJsTextBufferManager tsJsTextBufferManager)
     : base(workspaceService, tsJsTextBufferManager)
 {
     middleLayerHost.Register(new CompletionMiddleLayer(shouldFilterOutJSDocSnippet: true));
 }
 public WorkspaceInterpreterFactoryProvider(
     [Import] IVsFolderWorkspaceService workspaceService = null
     )
 {
     _workspaceService = workspaceService;
     _workspaceService.OnActiveWorkspaceChanged += OnActiveWorkspaceChanged;
 }
        internal static string GetSolutionPath(DTE2 dte, IVsFolderWorkspaceService workspaceService)
        {
            if (!SarifViewerPackage.IsUnitTesting)
            {
#pragma warning disable VSTHRD108 // Assert thread affinity unconditionally
                ThreadHelper.ThrowIfNotOnUIThread();
#pragma warning restore VSTHRD108
            }

            // Check to see if this is an "Open Folder" scenario where there is no ".sln" file.
            string solutionPath = workspaceService?.CurrentWorkspace?.Location;

            if (!string.IsNullOrEmpty(solutionPath))
            {
                return(solutionPath);
            }

            // If we don't have an open folder situation, then we assume there is a ".sln" file.
            // When VS opens a file instead of a solution/folder, it creates a temporary solution "Solution1"
            // and its opened but FullName is empty
            if (dte?.Solution != null && dte.Solution.IsOpen && !string.IsNullOrWhiteSpace(dte.Solution.FullName))
            {
                solutionPath = Path.GetDirectoryName(dte.Solution.FullName);
            }

            return(solutionPath);
        }
        public void CodeAnalysisResultManager_GetSolutionPath_NoSolutionNoWorkspaceOpened()
        {
            IVsFolderWorkspaceService workspaceService = null;
            DTE2 dte = null;

            string solutionPath = CodeAnalysisResultManager.GetSolutionPath(dte, workspaceService);

            solutionPath.Should().BeNull();
        }
        public void CodeAnalysisResultManager_GetSolutionPath_SolutionFolderOpened()
        {
            const string folder = @"C:\github\repo\myproject\";
            IVsFolderWorkspaceService workspaceService = SetupWorkspaceService(folder);
            DTE2 dte = null;

            string solutionPath = CodeAnalysisResultManager.GetSolutionPath(dte, workspaceService);

            solutionPath.Should().BeEquivalentTo(folder);
        }
        public void CodeAnalysisResultManager_GetSolutionPath_TempSolutionOpened()
        {
            string folder = string.Empty;
            IVsFolderWorkspaceService workspaceService = null;
            DTE2 dte = SetupSolutionService(folder);

            string solutionPath = CodeAnalysisResultManager.GetSolutionPath(dte, workspaceService);

            solutionPath.Should().BeNull();
        }
 public EnvironmentSwitcherManager(IServiceProvider serviceProvider)
 {
     _serviceProvider  = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     _optionsService   = serviceProvider.GetComponentModel().GetService <IInterpreterOptionsService>();
     _registryService  = serviceProvider.GetComponentModel().GetService <IInterpreterRegistryService>();
     _monitorSelection = serviceProvider.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
     _shell            = serviceProvider.GetService(typeof(SVsShell)) as IVsShell;
     _workspaceService = serviceProvider.GetComponentModel().GetService <IVsFolderWorkspaceService>();
     AllFactories      = Enumerable.Empty <IPythonInterpreterFactory>();
 }
        public SvelteLanguageClientBase(
            IVsFolderWorkspaceService workspaceService,
            TsJsTextBufferManager tsJsTextBufferManager)
        {
            this.workspaceService = workspaceService;
            var middleLayer = new MiddleLayerHost();

            MiddleLayer = middleLayerHost = middleLayer;

            TrackTsJsUpdate(tsJsTextBufferManager);
        }
Example #11
0
        public PythonWorkspaceContextProvider(
            [Import] IVsFolderWorkspaceService workspaceService,
            [Import] Lazy <IInterpreterOptionsService> optionsService,
            [Import] Lazy <IInterpreterRegistryService> registryService
            )
        {
            // Don't use registry service from the constructor, since that imports
            // all the factory providers, which may import IPythonWorkspaceContextProvider
            // (ie circular dependency).
            _workspaceService = workspaceService;
            _optionsService   = optionsService;
            _registryService  = registryService;

            _workspaceService.OnActiveWorkspaceChanged += OnActiveWorkspaceChanged;
        }
        public PackageJsonTestContainerDiscoverer(IVsFolderWorkspaceService workspaceService)
        {
            this.workspaceService = workspaceService;
            this.workspaceService.OnActiveWorkspaceChanged += this.OnActiveWorkspaceChangedAsync;

            if (this.workspaceService.CurrentWorkspace != null)
            {
                this.activeWorkspace = this.workspaceService.CurrentWorkspace;
                this.RegisterEvents();

                this.activeWorkspace.JTF.RunAsync(async() =>
                {
                    // Yield so we don't do this now. Don't want to block the constructor.
                    await Task.Yield();

                    // See if we have an update
                    await AttemptUpdateAsync();
                });
            }
        }
Example #13
0
        public Listener(StreamJsonRpc.JsonRpc rpc, IVsFolderWorkspaceService workspaceService, IServiceProvider site)
        {
            this._rpc = rpc;
            this._rpc.Disconnected += _rpc_Disconnected;

            // Ignore some common directories
            _matcher.AddExclude("**/.vs/**/*.*");

            // Ignore files that end with ~ or TMP
            _matcher.AddExclude("**/*~");
            _matcher.AddExclude("**/*TMP");

            // Depending upon if this is a workspace or a solution, listen to different change events.
            if (workspaceService != null && workspaceService.CurrentWorkspace != null)
            {
                workspaceService.CurrentWorkspace.GetService <IFileWatcherService>().OnFileSystemChanged += OnFileChanged;
                _root = workspaceService.CurrentWorkspace.Location;
            }
            else
            {
                var path = GetSolutionDirectory(site);
                if (path != null)
                {
                    _solutionWatcher      = new System.IO.FileSystemWatcher();
                    _solutionWatcher.Path = path;
                    _solutionWatcher.IncludeSubdirectories = true;
                    _solutionWatcher.NotifyFilter          =
                        NotifyFilters.LastWrite | NotifyFilters.CreationTime |
                        NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.Size;
                    _solutionWatcher.Changed            += OnFileChanged_Sync;
                    _solutionWatcher.Created            += OnFileChanged_Sync;
                    _solutionWatcher.Deleted            += OnFileChanged_Sync;
                    _solutionWatcher.Renamed            += OnFileChanged_Sync;
                    _solutionWatcher.EnableRaisingEvents = true;
                    _root = _solutionWatcher.Path;
                }
            }
        }
 public JsFileDebugLaunchTargetProvider(SVsServiceProvider serviceProvider, IVsFolderWorkspaceService workspaceService)
     : base(serviceProvider, workspaceService)
 {
 }
 public RustLanguageExtension([Import] IVsFolderWorkspaceService workspaceService, [Import(typeof(SAsyncServiceProvider))] IAsyncServiceProvider serviceProvider, [Import] OptionsModel optionsModel)
 {
     this.workspaceService = workspaceService;
     this.serviceProvider  = serviceProvider;
     this.optionsModel     = optionsModel;
 }
Example #16
0
 protected LaunchDebugTargetProvider(SVsServiceProvider serviceProvider, IVsFolderWorkspaceService workspaceService)
 {
     this.ServiceProvider  = serviceProvider;
     this.WorkspaceService = workspaceService;
 }
 public OpenFolderTracker(IVsFolderWorkspaceService vsFolderWorkspaceService)
 {
     _vsFolderWorkspaceService = vsFolderWorkspaceService;
 }