提交 5c9bbef2 编写于 作者: J Jason Malinowski

Reduce down to just one property that gives the workspace

AbstractProject had two properties: Workspace and VisualStudioWorkspace
which was very, very confusing. We reduce down to one, and the few
places that needed the derived types
上级 9239b08d
......@@ -174,7 +174,7 @@ public int GetValidStartupClasses(IntPtr[] classNames, ref int count)
{
// If classNames is NULL, then we need to populate the number of valid startup
// classes only
var project = VisualStudioWorkspace.CurrentSolution.GetProject(Id);
var project = Workspace.CurrentSolution.GetProject(Id);
var compilation = project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
var entryPoints = GetEntryPoints(project, compilation);
......
......@@ -15,7 +15,7 @@ public AbstractProjectCodeModel ProjectCodeModel
{
if (_projectCodeModel == null)
{
_projectCodeModel = new CSharpProjectCodeModel(this, this.VisualStudioWorkspace, ServiceProvider);
_projectCodeModel = new CSharpProjectCodeModel(this, (VisualStudioWorkspace)this.Workspace, ServiceProvider);
}
return _projectCodeModel;
......
......@@ -102,9 +102,9 @@ internal VsENCRebuildableProjectImpl(AbstractProject project)
{
_vsProject = project;
_encService = _vsProject.VisualStudioWorkspace.Services.GetService<IEditAndContinueWorkspaceService>();
_trackingService = _vsProject.VisualStudioWorkspace.Services.GetService<IActiveStatementTrackingService>();
_notifications = _vsProject.VisualStudioWorkspace.Services.GetService<INotificationService>();
_encService = _vsProject.Workspace.Services.GetService<IEditAndContinueWorkspaceService>();
_trackingService = _vsProject.Workspace.Services.GetService<IActiveStatementTrackingService>();
_notifications = _vsProject.Workspace.Services.GetService<INotificationService>();
_debugEncNotify = (IDebugEncNotify)project.ServiceProvider.GetService(typeof(ShellInterop.SVsShellDebugger));
......@@ -143,11 +143,11 @@ internal bool OnEdit(DocumentId documentId)
return;
}
var hostProject = _vsProject.VisualStudioWorkspace.GetHostProject(documentId.ProjectId) as AbstractRoslynProject;
var visualStudioWorkspace = _vsProject.Workspace as VisualStudioWorkspaceImpl;
var hostProject = visualStudioWorkspace?.GetHostProject(documentId.ProjectId) as AbstractRoslynProject;
if (hostProject?.EditAndContinueImplOpt?._metadata != null)
{
var projectHierarchy = _vsProject.VisualStudioWorkspace.GetHierarchy(documentId.ProjectId);
_debugEncNotify.NotifyEncEditDisallowedByProject(projectHierarchy);
_debugEncNotify.NotifyEncEditDisallowedByProject(hostProject.Hierarchy);
return;
}
......@@ -219,7 +219,7 @@ public int StartDebuggingPE()
_encService.OnBeforeDebuggingStateChanged(DebuggingState.Design, DebuggingState.Run);
_encService.StartDebuggingSession(_vsProject.VisualStudioWorkspace.CurrentSolution);
_encService.StartDebuggingSession(_vsProject.Workspace.CurrentSolution);
s_encDebuggingSessionInfo = new EncDebuggingSessionInfo();
s_readOnlyDocumentTracker = new VsReadOnlyDocumentTracker(_encService, _editorAdaptersFactoryService, _vsProject);
......@@ -322,7 +322,7 @@ public int StopDebuggingPE()
else
{
// an error might have been reported:
_diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.DebuggerErrorId, _vsProject.Id, documentId: null);
_diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.Workspace, EditAndContinueDiagnosticUpdateSource.DebuggerErrorId, _vsProject.Id, documentId: null);
}
_activeMethods = null;
......@@ -436,7 +436,7 @@ public int EnterBreakStateOnPE(Interop.ENC_BREAKSTATE_REASON encBreakReason, She
{
_encService.OnBeforeDebuggingStateChanged(DebuggingState.Run, DebuggingState.Break);
s_breakStateEntrySolution = _vsProject.VisualStudioWorkspace.CurrentSolution;
s_breakStateEntrySolution = _vsProject.Workspace.CurrentSolution;
// TODO: This is a workaround for a debugger bug in which not all projects exit the break state.
// Reset the project count.
......@@ -730,7 +730,7 @@ public int GetCurrentActiveStatementPosition(uint vsId, VsTextSpan[] ptsNewPosit
return VSConstants.E_FAIL;
}
Document document = _vsProject.VisualStudioWorkspace.CurrentSolution.GetDocument(id.DocumentId);
Document document = _vsProject.Workspace.CurrentSolution.GetDocument(id.DocumentId);
SourceText text = document.GetTextAsync(default(CancellationToken)).Result;
// Try to get spans from the tracking service first.
......@@ -801,7 +801,7 @@ public int GetENCBuildState(ShellInterop.ENC_BUILD_STATE[] pENCBuildState)
{
// Fetch the latest snapshot of the project and get an analysis summary for any changes
// made since the break mode was entered.
var currentProject = _vsProject.VisualStudioWorkspace.CurrentSolution.GetProject(_vsProject.Id);
var currentProject = _vsProject.Workspace.CurrentSolution.GetProject(_vsProject.Id);
if (currentProject == null)
{
// If the project has yet to be loaded into the solution (which may be the case,
......@@ -908,7 +908,7 @@ public int ExitBreakStateOnPE()
Debug.Assert(s_breakStateProjectCount >= 0);
_changesApplied = false;
_diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError);
_diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.Workspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError);
_documentsWithEmitError = default(ImmutableArray<DocumentId>);
}
......@@ -972,7 +972,7 @@ public unsafe int BuildForEnc(object pUpdatePE)
}
// Clear diagnostics, in case the project was built before and failed due to errors.
_diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError);
_diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.Workspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError);
if (!delta.EmitResult.Success)
{
......
......@@ -104,7 +104,8 @@ private bool AllowsReadOnly(DocumentId documentId)
// while the code is running and get refreshed next time the web page is hit.
// Note that Razor-like views are modelled as a ContainedDocument but normal code including code-behind are modelled as a StandardTextDocument.
var containedDocument = _vsProject.VisualStudioWorkspace.GetHostDocument(documentId) as ContainedDocument;
var visualStudioWorkspace = _vsProject.Workspace as VisualStudioWorkspaceImpl;
var containedDocument = visualStudioWorkspace?.GetHostDocument(documentId) as ContainedDocument;
return containedDocument == null;
}
......
......@@ -229,8 +229,6 @@ private static bool TryGetProjectDisplayName(IVsHierarchy hierarchy, out string
/// </summary>
internal string TryGetBinOutputPath() => _binOutputPathOpt;
internal VisualStudioWorkspaceImpl VisualStudioWorkspace => _visualStudioWorkspaceOpt;
internal IRuleSetFile RuleSetFile => this.ruleSet;
internal HostDiagnosticUpdateSource HostDiagnosticUpdateSource => _hostDiagnosticUpdateSourceOpt;
......
......@@ -233,7 +233,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim
Public Sub GetEntryPointsList(cItems As Integer, strList() As String, ByVal pcActualItems As IntPtr) Implements IVbCompilerProject.GetEntryPointsList
Try
Dim project = VisualStudioWorkspace.CurrentSolution.GetProject(Id)
Dim project = Workspace.CurrentSolution.GetProject(Id)
Dim compilation = project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None)
GetEntryPointsWorker(cItems, strList, pcActualItems, findFormsOnly:=False)
......@@ -246,7 +246,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim
strList() As String,
ByVal pcActualItems As IntPtr,
findFormsOnly As Boolean)
Dim project = VisualStudioWorkspace.CurrentSolution.GetProject(Id)
Dim project = Workspace.CurrentSolution.GetProject(Id)
Dim compilation = project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None)
' If called with cItems = 0 and pcActualItems != NULL, GetEntryPointsList returns in pcActualItems the number of items available.
......
......@@ -10,7 +10,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim
Public ReadOnly Property ProjectCodeModel As AbstractProjectCodeModel Implements IProjectCodeModelProvider.ProjectCodeModel
Get
LazyInitialization.EnsureInitialized(_projectCodeModel, Function() New VisualBasicProjectCodeModel(Me, Me.VisualStudioWorkspace, ServiceProvider))
LazyInitialization.EnsureInitialized(_projectCodeModel, Function() New VisualBasicProjectCodeModel(Me, DirectCast(Me.Workspace, VisualStudioWorkspace), ServiceProvider))
Return _projectCodeModel
End Get
End Property
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册