public Binder(BicepFile bicepFile, ISymbolContext symbolContext) { // TODO use lazy or some other pattern for init this.bicepFile = bicepFile; this.TargetScope = SyntaxHelper.GetTargetScope(bicepFile); var(declarations, outermostScopes) = DeclarationVisitor.GetDeclarations(bicepFile, symbolContext); var uniqueDeclarations = GetUniqueDeclarations(declarations); var builtInNamespaces = GetBuiltInNamespaces(this.TargetScope); this.bindings = GetBindings(bicepFile, uniqueDeclarations, builtInNamespaces, outermostScopes); this.cyclesBySymbol = GetCyclesBySymbol(bicepFile, this.bindings); // TODO: Avoid looping 5 times? this.FileSymbol = new FileSymbol( bicepFile.FileUri.LocalPath, bicepFile.ProgramSyntax, builtInNamespaces, outermostScopes, declarations.OfType <ParameterSymbol>(), declarations.OfType <VariableSymbol>(), declarations.OfType <ResourceSymbol>(), declarations.OfType <ModuleSymbol>(), declarations.OfType <OutputSymbol>(), bicepFile.FileUri); }
private static ImmutableArray <DeclaredSymbol> GetAllDeclarations(SyntaxTree syntaxTree, ISymbolContext symbolContext) { // collect declarations var declarations = new List <DeclaredSymbol>(); var declarationVisitor = new DeclarationVisitor(symbolContext, declarations); declarationVisitor.Visit(syntaxTree.ProgramSyntax); return(declarations.ToImmutableArray()); }
public Binder(INamespaceProvider namespaceProvider, BicepFile bicepFile, ISymbolContext symbolContext) { // TODO use lazy or some other pattern for init this.bicepFile = bicepFile; this.TargetScope = SyntaxHelper.GetTargetScope(bicepFile); var(declarations, outermostScopes) = DeclarationVisitor.GetDeclarations(namespaceProvider, TargetScope, bicepFile, symbolContext); var uniqueDeclarations = GetUniqueDeclarations(declarations); this.NamespaceResolver = GetNamespaceResolver(namespaceProvider, this.TargetScope, uniqueDeclarations); this.bindings = NameBindingVisitor.GetBindings(bicepFile.ProgramSyntax, uniqueDeclarations, NamespaceResolver, outermostScopes); this.cyclesBySymbol = GetCyclesBySymbol(bicepFile, this.bindings); this.FileSymbol = new FileSymbol( bicepFile.FileUri.LocalPath, bicepFile.ProgramSyntax, NamespaceResolver, outermostScopes, declarations, bicepFile.FileUri); }