提交 606da763 编写于 作者: J Jason Malinowski

Delete IVisualStudioHostProject[Container]

We now only have one implementation of these interfaces, so let's just
state the underlying types directly. The system is still just as
coupled as it is before, but this will make it easier to find dead
code.
上级 a24b2378
......@@ -33,7 +33,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
using Workspace = Microsoft.CodeAnalysis.Workspace;
// NOTE: Microsoft.VisualStudio.LanguageServices.TypeScript.TypeScriptProject derives from AbstractProject.
internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObject, IVisualStudioHostProject
internal abstract partial class AbstractProject : ForegroundThreadAffinitizedObject
{
internal static object RuleSetErrorId = new object();
private readonly object _gate = new object();
......
......@@ -16,13 +16,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
/// </summary>
internal class DocumentKey : IEquatable<DocumentKey>
{
private readonly IVisualStudioHostProject _hostProject;
private readonly AbstractProject _hostProject;
private readonly string _moniker;
public IVisualStudioHostProject HostProject { get { return _hostProject; } }
public AbstractProject HostProject { get { return _hostProject; } }
public string Moniker { get { return _moniker; } }
public DocumentKey(IVisualStudioHostProject hostProject, string moniker)
public DocumentKey(AbstractProject hostProject, string moniker)
{
Contract.ThrowIfNull(hostProject);
Contract.ThrowIfNull(moniker);
......
......@@ -37,7 +37,7 @@ private class StandardTextDocument : ForegroundThreadAffinitizedObject, IVisualS
public DocumentId Id { get; }
public IReadOnlyList<string> Folders { get; }
public IVisualStudioHostProject Project { get; }
public AbstractProject Project { get; }
public SourceCodeKind SourceCodeKind { get; }
public DocumentKey Key { get; }
......@@ -51,7 +51,7 @@ private class StandardTextDocument : ForegroundThreadAffinitizedObject, IVisualS
/// </summary>
public StandardTextDocument(
DocumentProvider documentProvider,
IVisualStudioHostProject project,
AbstractProject project,
DocumentKey documentKey,
Func<uint, IReadOnlyList<string>> getFolderNames,
SourceCodeKind sourceCodeKind,
......
......@@ -30,7 +30,7 @@ internal sealed partial class DocumentProvider : ForegroundThreadAffinitizedObje
#region Immutable readonly fields/properties that can be accessed from foreground or background threads - do not need locking for access.
private readonly object _gate = new object();
private readonly uint _runningDocumentTableEventCookie;
private readonly IVisualStudioHostProjectContainer _projectContainer;
private readonly VisualStudioProjectTracker _projectTracker;
private readonly IVsFileChangeEx _fileChangeService;
private readonly IVsTextManager _textManager;
private readonly IVsRunningDocumentTable4 _runningDocumentTable;
......@@ -53,17 +53,16 @@ internal sealed partial class DocumentProvider : ForegroundThreadAffinitizedObje
/// <summary>
/// Creates a document provider.
/// </summary>
/// <param name="projectContainer">Project container for the documents.</param>
/// <param name="serviceProvider">Service provider</param>
/// <param name="documentTrackingService">An optional <see cref="VisualStudioDocumentTrackingService"/> to track active and visible documents.</param>
public DocumentProvider(
IVisualStudioHostProjectContainer projectContainer,
VisualStudioProjectTracker projectTracker,
IServiceProvider serviceProvider,
VisualStudioDocumentTrackingService documentTrackingService)
{
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
_projectContainer = projectContainer;
_projectTracker = projectTracker;
this._documentTrackingServiceOpt = documentTrackingService;
this._runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));
this._editorAdaptersFactoryService = componentModel.GetService<IVsEditorAdaptersFactoryService>();
......@@ -91,7 +90,7 @@ internal sealed partial class DocumentProvider : ForegroundThreadAffinitizedObje
/// whenever <see cref="NotifyDocumentRegisteredToProjectAndStartToRaiseEvents"/> is invoked for the returned document.
/// </summary>
public IVisualStudioHostDocument TryGetDocumentForFile(
IVisualStudioHostProject hostProject,
AbstractProject hostProject,
string filePath,
SourceCodeKind sourceCodeKind,
Func<ITextBuffer, bool> canUseTextBuffer,
......@@ -331,7 +330,7 @@ private void TryProcessOpenForDocCookie_NoLock(uint docCookie)
if (_runningDocumentTable.GetDocumentData(docCookie) is IVsTextBuffer shimTextBuffer)
{
var hasAssociatedRoslynDocument = false;
foreach (var project in _projectContainer.GetProjects())
foreach (var project in _projectTracker.ImmutableProjects)
{
var documentKey = new DocumentKey(project, moniker);
......@@ -388,11 +387,11 @@ private void TryProcessOpenForDocCookie_NoLock(uint docCookie)
{
// This is opening some other designer or property page. If it's tied to our IVsHierarchy, we should
// let the workspace know
foreach (var project in _projectContainer.GetProjects())
foreach (var project in _projectTracker.ImmutableProjects)
{
if (hierarchy == project.Hierarchy)
{
_projectContainer.NotifyNonDocumentOpenedForProject(project);
_projectTracker.NotifyNonDocumentOpenedForProject(project);
}
}
}
......
......@@ -22,7 +22,7 @@ internal interface IVisualStudioHostDocument : IDisposable
/// <summary>
/// The visual studio project this document is part of.
/// </summary>
IVisualStudioHostProject Project { get; }
AbstractProject Project { get; }
/// <summary>
/// The Visual Studio identity of the document within its project.
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.Shell.Interop;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
/// <summary>
/// The interface implemented by all types of projects within Visual Studio (like regular
/// projects, Miscellaneous files projects, etc.)
/// </summary>
internal interface IVisualStudioHostProject
{
ProjectId Id { get; }
string Language { get; }
/// <summary>
/// The <see cref="IVsHierarchy"/> for this project. NOTE: May be null in Deferred Project Load cases.
/// </summary>
IVsHierarchy Hierarchy { get; }
Guid Guid { get; }
Microsoft.CodeAnalysis.Workspace Workspace { get; }
/// <summary>
/// The public display name of the project. This name is not unique and may be shared
/// between multiple projects, especially in cases like Venus where the intellisense
/// projects will match the name of their logical parent project.
/// </summary>
string DisplayName { get; }
/// <summary>
/// The name of the project according to the project system. In "regular" projects this is
/// equivalent to <see cref="DisplayName"/>, but in Venus cases these will differ. The
/// ProjectSystemName is the 2_Default.aspx project name, whereas the regular display name
/// matches the display name of the project the user actually sees in the solution explorer.
/// These can be assumed to be unique within the Visual Studio workspace.
/// </summary>
string ProjectSystemName { get; }
IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id);
IVisualStudioHostDocument GetCurrentDocumentFromPath(string filePath);
ProjectInfo CreateProjectInfoForCurrentState();
bool ContainsFile(string moniker);
}
}
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
/// <summary>
/// An interface implemented by a workspace to get the set of host projects contained in the
/// workspace.
/// </summary>
internal interface IVisualStudioHostProjectContainer
{
IReadOnlyList<IVisualStudioHostProject> GetProjects();
void NotifyNonDocumentOpenedForProject(IVisualStudioHostProject project);
}
}
......@@ -35,7 +35,7 @@ internal partial class InvisibleEditor : IInvisibleEditor
/// <see cref="IVsUIShellOpenDocument4.IsDocumentInAProject2"/>, which performs a much slower query of all
/// projects in the solution.</para>
/// </remarks>
public InvisibleEditor(IServiceProvider serviceProvider, string filePath, IVisualStudioHostProject projectOpt, bool needsSave, bool needsUndoDisabled)
public InvisibleEditor(IServiceProvider serviceProvider, string filePath, AbstractProject projectOpt, bool needsSave, bool needsUndoDisabled)
{
_serviceProvider = serviceProvider;
_filePath = filePath;
......
......@@ -118,23 +118,23 @@ private IVsHierarchy GetSharedHierarchyForItemInternal(IVsHierarchy headProjectH
: null;
}
public static IVisualStudioHostProject GetContextHostProject(IVsHierarchy sharedHierarchy, IVisualStudioHostProjectContainer hostProjectContainer)
public static AbstractProject GetContextHostProject(IVsHierarchy sharedHierarchy, VisualStudioProjectTracker projectTracker)
{
return s_singleton.GetContextHostProjectInternal(sharedHierarchy, hostProjectContainer);
return s_singleton.GetContextHostProjectInternal(sharedHierarchy, projectTracker);
}
private IVisualStudioHostProject GetContextHostProjectInternal(IVsHierarchy hierarchy, IVisualStudioHostProjectContainer hostProjectContainer)
private AbstractProject GetContextHostProjectInternal(IVsHierarchy hierarchy, VisualStudioProjectTracker projectTracker)
{
hierarchy = GetSharedItemContextHierarchy(hierarchy) ?? hierarchy;
var projectName = GetActiveIntellisenseProjectContextInternal(hierarchy);
if (projectName != null)
{
return hostProjectContainer.GetProjects().FirstOrDefault(p => p.ProjectSystemName == projectName);
return projectTracker.ImmutableProjects.FirstOrDefault(p => p.ProjectSystemName == projectName);
}
else
{
return hostProjectContainer.GetProjects().FirstOrDefault(p => p.Hierarchy == hierarchy);
return projectTracker.ImmutableProjects.FirstOrDefault(p => p.Hierarchy == hierarchy);
}
}
......
......@@ -12,7 +12,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
internal sealed partial class VisualStudioMetadataReference : IDisposable
{
private readonly VisualStudioMetadataReferenceManager _provider;
private readonly IVisualStudioHostProject _hostProject;
private readonly AbstractProject _hostProject;
private readonly MetadataReferenceProperties _properties;
private readonly FileChangeTracker _fileChangeTracker;
......@@ -22,7 +22,7 @@ internal sealed partial class VisualStudioMetadataReference : IDisposable
public VisualStudioMetadataReference(
VisualStudioMetadataReferenceManager provider,
IVisualStudioHostProject hostProject,
AbstractProject hostProject,
string filePath,
MetadataReferenceProperties properties)
{
......@@ -44,7 +44,7 @@ public string FilePath
get { return _fileChangeTracker.FilePath; }
}
public IVisualStudioHostProject Project
public AbstractProject Project
{
get { return _hostProject; }
}
......
......@@ -86,7 +86,7 @@ public PortableExecutableReference CreateMetadataReferenceSnapshot(string filePa
return new VisualStudioMetadataReference.Snapshot(this, properties, filePath);
}
public VisualStudioMetadataReference CreateMetadataReference(IVisualStudioHostProject hostProject, string filePath, MetadataReferenceProperties properties)
public VisualStudioMetadataReference CreateMetadataReference(AbstractProject hostProject, string filePath, MetadataReferenceProperties properties)
{
return new VisualStudioMetadataReference(this, hostProject, filePath, properties);
}
......
......@@ -17,7 +17,7 @@
namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
{
internal sealed partial class VisualStudioProjectTracker : ForegroundThreadAffinitizedObject, IVisualStudioHostProjectContainer
internal sealed partial class VisualStudioProjectTracker : ForegroundThreadAffinitizedObject
{
#region Readonly fields
private static readonly ConditionalWeakTable<SolutionId, string> s_workingFolderPathMap = new ConditionalWeakTable<SolutionId, string>();
......@@ -92,9 +92,7 @@ internal ImmutableArray<AbstractProject> ImmutableProjects
internal HostWorkspaceServices WorkspaceServices { get; }
IReadOnlyList<IVisualStudioHostProject> IVisualStudioHostProjectContainer.GetProjects() => this.ImmutableProjects;
void IVisualStudioHostProjectContainer.NotifyNonDocumentOpenedForProject(IVisualStudioHostProject project)
internal void NotifyNonDocumentOpenedForProject(AbstractProject project)
{
AssertIsForeground();
......
......@@ -108,12 +108,12 @@ internal IVisualStudioHostDocument GetHostDocument(DocumentId documentId)
return null;
}
internal IVisualStudioHostProject GetHostProject(ProjectId projectId)
internal AbstractProject GetHostProject(ProjectId projectId)
{
return DeferredState?.ProjectTracker.GetProject(projectId);
}
private bool TryGetHostProject(ProjectId projectId, out IVisualStudioHostProject project)
private bool TryGetHostProject(ProjectId projectId, out AbstractProject project)
{
project = GetHostProject(projectId);
return project != null;
......@@ -241,7 +241,7 @@ public override bool CanApplyChange(ApplyChangesKind feature)
}
}
private bool TryGetProjectData(ProjectId projectId, out IVisualStudioHostProject hostProject, out IVsHierarchy hierarchy, out EnvDTE.Project project)
private bool TryGetProjectData(ProjectId projectId, out AbstractProject hostProject, out IVsHierarchy hierarchy, out EnvDTE.Project project)
{
hierarchy = null;
project = null;
......@@ -251,7 +251,7 @@ private bool TryGetProjectData(ProjectId projectId, out IVisualStudioHostProject
&& hierarchy.TryGetProject(out project);
}
internal void GetProjectData(ProjectId projectId, out IVisualStudioHostProject hostProject, out IVsHierarchy hierarchy, out EnvDTE.Project project)
internal void GetProjectData(ProjectId projectId, out AbstractProject hostProject, out IVsHierarchy hierarchy, out EnvDTE.Project project)
{
if (!TryGetProjectData(projectId, out hostProject, out hierarchy, out project))
{
......@@ -622,7 +622,7 @@ protected override void AddExistingDocument(DocumentId documentId, string filePa
#endif
private ProjectItem AddDocumentToProject(
IVisualStudioHostProject hostProject,
AbstractProject hostProject,
EnvDTE.Project project,
DocumentId documentId,
string documentName,
......@@ -641,7 +641,7 @@ protected override void AddExistingDocument(DocumentId documentId, string filePa
}
private ProjectItem AddDocumentToFolder(
IVisualStudioHostProject hostProject,
AbstractProject hostProject,
EnvDTE.Project project,
DocumentId documentId,
IEnumerable<string> folders,
......@@ -662,7 +662,7 @@ protected override void AddExistingDocument(DocumentId documentId, string filePa
}
private ProjectItem AddDocumentToProjectItems(
IVisualStudioHostProject hostProject,
AbstractProject hostProject,
ProjectItems projectItems,
DocumentId documentId,
string folderPath,
......@@ -865,7 +865,7 @@ protected override void ApplyAdditionalDocumentTextChanged(DocumentId documentId
hostDocument.UpdateText(newText);
}
private static string GetPreferredExtension(IVisualStudioHostProject hostProject, SourceCodeKind sourceCodeKind)
private static string GetPreferredExtension(AbstractProject hostProject, SourceCodeKind sourceCodeKind)
{
// No extension was provided. Pick a good one based on the type of host project.
switch (hostProject.Language)
......
......@@ -181,8 +181,6 @@ public bool IsOpen
#pragma warning restore 67
IVisualStudioHostProject IVisualStudioHostDocument.Project { get { return this.Project; } }
public ITextBuffer GetOpenTextBuffer()
{
return _containedLanguage.SubjectBuffer;
......
......@@ -19,7 +19,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim
Partial Friend MustInherit Class VisualBasicProject
Inherits AbstractLegacyProject
Implements IVbCompilerProject
Implements IVisualStudioHostProject
Private ReadOnly _compilerHost As IVbCompilerHost
Private ReadOnly _imports As New List(Of GlobalImport)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册