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

Compile-time type imports #11298

Merged
merged 30 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c3cabe1
Rename Import* syntax kinds to Provider*
jeskew Jun 14, 2023
cb03a8d
Add support for compile-time imports to parser
jeskew Jun 27, 2023
594547f
Add feature flag for compile-time imports
jeskew Jun 27, 2023
1ef9d68
Add @export() decorator for types
jeskew Jun 29, 2023
e4e489e
Integrate imports into type system and module dispatcher
jeskew Jul 5, 2023
df81fb6
Tweak merge
jeskew Jul 17, 2023
232a832
Add support for LS completions
jeskew Jul 19, 2023
41fe9dd
Emit imported type symbols in compiled template
jeskew Jul 24, 2023
de138d7
Try to break import closure info calculation into separate steps
jeskew Jul 25, 2023
25e4f49
Move inner classes into separate files
jeskew Jul 25, 2023
0318593
Ensure @export() is targeting top-level type statement
jeskew Jul 25, 2023
4d0a2e2
Merge branch 'main' into jeskew/imports
jeskew Jul 25, 2023
2308e26
Improve compile-time import diagnostic messaging
jeskew Jul 26, 2023
d4bdc01
Implement go to definition for import symbols
jeskew Jul 26, 2023
928ccba
Regenerate baselines and fix failing tests
jeskew Jul 26, 2023
ecbb177
Augment compile time import completions
jeskew Jul 26, 2023
7206eb4
Fixup message formatting
jeskew Jul 27, 2023
b6eabe8
Fix failing tests
jeskew Jul 27, 2023
aa0f8f5
Use an incrementing counter rather than hashes to create unique names…
jeskew Jul 27, 2023
2a691da
Augment hover support on imported symbols and properties thereof
jeskew Jul 27, 2023
9a6329d
Ensure registry module restoration works as expected for `import` and…
jeskew Jul 27, 2023
700884d
Add ARM source template support for go-to-definition on imported symbols
jeskew Jul 27, 2023
69d84ac
Merge branch 'main' into jeskew/imports
jeskew Jul 30, 2023
e6cfd34
Inject import origin info into type definition metadata for imported …
jeskew Jul 30, 2023
c4b435f
Merge branch 'main' into jeskew/imports
jeskew Aug 1, 2023
9224888
Merge branch 'main' into jeskew/imports
jeskew Aug 2, 2023
6bf9e25
Merge branch 'main' into jeskew/imports
jeskew Aug 2, 2023
838d75c
Merge branch 'main' into jeskew/imports
jeskew Aug 3, 2023
0b292b2
Use ToImmutableDictionary instead of CreateRange
jeskew Aug 4, 2023
41e11e0
Merge branch 'main' into jeskew/imports
jeskew Aug 4, 2023
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
15 changes: 15 additions & 0 deletions docs/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ program -> statement* EOF
statement ->
targetScopeDecl |
importDecl |
compileTimeImportDecl |
metadataDecl |
parameterDecl |
typeDecl |
Expand All @@ -25,6 +26,20 @@ importWithClause -> "with" object

importAsClause -> "as" IDENTIFIER(alias)

compileTimeImportDecl -> decorator* "import" compileTimeImportTarget compileTimeImportFromClause

compileTimeImportTarget ->
importedSymbolsList |
wildcardImport

importedSymbolsList -> "{" ( NL+ ( importedSymbolsListItem NL+ )* )? "}"

importedSymbolsListItem -> IDENTIFIER(originalSymbolName) importAsClause?

wildcardImport -> "*" importAsClause

compileTimeImportFromClause -> "from" interpString(path)

metadataDecl -> "metadata" IDENTIFIER(name) "=" expression NL

parameterDecl ->
Expand Down
7 changes: 4 additions & 3 deletions src/Bicep.Cli/Services/CompilationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Bicep.Core.Diagnostics;
using Bicep.Core.Extensions;
using Bicep.Core.FileSystem;
using Bicep.Core.Navigation;
using Bicep.Core.Registry;
using Bicep.Core.Semantics;
using Bicep.Core.Syntax;
Expand Down Expand Up @@ -126,14 +127,14 @@ public DecompileResult DecompileParams(string inputPath, string outputPath, stri
{
workspace.UpsertSourceFile(SourceFileFactory.CreateBicepFile(fileUri, bicepOutput));
}

return decompilation;
}

private static ImmutableDictionary<BicepSourceFile, ImmutableArray<IDiagnostic>> GetModuleRestoreDiagnosticsByBicepFile(SourceFileGrouping sourceFileGrouping, ImmutableHashSet<ModuleSourceResolutionInfo> originalModulesToRestore, bool forceModulesRestore)
{
static IDiagnostic? DiagnosticForModule(SourceFileGrouping grouping, ModuleDeclarationSyntax module)
=> grouping.TryGetErrorDiagnostic(module) is { } errorBuilder ? errorBuilder(DiagnosticBuilder.ForPosition(module.Path)) : null;
static IDiagnostic? DiagnosticForModule(SourceFileGrouping grouping, IForeignTemplateReference module)
=> grouping.TryGetErrorDiagnostic(module) is { } errorBuilder ? errorBuilder(DiagnosticBuilder.ForPosition(module.ReferenceSourceSyntax)) : null;

static IEnumerable<(BicepFile, IDiagnostic)> GetDiagnosticsForModulesToRestore(SourceFileGrouping grouping, ImmutableHashSet<ModuleSourceResolutionInfo> originalModulesToRestore)
{
Expand Down
Loading
Loading