Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@262 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
13 changed files with 1813 additions and 1323 deletions
@ -0,0 +1,99 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Markus Palme" email="MarkusPalme@gmx.de"/>
|
||||||
|
// <version>$Revision: 230 $</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.Parser.AST |
||||||
|
{ |
||||||
|
public class CustomEventDeclaration : AttributedNode |
||||||
|
{ |
||||||
|
string name; |
||||||
|
EventAccessorDeclaration addHandlerDeclaration; |
||||||
|
EventAccessorDeclaration removeHandlerDeclaration; |
||||||
|
EventAccessorDeclaration raiseEventDeclaration; |
||||||
|
ArrayList implementsClause = new ArrayList(); |
||||||
|
|
||||||
|
public CustomEventDeclaration(Modifier modifier, List<AttributeSection> attributes, string name, EventAccessorDeclaration addHandlerDeclaration, EventAccessorDeclaration removeHandlerDeclaration, EventAccessorDeclaration raiseEventDeclaration, ArrayList implementsClause) : base(modifier, attributes) |
||||||
|
{ |
||||||
|
this.modifier = modifier; |
||||||
|
this.attributes = attributes; |
||||||
|
this.name = name; |
||||||
|
this.addHandlerDeclaration = addHandlerDeclaration; |
||||||
|
this.removeHandlerDeclaration = removeHandlerDeclaration; |
||||||
|
this.raiseEventDeclaration = raiseEventDeclaration; |
||||||
|
this.implementsClause = implementsClause; |
||||||
|
} |
||||||
|
|
||||||
|
public ArrayList ImplementsClause |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return implementsClause; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
implementsClause = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string Name |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return name; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
name = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public EventAccessorDeclaration AddHandlerDeclaration |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return addHandlerDeclaration; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
addHandlerDeclaration = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public EventAccessorDeclaration RemoveHandlerDeclaration |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return removeHandlerDeclaration; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
removeHandlerDeclaration = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public EventAccessorDeclaration RaiseEventDeclaration |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return raiseEventDeclaration; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
raiseEventDeclaration = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override object AcceptVisitor(IASTVisitor visitor, object data) |
||||||
|
{ |
||||||
|
return visitor.Visit(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,90 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Markus Palme" email="MarkusPalme@gmx.de"/>
|
||||||
|
// <version>$Revision: 230 $</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Collections; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.Parser.AST |
||||||
|
{ |
||||||
|
public enum EventAccessorType |
||||||
|
{ |
||||||
|
RemoveHandlerAccessor, |
||||||
|
AddHandlerAccessor, |
||||||
|
RaiseEventAccessor |
||||||
|
} |
||||||
|
|
||||||
|
public class EventAccessorDeclaration : AbstractNode |
||||||
|
{ |
||||||
|
protected BlockStatement body = BlockStatement.Null; |
||||||
|
protected EventAccessorType type; |
||||||
|
protected List<AttributeSection> attributes; |
||||||
|
protected List<ParameterDeclarationExpression> parameters; |
||||||
|
|
||||||
|
public EventAccessorDeclaration(BlockStatement body, List<ParameterDeclarationExpression> parameters, EventAccessorType type, List<AttributeSection> attributes) |
||||||
|
{ |
||||||
|
this.body = body; |
||||||
|
this.parameters = parameters; |
||||||
|
this.type = type; |
||||||
|
this.attributes = attributes; |
||||||
|
} |
||||||
|
|
||||||
|
public List<ParameterDeclarationExpression> Parameters |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return parameters; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
parameters = value == null ? new List<ParameterDeclarationExpression>(1) : value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public List<AttributeSection> Attributes |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return attributes; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
attributes = value == null ? new List<AttributeSection>(1) : value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public EventAccessorType Type |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return type; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
type = value; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public BlockStatement Body |
||||||
|
{ |
||||||
|
get |
||||||
|
{ |
||||||
|
return body; |
||||||
|
} |
||||||
|
set |
||||||
|
{ |
||||||
|
body = BlockStatement.CheckNull(value); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override object AcceptVisitor(IASTVisitor visitor, object data) |
||||||
|
{ |
||||||
|
return visitor.Visit(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,52 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||||
|
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||||
|
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||||
|
// <version>$Revision: 230 $</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using NUnit.Framework; |
||||||
|
using ICSharpCode.NRefactory.Parser; |
||||||
|
using ICSharpCode.NRefactory.Parser.AST; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.Tests.AST |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class CustomEventTests |
||||||
|
{ |
||||||
|
#region C#
|
||||||
|
// No C# representation
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region VB.NET
|
||||||
|
[Test] |
||||||
|
public void VBNetContinueStatementTest() |
||||||
|
{ |
||||||
|
string code = @" Public Custom Event TestEvent As EventHandler
|
||||||
|
AddHandler(ByVal value As EventHandler) |
||||||
|
Handlers = CType([Delegate].Combine(Handlers, value), _ |
||||||
|
EventHandler) |
||||||
|
End AddHandler |
||||||
|
|
||||||
|
RemoveHandler(ByVal value as EventHandler) |
||||||
|
Handlers = CType([Delegate].Remove(Handlers, value), _ |
||||||
|
EventHandler) |
||||||
|
End RemoveHandler |
||||||
|
|
||||||
|
RaiseEvent(ByVal sender As Object, ByVal e As EventArgs) |
||||||
|
Dim TempHandlers As EventHandler = Handlers |
||||||
|
|
||||||
|
If TempHandlers IsNot Nothing Then |
||||||
|
TempHandlers(sender, e) |
||||||
|
End If |
||||||
|
End RaiseEvent |
||||||
|
End Event";
|
||||||
|
CustomEventDeclaration customEventDecl = (CustomEventDeclaration)ParseUtilVBNet.ParseTypeMember(code, typeof(ContinueStatement)); |
||||||
|
Assert.IsNotNull(customEventDecl); |
||||||
|
Assert.AreEqual("TestEvent", customEventDecl.Name); |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue