Browse Source

NRefactory: remove collection setters from AST; expose AstNodeCollection<T> instead.

pull/37/head
Daniel Grunwald 14 years ago
parent
commit
9912340414
  1. 4
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 71
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  3. 4
      ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs
  4. 18
      ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs
  5. 4
      ICSharpCode.Decompiler/Ast/Transforms/ReplaceMethodCallsWithOperators.cs
  6. 10
      ICSharpCode.Decompiler/Ast/Transforms/RestoreLoop.cs
  7. 6
      ILSpy/CSharpLanguage.cs
  8. 31
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs
  9. 156
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNodeCollection.cs
  10. 3
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs
  11. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousMethodExpression.cs
  12. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArgListExpression.cs
  13. 6
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayCreateExpression.cs
  14. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayInitializerExpression.cs
  15. 39
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/Expression.cs
  16. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs
  17. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IndexerExpression.cs
  18. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/InvocationExpression.cs
  19. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/LambdaExpression.cs
  20. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs
  21. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ObjectCreateExpression.cs
  22. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs
  23. 6
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs
  24. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs
  25. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/AttributeSection.cs
  26. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs
  27. 11
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs
  28. 10
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs
  29. 14
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs
  30. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs
  31. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs
  32. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/BlockStatement.cs
  33. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs
  34. 8
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForStatement.cs
  35. 11
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs
  36. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs
  37. 15
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs
  38. 3
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs
  39. 8
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  40. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EventDeclaration.cs
  41. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FieldDeclaration.cs
  42. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/IndexerDeclaration.cs
  43. 11
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MethodDeclaration.cs
  44. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs
  45. 5
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs
  46. 4
      NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  47. 3
      NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

4
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -420,7 +420,7 @@ namespace Decompiler @@ -420,7 +420,7 @@ namespace Decompiler
astMethod.AddAnnotation(methodDef);
astMethod.Name = methodDef.Name;
astMethod.ReturnType = ConvertType(methodDef.ReturnType, methodDef.MethodReturnType);
astMethod.Parameters = MakeParameters(methodDef.Parameters);
astMethod.Parameters.AddRange(MakeParameters(methodDef.Parameters));
if (!methodDef.DeclaringType.IsInterface) {
astMethod.Modifiers = ConvertModifiers(methodDef);
astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context);
@ -437,7 +437,7 @@ namespace Decompiler @@ -437,7 +437,7 @@ namespace Decompiler
// don't show visibility for static ctors
astMethod.Modifiers &= ~Modifiers.VisibilityMask;
}
astMethod.Parameters = MakeParameters(methodDef.Parameters);
astMethod.Parameters.AddRange(MakeParameters(methodDef.Parameters));
astMethod.Body = AstMethodBodyBuilder.CreateMethodBody(methodDef, context);
return astMethod;
}

