Exemplo n.º 1
0
        private bool GetSpeculativeSemanticModelForMethodBody(SyntaxTreeSemanticModel parentModel, int position, BlockSyntax body, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var methodSymbol = (MethodSymbol)this.MemberSymbol;

            // Strip off ExecutableCodeBinder (see ctor).
            Binder binder = this.RootBinder;

            do
            {
                if (binder is ExecutableCodeBinder)
                {
                    binder = binder.Next;
                    break;
                }

                binder = binder.Next;
            }
            while (binder != null);

            Debug.Assert(binder != null);

            var executablebinder = new ExecutableCodeBinder(body, methodSymbol, binder ?? this.RootBinder);
            var blockBinder = executablebinder.GetBinder(body).WithAdditionalFlags(GetSemanticModelBinderFlags());
            speculativeModel = CreateSpeculative(parentModel, methodSymbol, body, blockBinder, position);
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a speculative AttributeSemanticModel that allows asking semantic questions about an attribute node that did not appear in the original source code.
        /// </summary>
        public static AttributeSemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, AttributeSyntax syntax, NamedTypeSymbol attributeType, AliasSymbol aliasOpt, Binder rootBinder, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return new AttributeSemanticModel(parentSemanticModel.Compilation, syntax, attributeType, aliasOpt, rootBinder, parentSemanticModel, position);
        }
Exemplo n.º 3
0
 private MethodBodySemanticModel(CSharpCompilation compilation, Symbol owner, Binder rootBinder, CSharpSyntaxNode syntax, SyntaxTreeSemanticModel parentSemanticModelOpt = null, int speculatedPosition = 0)
     : base(compilation, syntax, owner, rootBinder, parentSemanticModelOpt, speculatedPosition)
 {
     Debug.Assert((object)owner != null);
     Debug.Assert(owner.Kind == SymbolKind.Method);
     Debug.Assert(syntax != null);
     Debug.Assert(owner.ContainingType.IsScriptClass || syntax.Kind != SyntaxKind.CompilationUnit);
 }
 // create a SemanticModel for:
 // (a) A true field initializer (field = value) of a named type (incl. Enums) OR
 // (b) A constructor initializer (": this(...)" or ": base(...)") OR
 // (c) A parameter default value
 private InitializerSemanticModel(CSharpCompilation compilation,
                              CSharpSyntaxNode syntax,
                              Symbol symbol,
                              Binder rootBinder,
                              SyntaxTreeSemanticModel parentSemanticModelOpt = null,
                              int speculatedPosition = 0) :
     base(compilation, syntax, symbol, rootBinder, parentSemanticModelOpt, speculatedPosition)
 {
 }
        /// <summary>
        /// Creates a speculative SemanticModel for a constructor initializer that did not appear in the original source code.
        /// </summary>
        internal static MethodBodySemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, MethodSymbol owner, ConstructorInitializerSyntax syntax, Binder rootBinder, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(syntax != null);
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return(new MethodBodySemanticModel(owner, rootBinder, syntax, parentSemanticModelOpt: parentSemanticModel, speculatedPosition: position));
        }
Exemplo n.º 6
0
 // create a SemanticModel for:
 // (a) A true field initializer (field = value) of a named type (incl. Enums) OR
 // (b) A constructor initializer (": this(...)" or ": base(...)") OR
 // (c) A parameter default value
 private InitializerSemanticModel(CSharpCompilation compilation,
                                  CSharpSyntaxNode syntax,
                                  Symbol symbol,
                                  Binder rootBinder,
                                  SyntaxTreeSemanticModel parentSemanticModelOpt = null,
                                  int speculatedPosition = 0) :
     base(compilation, syntax, symbol, rootBinder, parentSemanticModelOpt, speculatedPosition)
 {
 }
