Browse Source

implemented DoLoopStatement and UsingStatement

newNRvisualizers
Siegfried Pammer 14 years ago
parent
commit
3531735e97
  1. 19
      ICSharpCode.NRefactory.VB/Ast/Enums.cs
  2. 14
      ICSharpCode.NRefactory.VB/Ast/Statements/DoLoopStatement.cs
  3. 33
      ICSharpCode.NRefactory.VB/Ast/Statements/UsingStatement.cs
  4. 13
      ICSharpCode.NRefactory.VB/IAstVisitor.cs
  5. 1
      ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj
  6. 46
      ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs
  7. 22
      ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

19
ICSharpCode.NRefactory.VB/Ast/Enums.cs

@ -102,25 +102,12 @@ namespace ICSharpCode.NRefactory.VB.Ast @@ -102,25 +102,12 @@ namespace ICSharpCode.NRefactory.VB.Ast
public enum ConditionType
{
None,
Until,
While,
LoopUntil,
LoopWhile,
DoUntil,
DoWhile
}
public enum ConditionPosition
{
None,
Start,
End
}
public enum ConstructorInitializerType
{
None,
Base,
This
}
public enum ConversionType
{
None,

14
ICSharpCode.NRefactory.VB/Ast/Statements/DoLoopStatement.cs

@ -8,6 +8,18 @@ namespace ICSharpCode.NRefactory.VB.Ast @@ -8,6 +8,18 @@ namespace ICSharpCode.NRefactory.VB.Ast
{
public class DoLoopStatement : Statement
{
public ConditionType ConditionType { get; set; }
public Expression Expression {
get { return GetChildByRole(Roles.Expression); }
set { SetChildByRole(Roles.Expression, value); }
}
public BlockStatement Body {
get { return GetChildByRole(Roles.Body); }
set { SetChildByRole(Roles.Body, value); }
}
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
{
throw new NotImplementedException();
@ -15,7 +27,7 @@ namespace ICSharpCode.NRefactory.VB.Ast @@ -15,7 +27,7 @@ namespace ICSharpCode.NRefactory.VB.Ast
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
throw new NotImplementedException();
return visitor.VisitDoLoopStatement(this, data);
}
}
}

33
ICSharpCode.NRefactory.VB/Ast/Statements/UsingStatement.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// 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 UsingStatement : Statement
{
public static readonly Role<AstNode> ResourceRole = new Role<AstNode>("Resource", AstNode.Null);
/// <remarks>either multiple VariableInitializers or one Expression</remarks>
public AstNodeCollection<AstNode> Resources {
get { return GetChildrenByRole(ResourceRole); }
}
public BlockStatement Body {
get { return GetChildByRole(Roles.Body); }
set { SetChildByRole(Roles.Body, 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.VisitUsingStatement(this, data);
}
}
}

13
ICSharpCode.NRefactory.VB/IAstVisitor.cs

@ -88,6 +88,13 @@ namespace ICSharpCode.NRefactory.VB { @@ -88,6 +88,13 @@ namespace ICSharpCode.NRefactory.VB {
S VisitExitStatement(ExitStatement exitStatement, T data);
S VisitSelectStatement(SelectStatement selectStatement, T data);
S VisitYieldStatement(YieldStatement yieldStatement, T data);
S VisitVariableInitializer(VariableInitializer variableInitializer, T data);
S VisitRangeCaseClause(RangeCaseClause rangeCaseClause, T data);
S VisitComparisonCaseClause(ComparisonCaseClause comparisonCaseClause, T data);
S VisitSimpleCaseClause(SimpleCaseClause simpleCaseClause, T data);
S VisitCaseStatement(CaseStatement caseStatement, T data);
S VisitDoLoopStatement(DoLoopStatement doLoopStatement, T data);
S VisitUsingStatement(UsingStatement usingStatement, T data);
// TypeName
S VisitPrimitiveType(PrimitiveType primitiveType, T data);
@ -95,11 +102,5 @@ namespace ICSharpCode.NRefactory.VB { @@ -95,11 +102,5 @@ namespace ICSharpCode.NRefactory.VB {
S VisitComposedType(ComposedType composedType, T data);
S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data);
S VisitSimpleType(SimpleType simpleType, T data);
S VisitVariableInitializer(VariableInitializer variableInitializer, T data);
S VisitRangeCaseClause(RangeCaseClause rangeCaseClause, T data);
S VisitComparisonCaseClause(ComparisonCaseClause comparisonCaseClause, T data);
S VisitSimpleCaseClause(SimpleCaseClause simpleCaseClause, T data);
S VisitCaseStatement(CaseStatement caseStatement, T data);
}
}

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

@ -100,6 +100,7 @@ @@ -100,6 +100,7 @@
<Compile Include="Ast\Statements\SyncLockStatement.cs" />
<Compile Include="Ast\Statements\ThrowStatement.cs" />
<Compile Include="Ast\Statements\TryStatement.cs" />
<Compile Include="Ast\Statements\UsingStatement.cs" />
<Compile Include="Ast\Statements\WhileStatement.cs" />
<Compile Include="Ast\Statements\WithStatement.cs" />
<Compile Include="Ast\Statements\YieldStatement.cs" />

46
ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs

@ -2201,5 +2201,51 @@ namespace ICSharpCode.NRefactory.VB @@ -2201,5 +2201,51 @@ namespace ICSharpCode.NRefactory.VB
return EndNode(variableDeclaratorWithObjectCreation);
}
public object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data)
{
StartNode(doLoopStatement);
WriteKeyword("Do");
if (doLoopStatement.ConditionType == ConditionType.DoUntil) {
WriteKeyword("Until");
doLoopStatement.Expression.AcceptVisitor(this, data);
}
if (doLoopStatement.ConditionType == ConditionType.DoWhile) {
WriteKeyword("While");
doLoopStatement.Expression.AcceptVisitor(this, data);
}
NewLine();
Indent();
doLoopStatement.Body.AcceptVisitor(this, data);
Unindent();
WriteKeyword("Loop");
if (doLoopStatement.ConditionType == ConditionType.LoopUntil) {
WriteKeyword("Until");
doLoopStatement.Expression.AcceptVisitor(this, data);
}
if (doLoopStatement.ConditionType == ConditionType.LoopWhile) {
WriteKeyword("While");
doLoopStatement.Expression.AcceptVisitor(this, data);
}
return EndNode(doLoopStatement);
}
public object VisitUsingStatement(UsingStatement usingStatement, object data)
{
StartNode(usingStatement);
WriteKeyword("Using");
WriteCommaSeparatedList(usingStatement.Resources);
NewLine();
Indent();
usingStatement.Body.AcceptVisitor(this, data);
Unindent();
WriteKeyword("End");
WriteKeyword("Using");
return EndNode(usingStatement);
}
}
}

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

