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

Refactor and simplify handling of single quotes in module completions #15913

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Expand Up @@ -96,7 +96,7 @@ private async Task<CliResult> Test(Options options)
// compile and publish modules using throwaway file system
var clientFactory = await RegistryHelper.CreateMockRegistryClientWithPublishedModulesAsync(
new MockFileSystem(),
options.PublishedModules.Select(x => (x, "", true)).ToArray());
[.. options.PublishedModules.Select(x => (x, "", true))]);

// create files
var mainFile = FileHelper.SaveResultFile(TestContext, "main.bicep", options.Bicep, testOutputPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ public ImmutableArray<PublicRegistryModuleMetadata> GetModulesMetadata()
{
StartCacheUpdateInBackgroundIfNeeded();

return this.cachedIndex
.Select(x => new PublicRegistryModuleMetadata(x.ModulePath, x.GetDescription(), x.GetDocumentationUri()))
.ToImmutableArray();
return [.. this.cachedIndex.Select(x => new PublicRegistryModuleMetadata(x.ModulePath, x.GetDescription(), x.GetDocumentationUri()))];
}

public ImmutableArray<PublicRegistryModuleVersionMetadata> GetModuleVersionsMetadata(string modulePath)
Expand All @@ -103,9 +101,7 @@ public ImmutableArray<PublicRegistryModuleVersionMetadata> GetModuleVersionsMeta
return [];
}

return entry.Versions
.Select(version => new PublicRegistryModuleVersionMetadata(version, entry.GetDescription(version), entry.GetDocumentationUri(version)))
.ToImmutableArray();
return [.. entry.Versions.Select(version => new PublicRegistryModuleVersionMetadata(version, entry.GetDescription(version), entry.GetDocumentationUri(version)))];
}

private void StartCacheUpdateInBackgroundIfNeeded(bool initialDelay = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ public async Task GetFilteredCompletions_WithInvalidTextInCompletionContext_Retu
[DataRow("module test 'br/public:app/dapr-containerapp:1.0.1|'")]
[DataRow("module test |'br/public:app/dapr-containerapp:1.0.1'")]
[DataRow("module test 'br/public:app/dapr-containerapp:1.0.1'|")]
[DataRow("module test 'br:mcr.microsoft.com/bicep/app/dapr-containerapp:1.0.1|")]
[DataRow("module test 'br:mcr.microsoft.com/bicep/app/dapr-containerapp:1.0.1|'")]
[DataRow("module test |'br:mcr.microsoft.com/bicep/app/dapr-containerapp:1.0.1'")]
[DataRow("module test 'br:mcr.microsoft.com/bicep/app/dapr-containerapp:1.0.1'|")]
[DataRow("module test 'br:contoso.com/app/dapr-containerapp:1.0.1|")]
[DataRow("module test 'br:contoso.com/app/dapr-containerapp:1.0.1|'")]
[DataRow("module test |'br:contoso.com/app/dapr-containerapp:1.0.1'")]
[DataRow("module test 'br:contoso.com/app/dapr-containerapp:1.0.1'|")]
public async Task GetFilteredCompletions_WithInvalidCompletionContext_ReturnsEmptyList(string inputWithCursors)
{
var publicRegistryModuleMetadataProvider = StrictMock.Of<IPublicRegistryModuleMetadataProvider>();
Expand Down
Loading
Loading