本文整理汇总了C#中ParenthesizedExpression类的典型用法代码示例。如果您正苦于以下问题:C# ParenthesizedExpression类的具体用法?C# ParenthesizedExpression怎么用?C# ParenthesizedExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParenthesizedExpression类属于命名空间,在下文中一共展示了ParenthesizedExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitParenthesizedExpression
public override void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression)
{
base.VisitParenthesizedExpression(parenthesizedExpression);
if (parenthesizedExpression.Expression is PrimitiveExpression)
parenthesizedExpression.ReplaceWith(parenthesizedExpression.Expression);
}
示例2: Visit
public override object Visit(ParenthesizedExpression parenthesizedExpression, object data)
{
if (parenthesizedExpression == null) {
return null;
}
return parenthesizedExpression.Expression.AcceptVisitor(this, data);
}
示例3: OptimizeExpression
public static Expression OptimizeExpression(Expression node)
{
var root = new ParenthesizedExpression(node.Clone());
var visitors = GetVisitors();
string oldText = null;
while (root.GetText() != oldText)
{
oldText = root.GetText();
foreach (var visitor in visitors)
root.Expression.AcceptVisitor(visitor);
}
return root.Expression;
}
示例4: GetValueFromParenthesizedExpression
public static dynamic GetValueFromParenthesizedExpression(ParenthesizedExpression expr)
{
return GetValueFromExpression(expr.Expression);
}
示例5: VisitParenthesizedExpression
public void VisitParenthesizedExpression(ParenthesizedExpression parensExpr)
{
parensExpr.Expression.AcceptWalker(this);
}
示例6: PostWalk
protected internal virtual void PostWalk(ParenthesizedExpression node) { }
示例7: Visit
public override object Visit (Mono.CSharpPs.ParenthesizedExpression parenthesizedExpression)
{
var result = new ParenthesizedExpression ();
var location = LocationsBag.GetLocations (parenthesizedExpression);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LPar), Roles.LPar);
if (parenthesizedExpression.Expr != null)
result.AddChild ((Expression)parenthesizedExpression.Expr.Accept (this), Roles.Expression);
if (location != null && location.Count > 1)
result.AddChild (new CSharpTokenNode (Convert (location [1]), Roles.RPar), Roles.RPar);
return result;
}
示例8: VisitParenthesizedExpression
public virtual void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression)
{
if (this.ThrowException)
{
throw (Exception)this.CreateException(parenthesizedExpression);
}
}
示例9: actionPerformed
/**
* Call back method that must be called as soon as the given <code>
* ParenthesizedExpression</code> object has been traversed.
*
* @param pParenthesizedExpression The <code>ParenthesizedExpression</code>
* object that has just been traversed.
*/
public void actionPerformed(
ParenthesizedExpression pParenthesizedExpression)
{
// Nothing to do.
}
示例10: VisitParenthesizedExpression
public override void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression)
{
ForceSpacesAfter(parenthesizedExpression.LParToken, policy.SpacesWithinParentheses);
ForceSpacesBefore(parenthesizedExpression.RParToken, policy.SpacesWithinParentheses);
base.VisitParenthesizedExpression(parenthesizedExpression);
}
示例11: VisitParenthesizedExpression
public override void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression)
{
new ParenthesizedBlock(this, parenthesizedExpression).Emit();
}
示例12: VisitParenthesizedExpression
public override void VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression)
{
var lp = parenthesizedExpression.LParToken;
var expr = parenthesizedExpression.Expression;
int extraSpaces = 0;
if (lp.StartLocation.Line == expr.StartLocation.Line) {
ForceSpacesAfter(lp, policy.SpacesWithinParentheses);
} else {
extraSpaces += options.IndentSize;
curIndent.ExtraSpaces += extraSpaces;
FixIndentation(expr);
}
base.VisitParenthesizedExpression(parenthesizedExpression);
var rp = parenthesizedExpression.RParToken;
curIndent.ExtraSpaces -= extraSpaces;
if (rp.StartLocation.Line == expr.EndLocation.Line) {
ForceSpacesBefore(rp, policy.SpacesWithinParentheses);
} else {
FixIndentation(rp);
}
}
示例13: VisitParenthesizedExpression
public override StringBuilder VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, int data)
{
throw new NotImplementedException();
}
示例14: CheckParenthesizedExpression
/// <summary>
/// Checks the given parenthesized expression to make sure that it is not unnecessary.
/// </summary>
/// <param name="element">The element containing the expression.</param>
/// <param name="parenthesizedExpression">The parenthesized expression to check.</param>
private void CheckParenthesizedExpression(Element element, ParenthesizedExpression parenthesizedExpression)
{
Param.AssertNotNull(element, "element");
Param.AssertNotNull(parenthesizedExpression, "parenthesizedExpression");
// Check the type of the inner expression to determine if it is one of types allowed to be wrapped within parenthesis.
if (parenthesizedExpression.InnerExpression != null)
{
// The following types of expressions are allowed to be placed within a set of parenthesis.
Expression innerExpression = parenthesizedExpression.InnerExpression;
if (innerExpression.ExpressionType != ExpressionType.Arithmetic &&
innerExpression.ExpressionType != ExpressionType.As &&
innerExpression.ExpressionType != ExpressionType.Assignment &&
innerExpression.ExpressionType != ExpressionType.Cast &&
innerExpression.ExpressionType != ExpressionType.Conditional &&
innerExpression.ExpressionType != ExpressionType.ConditionalLogical &&
innerExpression.ExpressionType != ExpressionType.Decrement &&
innerExpression.ExpressionType != ExpressionType.Increment &&
innerExpression.ExpressionType != ExpressionType.Is &&
innerExpression.ExpressionType != ExpressionType.Lambda &&
innerExpression.ExpressionType != ExpressionType.Logical &&
innerExpression.ExpressionType != ExpressionType.New &&
innerExpression.ExpressionType != ExpressionType.NewArray &&
innerExpression.ExpressionType != ExpressionType.NullCoalescing &&
innerExpression.ExpressionType != ExpressionType.Query &&
innerExpression.ExpressionType != ExpressionType.Relational &&
innerExpression.ExpressionType != ExpressionType.Unary &&
innerExpression.ExpressionType != ExpressionType.UnsafeAccess)
{
this.AddViolation(element, parenthesizedExpression.LineNumber, Rules.StatementMustNotUseUnnecessaryParenthesis);
}
else
{
// These types of expressions are allowed in some cases to be surrounded by parenthesis,
// as long as the parenthesized expression is within another expression. They are not allowed
// to be within parenthesis within a variable declarator expression. For example:
// int x = (2 + 3);
if (!(parenthesizedExpression.Parent is Expression) || parenthesizedExpression.Parent is VariableDeclaratorExpression)
{
this.AddViolation(element, parenthesizedExpression.LineNumber, Rules.StatementMustNotUseUnnecessaryParenthesis);
}
else
{
// This is also not allowed when the expression is on the right-hand side of an assignment.
AssignmentExpression assignment = parenthesizedExpression.Parent as AssignmentExpression;
if (assignment != null && assignment.RightHandSide == parenthesizedExpression)
{
this.AddViolation(element, parenthesizedExpression.LineNumber, Rules.StatementMustNotUseUnnecessaryParenthesis);
}
}
}
}
}
示例15: SimpleNonInvocationExpression
void SimpleNonInvocationExpression(
#line 1645 "VBNET.ATG"
out Expression pexpr) {
#line 1647 "VBNET.ATG"
Expression expr;
TypeReference type = null;
string name = String.Empty;
pexpr = null;
if (StartOf(32)) {
switch (la.kind) {
case 3: {
lexer.NextToken();
#line 1655 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 4: {
lexer.NextToken();
#line 1656 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 7: {
lexer.NextToken();
#line 1657 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 6: {
lexer.NextToken();
#line 1658 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 5: {
lexer.NextToken();
#line 1659 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 9: {
lexer.NextToken();
#line 1660 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 8: {
lexer.NextToken();
#line 1661 "VBNET.ATG"
pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };
break;
}
case 202: {
lexer.NextToken();
#line 1663 "VBNET.ATG"
pexpr = new PrimitiveExpression(true, "true");
break;
}
case 109: {
lexer.NextToken();
#line 1664 "VBNET.ATG"
pexpr = new PrimitiveExpression(false, "false");
break;
}
case 151: {
lexer.NextToken();
#line 1665 "VBNET.ATG"
pexpr = new PrimitiveExpression(null, "null");
break;
}
case 25: {
lexer.NextToken();
Expr(
#line 1666 "VBNET.ATG"
out expr);
Expect(26);
#line 1666 "VBNET.ATG"
pexpr = new ParenthesizedExpression(expr);
break;
}
case 2: case 45: case 49: case 51: case 52: case 53: case 54: case 57: case 74: case 85: case 91: case 94: case 103: case 108: case 113: case 120: case 126: case 130: case 133: case 156: case 162: case 169: case 188: case 197: case 198: case 208: case 209: case 215: {
Identifier();
#line 1668 "VBNET.ATG"
pexpr = new IdentifierExpression(t.val);
pexpr.StartLocation = t.Location; pexpr.EndLocation = t.EndLocation;
//.........这里部分代码省略.........