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;
        }
        /// <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);
        }
 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));
        }
Beispiel #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)
 {
 }
Beispiel #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));
        }
        /// <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);
        }
 internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     AccessorDeclarationSyntax accessor,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Beispiel #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));
        }
        /// <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));
 }
        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;
        }
Beispiel #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));
 }
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     PrimaryConstructorBaseTypeSyntax constructorInitializer,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Beispiel #17
0
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     EqualsValueClauseSyntax initializer,
     out SemanticModel?speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     ArrowExpressionClauseSyntax expressionBody,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
 internal override bool TryGetSpeculativeSemanticModelCore(
     SyntaxTreeSemanticModel parentModel,
     int position,
     StatementSyntax statement,
     out SemanticModel speculativeModel
     )
 {
     speculativeModel = null;
     return(false);
 }
Beispiel #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));
        }
        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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #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
                ));
 }
        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);
        }
 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
                ));
 }
Beispiel #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);
        }
 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
                ));
 }
Beispiel #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);
        }
Beispiel #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
                ));
 }
 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
                ));
 }
Beispiel #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);
 }
        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;
        }
Beispiel #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
                       ));
        }
 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;
 }
        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;
        }
Beispiel #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;
 }
Beispiel #46
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, EqualsValueClauseSyntax initializer, out SemanticModel speculativeModel);
        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;
        }
Beispiel #48
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, CrefSyntax crefSyntax, out SemanticModel speculativeModel);
Beispiel #49
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, TypeSyntax type, SpeculativeBindingOption bindingOption, out SemanticModel speculativeModel);
 internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
 internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel)
 {
     return GetSpeculativeSemanticModelForMethodBody(parentModel, position, accessor.Body, out speculativeModel);
 }
        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;
        }
 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;
 }
        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;
        }
        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;
        }
        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;
        }
Beispiel #58
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, StatementSyntax statement, out SemanticModel speculativeModel);
 internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, EqualsValueClauseSyntax initializer, out SemanticModel speculativeModel)
 {
     speculativeModel = null;
     return false;
 }
Beispiel #60
0
 internal abstract bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, ConstructorInitializerSyntax constructorInitializer, out SemanticModel speculativeModel);