Browse Source

Indexer declaration: make "this" a token instead of an identifier

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
911d47cb02
  1. 2
      ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
  2. 8
      ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/IndexerDeclarationTests.cs

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

@ -961,7 +961,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -961,7 +961,7 @@ namespace ICSharpCode.NRefactory.CSharp
newIndexer.AddChild (ConvertToType (indexer.TypeExpression), Roles.Type);
AddExplicitInterface (newIndexer, indexer.MemberName);
var name = indexer.MemberName;
newIndexer.AddChild (Identifier.Create ("this", Convert (name.Location)), Roles.Identifier);
newIndexer.AddChild (new CSharpTokenNode(Convert (name.Location), IndexerDeclaration.ThisKeywordRole), IndexerDeclaration.ThisKeywordRole);
if (location != null && location.Count > 0)
newIndexer.AddChild (new CSharpTokenNode (Convert (location [0]), Roles.LBracket), Roles.LBracket);

8
ICSharpCode.NRefactory.Tests/CSharp/Parser/TypeMembers/IndexerDeclarationTests.cs

@ -38,6 +38,14 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers @@ -38,6 +38,14 @@ namespace ICSharpCode.NRefactory.CSharp.Parser.TypeMembers
Assert.AreEqual("Item", id.Name);
}
[Test]
public void ThisTokenPosition()
{
IndexerDeclaration id = ParseUtilCSharp.ParseTypeMember<IndexerDeclaration>("public int this[int a] { get { } protected set { } }");
CSharpTokenNode thisKeyword = id.GetChildByRole(IndexerDeclaration.ThisKeywordRole);
Assert.AreEqual(12, thisKeyword.StartLocation.Column);
}
[Test]
public void IndexerImplementingInterfaceTest()
{

Loading…
Cancel
Save