Exemplo n.º 7
0
 private SpeculativeSyntaxTreeSemanticModel(SyntaxTreeSemanticModel parentSemanticModel, CSharpSyntaxNode root, Binder rootBinder, int position, SpeculativeBindingOption bindingOption)
     : base(parentSemanticModel.Compilation, parentSemanticModel.SyntaxTree, root.SyntaxTree)
 {
     _parentSemanticModel = parentSemanticModel;
     _root          = root;
     _rootBinder    = rootBinder;
     _position      = position;
     _bindingOption = bindingOption;
 }
        /// <summary>
        /// Creates a speculative SemanticModel for an expression body that did not appear in the original source code.
        /// </summary>
        internal static MethodBodySemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, MethodSymbol owner, ArrowExpressionClauseSyntax syntax, Binder rootBinder, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(syntax != null);
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return(new MethodBodySemanticModel(parentSemanticModel.Compilation, owner, rootBinder, syntax, parentSemanticModel, position));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a speculative SemanticModel for a method body that did not appear in the original source code.
        /// </summary>
        internal static MethodBodySemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, MethodSymbol owner, StatementSyntax syntax, Binder rootBinder, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(syntax != null);
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return new MethodBodySemanticModel(parentSemanticModel.Compilation, owner, rootBinder, syntax, parentSemanticModel, position);
        }
Exemplo n.º 10
0
 internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     AccessorDeclarationSyntax accessor,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a speculative SemanticModel for an initializer node (field initializer, constructor initializer, or parameter default value)
        /// that did not appear in the original source code.
        /// </summary>
        internal static InitializerSemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, Symbol owner, CSharpSyntaxNode syntax, Binder rootBinder, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(syntax != null);
            Debug.Assert(syntax.IsKind(SyntaxKind.EqualsValueClause) || syntax.IsKind(SyntaxKind.ThisConstructorInitializer) || syntax.IsKind(SyntaxKind.BaseConstructorInitializer));
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return(new InitializerSemanticModel(parentSemanticModel.Compilation, syntax, owner, rootBinder, parentSemanticModel, position));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Creates a speculative SemanticModel for an initializer node (field initializer, constructor initializer, or parameter default value)
        /// that did not appear in the original source code.
        /// </summary>
        internal static InitializerSemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, Symbol owner, CSharpSyntaxNode syntax, Binder rootBinder, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(syntax != null);
            Debug.Assert(syntax.IsKind(SyntaxKind.EqualsValueClause) || syntax.IsKind(SyntaxKind.ThisConstructorInitializer) || syntax.IsKind(SyntaxKind.BaseConstructorInitializer));
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return new InitializerSemanticModel(parentSemanticModel.Compilation, syntax, owner, rootBinder, parentSemanticModel, position);
        }
 public static SpeculativeSyntaxTreeSemanticModel Create(
     SyntaxTreeSemanticModel parentSemanticModel,
     TypeSyntax root,
     Binder rootBinder,
     int position,
     SpeculativeBindingOption bindingOption
     )
 {
     return(CreateCore(parentSemanticModel, root, rootBinder, position, bindingOption));
 }
Exemplo n.º 14
0
        private bool GetSpeculativeSemanticModelForMethodBody(SyntaxTreeSemanticModel parentModel, int position, BlockSyntax body, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var methodSymbol = (MethodSymbol)this.MemberSymbol;
            var executablebinder = new ExecutableCodeBinder(body, methodSymbol, this.rootBinder.Next); // Strip off ExecutableCodeBinder (see ctor).
            var blockBinder = executablebinder.GetBinder(body).WithAdditionalFlags(BinderFlags.SemanticModel);
            speculativeModel = CreateSpeculative(parentModel, methodSymbol, body, blockBinder, position);
            return true;
        }
Exemplo n.º 15
0
 // create a SemanticModel for:
 // (a) A true field initializer (field = value) of a named type (incl. Enums) OR
 // (b) A parameter default value
 private InitializerSemanticModel(CSharpSyntaxNode syntax,
                                  Symbol symbol,
                                  Binder rootBinder,
                                  SyntaxTreeSemanticModel containingSemanticModelOpt = null,
                                  SyntaxTreeSemanticModel parentSemanticModelOpt     = null,
                                  int speculatedPosition = 0) :
     base(syntax, symbol, rootBinder, containingSemanticModelOpt, parentSemanticModelOpt, speculatedPosition)
 {
     Debug.Assert(!(syntax is ConstructorInitializerSyntax));
 }
Exemplo n.º 16
0
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     PrimaryConstructorBaseTypeSyntax constructorInitializer,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Exemplo n.º 17
0
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     EqualsValueClauseSyntax initializer,
     out SemanticModel?speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Exemplo n.º 18
