@@ -40,16 +40,16 @@ private enum ModuleCompletionPriority
40
40
}
41
41
42
42
// Direct reference to a full registry login server URI via br:<registry>
43
- private static readonly Regex ModuleWithFullPath = new ( @"^br:(?<registry>(.*?))/" , RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
43
+ private static readonly Regex ModulePrefixWithFullPath = new ( @"^br:(?<registry>(.*?))/" , RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
44
44
45
45
// Aliased reference to a registry via br/alias:path
46
- private static readonly Regex ModuleWithAlias = new ( @"^br/(.*):(?<filePath>(.*?)):" , RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
46
+ private static readonly Regex ModulePrefixWithAlias = new ( @"^br/(.*):(?<filePath>(.*?)):" , RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
47
47
48
48
// Direct reference to the MCR (public) registry via br:mcr.microsoft.com/bicep/path
49
- private static readonly Regex PublicModuleWithFullPath = new ( $ "^br:{ PublicMCRRegistry } /bicep/(?<filePath>(.*?)):'?$", RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ; //asdfg needed?
49
+ private static readonly Regex PublicModuleWithFullPathAndVersionSeparator = new ( $ "^br:{ PublicMCRRegistry } /bicep/(?<filePath>(.*?)):'?$", RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
50
50
51
51
// Aliased reference to the MCR (public) registry via br/public:
52
- private static readonly Regex PublicModuleWithAlias = new ( @"^br/public:(?<filePath>(.*?)):'?$" , RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
52
+ private static readonly Regex PublicModuleWithAliasAndVersionSeparator = new ( @"^br/public:(?<filePath>(.*?)):'?$" , RegexOptions . Compiled | RegexOptions . ExplicitCapture | RegexOptions . IgnoreCase ) ;
53
53
54
54
private const string PublicMCRRegistry = LanguageConstants . BicepPublicMcrRegistry ; // "mcr.microsoft.com"
55
55
@@ -83,14 +83,14 @@ public async Task<IEnumerable<CompletionItem>> GetFilteredCompletions(Uri source
83
83
{
84
84
var trimmedReplacementText = replacementText . Trim ( '\' ' ) ;
85
85
86
- var replacementsAfterSingleQuote =
86
+ var replacementsRequiringStartingQuote =
87
87
GetOciModulePathCompletions ( context , trimmedReplacementText , sourceFileUri )
88
- . Concat ( GetMCRModuleRegistryVersionCompletions ( context , trimmedReplacementText , sourceFileUri ) )
88
+ . Concat ( GetPublicModuleVersionCompletions ( context , trimmedReplacementText , sourceFileUri ) )
89
89
. Concat ( await GetAllRegistryNameAndAliasCompletions ( context , trimmedReplacementText , sourceFileUri , cancellationToken ) ) ;
90
90
91
91
completions = [
92
92
..completions ,
93
- ..replacementsAfterSingleQuote ,
93
+ ..replacementsRequiringStartingQuote ,
94
94
] ;
95
95
}
96
96
@@ -180,7 +180,7 @@ void AddCompletionItem(string schemePrefix, string? alias, string detailLabel, M
180
180
/// <summary>
181
181
/// True if is an OCI module reference (i.e., it starts with br: or br/)
182
182
/// </summary>
183
- private bool IsOciArtifactRegistryReference ( string trimmedText ) //asdfg rename
183
+ private bool IsOciArtifactRegistryReference ( string trimmedText )
184
184
{
185
185
if ( trimmedText . StartsWith ( "br/" ) || trimmedText . StartsWith ( "br:" ) )
186
186
{
@@ -196,7 +196,7 @@ private bool IsOciArtifactRegistryReference(string trimmedText) //asdfg rename
196
196
// br:mcr.microsoft/bicep/module/name:<CURSOR>
197
197
//
198
198
// etc
199
- private IEnumerable < CompletionItem > GetMCRModuleRegistryVersionCompletions ( BicepCompletionContext context , string trimmedText , Uri sourceFileUri )
199
+ private IEnumerable < CompletionItem > GetPublicModuleVersionCompletions ( BicepCompletionContext context , string trimmedText , Uri sourceFileUri )
200
200
{
201
201
if ( ! IsOciArtifactRegistryReference ( trimmedText ) )
202
202
{
@@ -205,19 +205,19 @@ private IEnumerable<CompletionItem> GetMCRModuleRegistryVersionCompletions(Bicep
205
205
206
206
string ? modulePath ;
207
207
208
- if ( PublicModuleWithAlias . IsMatch ( trimmedText ) )
208
+ if ( PublicModuleWithAliasAndVersionSeparator . IsMatch ( trimmedText ) )
209
209
{
210
- var matches = PublicModuleWithAlias . Matches ( trimmedText ) ;
210
+ var matches = PublicModuleWithAliasAndVersionSeparator . Matches ( trimmedText ) ;
211
211
modulePath = matches [ 0 ] . Groups [ "filePath" ] . Value ;
212
212
}
213
- else if ( PublicModuleWithFullPath . IsMatch ( trimmedText ) )
213
+ else if ( PublicModuleWithFullPathAndVersionSeparator . IsMatch ( trimmedText ) )
214
214
{
215
- var matches = PublicModuleWithFullPath . Matches ( trimmedText ) ;
215
+ var matches = PublicModuleWithFullPathAndVersionSeparator . Matches ( trimmedText ) ;
216
216
modulePath = matches [ 0 ] . Groups [ "filePath" ] . Value ;
217
217
}
218
218
else
219
219
{
220
- modulePath = GetNonPublicMCRFilePathForVersionCompletion ( trimmedText , sourceFileUri ) ;
220
+ modulePath = GetAliasedMCRFilePath ( trimmedText , sourceFileUri ) ;
221
221
}
222
222
223
223
if ( modulePath is null )
@@ -248,56 +248,56 @@ private IEnumerable<CompletionItem> GetMCRModuleRegistryVersionCompletions(Bicep
248
248
}
249
249
250
250
return completions ;
251
- }
252
251
253
- // Handles scenario where the user has configured an alias for MCR in bicepconfig.json.
254
- private string ? GetNonPublicMCRFilePathForVersionCompletion ( string trimmedText , Uri sourceFileUri )
255
- {
256
- foreach ( var kvp in GetModuleAliases ( sourceFileUri ) )
252
+ // Handles scenario where the user has configured an alias for MCR in bicepconfig.json.
253
+ string ? GetAliasedMCRFilePath ( string trimmedText , Uri sourceFileUri )
257
254
{
258
- if ( kvp . Value . Registry is string registry &&
259
- registry . Equals ( PublicMCRRegistry , StringComparison . Ordinal ) )
255
+ foreach ( var kvp in GetModuleAliases ( sourceFileUri ) )
260
256
{
261
- var aliasFromBicepConfig = $ "br/{ kvp . Key } :";
262
-
263
- if ( trimmedText . StartsWith ( aliasFromBicepConfig , StringComparison . Ordinal ) )
257
+ if ( kvp . Value . Registry is string registry &&
258
+ registry . Equals ( PublicMCRRegistry , StringComparison . Ordinal ) )
264
259
{
265
- var matches = ModuleWithAlias . Matches ( trimmedText ) ;
260
+ var aliasFromBicepConfig = $ "br/ { kvp . Key } :" ;
266
261
267
- if ( ! matches . Any ( ) )
262
+ if ( trimmedText . StartsWith ( aliasFromBicepConfig , StringComparison . Ordinal ) )
268
263
{
269
- continue ;
270
- }
264
+ var matches = ModulePrefixWithAlias . Matches ( trimmedText ) ;
271
265
272
- string filePath = matches [ 0 ] . Groups [ "filePath" ] . Value ;
266
+ if ( ! matches . Any ( ) )
267
+ {
268
+ continue ;
269
+ }
273
270
274
- if ( filePath is null )
275
- {
276
- continue ;
277
- }
271
+ string filePath = matches [ 0 ] . Groups [ "filePath" ] . Value ;
278
272
279
- var modulePath = kvp . Value . ModulePath ;
273
+ if ( filePath is null )
274
+ {
275
+ continue ;
276
+ }
280
277
281
- if ( modulePath is not null )
282
- {
283
- if ( modulePath . StartsWith ( "bicep/" ) )
278
+ var modulePath = kvp . Value . ModulePath ;
279
+
280
+ if ( modulePath is not null )
284
281
{
285
- modulePath = modulePath . Substring ( "bicep/" . Length ) ;
286
- return $ "{ modulePath } /{ filePath } ";
282
+ if ( modulePath . StartsWith ( "bicep/" ) )
283
+ {
284
+ modulePath = modulePath . Substring ( "bicep/" . Length ) ;
285
+ return $ "{ modulePath } /{ filePath } ";
286
+ }
287
287
}
288
- }
289
- else
290
- {
291
- if ( filePath . StartsWith ( "bicep/" ) )
288
+ else
292
289
{
293
- return filePath . Substring ( "bicep/" . Length ) ;
290
+ if ( filePath . StartsWith ( "bicep/" ) )
291
+ {
292
+ return filePath . Substring ( "bicep/" . Length ) ;
293
+ }
294
294
}
295
295
}
296
296
}
297
297
}
298
- }
299
298
300
- return null ;
299
+ return null ;
300
+ }
301
301
}
302
302
303
303
private ImmutableSortedDictionary < string , OciArtifactModuleAlias > GetModuleAliases ( Uri sourceFileUri )
@@ -316,14 +316,14 @@ private IEnumerable<CompletionItem> GetOciModulePathCompletions(BicepCompletionC
316
316
317
317
return [
318
318
.. GetPublicModuleCompletions ( trimmedText , context ) ,
319
- .. GetACRPartialPathCompletionsFromModuleAliases ( trimmedText , context , sourceFileUri ) ,
320
- .. GetMCRPathCompletionFromBicepConfig ( trimmedText , context , sourceFileUri ) ,
319
+ .. GetPartialPrivatePathCompletionsFromAliases ( trimmedText , context , sourceFileUri ) ,
320
+ .. GetPublicPathCompletionFromAliases ( trimmedText , context , sourceFileUri ) ,
321
321
] ;
322
322
}
323
323
324
324
325
325
// Handles path completions for case where user has specified an alias in bicepconfig.json with registry set to "mcr.microsoft.com".
326
- private IEnumerable < CompletionItem > GetMCRPathCompletionFromBicepConfig ( string trimmedText , BicepCompletionContext context , Uri sourceFileUri )
326
+ private IEnumerable < CompletionItem > GetPublicPathCompletionFromAliases ( string trimmedText , BicepCompletionContext context , Uri sourceFileUri )
327
327
{
328
328
List < CompletionItem > completions = new ( ) ;
329
329
@@ -336,7 +336,7 @@ private IEnumerable<CompletionItem> GetMCRPathCompletionFromBicepConfig(string t
336
336
{
337
337
if ( kvp . Value . Registry is string registry )
338
338
{
339
- // We currently don't support path completion for ACR , but we'll go ahead and log telemetry to track usage.
339
+ // We currently don't support path completion for private modules , but we'll go ahead and log telemetry to track usage.
340
340
if ( ! registry . Equals ( PublicMCRRegistry , StringComparison . Ordinal ) &&
341
341
trimmedText . Equals ( $ "br/{ kvp . Key } :") )
342
342
{
@@ -457,7 +457,7 @@ private bool IsPrivateRegistryReference(string text, [NotNullWhen(true)] out str
457
457
{
458
458
registry = null ;
459
459
460
- var matches = ModuleWithFullPath . Matches ( text ) ;
460
+ var matches = ModulePrefixWithFullPath . Matches ( text ) ;
461
461
if ( ! matches . Any ( ) )
462
462
{
463
463
return false ;
@@ -484,7 +484,7 @@ private bool IsPrivateRegistryReference(string text, [NotNullWhen(true)] out str
484
484
// br:privateacr.azurecr.io/<CURSOR>
485
485
// =>
486
486
// br:privateacr.azurecr.io/bicep/app:<CURSOR>
487
- private IEnumerable < CompletionItem > GetACRPartialPathCompletionsFromModuleAliases ( string trimmedText , BicepCompletionContext context , Uri sourceFileUri )
487
+ private IEnumerable < CompletionItem > GetPartialPrivatePathCompletionsFromAliases ( string trimmedText , BicepCompletionContext context , Uri sourceFileUri )
488
488
{
489
489
List < CompletionItem > completions = new ( ) ;
490
490
@@ -607,15 +607,14 @@ private async Task<IEnumerable<CompletionItem>> GetAllRegistryNameAndAliasComple
607
607
608
608
completions . Add ( mcrCompletionItem ) ;
609
609
610
- IEnumerable < CompletionItem > acrCompletions = await GetACRModuleRegistriesCompletions ( trimmedText , context , sourceFileUri , cancellationToken ) ;
611
- completions . AddRange ( acrCompletions ) ;
610
+ completions . AddRange ( await GetPrivateModuleCompletions ( trimmedText , context , sourceFileUri , cancellationToken ) ) ;
612
611
}
613
612
614
613
return completions ;
615
614
}
616
615
617
616
// Handles registry name completions for private modules possibly available in ACR registries
618
- private async Task < IEnumerable < CompletionItem > > GetACRModuleRegistriesCompletions ( string trimmedText , BicepCompletionContext context , Uri sourceFileUri , CancellationToken cancellationToken )
617
+ private async Task < IEnumerable < CompletionItem > > GetPrivateModuleCompletions ( string trimmedText , BicepCompletionContext context , Uri sourceFileUri , CancellationToken cancellationToken )
619
618
{
620
619
if ( settingsProvider . GetSetting ( LangServerConstants . GetAllAzureContainerRegistriesForCompletionsSetting ) )
621
620
{
0 commit comments