diff --git a/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs b/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs new file mode 100644 index 0000000000..4ec41f6284 --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs @@ -0,0 +1,50 @@ +// 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 +{ + /// + /// Continue ( Do | For | While ) + /// + public class ContinueStatement : Statement + { + public static readonly Role ContinueKindTokenRole = new Role("ContinueKindToken"); + + public ContinueKind ContinueKind { get; set; } + + public VBTokenNode ContinueToken { + get { return GetChildByRole (Roles.Keyword); } + } + + public VBTokenNode ContinueKindToken { + get { return GetChildByRole (ContinueKindTokenRole); } + } + + public ContinueStatement(ContinueKind kind) + { + this.ContinueKind = kind; + } + + public override S AcceptVisitor(IAstVisitor visitor, T data) + { + return visitor.VisitContinueStatement(this, data); + } + + protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) + { + ContinueStatement o = other as ContinueStatement; + return o != null && this.ContinueKind == o.ContinueKind; + } + } + + public enum ContinueKind + { + None, + Do, + For, + While + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs b/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs index 5868523259..b5f7c0ff3c 100644 --- a/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs +++ b/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs @@ -11,7 +11,7 @@ namespace ICSharpCode.NRefactory.VB.Ast /// public class ExitStatement : Statement { - public static readonly Role ExitKindTokenRole = new Role("ExitKindTokenRole"); + public static readonly Role ExitKindTokenRole = new Role("ExitKindToken"); public ExitKind ExitKind { get; set; } diff --git a/ICSharpCode.NRefactory.VB/IAstVisitor.cs b/ICSharpCode.NRefactory.VB/IAstVisitor.cs index bf969a8430..c1f18edfbc 100644 --- a/ICSharpCode.NRefactory.VB/IAstVisitor.cs +++ b/ICSharpCode.NRefactory.VB/IAstVisitor.cs @@ -85,6 +85,7 @@ namespace ICSharpCode.NRefactory.VB { S VisitForStatement(ForStatement forStatement, T data); S VisitForEachStatement(ForEachStatement forEachStatement, T data); S VisitExitStatement(ExitStatement exitStatement, T data); + S VisitContinueStatement(ContinueStatement continueStatement, T data); S VisitSelectStatement(SelectStatement selectStatement, T data); S VisitYieldStatement(YieldStatement yieldStatement, T data); S VisitVariableInitializer(VariableInitializer variableInitializer, T data); diff --git a/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj index 2f3ab9777e..ef2ae0cb01 100644 --- a/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ b/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj @@ -95,6 +95,7 @@ + diff --git a/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs b/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs index 394aa98bc3..f48f8e2f07 100644 --- a/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs +++ b/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs @@ -2319,5 +2319,28 @@ namespace ICSharpCode.NRefactory.VB return EndNode(queryExpression); } + + public object VisitContinueStatement(ContinueStatement continueStatement, object data) + { + StartNode(continueStatement); + + WriteKeyword("Continue"); + + switch (continueStatement.ContinueKind) { + case ContinueKind.Do: + WriteKeyword("Do"); + break; + case ContinueKind.For: + WriteKeyword("For"); + break; + case ContinueKind.While: + WriteKeyword("While"); + break; + default: + throw new Exception("Invalid value for ContinueKind"); + } + + return EndNode(continueStatement); + } } } diff --git a/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs b/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs index 1a9210e31b..381d2f720d 100644 --- a/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs +++ b/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs @@ -803,13 +803,30 @@ namespace ICSharpCode.NRefactory.VB.Visitors public AstNode VisitCheckedStatement(CSharp.CheckedStatement checkedStatement, object data) { - // overflow/underflow checks are default on in VB + // overflow/underflow checks are on by default in VB throw new NotImplementedException(); } public AstNode VisitContinueStatement(CSharp.ContinueStatement continueStatement, object data) { - throw new NotImplementedException(); + var @continue = new ContinueStatement(ContinueKind.None); + + foreach (var stmt in continueStatement.Ancestors) { + if (stmt is CSharp.DoWhileStatement) { + @continue.ContinueKind = ContinueKind.Do; + break; + } + if (stmt is CSharp.ForStatement || stmt is CSharp.ForeachStatement) { + @continue.ContinueKind = ContinueKind.For; + break; + } + if (stmt is CSharp.WhileStatement) { + @continue.ContinueKind = ContinueKind.While; + break; + } + } + + return EndNode(continueStatement, @continue); } public AstNode VisitDoWhileStatement(CSharp.DoWhileStatement doWhileStatement, object data)