-
Notifications
You must be signed in to change notification settings - Fork 764
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
Fix IdentifierName issue in snippet templates with placeholder for symbolic name #2490
Fix IdentifierName issue in snippet templates with placeholder for symbolic name #2490
Conversation
Returning Can you tell me more why returning |
@@ -41,14 +46,53 @@ public string IdentifierName | |||
return identifier.Text; | |||
|
|||
case SkippedTriviaSyntax skipped: | |||
return skipped.Elements.Any() ? LanguageConstants.ErrorName : LanguageConstants.MissingName; | |||
|
|||
ImmutableArray<SyntaxBase> elements = skipped.Elements; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relies on a specific parser recovery behavior, which makes it kind of fragile. (We also want to avoid regexes in the main compiler path.)
If we agree that we need to support it in the parser (see my other comment), it should be its own type of syntax node and parsed by the parser like everything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Marcin, I'll investigate separate syntax node option and see how it goes.
Having a malformed identifier makes it difficult to figure out resource dependencies in snippet templates with multiple resources. I am wondering if we should skip having placeholder for symbolic name of parent resource in templates with multiple resources.
@MarcusFelling , for snippet templates with multiple resources, do you think it's okay to skip having placeholder for parent resource symbolic name for now? |
Had an offline discussion with @MarcusFelling. We'll skip adding placeholder for parent resource symbolic name. Made changes to flip ordering of resources to display parent resource first in this PR:#2172 I'll go ahead and close this PR. @majastrz , let me know if you have any concerns. |
Changes to return placeholder text as IdentifierName instead of
<error>
for snippet templates with placeholder text for symbolic nameSnippet templates available here: https://github.com/Azure/bicep/tree/main/src/Bicep.LangServer/Snippets/Templates have placeholder text for symbolic name. We seem to return
<error>
as IdentiferName while parsing. We should be returning placeholder text instead. Consider below example:resource ${1:dnsZone} 'Microsoft.Network/dnsZones@2018-05-01' = {
name: ${2:'name'}
location: 'global'
}
We should return ${1:dnsZone} as IdentifierName in this case