Browse Source

Add pattern matching for MemberDeclarations.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
b51f5a651f
  1. 2
      ICSharpCode.NRefactory/CSharp/Ast/AstType.cs
  2. 2
      ICSharpCode.NRefactory/CSharp/Ast/Expressions/ArrayCreateExpression.cs
  3. 5
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/Constraint.cs
  4. 19
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/DelegateDeclaration.cs
  5. 9
      ICSharpCode.NRefactory/CSharp/Ast/GeneralScope/TypeDeclaration.cs
  6. 2
      ICSharpCode.NRefactory/CSharp/Ast/Statements/FixedStatement.cs
  7. 3
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/Accessor.cs
  8. 4
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/AttributedNode.cs
  9. 7
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ConstructorDeclaration.cs
  10. 8
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/DestructorDeclaration.cs
  11. 11
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EnumMemberDeclaration.cs
  12. 13
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/EventDeclaration.cs
  13. 6
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/FieldDeclaration.cs
  14. 34
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/IndexerDeclaration.cs
  15. 6
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs
  16. 14
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MethodDeclaration.cs
  17. 11
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/OperatorDeclaration.cs
  18. 4
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/ParameterDeclaration.cs
  19. 11
      ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/PropertyDeclaration.cs
  20. 5
      ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
  21. 6
      ICSharpCode.NRefactory/CSharp/Parser/CSharpParser.cs
  22. 21
      ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs
  23. 8
      ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs

2
ICSharpCode.NRefactory/CSharp/Ast/AstType.cs

@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,7 +40,7 @@ namespace ICSharpCode.NRefactory.CSharp
return new ComposedType { BaseType = this }.MakePointerType();
}
public virtual AstType MakeArrayType(int rank)
public virtual AstType MakeArrayType(int rank = 1)
{
return new ComposedType { BaseType = this }.MakeArrayType(rank);
}

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

@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ArrayCreateExpression o = other as ArrayCreateExpression;
return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.Initializer.DoMatch(o.Initializer, match);
return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.AdditionalArraySpecifiers.DoMatch(o.AdditionalArraySpecifiers, match) && this.Initializer.DoMatch(o.Initializer, match);
}
}
}

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

@ -31,6 +31,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -31,6 +31,9 @@ namespace ICSharpCode.NRefactory.CSharp
/// <summary>
/// where TypeParameter : BaseTypes
/// </summary>
/// <remarks>
/// new(), struct and class constraints are represented using a PrimitiveType "new", "struct" or "class"
/// </remarks>
public class Constraint : AstNode
{
public readonly static Role<CSharpTokenNode> ColonRole = TypeDeclaration.ColonRole;
@ -51,8 +54,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -51,8 +54,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
// TODO: what about new(), struct and class constraints?
public AstNodeCollection<AstType> BaseTypes {
get { return GetChildrenByRole (BaseTypeRole); }
}

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

@ -40,6 +40,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -40,6 +40,11 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public AstType ReturnType {
get { return GetChildByRole (Roles.Type); }
set { SetChildByRole (Roles.Type, value); }
}
public string Name {
get {
return GetChildByRole (Roles.Identifier).Name;
@ -49,11 +54,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -49,11 +54,6 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public AstType ReturnType {
get { return GetChildByRole (Roles.Type); }
set { SetChildByRole (Roles.Type, value); }
}
public AstNodeCollection<TypeParameterDeclaration> TypeParameters {
get { return GetChildrenByRole (Roles.TypeParameter); }
}
@ -78,5 +78,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -78,5 +78,14 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitDelegateDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DelegateDeclaration o = other as DelegateDeclaration;
return o != null && this.MatchAttributesAndModifiers(o, match)
&& this.ReturnType.DoMatch(o.ReturnType, match) && MatchString(this.Name, o.Name)
&& this.TypeParameters.DoMatch(o.TypeParameters, match) && this.Parameters.DoMatch(o.Parameters, match)
&& this.Constraints.DoMatch(o.Constraints, match);
}
}
}

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

@ -87,5 +87,14 @@ namespace ICSharpCode.NRefactory.CSharp @@ -87,5 +87,14 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitTypeDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
TypeDeclaration o = other as TypeDeclaration;
return o != null && this.ClassType == o.ClassType && this.MatchAttributesAndModifiers(o, match)
&& MatchString(this.Name, o.Name) && this.TypeParameters.DoMatch(o.TypeParameters, match)
&& this.BaseTypes.DoMatch(o.BaseTypes, match) && this.Constraints.DoMatch(o.Constraints, match)
&& this.Members.DoMatch(o.Members, match);
}
}
}

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

