Browse Source

C# AST: Add C# 6 property initializer

pull/734/merge
Siegfried Pammer 8 years ago
parent
commit
15905a8f03
  1. 7
      ICSharpCode.Decompiler/CSharp/OutputVisitor/CSharpOutputVisitor.cs
  2. 14
      ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/PropertyDeclaration.cs

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

@ -2079,6 +2079,13 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
} }
} }
CloseBrace(policy.PropertyBraceStyle); CloseBrace(policy.PropertyBraceStyle);
if (!propertyDeclaration.Initializer.IsNull) {
Space(policy.SpaceAroundAssignment);
WriteToken(Roles.Assign);
Space(policy.SpaceAroundAssignment);
propertyDeclaration.Initializer.AcceptVisitor(this);
Semicolon();
}
NewLine(); NewLine();
EndNode(propertyDeclaration); EndNode(propertyDeclaration);
} }

14
ICSharpCode.Decompiler/CSharp/Syntax/TypeMembers/PropertyDeclaration.cs

@ -65,7 +65,16 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
public CSharpTokenNode RBraceToken { public CSharpTokenNode RBraceToken {
get { return GetChildByRole (Roles.RBrace); } get { return GetChildByRole (Roles.RBrace); }
} }
public CSharpTokenNode AssignToken {
get { return GetChildByRole(Roles.Assign); }
}
public Expression Initializer {
get { return GetChildByRole(Roles.Expression); }
set { SetChildByRole(Roles.Expression, value); }
}
public override void AcceptVisitor (IAstVisitor visitor) public override void AcceptVisitor (IAstVisitor visitor)
{ {
visitor.VisitPropertyDeclaration (this); visitor.VisitPropertyDeclaration (this);
@ -87,7 +96,8 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return o != null && MatchString(this.Name, o.Name) return o != null && MatchString(this.Name, o.Name)
&& this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match) && this.MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match)
&& this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) && this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match)
&& this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match); && this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match)
&& this.Initializer.DoMatch(o.Initializer, match);
} }
} }
} }

Loading…
Cancel
Save