Ejemplo n.º 1
0
        private static ImmutableDictionary <SyntaxBase, Symbol> GetBindings(SyntaxTree syntaxTree, IReadOnlyDictionary <string, DeclaredSymbol> uniqueDeclarations, ImmutableDictionary <string, NamespaceSymbol> builtInNamespaces)
        {
            // bind identifiers to declarations
            var bindings = new Dictionary <SyntaxBase, Symbol>();
            var binder   = new NameBindingVisitor(uniqueDeclarations, bindings, builtInNamespaces);

            binder.Visit(syntaxTree.ProgramSyntax);

            return(bindings.ToImmutableDictionary());
        }
Ejemplo n.º 2
0
        private static ImmutableDictionary <SyntaxBase, Symbol> GetBindings(
            BicepFile bicepFile,
            IReadOnlyDictionary <string, DeclaredSymbol> outermostDeclarations,
            ImmutableDictionary <string, NamespaceSymbol> builtInNamespaces,
            ImmutableArray <LocalScope> childScopes)
        {
            // bind identifiers to declarations
            var bindings = new Dictionary <SyntaxBase, Symbol>();
            var binder   = new NameBindingVisitor(outermostDeclarations, bindings, builtInNamespaces, childScopes);

            binder.Visit(bicepFile.ProgramSyntax);

            return(bindings.ToImmutableDictionary());
        }
Ejemplo n.º 3
0
        public static ImmutableDictionary <SyntaxBase, Symbol> GetBindings(
            ProgramSyntax programSyntax,
            IReadOnlyDictionary <string, DeclaredSymbol> outermostDeclarations,
            NamespaceResolver namespaceResolver,
            ImmutableArray <LocalScope> childScopes)
        {
            // bind identifiers to declarations
            var bindings       = new Dictionary <SyntaxBase, Symbol>();
            var allLocalScopes = ScopeCollectorVisitor.Build(childScopes);
            var binder         = new NameBindingVisitor(outermostDeclarations, bindings, namespaceResolver, allLocalScopes);

            binder.Visit(programSyntax);

            return(bindings.ToImmutableDictionary());
        }
Ejemplo n.º 4
0
        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);
        }