0
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     ArrowExpressionClauseSyntax expressionBody,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Exemplo n.º 19
0
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     StatementSyntax statement,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Exemplo n.º 20
0
        internal static InitializerSemanticModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, Symbol owner, CSharpSyntaxNode syntax, Binder rootBinder, ImmutableDictionary <Symbol, Symbol> parentRemappedSymbolsOpt, int position)
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(syntax != null);
            Debug.Assert(syntax.IsKind(SyntaxKind.EqualsValueClause));
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return(new InitializerSemanticModel(syntax, owner, rootBinder, parentSemanticModelOpt: parentSemanticModel, parentRemappedSymbolsOpt: parentRemappedSymbolsOpt, speculatedPosition: position));
        }
Exemplo n.º 21
0
        private bool GetSpeculativeSemanticModelForMethodBody(SyntaxTreeSemanticModel parentModel, int position, BlockSyntax body, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var methodSymbol     = (MethodSymbol)this.MemberSymbol;
            var executablebinder = new ExecutableCodeBinder(body, methodSymbol, this.rootBinder.Next); // Strip off ExecutableCodeBinder (see ctor).
            var blockBinder      = executablebinder.GetBinder(body).WithAdditionalFlags(BinderFlags.SemanticModel);

            speculativeModel = CreateSpeculative(parentModel, methodSymbol, body, blockBinder, position);
            return(true);
        }
Exemplo n.º 22
0
 private InitializerSemanticModel(CSharpSyntaxNode syntax,
                                  Symbol symbol,
                                  Binder rootBinder,
                                  SyntaxTreeSemanticModel containingSemanticModelOpt            = null,
                                  SyntaxTreeSemanticModel parentSemanticModelOpt                = null,
                                  ImmutableDictionary <Symbol, Symbol> parentRemappedSymbolsOpt = null,
                                  int speculatedPosition = 0) :
     base(syntax, symbol, rootBinder, containingSemanticModelOpt, parentSemanticModelOpt, snapshotManagerOpt: null, parentRemappedSymbolsOpt, speculatedPosition)
 {
     Debug.Assert(!(syntax is ConstructorInitializerSyntax || syntax is PrimaryConstructorBaseTypeSyntax));
 }
        private static SpeculativeSyntaxTreeSemanticModel CreateCore(SyntaxTreeSemanticModel parentSemanticModel, CSharpSyntaxNode root, Binder rootBinder, int position, SpeculativeBindingOption bindingOption)
        {
            Debug.Assert(parentSemanticModel is SyntaxTreeSemanticModel);
            Debug.Assert(root != null);
            Debug.Assert(root is TypeSyntax || root is CrefSyntax);
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            var speculativeModel = new SpeculativeSyntaxTreeSemanticModel(parentSemanticModel, root, rootBinder, position, bindingOption);

            return(speculativeModel);
        }
Exemplo n.º 24
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, EqualsValueClauseSyntax initializer, out SemanticModel speculativeModel)
        {
            var binder = this.GetEnclosingBinder(position);
            if (binder == null)
            {
                speculativeModel = null;
                return false;
            }

            binder = new ExecutableCodeBinder(initializer, binder.ContainingMemberOrLambda, binder);
            speculativeModel = CreateSpeculative(parentModel, this.MemberSymbol, initializer, binder, GetRemappedSymbols(), position);
            return true;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Creates a SemanticModel for the method.
        /// </summary>
        internal static MethodBodySemanticModel Create(SyntaxTreeSemanticModel containingSemanticModel, MethodSymbol owner, ExecutableCodeBinder executableCodeBinder,
                                                       CSharpSyntaxNode syntax, BoundNode boundNode = null)
        {
            Debug.Assert(containingSemanticModel != null);
            var result = new MethodBodySemanticModel(owner, executableCodeBinder, syntax, containingSemanticModel);

            if (boundNode != null)
            {
                result.UnguardedAddBoundTreeForStandaloneSyntax(syntax, boundNode);
            }

            return(result);
        }
Exemplo n.º 26
0
 private AttributeSemanticModel(
     AttributeSyntax syntax,
     NamedTypeSymbol attributeType,
     AliasSymbol aliasOpt,
     Binder rootBinder,
     SyntaxTreeSemanticModel containingSemanticModelOpt = null,
     SyntaxTreeSemanticModel parentSemanticModelOpt     = null,
     int speculatedPosition = 0)
     : base(syntax, attributeType, new ExecutableCodeBinder(syntax, rootBinder.ContainingMember(), rootBinder), containingSemanticModelOpt, parentSemanticModelOpt, speculatedPosition)
 {
     Debug.Assert(syntax != null);
     _aliasOpt = aliasOpt;
 }
Exemplo n.º 27
0
 private MethodBodySemanticModel(
     Symbol owner,
     Binder rootBinder,
     CSharpSyntaxNode syntax,
     SyntaxTreeSemanticModel containingSemanticModelOpt = null,
     SyntaxTreeSemanticModel parentSemanticModelOpt     = null,
     int speculatedPosition = 0)
     : base(syntax, owner, rootBinder, containingSemanticModelOpt, parentSemanticModelOpt, speculatedPosition)
 {
     Debug.Assert((object)owner != null);
     Debug.Assert(owner.Kind == SymbolKind.Method);
     Debug.Assert(syntax != null);
     Debug.Assert(syntax.Kind() != SyntaxKind.CompilationUnit);
 }
        protected MemberSemanticModel(CSharpCompilation compilation, CSharpSyntaxNode root, Symbol memberSymbol, Binder rootBinder, SyntaxTreeSemanticModel parentSemanticModelOpt, int speculatedPosition)
        {
            Debug.Assert(compilation != null);
            Debug.Assert(root != null);
            Debug.Assert((object)memberSymbol != null);
            Debug.Assert(parentSemanticModelOpt == null || !parentSemanticModelOpt.IsSpeculativeSemanticModel, CSharpResources.ChainingSpeculativeModelIsNotSupported);

            this.compilation = compilation;
            this.root = root;
            this.memberSymbol = memberSymbol;
            this.RootBinder = rootBinder.WithAdditionalFlags(BinderFlags.SemanticModel);
            this.parentSemanticModelOpt = parentSemanticModelOpt;
            this.speculatedPosition = speculatedPosition;
        }
 public static SpeculativeSyntaxTreeSemanticModel Create(
     SyntaxTreeSemanticModel parentSemanticModel,
     CrefSyntax root,
     Binder rootBinder,
     int position
     )
 {
     return(CreateCore(
                parentSemanticModel,
                root,
                rootBinder,
                position,
                bindingOption: SpeculativeBindingOption.BindAsTypeOrNamespace
                ));
 }
Exemplo n.º 30
0
        private bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CSharpSyntaxNode initializer, out SemanticModel speculativeModel)
        {
            Debug.Assert(initializer is EqualsValueClauseSyntax || initializer is ConstructorInitializerSyntax);

            var binder = this.GetEnclosingBinder(position);

            if (binder == null)
            {
                speculativeModel = null;
                return(false);
            }

            speculativeModel = CreateSpeculative(parentModel, this.MemberSymbol, initializer, binder, position);
            return(true);
        }
Exemplo n.º 31
0
 internal static InitializerSemanticModel Create(
     SyntaxTreeSemanticModel containingSemanticModel,
     CSharpSyntaxNode syntax,
     PropertySymbol propertySymbol,
     Binder rootBinder
     )
 {
     Debug.Assert(containingSemanticModel != null);
     Debug.Assert(syntax.IsKind(SyntaxKind.PropertyDeclaration));
     return(new InitializerSemanticModel(
                syntax,
                propertySymbol,
                rootBinder,
                containingSemanticModel
                ));
 }
Exemplo n.º 32
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out SemanticModel speculativeModel)
        {
            if ((MemberSymbol as MethodSymbol)?.MethodKind == MethodKind.Constructor)
            {
                var binder = this.GetEnclosingBinder(position);
                if (binder != null)
                {
                    var methodSymbol = (MethodSymbol)this.MemberSymbol;
                    binder           = new ExecutableCodeBinder(constructorInitializer, methodSymbol, binder);
                    speculativeModel = CreateSpeculative(parentModel, methodSymbol, constructorInitializer, binder, position);
                    return(true);
                }
            }

            speculativeModel = null;
            return(false);
        }
Exemplo n.º 33
0
 internal static InitializerSemanticModel Create(
     SyntaxTreeSemanticModel containingSemanticModel,
     ParameterSyntax syntax,
     ParameterSymbol parameterSymbol,
     Binder rootBinder,
     ImmutableDictionary <Symbol, Symbol> parentRemappedSymbolsOpt
     )
 {
     Debug.Assert(containingSemanticModel != null);
     return(new InitializerSemanticModel(
                syntax,
                parameterSymbol,
                rootBinder,
                containingSemanticModel,
                parentRemappedSymbolsOpt: parentRemappedSymbolsOpt
                ));
 }
