Skip to content

Commit 8ea021c

Browse files
authored
Improve F12 UX for using declaration in .bicepparam (#18372)
Updated `BicepDefinitionHandler` to handle `UsingDeclarationSyntax`, ensuring that Bicep source files instead of ARM template files for remote modules are opened (if Bicep source is available). This aligns the user experience with the behavior of Go to Definition for module paths in Bicep files. Closes #17859. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/18372)
1 parent eb45f4e commit 8ea021c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Bicep.LangServer/Handlers/BicepDefinitionHandler.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ private LocationOrLocationLinks HandleUnboundSymbolLocation(DefinitionParams req
109109
return HandleModuleReference(context, stringToken, sourceFile, moduleReference);
110110
}
111111
}
112+
{
113+
// Handle using '<module_path>'
114+
if (SyntaxMatcher.IsTailMatch<UsingDeclarationSyntax, StringSyntax, Token>(matchingNodes, (usingDeclaration, usingPath, token) => token.Type == TokenType.StringComplete) &&
115+
matchingNodes[^3] is UsingDeclarationSyntax usingDeclaration &&
116+
matchingNodes[^2] is StringSyntax stringSyntax &&
117+
context.Compilation.SourceFileGrouping.TryGetSourceFile(usingDeclaration).IsSuccess(out var sourceFile) &&
118+
moduleDispatcher.TryGetArtifactReference(context.Compilation.SourceFileGrouping.EntryPoint, usingDeclaration).IsSuccess(out var moduleReference))
119+
{
120+
return HandleModuleReference(context, stringSyntax, sourceFile, moduleReference);
121+
}
122+
}
112123
{ // Definition handler for a non symbol bound to implement import path goto.
113124
// try to resolve import path syntax from given offset using tail matching.
114125
if (SyntaxMatcher.IsTailMatch<CompileTimeImportDeclarationSyntax, CompileTimeImportFromClauseSyntax, StringSyntax, Token>(

0 commit comments

Comments
 (0)