public override IBindingContainer CreateBindingContainer(
            )
        {
            var types = BuildTypes();

            var bindingContainer = new ConstantBindingContainer(
                types,
                _constantClause,
                _scope,
                _expressionNode,
                _whenArgumentClause,
                _settings
                );

            return(bindingContainer);
        }
예제 #2
0
        private void ProcessConstant(
            ExpressionStatementSyntax expressionNode,
            GenericNameSyntax bindGenericNode,
            ArgumentSyntax?whenArgumentClause
            )
        {
            var genericNodes = expressionNode
                               .DescendantNodes()
                               .OfType <GenericNameSyntax>()
                               .ToList();


            var withScopeSyntax = expressionNode
                                  .DescendantNodes()
                                  .Where(s => s.GetText().ToString() == nameof(IToOrConstantBinding.WithConstScope))
                                  .First();

            var constTypeSymbol = (_semanticModel.GetSymbolInfo(withScopeSyntax).Symbol as IMethodSymbol) !.TypeArguments[0];

            var constantClause = DetermineArgumentSubClause(
                expressionNode,
                nameof(IToOrConstantBinding.WithConstScope)
                );

            if (constantClause is null)
            {
                throw new DpdtException(DpdtExceptionTypeEnum.InternalError, $"Cannot find constant clause");
            }

            var bindFromTypeSemantics = GetBindFromTypes(
                bindGenericNode
                );

            var bindingContainer = new ConstantBindingContainer(
                bindFromTypeSemantics,
                constTypeSymbol,
                constantClause,
                BindScopeEnum.Constant,
                whenArgumentClause
                );

            _bindingContainers.Add(bindingContainer);
        }