diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs index ae810cd8c3caa65099a9f31b1727094db2d2a7d8..148abcc1d9b62d6434c71007f92e57ca46f69f9f 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs @@ -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(); diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentKey.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentKey.cs index 24d072107cf2070afb6a5b70f7eb1666054cb5e3..6426d36cbd48af07b46cd096dc9a676c534a3aa4 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentKey.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentKey.cs @@ -16,13 +16,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem /// internal class DocumentKey : IEquatable { - 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); diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.StandardTextDocument.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.StandardTextDocument.cs index e2c13f40d14e727c956423cde0a6b72e9c7af082..9b9580a71415424628ab2e7e1dfd369710104a18 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.StandardTextDocument.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.StandardTextDocument.cs @@ -37,7 +37,7 @@ private class StandardTextDocument : ForegroundThreadAffinitizedObject, IVisualS public DocumentId Id { get; } public IReadOnlyList 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 /// public StandardTextDocument( DocumentProvider documentProvider, - IVisualStudioHostProject project, + AbstractProject project, DocumentKey documentKey, Func> getFolderNames, SourceCodeKind sourceCodeKind, diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.cs index fc06b4d5dbd1250502184034d72a319059ee7b94..215491186c73f94fa189389914ee386a1ec3de0f 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/DocumentProvider.cs @@ -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 /// /// Creates a document provider. /// - /// Project container for the documents. /// Service provider /// An optional to track active and visible documents. 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(); @@ -91,7 +90,7 @@ internal sealed partial class DocumentProvider : ForegroundThreadAffinitizedObje /// whenever is invoked for the returned document. /// public IVisualStudioHostDocument TryGetDocumentForFile( - IVisualStudioHostProject hostProject, + AbstractProject hostProject, string filePath, SourceCodeKind sourceCodeKind, Func 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); } } } diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostDocument.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostDocument.cs index 292838a7e25995fd45914d8976e92749cecce659..7689adb7c402949212a3a333897d1624d53de270 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostDocument.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostDocument.cs @@ -22,7 +22,7 @@ internal interface IVisualStudioHostDocument : IDisposable /// /// The visual studio project this document is part of. /// - IVisualStudioHostProject Project { get; } + AbstractProject Project { get; } /// /// The Visual Studio identity of the document within its project. diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostProject.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostProject.cs deleted file mode 100644 index 34e4f5621f7aaa885e5923616e837797cd0d9b32..0000000000000000000000000000000000000000 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostProject.cs +++ /dev/null @@ -1,49 +0,0 @@ -// 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 -{ - /// - /// The interface implemented by all types of projects within Visual Studio (like regular - /// projects, Miscellaneous files projects, etc.) - /// - internal interface IVisualStudioHostProject - { - ProjectId Id { get; } - string Language { get; } - - /// - /// The for this project. NOTE: May be null in Deferred Project Load cases. - /// - IVsHierarchy Hierarchy { get; } - Guid Guid { get; } - - Microsoft.CodeAnalysis.Workspace Workspace { get; } - - /// - /// 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. - /// - string DisplayName { get; } - - /// - /// The name of the project according to the project system. In "regular" projects this is - /// equivalent to , 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. - /// - string ProjectSystemName { get; } - - IVisualStudioHostDocument GetDocumentOrAdditionalDocument(DocumentId id); - IVisualStudioHostDocument GetCurrentDocumentFromPath(string filePath); - - ProjectInfo CreateProjectInfoForCurrentState(); - - bool ContainsFile(string moniker); - } -} diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostProjectContainer.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostProjectContainer.cs deleted file mode 100644 index ed1b129558a8da5f325ef6be35a7069e43ae5098..0000000000000000000000000000000000000000 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/IVisualStudioHostProjectContainer.cs +++ /dev/null @@ -1,17 +0,0 @@ -// 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 -{ - /// - /// An interface implemented by a workspace to get the set of host projects contained in the - /// workspace. - /// - internal interface IVisualStudioHostProjectContainer - { - IReadOnlyList GetProjects(); - - void NotifyNonDocumentOpenedForProject(IVisualStudioHostProject project); - } -} diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs index 2f4728a5b20fe3b9748251768ee700b6eaf26b9d..deaf7be84b9642c22380c6c78d7bce080b9e42d4 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/InvisibleEditor.cs @@ -35,7 +35,7 @@ internal partial class InvisibleEditor : IInvisibleEditor /// , which performs a much slower query of all /// projects in the solution. /// - 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; diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/LinkedFileUtilities.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/LinkedFileUtilities.cs index 43a024ca2a61966fb10fdb9a71eb43c865bd9c1b..6c72fce22c0f03e31e7b747f8bf516676834d8ec 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/LinkedFileUtilities.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/LinkedFileUtilities.cs @@ -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); } } diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReference.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReference.cs index 77cc71b5445f84a8e1422d1a838e0f21c81615e1..938614550e12c2f6993f38ba5db8ff2805d24aa6 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReference.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReference.cs @@ -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; } } diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs index 4e2e149f4f021e08fdc74e5b3097c01f9bcc7199..a3481278cf5e07f87e2adff343df3684a756dc2c 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/MetadataReferences/VisualStudioMetadataReferenceManager.cs @@ -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); } diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs index 85e3d1130d65b43dab4c5c92288e873b7dc3c844..0fca1b9997faa41c7102635f030199be50a32de9 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioProjectTracker.cs @@ -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 s_workingFolderPathMap = new ConditionalWeakTable(); @@ -92,9 +92,7 @@ internal ImmutableArray ImmutableProjects internal HostWorkspaceServices WorkspaceServices { get; } - IReadOnlyList IVisualStudioHostProjectContainer.GetProjects() => this.ImmutableProjects; - - void IVisualStudioHostProjectContainer.NotifyNonDocumentOpenedForProject(IVisualStudioHostProject project) + internal void NotifyNonDocumentOpenedForProject(AbstractProject project) { AssertIsForeground(); diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs index 471df955dce903adb89bdb183dfffd38ca7a6d02..f08f586d5f20ba8881186c56f8104c4d2fb42dda 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs @@ -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 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) diff --git a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs index af9e9153fe6fd3cdc499ab22d903d7e82b592c73..8dd9bad0ceeb4943061a65c50fb369809201e057 100644 --- a/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs +++ b/src/VisualStudio/Core/Def/Implementation/Venus/ContainedDocument.cs @@ -181,8 +181,6 @@ public bool IsOpen #pragma warning restore 67 - IVisualStudioHostProject IVisualStudioHostDocument.Project { get { return this.Project; } } - public ITextBuffer GetOpenTextBuffer() { return _containedLanguage.SubjectBuffer; diff --git a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb index 2f2c8c42eff3d6b76e2fb31b69868d06ba00dd43..a0c2e56289dff11203b29d3976df53a5ab3dd7e7 100644 --- a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb +++ b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb @@ -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)