Skip to content

Commit

Permalink
Refactor and simplify handling of single quotes in module completions
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford committed Dec 20, 2024
1 parent 81e0d13 commit cca9277
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 120 deletions.
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

0 comments on commit cca9277

Please sign in to comment.