本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.SyntaxTreeSemanticModel类的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTreeSemanticModel类的具体用法?C# SyntaxTreeSemanticModel怎么用?C# SyntaxTreeSemanticModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyntaxTreeSemanticModel类属于Microsoft.CodeAnalysis.CSharp命名空间,在下文中一共展示了SyntaxTreeSemanticModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSpeculativeSemanticModelForMethodBody
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;
}
示例2: CreateSpeculative
/// <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);
}
示例3: MethodBodySemanticModel
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);
}
示例4: InitializerSemanticModel
// 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)
{
}
示例5: CreateSpeculative
/// <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);
}
示例6: GetSpeculativeSemanticModelForMethodBody
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;
}
示例7: CreateSpeculative
/// <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);
}
示例8: MemberSemanticModel
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;
}
示例9: TryGetSpeculativeSemanticModelCore
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;
}
示例10: TryGetSpeculativeSemanticModelCore
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;
}
示例11: TryGetSpeculativeSemanticModelCore
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;
}
示例12: TryGetSpeculativeSemanticModelForMethodBodyCore
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;
}
示例13: TryGetSpeculativeSemanticModelForMethodBodyCore
internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel)
{
speculativeModel = null;
return false;
}
示例14: TryGetSpeculativeSemanticModelForMethodBodyCore
internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel)
{
return GetSpeculativeSemanticModelForMethodBody(parentModel, position, accessor.Body, out speculativeModel);
}
示例15: TryGetSpeculativeSemanticModelCore
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;
}