Exemplo n.º 34
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var binder = this.GetEnclosingBinder(position);

            if (binder == null)
            {
                speculativeModel = null;
                return(false);
            }

            var methodSymbol = (MethodSymbol)this.MemberSymbol;

            binder           = new ExecutableCodeBinder(statement, methodSymbol, binder);
            speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, position);
            return(true);
        }
Exemplo n.º 35
0
 /// <summary>
 /// Creates an AttributeSemanticModel that allows asking semantic questions about an attribute node.
 /// </summary>
 public static AttributeSemanticModel Create(
     SyntaxTreeSemanticModel containingSemanticModel,
     AttributeSyntax syntax,
     NamedTypeSymbol attributeType,
     AliasSymbol aliasOpt,
     Binder rootBinder,
     ImmutableDictionary <Symbol, Symbol> parentRemappedSymbolsOpt
     )
 {
     return(new AttributeSemanticModel(
                syntax,
                attributeType,
                aliasOpt,
                rootBinder,
                containingSemanticModel,
                parentRemappedSymbolsOpt: parentRemappedSymbolsOpt
                ));
 }
Exemplo n.º 36
0
 internal static InitializerSemanticModel Create(
     SyntaxTreeSemanticModel containingSemanticModel,
     CSharpSyntaxNode syntax,
     FieldSymbol fieldSymbol,
     Binder rootBinder
     )
 {
     Debug.Assert(containingSemanticModel != null);
     Debug.Assert(
         syntax.IsKind(SyntaxKind.VariableDeclarator) ||
         syntax.IsKind(SyntaxKind.EnumMemberDeclaration)
         );
     return(new InitializerSemanticModel(
                syntax,
                fieldSymbol,
                rootBinder,
                containingSemanticModel
                ));
 }
Exemplo n.º 37
0
 public SpeculativeMemberSemanticModel(
     SyntaxTreeSemanticModel parentSemanticModel,
     Symbol owner,
     TypeSyntax root,
     Binder rootBinder,
     NullableWalker.SnapshotManager snapshotManagerOpt,
     ImmutableDictionary <Symbol, Symbol> parentRemappedSymbolsOpt,
     int position
     )
     : base(
         root,
         owner,
         rootBinder,
         containingSemanticModelOpt: null,
         parentSemanticModelOpt: parentSemanticModel,
         snapshotManagerOpt,
         parentRemappedSymbolsOpt,
         speculatedPosition: position
         )
 {
     Debug.Assert(parentSemanticModel is not null);
 }
Exemplo n.º 38
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var binder = this.GetEnclosingBinder(position);
            if (binder == null)
            {
                speculativeModel = null;
                return false;
            }

            var methodSymbol = (MethodSymbol)this.MemberSymbol;
            binder = new ExecutableCodeBinder(statement, methodSymbol, binder);

            // local declaration statements need to be wrapped in a block so the local gets seen 
            if (!statement.IsKind(SyntaxKind.Block))
            {
                binder = new BlockBinder(methodSymbol, binder, new SyntaxList<StatementSyntax>(statement));
            }

            speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, position);
            return true;
        }
Exemplo n.º 39
0
        /// <summary>
        /// Creates a speculative AttributeSemanticModel that allows asking semantic questions about an attribute node that did not appear in the original source code.
        /// </summary>
        public static AttributeSemanticModel CreateSpeculative(
            SyntaxTreeSemanticModel parentSemanticModel,
            AttributeSyntax syntax,
            NamedTypeSymbol attributeType,
            AliasSymbol aliasOpt,
            Binder rootBinder,
            ImmutableDictionary <Symbol, Symbol> parentRemappedSymbolsOpt,
            int position
            )
        {
            Debug.Assert(parentSemanticModel != null);
            Debug.Assert(rootBinder != null);
            Debug.Assert(rootBinder.IsSemanticModelBinder);

            return(new AttributeSemanticModel(
                       syntax,
                       attributeType,
                       aliasOpt,
                       rootBinder,
                       parentSemanticModelOpt: parentSemanticModel,
                       parentRemappedSymbolsOpt: parentRemappedSymbolsOpt,
                       speculatedPosition: position
                       ));
        }
