diff --git a/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs b/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs new file mode 100644 index 0000000000..32dc7d7456 --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs @@ -0,0 +1,27 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under MIT X11 license (for details please see \doc\license.txt) + +using System; +using System.IO; + +namespace ICSharpCode.NRefactory.VB.Ast +{ + public class GoToStatement : Statement + { + /// either PrimitiveExpression or IdentifierExpression + public Expression Label { + get { return GetChildByRole(Roles.Expression); } + set { SetChildByRole(Roles.Expression, value); } + } + + protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) + { + throw new NotImplementedException(); + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitGoToStatement(this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs b/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs index f613a76788..589fea5a6c 100644 --- a/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs +++ b/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs @@ -11,9 +11,10 @@ namespace ICSharpCode.NRefactory.VB.Ast /// public class LabelDeclarationStatement : Statement { - public Identifier Label { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } + /// either PrimitiveExpression or IdentifierExpression + public Expression Label { + get { return GetChildByRole(Roles.Expression); } + set { SetChildByRole(Roles.Expression, value); } } public VBTokenNode Colon { @@ -28,7 +29,7 @@ namespace ICSharpCode.NRefactory.VB.Ast protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) { LabelDeclarationStatement o = other as LabelDeclarationStatement; - return o != null && MatchString(this.Label.Name, o.Label.Name); + return o != null && this.Label.DoMatch(o.Label, match); } } } diff --git a/ICSharpCode.NRefactory.VB/IAstVisitor.cs b/ICSharpCode.NRefactory.VB/IAstVisitor.cs index 4d7e638995..875ff210a5 100644 --- a/ICSharpCode.NRefactory.VB/IAstVisitor.cs +++ b/ICSharpCode.NRefactory.VB/IAstVisitor.cs @@ -102,5 +102,7 @@ namespace ICSharpCode.NRefactory.VB { S VisitComposedType(ComposedType composedType, T data); S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data); S VisitSimpleType(SimpleType simpleType, T data); + + S VisitGoToStatement(GoToStatement goToStatement, T data); } } diff --git a/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj index 5a14a81400..0cccd7a54d 100644 --- a/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ b/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj @@ -91,6 +91,7 @@ + diff --git a/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs b/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs index e73946064f..3de803f957 100644 --- a/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs +++ b/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs @@ -1344,7 +1344,12 @@ namespace ICSharpCode.NRefactory.VB public object VisitLabelDeclarationStatement(LabelDeclarationStatement labelDeclarationStatement, object data) { - throw new NotImplementedException(); + StartNode(labelDeclarationStatement); + + labelDeclarationStatement.Label.AcceptVisitor(this, data); + WriteToken(":", LabelDeclarationStatement.Roles.Colon); + + return EndNode(labelDeclarationStatement); } public object VisitLocalDeclarationStatement(LocalDeclarationStatement localDeclarationStatement, object data) @@ -2247,5 +2252,15 @@ namespace ICSharpCode.NRefactory.VB return EndNode(usingStatement); } + + public object VisitGoToStatement(GoToStatement goToStatement, object data) + { + StartNode(goToStatement); + + WriteKeyword("GoTo"); + goToStatement.Label.AcceptVisitor(this, data); + + return EndNode(goToStatement); + } } } diff --git a/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs b/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs index 48dc0c1d59..bfd373a765 100644 --- a/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs +++ b/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs @@ -175,6 +175,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors op = BinaryOperatorType.LessThanOrEqual; break; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Add: + // TODO might be string concatenation op = BinaryOperatorType.Add; break; case ICSharpCode.NRefactory.CSharp.BinaryOperatorType.Subtract: @@ -860,7 +861,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors public AstNode VisitGotoStatement(CSharp.GotoStatement gotoStatement, object data) { - throw new NotImplementedException(); + return EndNode(gotoStatement, new GoToStatement() { Label = new IdentifierExpression() { Identifier = gotoStatement.Label } }); } public AstNode VisitIfElseStatement(CSharp.IfElseStatement ifElseStatement, object data) @@ -876,7 +877,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors public AstNode VisitLabelStatement(CSharp.LabelStatement labelStatement, object data) { - throw new NotImplementedException(); + return EndNode(labelStatement, new LabelDeclarationStatement() { Label = new IdentifierExpression() { Identifier = labelStatement.Label } }); } public AstNode VisitLockStatement(CSharp.LockStatement lockStatement, object data)