71
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -193,27 +193,27 @@ namespace Decompiler @@ -193,27 +193,27 @@ namespace Decompiler
ILSwitch ilSwitch = (ILSwitch)node;
SwitchStatement switchStmt = new SwitchStatement() { Expression = (Expression)TransformExpression(ilSwitch.Condition.Arguments[0]) };
for (int i = 0; i < ilSwitch.CaseBlocks.Count; i++) {
switchStmt.AddChild(new SwitchSection() {
CaseLabels = new[] { new CaseLabel() { Expression = new PrimitiveExpression(i) } },
Statements = new[] { TransformBlock(ilSwitch.CaseBlocks[i]) }
}, SwitchStatement.SwitchSectionRole);
SwitchSection section = new SwitchSection();
section.CaseLabels.Add(new CaseLabel() { Expression = new PrimitiveExpression(i) });
section.Statements.Add(TransformBlock(ilSwitch.CaseBlocks[i]));
switchStmt.SwitchSections.Add(section);
}
yield return switchStmt;
} else if (node is ILTryCatchBlock) {
ILTryCatchBlock tryCatchNode = ((ILTryCatchBlock)node);
List<Ast.CatchClause> catchClauses = new List<CatchClause>();
var tryCatchStmt = new Ast.TryCatchStatement();
tryCatchStmt.TryBlock = TransformBlock(tryCatchNode.TryBlock);
foreach (var catchClause in tryCatchNode.CatchBlocks) {
catchClauses.Add(new Ast.CatchClause {
Type = AstBuilder.ConvertType(catchClause.ExceptionType),
VariableName = "exception",
Body = TransformBlock(catchClause)
});
tryCatchStmt.CatchClauses.Add(
new Ast.CatchClause {
Type = AstBuilder.ConvertType(catchClause.ExceptionType),
VariableName = "exception",
Body = TransformBlock(catchClause)
});
}
yield return new Ast.TryCatchStatement {
TryBlock = TransformBlock(tryCatchNode.TryBlock),
CatchClauses = catchClauses,
FinallyBlock = tryCatchNode.FinallyBlock != null ? TransformBlock(tryCatchNode.FinallyBlock) : null
};
if (tryCatchNode.FinallyBlock != null)
tryCatchStmt.FinallyBlock = TransformBlock(tryCatchNode.FinallyBlock);
yield return tryCatchStmt;
} else if (node is ILBlock) {
yield return TransformBlock((ILBlock)node);
} else {
@ -402,12 +402,12 @@ namespace Decompiler @@ -402,12 +402,12 @@ namespace Decompiler
#endregion
#region Arrays
case Code.Newarr:
operandAsTypeRef = operandAsTypeRef.MakeArrayType(0);
return new Ast.ArrayCreateExpression {
Type = operandAsTypeRef,
Arguments = new Expression[] {arg1}
};
{
var ace = new Ast.ArrayCreateExpression();
ace.Type = operandAsTypeRef;
ace.Arguments.Add(arg1);
return ace;
}
case Code.Ldlen:
return arg1.Member("Length");
@ -532,7 +532,7 @@ namespace Decompiler @@ -532,7 +532,7 @@ namespace Decompiler
{
Cecil.MethodReference cecilMethod = ((MethodReference)operand);
var expr = new Ast.IdentifierExpression(cecilMethod.Name);
expr.TypeArguments = ConvertTypeArguments(cecilMethod);
expr.TypeArguments.AddRange(ConvertTypeArguments(cecilMethod));
expr.AddAnnotation(cecilMethod);
return new IdentifierExpression("ldftn").Invoke(expr)
.WithAnnotation(new Transforms.DelegateConstruction.Annotation(false));
@ -541,7 +541,7 @@ namespace Decompiler @@ -541,7 +541,7 @@ namespace Decompiler
{
Cecil.MethodReference cecilMethod = ((MethodReference)operand);
var expr = new Ast.IdentifierExpression(cecilMethod.Name);
expr.TypeArguments = ConvertTypeArguments(cecilMethod);
expr.TypeArguments.AddRange(ConvertTypeArguments(cecilMethod));
expr.AddAnnotation(cecilMethod);
return new IdentifierExpression("ldvirtftn").Invoke(expr)
.WithAnnotation(new Transforms.DelegateConstruction.Annotation(true));
@ -634,18 +634,21 @@ namespace Decompiler @@ -634,18 +634,21 @@ namespace Decompiler
case Code.Localloc: throw new NotImplementedException();
case Code.Mkrefany: throw new NotImplementedException();
case Code.Newobj:
Cecil.TypeReference declaringType = ((MethodReference)operand).DeclaringType;
// TODO: Ensure that the corrent overloaded constructor is called
if (declaringType is ArrayType) {
{
Cecil.TypeReference declaringType = ((MethodReference)operand).DeclaringType;
// TODO: Ensure that the corrent overloaded constructor is called
/*if (declaringType is ArrayType) { shouldn't this be newarr?
return new Ast.ArrayCreateExpression {
Type = AstBuilder.ConvertType((ArrayType)declaringType),
Arguments = args
};
}*/
var oce = new Ast.ObjectCreateExpression();
oce.Type = AstBuilder.ConvertType(declaringType);
oce.Arguments.AddRange(args);
return oce.WithAnnotation(operand);
}
return new Ast.ObjectCreateExpression {
Type = AstBuilder.ConvertType(declaringType),
Arguments = args
};
case Code.No: throw new NotImplementedException();
case Code.Nop: return null;
case Code.Pop: return arg1;
@ -667,10 +670,10 @@ namespace Decompiler @@ -667,10 +670,10 @@ namespace Decompiler
ILVariable locVar = (ILVariable)operand;
if (!definedLocalVars.Contains(locVar)) {
definedLocalVars.Add(locVar);
return new Ast.VariableDeclarationStatement() {
Type = locVar.Type != null ? AstBuilder.ConvertType(locVar.Type) : new Ast.PrimitiveType("var"),
Variables = new[] { new Ast.VariableInitializer(locVar.Name, arg1) }
};
return new Ast.VariableDeclarationStatement(
locVar.Type != null ? AstBuilder.ConvertType(locVar.Type) : new Ast.PrimitiveType("var"),
locVar.Name,
arg1);
} else {
return new Ast.AssignmentExpression(new Ast.IdentifierExpression(locVar.Name), arg1);
}

4
ICSharpCode.Decompiler/Ast/Transforms/ConvertConstructorCallIntoInitializer.cs

@ -28,9 +28,7 @@ namespace Decompiler.Transforms @@ -28,9 +28,7 @@ namespace Decompiler.Transforms
else
return null;
// Move arguments from invocation to initializer:
var arguments = invocation.Arguments.ToArray();
invocation.Arguments = null;
ci.Arguments = arguments;
invocation.Arguments.MoveTo(ci.Arguments);
// Add the initializer:
constructorDeclaration.Initializer = ci.WithAnnotation(invocation.Annotation<MethodReference>());
// Remove the statement:

18
ICSharpCode.Decompiler/Ast/Transforms/DelegateConstruction.cs

@ -74,15 +74,13 @@ namespace Decompiler.Transforms @@ -74,15 +74,13 @@ namespace Decompiler.Transforms
}
}
// now transform the identifier into a member reference
var typeArguments = methodIdent.TypeArguments.ToArray();
methodIdent.TypeArguments = null;
MemberReferenceExpression mre = new MemberReferenceExpression {
Target = obj,
MemberName = methodIdent.Identifier,
TypeArguments = typeArguments
};
MemberReferenceExpression mre = new MemberReferenceExpression();
mre.Target = obj;
mre.MemberName = methodIdent.Identifier;
methodIdent.TypeArguments.MoveTo(mre.TypeArguments);
mre.AddAnnotation(method);
objectCreateExpression.Arguments = new [] { mre };
objectCreateExpression.Arguments.Clear();
objectCreateExpression.Arguments.Add(mre);
return null;
}
}
@ -112,7 +110,7 @@ namespace Decompiler.Transforms @@ -112,7 +110,7 @@ namespace Decompiler.Transforms
ame.HasParameterList = false;
} else {
ame.HasParameterList = true;
ame.Parameters = AstBuilder.MakeParameters(method.Parameters);
ame.Parameters.AddRange(AstBuilder.MakeParameters(method.Parameters));
}
ame.Body = body;
// Replace all occurrences of 'this' in the method body with the delegate's target:
@ -193,7 +191,7 @@ namespace Decompiler.Transforms @@ -193,7 +191,7 @@ namespace Decompiler.Transforms
continue;
VariableDeclarationStatement newVarDecl = new VariableDeclarationStatement();
newVarDecl.Type = AstBuilder.ConvertType(field.FieldType, field);
newVarDecl.Variables = new [] { new VariableInitializer(field.Name) };
newVarDecl.Variables.Add(new VariableInitializer(field.Name));
blockStatement.InsertChildBefore(cur, newVarDecl, BlockStatement.StatementRole);
dict[field.Name] = new IdentifierExpression(field.Name);
}