@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,7 +67,7 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
FixedStatement o = other as FixedStatement;
return o != null && this.Variables.DoMatch(o.Variables, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
return o != null && this.Type.DoMatch(o.Type, match) && this.Variables.DoMatch(o.Variables, match) && this.EmbeddedStatement.DoMatch(o.EmbeddedStatement, match);
}
}
}

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

@ -64,7 +64,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -64,7 +64,8 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
throw new NotImplementedException();
Accessor o = other as Accessor;
return o != null && this.MatchAttributesAndModifiers(o, match) && this.Body.DoMatch(o.Body, match);
}
}
}

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

@ -58,9 +58,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -58,9 +58,9 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.CSharp.PatternMatching.Match match)
protected bool MatchAttributesAndModifiers(AttributedNode o, PatternMatching.Match match)
{
throw new NotImplementedException();
return this.Modifiers == o.Modifiers && this.Attributes.DoMatch(o.Attributes, match);
}
}
}

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

@ -70,6 +70,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -70,6 +70,13 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitConstructorDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ConstructorDeclaration o = other as ConstructorDeclaration;
return o != null && this.MatchAttributesAndModifiers(o, match) && this.Parameters.DoMatch(o.Parameters, match)
&& this.Initializer.DoMatch(o.Initializer, match) && this.Body.DoMatch(o.Body, match);
}
}
public enum ConstructorInitializerType {

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// DestructorDeclaration.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -61,5 +61,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -61,5 +61,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitDestructorDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
DestructorDeclaration o = other as DestructorDeclaration;
return o != null && this.MatchAttributesAndModifiers(o, match) && this.Body.DoMatch(o.Body, match);
}
}
}

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
//
// EnumMemberDeclaration.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -53,6 +53,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,6 +53,13 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitEnumMemberDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
EnumMemberDeclaration o = other as EnumMemberDeclaration;
return o != null && this.MatchAttributesAndModifiers(o, match)
&& MatchString(this.Name, o.Name) && this.Initializer.DoMatch(o.Initializer, match);
}
}
}

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

@ -38,6 +38,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -38,6 +38,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitEventDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
EventDeclaration o = other as EventDeclaration;
return o != null && this.MatchMember(o, match) && this.Variables.DoMatch(o.Variables, match);
}
}
public class CustomEventDeclaration : MemberDeclaration
@ -67,5 +73,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,5 +73,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitCustomEventDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
CustomEventDeclaration o = other as CustomEventDeclaration;
return o != null && this.MatchMember(o, match)
&& this.AddAccessor.DoMatch(o.AddAccessor, match) && this.RemoveAccessor.DoMatch(o.RemoveAccessor, match);
}
}
}

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

@ -39,5 +39,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -39,5 +39,11 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitFieldDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
FieldDeclaration o = other as FieldDeclaration;
return o != null && this.MatchMember(o, match) && this.Variables.DoMatch(o.Variables, match);
}
}
}

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// IndexerDeclaration.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -29,13 +29,16 @@ using System.Linq; @@ -29,13 +29,16 @@ using System.Linq;
namespace ICSharpCode.NRefactory.CSharp
{
public class IndexerDeclaration : PropertyDeclaration
public class IndexerDeclaration : MemberDeclaration
{
public static readonly Role<Accessor> GetterRole = PropertyDeclaration.GetterRole;
public static readonly Role<Accessor> SetterRole = PropertyDeclaration.SetterRole;
public CSharpTokenNode LBracketToken {
get { return GetChildByRole (Roles.LBracket); }
}
public AstNodeCollection<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
}
@ -43,9 +46,34 @@ namespace ICSharpCode.NRefactory.CSharp @@ -43,9 +46,34 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RBracket); }
}
public CSharpTokenNode LBraceToken {
get { return GetChildByRole (Roles.LBrace); }
}
public Accessor Getter {
get { return GetChildByRole(GetterRole); }
set { SetChildByRole(GetterRole, value); }
}
public Accessor Setter {
get { return GetChildByRole(SetterRole); }
set { SetChildByRole(SetterRole, value); }
}
public CSharpTokenNode RBraceToken {
get { return GetChildByRole (Roles.RBrace); }
}
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
{
return visitor.VisitIndexerDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
IndexerDeclaration o = other as IndexerDeclaration;
return o != null && this.MatchMember(o, match) && this.Parameters.DoMatch(o.Parameters, match)
&& this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match);
}
}
}