Exemplo n.º 40
0
 internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel)
 {
     // crefs can never legally appear within members.
     speculativeModel = null;
     return false;
 }
Exemplo n.º 41
0
        internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, TypeSyntax type, SpeculativeBindingOption bindingOption, out SemanticModel speculativeModel)
        {
            var expression = SyntaxFactory.GetStandaloneExpression(type);

            var binder = this.GetSpeculativeBinder(position, expression, bindingOption);
            if (binder != null)
            {
                speculativeModel = new SpeculativeMemberSemanticModel(parentModel, _memberSymbol, type, binder, position);
                return true;
            }

            speculativeModel = null;
            return false;
        }
        private bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CSharpSyntaxNode initializer, out SemanticModel speculativeModel)
        {
            Debug.Assert(initializer is EqualsValueClauseSyntax || initializer is ConstructorInitializerSyntax);

            var binder = this.GetEnclosingBinder(position);
            if (binder == null)
            {
                speculativeModel = null;
                return false;
            }

            speculativeModel = CreateSpeculative(parentModel, this.MemberSymbol, initializer, binder, position);
            return true;
        }
Exemplo n.º 43
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ArrowExpressionClauseSyntax expressionBody, out SemanticModel speculativeModel);
 internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
 internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ArrowExpressionClauseSyntax expressionBody, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
Exemplo n.º 46
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, EqualsValueClauseSyntax initializer, out SemanticModel speculativeModel);
Exemplo n.º 47
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            Binder binder = GetEnclosingBinder(position);
            if (binder?.InCref == true)
            {
                speculativeModel = SpeculativeSyntaxTreeSemanticModel.Create(parentModel, crefSyntax, binder, position);
                return true;
            }

            speculativeModel = null;
            return false;
        }
Exemplo n.º 48
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel);
Exemplo n.º 49
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, TypeSyntax type, SpeculativeBindingOption bindingOption, out SemanticModel speculativeModel);
Exemplo n.º 50
0
 internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
Exemplo n.º 51
0
 internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel)
 {
     return GetSpeculativeSemanticModelForMethodBody(parentModel, position, accessor.Body, out speculativeModel);
 }
Exemplo n.º 52
0
        internal sealed override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var model = this.GetMemberModel(position);
            if (model != null)
            {
                return model.TryGetSpeculativeSemanticModelForMethodBodyCore(parentModel, position, accessor, out speculativeModel);
            }

            speculativeModel = null;
            return false;
        }
Exemplo n.º 53
0
 internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, BaseMethodDeclarationSyntax method, out SemanticModel speculativeModel)
 {
     // CONSIDER: Do we want to ensure that speculated method and the original method have identical signatures?
     return GetSpeculativeSemanticModelForMethodBody(parentModel, position, method.Body, out speculativeModel);
 }
 internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
Exemplo n.º 55
0
        internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ArrowExpressionClauseSyntax expressionBody, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var model = this.GetMemberModel(position);
            if (model != null)
            {
                return model.TryGetSpeculativeSemanticModelCore(parentModel, position, expressionBody, out speculativeModel);
            }

            speculativeModel = null;
            return false;
        }
Exemplo n.º 56
0
        internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, TypeSyntax type, SpeculativeBindingOption bindingOption, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var model = this.GetMemberModel(position);
            if (model != null)
            {
                return model.TryGetSpeculativeSemanticModelCore(parentModel, position, type, bindingOption, out speculativeModel);
            }

            Binder binder = GetSpeculativeBinder(position, type, bindingOption);
            if (binder != null)
            {
                speculativeModel = SpeculativeSyntaxTreeSemanticModel.Create(parentModel, type, binder, position, bindingOption);
                return true;
            }

            speculativeModel = null;
            return false;
        }
Exemplo n.º 57
0
        internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out SemanticModel speculativeModel)
        {
            position = CheckAndAdjustPosition(position);

            var model = this.GetMemberModel(position);
            if (model != null)
            {
                return model.TryGetSpeculativeSemanticModelCore(parentModel, position, constructorInitializer, out speculativeModel);
            }

            speculativeModel = null;
            return false;
        }
Exemplo n.º 58
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel);
Exemplo n.º 59
0
 internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, EqualsValueClauseSyntax initializer, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
Exemplo n.º 60
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out SemanticModel speculativeModel);