Browse Source

implement GoToStatement

newNRvisualizers
Siegfried Pammer 14 years ago
parent
commit
bf89db8e85
  1. 27
      ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs
  2. 9
      ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs
  3. 2
      ICSharpCode.NRefactory.VB/IAstVisitor.cs
  4. 1
      ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj
  5. 17
      ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs
  6. 5
      ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

27
ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs

@ -0,0 +1,27 @@ @@ -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
{
/// <remarks>either PrimitiveExpression or IdentifierExpression</remarks>
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<T, S>(IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitGoToStatement(this, data);
}
}
}

9
ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs

@ -11,9 +11,10 @@ namespace ICSharpCode.NRefactory.VB.Ast @@ -11,9 +11,10 @@ namespace ICSharpCode.NRefactory.VB.Ast
/// </summary>
public class LabelDeclarationStatement : Statement
{
public Identifier Label {
get { return GetChildByRole(Roles.Identifier); }
set { SetChildByRole(Roles.Identifier, value); }
/// <remarks>either PrimitiveExpression or IdentifierExpression</remarks>
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 @@ -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);
}
}
}

2
ICSharpCode.NRefactory.VB/IAstVisitor.cs

@ -102,5 +102,7 @@ namespace ICSharpCode.NRefactory.VB { @@ -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);
}
}

1
ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj

@ -91,6 +91,7 @@ @@ -91,6 +91,7 @@
<Compile Include="Ast\Statements\ExpressionStatement.cs" />
<Compile Include="Ast\Statements\ForEachStatement.cs" />
<Compile Include="Ast\Statements\ForStatement.cs" />
<Compile Include="Ast\Statements\GoToStatement.cs" />
<Compile Include="Ast\Statements\IfElseStatement.cs" />
<Compile Include="Ast\Statements\LabelDeclarationStatement.cs" />
<Compile Include="Ast\Statements\LocalDeclarationStatement.cs" />

17
ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs

@ -1344,7 +1344,12 @@ namespace ICSharpCode.NRefactory.VB @@ -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 @@ -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);
}
}
}

5
ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

@ -175,6 +175,7 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -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 @@ -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 @@ -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)

Loading…
Cancel
Save