6
ICSharpCode.NRefactory/CSharp/Ast/TypeMembers/MemberDeclaration.cs

@ -55,5 +55,11 @@ namespace ICSharpCode.NRefactory.CSharp @@ -55,5 +55,11 @@ namespace ICSharpCode.NRefactory.CSharp
public override NodeType NodeType {
get { return NodeType.Member; }
}
protected bool MatchMember(MemberDeclaration o, PatternMatching.Match match)
{
return MatchAttributesAndModifiers(o, match) && this.ReturnType.DoMatch(o.ReturnType, match)
&& this.PrivateImplementationType.DoMatch(o.PrivateImplementationType, match) && MatchString(this.Name, o.Name);
}
}
}

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// MethodDeclaration.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -39,7 +39,7 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public AstNodeCollection<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
}
@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -47,7 +47,7 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.RPar); }
}
public AstNodeCollection<Constraint> Constraints {
public AstNodeCollection<Constraint> Constraints {
get { return GetChildrenByRole (Roles.Constraint); }
}
@ -67,5 +67,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -67,5 +67,13 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitMethodDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
MethodDeclaration o = other as MethodDeclaration;
return o != null && this.MatchMember(o, match) && this.TypeParameters.DoMatch(o.TypeParameters, match)
&& this.Parameters.DoMatch(o.Parameters, match) && this.Constraints.DoMatch(o.Constraints, match)
&& this.Body.DoMatch(o.Body, match);
}
}
}

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
// OperatorDeclaration.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -80,7 +80,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -80,7 +80,7 @@ namespace ICSharpCode.NRefactory.CSharp
get { return GetChildByRole (Roles.LPar); }
}
public AstNodeCollection<ParameterDeclaration> Parameters {
public AstNodeCollection<ParameterDeclaration> Parameters {
get { return GetChildrenByRole (Roles.Parameter); }
}
@ -107,5 +107,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -107,5 +107,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitOperatorDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
OperatorDeclaration o = other as OperatorDeclaration;
return o != null && this.MatchMember(o, match) && this.OperatorType == o.OperatorType
&& this.Parameters.DoMatch(o.Parameters, match) && this.Body.DoMatch(o.Body, match);
}
}
}

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

@ -85,7 +85,9 @@ namespace ICSharpCode.NRefactory.CSharp @@ -85,7 +85,9 @@ namespace ICSharpCode.NRefactory.CSharp
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
ParameterDeclaration o = other as ParameterDeclaration;
return o != null && this.Attributes.DoMatch(o.Attributes, match) && this.ParameterModifier == o.ParameterModifier && MatchString(this.Name, o.Name) && this.DefaultExpression.DoMatch(o.DefaultExpression, match);
return o != null && this.Attributes.DoMatch(o.Attributes, match) && this.ParameterModifier == o.ParameterModifier
&& this.Type.DoMatch(o.Type, match) && MatchString(this.Name, o.Name)
&& this.DefaultExpression.DoMatch(o.DefaultExpression, match);
}
}
}

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

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
//
//
// PropertyDeclaration.cs
//
//
// Author:
// Mike Krüger <mkrueger@novell.com>
//
@ -53,5 +53,12 @@ namespace ICSharpCode.NRefactory.CSharp @@ -53,5 +53,12 @@ namespace ICSharpCode.NRefactory.CSharp
{
return visitor.VisitPropertyDeclaration (this, data);
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
PropertyDeclaration o = other as PropertyDeclaration;
return o != null && this.MatchMember(o, match)
&& this.Getter.DoMatch(o.Getter, match) && this.Setter.DoMatch(o.Setter, match);
}
}
}

