本文整理汇总了C#中CSharpSyntaxNode.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# CSharpSyntaxNode.Contains方法的具体用法?C# CSharpSyntaxNode.Contains怎么用?C# CSharpSyntaxNode.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSharpSyntaxNode
的用法示例。
在下文中一共展示了CSharpSyntaxNode.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdjustStartingNodeAccordingToNewRoot
private static CSharpSyntaxNode AdjustStartingNodeAccordingToNewRoot(CSharpSyntaxNode startingNode, CSharpSyntaxNode root)
{
CSharpSyntaxNode result = startingNode.Contains(root) ? root : startingNode;
if (result != root && !root.Contains(result))
{
result = root;
}
return result;
}
示例2: GetEnclosingBinder
private static Binder GetEnclosingBinder(CSharpSyntaxNode node, int position, Binder rootBinder, CSharpSyntaxNode root)
{
if (node == root)
{
return rootBinder.GetBinder(node) ?? rootBinder;
}
Debug.Assert(root.Contains(node));
ExpressionSyntax typeOfArgument = null;
CSharpSyntaxNode unexpectedAnonymousFunction = null;
// Keep track of which fix-up should be applied first. If we see a typeof expression inside an unexpected
// anonymous function, that the typeof binder should be innermost (i.e. should have the unexpected
// anonymous function binder as its Next).
// NOTE: only meaningful if typeOfArgument is non-null;
bool typeOfEncounteredBeforeUnexpectedAnonymousFunction = false;
Binder binder = null;
for (var current = node; binder == null; current = current.ParentOrStructuredTriviaParent)
{
Debug.Assert(current != null); // Why were we asked for an enclosing binder for a node outside our root?
StatementSyntax stmt = current as StatementSyntax;
TypeOfExpressionSyntax typeOfExpression;
if (stmt != null)
{
if (LookupPosition.IsInStatementScope(position, stmt))
{
binder = rootBinder.GetBinder(current);
if (binder != null)
{
binder = AdjustBinderForPositionWithinStatement(position, binder, stmt);
}
}
}
else if (current.Kind() == SyntaxKind.CatchClause)
{
if (LookupPosition.IsInCatchBlockScope(position, (CatchClauseSyntax)current))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.Kind() == SyntaxKind.CatchFilterClause)
{
if (LookupPosition.IsInCatchFilterScope(position, (CatchFilterClauseSyntax)current))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.IsAnonymousFunction())
{
if (LookupPosition.IsInAnonymousFunctionOrQuery(position, current))
{
binder = rootBinder.GetBinder(current);
// This should only happen in error scenarios. For example, C# does not allow array rank
// specifiers in types, (e.g. int[1] x;), but the syntax model does. In order to construct
// an appropriate binder chain for the anonymous method body, we need to construct an
// ExecutableCodeBinder.
if (binder == null && unexpectedAnonymousFunction == null && current != root)
{
unexpectedAnonymousFunction = current;
}
}
}
else if (current.Kind() == SyntaxKind.TypeOfExpression &&
typeOfArgument == null &&
LookupPosition.IsBetweenTokens(
position,
(typeOfExpression = (TypeOfExpressionSyntax)current).OpenParenToken,
typeOfExpression.CloseParenToken))
{
typeOfArgument = typeOfExpression.Type;
typeOfEncounteredBeforeUnexpectedAnonymousFunction = unexpectedAnonymousFunction == null;
}
else if (current.Kind() == SyntaxKind.SwitchSection)
{
if (LookupPosition.IsInSwitchSectionScope(position, (SwitchSectionSyntax)current))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.Kind() == SyntaxKind.ArgumentList)
{
var argList = (ArgumentListSyntax)current;
if (LookupPosition.IsBetweenTokens(position, argList.OpenParenToken, argList.CloseParenToken))
{
binder = rootBinder.GetBinder(current);
}
}
else if (current.Kind() == SyntaxKind.EqualsValueClause)
{
binder = rootBinder.GetBinder(current);
}
else if (current.Kind() == SyntaxKind.Attribute)
{
binder = rootBinder.GetBinder(current);
}
//.........这里部分代码省略.........