4
ICSharpCode.Decompiler/Ast/Transforms/ReplaceMethodCallsWithOperators.cs

@ -25,7 +25,7 @@ namespace Decompiler.Transforms @@ -25,7 +25,7 @@ namespace Decompiler.Transforms
// Reduce "String.Concat(a, b)" to "a + b"
if (methodRef != null && methodRef.Name == "Concat" && methodRef.DeclaringType.FullName == "System.String" && arguments.Length >= 2)
{
invocationExpression.Arguments = null; // detach arguments from invocationExpression
invocationExpression.Arguments.Clear(); // detach arguments from invocationExpression
Expression expr = arguments[0];
for (int i = 1; i < arguments.Length; i++) {
expr = new BinaryOperatorExpression(expr, BinaryOperatorType.Add, arguments[i]);
@ -48,7 +48,7 @@ namespace Decompiler.Transforms @@ -48,7 +48,7 @@ namespace Decompiler.Transforms
BinaryOperatorType? bop = GetBinaryOperatorTypeFromMetadataName(methodRef.Name);
if (bop != null && arguments.Length == 2) {
invocationExpression.Arguments = null; // detach arguments from invocationExpression
invocationExpression.Arguments.Clear(); // detach arguments from invocationExpression
invocationExpression.ReplaceWith(
new BinaryOperatorExpression(arguments[0], bop.Value, arguments[1]).WithAnnotation(methodRef)
);

10
ICSharpCode.Decompiler/Ast/Transforms/RestoreLoop.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System;
using System.Linq;
using ICSharpCode.NRefactory.CSharp;
using System;
using System.Linq;
using ICSharpCode.NRefactory.CSharp;
namespace Decompiler.Transforms.Ast
{
@ -15,7 +15,7 @@ namespace Decompiler.Transforms.Ast @@ -15,7 +15,7 @@ namespace Decompiler.Transforms.Ast
VariableDeclarationStatement varDeclr = forStatement.PrevSibling as VariableDeclarationStatement;
if (varDeclr != null) {
varDeclr.ReplaceWith(Statement.Null);
forStatement.Initializers = new Statement[] { varDeclr };
forStatement.Initializers.Add(varDeclr);
}
}
@ -63,7 +63,7 @@ namespace Decompiler.Transforms.Ast @@ -63,7 +63,7 @@ namespace Decompiler.Transforms.Ast
if (lastStmt != null &&
(lastStmt.Expression is AssignmentExpression || lastStmt.Expression is UnaryOperatorExpression)) {
lastStmt.Remove();
forStatement.Iterators = new Statement[] { lastStmt };
forStatement.Iterators.Add(lastStmt);
}
}

6
ILSpy/CSharpLanguage.cs

@ -157,9 +157,9 @@ namespace ICSharpCode.ILSpy @@ -157,9 +157,9 @@ namespace ICSharpCode.ILSpy
base.VisitMemberType(memberType, data);
SimpleType st = memberType.Target as SimpleType;
if (st != null && !st.TypeArguments.Any()) {
var ta = memberType.TypeArguments.ToArray();
memberType.TypeArguments = null;
memberType.ReplaceWith(new SimpleType { Identifier = memberType.MemberName, TypeArguments = ta });
SimpleType newSt = new SimpleType(memberType.MemberName);
memberType.TypeArguments.MoveTo(newSt.TypeArguments);
memberType.ReplaceWith(newSt);
}
return null;
}

31
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// AstNode.cs
//
// Author:
@ -164,16 +164,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -164,16 +164,9 @@ namespace ICSharpCode.NRefactory.CSharp
return role.NullObject;
}
public IEnumerable<T> GetChildrenByRole<T>(Role<T> role) where T : AstNode
public AstNodeCollection<T> GetChildrenByRole<T>(Role<T> role) where T : AstNode
{
AstNode next;
for (AstNode cur = firstChild; cur != null; cur = next) {
// Remember next before yielding cur.
// This allows removing/replacing nodes while iterating through the list.
next = cur.nextSibling;
if (cur.role == role)
yield return (T)cur;
}
return new AstNodeCollection<T>(this, role);
}
protected void SetChildByRole<T>(Role<T> role, T newChild) where T : AstNode
@ -185,24 +178,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -185,24 +178,6 @@ namespace ICSharpCode.NRefactory.CSharp
oldChild.ReplaceWith(newChild);
}
protected void SetChildrenByRole<T>(Role<T> role, IEnumerable<T> newChildren) where T : AstNode
{
// Evaluate 'newChildren' first, since it might change when we remove the old children
// Example: SetChildren(role, GetChildrenByRole(role));
if (newChildren != null)
newChildren = newChildren.ToList();
// remove old children
foreach (AstNode node in GetChildrenByRole(role))
node.Remove();
// add new children
if (newChildren != null) {
foreach (T node in newChildren) {
AddChild(node, role);
}
}
}
public void AddChild<T>(T child, Role<T> role) where T : AstNode
{
if (role == null)

156
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/AstNodeCollection.cs

@ -0,0 +1,156 @@ @@ -0,0 +1,156 @@
// 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.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ICSharpCode.NRefactory.CSharp
{
/// <summary>
/// Represents the children of an AstNode that have a specific role.
/// </summary>
public struct AstNodeCollection<T> : ICollection<T> where T : AstNode
{
readonly AstNode node;
readonly Role<T> role;
public AstNodeCollection(AstNode node, Role<T> role)
{
if (node == null)
throw new ArgumentNullException("node");
if (role == null)
throw new ArgumentNullException("role");
this.node = node;
this.role = role;
}
public int Count {
get {
var e = GetEnumerator();
int count = 0;
while (e.MoveNext())
count++;
return count;
}
}
public void Add(T element)
{
node.AddChild(element, role);
}
public void AddRange(IEnumerable<T> nodes)
{
// Evaluate 'nodes' first, since it might change when we add the new children
// Example: collection.AddRange(collection);
if (nodes != null) {
foreach (T node in nodes.ToList())
Add(node);
}
}
public void AddRange(T[] nodes)
{
// Fast overload for arrays - we don't need to create a copy
if (nodes != null) {
foreach (T node in nodes)
Add(node);
}
}
public void ReplaceWith(IEnumerable<T> nodes)
{
// Evaluate 'nodes' first, since it might change when we call Clear()
// Example: collection.ReplaceWith(collection);
if (nodes != null)
nodes = nodes.ToList();
Clear();
foreach (T node in nodes)
Add(node);
}
public void MoveTo(ICollection<T> targetCollection)
{
foreach (T node in this) {
node.Remove();
targetCollection.Add(node);
}
}
public bool Contains(T element)
{
return element != null && element.Parent == node && element.Role == role;
}
public bool Remove(T element)
{
if (Contains(element)) {
element.Remove();
return true;
} else {
return false;
}
}
public void CopyTo(T[] array, int arrayIndex)
{
foreach (T item in this)
array[arrayIndex++] = item;
}
public void Clear()
{
foreach (T item in this)
item.Remove();
}
bool ICollection<T>.IsReadOnly {
get { return false; }
}
public IEnumerator<T> GetEnumerator()
{
AstNode next;
for (AstNode cur = node.FirstChild; cur != null; cur = next) {
// Remember next before yielding cur.
// This allows removing/replacing nodes while iterating through the list.
next = cur.NextSibling;
if (cur.Role == role)
yield return (T)cur;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#region Equals and GetHashCode implementation
public override bool Equals(object obj)
{
if (obj is AstNodeCollection<T>) {
return ((AstNodeCollection<T>)obj) == this;
} else {
return false;
}
}
public override int GetHashCode()
{
return node.GetHashCode() ^ role.GetHashCode();
}
public static bool operator ==(AstNodeCollection<T> left, AstNodeCollection<T> right)
{
return left.role == right.role && left.node == right.node;
}
public static bool operator !=(AstNodeCollection<T> left, AstNodeCollection<T> right)
{
return !(left.role == right.role && left.node == right.node);
}
#endregion
}
}

3
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs

@ -67,9 +67,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,9 +67,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<ArraySpecifier> ArraySpecifiers {
public AstNodeCollection<ArraySpecifier> ArraySpecifiers {
get { return GetChildrenByRole (ArraySpecifierRole); }
set { SetChildrenByRole (ArraySpecifierRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousMethodExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// AnonymousMethodExpression.cs
//
// Author:
@ -47,9 +47,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,9 +47,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode RParToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArgListExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ArgListExpression.cs
//
// Author:
@ -45,9 +45,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -45,9 +45,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole(Roles.Argument); }
set { SetChildrenByRole(Roles.Argument, value); }
}
public CSharpTokenNode RParToken {

6
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayCreateExpression.cs

@ -16,18 +16,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -16,18 +16,16 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Type, value); }
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole (Roles.Argument); }
set { SetChildrenByRole (Roles.Argument, value); }
}
/// <summary>
/// Gets additional array ranks (those without size info).
/// Empty for "new int[5,1]"; will contain a single element for "new int[5][]".
/// </summary>
public IEnumerable<ArraySpecifier> AdditionalArraySpecifiers {
public AstNodeCollection<ArraySpecifier> AdditionalArraySpecifiers {
get { return GetChildrenByRole(AdditionalArraySpecifierRole); }
set { SetChildrenByRole (AdditionalArraySpecifierRole, value); }
}
public ArrayInitializerExpression Initializer {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayInitializerExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ArrayInitializerExpression.cs
//
// Author:
@ -55,9 +55,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -55,9 +55,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBrace); }
}
public IEnumerable<Expression> Elements {
public AstNodeCollection<Expression> Elements {
get { return GetChildrenByRole(Roles.Expression); }
set { SetChildrenByRole(Roles.Expression, value); }
}
public CSharpTokenNode RBraceToken {

39
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/Expression.cs

@ -66,7 +66,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -66,7 +66,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public IndexerExpression Indexer(IEnumerable<Expression> arguments)
{
return new IndexerExpression { Target = this, Arguments = arguments };
IndexerExpression expr = new IndexerExpression();
expr.Target = this;
expr.Arguments.AddRange(arguments);
return expr;
}
/// <summary>
@ -74,7 +77,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -74,7 +77,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public IndexerExpression Indexer(params Expression[] arguments)
{
return new IndexerExpression { Target = this, Arguments = arguments };
IndexerExpression expr = new IndexerExpression();
expr.Target = this;
expr.Arguments.AddRange(arguments);
return expr;
}
/// <summary>
@ -98,14 +104,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -98,14 +104,14 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public InvocationExpression Invoke(string methodName, IEnumerable<AstType> typeArguments, IEnumerable<Expression> arguments)
{
return new InvocationExpression {
Target = new MemberReferenceExpression {
Target = this,
MemberName = methodName,
TypeArguments = typeArguments
},
Arguments = arguments
};
InvocationExpression ie = new InvocationExpression();
MemberReferenceExpression mre = new MemberReferenceExpression();
mre.Target = this;
mre.MemberName = methodName;
mre.TypeArguments.AddRange(typeArguments);
ie.Target = mre;
ie.Arguments.AddRange(arguments);
return ie;
}
/// <summary>
@ -113,10 +119,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -113,10 +119,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public InvocationExpression Invoke(IEnumerable<Expression> arguments)
{
return new InvocationExpression {
Target = this,
Arguments = arguments
};
InvocationExpression ie = new InvocationExpression();
ie.Target = this;
ie.Arguments.AddRange(arguments);
return ie;
}
/// <summary>
@ -124,7 +130,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -124,7 +130,10 @@ namespace ICSharpCode.NRefactory.CSharp
/// </summary>
public InvocationExpression Invoke(params Expression[] arguments)
{
return Invoke(arguments.AsEnumerable());
InvocationExpression ie = new InvocationExpression();
ie.Target = this;
ie.Arguments.AddRange(arguments);
return ie;
}
public CastExpression CastTo(AstType type)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// IdentifierExpression.cs
//
// Author:
@ -56,9 +56,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -56,9 +56,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<AstType> TypeArguments {
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
set { SetChildrenByRole (Roles.TypeArgument, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/IndexerExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// IndexerExpression.cs
//
// Author:
@ -42,9 +42,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -42,9 +42,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBracket); }
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole<Expression>(Roles.Argument); }
set { SetChildrenByRole(Roles.Argument, value); }
}
public CSharpTokenNode RBracketToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/InvocationExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// InvocationExpression.cs
//
// Author:
@ -42,9 +42,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -42,9 +42,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole<Expression>(Roles.Argument); }
set { SetChildrenByRole(Roles.Argument, value); }
}
public CSharpTokenNode RParToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/LambdaExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// LambdaExpression.cs
//
// Author:
@ -36,9 +36,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -36,9 +36,8 @@ namespace ICSharpCode.NRefactory.CSharp
public readonly static Role<CSharpTokenNode> ArrowRole = new Role<CSharpTokenNode>("Arrow", CSharpTokenNode.Null);
public static readonly Role<AstNode> BodyRole = new Role<AstNode>("Body", AstNode.Null);
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode ArrowToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// MemberReferenceExpression.cs
//
// Author:
@ -51,9 +51,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -51,9 +51,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LChevron); }
}
public IEnumerable<AstType> TypeArguments {
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
set { SetChildrenByRole (Roles.TypeArgument, value); }
}
public CSharpTokenNode RChevronToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/ObjectCreateExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ObjectCreateExpression.cs
//
// Author:
@ -48,9 +48,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -48,9 +48,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole (Roles.Argument); }
set { SetChildrenByRole (Roles.Argument, value); }
}
public CSharpTokenNode RParToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// PointerReferenceExpression.cs
//
// Author:
@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<AstType> TypeArguments {
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
set { SetChildrenByRole (Roles.TypeArgument, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

6
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs

@ -28,9 +28,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -28,9 +28,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
#endregion
public IEnumerable<QueryClause> Clauses {
public AstNodeCollection<QueryClause> Clauses {
get { return GetChildrenByRole(ClauseRole); }
set { SetChildrenByRole(ClauseRole, value); }
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
@ -260,9 +259,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -260,9 +259,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.Keyword); }
}
public IEnumerable<QueryOrdering> Orderings {
public AstNodeCollection<QueryOrdering> Orderings {
get { return GetChildrenByRole (OrderingRole); }
set { SetChildrenByRole (OrderingRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// Attribute.cs
//
// Author:
@ -44,9 +44,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -44,9 +44,8 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Type, value); }
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return base.GetChildrenByRole (Roles.Argument); }
set { SetChildrenByRole (Roles.Argument, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/AttributeSection.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// AttributeSection.cs
//
// Author:
@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public IEnumerable<Attribute> Attributes {
public AstNodeCollection<Attribute> Attributes {
get { return base.GetChildrenByRole (AttributeRole); }
set { SetChildrenByRole (AttributeRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// Constraint.cs
//
// Author:
@ -53,9 +53,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,9 +53,8 @@ namespace ICSharpCode.NRefactory.CSharp
// TODO: what about new(), struct and class constraints?
public IEnumerable<AstType> BaseTypes {
public AstNodeCollection<AstType> BaseTypes {
get { return GetChildrenByRole (BaseTypeRole); }
set { SetChildrenByRole (BaseTypeRole, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

11
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// DelegateDeclaration.cs
//
// Author:
@ -54,27 +54,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,27 +54,24 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Type, value); }
}
public IEnumerable<TypeParameterDeclaration> TypeParameters {
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
get { return GetChildrenByRole (Roles.TypeParameter); }
set { SetChildrenByRole (Roles.TypeParameter, value); }
}
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode RParToken {
get { return GetChildByRole (Roles.RPar); }
}
public IEnumerable<Constraint> Constraints {
public AstNodeCollection<Constraint> Constraints {
get { return GetChildrenByRole (Roles.Constraint); }
set { SetChildrenByRole (Roles.Constraint, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

10
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// NamespaceDeclaration.cs
//
// Author:
@ -54,13 +54,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -54,13 +54,12 @@ namespace ICSharpCode.NRefactory.CSharp
return builder.ToString ();
}
set {
SetChildrenByRole (Roles.Identifier, value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty)));
GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty)));
}
}
public IEnumerable<Identifier> Identifiers {
public AstNodeCollection<Identifier> Identifiers {
get { return GetChildrenByRole (Roles.Identifier); }
set { SetChildrenByRole (Roles.Identifier, value); }
}
/// <summary>
@ -79,9 +78,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -79,9 +78,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBrace); }
}
public IEnumerable<AstNode> Members {
public AstNodeCollection<AstNode> Members {
get { return GetChildrenByRole(MemberRole); }
set { SetChildrenByRole(MemberRole, value); }
}
public CSharpTokenNode RBraceToken {

14
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// TypeDeclaration.cs
//
// Author:
@ -59,28 +59,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -59,28 +59,24 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<TypeParameterDeclaration> TypeParameters {
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
get { return GetChildrenByRole (Roles.TypeParameter); }
set { SetChildrenByRole (Roles.TypeParameter, value); }
}
public IEnumerable<AstType> BaseTypes {
public AstNodeCollection<AstType> BaseTypes {
get { return GetChildrenByRole (BaseTypeRole); }
set { SetChildrenByRole (BaseTypeRole, value); }
}
public IEnumerable<Constraint> Constraints {
public AstNodeCollection<Constraint> Constraints {
get { return GetChildrenByRole (Roles.Constraint); }
set { SetChildrenByRole (Roles.Constraint, value); }
}
public CSharpTokenNode LBraceToken {
get { return GetChildByRole (Roles.LBrace); }
}
public IEnumerable<AttributedNode> Members {
public AstNodeCollection<AttributedNode> Members {
get { return GetChildrenByRole (MemberRole); }
set { SetChildrenByRole (MemberRole, value); }
}
public CSharpTokenNode RBraceToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// FullTypeName.cs
//
// Author:
@ -51,9 +51,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -51,9 +51,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<AstType> TypeArguments {
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
set { SetChildrenByRole (Roles.TypeArgument, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// FullTypeName.cs
//
// Author:
@ -56,9 +56,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -56,9 +56,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<AstType> TypeArguments {
public AstNodeCollection<AstType> TypeArguments {
get { return GetChildrenByRole (Roles.TypeArgument); }
set { SetChildrenByRole (Roles.TypeArgument, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/BlockStatement.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// BlockStatement.cs
//
// Author:
@ -56,9 +56,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -56,9 +56,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBrace); }
}
public IEnumerable<Statement> Statements {
public AstNodeCollection<Statement> Statements {
get { return GetChildrenByRole (StatementRole); }
set { SetChildrenByRole (StatementRole, value); }
}
public CSharpTokenNode RBraceToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// FixedStatement.cs
//
// Author:
@ -46,9 +46,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -46,9 +46,8 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Type, value); }
}
public IEnumerable<VariableInitializer> Variables {
public AstNodeCollection<VariableInitializer> Variables {
get { return GetChildrenByRole (Roles.Variable); }
set { SetChildrenByRole (Roles.Variable, value); }
}
public CSharpTokenNode RParToken {

8
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/ForStatement.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ForStatement.cs
//
// Author:
@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp
/// Note: this contains multiple statements for "for (a = 2, b = 1; a > b; a--)", but contains
/// only a single statement for "for (int a = 2, b = 1; a > b; a--)" (a single VariableDeclarationStatement with two variables)
/// </summary>
public IEnumerable<Statement> Initializers {
public AstNodeCollection<Statement> Initializers {
get { return GetChildrenByRole (InitializerRole); }
set { SetChildrenByRole (InitializerRole, value); }
}
public Expression Condition {
@ -59,9 +58,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -59,9 +58,8 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Condition, value); }
}
public IEnumerable<Statement> Iterators {
public AstNodeCollection<Statement> Iterators {
get { return GetChildrenByRole (IteratorRole); }
set { SetChildrenByRole (IteratorRole, value); }
}
public CSharpTokenNode RParToken {

11
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// SwitchStatement.cs
//
// Author:
@ -57,9 +57,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -57,9 +57,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBrace); }
}
public IEnumerable<SwitchSection> SwitchSections {
public AstNodeCollection<SwitchSection> SwitchSections {
get { return GetChildrenByRole (SwitchSectionRole); }
set { SetChildrenByRole (SwitchSectionRole, value); }
}
public CSharpTokenNode RBraceToken {
@ -82,14 +81,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -82,14 +81,12 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<CaseLabel> CaseLabels {
public AstNodeCollection<CaseLabel> CaseLabels {
get { return GetChildrenByRole (CaseLabelRole); }
set { SetChildrenByRole (CaseLabelRole, value); }
}
public IEnumerable<Statement> Statements {
public AstNodeCollection<Statement> Statements {
get { return GetChildrenByRole (Roles.EmbeddedStatement); }
set { SetChildrenByRole (Roles.EmbeddedStatement, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// TryCatchStatement.cs
//
// Author:
@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (TryBlockRole, value); }
}
public IEnumerable<CatchClause> CatchClauses {
public AstNodeCollection<CatchClause> CatchClauses {
get { return GetChildrenByRole (CatchClauseRole); }
set { SetChildrenByRole (CatchClauseRole, value); }
}
public CSharpTokenNode FinallyToken {

15
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// VariableDeclarationStatement.cs
//
// Author:
@ -33,6 +33,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -33,6 +33,16 @@ namespace ICSharpCode.NRefactory.CSharp
{
public static readonly Role<CSharpModifierToken> ModifierRole = AttributedNode.ModifierRole;
public VariableDeclarationStatement()
{
}
public VariableDeclarationStatement(AstType type, string name, Expression initializer = null)
{
this.Type = type;
this.Variables.Add(new VariableInitializer(name, initializer));
}
public Modifiers Modifiers {
get { return AttributedNode.GetModifiers(this); }
set { AttributedNode.SetModifiers(this, value); }
@ -43,9 +53,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -43,9 +53,8 @@ namespace ICSharpCode.NRefactory.CSharp
set { SetChildByRole (Roles.Type, value); }
}
public IEnumerable<VariableInitializer> Variables {
public AstNodeCollection<VariableInitializer> Variables {
get { return GetChildrenByRole (Roles.Variable); }
set { SetChildrenByRole (Roles.Variable, value); }
}
public CSharpTokenNode SemicolonToken {

3
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs

@ -11,9 +11,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -11,9 +11,8 @@ namespace ICSharpCode.NRefactory.CSharp
public static readonly Role<AttributeSection> AttributeRole = new Role<AttributeSection>("Attribute");
public static readonly Role<CSharpModifierToken> ModifierRole = new Role<CSharpModifierToken>("Modifier");
public IEnumerable<AttributeSection> Attributes {
public AstNodeCollection<AttributeSection> Attributes {
get { return base.GetChildrenByRole (AttributeRole); }
set { SetChildrenByRole (AttributeRole, value); }
}
public Modifiers Modifiers {

8
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ConstructorDeclaration.cs
//
// Author:
@ -37,9 +37,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -37,9 +37,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode RParToken {
@ -105,9 +104,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -105,9 +104,8 @@ namespace ICSharpCode.NRefactory.CSharp
set;
}
public IEnumerable<Expression> Arguments {
public AstNodeCollection<Expression> Arguments {
get { return GetChildrenByRole (Roles.Argument); }
set { SetChildrenByRole (Roles.Argument, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EventDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// EventDeclaration.cs
//
// Author:
@ -30,9 +30,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -30,9 +30,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class EventDeclaration : MemberDeclaration
{
public IEnumerable<VariableInitializer> Variables {
public AstNodeCollection<VariableInitializer> Variables {
get { return GetChildrenByRole (Roles.Variable); }
set { SetChildrenByRole (Roles.Variable, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FieldDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// FieldDeclaration.cs
//
// Author:
@ -31,9 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,9 +31,8 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class FieldDeclaration : MemberDeclaration
{
public IEnumerable<VariableInitializer> Variables {
public AstNodeCollection<VariableInitializer> Variables {
get { return GetChildrenByRole (Roles.Variable); }
set { SetChildrenByRole (Roles.Variable, value); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/IndexerDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// IndexerDeclaration.cs
//
// Author:
@ -35,9 +35,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -35,9 +35,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LBracket); }
}
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode RBracketToken {

11
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MethodDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// MethodDeclaration.cs
//
// Author:
@ -31,27 +31,24 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,27 +31,24 @@ namespace ICSharpCode.NRefactory.CSharp
{
public class MethodDeclaration : MemberDeclaration
{
public IEnumerable<TypeParameterDeclaration> TypeParameters {
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
get { return GetChildrenByRole (Roles.TypeParameter); }
set { SetChildrenByRole (Roles.TypeParameter, value); }
}
public CSharpTokenNode LParToken {
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode RParToken {
get { return GetChildByRole (Roles.RPar); }
}
public IEnumerable<Constraint> Constraints {
public AstNodeCollection<Constraint> Constraints {
get { return GetChildrenByRole (Roles.Constraint); }
set { SetChildrenByRole (Roles.Constraint, value); }
}
public BlockStatement Body {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// OperatorDeclaration.cs
//
// Author:
@ -80,9 +80,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -80,9 +80,8 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public IEnumerable<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
set { SetChildrenByRole (Roles.Parameter, value); }
}
public CSharpTokenNode RParToken {

5
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// ParameterDeclarationExpression.cs
//
// Author:
@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,9 +49,8 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public IEnumerable<AttributeSection> Attributes {
public AstNodeCollection<AttributeSection> Attributes {
get { return GetChildrenByRole (AttributeRole); }
set { SetChildrenByRole (AttributeRole, value); }
}
public ParameterModifier ParameterModifier {

4
NRefactory/ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs

@ -122,9 +122,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -122,9 +122,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (location != null)
spec.AddChild (new CSharpTokenNode (Convert (location[0]), 1), FieldDeclaration.Roles.RBracket);
result.ArraySpecifiers = new ArraySpecifier[] {
spec
};
result.ArraySpecifiers.Add(spec);
}
return result;
}

3
NRefactory/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</ProjectGuid>
@ -56,6 +56,7 @@ @@ -56,6 +56,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="CSharp\Ast\AstComparer.cs" />
<Compile Include="CSharp\Ast\AstNodeCollection.cs" />
<Compile Include="CSharp\Ast\Expressions\TypeReferenceExpression.cs" />
<Compile Include="CSharp\Ast\IAstVisitor.cs" />
<Compile Include="CSharp\Ast\CompilationUnit.cs" />

Loading…
Cancel
Save