Browse Source

Merge branch 'master' of git://github.com/icsharpcode/ILSpy into Debugger

newNRvisualizers
Eusebiu Marcu 15 years ago
parent
commit
c3cbf9e153
  1. 31
      ICSharpCode.NRefactory/CSharp/Ast/AstNode.cs
  2. 156
      ICSharpCode.NRefactory/CSharp/Ast/AstNodeCollection.cs
  3. 3
      ICSharpCode.NRefactory/CSharp/Ast/ComposedType.cs
  4. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/AnonymousMethodExpression.cs
  5. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArgListExpression.cs
  6. 6
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayCreateExpression.cs
  7. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayInitializerExpression.cs
  8. 39
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/Expression.cs
  9. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/IdentifierExpression.cs
  10. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/IndexerExpression.cs
  11. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/InvocationExpression.cs
  12. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/LambdaExpression.cs
  13. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/MemberReferenceExpression.cs
  14. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ObjectCreateExpression.cs
  15. 5
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/PointerReferenceExpression.cs
  16. 6
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/QueryExpression.cs
  17. 5
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Attribute.cs
  18. 5
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/AttributeSection.cs
  19. 5
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs
  20. 11
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs
  21. 10
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/NamespaceDeclaration.cs
  22. 14
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs
  23. 5
      ICSharpCode.NRefactory/CSharp/Ast/MemberType.cs
  24. 5
      ICSharpCode.NRefactory/CSharp/Ast/SimpleType.cs
  25. 5
      ICSharpCode.NRefactory/CSharp/Ast/Statements/BlockStatement.cs
  26. 5
      ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs
  27. 8
      ICSharpCode.NRefactory/CSharp/Ast/Statements/ForStatement.cs
  28. 11
      ICSharpCode.NRefactory/CSharp/Ast/Statements/SwitchStatement.cs
  29. 5
      ICSharpCode.NRefactory/CSharp/Ast/Statements/TryCatchStatement.cs
  30. 15
      ICSharpCode.NRefactory/CSharp/Ast/Statements/VariableDeclarationStatement.cs
  31. 3
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs
  32. 8
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  33. 5
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EventDeclaration.cs
  34. 5
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FieldDeclaration.cs
  35. 5
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/IndexerDeclaration.cs
  36. 11
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MethodDeclaration.cs
  37. 5
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs
  38. 5
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs
  39. 4
      ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
  40. 4
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  41. 3
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

31
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -675,10 +675,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -675,10 +675,10 @@ namespace ICSharpCode.NRefactory.CSharp
bool LambdaNeedsParenthesis(LambdaExpression lambdaExpression)
{
if (lambdaExpression.Parameters.Count() != 1)
if (lambdaExpression.Parameters.Count != 1)
return true;
var p = lambdaExpression.Parameters.Single();
return p.Type.IsNull && p.ParameterModifier == ParameterModifier.None;
return !(p.Type.IsNull && p.ParameterModifier == ParameterModifier.None);
}
public object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data)

4
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
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