@ -791,12 +791,18 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -791,12 +791,18 @@ namespace ICSharpCode.NRefactory.VB.Visitors
public AstNode VisitDoWhileStatement(CSharp.DoWhileStatement doWhileStatement, object data)
{
throw new NotImplementedException();
var stmt = new DoLoopStatement();
stmt.ConditionType = ConditionType.LoopWhile;
stmt.Expression = (Expression)doWhileStatement.Condition.AcceptVisitor(this, data);
stmt.Body = (BlockStatement)doWhileStatement.EmbeddedStatement.AcceptVisitor(this, data);
return EndNode(doWhileStatement, stmt);
}
public AstNode VisitEmptyStatement(CSharp.EmptyStatement emptyStatement, object data)
{
throw new NotImplementedException();
return EndNode<Statement>(emptyStatement, null);
}
public AstNode VisitExpressionStatement(CSharp.ExpressionStatement expressionStatement, object data)
@ -816,7 +822,10 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -816,7 +822,10 @@ namespace ICSharpCode.NRefactory.VB.Visitors
var stmt = new ForEachStatement() {
Body = (BlockStatement)foreachStatement.EmbeddedStatement.AcceptVisitor(this, data),
InExpression = (Expression)foreachStatement.InExpression.AcceptVisitor(this, data),
Variable = new VariableInitializer() { Identifier = new VariableIdentifier() { Name = foreachStatement.VariableName }, Type = (AstType)foreachStatement.VariableType.AcceptVisitor(this, data) }
Variable = new VariableInitializer() {
Identifier = new VariableIdentifier() { Name = foreachStatement.VariableName },
Type = (AstType)foreachStatement.VariableType.AcceptVisitor(this, data)
}
};
return EndNode(foreachStatement, stmt);
@ -954,7 +963,12 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -954,7 +963,12 @@ namespace ICSharpCode.NRefactory.VB.Visitors
public AstNode VisitUsingStatement(CSharp.UsingStatement usingStatement, object data)
{
throw new NotImplementedException();
var stmt = new UsingStatement();
stmt.Resources.Add(usingStatement.ResourceAcquisition.AcceptVisitor(this, data));
stmt.Body = (BlockStatement)usingStatement.EmbeddedStatement.AcceptVisitor(this, data);
return EndNode(usingStatement, stmt);
}
public AstNode VisitVariableDeclarationStatement(CSharp.VariableDeclarationStatement variableDeclarationStatement, object data)

Loading…
Cancel
Save