Exemplo n.º 1
0
        internal CodeModelProjectCache GetCodeModelCache()
        {
            Contract.ThrowIfNull(_vsProject);
            Contract.ThrowIfNull(_visualStudioWorkspace);

            using (_guard.DisposableWait())
            {
                if (_codeModelCache == null)
                {
                    var project = _visualStudioWorkspace.CurrentSolution.GetProject(_vsProject.Id);
                    if (project == null && !_vsProject.PushingChangesToWorkspaceHosts)
                    {
                        // if this project hasn't been pushed yet, push it now so that the user gets a useful experience here.
                        _vsProject.StartPushingToWorkspaceAndNotifyOfOpenDocuments();

                        // re-check to see whether we now has the project in the workspace
                        project = _visualStudioWorkspace.CurrentSolution.GetProject(_vsProject.Id);
                    }

                    if (project != null)
                    {
                        _codeModelCache = new CodeModelProjectCache(_vsProject, _serviceProvider, project.LanguageServices, _visualStudioWorkspace);
                    }
                }

                return(_codeModelCache);
            }
        }
Exemplo n.º 2
0
        private CodeModelProjectCache GetCodeModelCache()
        {
            Contract.ThrowIfNull(_projectId);
            Contract.ThrowIfNull(_visualStudioWorkspace);

            using (_guard.DisposableWait())
            {
                if (_codeModelCache == null)
                {
                    var workspaceProject = _visualStudioWorkspace.CurrentSolution.GetProject(_projectId);
                    var hostProject      = _visualStudioWorkspace.GetHostProject(_projectId);
                    if (workspaceProject == null && !hostProject.PushingChangesToWorkspace)
                    {
                        // if this project hasn't been pushed yet, push it now so that the user gets a useful experience here.
                        hostProject.StartPushingToWorkspaceAndNotifyOfOpenDocuments();

                        // re-check to see whether we now has the project in the workspace
                        workspaceProject = _visualStudioWorkspace.CurrentSolution.GetProject(_projectId);
                    }

                    if (workspaceProject != null)
                    {
                        _codeModelCache = new CodeModelProjectCache(_threadingContext, _projectId, _codeModelInstanceFactory, _serviceProvider, workspaceProject.LanguageServices, _visualStudioWorkspace);
                    }
                }

                return(_codeModelCache);
            }
        }
Exemplo n.º 3
0
        internal CodeModelProjectCache GetCodeModelCache()
        {
            Contract.ThrowIfNull(VSProject);
            Contract.ThrowIfNull(VisualStudioWorkspace);

            using (_guard.DisposableWait())
            {
                if (_codeModelCache == null)
                {
                    var project = VisualStudioWorkspace.CurrentSolution.GetProject(VSProject.Id);
                    if (project == null && !VSProject.PushingChangesToWorkspaceHosts)
                    {
                        // if this project hasn't been pushed yet, push it now so that the user gets a useful experience here.
                        VSProject.StartPushingToWorkspaceAndNotifyOfOpenDocuments();

                        // re-check to see whether we now has the project in the workspace
                        project = VisualStudioWorkspace.CurrentSolution.GetProject(VSProject.Id);
                    }

                    if (project != null)
                    {
                        _codeModelCache = new CodeModelProjectCache(VSProject, ServiceProvider, project.LanguageServices, VisualStudioWorkspace);
                    }
                }

                return _codeModelCache;
            }
        }
Exemplo n.º 4
0
        private CodeModelProjectCache GetCodeModelCache()
        {
            Contract.ThrowIfNull(_projectId);
            Contract.ThrowIfNull(_visualStudioWorkspace);

            using (_guard.DisposableWait())
            {
                if (_codeModelCache == null)
                {
                    var workspaceProject = _visualStudioWorkspace.CurrentSolution.GetProject(
                        _projectId
                        );

                    if (workspaceProject != null)
                    {
                        _codeModelCache = new CodeModelProjectCache(
                            _threadingContext,
                            _projectId,
                            _codeModelInstanceFactory,
                            _projectCodeModelFactory,
                            _serviceProvider,
                            workspaceProject.LanguageServices,
                            _visualStudioWorkspace
                            );
                    }
                }

                return(_codeModelCache);
            }
        }