From b5c55470c535466e86a572416e927c4c9ff9bbbc Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 7 May 2011 18:07:24 +0200 Subject: [PATCH] finished implementation of global level VB constructs --- ICSharpCode.NRefactory.VB/Ast/AstNode.cs | 5 +- ICSharpCode.NRefactory.VB/Ast/Enums.cs | 32 ++---- .../Ast/General/AttributeBlock.cs | 1 + .../AttributedNode.cs} | 15 +-- .../Ast/General/ParameterDeclaration.cs | 40 ++++++++ .../Ast/General/TypeParameterDeclaration.cs | 44 +++++++++ .../Ast/GlobalScope/DelegateDeclaration.cs | 52 ++++++++++ .../Ast/GlobalScope/EnumDeclaration.cs | 44 +++++++++ .../Ast/GlobalScope/EnumMemberDeclaration.cs | 39 ++++++++ .../Ast/GlobalScope/NamespaceDeclaration.cs | 78 +++++++++++++++ .../Ast/GlobalScope/TypeDeclaration.cs | 58 +++++++++++ .../Ast/VBModifierToken.cs | 1 - ICSharpCode.NRefactory.VB/IAstVisitor.cs | 22 +++-- .../ICSharpCode.NRefactory.VB.csproj | 10 +- .../OutputVisitor/OutputVisitor.cs | 98 +++++++++++++------ .../Parser/ParamModifierList.cs | 49 ---------- 16 files changed, 457 insertions(+), 131 deletions(-) rename ICSharpCode.NRefactory.VB/Ast/{GlobalScope/ModuleDeclaration.cs => General/AttributedNode.cs} (90%) create mode 100644 ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs create mode 100644 ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs create mode 100644 ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs create mode 100644 ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs create mode 100644 ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs create mode 100644 ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs create mode 100644 ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs delete mode 100644 ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs diff --git a/ICSharpCode.NRefactory.VB/Ast/AstNode.cs b/ICSharpCode.NRefactory.VB/Ast/AstNode.cs index 8adca8fe18..d66abad926 100644 --- a/ICSharpCode.NRefactory.VB/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.VB/Ast/AstNode.cs @@ -677,16 +677,15 @@ namespace ICSharpCode.NRefactory.VB public static readonly Role XmlLiteralString = new Role("XmlLiteralString", Ast.XmlLiteralString.Null); // public static readonly Role Body = new Role("Body", CSharp.BlockStatement.Null); -// public static readonly Role Parameter = new Role("Parameter"); + public static readonly Role Parameter = new Role("Parameter"); public static readonly Role Argument = new Role("Argument", Ast.Expression.Null); public static readonly Role Type = new Role("Type", AstType.Null); public static readonly Role Expression = new Role("Expression", Ast.Expression.Null); // public static readonly Role TargetExpression = new Role("Target", CSharp.Expression.Null); // public readonly static Role Condition = new Role("Condition", CSharp.Expression.Null); // -// public static readonly Role TypeParameter = new Role("TypeParameter"); + public static readonly Role TypeParameter = new Role("TypeParameter"); public static readonly Role TypeArgument = new Role("TypeArgument", AstType.Null); -// public readonly static Role Constraint = new Role("Constraint"); // public static readonly Role Variable = new Role("Variable"); // public static readonly Role EmbeddedStatement = new Role("EmbeddedStatement", CSharp.Statement.Null); // diff --git a/ICSharpCode.NRefactory.VB/Ast/Enums.cs b/ICSharpCode.NRefactory.VB/Ast/Enums.cs index 41ba454e30..d0fc139296 100644 --- a/ICSharpCode.NRefactory.VB/Ast/Enums.cs +++ b/ICSharpCode.NRefactory.VB/Ast/Enums.cs @@ -21,7 +21,7 @@ namespace ICSharpCode.NRefactory.VB.Ast MustOverride = 0x0020, // Members Overridable = 0x0040, NotInheritable = 0x0080, // Types - NotOverridable = 0x0100, // Members + NotOverridable = 0x0100, // Members Const = 0x0200, Shared = 0x0400, Static = 0x0800, @@ -35,10 +35,15 @@ namespace ICSharpCode.NRefactory.VB.Ast WithEvents = 0x20000, // VB specific Default = 0x40000, // VB specific - Dim = 0x100000, // VB.NET SPECIFIC, for fields/local variables only + Dim = 0x80000, // VB.NET SPECIFIC, for fields/local variables only /// Only for VB properties. - WriteOnly = 0x200000, // VB specific + WriteOnly = 0x100000, // VB specific + + ByVal = 0x200000, + ByRef = 0x400000, + ParamArray = 0x800000, + Optional = 0x1000000, /// /// Special value used to match any modifiers during pattern matching. @@ -46,15 +51,6 @@ namespace ICSharpCode.NRefactory.VB.Ast Any = unchecked((int)0x80000000) } - public enum ClassType - { - Class, - Module, - Interface, - Struct, - Enum - } - public enum ParentType { ClassOrStruct, @@ -71,18 +67,6 @@ namespace ICSharpCode.NRefactory.VB.Ast Ref } - [Flags] - public enum ParameterModifiers - { - // Values must be the same as in SharpDevelop's ParameterModifiers - None = 0, - In = 1, - Out = 2, - Ref = 4, - Params = 8, - Optional = 16 - } - public enum VarianceModifier { Invariant, diff --git a/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs b/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs index e254b213b2..2e06d39172 100644 --- a/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs +++ b/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs @@ -8,6 +8,7 @@ namespace ICSharpCode.NRefactory.VB.Ast public class AttributeBlock : AstNode { public readonly static Role AttributeBlockRole = new Role("AttributeBlock"); + public readonly static Role ReturnTypeAttributeBlockRole = new Role("ReturnTypeAttributeBlock"); public VBTokenNode LChevron { get { return GetChildByRole(Roles.LChevron); } diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ModuleDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/General/AttributedNode.cs similarity index 90% rename from ICSharpCode.NRefactory.VB/Ast/GlobalScope/ModuleDeclaration.cs rename to ICSharpCode.NRefactory.VB/Ast/General/AttributedNode.cs index 6093b9cd07..37e364ee6b 100644 --- a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ModuleDeclaration.cs +++ b/ICSharpCode.NRefactory.VB/Ast/General/AttributedNode.cs @@ -63,18 +63,5 @@ namespace ICSharpCode.NRefactory.VB.Ast } } - public abstract class TypeDeclaration : AttributedNode - { - - } - - /// - /// Description of ModuleDeclaration. - /// - public class ModuleDeclaration - { - public ModuleDeclaration() - { - } - } + } diff --git a/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs new file mode 100644 index 0000000000..87b4162b4f --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs @@ -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(IAstVisitor visitor, T data) + { + return visitor.VisitParameterDeclaration(this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs new file mode 100644 index 0000000000..794615fc2a --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs @@ -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 +{ + /// + /// [In|Out] Name [As Contraints] + /// + /// Represents a type parameter. + /// + public class TypeParameterDeclaration : AstNode + { + public static readonly Role TypeConstraintRole = TypeDeclaration.InheritsTypeRole; + public static readonly Role VarianceRole = new Role("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 Constraints { + get { return GetChildrenByRole(TypeConstraintRole); } + } + + public override S AcceptVisitor(IAstVisitor 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); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs new file mode 100644 index 0000000000..bc2d06ca03 --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs @@ -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 TypeParameters { + get { return GetChildrenByRole(Roles.TypeParameter); } + } + + public Identifier Name { + get { return GetChildByRole(Roles.Identifier); } + set { SetChildByRole(Roles.Identifier, value); } + } + + public AstNodeCollection Parameters { + get { return GetChildrenByRole(Roles.Parameter); } + } + + public AstNodeCollection 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(IAstVisitor visitor, T data) + { + return visitor.VisitDelegateDeclaration(this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs new file mode 100644 index 0000000000..49fe3f239c --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs @@ -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 MemberRole = new Role("Member"); + public readonly static Role UnderlyingTypeRole = new Role("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 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(IAstVisitor visitor, T data) + { + return visitor.VisitEnumDeclaration(this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs new file mode 100644 index 0000000000..476ec56360 --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs @@ -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 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(IAstVisitor visitor, T data) + { + return visitor.VisitEnumMemberDeclaration(this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs new file mode 100644 index 0000000000..b91a753e03 --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs @@ -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 +{ + /// + /// Namespace Name + /// Members + /// End Namespace + /// + public class NamespaceDeclaration : AstNode + { + public static readonly Role 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 Identifiers { + get { return GetChildrenByRole (Roles.Identifier); } + } + + /// + /// Gets the full namespace name (including any parent namespaces) + /// + public string FullName { + get { + NamespaceDeclaration parentNamespace = Parent as NamespaceDeclaration; + if (parentNamespace != null) + return BuildQualifiedName (parentNamespace.FullName, Name); + return Name; + } + } + + public AstNodeCollection 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 (IAstVisitor 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); + } + } +}; diff --git a/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs new file mode 100644 index 0000000000..28b669d9c5 --- /dev/null +++ b/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs @@ -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 MemberRole = new Role("Member"); + public readonly static Role InheritsTypeRole = new Role("InheritsType", AstType.Null); + public readonly static Role ImplementsTypesRole = new Role("ImplementsTypes", AstType.Null); + + public AstNodeCollection 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 TypeParameters { + get { return GetChildrenByRole(Roles.TypeParameter); } + } + + public AstType InheritsType { + get { return GetChildByRole(InheritsTypeRole); } + } + + public AstNodeCollection 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(IAstVisitor visitor, T data) + { + return visitor.VisitTypeDeclaration(this, data); + } + } +} diff --git a/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs b/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs index 21fa3a0c6f..05a22acc44 100644 --- a/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs +++ b/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs @@ -58,7 +58,6 @@ namespace ICSharpCode.NRefactory.VB.Ast new KeyValuePair(Modifiers.WithEvents, "WithEvents".Length), new KeyValuePair(Modifiers.Default, "Default".Length), new KeyValuePair(Modifiers.Dim, "Dim".Length), - // even though it's used for patterns only, it needs to be in this table to be usable in the AST new KeyValuePair(Modifiers.Any, "Any".Length) diff --git a/ICSharpCode.NRefactory.VB/IAstVisitor.cs b/ICSharpCode.NRefactory.VB/IAstVisitor.cs index 8304874c4a..a2f8ac6c75 100644 --- a/ICSharpCode.NRefactory.VB/IAstVisitor.cs +++ b/ICSharpCode.NRefactory.VB/IAstVisitor.cs @@ -6,20 +6,28 @@ using ICSharpCode.NRefactory.VB.Ast; using Attribute = ICSharpCode.NRefactory.VB.Ast.Attribute; namespace ICSharpCode.NRefactory.VB { - public interface IAstVisitor { + public interface IAstVisitor + { + S VisitBlockStatement(BlockStatement blockStatement, T data); + S VisitCompilationUnit(CompilationUnit compilationUnit, T data); S VisitPatternPlaceholder(AstNode placeholder, PatternMatching.Pattern pattern, T data); + S VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, T data); + S VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, T data); S VisitVBTokenNode(VBTokenNode vBTokenNode, T data); - S VisitCompilationUnit(CompilationUnit compilationUnit, T data); - S VisitBlockStatement(BlockStatement blockStatement, T data); // Global scope - S VisitOptionStatement(OptionStatement optionStatement, T data); - S VisitImportsStatement(ImportsStatement importsStatement, T data); S VisitAliasImportsClause(AliasImportsClause aliasImportsClause, T data); - S VisitMembersImportsClause(MemberImportsClause membersImportsClause, T data); - S VisitXmlNamespaceImportsClause(XmlNamespaceImportsClause xmlNamespaceImportsClause, T data); S VisitAttribute(Attribute attribute, T data); S VisitAttributeBlock(AttributeBlock attributeBlock, T data); + S VisitImportsStatement(ImportsStatement importsStatement, T data); + S VisitMembersImportsClause(MemberImportsClause membersImportsClause, T data); + S VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, T data); + S VisitOptionStatement(OptionStatement optionStatement, T data); + S VisitTypeDeclaration(TypeDeclaration typeDeclaration, T data); + S VisitXmlNamespaceImportsClause(XmlNamespaceImportsClause xmlNamespaceImportsClause, T data); + S VisitEnumDeclaration(EnumDeclaration enumDeclaration, T data); + S VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, T data); + S VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, T data); // Expression scope S VisitIdentifier(Identifier identifier, T data); diff --git a/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj index a823b63ae8..1dac9e1d98 100644 --- a/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ b/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj @@ -54,11 +54,18 @@ + + + + + + - + + @@ -100,7 +107,6 @@ - vb.atg diff --git a/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs b/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs index 59af78011d..f4085b6bc7 100644 --- a/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs +++ b/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.IO; using ICSharpCode.NRefactory.PatternMatching; +using ICSharpCode.NRefactory.VB.Ast; namespace ICSharpCode.NRefactory.VB { @@ -40,145 +41,180 @@ namespace ICSharpCode.NRefactory.VB this.policy = formattingPolicy; } + public object VisitCompilationUnit(ICSharpCode.NRefactory.VB.Ast.CompilationUnit compilationUnit, object data) + { + // don't do node tracking as we visit all children directly + foreach (AstNode node in compilationUnit.Children) + node.AcceptVisitor(this, data); + return null; + } + + public object VisitBlockStatement(BlockStatement blockStatement, object data) + { + throw new NotImplementedException(); + } + public object VisitPatternPlaceholder(AstNode placeholder, Pattern pattern, object data) { throw new NotImplementedException(); } - public object VisitVBTokenNode(ICSharpCode.NRefactory.VB.Ast.VBTokenNode vBTokenNode, object data) + public object VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, object data) { throw new NotImplementedException(); } - public object VisitCompilationUnit(ICSharpCode.NRefactory.VB.Ast.CompilationUnit compilationUnit, object data) + public object VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, object data) { - // don't do node tracking as we visit all children directly - foreach (AstNode node in compilationUnit.Children) - node.AcceptVisitor(this, data); - return null; + throw new NotImplementedException(); } - public object VisitBlockStatement(ICSharpCode.NRefactory.VB.Ast.BlockStatement blockStatement, object data) + public object VisitVBTokenNode(VBTokenNode vBTokenNode, object data) { throw new NotImplementedException(); } - public object VisitOptionStatement(ICSharpCode.NRefactory.VB.Ast.OptionStatement optionStatement, object data) + public object VisitAliasImportsClause(AliasImportsClause aliasImportsClause, object data) { throw new NotImplementedException(); } - public object VisitImportsStatement(ICSharpCode.NRefactory.VB.Ast.ImportsStatement importsStatement, object data) + public object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) { throw new NotImplementedException(); } - public object VisitAliasImportsClause(ICSharpCode.NRefactory.VB.Ast.AliasImportsClause aliasImportsClause, object data) + public object VisitAttributeBlock(AttributeBlock attributeBlock, object data) { throw new NotImplementedException(); } - public object VisitMembersImportsClause(ICSharpCode.NRefactory.VB.Ast.MemberImportsClause membersImportsClause, object data) + public object VisitImportsStatement(ImportsStatement importsStatement, object data) { throw new NotImplementedException(); } - public object VisitXmlNamespaceImportsClause(ICSharpCode.NRefactory.VB.Ast.XmlNamespaceImportsClause xmlNamespaceImportsClause, object data) + public object VisitMembersImportsClause(MemberImportsClause membersImportsClause, object data) { throw new NotImplementedException(); } - public object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) + public object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) { throw new NotImplementedException(); } - public object VisitAttributeBlock(ICSharpCode.NRefactory.VB.Ast.AttributeBlock attributeBlock, object data) + public object VisitOptionStatement(OptionStatement optionStatement, object data) { throw new NotImplementedException(); } - public object VisitIdentifier(ICSharpCode.NRefactory.VB.Ast.Identifier identifier, object data) + public object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) { throw new NotImplementedException(); } - public object VisitXmlIdentifier(ICSharpCode.NRefactory.VB.Ast.XmlIdentifier xmlIdentifier, object data) + public object VisitXmlNamespaceImportsClause(XmlNamespaceImportsClause xmlNamespaceImportsClause, object data) { throw new NotImplementedException(); } - public object VisitSimpleNameExpression(ICSharpCode.NRefactory.VB.Ast.SimpleNameExpression identifierExpression, object data) + public object VisitEnumDeclaration(EnumDeclaration enumDeclaration, object data) { throw new NotImplementedException(); } - public object VisitPrimitiveExpression(ICSharpCode.NRefactory.VB.Ast.PrimitiveExpression primitiveExpression, object data) + public object VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data) { throw new NotImplementedException(); } - public object VisitPrimitiveType(ICSharpCode.NRefactory.VB.Ast.PrimitiveType primitiveType, object data) + public object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data) { throw new NotImplementedException(); } - public object VisitComposedType(ICSharpCode.NRefactory.VB.Ast.ComposedType composedType, object data) + public object VisitIdentifier(Identifier identifier, object data) { throw new NotImplementedException(); } - public object VisitArraySpecifier(ICSharpCode.NRefactory.VB.Ast.ArraySpecifier arraySpecifier, object data) + public object VisitXmlIdentifier(XmlIdentifier xmlIdentifier, object data) { throw new NotImplementedException(); } - public object VisitSimpleType(ICSharpCode.NRefactory.VB.Ast.SimpleType simpleType, object data) + public object VisitXmlLiteralString(XmlLiteralString xmlLiteralString, object data) { throw new NotImplementedException(); } - public object VisitAnyNode(AnyNode anyNode, object data) + public object VisitSimpleNameExpression(SimpleNameExpression identifierExpression, object data) { throw new NotImplementedException(); } - public object VisitBackreference(Backreference backreference, object data) + public object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) { throw new NotImplementedException(); } - public object VisitChoice(Choice choice, object data) + public object VisitPrimitiveType(PrimitiveType primitiveType, object data) { throw new NotImplementedException(); } - public object VisitNamedNode(NamedNode namedNode, object data) + public object VisitQualifiedType(QualifiedType qualifiedType, object data) { throw new NotImplementedException(); } - public object VisitRepeat(Repeat repeat, object data) + public object VisitComposedType(ComposedType composedType, object data) { throw new NotImplementedException(); } - public object VisitOptionalNode(OptionalNode optionalNode, object data) + public object VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) { throw new NotImplementedException(); } - public object VisitIdentifierExpressionBackreference(IdentifierExpressionBackreference identifierExpressionBackreference, object data) + public object VisitSimpleType(SimpleType simpleType, object data) { throw new NotImplementedException(); } - public object VisitXmlLiteralString(ICSharpCode.NRefactory.VB.Ast.XmlLiteralString xmlLiteralString, object data) + public object VisitAnyNode(AnyNode anyNode, object data) + { + throw new NotImplementedException(); + } + + public object VisitBackreference(Backreference backreference, object data) + { + throw new NotImplementedException(); + } + + public object VisitChoice(Choice choice, object data) { throw new NotImplementedException(); } - public object VisitQualifiedType(ICSharpCode.NRefactory.VB.Ast.QualifiedType qualifiedType, object data) + public object VisitNamedNode(NamedNode namedNode, object data) + { + throw new NotImplementedException(); + } + + public object VisitRepeat(Repeat repeat, object data) + { + throw new NotImplementedException(); + } + + public object VisitOptionalNode(OptionalNode optionalNode, object data) + { + throw new NotImplementedException(); + } + + public object VisitIdentifierExpressionBackreference(IdentifierExpressionBackreference identifierExpressionBackreference, object data) { throw new NotImplementedException(); } diff --git a/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs b/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs deleted file mode 100644 index f9a6c6dd9e..0000000000 --- a/ICSharpCode.NRefactory.VB/Parser/ParamModifierList.cs +++ /dev/null @@ -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."); - } - } - } -}