Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IDocumentSnapshot.GetImports #9845

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
Expand Down Expand Up @@ -36,11 +35,6 @@ internal class CohostDocumentSnapshot(TextDocument textDocument, IProjectSnapsho

public bool TryGetTextVersion(out VersionStamp result) => _textDocument.TryGetTextVersion(out result);

public ImmutableArray<IDocumentSnapshot> GetImports()
{
return DocumentState.GetImportsCore(Project, FilePath.AssumeNotNull(), FileKind.AssumeNotNull());
}

public async Task<RazorCodeDocument> GetGeneratedOutputAsync()
{
// TODO: We don't need to worry about locking if we get called from the didOpen/didChange LSP requests, as CLaSP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
Expand All @@ -27,9 +26,6 @@ public DocumentSnapshot(ProjectSnapshot project, DocumentState state)
State = state ?? throw new ArgumentNullException(nameof(state));
}

public virtual ImmutableArray<IDocumentSnapshot> GetImports()
=> State.GetImports(ProjectInternal);

public Task<SourceText> GetTextAsync()
=> State.GetTextAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.PooledObjects;
using Microsoft.CodeAnalysis.Text;
Expand Down Expand Up @@ -80,11 +81,6 @@ private ComputedStateTracker ComputedState
return ComputedState.GetGeneratedOutputAndVersionAsync(project, document);
}

public ImmutableArray<IDocumentSnapshot> GetImports(ProjectSnapshot project)
{
return GetImportsCore(project, HostDocument.FilePath, HostDocument.FileKind);
}

public async Task<SourceText> GetTextAsync()
{
if (TryGetText(out var text))
Expand Down Expand Up @@ -502,7 +498,7 @@ private static async Task<RazorSourceDocument> GetRazorSourceDocumentAsync(IDocu

internal static async Task<ImmutableArray<ImportItem>> GetImportsAsync(IDocumentSnapshot document)
{
var imports = document.GetImports();
var imports = DocumentState.GetImportsCore(document.Project, document.FilePath.AssumeNotNull(), document.FileKind.AssumeNotNull());
using var result = new PooledArrayBuilder<ImportItem>(imports.Length);

foreach (var snapshot in imports)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
Expand All @@ -17,8 +16,6 @@ internal interface IDocumentSnapshot
IProjectSnapshot Project { get; }
bool SupportsOutput { get; }

ImmutableArray<IDocumentSnapshot> GetImports();

Task<SourceText> GetTextAsync();
Task<VersionStamp> GetTextVersionAsync();
Task<RazorCodeDocument> GetGeneratedOutputAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading.Tasks;
Expand Down Expand Up @@ -36,9 +35,6 @@ public ImportDocumentSnapshot(IProjectSnapshot project, RazorProjectItem item)
public Task<RazorCodeDocument> GetGeneratedOutputAsync()
=> throw new NotSupportedException();

public ImmutableArray<IDocumentSnapshot> GetImports()
=> ImmutableArray<IDocumentSnapshot>.Empty;

public async Task<SourceText> GetTextAsync()
{
using (var stream = _importItem.Read())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,6 @@ internal static IDocumentSnapshot CreateDocumentSnapshot(string path, ImmutableA
documentSnapshot
.Setup(d => d.GetGeneratedOutputAsync())
.ReturnsAsync(codeDocument);
documentSnapshot
.Setup(d => d.GetImports())
.Returns(imports);
documentSnapshot
.Setup(d => d.FilePath)
.Returns(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public override Task<RazorCodeDocument> GetGeneratedOutputAsync()
return Task.FromResult(_codeDocument);
}

public override ImmutableArray<IDocumentSnapshot> GetImports()
{
return ImmutableArray<IDocumentSnapshot>.Empty;
}

public override bool TryGetGeneratedOutput(out RazorCodeDocument result)
{
if (_codeDocument is null)
Expand Down