本文整理汇总了C#中SpeculativeBindingOption类的典型用法代码示例。如果您正苦于以下问题:C# SpeculativeBindingOption类的具体用法?C# SpeculativeBindingOption怎么用?C# SpeculativeBindingOption使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpeculativeBindingOption类属于命名空间,在下文中一共展示了SpeculativeBindingOption类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SpeculativeSyntaxTreeSemanticModel
private SpeculativeSyntaxTreeSemanticModel(CSharpSemanticModel parentSemanticModel, CSharpSyntaxNode root, Binder rootBinder, int position, SpeculativeBindingOption bindingOption)
: base(parentSemanticModel.Compilation, parentSemanticModel.SyntaxTree, root.SyntaxTree)
{
this.parentSemanticModel = parentSemanticModel;
this.root = root;
this.rootBinder = rootBinder;
this.position = position;
this.bindingOption = bindingOption;
}
示例2: CreateCore
private static SpeculativeSyntaxTreeSemanticModel CreateCore(CSharpSemanticModel 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;
}
示例3: TestGetSpeculativeSemanticModelForTypeSyntax_Common
private static void TestGetSpeculativeSemanticModelForTypeSyntax_Common(
SemanticModel model,
int position,
TypeSyntax speculatedTypeSyntax,
SpeculativeBindingOption bindingOption,
SymbolKind expectedSymbolKind,
string expectedTypeDislayString)
{
Assert.False(model.IsSpeculativeSemanticModel);
Assert.Null(model.ParentModel);
Assert.Equal(0, model.OriginalPositionForSpeculation);
SemanticModel speculativeModel;
var success = model.TryGetSpeculativeSemanticModel(position, speculatedTypeSyntax, out speculativeModel, bindingOption);
Assert.True(success);
Assert.NotNull(speculativeModel);
Assert.True(speculativeModel.IsSpeculativeSemanticModel);
Assert.Equal(model, speculativeModel.ParentModel);
Assert.NotNull(speculativeModel);
Assert.Equal(position, speculativeModel.OriginalPositionForSpeculation);
var symbol = speculativeModel.GetSymbolInfo(speculatedTypeSyntax).Symbol;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
var typeSymbol = speculativeModel.GetTypeInfo(speculatedTypeSyntax).Type;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
if (speculatedTypeSyntax.Kind == SyntaxKind.QualifiedName)
{
var right = ((QualifiedNameSyntax)speculatedTypeSyntax).Right;
symbol = speculativeModel.GetSymbolInfo(right).Symbol;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
typeSymbol = speculativeModel.GetTypeInfo(right).Type;
Assert.NotNull(symbol);
Assert.Equal(expectedSymbolKind, symbol.Kind);
Assert.Equal(expectedTypeDislayString, symbol.ToDisplayString());
}
}
示例4: GetSpeculativeSymbolInfo
/// <summary>
/// Binds the node in the context of the specified location and get semantic information
/// such as type, symbols and diagnostics. This method is used to get semantic information
/// about an expression that did not actually appear in the source code.
/// </summary>
/// <param name="semanticModel"></param>
/// <param name="position">A character position used to identify a declaration scope and
/// accessibility. This character position must be within the FullSpan of the Root syntax
/// node in this SemanticModel.
/// </param>
/// <param name="expression">A syntax node that represents a parsed expression. This syntax
/// node need not and typically does not appear in the source code referred to SemanticModel
/// instance.</param>
/// <param name="bindingOption">Indicates whether to binding the expression as a full expressions,
/// or as a type or namespace. If SpeculativeBindingOption.BindAsTypeOrNamespace is supplied, then
/// expression should derive from TypeSyntax.</param>
/// <returns>The semantic information for the topmost node of the expression.</returns>
/// <remarks>The passed in expression is interpreted as a stand-alone expression, as if it
/// appeared by itself somewhere within the scope that encloses "position".</remarks>
public static SymbolInfo GetSpeculativeSymbolInfo(this SemanticModel semanticModel, int position, SyntaxNode expression, SpeculativeBindingOption bindingOption)
{
return semanticModel.GetSpeculativeSymbolInfo(position, expression, bindingOption);
}
示例5: GetSpeculativeAliasInfoCore
/// <summary>
/// Binds the name in the context of the specified location and sees if it resolves to an
/// alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
/// </summary>
/// <param name="position">A character position used to identify a declaration scope and
/// accessibility. This character position must be within the FullSpan of the Root syntax
/// node in this SemanticModel.
/// </param>
/// <param name="nameSyntax">A syntax node that represents a name. This syntax
/// node need not and typically does not appear in the source code referred to by the
/// SemanticModel instance.</param>
/// <param name="bindingOption">Indicates whether to binding the name as a full expression,
/// or as a type or namespace. If SpeculativeBindingOption.BindAsTypeOrNamespace is supplied, then
/// expression should derive from TypeSyntax.</param>
/// <remarks>The passed in name is interpreted as a stand-alone name, as if it
/// appeared by itself somewhere within the scope that encloses "position".</remarks>
protected abstract IAliasSymbol GetSpeculativeAliasInfoCore(int position, SyntaxNode nameSyntax, SpeculativeBindingOption bindingOption);
示例6: GetSpeculativeTypeInfoCore
/// <summary>
/// Binds the node in the context of the specified location and get semantic information
/// such as type, symbols and diagnostics. This method is used to get semantic information
/// about an expression that did not actually appear in the source code.
/// </summary>
/// <param name="position">A character position used to identify a declaration scope and
/// accessibility. This character position must be within the FullSpan of the Root syntax
/// node in this SemanticModel.
/// </param>
/// <param name="expression">A syntax node that represents a parsed expression. This syntax
/// node need not and typically does not appear in the source code referred to SemanticModel
/// instance.</param>
/// <param name="bindingOption">Indicates whether to binding the expression as a full expressions,
/// or as a type or namespace. If SpeculativeBindingOption.BindAsTypeOrNamespace is supplied, then
/// expression should derive from TypeSyntax.</param>
/// <returns>The semantic information for the topmost node of the expression.</returns>
/// <remarks>The passed in expression is interpreted as a stand-alone expression, as if it
/// appeared by itself somewhere within the scope that encloses "position".</remarks>
protected abstract TypeInfo GetSpeculativeTypeInfoCore(int position, SyntaxNode expression, SpeculativeBindingOption bindingOption);
示例7: GetSpeculativeTypeInfo
/// <summary>
/// Binds the node in the context of the specified location and get semantic information
/// such as type, symbols and diagnostics. This method is used to get semantic information
/// about an expression that did not actually appear in the source code.
/// </summary>
/// <param name="position">A character position used to identify a declaration scope and
/// accessibility. This character position must be within the FullSpan of the Root syntax
/// node in this SemanticModel.
/// </param>
/// <param name="expression">A syntax node that represents a parsed expression. This syntax
/// node need not and typically does not appear in the source code referred to SemanticModel
/// instance.</param>
/// <param name="bindingOption">Indicates whether to binding the expression as a full expressions,
/// or as a type or namespace. If SpeculativeBindingOption.BindAsTypeOrNamespace is supplied, then
/// expression should derive from TypeSyntax.</param>
/// <returns>The semantic information for the topmost node of the expression.</returns>
/// <remarks>The passed in expression is interpreted as a stand-alone expression, as if it
/// appeared by itself somewhere within the scope that encloses "position".</remarks>
internal TypeInfo GetSpeculativeTypeInfo(int position, SyntaxNode expression, SpeculativeBindingOption bindingOption)
{
return GetSpeculativeTypeInfoCore(position, expression, bindingOption);
}
示例8: GetSpeculativeAliasInfo
/// <summary>
/// Binds the name in the context of the specified location and sees if it resolves to an
/// alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
/// </summary>
/// <param name="position">A character position used to identify a declaration scope and
/// accessibility. This character position must be within the FullSpan of the Root syntax
/// node in this SemanticModel.
/// </param>
/// <param name="nameSyntax">A syntax node that represents a name. This syntax
/// node need not and typically does not appear in the source code referred to by the
/// SemanticModel instance.</param>
/// <param name="bindingOption">Indicates whether to binding the name as a full expression,
/// or as a type or namespace. If SpeculativeBindingOption.BindAsTypeOrNamespace is supplied, then
/// expression should derive from TypeSyntax.</param>
/// <remarks>The passed in name is interpreted as a stand-alone name, as if it
/// appeared by itself somewhere within the scope that encloses "position".</remarks>
internal IAliasSymbol GetSpeculativeAliasInfo(int position, SyntaxNode nameSyntax, SpeculativeBindingOption bindingOption)
{
return GetSpeculativeAliasInfoCore(position, nameSyntax, bindingOption);
}
示例9: 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;
}
示例10: GetSpeculativeAliasInfo
/// <summary>
/// Binds the name in the context of the specified location and sees if it resolves to an
/// alias name. If it does, return the AliasSymbol corresponding to it. Otherwise, return null.
/// </summary>
/// <param name="semanticModel"></param>
/// <param name="position">A character position used to identify a declaration scope and
/// accessibility. This character position must be within the FullSpan of the Root syntax
/// node in this SemanticModel.
/// </param>
/// <param name="nameSyntax">A syntax node that represents a name. This syntax
/// node need not and typically does not appear in the source code referred to by the
/// SemanticModel instance.</param>
/// <param name="bindingOption">Indicates whether to binding the name as a full expression,
/// or as a type or namespace. If SpeculativeBindingOption.BindAsTypeOrNamespace is supplied, then
/// expression should derive from TypeSyntax.</param>
/// <remarks>The passed in name is interpreted as a stand-alone name, as if it
/// appeared by itself somewhere within the scope that encloses "position".</remarks>
public static IAliasSymbol GetSpeculativeAliasInfo(this SemanticModel semanticModel, int position, SyntaxNode nameSyntax, SpeculativeBindingOption bindingOption)
{
return semanticModel.GetSpeculativeAliasInfo(position, nameSyntax, bindingOption);
}
示例11: TryGetSpeculativeSemanticModelCore
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;
}
示例12: Create
public static SpeculativeSyntaxTreeSemanticModel Create(CSharpSemanticModel parentSemanticModel, TypeSyntax root, Binder rootBinder, int position, SpeculativeBindingOption bindingOption)
{
return CreateCore(parentSemanticModel, root, rootBinder, position, bindingOption);
}