提交 afdd7e61 编写于 作者: J Jason Malinowski

Fix up VisualStudioWorkspace.GetFileCodeModel

The implementation was commented out and not restored prior to merging
the project system refactoring.
上级 589b1835
...@@ -29,15 +29,18 @@ namespace Microsoft.VisualStudio.LanguageServices ...@@ -29,15 +29,18 @@ namespace Microsoft.VisualStudio.LanguageServices
internal class RoslynVisualStudioWorkspace : VisualStudioWorkspaceImpl internal class RoslynVisualStudioWorkspace : VisualStudioWorkspaceImpl
{ {
private readonly IEnumerable<Lazy<IStreamingFindUsagesPresenter>> _streamingPresenters; private readonly IEnumerable<Lazy<IStreamingFindUsagesPresenter>> _streamingPresenters;
private readonly Lazy<ProjectCodeModelFactory> _projectCodeModelFactory;
[ImportingConstructor] [ImportingConstructor]
private RoslynVisualStudioWorkspace( private RoslynVisualStudioWorkspace(
ExportProvider exportProvider, ExportProvider exportProvider,
[ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters, [ImportMany] IEnumerable<Lazy<IStreamingFindUsagesPresenter>> streamingPresenters,
[ImportMany] IEnumerable<IDocumentOptionsProviderFactory> documentOptionsProviderFactories) [ImportMany] IEnumerable<IDocumentOptionsProviderFactory> documentOptionsProviderFactories,
Lazy<ProjectCodeModelFactory> projectCodeModelFactory)
: base(exportProvider, AsyncServiceProvider.GlobalProvider) // TODO: switch to the cleaner MEF import : base(exportProvider, AsyncServiceProvider.GlobalProvider) // TODO: switch to the cleaner MEF import
{ {
_streamingPresenters = streamingPresenters; _streamingPresenters = streamingPresenters;
_projectCodeModelFactory = projectCodeModelFactory;
foreach (var providerFactory in documentOptionsProviderFactories) foreach (var providerFactory in documentOptionsProviderFactories)
{ {
...@@ -52,28 +55,21 @@ public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId) ...@@ -52,28 +55,21 @@ public override EnvDTE.FileCodeModel GetFileCodeModel(DocumentId documentId)
throw new ArgumentNullException(nameof(documentId)); throw new ArgumentNullException(nameof(documentId));
} }
/* var project = CurrentSolution.GetProject(documentId.ProjectId);
var project = DeferredState.ProjectTracker.GetProject(documentId.ProjectId);
if (project == null) if (project == null)
{ {
throw new ArgumentException(ServicesVSResources.The_given_DocumentId_did_not_come_from_the_Visual_Studio_workspace, nameof(documentId)); throw new ArgumentException(ServicesVSResources.The_given_DocumentId_did_not_come_from_the_Visual_Studio_workspace, nameof(documentId));
} }
var document = project.GetDocumentOrAdditionalDocument(documentId); var documentFilePath = GetFilePath(documentId);
if (document == null) if (documentFilePath == null)
{ {
throw new ArgumentException(ServicesVSResources.The_given_DocumentId_did_not_come_from_the_Visual_Studio_workspace, nameof(documentId)); throw new ArgumentException(ServicesVSResources.The_given_DocumentId_did_not_come_from_the_Visual_Studio_workspace, nameof(documentId));
} }
if (project.ProjectCodeModel != null) IProjectCodeModel projectCodeModel = _projectCodeModelFactory.Value.GetProjectCodeModel(project.Id);
{
return project.ProjectCodeModel.GetOrCreateFileCodeModel(document.FilePath);
}
*/ return projectCodeModel.GetOrCreateFileCodeModel(documentFilePath);
return null;
} }
internal override IInvisibleEditor OpenInvisibleEditor(DocumentId documentId) internal override IInvisibleEditor OpenInvisibleEditor(DocumentId documentId)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册