16 changed files with 457 additions and 131 deletions
@ -0,0 +1,40 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
public class ParameterDeclaration : AttributedNode |
||||||
|
{ |
||||||
|
public Identifier Name { |
||||||
|
get { return GetChildByRole(Roles.Identifier); } |
||||||
|
set { SetChildByRole(Roles.Identifier, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public Expression OptionalValue { |
||||||
|
get { return GetChildByRole(Roles.Expression); } |
||||||
|
set { SetChildByRole(Roles.Expression, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstType ReturnType { |
||||||
|
get { return GetChildByRole(Roles.Type); } |
||||||
|
set { SetChildByRole(Roles.Type, value); } |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||||
|
{ |
||||||
|
var param = other as ParameterDeclaration; |
||||||
|
return param != null && |
||||||
|
MatchAttributesAndModifiers(param, match) && |
||||||
|
Name.DoMatch(param.Name, match) && |
||||||
|
OptionalValue.DoMatch(param.OptionalValue, match) && |
||||||
|
ReturnType.DoMatch(param.ReturnType, match); |
||||||
|
} |
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitParameterDeclaration(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// [In|Out] Name [As Contraints]
|
||||||
|
///
|
||||||
|
/// Represents a type parameter.
|
||||||
|
/// </summary>
|
||||||
|
public class TypeParameterDeclaration : AstNode |
||||||
|
{ |
||||||
|
public static readonly Role<AstType> TypeConstraintRole = TypeDeclaration.InheritsTypeRole; |
||||||
|
public static readonly Role<VBTokenNode> VarianceRole = new Role<VBTokenNode>("Variance"); |
||||||
|
|
||||||
|
public VarianceModifier Variance { get; set; } |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { return GetChildByRole (Roles.Identifier).Name; } |
||||||
|
set { SetChildByRole(Roles.Identifier, new Identifier(value, AstLocation.Empty)); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<AstType> Constraints { |
||||||
|
get { return GetChildrenByRole(TypeConstraintRole); } |
||||||
|
} |
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitTypeParameterDeclaration(this, data); |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||||
|
{ |
||||||
|
TypeParameterDeclaration o = other as TypeParameterDeclaration; |
||||||
|
return o != null && this.Variance == o.Variance |
||||||
|
&& MatchString(this.Name, o.Name) |
||||||
|
&& this.Constraints.DoMatch(o.Constraints, match); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
public class DelegateDeclaration : AttributedNode |
||||||
|
{ |
||||||
|
public bool IsSub { get; set; } |
||||||
|
|
||||||
|
public AstNodeCollection<TypeParameterDeclaration> TypeParameters { |
||||||
|
get { return GetChildrenByRole(Roles.TypeParameter); } |
||||||
|
} |
||||||
|
|
||||||
|
public Identifier Name { |
||||||
|
get { return GetChildByRole(Roles.Identifier); } |
||||||
|
set { SetChildByRole(Roles.Identifier, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<ParameterDeclaration> Parameters { |
||||||
|
get { return GetChildrenByRole(Roles.Parameter); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<AttributeBlock> ReturnTypeAttributes { |
||||||
|
get { return GetChildrenByRole(AttributeBlock.ReturnTypeAttributeBlockRole); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstType ReturnType { |
||||||
|
get { return GetChildByRole(Roles.Type); } |
||||||
|
set { SetChildByRole(Roles.Type, value); } |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||||
|
{ |
||||||
|
var o = other as DelegateDeclaration; |
||||||
|
return o != null && |
||||||
|
MatchAttributesAndModifiers(o, match) && |
||||||
|
IsSub == o.IsSub && |
||||||
|
TypeParameters.DoMatch(o.TypeParameters, match) && |
||||||
|
Name.DoMatch(o.Name, match) && |
||||||
|
Parameters.DoMatch(o.Parameters, match) && |
||||||
|
ReturnTypeAttributes.DoMatch(o.ReturnTypeAttributes, match) && |
||||||
|
ReturnType.DoMatch(o.ReturnType, match); |
||||||
|
} |
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitDelegateDeclaration(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,44 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
public class EnumDeclaration : AttributedNode |
||||||
|
{ |
||||||
|
public readonly static Role<EnumMemberDeclaration> MemberRole = new Role<EnumMemberDeclaration>("Member"); |
||||||
|
public readonly static Role<AstType> UnderlyingTypeRole = new Role<AstType>("UnderlyingType", AstType.Null); |
||||||
|
|
||||||
|
public Identifier Name { |
||||||
|
get { return GetChildByRole(Roles.Identifier); } |
||||||
|
set { SetChildByRole(Roles.Identifier, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstType UnderlyingType { |
||||||
|
get { return GetChildByRole(UnderlyingTypeRole); } |
||||||
|
set { SetChildByRole(UnderlyingTypeRole, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<EnumMemberDeclaration> Member { |
||||||
|
get { return GetChildrenByRole(MemberRole); } |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||||
|
{ |
||||||
|
var decl = other as EnumDeclaration; |
||||||
|
return decl != null && |
||||||
|
MatchAttributesAndModifiers(decl, match) && |
||||||
|
Name.DoMatch(decl.Name, match) && |
||||||
|
UnderlyingType.DoMatch(decl.UnderlyingType, match) && |
||||||
|
Member.DoMatch(decl.Member, match); |
||||||
|
} |
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitEnumDeclaration(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
public class EnumMemberDeclaration : AstNode |
||||||
|
{ |
||||||
|
public AstNodeCollection<AttributeBlock> Attributes { |
||||||
|
get { return GetChildrenByRole(AttributeBlock.AttributeBlockRole); } |
||||||
|
} |
||||||
|
|
||||||
|
public Identifier Name { |
||||||
|
get { return GetChildByRole(Roles.Identifier); } |
||||||
|
set { SetChildByRole(Roles.Identifier, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public Expression Value { |
||||||
|
get { return GetChildByRole(Roles.Expression); } |
||||||
|
set { SetChildByRole(Roles.Expression, value); } |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||||
|
{ |
||||||
|
var member = other as EnumMemberDeclaration; |
||||||
|
return Attributes.DoMatch(member.Attributes, match) && |
||||||
|
Name.DoMatch(member.Name, match) && |
||||||
|
Value.DoMatch(member.Value, match); |
||||||
|
} |
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitEnumMemberDeclaration(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,78 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
using ICSharpCode.NRefactory.PatternMatching; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Namespace Name
|
||||||
|
/// Members
|
||||||
|
/// End Namespace
|
||||||
|
/// </summary>
|
||||||
|
public class NamespaceDeclaration : AstNode |
||||||
|
{ |
||||||
|
public static readonly Role<AstNode> MemberRole = CompilationUnit.MemberRole; |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { |
||||||
|
StringBuilder builder = new StringBuilder(); |
||||||
|
foreach (Identifier identifier in GetChildrenByRole (Roles.Identifier)) { |
||||||
|
if (builder.Length > 0) |
||||||
|
builder.Append ('.'); |
||||||
|
builder.Append (identifier.Name); |
||||||
|
} |
||||||
|
return builder.ToString (); |
||||||
|
} |
||||||
|
set { |
||||||
|
GetChildrenByRole(Roles.Identifier).ReplaceWith(value.Split('.').Select(ident => new Identifier(ident, AstLocation.Empty))); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<Identifier> Identifiers { |
||||||
|
get { return GetChildrenByRole (Roles.Identifier); } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the full namespace name (including any parent namespaces)
|
||||||
|
/// </summary>
|
||||||
|
public string FullName { |
||||||
|
get { |
||||||
|
NamespaceDeclaration parentNamespace = Parent as NamespaceDeclaration; |
||||||
|
if (parentNamespace != null) |
||||||
|
return BuildQualifiedName (parentNamespace.FullName, Name); |
||||||
|
return Name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<AstNode> Members { |
||||||
|
get { return GetChildrenByRole(MemberRole); } |
||||||
|
} |
||||||
|
|
||||||
|
public static string BuildQualifiedName (string name1, string name2) |
||||||
|
{ |
||||||
|
if (string.IsNullOrEmpty (name1)) |
||||||
|
return name2; |
||||||
|
if (string.IsNullOrEmpty (name2)) |
||||||
|
return name1; |
||||||
|
return name1 + "." + name2; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitNamespaceDeclaration(this, data); |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||||
|
{ |
||||||
|
NamespaceDeclaration o = other as NamespaceDeclaration; |
||||||
|
return o != null && MatchString(this.Name, o.Name) && this.Members.DoMatch(o.Members, match); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,58 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.NRefactory.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.VB.Ast |
||||||
|
{ |
||||||
|
public class TypeDeclaration : AttributedNode |
||||||
|
{ |
||||||
|
public readonly static Role<AttributedNode> MemberRole = new Role<AttributedNode>("Member"); |
||||||
|
public readonly static Role<AstType> InheritsTypeRole = new Role<AstType>("InheritsType", AstType.Null); |
||||||
|
public readonly static Role<AstType> ImplementsTypesRole = new Role<AstType>("ImplementsTypes", AstType.Null); |
||||||
|
|
||||||
|
public AstNodeCollection<AttributedNode> Members { |
||||||
|
get { return base.GetChildrenByRole(MemberRole); } |
||||||
|
} |
||||||
|
|
||||||
|
public ClassType ClassType { get; set; } |
||||||
|
|
||||||
|
public Identifier Name { |
||||||
|
get { return GetChildByRole(Roles.Identifier); } |
||||||
|
set { SetChildByRole(Roles.Identifier, value); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<TypeParameterDeclaration> TypeParameters { |
||||||
|
get { return GetChildrenByRole(Roles.TypeParameter); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstType InheritsType { |
||||||
|
get { return GetChildByRole(InheritsTypeRole); } |
||||||
|
} |
||||||
|
|
||||||
|
public AstNodeCollection<AstType> ImplementsTypes { |
||||||
|
get { return GetChildrenByRole(ImplementsTypesRole); } |
||||||
|
} |
||||||
|
|
||||||
|
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||||
|
{ |
||||||
|
TypeDeclaration t = other as TypeDeclaration; |
||||||
|
return t != null && |
||||||
|
MatchAttributesAndModifiers(t, match) && |
||||||
|
Members.DoMatch(t.Members, match) && |
||||||
|
ClassType == t.ClassType && |
||||||
|
Name.DoMatch(t.Name, match) && |
||||||
|
TypeParameters.DoMatch(t.TypeParameters, match) && |
||||||
|
InheritsType.DoMatch(t.InheritsType, match) && |
||||||
|
ImplementsTypes.DoMatch(t.ImplementsTypes, match); |
||||||
|
} |
||||||
|
|
||||||
|
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||||
|
{ |
||||||
|
return visitor.VisitTypeDeclaration(this, data); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,49 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using ICSharpCode.NRefactory.VB.Ast; |
|
||||||
|
|
||||||
namespace ICSharpCode.NRefactory.VB.Parser |
|
||||||
{ |
|
||||||
internal class ParamModifierList |
|
||||||
{ |
|
||||||
ParameterModifiers cur; |
|
||||||
VBParser parser; |
|
||||||
|
|
||||||
public ParameterModifiers Modifier { |
|
||||||
get { |
|
||||||
return cur; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ParamModifierList(VBParser parser) |
|
||||||
{ |
|
||||||
this.parser = parser; |
|
||||||
cur = ParameterModifiers.None; |
|
||||||
} |
|
||||||
|
|
||||||
public bool isNone { get { return cur == ParameterModifiers.None; } } |
|
||||||
|
|
||||||
public void Add(ParameterModifiers m) |
|
||||||
{ |
|
||||||
if ((cur & m) == 0) { |
|
||||||
cur |= m; |
|
||||||
} else { |
|
||||||
parser.Error("param modifier " + m + " already defined"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Add(ParamModifierList m) |
|
||||||
{ |
|
||||||
Add(m.cur); |
|
||||||
} |
|
||||||
|
|
||||||
public void Check() |
|
||||||
{ |
|
||||||
if((cur & ParameterModifiers.In) != 0 && |
|
||||||
(cur & ParameterModifiers.Ref) != 0) { |
|
||||||
parser.Error("ByRef and ByVal are not allowed at the same time."); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue