Browse Source

Fix tokens used for catch-when clause.

pull/1920/head
Siegfried Pammer 5 years ago
parent
commit
e029266d40
  1. 4
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  2. 12
      ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs

4
ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs

@ -1812,11 +1812,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -1812,11 +1812,11 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
Space();
WriteKeyword(CatchClause.WhenKeywordRole);
Space(policy.SpaceBeforeIfParentheses);
LPar();
WriteToken(CatchClause.CondLPar);
Space(policy.SpacesWithinIfParentheses);
catchClause.Condition.AcceptVisitor(this);
Space(policy.SpacesWithinIfParentheses);
RPar();
WriteToken(CatchClause.CondRPar);
}
WriteBlock(catchClause.Body, policy.StatementBraceStyle);
EndNode(catchClause);

12
ICSharpCode.Decompiler/CSharp/Syntax/Statements/TryCatchStatement.cs

@ -90,6 +90,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -90,6 +90,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public static readonly TokenRole CatchKeywordRole = new TokenRole("catch");
public static readonly TokenRole WhenKeywordRole = new TokenRole("when");
public static readonly Role<Expression> ConditionRole = Roles.Condition;
public static readonly TokenRole CondLPar = new TokenRole("(");
public static readonly TokenRole CondRPar = new TokenRole(")");
#region Null
public new static readonly CatchClause Null = new NullCatchClause();
@ -195,7 +197,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -195,7 +197,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
if (string.IsNullOrEmpty(value))
SetChildByRole(Roles.Identifier, null);
else
SetChildByRole (Roles.Identifier, Identifier.Create (value));
SetChildByRole(Roles.Identifier, Identifier.Create(value));
}
}
@ -216,11 +218,19 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -216,11 +218,19 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
get { return GetChildByRole(WhenKeywordRole); }
}
public CSharpTokenNode CondLParToken {
get { return GetChildByRole(CondLPar); }
}
public Expression Condition {
get { return GetChildByRole(ConditionRole); }
set { SetChildByRole(ConditionRole, value); }
}
public CSharpTokenNode CondRParToken {
get { return GetChildByRole(CondRPar); }
}
public BlockStatement Body {
get { return GetChildByRole(Roles.Body); }
set { SetChildByRole(Roles.Body, value); }

Loading…
Cancel
Save