5
ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -1889,7 +1889,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1889,7 +1889,10 @@ namespace ICSharpCode.NRefactory.CSharp
{
StartNode(memberType);
memberType.Target.AcceptVisitor(this, data);
WriteToken(".", MemberType.Roles.Dot);
if (memberType.IsDoubleColon)
WriteToken("::", MemberType.Roles.Dot);
else
WriteToken(".", MemberType.Roles.Dot);
WriteIdentifier(memberType.MemberName);
WriteTypeArguments(memberType.TypeArguments);
return EndNode(memberType);

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

@ -2540,7 +2540,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2540,7 +2540,7 @@ namespace ICSharpCode.NRefactory.CSharp
return EmptyList<AttributedNode>.Instance;
}
public IEnumerable<AstNode> ParseStatements(TextReader reader)
public IEnumerable<Statement> ParseStatements(TextReader reader)
{
string code = "void M() { " + reader.ReadToEnd() + "}";
var members = ParseTypeMembers(new StringReader(code));
@ -2548,10 +2548,10 @@ namespace ICSharpCode.NRefactory.CSharp @@ -2548,10 +2548,10 @@ namespace ICSharpCode.NRefactory.CSharp
if (method != null && method.Body != null)
return method.Body.Statements;
else
return EmptyList<AstNode>.Instance;
return EmptyList<Statement>.Instance;
}
public AstNode ParseTypeReference(TextReader reader)
public AstType ParseTypeReference(TextReader reader)
{
// TODO: add support for parsing type references
throw new NotImplementedException();

21
ICSharpCode.NRefactory/CSharp/Parser/TypeSystemConvertVisitor.cs

@ -395,13 +395,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -395,13 +395,6 @@ namespace ICSharpCode.NRefactory.CSharp
public override IEntity VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
DefaultProperty p = new DefaultProperty(currentTypeDefinition, propertyDeclaration.Name);
HandlePropertyOrIndexer(p, propertyDeclaration);
currentTypeDefinition.Properties.Add(p);
return p;
}
void HandlePropertyOrIndexer(DefaultProperty p, PropertyDeclaration propertyDeclaration)
{
p.Region = MakeRegion(propertyDeclaration);
p.BodyRegion = MakeBraceRegion(propertyDeclaration);
ApplyModifiers(p, propertyDeclaration.Modifiers);
@ -413,13 +406,25 @@ namespace ICSharpCode.NRefactory.CSharp @@ -413,13 +406,25 @@ namespace ICSharpCode.NRefactory.CSharp
}
p.Getter = ConvertAccessor(propertyDeclaration.Getter, p.Accessibility);
p.Setter = ConvertAccessor(propertyDeclaration.Setter, p.Accessibility);
currentTypeDefinition.Properties.Add(p);
return p;
}
public override IEntity VisitIndexerDeclaration(IndexerDeclaration indexerDeclaration, object data)
{
DefaultProperty p = new DefaultProperty(currentTypeDefinition, "Items");
p.EntityType = EntityType.Indexer;
HandlePropertyOrIndexer(p, indexerDeclaration);
p.Region = MakeRegion(indexerDeclaration);
p.BodyRegion = MakeBraceRegion(indexerDeclaration);
ApplyModifiers(p, indexerDeclaration.Modifiers);
p.ReturnType = ConvertType(indexerDeclaration.ReturnType);
ConvertAttributes(p.Attributes, indexerDeclaration.Attributes);
if (!indexerDeclaration.PrivateImplementationType.IsNull) {
p.Accessibility = Accessibility.None;
p.InterfaceImplementations.Add(ConvertInterfaceImplementation(indexerDeclaration.PrivateImplementationType, p.Name));
}
p.Getter = ConvertAccessor(indexerDeclaration.Getter, p.Accessibility);
p.Setter = ConvertAccessor(indexerDeclaration.Setter, p.Accessibility);
ConvertParameters(p.Parameters, indexerDeclaration.Parameters);
currentTypeDefinition.Properties.Add(p);
return p;

8
ICSharpCode.NRefactory/CSharp/Resolver/ResolveVisitor.cs

@ -309,14 +309,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -309,14 +309,14 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
}
// handle properties/indexers
ResolveResult VisitPropertyMember(PropertyDeclaration propertyDeclaration)
ResolveResult VisitPropertyMember(MemberDeclaration propertyOrIndexerDeclaration)
{
try {
if (resolver.CurrentTypeDefinition != null) {
resolver.CurrentMember = resolver.CurrentTypeDefinition.Properties.FirstOrDefault(p => p.Region.IsInside(propertyDeclaration.StartLocation));
resolver.CurrentMember = resolver.CurrentTypeDefinition.Properties.FirstOrDefault(p => p.Region.IsInside(propertyOrIndexerDeclaration.StartLocation));
}
for (AstNode node = propertyDeclaration.FirstChild; node != null; node = node.NextSibling) {
for (AstNode node = propertyOrIndexerDeclaration.FirstChild; node != null; node = node.NextSibling) {
if (node.Role == PropertyDeclaration.SetterRole && resolver.CurrentMember != null) {
resolver.PushBlock();
resolver.AddVariable(resolver.CurrentMember.ReturnType, "value");
@ -1135,7 +1135,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -1135,7 +1135,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
{
throw new NotImplementedException();
}
*/
*/
#endregion
public override ResolveResult VisitIdentifier(Identifier identifier, object data)

Loading…
Cancel
Save