зеркало из https://github.com/dotnet/razor.git
Remove unused ISnapshotResolver methods
This commit is contained in:
Родитель
652e3fa96c
Коммит
b4d110ddcd
|
@ -12,13 +12,6 @@ namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
|
|||
|
||||
internal interface ISnapshotResolver
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds all the projects where the document path starts with the path of the folder that contains the project file.
|
||||
/// </summary>
|
||||
ImmutableArray<IProjectSnapshot> FindPotentialProjects(string documentFilePath);
|
||||
|
||||
IProjectSnapshot GetMiscellaneousProject();
|
||||
|
||||
/// <summary>
|
||||
/// Finds a <see cref="IDocumentSnapshot"/> for the given document path that is contained within any project, and returns the first
|
||||
/// one found if it does. This method should be avoided where possible, and the overload that takes a <see cref="ProjectKey"/> should be used instead
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the MIT license. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Razor.PooledObjects;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
|
||||
namespace Microsoft.AspNetCore.Razor.LanguageServer.ProjectSystem;
|
||||
|
||||
internal static class ISnapshotResolverExtensions
|
||||
{
|
||||
public static bool TryResolveAllProjects(
|
||||
this ISnapshotResolver snapshotResolver,
|
||||
string documentFilePath,
|
||||
out ImmutableArray<IProjectSnapshot> projects)
|
||||
{
|
||||
var potentialProjects = snapshotResolver.FindPotentialProjects(documentFilePath);
|
||||
|
||||
using var builder = new PooledArrayBuilder<IProjectSnapshot>(capacity: potentialProjects.Length);
|
||||
|
||||
foreach (var project in potentialProjects)
|
||||
{
|
||||
if (project.GetDocument(documentFilePath) is not null)
|
||||
{
|
||||
builder.Add(project);
|
||||
}
|
||||
}
|
||||
|
||||
var normalizedDocumentPath = FilePathNormalizer.Normalize(documentFilePath);
|
||||
var miscProject = snapshotResolver.GetMiscellaneousProject();
|
||||
if (miscProject.GetDocument(normalizedDocumentPath) is not null)
|
||||
{
|
||||
builder.Add(miscProject);
|
||||
}
|
||||
|
||||
projects = builder.DrainToImmutable();
|
||||
return projects.Length > 0;
|
||||
}
|
||||
}
|
|
@ -22,36 +22,6 @@ internal sealed class SnapshotResolver(IProjectSnapshotManager projectManager, I
|
|||
private readonly IProjectSnapshotManager _projectManager = projectManager;
|
||||
private readonly ILogger _logger = loggerFactory.GetOrCreateLogger<SnapshotResolver>();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ImmutableArray<IProjectSnapshot> FindPotentialProjects(string documentFilePath)
|
||||
{
|
||||
var normalizedDocumentPath = FilePathNormalizer.Normalize(documentFilePath);
|
||||
|
||||
using var projects = new PooledArrayBuilder<IProjectSnapshot>();
|
||||
|
||||
foreach (var project in _projectManager.GetProjects())
|
||||
{
|
||||
// Always exclude the miscellaneous project.
|
||||
if (project.FilePath == MiscFilesHostProject.Instance.FilePath)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var projectDirectory = FilePathNormalizer.GetNormalizedDirectoryName(project.FilePath);
|
||||
if (normalizedDocumentPath.StartsWith(projectDirectory, FilePathComparison.Instance))
|
||||
{
|
||||
projects.Add(project);
|
||||
}
|
||||
}
|
||||
|
||||
return projects.DrainToImmutable();
|
||||
}
|
||||
|
||||
public IProjectSnapshot GetMiscellaneousProject()
|
||||
{
|
||||
return _projectManager.GetLoadedProject(MiscFilesHostProject.Instance.Key);
|
||||
}
|
||||
|
||||
public bool TryResolveDocumentInAnyProject(string documentFilePath, [NotNullWhen(true)] out IDocumentSnapshot? document)
|
||||
{
|
||||
_logger.LogTrace($"Looking for {documentFilePath}.");
|
||||
|
|
|
@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Razor.Test.Common.LanguageServer;
|
|||
using Microsoft.AspNetCore.Razor.Test.Common.ProjectSystem;
|
||||
using Microsoft.AspNetCore.Razor.Utilities;
|
||||
using Microsoft.CodeAnalysis.Razor.ProjectSystem;
|
||||
using Microsoft.VisualStudio.Copilot;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
@ -190,12 +189,6 @@ public class DocumentContextFactoryTest : LanguageServerTestBase
|
|||
{
|
||||
private readonly IDocumentSnapshot? _documentSnapshot = documentSnapshot;
|
||||
|
||||
public ImmutableArray<IProjectSnapshot> FindPotentialProjects(string documentFilePath)
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public IProjectSnapshot GetMiscellaneousProject()
|
||||
=> throw new NotImplementedException();
|
||||
|
||||
public bool TryResolveDocumentInAnyProject(string documentFilePath, [NotNullWhen(true)] out IDocumentSnapshot? document)
|
||||
{
|
||||
if (documentFilePath == _documentSnapshot?.FilePath)
|
||||
|
|
Загрузка…
Ссылка в новой задаче