diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/AssemblyInfo.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/AssemblyInfo.cs deleted file mode 100644 index 065e001fe..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/AssemblyInfo.cs +++ /dev/null @@ -1,35 +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 System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("NRefactory Test")] -[assembly: AssemblyDescription("Unit tests for the parser and refactoring library for C# and VB.NET")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("ic#code")] -[assembly: AssemblyProduct("SharpDevelop")] -[assembly: AssemblyCopyright("2004-2006 AlphaSierraPapa")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("2.0.0.1")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs deleted file mode 100644 index def7d7d0f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/General/UnitTest.cs +++ /dev/null @@ -1,102 +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 System; -using System.Reflection; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; - -namespace ICSharpCode.NRefactory.VB.Tests -{ - [TestFixture] - public class StructuralTest - { -// [Test] -// public void TestToStringMethods() -// { -// Type[] allTypes = typeof(INode).Assembly.GetTypes(); -// -// foreach (Type type in allTypes) { -// if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null) { -// MethodInfo methodInfo = type.GetMethod("ToString", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); -// Assert.IsNotNull(methodInfo, "ToString() not found in " + type.FullName); -// } -// } -// } -// -// [Test] -// public void TestUnitTests() -// { -// Type[] allTypes = typeof(StructuralTest).Assembly.GetTypes(); -// -// foreach (Type type in allTypes) { -// if (type.GetCustomAttributes(typeof(TestFixtureAttribute), true).Length > 0) { -// foreach (MethodInfo m in type.GetMethods()) { -// if (m.IsPublic && m.ReturnType == typeof(void) && m.GetParameters().Length == 0) { -// if (m.GetCustomAttributes(typeof(TestAttribute), true).Length == 0) { -// Assert.Fail(type.Name + "." + m.Name + " should have the [Test] attribute!"); -// } -// } -// } -// } -// } -// } -// -// [Test] -// public void TestAcceptVisitorMethods() -// { -// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes(); -// -// foreach (Type type in allTypes) { -// if (type.IsClass && !type.IsAbstract && type.GetInterface(typeof(INode).FullName) != null) { -// MethodInfo methodInfo = type.GetMethod("AcceptVisitor", BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); -// Assertion.AssertNotNull("AcceptVisitor() not found in " + type.FullName, methodInfo); -// } -// } -// } -// -// [Test] -// public void TestIAstVisitor() -// { -// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes(); -// Type visitor = typeof(IAstVisitor); -// -// foreach (Type type in allTypes) { -// if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { -// MethodInfo methodInfo = visitor.GetMethod("Visit" + type.Name, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null); -// Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found"); -// Assert.AreEqual(2, methodInfo.GetParameters().Length); -// ParameterInfo first = methodInfo.GetParameters()[0]; -// Assert.AreEqual(Char.ToLower(first.ParameterType.Name[0]) + first.ParameterType.Name.Substring(1), first.Name); -// -// ParameterInfo second = methodInfo.GetParameters()[1]; -// Assert.AreEqual(typeof(System.Object), second.ParameterType); -// Assert.AreEqual("data", second.Name); -// } -// } -// } -// -// [Test] -// public void TestAbstractAstVisitorVisitor() -// { -// Type[] allTypes = typeof(AbstractNode).Assembly.GetTypes(); -// Type visitor = typeof(AbstractAstVisitor); -// -// foreach (Type type in allTypes) { -// if (type.IsClass && !type.IsAbstract && !type.IsNested && type.GetInterface(typeof(INode).FullName) != null && !type.Name.StartsWith("Null")) { -// MethodInfo methodInfo = visitor.GetMethod("Visit" + type.Name, BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.ExactBinding, null, new Type[] {type, typeof(object)}, null); -// Assert.IsNotNull(methodInfo, "Visit with parameter " + type.FullName + " not found"); -// -// Assert.AreEqual(2, methodInfo.GetParameters().Length); -// ParameterInfo first = methodInfo.GetParameters()[0]; -// Assert.AreEqual(Char.ToLower(first.ParameterType.Name[0]) + first.ParameterType.Name.Substring(1), first.Name); -// -// ParameterInfo second = methodInfo.GetParameters()[1]; -// Assert.AreEqual(typeof(System.Object), second.ParameterType); -// Assert.AreEqual("data", second.Name); -// } -// } -// } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj deleted file mode 100644 index ee1d38229..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/ICSharpCode.NRefactory.VB.Tests.csproj +++ /dev/null @@ -1,109 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50215 - 2.0 - {870115DD-960A-4406-A6B9-600BCDC36A03} - ICSharpCode.NRefactory.VB.Tests - ICSharpCode.NRefactory.VB.Tests - Library - False - False - OnBuildSuccess - Library - bin\$(Configuration)\ - False - 4 - v4.0 - False - Client - False - obj\$(Configuration)\ - - - True - DEBUG - False - - - True - False - - - Full - true - Project - obj\ - - - False - - - False - Auto - 4194304 - 4096 - AnyCPU - - - True - DEBUG - False - - - True - False - - - False - Auto - 4194304 - 4096 - x86 - - - - ..\..\ICSharpCode.Decompiler\Tests\nunit.framework.dll - - - - 3.5 - - - - - - - - - - - - - - - - - - - - - - - - - {7b82b671-419f-45f4-b778-d9286f996efa} - ICSharpCode.NRefactory.VB - - - {3b2a5653-ec97-4001-bb9b-d90f1af2c371} - ICSharpCode.NRefactory - - - - - - - \ No newline at end of file diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/CustomLexerTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/CustomLexerTests.cs deleted file mode 100644 index c37cf1b02..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/CustomLexerTests.cs +++ /dev/null @@ -1,118 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class CustomLexerTests - { - VBLexer GenerateLexer(StringReader sr) - { - return new VBLexer(sr); - } - - [Test] - public void TestSingleEOLForMulitpleLines() - { - VBLexer lexer = GenerateLexer(new StringReader("Stop\n\n\nEnd")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Stop)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.End)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void TestSingleEOLForMulitpleLinesWithContinuation() - { - VBLexer lexer = GenerateLexer(new StringReader("Stop\n _\n\nEnd")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Stop)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.End)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void EscapedIdentifier() - { - VBLexer lexer = GenerateLexer(new StringReader("[Stop]")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void IdentifierWithTypeCharacter() - { - VBLexer lexer = GenerateLexer(new StringReader("Stop$")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void ExclamationMarkIsTypeCharacter() - { - VBLexer lexer = GenerateLexer(new StringReader("a!=b")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Assign)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void ExclamationMarkIsTypeCharacter2() - { - VBLexer lexer = GenerateLexer(new StringReader("a! b")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void ExclamationMarkIsIdentifier() - { - VBLexer lexer = GenerateLexer(new StringReader("a!b")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.ExclamationMark)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void ExclamationMarkIsIdentifier2() - { - VBLexer lexer = GenerateLexer(new StringReader("a![b]")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.ExclamationMark)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void RemCommentTest() - { - VBLexer lexer = GenerateLexer(new StringReader("a rem b")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.Identifier)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOL)); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - - [Test] - public void RemCommentTest2() - { - VBLexer lexer = GenerateLexer(new StringReader("REM c")); - Assert.That(lexer.NextToken().Kind, Is.EqualTo(Tokens.EOF)); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/ImplicitLineContinuationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/ImplicitLineContinuationTests.cs deleted file mode 100644 index 8e5bcdb71..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/ImplicitLineContinuationTests.cs +++ /dev/null @@ -1,230 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class ImplicitLineContinuationTests - { - [Test] - public void Example1() - { - string code = @"Module Test - Sub Print( - Param1 As Integer, - Param2 As Integer) - - If (Param1 < Param2) Or - (Param1 > Param2) Then - Console.WriteLine(""Not equal"") - End If - End Sub -End Module"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens(lexer, Tokens.Module, Tokens.Identifier, Tokens.EOL, - Tokens.Sub, Tokens.Identifier, Tokens.OpenParenthesis, - Tokens.Identifier, Tokens.As, Tokens.Integer, Tokens.Comma, - Tokens.Identifier, Tokens.As, Tokens.Integer, Tokens.CloseParenthesis, Tokens.EOL, - Tokens.If, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.LessThan, Tokens.Identifier, Tokens.CloseParenthesis, Tokens.Or, - Tokens.OpenParenthesis, Tokens.Identifier, Tokens.GreaterThan, Tokens.Identifier, Tokens.CloseParenthesis, Tokens.Then, Tokens.EOL, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.LiteralString, Tokens.CloseParenthesis, Tokens.EOL, - Tokens.End, Tokens.If, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Module); - } - - [Test] - public void QualifierInWith() - { - string code = @"Module Test - Sub Print - With xml - Dim a = b. - d - Dim c = . - Count - End With - End Sub -End Module"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens(lexer, Tokens.Module, Tokens.Identifier, Tokens.EOL, - Tokens.Sub, Tokens.Identifier, Tokens.EOL, - Tokens.With, Tokens.Identifier, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.Dot, Tokens.EOL, - Tokens.Identifier, Tokens.EOL, - Tokens.End, Tokens.With, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Module); - } - - [Test] - public void Example2() - { - string code = @"Module Test - Sub Print - Dim a = _ - - y - End Sub -End Module"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens(lexer, Tokens.Module, Tokens.Identifier, Tokens.EOL, - Tokens.Sub, Tokens.Identifier, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.EOL, Tokens.Identifier, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Module); - } - - [Test] - public void Query() - { - string code = @"Module Test - Sub A - Dim q = From x In a - Select x - End Sub -End Module"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens(lexer, Tokens.Module, Tokens.Identifier, Tokens.EOL, - Tokens.Sub, Tokens.Identifier, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, - Tokens.Select, Tokens.Identifier, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Module); - } - - [Test] - public void Query1() - { - string code = @"Module Test - Sub A - Dim actions = From a in b Select Sub() - Dim i = 1 - Select Case i - End Select - End Sub - End Sub -End Module"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens(lexer, Tokens.Module, Tokens.Identifier, Tokens.EOL, - Tokens.Sub, Tokens.Identifier, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, Tokens.Select, Tokens.Sub, Tokens.OpenParenthesis, Tokens.CloseParenthesis, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.LiteralInteger, Tokens.EOL, - Tokens.Select, Tokens.Case, Tokens.Identifier, Tokens.EOL, - Tokens.End, Tokens.Select, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Module); - } - - /// tests http://community.sharpdevelop.net/forums/p/12068/32893.aspx#32893 - [Test] - public void Bug_Thread12068() - { - string code = @"Class MainClass - Public Shared Sub Main() - Dim categoryNames = From p In AList _ - Select p.AFunction(1,2,3) _ - Distinct - End Sub -End Class"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens( - lexer, Tokens.Class, Tokens.Identifier, Tokens.EOL, - Tokens.Public, Tokens.Shared, Tokens.Sub, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.CloseParenthesis, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, - Tokens.Select, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.LiteralInteger, - Tokens.Comma, Tokens.LiteralInteger, Tokens.Comma, Tokens.LiteralInteger, Tokens.CloseParenthesis, - Tokens.Distinct, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Class - ); - } - - [Test] - public void LineContinuationAfterAttributes() - { - string code = @" -Public Class TestContinuation - - Public Sub TestMethod - Assert.Fail - End Sub - - _ - Public Sub TestMethod2 - Assert.Fail - End Sub -End Class"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens( - lexer, Tokens.LessThan, Tokens.Identifier, Tokens.GreaterThan, - Tokens.Public, Tokens.Class, Tokens.Identifier, Tokens.EOL, - Tokens.LessThan, Tokens.Identifier, Tokens.GreaterThan, - Tokens.Public, Tokens.Sub, Tokens.Identifier, Tokens.EOL, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.LessThan, Tokens.Identifier, Tokens.GreaterThan, - Tokens.Public, Tokens.Sub, Tokens.Identifier, Tokens.EOL, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.EOL, - Tokens.End, Tokens.Sub, Tokens.EOL, - Tokens.End, Tokens.Class - ); - } - - [Test] - public void NoILCAfterGlobalAttributes() - { - string code = "" + Environment.NewLine + - ""; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens( - lexer, Tokens.LessThan, Tokens.Assembly, Tokens.Colon, - Tokens.Identifier, Tokens.OpenParenthesis, Tokens.LiteralString, - Tokens.CloseParenthesis, Tokens.GreaterThan, Tokens.EOL, - Tokens.LessThan, Tokens.Assembly, Tokens.Colon, - Tokens.Identifier, Tokens.OpenParenthesis, Tokens.LiteralString, - Tokens.CloseParenthesis, Tokens.GreaterThan - ); - } - - #region Helpers - VBLexer GenerateLexer(StringReader sr) - { - return new VBLexer(sr); - } - - void CheckTokens(VBLexer lexer, params int[] tokens) - { - for (int i = 0; i < tokens.Length; i++) { - int token = tokens[i]; - Token t = lexer.NextToken(); - int next = t.Kind; - Assert.AreEqual(token, next, "{2} of {3}: {0} != {1}; at {4}", Tokens.GetTokenString(token), Tokens.GetTokenString(next), i + 1, tokens.Length, t.Location); - } - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LATextReaderTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LATextReaderTests.cs deleted file mode 100644 index 2671dad2e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LATextReaderTests.cs +++ /dev/null @@ -1,35 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class LATextReaderTests - { - [Test] - public void TestPeek() - { - LATextReader reader = new LATextReader(new StringReader("abcd")); - - CheckPeek(reader, 0, 'a'); - CheckPeek(reader, 2, 'c'); - CheckPeek(reader, 3, 'd'); - CheckPeek(reader, 1, 'b'); - CheckPeek(reader, 0, 'a'); - Assert.AreEqual((int)'a', reader.Read()); - CheckPeek(reader, 1, 'c'); - CheckPeek(reader, 2, 'd'); - CheckPeek(reader, 0, 'b'); - } - - void CheckPeek(LATextReader reader, int num1, char char2) - { - Assert.AreEqual((int)char2, reader.Peek(num1)); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs deleted file mode 100644 index 770584a0b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerContextTests.cs +++ /dev/null @@ -1,575 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class LexerContextTests - { - [Test] - public void SimpleGlobal() - { - RunTest( - @"Option Explicit", - @"enter Global -exit Global -" - ); - } - - [Test] - public void VariableWithXmlLiteral() - { - RunTest( - @"Class Test - Public Sub New() - Dim x = - End Sub -End Class -", - @"enter Global - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Body - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - enter Xml - enter Xml - exit Xml - exit Xml - exit Expression - exit Expression - exit Expression - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void MemberWithXmlLiteral() - { - RunTest( - @"Class Test - Private xml As XElement = - - Public Sub New() - Dim x = - End Sub -End Class -", - @"enter Global - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Type - exit Type - enter Expression - enter Expression - enter Expression - enter Xml - enter Xml - exit Xml - exit Xml - exit Expression - exit Expression - exit Expression - exit Member - enter Member - enter Identifier - exit Identifier - enter Body - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - enter Xml - enter Xml - exit Xml - exit Xml - exit Expression - exit Expression - exit Expression - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void GlobalAttributeTest() - { - RunTest( - @" -Class Test - Public Sub New() - Dim x = 5 - End Sub -End Class -", - @"enter Global - enter Attribute - exit Attribute - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Body - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void ClassAttributeTest() - { - RunTest( - @" -Class Test - Public Sub New() - Dim x = 5 - End Sub -End Class -", - @"enter Global - enter Attribute - exit Attribute - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Body - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void MethodAttributeTest() - { - RunTest( - @"Class Test - - Public Sub New() - Dim x = 5 - End Sub -End Class -", - @"enter Global - enter TypeDeclaration - enter Identifier - exit Identifier - enter Attribute - exit Attribute - enter Member - enter Identifier - exit Identifier - enter Body - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void WithBlockTest() - { - RunTest( - @"Class Test - Public Sub New() - With x - - End With - End Sub -End Class -", - @"enter Global - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Body - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Body - exit Body - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void StatementsTest() - { - RunTest( - @"Class Test - Public Sub New() - For i As Integer = 0 To 10 - - Next - - For Each x As Integer In list - - Next - - Try - - Catch e As Exception - - End Try - End Sub -End Class -", - @"enter Global - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Body - enter Identifier - enter Expression - exit Expression - exit Identifier - enter Type - exit Type - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Body - exit Body - enter Identifier - enter Expression - exit Expression - exit Identifier - enter Type - exit Type - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Body - exit Body - enter Body - exit Body - enter Identifier - exit Identifier - enter Type - exit Type - enter Body - exit Body - exit Body - exit Member - exit TypeDeclaration -exit Global -" - ); - } - - [Test] - public void ClassTest() - { - RunTest( - @"Class MainClass ' a comment - Dim under_score_field As Integer - Sub SomeMethod() - simple += 1 - For Each loopVarName In collection - Next - End Sub -End Class", - @"enter Global - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Type - exit Type - exit Member - enter Member - enter Identifier - exit Identifier - enter Body - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Identifier - enter Expression - exit Expression - exit Identifier - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Body - exit Body - exit Body - exit Member - exit TypeDeclaration -exit Global -"); - } - - [Test] - public void CollectionInitializer() - { - RunTest(@"' -' Created by SharpDevelop. -' User: Siegfried -' Date: 22.06.2010 -' Time: 21:29 -' -' To change this template use Tools | Options | Coding | Edit Standard Headers. -' - -Option Infer On - -Imports System.Linq -Imports System.Xml.Linq - -Module Program - Sub Main() - Console.WriteLine(""Hello World!"") - - Dim name = ""Test"" - Dim content = { 4, 5, New XAttribute(""a"", 3) } - - Dim xml = <<%= name %> <%= content %> /> - - Console.ReadKey() - End Sub -End Module", - @"enter Global - enter Importable - exit Importable - enter Importable - exit Importable - enter TypeDeclaration - enter Identifier - exit Identifier - enter Member - enter Identifier - exit Identifier - enter Body - enter Expression - enter Expression - enter Expression - exit Expression - enter Expression - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Expression - exit Expression - exit Expression - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Expression - enter Expression - enter ObjectCreation - enter Expression - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Expression - exit ObjectCreation - exit Expression - exit Expression - exit Expression - exit Expression - enter Identifier - exit Identifier - enter Expression - enter Expression - enter Expression - enter Xml - enter Xml - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - enter Expression - enter Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Xml - exit Xml - exit Expression - exit Expression - exit Expression - enter Expression - enter Expression - enter Expression - exit Expression - enter Expression - exit Expression - exit Expression - exit Expression - exit Body - exit Member - exit TypeDeclaration -exit Global -"); - } - - [Test] - public void Imports() - { - RunTest(@"Imports System -Imports System.Linq -Imports System.Collections.Generic", - @"enter Global - enter Importable - exit Importable - enter Importable - exit Importable - enter Importable - exit Importable -exit Global -"); - } - - void RunTest(string code, string expectedOutput) - { - ExpressionFinder p = new ExpressionFinder(); - VBLexer lexer = new VBLexer(new StringReader(code)); - Token t; - - do { - t = lexer.NextToken(); - p.InformToken(t); - } while (t.Kind != Tokens.EOF); - - Console.WriteLine(p.Output); - - Assert.IsEmpty(p.Errors); - - Assert.AreEqual(expectedOutput.Replace("\r", ""), - p.Output.Replace("\r", "")); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerPositionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerPositionTests.cs deleted file mode 100644 index 47c52f8ee..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerPositionTests.cs +++ /dev/null @@ -1,87 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class LexerPositionTests - { - VBLexer GenerateLexer(string s) - { - return new VBLexer(new StringReader(s)); - } - - [Test] - public void TestNewLine() - { - VBLexer l = GenerateLexer("public\nstatic"); - Token t = l.NextToken(); - Assert.AreEqual(Tokens.Public, t.Kind); - Assert.AreEqual(new TextLocation(1, 1), t.Location); - Assert.AreEqual(new TextLocation(1, 7), t.EndLocation); - t = l.NextToken(); - Assert.AreEqual(Tokens.EOL, t.Kind); - Assert.AreEqual(new TextLocation(1, 7), t.Location); - Assert.AreEqual(new TextLocation(2, 1), t.EndLocation); - t = l.NextToken(); - Assert.AreEqual(Tokens.Static, t.Kind); - Assert.AreEqual(new TextLocation(2, 1), t.Location); - Assert.AreEqual(new TextLocation(2, 7), t.EndLocation); - } - - [Test] - public void TestCarriageReturnNewLine() - { - VBLexer l = GenerateLexer("public\r\nstatic"); - Token t = l.NextToken(); - Assert.AreEqual(Tokens.Public, t.Kind); - Assert.AreEqual(new TextLocation(1, 1), t.Location); - Assert.AreEqual(new TextLocation(1, 7), t.EndLocation); - t = l.NextToken(); - Assert.AreEqual(Tokens.EOL, t.Kind); - Assert.AreEqual(new TextLocation(1, 7), t.Location); - Assert.AreEqual(new TextLocation(2, 1), t.EndLocation); - t = l.NextToken(); - Assert.AreEqual(Tokens.Static, t.Kind); - Assert.AreEqual(new TextLocation(2, 1), t.Location); - Assert.AreEqual(new TextLocation(2, 7), t.EndLocation); - } - - [Test] - public void TestPositionOfEOF1() - { - VBLexer l = GenerateLexer("public"); - l.NextToken(); // public - Token t = l.NextToken(); - Assert.AreEqual(Tokens.EOL, t.Kind); - Assert.AreEqual(new TextLocation(1, 7), t.Location); - Assert.AreEqual(new TextLocation(1, 7), t.EndLocation); - - t = l.NextToken(); - Assert.AreEqual(Tokens.EOF, t.Kind); - Assert.AreEqual(new TextLocation(1, 7), t.Location); - Assert.AreEqual(new TextLocation(1, 7), t.EndLocation); - } - - [Test] - public void TestPositionOfEOF2() - { - VBLexer l = GenerateLexer("public _\n "); - l.NextToken(); // public - Token t = l.NextToken(); - Assert.AreEqual(Tokens.EOL, t.Kind); - Assert.AreEqual(new TextLocation(2, 2), t.Location); - Assert.AreEqual(new TextLocation(2, 2), t.EndLocation); - - t = l.NextToken(); - Assert.AreEqual(Tokens.EOF, t.Kind); - Assert.AreEqual(new TextLocation(2, 2), t.Location); - Assert.AreEqual(new TextLocation(2, 2), t.EndLocation); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerTests.cs deleted file mode 100644 index 9b2ec8386..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LexerTests.cs +++ /dev/null @@ -1,1538 +0,0 @@ -// this file was autogenerated by a tool. -using System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.PrettyPrinter; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public sealed class LexerTests - { - VBLexer GenerateLexer(StringReader sr) - { - return new VBLexer(sr); - } - - [Test] - public void TestAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("=")); - Assert.AreEqual(Tokens.Assign, lexer.NextToken().Kind); - } - - [Test] - public void TestColon() - { - VBLexer lexer = GenerateLexer(new StringReader(":")); - Assert.AreEqual(Tokens.Colon, lexer.NextToken().Kind); - } - - [Test] - public void TestComma() - { - VBLexer lexer = GenerateLexer(new StringReader(",")); - Assert.AreEqual(Tokens.Comma, lexer.NextToken().Kind); - } - - [Test] - public void TestConcatString() - { - VBLexer lexer = GenerateLexer(new StringReader("&")); - Assert.AreEqual(Tokens.ConcatString, lexer.NextToken().Kind); - } - - [Test] - public void TestDiv() - { - VBLexer lexer = GenerateLexer(new StringReader("/")); - Assert.AreEqual(Tokens.Div, lexer.NextToken().Kind); - } - - [Test] - public void TestDivInteger() - { - VBLexer lexer = GenerateLexer(new StringReader("\\")); - Assert.AreEqual(Tokens.DivInteger, lexer.NextToken().Kind); - } - - [Test] - public void TestDot() - { - VBLexer lexer = GenerateLexer(new StringReader(".")); - Assert.AreEqual(Tokens.Dot, lexer.NextToken().Kind); - } - - [Test] - public void TestTripleDot() - { - VBLexer lexer = GenerateLexer(new StringReader("...")); - Assert.AreEqual(Tokens.TripleDot, lexer.NextToken().Kind); - } - - [Test] - public void TestDotAt() - { - VBLexer lexer = GenerateLexer(new StringReader(".@")); - Assert.AreEqual(Tokens.DotAt, lexer.NextToken().Kind); - } - - [Test] - public void TestExclamationMark() - { - VBLexer lexer = GenerateLexer(new StringReader("!")); - Assert.AreEqual(Tokens.ExclamationMark, lexer.NextToken().Kind); - } - - [Test] - public void TestMinus() - { - VBLexer lexer = GenerateLexer(new StringReader("-")); - Assert.AreEqual(Tokens.Minus, lexer.NextToken().Kind); - } - - [Test] - public void TestPlus() - { - VBLexer lexer = GenerateLexer(new StringReader("+")); - Assert.AreEqual(Tokens.Plus, lexer.NextToken().Kind); - } - - [Test] - public void TestPower() - { - VBLexer lexer = GenerateLexer(new StringReader("^")); - Assert.AreEqual(Tokens.Power, lexer.NextToken().Kind); - } - - [Test] - public void TestQuestionMark() - { - VBLexer lexer = GenerateLexer(new StringReader("?")); - Assert.AreEqual(Tokens.QuestionMark, lexer.NextToken().Kind); - } - - [Test] - public void TestTimes() - { - VBLexer lexer = GenerateLexer(new StringReader("*")); - Assert.AreEqual(Tokens.Times, lexer.NextToken().Kind); - } - - [Test] - public void TestOpenCurlyBrace() - { - VBLexer lexer = GenerateLexer(new StringReader("{")); - Assert.AreEqual(Tokens.OpenCurlyBrace, lexer.NextToken().Kind); - } - - [Test] - public void TestCloseCurlyBrace() - { - VBLexer lexer = GenerateLexer(new StringReader("}")); - Assert.AreEqual(Tokens.CloseCurlyBrace, lexer.NextToken().Kind); - } - - [Test] - public void TestOpenParenthesis() - { - VBLexer lexer = GenerateLexer(new StringReader("(")); - Assert.AreEqual(Tokens.OpenParenthesis, lexer.NextToken().Kind); - } - - [Test] - public void TestCloseParenthesis() - { - VBLexer lexer = GenerateLexer(new StringReader(")")); - Assert.AreEqual(Tokens.CloseParenthesis, lexer.NextToken().Kind); - } - - [Test] - public void TestGreaterThan() - { - VBLexer lexer = GenerateLexer(new StringReader(">")); - Assert.AreEqual(Tokens.GreaterThan, lexer.NextToken().Kind); - } - - [Test] - public void TestLessThan() - { - VBLexer lexer = GenerateLexer(new StringReader("<")); - Assert.AreEqual(Tokens.LessThan, lexer.NextToken().Kind); - } - - [Test] - public void TestNotEqual() - { - VBLexer lexer = GenerateLexer(new StringReader("<>")); - Assert.AreEqual(Tokens.NotEqual, lexer.NextToken().Kind); - } - - [Test] - public void TestGreaterEqual() - { - VBLexer lexer = GenerateLexer(new StringReader(">=")); - Assert.AreEqual(Tokens.GreaterEqual, lexer.NextToken().Kind); - } - - [Test] - public void TestLessEqual() - { - VBLexer lexer = GenerateLexer(new StringReader("<=")); - Assert.AreEqual(Tokens.LessEqual, lexer.NextToken().Kind); - } - - [Test] - public void TestShiftLeft() - { - VBLexer lexer = GenerateLexer(new StringReader("<<")); - Assert.AreEqual(Tokens.ShiftLeft, lexer.NextToken().Kind); - } - - [Test] - public void TestShiftRight() - { - VBLexer lexer = GenerateLexer(new StringReader(">>")); - Assert.AreEqual(Tokens.ShiftRight, lexer.NextToken().Kind); - } - - [Test] - public void TestPlusAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("+=")); - Assert.AreEqual(Tokens.PlusAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestPowerAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("^=")); - Assert.AreEqual(Tokens.PowerAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestMinusAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("-=")); - Assert.AreEqual(Tokens.MinusAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestTimesAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("*=")); - Assert.AreEqual(Tokens.TimesAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestDivAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("/=")); - Assert.AreEqual(Tokens.DivAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestDivIntegerAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("\\=")); - Assert.AreEqual(Tokens.DivIntegerAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestShiftLeftAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("<<=")); - Assert.AreEqual(Tokens.ShiftLeftAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestShiftRightAssign() - { - VBLexer lexer = GenerateLexer(new StringReader(">>=")); - Assert.AreEqual(Tokens.ShiftRightAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestConcatStringAssign() - { - VBLexer lexer = GenerateLexer(new StringReader("&=")); - Assert.AreEqual(Tokens.ConcatStringAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestColonAssign() - { - VBLexer lexer = GenerateLexer(new StringReader(":=")); - Assert.AreEqual(Tokens.ColonAssign, lexer.NextToken().Kind); - } - - [Test] - public void TestAddHandler() - { - VBLexer lexer = GenerateLexer(new StringReader("AddHandler")); - Assert.AreEqual(Tokens.AddHandler, lexer.NextToken().Kind); - } - - [Test] - public void TestAddressOf() - { - VBLexer lexer = GenerateLexer(new StringReader("AddressOf")); - Assert.AreEqual(Tokens.AddressOf, lexer.NextToken().Kind); - } - - [Test] - public void TestAggregate() - { - VBLexer lexer = GenerateLexer(new StringReader("Aggregate")); - Assert.AreEqual(Tokens.Aggregate, lexer.NextToken().Kind); - } - - [Test] - public void TestAlias() - { - VBLexer lexer = GenerateLexer(new StringReader("Alias")); - Assert.AreEqual(Tokens.Alias, lexer.NextToken().Kind); - } - - [Test] - public void TestAnd() - { - VBLexer lexer = GenerateLexer(new StringReader("And")); - Assert.AreEqual(Tokens.And, lexer.NextToken().Kind); - } - - [Test] - public void TestAndAlso() - { - VBLexer lexer = GenerateLexer(new StringReader("AndAlso")); - Assert.AreEqual(Tokens.AndAlso, lexer.NextToken().Kind); - } - - [Test] - public void TestAnsi() - { - VBLexer lexer = GenerateLexer(new StringReader("Ansi")); - Assert.AreEqual(Tokens.Ansi, lexer.NextToken().Kind); - } - - [Test] - public void TestAs() - { - VBLexer lexer = GenerateLexer(new StringReader("As")); - Assert.AreEqual(Tokens.As, lexer.NextToken().Kind); - } - - [Test] - public void TestAscending() - { - VBLexer lexer = GenerateLexer(new StringReader("Ascending")); - Assert.AreEqual(Tokens.Ascending, lexer.NextToken().Kind); - } - - [Test] - public void TestAssembly() - { - VBLexer lexer = GenerateLexer(new StringReader("Assembly")); - Assert.AreEqual(Tokens.Assembly, lexer.NextToken().Kind); - } - - [Test] - public void TestAuto() - { - VBLexer lexer = GenerateLexer(new StringReader("Auto")); - Assert.AreEqual(Tokens.Auto, lexer.NextToken().Kind); - } - - [Test] - public void TestBinary() - { - VBLexer lexer = GenerateLexer(new StringReader("Binary")); - Assert.AreEqual(Tokens.Binary, lexer.NextToken().Kind); - } - - [Test] - public void TestBoolean() - { - VBLexer lexer = GenerateLexer(new StringReader("Boolean")); - Assert.AreEqual(Tokens.Boolean, lexer.NextToken().Kind); - } - - [Test] - public void TestByRef() - { - VBLexer lexer = GenerateLexer(new StringReader("ByRef")); - Assert.AreEqual(Tokens.ByRef, lexer.NextToken().Kind); - } - - [Test] - public void TestBy() - { - VBLexer lexer = GenerateLexer(new StringReader("By")); - Assert.AreEqual(Tokens.By, lexer.NextToken().Kind); - } - - [Test] - public void TestByte() - { - VBLexer lexer = GenerateLexer(new StringReader("Byte")); - Assert.AreEqual(Tokens.Byte, lexer.NextToken().Kind); - } - - [Test] - public void TestByVal() - { - VBLexer lexer = GenerateLexer(new StringReader("ByVal")); - Assert.AreEqual(Tokens.ByVal, lexer.NextToken().Kind); - } - - [Test] - public void TestCall() - { - VBLexer lexer = GenerateLexer(new StringReader("Call")); - Assert.AreEqual(Tokens.Call, lexer.NextToken().Kind); - } - - [Test] - public void TestCase() - { - VBLexer lexer = GenerateLexer(new StringReader("Case")); - Assert.AreEqual(Tokens.Case, lexer.NextToken().Kind); - } - - [Test] - public void TestCatch() - { - VBLexer lexer = GenerateLexer(new StringReader("Catch")); - Assert.AreEqual(Tokens.Catch, lexer.NextToken().Kind); - } - - [Test] - public void TestCBool() - { - VBLexer lexer = GenerateLexer(new StringReader("CBool")); - Assert.AreEqual(Tokens.CBool, lexer.NextToken().Kind); - } - - [Test] - public void TestCByte() - { - VBLexer lexer = GenerateLexer(new StringReader("CByte")); - Assert.AreEqual(Tokens.CByte, lexer.NextToken().Kind); - } - - [Test] - public void TestCChar() - { - VBLexer lexer = GenerateLexer(new StringReader("CChar")); - Assert.AreEqual(Tokens.CChar, lexer.NextToken().Kind); - } - - [Test] - public void TestCDate() - { - VBLexer lexer = GenerateLexer(new StringReader("CDate")); - Assert.AreEqual(Tokens.CDate, lexer.NextToken().Kind); - } - - [Test] - public void TestCDbl() - { - VBLexer lexer = GenerateLexer(new StringReader("CDbl")); - Assert.AreEqual(Tokens.CDbl, lexer.NextToken().Kind); - } - - [Test] - public void TestCDec() - { - VBLexer lexer = GenerateLexer(new StringReader("CDec")); - Assert.AreEqual(Tokens.CDec, lexer.NextToken().Kind); - } - - [Test] - public void TestChar() - { - VBLexer lexer = GenerateLexer(new StringReader("Char")); - Assert.AreEqual(Tokens.Char, lexer.NextToken().Kind); - } - - [Test] - public void TestCInt() - { - VBLexer lexer = GenerateLexer(new StringReader("CInt")); - Assert.AreEqual(Tokens.CInt, lexer.NextToken().Kind); - } - - [Test] - public void TestClass() - { - VBLexer lexer = GenerateLexer(new StringReader("Class")); - Assert.AreEqual(Tokens.Class, lexer.NextToken().Kind); - } - - [Test] - public void TestCLng() - { - VBLexer lexer = GenerateLexer(new StringReader("CLng")); - Assert.AreEqual(Tokens.CLng, lexer.NextToken().Kind); - } - - [Test] - public void TestCObj() - { - VBLexer lexer = GenerateLexer(new StringReader("CObj")); - Assert.AreEqual(Tokens.CObj, lexer.NextToken().Kind); - } - - [Test] - public void TestCompare() - { - VBLexer lexer = GenerateLexer(new StringReader("Compare")); - Assert.AreEqual(Tokens.Compare, lexer.NextToken().Kind); - } - - [Test] - public void TestConst() - { - VBLexer lexer = GenerateLexer(new StringReader("Const")); - Assert.AreEqual(Tokens.Const, lexer.NextToken().Kind); - } - - [Test] - public void TestContinue() - { - VBLexer lexer = GenerateLexer(new StringReader("Continue")); - Assert.AreEqual(Tokens.Continue, lexer.NextToken().Kind); - } - - [Test] - public void TestCSByte() - { - VBLexer lexer = GenerateLexer(new StringReader("CSByte")); - Assert.AreEqual(Tokens.CSByte, lexer.NextToken().Kind); - } - - [Test] - public void TestCShort() - { - VBLexer lexer = GenerateLexer(new StringReader("CShort")); - Assert.AreEqual(Tokens.CShort, lexer.NextToken().Kind); - } - - [Test] - public void TestCSng() - { - VBLexer lexer = GenerateLexer(new StringReader("CSng")); - Assert.AreEqual(Tokens.CSng, lexer.NextToken().Kind); - } - - [Test] - public void TestCStr() - { - VBLexer lexer = GenerateLexer(new StringReader("CStr")); - Assert.AreEqual(Tokens.CStr, lexer.NextToken().Kind); - } - - [Test] - public void TestCType() - { - VBLexer lexer = GenerateLexer(new StringReader("CType")); - Assert.AreEqual(Tokens.CType, lexer.NextToken().Kind); - } - - [Test] - public void TestCUInt() - { - VBLexer lexer = GenerateLexer(new StringReader("CUInt")); - Assert.AreEqual(Tokens.CUInt, lexer.NextToken().Kind); - } - - [Test] - public void TestCULng() - { - VBLexer lexer = GenerateLexer(new StringReader("CULng")); - Assert.AreEqual(Tokens.CULng, lexer.NextToken().Kind); - } - - [Test] - public void TestCUShort() - { - VBLexer lexer = GenerateLexer(new StringReader("CUShort")); - Assert.AreEqual(Tokens.CUShort, lexer.NextToken().Kind); - } - - [Test] - public void TestCustom() - { - VBLexer lexer = GenerateLexer(new StringReader("Custom")); - Assert.AreEqual(Tokens.Custom, lexer.NextToken().Kind); - } - - [Test] - public void TestDate() - { - VBLexer lexer = GenerateLexer(new StringReader("Date")); - Assert.AreEqual(Tokens.Date, lexer.NextToken().Kind); - } - - [Test] - public void TestDecimal() - { - VBLexer lexer = GenerateLexer(new StringReader("Decimal")); - Assert.AreEqual(Tokens.Decimal, lexer.NextToken().Kind); - } - - [Test] - public void TestDeclare() - { - VBLexer lexer = GenerateLexer(new StringReader("Declare")); - Assert.AreEqual(Tokens.Declare, lexer.NextToken().Kind); - } - - [Test] - public void TestDefault() - { - VBLexer lexer = GenerateLexer(new StringReader("Default")); - Assert.AreEqual(Tokens.Default, lexer.NextToken().Kind); - } - - [Test] - public void TestDelegate() - { - VBLexer lexer = GenerateLexer(new StringReader("Delegate")); - Assert.AreEqual(Tokens.Delegate, lexer.NextToken().Kind); - } - - [Test] - public void TestDescending() - { - VBLexer lexer = GenerateLexer(new StringReader("Descending")); - Assert.AreEqual(Tokens.Descending, lexer.NextToken().Kind); - } - - [Test] - public void TestDim() - { - VBLexer lexer = GenerateLexer(new StringReader("Dim")); - Assert.AreEqual(Tokens.Dim, lexer.NextToken().Kind); - } - - [Test] - public void TestDirectCast() - { - VBLexer lexer = GenerateLexer(new StringReader("DirectCast")); - Assert.AreEqual(Tokens.DirectCast, lexer.NextToken().Kind); - } - - [Test] - public void TestDistinct() - { - VBLexer lexer = GenerateLexer(new StringReader("Distinct")); - Assert.AreEqual(Tokens.Distinct, lexer.NextToken().Kind); - } - - [Test] - public void TestDo() - { - VBLexer lexer = GenerateLexer(new StringReader("Do")); - Assert.AreEqual(Tokens.Do, lexer.NextToken().Kind); - } - - [Test] - public void TestDouble() - { - VBLexer lexer = GenerateLexer(new StringReader("Double")); - Assert.AreEqual(Tokens.Double, lexer.NextToken().Kind); - } - - [Test] - public void TestEach() - { - VBLexer lexer = GenerateLexer(new StringReader("Each")); - Assert.AreEqual(Tokens.Each, lexer.NextToken().Kind); - } - - [Test] - public void TestElse() - { - VBLexer lexer = GenerateLexer(new StringReader("Else")); - Assert.AreEqual(Tokens.Else, lexer.NextToken().Kind); - } - - [Test] - public void TestElseIf() - { - VBLexer lexer = GenerateLexer(new StringReader("ElseIf")); - Assert.AreEqual(Tokens.ElseIf, lexer.NextToken().Kind); - } - - [Test] - public void TestEnd() - { - VBLexer lexer = GenerateLexer(new StringReader("End")); - Assert.AreEqual(Tokens.End, lexer.NextToken().Kind); - } - - [Test] - public void TestEndIf() - { - VBLexer lexer = GenerateLexer(new StringReader("EndIf")); - Assert.AreEqual(Tokens.EndIf, lexer.NextToken().Kind); - } - - [Test] - public void TestEnum() - { - VBLexer lexer = GenerateLexer(new StringReader("Enum")); - Assert.AreEqual(Tokens.Enum, lexer.NextToken().Kind); - } - - [Test] - public void TestEquals() - { - VBLexer lexer = GenerateLexer(new StringReader("Equals")); - Assert.AreEqual(Tokens.Equals, lexer.NextToken().Kind); - } - - [Test] - public void TestErase() - { - VBLexer lexer = GenerateLexer(new StringReader("Erase")); - Assert.AreEqual(Tokens.Erase, lexer.NextToken().Kind); - } - - [Test] - public void TestError() - { - VBLexer lexer = GenerateLexer(new StringReader("Error")); - Assert.AreEqual(Tokens.Error, lexer.NextToken().Kind); - } - - [Test] - public void TestEvent() - { - VBLexer lexer = GenerateLexer(new StringReader("Event")); - Assert.AreEqual(Tokens.Event, lexer.NextToken().Kind); - } - - [Test] - public void TestExit() - { - VBLexer lexer = GenerateLexer(new StringReader("Exit")); - Assert.AreEqual(Tokens.Exit, lexer.NextToken().Kind); - } - - [Test] - public void TestExplicit() - { - VBLexer lexer = GenerateLexer(new StringReader("Explicit")); - Assert.AreEqual(Tokens.Explicit, lexer.NextToken().Kind); - } - - [Test] - public void TestFalse() - { - VBLexer lexer = GenerateLexer(new StringReader("False")); - Assert.AreEqual(Tokens.False, lexer.NextToken().Kind); - } - - [Test] - public void TestFinally() - { - VBLexer lexer = GenerateLexer(new StringReader("Finally")); - Assert.AreEqual(Tokens.Finally, lexer.NextToken().Kind); - } - - [Test] - public void TestFor() - { - VBLexer lexer = GenerateLexer(new StringReader("For")); - Assert.AreEqual(Tokens.For, lexer.NextToken().Kind); - } - - [Test] - public void TestFriend() - { - VBLexer lexer = GenerateLexer(new StringReader("Friend")); - Assert.AreEqual(Tokens.Friend, lexer.NextToken().Kind); - } - - [Test] - public void TestFrom() - { - VBLexer lexer = GenerateLexer(new StringReader("From")); - Assert.AreEqual(Tokens.From, lexer.NextToken().Kind); - } - - [Test] - public void TestFunction() - { - VBLexer lexer = GenerateLexer(new StringReader("Function")); - Assert.AreEqual(Tokens.Function, lexer.NextToken().Kind); - } - - [Test] - public void TestGet() - { - VBLexer lexer = GenerateLexer(new StringReader("Get")); - Assert.AreEqual(Tokens.Get, lexer.NextToken().Kind); - } - - [Test] - public void TestGetType() - { - VBLexer lexer = GenerateLexer(new StringReader("GetType")); - Assert.AreEqual(Tokens.GetType, lexer.NextToken().Kind); - } - - [Test] - public void TestGlobal() - { - VBLexer lexer = GenerateLexer(new StringReader("Global")); - Assert.AreEqual(Tokens.Global, lexer.NextToken().Kind); - } - - [Test] - public void TestGoSub() - { - VBLexer lexer = GenerateLexer(new StringReader("GoSub")); - Assert.AreEqual(Tokens.GoSub, lexer.NextToken().Kind); - } - - [Test] - public void TestGoTo() - { - VBLexer lexer = GenerateLexer(new StringReader("GoTo")); - Assert.AreEqual(Tokens.GoTo, lexer.NextToken().Kind); - } - - [Test] - public void TestGroup() - { - VBLexer lexer = GenerateLexer(new StringReader("Group")); - Assert.AreEqual(Tokens.Group, lexer.NextToken().Kind); - } - - [Test] - public void TestHandles() - { - VBLexer lexer = GenerateLexer(new StringReader("Handles")); - Assert.AreEqual(Tokens.Handles, lexer.NextToken().Kind); - } - - [Test] - public void TestIf() - { - VBLexer lexer = GenerateLexer(new StringReader("If")); - Assert.AreEqual(Tokens.If, lexer.NextToken().Kind); - } - - [Test] - public void TestImplements() - { - VBLexer lexer = GenerateLexer(new StringReader("Implements")); - Assert.AreEqual(Tokens.Implements, lexer.NextToken().Kind); - } - - [Test] - public void TestImports() - { - VBLexer lexer = GenerateLexer(new StringReader("Imports")); - Assert.AreEqual(Tokens.Imports, lexer.NextToken().Kind); - } - - [Test] - public void TestIn() - { - VBLexer lexer = GenerateLexer(new StringReader("In")); - Assert.AreEqual(Tokens.In, lexer.NextToken().Kind); - } - - [Test] - public void TestInfer() - { - VBLexer lexer = GenerateLexer(new StringReader("Infer")); - Assert.AreEqual(Tokens.Infer, lexer.NextToken().Kind); - } - - [Test] - public void TestInherits() - { - VBLexer lexer = GenerateLexer(new StringReader("Inherits")); - Assert.AreEqual(Tokens.Inherits, lexer.NextToken().Kind); - } - - [Test] - public void TestInteger() - { - VBLexer lexer = GenerateLexer(new StringReader("Integer")); - Assert.AreEqual(Tokens.Integer, lexer.NextToken().Kind); - } - - [Test] - public void TestInterface() - { - VBLexer lexer = GenerateLexer(new StringReader("Interface")); - Assert.AreEqual(Tokens.Interface, lexer.NextToken().Kind); - } - - [Test] - public void TestInto() - { - VBLexer lexer = GenerateLexer(new StringReader("Into")); - Assert.AreEqual(Tokens.Into, lexer.NextToken().Kind); - } - - [Test] - public void TestIs() - { - VBLexer lexer = GenerateLexer(new StringReader("Is")); - Assert.AreEqual(Tokens.Is, lexer.NextToken().Kind); - } - - [Test] - public void TestIsNot() - { - VBLexer lexer = GenerateLexer(new StringReader("IsNot")); - Assert.AreEqual(Tokens.IsNot, lexer.NextToken().Kind); - } - - [Test] - public void TestJoin() - { - VBLexer lexer = GenerateLexer(new StringReader("Join")); - Assert.AreEqual(Tokens.Join, lexer.NextToken().Kind); - } - - [Test] - public void TestKey() - { - VBLexer lexer = GenerateLexer(new StringReader("Key")); - Assert.AreEqual(Tokens.Key, lexer.NextToken().Kind); - } - - [Test] - public void TestLet() - { - VBLexer lexer = GenerateLexer(new StringReader("Let")); - Assert.AreEqual(Tokens.Let, lexer.NextToken().Kind); - } - - [Test] - public void TestLib() - { - VBLexer lexer = GenerateLexer(new StringReader("Lib")); - Assert.AreEqual(Tokens.Lib, lexer.NextToken().Kind); - } - - [Test] - public void TestLike() - { - VBLexer lexer = GenerateLexer(new StringReader("Like")); - Assert.AreEqual(Tokens.Like, lexer.NextToken().Kind); - } - - [Test] - public void TestLong() - { - VBLexer lexer = GenerateLexer(new StringReader("Long")); - Assert.AreEqual(Tokens.Long, lexer.NextToken().Kind); - } - - [Test] - public void TestLoop() - { - VBLexer lexer = GenerateLexer(new StringReader("Loop")); - Assert.AreEqual(Tokens.Loop, lexer.NextToken().Kind); - } - - [Test] - public void TestMe() - { - VBLexer lexer = GenerateLexer(new StringReader("Me")); - Assert.AreEqual(Tokens.Me, lexer.NextToken().Kind); - } - - [Test] - public void TestMod() - { - VBLexer lexer = GenerateLexer(new StringReader("Mod")); - Assert.AreEqual(Tokens.Mod, lexer.NextToken().Kind); - } - - [Test] - public void TestModule() - { - VBLexer lexer = GenerateLexer(new StringReader("Module")); - Assert.AreEqual(Tokens.Module, lexer.NextToken().Kind); - } - - [Test] - public void TestMustInherit() - { - VBLexer lexer = GenerateLexer(new StringReader("MustInherit")); - Assert.AreEqual(Tokens.MustInherit, lexer.NextToken().Kind); - } - - [Test] - public void TestMustOverride() - { - VBLexer lexer = GenerateLexer(new StringReader("MustOverride")); - Assert.AreEqual(Tokens.MustOverride, lexer.NextToken().Kind); - } - - [Test] - public void TestMyBase() - { - VBLexer lexer = GenerateLexer(new StringReader("MyBase")); - Assert.AreEqual(Tokens.MyBase, lexer.NextToken().Kind); - } - - [Test] - public void TestMyClass() - { - VBLexer lexer = GenerateLexer(new StringReader("MyClass")); - Assert.AreEqual(Tokens.MyClass, lexer.NextToken().Kind); - } - - [Test] - public void TestNamespace() - { - VBLexer lexer = GenerateLexer(new StringReader("Namespace")); - Assert.AreEqual(Tokens.Namespace, lexer.NextToken().Kind); - } - - [Test] - public void TestNarrowing() - { - VBLexer lexer = GenerateLexer(new StringReader("Narrowing")); - Assert.AreEqual(Tokens.Narrowing, lexer.NextToken().Kind); - } - - [Test] - public void TestNew() - { - VBLexer lexer = GenerateLexer(new StringReader("New")); - Assert.AreEqual(Tokens.New, lexer.NextToken().Kind); - } - - [Test] - public void TestNext() - { - VBLexer lexer = GenerateLexer(new StringReader("Next")); - Assert.AreEqual(Tokens.Next, lexer.NextToken().Kind); - } - - [Test] - public void TestNot() - { - VBLexer lexer = GenerateLexer(new StringReader("Not")); - Assert.AreEqual(Tokens.Not, lexer.NextToken().Kind); - } - - [Test] - public void TestNothing() - { - VBLexer lexer = GenerateLexer(new StringReader("Nothing")); - Assert.AreEqual(Tokens.Nothing, lexer.NextToken().Kind); - } - - [Test] - public void TestNotInheritable() - { - VBLexer lexer = GenerateLexer(new StringReader("NotInheritable")); - Assert.AreEqual(Tokens.NotInheritable, lexer.NextToken().Kind); - } - - [Test] - public void TestNotOverridable() - { - VBLexer lexer = GenerateLexer(new StringReader("NotOverridable")); - Assert.AreEqual(Tokens.NotOverridable, lexer.NextToken().Kind); - } - - [Test] - public void TestObject() - { - VBLexer lexer = GenerateLexer(new StringReader("Object")); - Assert.AreEqual(Tokens.Object, lexer.NextToken().Kind); - } - - [Test] - public void TestOf() - { - VBLexer lexer = GenerateLexer(new StringReader("Of")); - Assert.AreEqual(Tokens.Of, lexer.NextToken().Kind); - } - - [Test] - public void TestOff() - { - VBLexer lexer = GenerateLexer(new StringReader("Off")); - Assert.AreEqual(Tokens.Off, lexer.NextToken().Kind); - } - - [Test] - public void TestOn() - { - VBLexer lexer = GenerateLexer(new StringReader("On")); - Assert.AreEqual(Tokens.On, lexer.NextToken().Kind); - } - - [Test] - public void TestOperator() - { - VBLexer lexer = GenerateLexer(new StringReader("Operator")); - Assert.AreEqual(Tokens.Operator, lexer.NextToken().Kind); - } - - [Test] - public void TestOption() - { - VBLexer lexer = GenerateLexer(new StringReader("Option")); - Assert.AreEqual(Tokens.Option, lexer.NextToken().Kind); - } - - [Test] - public void TestOptional() - { - VBLexer lexer = GenerateLexer(new StringReader("Optional")); - Assert.AreEqual(Tokens.Optional, lexer.NextToken().Kind); - } - - [Test] - public void TestOr() - { - VBLexer lexer = GenerateLexer(new StringReader("Or")); - Assert.AreEqual(Tokens.Or, lexer.NextToken().Kind); - } - - [Test] - public void TestOrder() - { - VBLexer lexer = GenerateLexer(new StringReader("Order")); - Assert.AreEqual(Tokens.Order, lexer.NextToken().Kind); - } - - [Test] - public void TestOrElse() - { - VBLexer lexer = GenerateLexer(new StringReader("OrElse")); - Assert.AreEqual(Tokens.OrElse, lexer.NextToken().Kind); - } - - [Test] - public void TestOut() - { - VBLexer lexer = GenerateLexer(new StringReader("Out")); - Assert.AreEqual(Tokens.Out, lexer.NextToken().Kind); - } - - [Test] - public void TestOverloads() - { - VBLexer lexer = GenerateLexer(new StringReader("Overloads")); - Assert.AreEqual(Tokens.Overloads, lexer.NextToken().Kind); - } - - [Test] - public void TestOverridable() - { - VBLexer lexer = GenerateLexer(new StringReader("Overridable")); - Assert.AreEqual(Tokens.Overridable, lexer.NextToken().Kind); - } - - [Test] - public void TestOverrides() - { - VBLexer lexer = GenerateLexer(new StringReader("Overrides")); - Assert.AreEqual(Tokens.Overrides, lexer.NextToken().Kind); - } - - [Test] - public void TestParamArray() - { - VBLexer lexer = GenerateLexer(new StringReader("ParamArray")); - Assert.AreEqual(Tokens.ParamArray, lexer.NextToken().Kind); - } - - [Test] - public void TestPartial() - { - VBLexer lexer = GenerateLexer(new StringReader("Partial")); - Assert.AreEqual(Tokens.Partial, lexer.NextToken().Kind); - } - - [Test] - public void TestPreserve() - { - VBLexer lexer = GenerateLexer(new StringReader("Preserve")); - Assert.AreEqual(Tokens.Preserve, lexer.NextToken().Kind); - } - - [Test] - public void TestPrivate() - { - VBLexer lexer = GenerateLexer(new StringReader("Private")); - Assert.AreEqual(Tokens.Private, lexer.NextToken().Kind); - } - - [Test] - public void TestProperty() - { - VBLexer lexer = GenerateLexer(new StringReader("Property")); - Assert.AreEqual(Tokens.Property, lexer.NextToken().Kind); - } - - [Test] - public void TestProtected() - { - VBLexer lexer = GenerateLexer(new StringReader("Protected")); - Assert.AreEqual(Tokens.Protected, lexer.NextToken().Kind); - } - - [Test] - public void TestPublic() - { - VBLexer lexer = GenerateLexer(new StringReader("Public")); - Assert.AreEqual(Tokens.Public, lexer.NextToken().Kind); - } - - [Test] - public void TestRaiseEvent() - { - VBLexer lexer = GenerateLexer(new StringReader("RaiseEvent")); - Assert.AreEqual(Tokens.RaiseEvent, lexer.NextToken().Kind); - } - - [Test] - public void TestReadOnly() - { - VBLexer lexer = GenerateLexer(new StringReader("ReadOnly")); - Assert.AreEqual(Tokens.ReadOnly, lexer.NextToken().Kind); - } - - [Test] - public void TestReDim() - { - VBLexer lexer = GenerateLexer(new StringReader("ReDim")); - Assert.AreEqual(Tokens.ReDim, lexer.NextToken().Kind); - } - - [Test] - public void TestRemoveHandler() - { - VBLexer lexer = GenerateLexer(new StringReader("RemoveHandler")); - Assert.AreEqual(Tokens.RemoveHandler, lexer.NextToken().Kind); - } - - [Test] - public void TestResume() - { - VBLexer lexer = GenerateLexer(new StringReader("Resume")); - Assert.AreEqual(Tokens.Resume, lexer.NextToken().Kind); - } - - [Test] - public void TestReturn() - { - VBLexer lexer = GenerateLexer(new StringReader("Return")); - Assert.AreEqual(Tokens.Return, lexer.NextToken().Kind); - } - - [Test] - public void TestSByte() - { - VBLexer lexer = GenerateLexer(new StringReader("SByte")); - Assert.AreEqual(Tokens.SByte, lexer.NextToken().Kind); - } - - [Test] - public void TestSelect() - { - VBLexer lexer = GenerateLexer(new StringReader("Select")); - Assert.AreEqual(Tokens.Select, lexer.NextToken().Kind); - } - - [Test] - public void TestSet() - { - VBLexer lexer = GenerateLexer(new StringReader("Set")); - Assert.AreEqual(Tokens.Set, lexer.NextToken().Kind); - } - - [Test] - public void TestShadows() - { - VBLexer lexer = GenerateLexer(new StringReader("Shadows")); - Assert.AreEqual(Tokens.Shadows, lexer.NextToken().Kind); - } - - [Test] - public void TestShared() - { - VBLexer lexer = GenerateLexer(new StringReader("Shared")); - Assert.AreEqual(Tokens.Shared, lexer.NextToken().Kind); - } - - [Test] - public void TestShort() - { - VBLexer lexer = GenerateLexer(new StringReader("Short")); - Assert.AreEqual(Tokens.Short, lexer.NextToken().Kind); - } - - [Test] - public void TestSingle() - { - VBLexer lexer = GenerateLexer(new StringReader("Single")); - Assert.AreEqual(Tokens.Single, lexer.NextToken().Kind); - } - - [Test] - public void TestSkip() - { - VBLexer lexer = GenerateLexer(new StringReader("Skip")); - Assert.AreEqual(Tokens.Skip, lexer.NextToken().Kind); - } - - [Test] - public void TestStatic() - { - VBLexer lexer = GenerateLexer(new StringReader("Static")); - Assert.AreEqual(Tokens.Static, lexer.NextToken().Kind); - } - - [Test] - public void TestStep() - { - VBLexer lexer = GenerateLexer(new StringReader("Step")); - Assert.AreEqual(Tokens.Step, lexer.NextToken().Kind); - } - - [Test] - public void TestStop() - { - VBLexer lexer = GenerateLexer(new StringReader("Stop")); - Assert.AreEqual(Tokens.Stop, lexer.NextToken().Kind); - } - - [Test] - public void TestStrict() - { - VBLexer lexer = GenerateLexer(new StringReader("Strict")); - Assert.AreEqual(Tokens.Strict, lexer.NextToken().Kind); - } - - [Test] - public void TestString() - { - VBLexer lexer = GenerateLexer(new StringReader("String")); - Assert.AreEqual(Tokens.String, lexer.NextToken().Kind); - } - - [Test] - public void TestStructure() - { - VBLexer lexer = GenerateLexer(new StringReader("Structure")); - Assert.AreEqual(Tokens.Structure, lexer.NextToken().Kind); - } - - [Test] - public void TestSub() - { - VBLexer lexer = GenerateLexer(new StringReader("Sub")); - Assert.AreEqual(Tokens.Sub, lexer.NextToken().Kind); - } - - [Test] - public void TestSyncLock() - { - VBLexer lexer = GenerateLexer(new StringReader("SyncLock")); - Assert.AreEqual(Tokens.SyncLock, lexer.NextToken().Kind); - } - - [Test] - public void TestTake() - { - VBLexer lexer = GenerateLexer(new StringReader("Take")); - Assert.AreEqual(Tokens.Take, lexer.NextToken().Kind); - } - - [Test] - public void TestText() - { - VBLexer lexer = GenerateLexer(new StringReader("Text")); - Assert.AreEqual(Tokens.Text, lexer.NextToken().Kind); - } - - [Test] - public void TestThen() - { - VBLexer lexer = GenerateLexer(new StringReader("Then")); - Assert.AreEqual(Tokens.Then, lexer.NextToken().Kind); - } - - [Test] - public void TestThrow() - { - VBLexer lexer = GenerateLexer(new StringReader("Throw")); - Assert.AreEqual(Tokens.Throw, lexer.NextToken().Kind); - } - - [Test] - public void TestTo() - { - VBLexer lexer = GenerateLexer(new StringReader("To")); - Assert.AreEqual(Tokens.To, lexer.NextToken().Kind); - } - - [Test] - public void TestTrue() - { - VBLexer lexer = GenerateLexer(new StringReader("True")); - Assert.AreEqual(Tokens.True, lexer.NextToken().Kind); - } - - [Test] - public void TestTry() - { - VBLexer lexer = GenerateLexer(new StringReader("Try")); - Assert.AreEqual(Tokens.Try, lexer.NextToken().Kind); - } - - [Test] - public void TestTryCast() - { - VBLexer lexer = GenerateLexer(new StringReader("TryCast")); - Assert.AreEqual(Tokens.TryCast, lexer.NextToken().Kind); - } - - [Test] - public void TestTypeOf() - { - VBLexer lexer = GenerateLexer(new StringReader("TypeOf")); - Assert.AreEqual(Tokens.TypeOf, lexer.NextToken().Kind); - } - - [Test] - public void TestUInteger() - { - VBLexer lexer = GenerateLexer(new StringReader("UInteger")); - Assert.AreEqual(Tokens.UInteger, lexer.NextToken().Kind); - } - - [Test] - public void TestULong() - { - VBLexer lexer = GenerateLexer(new StringReader("ULong")); - Assert.AreEqual(Tokens.ULong, lexer.NextToken().Kind); - } - - [Test] - public void TestUnicode() - { - VBLexer lexer = GenerateLexer(new StringReader("Unicode")); - Assert.AreEqual(Tokens.Unicode, lexer.NextToken().Kind); - } - - [Test] - public void TestUntil() - { - VBLexer lexer = GenerateLexer(new StringReader("Until")); - Assert.AreEqual(Tokens.Until, lexer.NextToken().Kind); - } - - [Test] - public void TestUShort() - { - VBLexer lexer = GenerateLexer(new StringReader("UShort")); - Assert.AreEqual(Tokens.UShort, lexer.NextToken().Kind); - } - - [Test] - public void TestUsing() - { - VBLexer lexer = GenerateLexer(new StringReader("Using")); - Assert.AreEqual(Tokens.Using, lexer.NextToken().Kind); - } - - [Test] - public void TestVariant() - { - VBLexer lexer = GenerateLexer(new StringReader("Variant")); - Assert.AreEqual(Tokens.Variant, lexer.NextToken().Kind); - } - - [Test] - public void TestWend() - { - VBLexer lexer = GenerateLexer(new StringReader("Wend")); - Assert.AreEqual(Tokens.Wend, lexer.NextToken().Kind); - } - - [Test] - public void TestWhen() - { - VBLexer lexer = GenerateLexer(new StringReader("When")); - Assert.AreEqual(Tokens.When, lexer.NextToken().Kind); - } - - [Test] - public void TestWhere() - { - VBLexer lexer = GenerateLexer(new StringReader("Where")); - Assert.AreEqual(Tokens.Where, lexer.NextToken().Kind); - } - - [Test] - public void TestWhile() - { - VBLexer lexer = GenerateLexer(new StringReader("While")); - Assert.AreEqual(Tokens.While, lexer.NextToken().Kind); - } - - [Test] - public void TestWidening() - { - VBLexer lexer = GenerateLexer(new StringReader("Widening")); - Assert.AreEqual(Tokens.Widening, lexer.NextToken().Kind); - } - - [Test] - public void TestWith() - { - VBLexer lexer = GenerateLexer(new StringReader("With")); - Assert.AreEqual(Tokens.With, lexer.NextToken().Kind); - } - - [Test] - public void TestWithEvents() - { - VBLexer lexer = GenerateLexer(new StringReader("WithEvents")); - Assert.AreEqual(Tokens.WithEvents, lexer.NextToken().Kind); - } - - [Test] - public void TestWriteOnly() - { - VBLexer lexer = GenerateLexer(new StringReader("WriteOnly")); - Assert.AreEqual(Tokens.WriteOnly, lexer.NextToken().Kind); - } - - [Test] - public void TestXor() - { - VBLexer lexer = GenerateLexer(new StringReader("Xor")); - Assert.AreEqual(Tokens.Xor, lexer.NextToken().Kind); - } - - [Test] - public void TestGetXmlNamespace() - { - VBLexer lexer = GenerateLexer(new StringReader("GetXmlNamespace")); - Assert.AreEqual(Tokens.GetXmlNamespace, lexer.NextToken().Kind); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LiteralsTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LiteralsTests.cs deleted file mode 100644 index 7572b916c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/LiteralsTests.cs +++ /dev/null @@ -1,194 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public sealed class LiteralsTests - { - VBLexer GenerateLexer(StringReader sr) - { - return new VBLexer(sr); - } - - Token GetSingleToken(string text) - { - VBLexer lexer = GenerateLexer(new StringReader(text)); - Token t = lexer.NextToken(); - Assert.AreEqual(Tokens.EOL, lexer.NextToken().Kind, "Tokens.EOL"); - Assert.AreEqual(Tokens.EOF, lexer.NextToken().Kind, "Tokens.EOF"); - Assert.AreEqual("", lexer.Errors.ErrorOutput); - return t; - } - - void CheckToken(string text, int tokenType, object val) - { - Token t = GetSingleToken(text); - Assert.AreEqual(tokenType, t.Kind, "Tokens.Literal"); - Assert.IsNotNull(t.LiteralValue, "literalValue is null"); - Assert.AreEqual(val.GetType(), t.LiteralValue.GetType(), "literalValue.GetType()"); - Assert.AreEqual(val, t.LiteralValue, "literalValue"); - } - - [Test] - public void TestSingleDigit() - { - CheckToken("5", Tokens.LiteralInteger, 5); - } - - [Test] - public void TestZero() - { - CheckToken("0", Tokens.LiteralInteger, 0); - } - - [Test] - public void TestInteger() - { - CheckToken("15", Tokens.LiteralInteger, 15); - CheckToken("8581", Tokens.LiteralInteger, 8581); - } - - [Test] - public void InvalidTypeCharacter() - { - // just check that we don't get exceptions: - GenerateLexer(new StringReader(".5s")).NextToken(); - GenerateLexer(new StringReader(".5ul")).NextToken(); - } - - [Test] - public void TestHexadecimalInteger() - { - CheckToken("&H10", Tokens.LiteralInteger, 0x10); - CheckToken("&H10&", Tokens.LiteralInteger, (long)0x10); - CheckToken("&h3ff%", Tokens.LiteralInteger, 0x3ff); - CheckToken("&h8000s", Tokens.LiteralInteger, short.MinValue); - CheckToken("&h8000us", Tokens.LiteralInteger, (ushort)0x8000); - CheckToken("&HffffFFFF", Tokens.LiteralInteger, -1); - CheckToken("&HffffFFFF%", Tokens.LiteralInteger, -1); - CheckToken("&HffffFFFFui", Tokens.LiteralInteger, uint.MaxValue); - CheckToken("&HffffFFFF&", Tokens.LiteralInteger, (long)uint.MaxValue); - } - - [Test] - public void TestLongHexadecimalInteger() - { - CheckToken("&H4244636f446c6d58", Tokens.LiteralInteger, 0x4244636f446c6d58); - CheckToken("&hf244636f446c6d58", Tokens.LiteralInteger, -989556688574190248); - CheckToken("&hf244636f446c6d58&", Tokens.LiteralInteger, -989556688574190248); - CheckToken("&hf244636f446c6d58ul", Tokens.LiteralInteger, 0xf244636f446c6d58); - } - - [Test] - public void InvalidHexadecimalInteger() - { - // just check that we don't get exceptions: - GenerateLexer(new StringReader("&H")).NextToken(); - // >ulong.MaxValue - GenerateLexer(new StringReader("&hff244636f446c6d58")).NextToken(); - // needs an ulong, but "i" postfix specified integer - GenerateLexer(new StringReader("&hf244636f446c6d58i")).NextToken(); - GenerateLexer(new StringReader("&hf244636f446c6d58ui")).NextToken(); - } - - [Test] - public void TestIncompleteHexadecimal() - { - VBLexer lexer = GenerateLexer(new StringReader("&H\r\nabc")); - Token t = lexer.NextToken(); - Assert.AreEqual(Tokens.LiteralInteger, t.Kind); - Assert.AreEqual(0, (int)t.LiteralValue); - Assert.AreEqual(Tokens.EOL, lexer.NextToken().Kind, "Tokens.EOL (1)"); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind, "Tokens.Identifier"); - Assert.AreEqual(Tokens.EOL, lexer.NextToken().Kind, "Tokens.EOL (2)"); - Assert.AreEqual(Tokens.EOF, lexer.NextToken().Kind, "Tokens.EOF"); - Assert.AreNotEqual("", lexer.Errors.ErrorOutput); - } - - [Test] - public void TestStringLiterals() - { - CheckToken("\"\"", Tokens.LiteralString, ""); - CheckToken("\"Hello, World!\"", Tokens.LiteralString, "Hello, World!"); - CheckToken("\"\"\"\"", Tokens.LiteralString, "\""); - } - - [Test] - public void TestCharacterLiterals() - { - CheckToken("\" \"c", Tokens.LiteralCharacter, ' '); - CheckToken("\"!\"c", Tokens.LiteralCharacter, '!'); - CheckToken("\"\"\"\"c", Tokens.LiteralCharacter, '"'); - } - - [Test] - public void TestDateLiterals() - { - CheckToken("# 8/23/1970 #", Tokens.LiteralDate, new DateTime(1970, 8, 23, 0, 0, 0)); - CheckToken("#8/23/1970#", Tokens.LiteralDate, new DateTime(1970, 8, 23, 0, 0, 0)); - CheckToken("# 8/23/1970 3:45:39AM #", Tokens.LiteralDate, new DateTime(1970, 8, 23, 3, 45, 39)); - CheckToken("# 3:45:39AM #", Tokens.LiteralDate, new DateTime(1, 1, 1, 3, 45, 39)); - CheckToken("# 3:45:39 PM #", Tokens.LiteralDate, new DateTime(1, 1, 1, 15, 45, 39)); - CheckToken("# 3:45:39 #", Tokens.LiteralDate, new DateTime(1, 1, 1, 3, 45, 39)); - CheckToken("# 13:45:39 #", Tokens.LiteralDate, new DateTime(1, 1, 1, 13, 45, 39)); - CheckToken("# 1AM #", Tokens.LiteralDate, new DateTime(1, 1, 1, 1, 0, 0)); - } - - [Test] - public void TestDouble() - { - CheckToken("1.0", Tokens.LiteralDouble, 1.0); - CheckToken("1.1", Tokens.LiteralDouble, 1.1); - CheckToken("2e-5", Tokens.LiteralDouble, 2e-5); - CheckToken("2.0e-5", Tokens.LiteralDouble, 2e-5); - CheckToken("2e5", Tokens.LiteralDouble, 2e5); - CheckToken("2.2e5", Tokens.LiteralDouble, 2.2e5); - CheckToken("2e+5", Tokens.LiteralDouble, 2e5); - CheckToken("2.2e+5", Tokens.LiteralDouble, 2.2e5); - - CheckToken("1r", Tokens.LiteralDouble, 1.0); - CheckToken("1.0r", Tokens.LiteralDouble, 1.0); - CheckToken("1.1r", Tokens.LiteralDouble, 1.1); - CheckToken("2e-5r", Tokens.LiteralDouble, 2e-5); - CheckToken("2.0e-5r", Tokens.LiteralDouble, 2e-5); - CheckToken("2e5r", Tokens.LiteralDouble, 2e5); - CheckToken("2.2e5r", Tokens.LiteralDouble, 2.2e5); - CheckToken("2e+5r", Tokens.LiteralDouble, 2e5); - CheckToken("2.2e+5r", Tokens.LiteralDouble, 2.2e5); - } - - [Test] - public void TestSingle() - { - CheckToken("1f", Tokens.LiteralSingle, 1.0f); - CheckToken("1.0f", Tokens.LiteralSingle, 1.0f); - CheckToken("1.1f", Tokens.LiteralSingle, 1.1f); - CheckToken("2e-5f", Tokens.LiteralSingle, 2e-5f); - CheckToken("2.0e-5f", Tokens.LiteralSingle, 2e-5f); - CheckToken("2e5f", Tokens.LiteralSingle, 2e5f); - CheckToken("2.2e5f", Tokens.LiteralSingle, 2.2e5f); - CheckToken("2e+5f", Tokens.LiteralSingle, 2e5f); - CheckToken("2.2e+5f", Tokens.LiteralSingle, 2.2e5f); - } - - [Test] - public void TestDecimal() - { - CheckToken("1d", Tokens.LiteralDecimal, 1m); - CheckToken("1.0d", Tokens.LiteralDecimal, 1.0m); - CheckToken("1.1d", Tokens.LiteralDecimal, 1.1m); - CheckToken("2e-5d", Tokens.LiteralDecimal, 2e-5m); - CheckToken("2.0e-5d", Tokens.LiteralDecimal, 2.0e-5m); - CheckToken("2e5d", Tokens.LiteralDecimal, 2e5m); - CheckToken("2.2e5d", Tokens.LiteralDecimal, 2.2e5m); - CheckToken("2e+5d", Tokens.LiteralDecimal, 2e5m); - CheckToken("2.2e+5d", Tokens.LiteralDecimal, 2.2e5m); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/TokenTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/TokenTests.cs deleted file mode 100644 index 5b21fe89a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/TokenTests.cs +++ /dev/null @@ -1,23 +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 System; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class TokenTests - { - [Test] - public void TokenToStringDoesNotThrowException() - { - Assert.DoesNotThrow( - () => { - string text = new Token(71, 1, 1).ToString(); - } - ); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/XmlModeLexerTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/XmlModeLexerTests.cs deleted file mode 100644 index e55c4f9b5..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Lexer/XmlModeLexerTests.cs +++ /dev/null @@ -1,993 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Lexer -{ - [TestFixture] - public class XmlModeLexerTests - { - #region Xml Tests - [Test] - public void TagWithContent() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim x = Hello World"))); - - CheckHead(lexer); - - Assert.AreEqual(Tokens.Dim, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Assign, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlOpenTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlContent, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlOpenEndTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - CheckFoot(lexer); - } - - [Test] - public void HtmlText() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim x =

Title

" + - "

test test
test

"))); - - CheckHead(lexer); - - Assert.AreEqual(Tokens.Dim, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Assign, lexer.NextToken().Kind); - - //
- Assert.AreEqual(Tokens.XmlOpenTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - //

- Assert.AreEqual(Tokens.XmlOpenTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - // Title - Assert.AreEqual(Tokens.XmlContent, lexer.NextToken().Kind); - - //

- Assert.AreEqual(Tokens.XmlOpenEndTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - //

- Assert.AreEqual(Tokens.XmlOpenTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - // test test - Assert.AreEqual(Tokens.XmlContent, lexer.NextToken().Kind); - - //
- Assert.AreEqual(Tokens.XmlOpenTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTagEmptyElement, lexer.NextToken().Kind); - - // test - Assert.AreEqual(Tokens.XmlContent, lexer.NextToken().Kind); - - //

- Assert.AreEqual(Tokens.XmlOpenEndTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - //
- Assert.AreEqual(Tokens.XmlOpenEndTag, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.Identifier, lexer.NextToken().Kind); - Assert.AreEqual(Tokens.XmlCloseTag, lexer.NextToken().Kind); - - CheckFoot(lexer); - } - - [Test] - public void XmlLiteralsExample1() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim xml = \n" + - " \n" + - " Shrimp Cocktail\n" + - " Escargot\n" + - " \n" + - " \n" + - " Filet Mignon\n" + - " Garlic Potatoes\n" + - " Broccoli\n" + - " \n" + - " \n" + - " Chocolate Cheesecake\n" + - " \n" + - " "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - // - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // Shrimp Cocktail - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // Escargot - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // Filet Mignon - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // Garlic Potatoes - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // Broccoli - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // Chocolate Cheesecake - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - // whitespaces - Tokens.XmlContent, - // - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag - ); - - CheckFoot(lexer); - } - - [Test] - public void SimpleXmlWithComments() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(@"Dim x = - - - - - - - "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.XmlProcessingInstruction, Tokens.XmlContent, Tokens.XmlComment, Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.XmlContent, Tokens.XmlComment, Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, - Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlComment, Tokens.XmlComment, Tokens.XmlProcessingInstruction); - - CheckFoot(lexer); - } - - [Test] - public void SimpleEmptyTag() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim x = "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement); - - CheckFoot(lexer); - } - - [Test] - public void SimpleTag() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim x = "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlOpenEndTag, - Tokens.Identifier, Tokens.XmlCloseTag); - - CheckFoot(lexer); - } - - [Test] - public void XmlImport() - { - string code = @"Imports System -Imports System.Linq - -Imports -Imports - -Class TestClass - Sub TestSub() - Dim xml = - - 1. Cell - - - End Sub -End Class"; - - VBLexer lexer = GenerateLexer(new StringReader(code)); - - CheckTokens(lexer, Tokens.Imports, Tokens.Identifier, Tokens.EOL, - Tokens.Imports, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.EOL, - Tokens.Imports, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, Tokens.EOL, - Tokens.Imports, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, Tokens.EOL, - Tokens.Class, Tokens.Identifier, Tokens.EOL, Tokens.Sub, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.CloseParenthesis, Tokens.EOL, - Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.EOL, Tokens.End, Tokens.Sub, Tokens.EOL, Tokens.End, Tokens.Class - ); - } - - [Test] - public void CDataSection() - { - string xml = @"Dim xml = - "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(xml))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, // 2 - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, // 6 - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, // 10 - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, // 14 - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, // 18 - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, // 22 - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, // 28 - Tokens.XmlContent, Tokens.XmlCData, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, // 34 - Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, - Tokens.XmlContent, Tokens.XmlCData, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag - ); - - - CheckFoot(lexer); - } - - [Test] - public void InlineVB() - { - string code = @"Dim xml = - - - <%= From m In menu _ - Where m.Course = ""appetizer"" _ - Select <%= m.Food %> _ - %> - - - <%= From m In menu _ - Where m.Course = ""main"" _ - Select <%= m.Food %> _ - %> - - - <%= From m In menu _ - Where m.Course = ""dessert"" _ - Select <%= m.Food %> _ - %> - - "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(code))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.XmlProcessingInstruction, Tokens.XmlContent, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlStartInlineVB, - Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, Tokens.Where, Tokens.Identifier, Tokens.Dot, - Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.Select, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.XmlCloseTag, Tokens.XmlStartInlineVB, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.XmlEndInlineVB, - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlEndInlineVB, Tokens.XmlContent, Tokens.XmlOpenEndTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlStartInlineVB, - Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, Tokens.Where, Tokens.Identifier, Tokens.Dot, - Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.Select, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.XmlCloseTag, Tokens.XmlStartInlineVB, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.XmlEndInlineVB, - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlEndInlineVB, Tokens.XmlContent, Tokens.XmlOpenEndTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlStartInlineVB, - Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, Tokens.Where, Tokens.Identifier, Tokens.Dot, - Tokens.Identifier, Tokens.Assign, Tokens.LiteralString, Tokens.Select, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.XmlCloseTag, Tokens.XmlStartInlineVB, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.XmlEndInlineVB, - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlEndInlineVB, Tokens.XmlContent, Tokens.XmlOpenEndTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag - ); - - CheckFoot(lexer); - } - - [Test] - public void InlineVB2() - { - string code = @"Dim contact As XElement = <<%=elementName %>> - <%= MyName %> - "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(code))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.As, Tokens.Identifier, Tokens.Assign, Tokens.XmlOpenTag, - Tokens.XmlStartInlineVB, Tokens.Identifier, Tokens.XmlEndInlineVB, Tokens.XmlCloseTag, Tokens.XmlContent, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlStartInlineVB, Tokens.Identifier, Tokens.XmlEndInlineVB, - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, Tokens.XmlCloseTag); - - CheckFoot(lexer); - } - - [Test] - public void XmlAccessOperators() - { - string code = @"Dim childAxis = xml.
. -Dim course3 = xml...(2) -Dim childAxis = xml... -For Each item In childAxis - Console.WriteLine(item.@name) -Next"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(code))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.Identifier, Tokens.Dot, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.Dot, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, - Tokens.EOL, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.Identifier, Tokens.TripleDot, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.OpenParenthesis, Tokens.LiteralInteger, Tokens.CloseParenthesis, - Tokens.EOL, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.Identifier, Tokens.TripleDot, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTag, Tokens.EOL, Tokens.For, Tokens.Each, Tokens.Identifier, Tokens.In, Tokens.Identifier, Tokens.EOL, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.DotAt, Tokens.Identifier, Tokens.CloseParenthesis, Tokens.EOL, - Tokens.Next); - - CheckFoot(lexer); - } - - [Test] - public void GetXmlNamespace() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim name = GetXmlNamespace(x)"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.GetXmlNamespace, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.CloseParenthesis); - - CheckFoot(lexer); - } - - [Test] - public void GetXmlNamespace2() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim name = GetXmlNamespace(db-name)"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.GetXmlNamespace, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.CloseParenthesis); - - - CheckFoot(lexer); - } - - [Test] - public void XmlInSelect() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim data = From x In list Select x"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.From, Tokens.Identifier, Tokens.In, Tokens.Identifier, Tokens.Select, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, Tokens.XmlOpenEndTag, - Tokens.Identifier, Tokens.XmlCloseTag); - - CheckFoot(lexer); - } - - [Test] - public void IfExpressionTest() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Dim name = If(a <> 2, 4, 8)"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.If, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.NotEqual, Tokens.LiteralInteger, - Tokens.Comma, Tokens.LiteralInteger, Tokens.Comma, Tokens.LiteralInteger, Tokens.CloseParenthesis); - - CheckFoot(lexer); - } - - [Test] - public void IfStatementTest() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("If a <> 2 Then Return"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.If, Tokens.Identifier, Tokens.NotEqual, Tokens.LiteralInteger, - Tokens.Then, Tokens.Return); - - - CheckFoot(lexer); - } - - [Test] - public void Bug1() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(@"Dim xml = "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.XmlComment); - - CheckFoot(lexer); - } - - [Test] - public void Bug2() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(@"Dim xml = "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, - Tokens.XmlProcessingInstruction, Tokens.XmlOpenTag, Tokens.Identifier, - Tokens.XmlCloseTagEmptyElement, Tokens.XmlComment); - - CheckFoot(lexer); - } - - [Test] - public void Bug3() - { - VBLexer lexer = GenerateLexerForSnippet(new StringReader("New String() {}"), SnippetType.Expression); - - CheckTokens(lexer, Tokens.New, Tokens.String, Tokens.OpenParenthesis, - Tokens.CloseParenthesis, Tokens.OpenCurlyBrace, Tokens.CloseCurlyBrace); - } - - [Test] - public void Bug4() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(@"Dim x = From kvp As KeyValuePair(Of String, DataGridViewCellStyle) In styleCache.CellStyleCache _ - Select includeStyle(kvp.Key, kvp.Value)"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Dim, Tokens.Identifier, Tokens.Assign, Tokens.From, Tokens.Identifier, Tokens.As, Tokens.Identifier, - Tokens.OpenParenthesis, Tokens.Of, Tokens.String, Tokens.Comma, Tokens.Identifier, Tokens.CloseParenthesis, - Tokens.In, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, - Tokens.Select, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.Identifier, Tokens.Dot, Tokens.Key, Tokens.Comma, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.CloseParenthesis); - - CheckFoot(lexer); - } - - [Test] - public void LessThanCheck() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(@"Dim xml = , True)"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, Tokens.True, - Tokens.CloseParenthesis); - - CheckFoot(lexer); - } - - [Test] - public void AddHandlerStatement() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("AddHandler , True"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.AddHandler, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, Tokens.True); - - CheckFoot(lexer); - } - - [Test] - public void AddHandlerStatement2() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("AddHandler , "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.AddHandler, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTagEmptyElement); - - CheckFoot(lexer); - } - - [Test] - public void RemoveHandlerStatement() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("RemoveHandler , 5"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.RemoveHandler, Tokens.XmlOpenTag, - Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlContent, - Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag - ); - - CheckFoot(lexer); - } - - [Test] - public void ErrorHandlingStatement() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("On Error Resume Next\n" + - "On Error GoTo -1\n" + - "On Error GoTo 0\n" + - "On Error GoTo Test\n" + - "Error 5\n" + - "Error \n" + - "Resume Next\n" + - "Resume Label\n" + - "Resume 4"))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.On, Tokens.Error, Tokens.Resume, Tokens.Next, Tokens.EOL, - Tokens.On, Tokens.Error, Tokens.GoTo, Tokens.Minus, Tokens.LiteralInteger, Tokens.EOL, - Tokens.On, Tokens.Error, Tokens.GoTo, Tokens.LiteralInteger, Tokens.EOL, - Tokens.On, Tokens.Error, Tokens.GoTo, Tokens.Identifier, Tokens.EOL, - Tokens.Error, Tokens.LiteralInteger, Tokens.EOL, - Tokens.Error, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Resume, Tokens.Next, Tokens.EOL, - Tokens.Resume, Tokens.Identifier, Tokens.EOL, - Tokens.Resume, Tokens.LiteralInteger - ); - - CheckFoot(lexer); - } - - [Test] - public void ForLoopStatement() - { - string statement = @"For = To Step -Next , - -For Each In -Next "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.For, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, - Tokens.Assign, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, - Tokens.To, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, - Tokens.Step, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Next, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.For, Tokens.Each, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, - Tokens.In, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Next, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement - ); - - CheckFoot(lexer); - } - - [Test] - public void WhileLoopStatement() - { - string statement = @"While -End While"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.While, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.End, Tokens.While - ); - - CheckFoot(lexer); - } - - [Test] - public void WhileLoopStatement2() - { - string statement = @"Do While -Loop"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Do, Tokens.While, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Loop - ); - - CheckFoot(lexer); - } - - [Test] - public void WhileLoopStatement3() - { - string statement = @"Do -Loop While "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Do, Tokens.EOL, - Tokens.Loop, Tokens.While, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement - ); - - CheckFoot(lexer); - } - - [Test] - public void UntilLoopStatement() - { - string statement = @"Do Until -Loop"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Do, Tokens.Until, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Loop - ); - - CheckFoot(lexer); - } - - [Test] - public void UntilLoopStatement2() - { - string statement = @"Do -Loop Until "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Do, Tokens.EOL, - Tokens.Loop, Tokens.Until, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement - ); - - CheckFoot(lexer); - } - - [Test] - public void IfStatementLarge() - { - string statement = @"If Then -Else If Then -ElseIf Then -Else -End If"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.If, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Then, Tokens.EOL, - Tokens.Else, Tokens.If, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Then, Tokens.EOL, - Tokens.ElseIf, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.XmlOpenEndTag, Tokens.Identifier, Tokens.XmlCloseTag, Tokens.Then, Tokens.EOL, - Tokens.Else, Tokens.EOL, - Tokens.End, Tokens.If - ); - - CheckFoot(lexer); - } - - [Test] - public void SelectStatement() - { - string statement = @"Select Case - Case , - Case Else -End Select"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Select, Tokens.Case, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Case, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Case, Tokens.Else, Tokens.EOL, - Tokens.End, Tokens.Select - ); - - CheckFoot(lexer); - } - - [Test] - public void TryStatement() - { - string statement = @"Try - Catch x - Catch y As Exception - Catch When - Finally -End Try"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Try, Tokens.EOL, - Tokens.Catch, Tokens.Identifier, Tokens.EOL, - Tokens.Catch, Tokens.Identifier, Tokens.As, Tokens.Identifier, Tokens.EOL, - Tokens.Catch, Tokens.When, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Finally, Tokens.EOL, - Tokens.End, Tokens.Try - ); - - CheckFoot(lexer); - } - - [Test] - public void ThrowStatement() - { - VBLexer lexer = GenerateLexer(new StringReader(TestStatement("Throw "))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Throw, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement); - - CheckFoot(lexer); - } - - [Test] - public void BranchStatements() - { - string statement = @"GoTo 5 -GoTo LabelName -Exit Do -Exit For -Exit While -Exit Select -Exit Sub -Exit Function -Exit Property -Exit Try -Continue Do -Continue For -Continue While -Stop -End -Return -Return 5 -Return "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.GoTo, Tokens.LiteralInteger, Tokens.EOL, - Tokens.GoTo, Tokens.Identifier, Tokens.EOL, - Tokens.Exit, Tokens.Do, Tokens.EOL, - Tokens.Exit, Tokens.For, Tokens.EOL, - Tokens.Exit, Tokens.While, Tokens.EOL, - Tokens.Exit, Tokens.Select, Tokens.EOL, - Tokens.Exit, Tokens.Sub, Tokens.EOL, - Tokens.Exit, Tokens.Function, Tokens.EOL, - Tokens.Exit, Tokens.Property, Tokens.EOL, - Tokens.Exit, Tokens.Try, Tokens.EOL, - Tokens.Continue, Tokens.Do, Tokens.EOL, - Tokens.Continue, Tokens.For, Tokens.EOL, - Tokens.Continue, Tokens.While, Tokens.EOL, - Tokens.Stop, Tokens.EOL, - Tokens.End, Tokens.EOL, - Tokens.Return, Tokens.EOL, - Tokens.Return, Tokens.LiteralInteger, Tokens.EOL, - Tokens.Return, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement - ); - - CheckFoot(lexer); - } - - [Test] - public void ArrayHandlingStatements() - { - string statement = @"Erase -Erase , -ReDim Preserve "; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Erase, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.Erase, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.Comma, - Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.ReDim, Tokens.Preserve, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement - ); - - CheckFoot(lexer); - } - - [Test] - public void UsingStatement() - { - string statement = @"Using -End Using"; - - VBLexer lexer = GenerateLexer(new StringReader(TestStatement(statement))); - - CheckHead(lexer); - - CheckTokens(lexer, Tokens.Using, Tokens.XmlOpenTag, Tokens.Identifier, Tokens.XmlCloseTagEmptyElement, Tokens.EOL, - Tokens.End, Tokens.Using - ); - - CheckFoot(lexer); - } - - [Test] - public void NewExpressionWithObjectInitializer() - { - string code = @"New Common.ComboBoxItem With {.Item = _ - Localizer.GetString(""Month"" & initParameters.SelectedDate.FirstDayOfPreviousMonth.Month) & "" "" & - initParameters.SelectedDate.FirstDayOfPreviousMonth.Year, .Value = New Date(2010, initParameters.SelectedDate.FirstDayOfPreviousMonth.Month, 1)}"; - - VBLexer lexer = GenerateLexerForSnippet(new StringReader(code), SnippetType.Expression); - - CheckTokens(lexer, Tokens.New, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, - Tokens.With, Tokens.OpenCurlyBrace, Tokens.Dot, Tokens.Identifier, Tokens.Assign, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.OpenParenthesis, Tokens.LiteralString, - Tokens.ConcatString, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.Dot, - Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.CloseParenthesis, Tokens.ConcatString, - Tokens.LiteralString, Tokens.ConcatString, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, - Tokens.Dot, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.Comma, Tokens.Dot, - Tokens.Identifier, Tokens.Assign, Tokens.New, Tokens.Date, Tokens.OpenParenthesis, Tokens.LiteralInteger, - Tokens.Comma, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.Dot, Tokens.Identifier, Tokens.Dot, - Tokens.Identifier, Tokens.Comma, Tokens.LiteralInteger, Tokens.CloseParenthesis, Tokens.CloseCurlyBrace); - } - #endregion - - #region Helpers - VBLexer GenerateLexer(StringReader sr) - { - return new VBLexer(sr); - } - - VBLexer GenerateLexerForSnippet(StringReader sr, SnippetType type) - { - var lexer = new VBLexer(sr); - lexer.SetInitialContext(type); - return lexer; - } - - string TestStatement(string stmt) - { - return "Class Test\n" + - "Sub A\n" + - stmt + "\n" + - "End Sub\n" + - "End Class"; - } - - void CheckFoot(VBLexer lexer) - { - CheckTokens(lexer, Tokens.EOL, Tokens.End, Tokens.Sub, Tokens.EOL, Tokens.End, Tokens.Class); - } - - void CheckHead(VBLexer lexer) - { - CheckTokens(lexer, Tokens.Class, Tokens.Identifier, Tokens.EOL, - Tokens.Sub, Tokens.Identifier, Tokens.EOL); - } - - void CheckTokens(VBLexer lexer, params int[] tokens) - { - for (int i = 0; i < tokens.Length; i++) { - int token = tokens[i]; - Token t = lexer.NextToken(); - int next = t.Kind; - Assert.IsEmpty(lexer.Errors.ErrorOutput); - Assert.AreEqual(token, next, "{2} of {3}: expected: \"{0}\", was: \"{1}\"; at {4}", Tokens.GetTokenString(token), Tokens.GetTokenString(next), i + 1, tokens.Length, t.Location); - } - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs deleted file mode 100644 index 6d4bb2da9..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMParenthesizedExpressionTest.cs +++ /dev/null @@ -1,22 +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 System; -using System.CodeDom; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Visitors; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests -{ - [TestFixture] - public class CodeDOMParenthesizedExpressionTest - { - [Test] - public void TestParenthesizedExpression() - { - object output = new ParenthesizedExpression(new PrimitiveExpression(5, "5")).AcceptVisitor(new CodeDomVisitor(), null); - Assert.IsTrue(output is CodePrimitiveExpression); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs deleted file mode 100644 index 2d1c89d1b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMPrimitiveExpressionTest.cs +++ /dev/null @@ -1,23 +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 System; -using System.CodeDom; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Visitors; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests -{ - [TestFixture] - public class CodeDOMPrimitiveExpressionsTests - { - [Test] - public void TestPrimitiveExpression() - { - object output = new PrimitiveExpression(5, "5").AcceptVisitor(new CodeDomVisitor(), null); - Assert.IsTrue(output is CodePrimitiveExpression); - Assert.AreEqual(((CodePrimitiveExpression)output).Value, 5); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs deleted file mode 100644 index fffd395c1..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/CodeDOMTypeReferenceTest.cs +++ /dev/null @@ -1,30 +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 System; -using System.CodeDom; -using System.Collections.Generic; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Visitors; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests -{ - [TestFixture] - public class CodeDOMTypeReferenceTest - { - [TestAttribute] - public void InnerClassTypeReferencTest() - { - InnerClassTypeReference ictr = new InnerClassTypeReference( - new TypeReference("OuterClass", new List { new TypeReference("String") }), - "InnerClass", - new List { new TypeReference("Int32"), new TypeReference("Int64") }); - Assert.AreEqual("OuterClass+InnerClass", ictr.ToString()); - CodeTypeOfExpression result = (CodeTypeOfExpression)new TypeOfExpression(ictr).AcceptVisitor(new CodeDomVisitor(), null); - Assert.AreEqual("OuterClass`1+InnerClass`2", result.Type.BaseType); - Assert.AreEqual(3, result.Type.TypeArguments.Count); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs deleted file mode 100644 index 443dcfe3c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/CodeDOM/InvocationExpressionTest.cs +++ /dev/null @@ -1,59 +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 System; -using System.CodeDom; -using System.Collections.Generic; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Visitors; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Output.CodeDom.Tests -{ - [TestFixture] - public class InvocationExpressionsTests - { - [Test] - public void IdentifierOnlyInvocation() - { - // InitializeComponents(); - SimpleNameExpression identifier = new SimpleNameExpression("InitializeComponents"); - InvocationExpression invocation = new InvocationExpression(identifier, new List()); - object output = invocation.AcceptVisitor(new CodeDomVisitor(), null); - Assert.IsTrue(output is CodeMethodInvokeExpression); - CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output; - Assert.AreEqual("InitializeComponents", mie.Method.MethodName); - Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression); - } - - [Test] - public void MethodOnThisReferenceInvocation() - { - // InitializeComponents(); - MemberReferenceExpression field = new MemberReferenceExpression(new ThisReferenceExpression(), "InitializeComponents"); - InvocationExpression invocation = new InvocationExpression(field, new List()); - object output = invocation.AcceptVisitor(new CodeDomVisitor(), null); - Assert.IsTrue(output is CodeMethodInvokeExpression); - CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output; - Assert.AreEqual("InitializeComponents", mie.Method.MethodName); - Assert.IsTrue(mie.Method.TargetObject is CodeThisReferenceExpression); - } - - [Test] - public void InvocationOfStaticMethod() - { - // System.Drawing.Color.FromArgb(); - MemberReferenceExpression field = new MemberReferenceExpression(new SimpleNameExpression("System"), "Drawing"); - field = new MemberReferenceExpression(field, "Color"); - field = new MemberReferenceExpression(field, "FromArgb"); - InvocationExpression invocation = new InvocationExpression(field, new List()); - object output = invocation.AcceptVisitor(new CodeDomVisitor(), null); - Assert.IsTrue(output is CodeMethodInvokeExpression); - CodeMethodInvokeExpression mie = (CodeMethodInvokeExpression)output; - Assert.AreEqual("FromArgb", mie.Method.MethodName); - Assert.IsTrue(mie.Method.TargetObject is CodeTypeReferenceExpression); - Assert.AreEqual("System.Drawing.Color", (mie.Method.TargetObject as CodeTypeReferenceExpression).Type.BaseType); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs deleted file mode 100644 index 5c0328ec2..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/SpecialOutputVisitorTest.cs +++ /dev/null @@ -1,79 +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 System; -using System.Collections.Generic; -using System.IO; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.PrettyPrinter; - -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter -{ - [TestFixture] - public class SpecialOutputVisitorTest - { - void TestProgram(string program) - { - VBParser parser = ParserFactory.CreateParser(new StringReader(program)); - parser.Parse(); - Assert.AreEqual("", parser.Errors.ErrorOutput); - VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); - outputVisitor.Options.IndentationChar = ' '; - outputVisitor.Options.TabSize = 2; - outputVisitor.Options.IndentSize = 2; - using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(), - outputVisitor)) { - outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null); - } - Assert.AreEqual("", outputVisitor.Errors.ErrorOutput); - Assert.AreEqual(program.Replace("\r", ""), outputVisitor.Text.TrimEnd().Replace("\r", "")); - parser.Dispose(); - } - - [Test] - public void Enum() - { - TestProgram("Enum Test\n" + - " ' a\n" + - " m1\n" + - " ' b\n" + - " m2\n" + - " ' c\n" + - "End Enum\n" + - "' d"); - } - - [Test] - public void CommentsInsideMethod() - { - TestProgram(@"Public Class Class1 - Private Function test(l As Integer, lvw As Integer) As Boolean - ' Begin - Dim i As Integer = 1 - Return False - ' End of method - End Function -End Class"); - } - - [Test] - public void BlankLines() - { - TestProgram("Imports System\n" + - "\n" + - "Imports System.IO"); - TestProgram("Imports System\n" + - "\n" + - "\n" + - "Imports System.IO"); - TestProgram("\n" + - "' Some comment\n" + - "\n" + - "Imports System.IO"); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs deleted file mode 100644 index dc8160638..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Output/VBNet/VBNetOutputTest.cs +++ /dev/null @@ -1,670 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.PrettyPrinter; -using ICSharpCode.NRefactory.VB.Visitors; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.PrettyPrinter -{ - [TestFixture] - public class VBNetOutputTest - { - void TestProgram(string program) - { - VBParser parser = ParserFactory.CreateParser(new StringReader(program)); - parser.Parse(); - Assert.AreEqual("", parser.Errors.ErrorOutput); - VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); - outputVisitor.Options.OutputByValModifier = true; - outputVisitor.VisitCompilationUnit(parser.CompilationUnit, null); - Assert.AreEqual("", outputVisitor.Errors.ErrorOutput); - Assert.AreEqual(StripWhitespace(program), StripWhitespace(outputVisitor.Text)); - } - - string StripWhitespace(string text) - { - text = text.Trim().Replace("\t", "").Replace("\r", "").Replace("\n", " ").Replace(" ", " "); - while (text.Contains(" ")) { - text = text.Replace(" ", " "); - } - return text; - } - - void TestTypeMember(string program) - { - TestProgram("Class A\n" + program + "\nEnd Class"); - } - - void TestStatement(string statement) - { - TestTypeMember("Sub Method()\n" + statement + "\nEnd Sub"); - } - - void TestExpression(string expression) - { - VBParser parser = ParserFactory.CreateParser(new StringReader(expression)); - Expression e = parser.ParseExpression(); - Assert.AreEqual("", parser.Errors.ErrorOutput); - VBNetOutputVisitor outputVisitor = new VBNetOutputVisitor(); - e.AcceptVisitor(outputVisitor, null); - Assert.AreEqual("", outputVisitor.Errors.ErrorOutput); - Assert.AreEqual(StripWhitespace(expression), StripWhitespace(outputVisitor.Text)); - } - - [Test] - public void Field() - { - TestTypeMember("Private a As Integer"); - } - - [Test] - public void Method() - { - TestTypeMember("Sub Method()\nEnd Sub"); - } - - [Test] - public void EnumWithBaseType() - { - TestProgram("Public Enum Foo As UShort\nEnd Enum"); - } - - [Test] - public void PartialModifier() - { - TestProgram("Public Partial Class Foo\nEnd Class"); - } - - [Test] - public void MustInheritClass() - { - TestProgram("Public MustInherit Class Foo\nEnd Class"); - } - - [Test] - public void GenericClassDefinition() - { - TestProgram("Public Class Foo(Of T As {IDisposable, ICloneable})\nEnd Class"); - } - - [Test] - public void GenericClassDefinitionWithBaseType() - { - TestProgram("Public Class Foo(Of T As IDisposable)\nInherits BaseType\nEnd Class"); - } - - [Test] - public void GenericMethodDefinition() - { - TestTypeMember("Public Sub Foo(Of T As {IDisposable, ICloneable})(ByVal arg As T)\nEnd Sub"); - } - - [Test] - public void ArrayRank() - { - TestStatement("Dim a As Object(,,)"); - } - - [Test] - public void ArrayInitialization() - { - TestStatement("Dim a As Object() = New Object(10) {}"); - TestTypeMember("Private MultiDim As Integer(,) = {{1, 2}, {1, 3}}"); - TestExpression("New Integer(, ) {{1, 1}, {1, 1}}"); - TestTypeMember("Private _titles As String() = New String() {}"); - } - - [Test] - public void MethodCallWithOptionalArguments() - { - TestExpression("M(, )"); - } - - [Test] - public void IfStatement() - { - TestStatement("If a Then\n" + - "\tm1()\n" + - "ElseIf b Then\n" + - "\tm2()\n" + - "Else\n" + - "\tm3()\n" + - "End If"); - } - - [Test] - public void ForNextLoop() - { - TestStatement("For i = 0 To 10\n" + - "Next"); - TestStatement("For i As Long = 10 To 0 Step -1\n" + - "Next"); - } - - [Test] - public void DoLoop() - { - TestStatement("Do\n" + - "Loop"); - TestStatement("Do\n" + - "Loop While Not (i = 10)"); - } - - [Test] - public void SelectCase() - { - TestStatement(@"Select Case i - Case 0 - Case 1 To 4 - Case Else -End Select"); - } - - [Test] - public void UsingStatement() - { - TestStatement(@"Using nf As New Font(), nf2 As New List(Of Font)(), nf3 = Nothing - Bla(nf) -End Using"); - } - - [Test] - public void UntypedVariable() - { - TestStatement("Dim x = 0"); - } - - [Test] - public void UntypedField() - { - TestTypeMember("Dim x = 0"); - } - - [Test] - public void Assignment() - { - TestExpression("a = b"); - } - - [Test] - public void SpecialIdentifiers() - { - // Assembly, Ansi and Until are contextual keywords - // Custom is valid inside methods, but not valid for field names - TestExpression("Assembly = Ansi * [For] + Until - [Custom]"); - } - - [Test] - public void DictionaryAccess() - { - TestExpression("c!key"); - } - - [Test] - public void GenericMethodInvocation() - { - TestExpression("GenericMethod(Of T)(arg)"); - } - - [Test] - public void SpecialIdentifierName() - { - TestExpression("[Class]"); - } - - [Test] - public void GenericDelegate() - { - TestProgram("Public Delegate Function Predicate(Of T)(ByVal item As T) As String"); - } - - [Test] - public void Enum() - { - TestProgram("Enum MyTest\nRed\n Green\n Blue\nYellow\n End Enum"); - } - - [Test] - public void EnumWithInitializers() - { - TestProgram("Enum MyTest\nRed = 1\n Green = 2\n Blue = 4\n Yellow = 8\n End Enum"); - } - - [Test] - public void SyncLock() - { - TestStatement("SyncLock a\nWork()\nEnd SyncLock"); - } - - [Test] - public void Using() - { - TestStatement("Using a As New A()\na.Work()\nEnd Using"); - } - - [Test] - public void Cast() - { - TestExpression("CType(a, T)"); - } - - [Test] - public void DirectCast() - { - TestExpression("DirectCast(a, T)"); - } - - [Test] - public void TryCast() - { - TestExpression("TryCast(a, T)"); - } - - [Test] - public void PrimitiveCast() - { - TestExpression("CStr(a)"); - } - - [Test] - public void TypeOfIs() - { - TestExpression("TypeOf a Is String"); - } - - [Test] - public void PropertyWithAccessorAccessModifiers() - { - TestTypeMember("Public Property ExpectsValue() As Boolean\n" + - "\tPublic Get\n" + - "\tEnd Get\n" + - "\tProtected Set\n" + - "\tEnd Set\n" + - "End Property"); - } - - [Test] - public void AutoProperty() - { - TestTypeMember("Public Property Value()"); - TestTypeMember("Public Property Value() As Integer"); - TestTypeMember("Public Property Value() As Integer = 5"); - TestTypeMember("Public Property Value() As New List()"); - } - - [Test] - public void AbstractProperty() - { - TestTypeMember("Public MustOverride Property ExpectsValue() As Boolean"); - TestTypeMember("Public MustOverride ReadOnly Property ExpectsValue() As Boolean"); - TestTypeMember("Public MustOverride WriteOnly Property ExpectsValue() As Boolean"); - } - - [Test] - public void AbstractMethod() - { - TestTypeMember("Public MustOverride Sub Run()"); - TestTypeMember("Public MustOverride Function Run() As Boolean"); - } - - [Test] - public void InterfaceImplementingMethod() - { - TestTypeMember("Public Sub Run() Implements SomeInterface.Run\nEnd Sub"); - TestTypeMember("Public Function Run() As Boolean Implements SomeInterface.Bla\nEnd Function"); - } - - [Test] - public void NamedAttributeArgument() - { - TestProgram(" _\n" + - "Class Test\n" + - "End Class"); - } - - [Test] - public void ReturnTypeAttribute() - { - TestTypeMember("Function A() As String\n" + - "End Function"); - } - - [Test] - public void AssemblyAttribute() - { - TestProgram(""); - } - - [Test] - public void ModuleAttribute() - { - TestProgram(""); - } - - [Test] - public void Interface() - { - TestProgram("Interface ITest\n" + - "Property GetterAndSetter() As Boolean\n" + - "ReadOnly Property GetterOnly() As Boolean\n" + - "WriteOnly Property SetterOnly() As Boolean\n" + - "Sub InterfaceMethod()\n" + - "Function InterfaceMethod2() As String\n" + - "End Interface"); - } - - [Test] - public void OnErrorStatement() - { - TestStatement("On Error Resume Next"); - } - - [Test] - public void OverloadedConversionOperators() - { - TestTypeMember("Public Shared Narrowing Operator CType(ByVal xmlNode As XmlNode) As TheBug\nEnd Operator"); - TestTypeMember("Public Shared Widening Operator CType(ByVal bugNode As TheBug) As XmlNode\nEnd Operator"); - } - - [Test] - public void OverloadedTrueFalseOperators() - { - TestTypeMember("Public Shared Operator IsTrue(ByVal a As TheBug) As Boolean\nEnd Operator"); - TestTypeMember("Public Shared Operator IsFalse(ByVal a As TheBug) As Boolean\nEnd Operator"); - } - - [Test] - public void OverloadedOperators() - { - TestTypeMember("Public Shared Operator +(ByVal bugNode As TheBug, ByVal bugNode2 As TheBug) As TheBug\nEnd Operator"); - TestTypeMember("Public Shared Operator >>(ByVal bugNode As TheBug, ByVal b As Integer) As TheBug\nEnd Operator"); - } - - [Test] - public void AttributeOnParameter() - { - TestTypeMember("Sub Main(ByRef one As Integer, ByRef two As Integer, ByRef three As Integer)\nEnd Sub"); - } - - [Test] - public void FieldWithoutType() - { - TestTypeMember("Dim X"); - } - - [Test] - public void UsingStatementForExistingVariable() - { - TestStatement("Using obj\nEnd Using"); - } - - [Test] - public void ContinueFor() - { - TestStatement("Continue For"); - } - - [Test] - public void ForNextStatementWithFieldLoopVariable() - { - TestStatement("For Me.Field = 0 To 10\n" + - "Next Me.Field"); - } - - [Test] - public void WithStatement() - { - TestStatement("With Ejes\n" + - "\t.AddLine(New Point(Me.ClientSize.Width / 2, 0), (New Point(Me.ClientSize.Width / 2, Me.ClientSize.Height)))\n" + - "End With"); - } - - [Test] - public void NewConstraint() - { - TestProgram("Public Class Rational(Of T, O As {IRationalMath(Of T), New})\nEnd Class"); - } - - [Test] - public void StructConstraint() - { - TestProgram("Public Class Rational(Of T, O As {IRationalMath(Of T), Structure})\nEnd Class"); - } - - [Test] - public void ClassConstraint() - { - TestProgram("Public Class Rational(Of T, O As {IRationalMath(Of T), Class})\nEnd Class"); - } - - [Test] - public void Integer() - { - TestExpression("16"); - } - - [Test] - public void Double() - { - TestExpression("1.0"); - } - - [Test] - public void HexadecimalInteger() - { - TestExpression("&H10"); - } - - [Test] - public void HexadecimalMinusOne() - { - TestExpression("&Hffffffff"); - } - - [Test] - public void TypeCharacters() - { - TestExpression("347S"); - TestExpression("347L"); - TestExpression("347D"); - TestExpression("347F"); - TestExpression("347US"); - TestExpression("347UI"); - TestExpression("347UL"); - TestExpression("\".\"C"); - } - - [Test] - public void AddressOf() - { - TestExpression("AddressOf Abc"); - } - - [Test] - public void ChainedConstructorCall() - { - TestExpression("MyBase.New()"); - TestExpression("Me.New()"); - TestExpression("MyClass.New()"); - } - - [Test] - public void NewMethodCall() - { - TestExpression("something.[New]()"); - } - - [Test] - public void ObjectInitializer() - { - TestExpression("New StringWriter() With { _\n" + - " .NewLine = Environment.NewLine, _\n" + - " .Encoding = Encoding.UTF8 _\n" + - "}"); - } - - [Test] - public void EventDefinition() - { - TestTypeMember("Public Event MyEvent(ByVal sender As Object)"); - } - - [Test] - public void Options() - { - TestProgram("Option Strict On\n" + - "Option Explicit On\n" + - "Option Infer On\n" + - "Option Compare Text"); - } - - [Test] - public void UntypedForeach() - { - TestStatement("For Each x In myGuidArray\nNext"); - } - - [Test] - public void MethodDefinitionWithOptionalParameter() - { - TestTypeMember("Sub M(Optional ByVal msg As String = Nothing, Optional ByRef output As String = Nothing)\nEnd Sub"); - } - - [Test] - public void Module() - { - TestProgram("Module Test\n" + - " Sub M()\n" + - " End Sub\n" + - "End Module"); - } - - [Test] - public void WithEvents() - { - TestTypeMember("Dim WithEvents a As Button"); - } - - [Test] - public void FriendWithEventsField() - { - TestTypeMember("Friend WithEvents Button1 As System.Windows.Forms.Button"); - } - - [Test] - public void SimpleFunctionLambda() - { - TestExpression("Function(x) x * x"); - } - - [Test] - public void SimpleFunctionLambdaWithType() - { - TestExpression("Function(x As Integer) x * x"); - } - - [Test] - public void SimpleSubLambdaWithType() - { - TestExpression("Sub(x As Integer) Console.WriteLine(x)"); - } - - [Test] - public void BlockSubLambdaWithType() - { - TestExpression("Sub(x As Integer)\n" + - " Console.WriteLine(x)\n" + - "End Sub"); - } - - [Test] - public void BlockFunctionLambdaWithType() - { - TestExpression("Function(x As Integer) As Integer\n" + - " If x < 2 Then\n" + - " Return x\n" + - " End If\n" + - " Return x * x\n" + - "End Function"); - } - - [Test] - public void XmlSimple() - { - TestExpression("\n" + - "\n" + - "\n" + - " \n" + - " />\n" + - ""); - } - - [Test] - public void XmlNested() - { - TestExpression(@" - - Shrimp Cocktail - Escargot - - - Filet Mignon - Garlic Potatoes - Broccoli - - - Chocolate Cheesecake - - "); - } - - [Test] - public void XmlDocument() - { - TestExpression(@" - - - Shrimp Cocktail - Escargot - - "); - } - - [Test] - public void XmlNestedWithExpressions() - { - TestExpression(@" - - - <%= From m In menu _ - Where m.Course = ""appetizer"" _ - Select <%= m.Food %> %> - - - <%= From m In menu _ - Where m.Course = ""main"" _ - Select <%= m.Food %> %> - - - <%= From m In menu _ - Where m.Course = ""dessert"" _ - Select <%= m.Food %> %> - - "); - } - - [Test] - public void XmlAccessExpressions() - { - TestExpression("xml.."); - TestExpression("xml..."); - TestExpression("xml...(2)"); - TestExpression("item.@name"); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs deleted file mode 100644 index 40df05fef..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AddressOfExpressionTests.cs +++ /dev/null @@ -1,45 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class AddressOfExpressionTests - { - [Test] - public void SimpleAddressOfExpressionTest() - { - AddressOfExpression ae = ParseUtil.ParseExpression("AddressOf t"); - Assert.IsNotNull(ae); - Assert.IsInstanceOf(typeof(IdentifierExpression), ae.Expression); - Assert.AreEqual("t", ((IdentifierExpression)ae.Expression).Identifier, "t"); - } - - [Test] - public void GenericAddressOfExpressionTest() - { - AddressOfExpression ae = ParseUtil.ParseExpression("AddressOf t(Of X)"); - Assert.IsNotNull(ae); - Assert.IsInstanceOf(typeof(IdentifierExpression), ae.Expression); - Assert.AreEqual("t", ((IdentifierExpression)ae.Expression).Identifier, "t"); - Assert.AreEqual(1, ((IdentifierExpression)ae.Expression).TypeArguments.Count); - Assert.AreEqual("X", ((IdentifierExpression)ae.Expression).TypeArguments[0].Type); - } - - [Test] - public void MemberReferenceAddressOfExpressionTest() - { - AddressOfExpression ae = ParseUtil.ParseExpression("AddressOf Me.t(Of X)"); - Assert.IsNotNull(ae); - Assert.IsInstanceOf(typeof(MemberReferenceExpression), ae.Expression); - Assert.AreEqual("t", ((MemberReferenceExpression)ae.Expression).MemberName, "t"); - Assert.IsInstanceOf(typeof(ThisReferenceExpression), ((MemberReferenceExpression)ae.Expression).TargetObject); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs deleted file mode 100644 index 673c6f8ab..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ArrayCreateExpressionTests.cs +++ /dev/null @@ -1,36 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ArrayCreateExpressionTests - { - [Test] - public void ArrayCreateExpressionTest1() - { - ArrayCreateExpression ace = ParseUtil.ParseExpression("new Integer() {1, 2, 3, 4}"); - - Assert.AreEqual("System.Int32", ace.CreateType.Type); - Assert.AreEqual(0, ace.Arguments.Count); - Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); - } - - [Test] - public void ArrayCreateExpressionTest2() - { - ArrayCreateExpression ace = ParseUtil.ParseExpression("New Integer(0 To 5){0, 1, 2, 3, 4, 5}"); - - Assert.AreEqual("System.Int32", ace.CreateType.Type); - Assert.AreEqual(1, ace.Arguments.Count); - Assert.AreEqual(5, (ace.Arguments[0] as PrimitiveExpression).Value); - Assert.AreEqual(new int[] {0}, ace.CreateType.RankSpecifier); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs deleted file mode 100644 index f01c4e272..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/AssignmentExpressionTests.cs +++ /dev/null @@ -1,73 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class AssignmentExpressionTests - { - void TestAssignmentExpression(string program, AssignmentOperatorType op) - { - ExpressionStatement se = ParseUtil.ParseStatement(program); - AssignmentExpression ae = se.Expression as AssignmentExpression; - Assert.AreEqual(op, ae.Op); - - Assert.IsTrue(ae.Left is IdentifierExpression); - Assert.IsTrue(ae.Right is IdentifierExpression); - } - - [Test] - public void AssignTest() - { - TestAssignmentExpression("a = b", AssignmentOperatorType.Assign); - } - - [Test] - public void AddTest() - { - TestAssignmentExpression("a += b", AssignmentOperatorType.Add); - } - - [Test] - public void SubtractTest() - { - TestAssignmentExpression("a -= b", AssignmentOperatorType.Subtract); - } - - [Test] - public void MultiplyTest() - { - TestAssignmentExpression("a *= b", AssignmentOperatorType.Multiply); - } - - [Test] - public void DivideTest() - { - TestAssignmentExpression("a /= b", AssignmentOperatorType.Divide); - } - - [Test] - public void ExclusiveOrTest() - { - TestAssignmentExpression("a ^= b", AssignmentOperatorType.Power); - } - - [Test] - public void StringConcatTest() - { - TestAssignmentExpression("a &= b", AssignmentOperatorType.ConcatString); - } - - [Test] - public void ModulusTest() - { - TestAssignmentExpression("a \\= b", AssignmentOperatorType.DivideInteger); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs deleted file mode 100644 index 0747f40f6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BaseReferenceExpressionTests.cs +++ /dev/null @@ -1,24 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class BaseReferenceExpressionTests - { - #region VB.NET - [Test] - public void VBNetBaseReferenceExpressionTest1() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("MyBase.myField"); - Assert.IsTrue(fre.TargetObject is BaseReferenceExpression); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs deleted file mode 100644 index 256144aae..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/BinaryOperatorExpressionTests.cs +++ /dev/null @@ -1,268 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.PrettyPrinter; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class BinaryOperatorExpressionTests - { - void OperatorPrecedenceTest(string strongOperator, BinaryOperatorType strongOperatorType, - string weakOperator, BinaryOperatorType weakOperatorType) - { - string program = "a " + weakOperator + " b " + strongOperator + " c"; - BinaryOperatorExpression boe; - boe = ParseUtil.ParseExpression(program); - Assert.AreEqual(weakOperatorType, boe.Op); - Assert.IsTrue(boe.Left is SimpleNameExpression); - boe = (BinaryOperatorExpression)boe.Right; - Assert.AreEqual(strongOperatorType, boe.Op); - Assert.IsTrue(boe.Left is SimpleNameExpression); - Assert.IsTrue(boe.Right is SimpleNameExpression); - - program = "a " + strongOperator + " b " + weakOperator + " c"; - boe = ParseUtil.ParseExpression(program); - Assert.AreEqual(weakOperatorType, boe.Op); - Assert.IsTrue(boe.Right is SimpleNameExpression); - boe = (BinaryOperatorExpression)boe.Left; - Assert.AreEqual(strongOperatorType, boe.Op); - Assert.IsTrue(boe.Left is SimpleNameExpression); - Assert.IsTrue(boe.Right is SimpleNameExpression); - } - - void SameOperatorPrecedenceTest(string firstOperator, BinaryOperatorType firstOperatorType, - string secondOperator, BinaryOperatorType secondOperatorType) - { - string program = "a " + secondOperator + " b " + firstOperator + " c"; - BinaryOperatorExpression boe; - boe = ParseUtil.ParseExpression(program); - Assert.AreEqual(firstOperatorType, boe.Op); - Assert.IsTrue(boe.Right is SimpleNameExpression); - boe = (BinaryOperatorExpression)boe.Left; - Assert.AreEqual(secondOperatorType, boe.Op); - Assert.IsTrue(boe.Left is SimpleNameExpression); - Assert.IsTrue(boe.Right is SimpleNameExpression); - - program = "a " + firstOperator + " b " + secondOperator + " c"; - boe = ParseUtil.ParseExpression(program); - Assert.AreEqual(secondOperatorType, boe.Op); - Assert.IsTrue(boe.Right is SimpleNameExpression); - boe = (BinaryOperatorExpression)boe.Left; - Assert.AreEqual(firstOperatorType, boe.Op); - Assert.IsTrue(boe.Left is SimpleNameExpression); - Assert.IsTrue(boe.Right is SimpleNameExpression); - } - - #region VB.NET - void VBNetTestBinaryOperatorExpressionTest(string program, BinaryOperatorType op) - { - BinaryOperatorExpression boe = ParseUtil.ParseExpression(program); - Assert.AreEqual(op, boe.Op); - - Assert.IsTrue(boe.Left is SimpleNameExpression); - Assert.IsTrue(boe.Right is SimpleNameExpression); - } - - [Test] - public void VBOperatorPrecedenceTest() - { - OperatorPrecedenceTest("^", BinaryOperatorType.Power, "*", BinaryOperatorType.Multiply); - SameOperatorPrecedenceTest("*", BinaryOperatorType.Multiply, "/", BinaryOperatorType.Divide); - OperatorPrecedenceTest("/", BinaryOperatorType.Divide, "\\", BinaryOperatorType.DivideInteger); - OperatorPrecedenceTest("\\", BinaryOperatorType.DivideInteger, "Mod", BinaryOperatorType.Modulus); - OperatorPrecedenceTest("Mod", BinaryOperatorType.Modulus, "+", BinaryOperatorType.Add); - SameOperatorPrecedenceTest("+", BinaryOperatorType.Add, "-", BinaryOperatorType.Subtract); - OperatorPrecedenceTest("-", BinaryOperatorType.Subtract, "&", BinaryOperatorType.Concat); - OperatorPrecedenceTest("&", BinaryOperatorType.Concat, "<<", BinaryOperatorType.ShiftLeft); - SameOperatorPrecedenceTest("<<", BinaryOperatorType.ShiftLeft, ">>", BinaryOperatorType.ShiftRight); - OperatorPrecedenceTest("<<", BinaryOperatorType.ShiftLeft, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest("<>", BinaryOperatorType.InEquality, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest("<", BinaryOperatorType.LessThan, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest("<=", BinaryOperatorType.LessThanOrEqual, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest(">", BinaryOperatorType.GreaterThan, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest(">=", BinaryOperatorType.GreaterThanOrEqual, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest("Like", BinaryOperatorType.Like, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest("Is", BinaryOperatorType.ReferenceEquality, "=", BinaryOperatorType.Equality); - SameOperatorPrecedenceTest("IsNot", BinaryOperatorType.ReferenceInequality, "=", BinaryOperatorType.Equality); - OperatorPrecedenceTest("=", BinaryOperatorType.Equality, "And", BinaryOperatorType.BitwiseAnd); - SameOperatorPrecedenceTest("And", BinaryOperatorType.BitwiseAnd, "AndAlso", BinaryOperatorType.LogicalAnd); - OperatorPrecedenceTest("And", BinaryOperatorType.BitwiseAnd, "Or", BinaryOperatorType.BitwiseOr); - SameOperatorPrecedenceTest("Or", BinaryOperatorType.BitwiseOr, "OrElse", BinaryOperatorType.LogicalOr); - SameOperatorPrecedenceTest("Or", BinaryOperatorType.BitwiseOr, "Xor", BinaryOperatorType.ExclusiveOr); - } - - [Test] - public void VBNetPowerTest() - { - VBNetTestBinaryOperatorExpressionTest("a ^ b", BinaryOperatorType.Power); - } - - [Test] - public void VBNetConcatTest() - { - VBNetTestBinaryOperatorExpressionTest("a & b", BinaryOperatorType.Concat); - } - - [Test] - public void VBNetLogicalAndTest() - { - VBNetTestBinaryOperatorExpressionTest("a AndAlso b", BinaryOperatorType.LogicalAnd); - } - [Test] - public void VBNetLogicalAndNotLazyTest() - { - VBNetTestBinaryOperatorExpressionTest("a And b", BinaryOperatorType.BitwiseAnd); - } - - [Test] - public void VBNetLogicalOrTest() - { - VBNetTestBinaryOperatorExpressionTest("a OrElse b", BinaryOperatorType.LogicalOr); - } - [Test] - public void VBNetLogicalOrNotLazyTest() - { - VBNetTestBinaryOperatorExpressionTest("a Or b", BinaryOperatorType.BitwiseOr); - } - - [Test] - public void VBNetExclusiveOrTest() - { - VBNetTestBinaryOperatorExpressionTest("a Xor b", BinaryOperatorType.ExclusiveOr); - } - - - [Test] - public void VBNetGreaterThanTest() - { - VBNetTestBinaryOperatorExpressionTest("a > b", BinaryOperatorType.GreaterThan); - } - - [Test] - public void VBNetGreaterThanOrEqualTest() - { - VBNetTestBinaryOperatorExpressionTest("a >= b", BinaryOperatorType.GreaterThanOrEqual); - } - - [Test] - public void VBNetEqualityTest() - { - VBNetTestBinaryOperatorExpressionTest("a = b", BinaryOperatorType.Equality); - } - - [Test] - public void VBNetInEqualityTest() - { - VBNetTestBinaryOperatorExpressionTest("a <> b", BinaryOperatorType.InEquality); - } - - [Test] - public void VBNetLessThanTest() - { - VBNetTestBinaryOperatorExpressionTest("a < b", BinaryOperatorType.LessThan); - } - - [Test] - public void VBNetLessThanOrEqualTest() - { - VBNetTestBinaryOperatorExpressionTest("a <= b", BinaryOperatorType.LessThanOrEqual); - } - - [Test] - public void VBNetAddTest() - { - VBNetTestBinaryOperatorExpressionTest("a + b", BinaryOperatorType.Add); - } - - [Test] - public void VBNetSubtractTest() - { - VBNetTestBinaryOperatorExpressionTest("a - b", BinaryOperatorType.Subtract); - } - - [Test] - public void VBNetMultiplyTest() - { - VBNetTestBinaryOperatorExpressionTest("a * b", BinaryOperatorType.Multiply); - } - - [Test] - public void VBNetDivideTest() - { - VBNetTestBinaryOperatorExpressionTest("a / b", BinaryOperatorType.Divide); - } - - [Test] - public void VBNetDivideIntegerTest() - { - VBNetTestBinaryOperatorExpressionTest("a \\ b", BinaryOperatorType.DivideInteger); - } - - [Test] - public void VBNetModulusTest() - { - VBNetTestBinaryOperatorExpressionTest("a Mod b", BinaryOperatorType.Modulus); - } - - [Test] - public void VBNetShiftLeftTest() - { - VBNetTestBinaryOperatorExpressionTest("a << b", BinaryOperatorType.ShiftLeft); - } - - [Test] - public void VBNetShiftRightTest() - { - VBNetTestBinaryOperatorExpressionTest("a >> b", BinaryOperatorType.ShiftRight); - } - - [Test] - public void VBNetISTest() - { - VBNetTestBinaryOperatorExpressionTest("a is b", BinaryOperatorType.ReferenceEquality); - } - - [Test] - public void VBNetISNotTest() - { - VBNetTestBinaryOperatorExpressionTest("a IsNot b", BinaryOperatorType.ReferenceInequality); - } - - [Test] - public void VBNetLikeTest() - { - VBNetTestBinaryOperatorExpressionTest("a Like b", BinaryOperatorType.Like); - } - - [Test] - public void VBNetNullCoalescingTest() - { - VBNetTestBinaryOperatorExpressionTest("If(a, b)", BinaryOperatorType.NullCoalescing); - } - - [Test] - public void VBNetDictionaryAccess() - { - BinaryOperatorExpression boe = ParseUtil.ParseExpression("a!b"); - Assert.AreEqual(BinaryOperatorType.DictionaryAccess, boe.Op); - Assert.IsTrue(boe.Left is SimpleNameExpression); - Assert.IsTrue(boe.Right is PrimitiveExpression); - } - - [Test] - public void VBNetWithDictionaryAccess() - { - BinaryOperatorExpression boe = ParseUtil.ParseExpression("!b"); - Assert.AreEqual(BinaryOperatorType.DictionaryAccess, boe.Op); - Assert.IsTrue(boe.Left.IsNull); - Assert.IsTrue(boe.Right is PrimitiveExpression); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs deleted file mode 100644 index d93aa709d..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/CastExpressionTests.cs +++ /dev/null @@ -1,181 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class CastExpressionTests - { - #region VB.NET - void TestSpecializedCast(string castExpression, Type castType) - { - CastExpression ce = ParseUtil.ParseExpression(castExpression); - Assert.AreEqual(castType.FullName, ce.CastTo.Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.PrimitiveConversion, ce.CastType); - } - - - [Test] - public void VBNetSimpleCastExpression() - { - CastExpression ce = ParseUtil.ParseExpression("CType(o, MyObject)"); - Assert.AreEqual("MyObject", ce.CastTo.Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.Conversion, ce.CastType); - } - - [Test] - public void VBNetGenericCastExpression() - { - CastExpression ce = ParseUtil.ParseExpression("CType(o, List(of T))"); - Assert.AreEqual("List", ce.CastTo.Type); - Assert.AreEqual("T", ce.CastTo.GenericTypes[0].Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.Conversion, ce.CastType); - } - - [Test] - public void VBNetSimpleDirectCastExpression() - { - CastExpression ce = ParseUtil.ParseExpression("DirectCast(o, MyObject)"); - Assert.AreEqual("MyObject", ce.CastTo.Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.Cast, ce.CastType); - } - - [Test] - public void VBNetGenericDirectCastExpression() - { - CastExpression ce = ParseUtil.ParseExpression("DirectCast(o, List(of T))"); - Assert.AreEqual("List", ce.CastTo.Type); - Assert.AreEqual("T", ce.CastTo.GenericTypes[0].Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.Cast, ce.CastType); - } - - [Test] - public void VBNetSimpleTryCastExpression() - { - CastExpression ce = ParseUtil.ParseExpression("TryCast(o, MyObject)"); - Assert.AreEqual("MyObject", ce.CastTo.Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.TryCast, ce.CastType); - } - - [Test] - public void VBNetGenericTryCastExpression() - { - CastExpression ce = ParseUtil.ParseExpression("TryCast(o, List(of T))"); - Assert.AreEqual("List", ce.CastTo.Type); - Assert.AreEqual("T", ce.CastTo.GenericTypes[0].Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - Assert.AreEqual(CastType.TryCast, ce.CastType); - } - - [Test] - public void VBNetSpecializedBoolCastExpression() - { - TestSpecializedCast("CBool(o)", typeof(System.Boolean)); - } - - [Test] - public void VBNetSpecializedCharCastExpression() - { - TestSpecializedCast("CChar(o)", typeof(System.Char)); - } - - - [Test] - public void VBNetSpecializedStringCastExpression() - { - TestSpecializedCast("CStr(o)", typeof(System.String)); - } - - [Test] - public void VBNetSpecializedDateTimeCastExpression() - { - TestSpecializedCast("CDate(o)", typeof(System.DateTime)); - } - - [Test] - public void VBNetSpecializedDecimalCastExpression() - { - TestSpecializedCast("CDec(o)", typeof(System.Decimal)); - } - - [Test] - public void VBNetSpecializedSingleCastExpression() - { - TestSpecializedCast("CSng(o)", typeof(System.Single)); - } - - [Test] - public void VBNetSpecializedDoubleCastExpression() - { - TestSpecializedCast("CDbl(o)", typeof(System.Double)); - } - - [Test] - public void VBNetSpecializedByteCastExpression() - { - TestSpecializedCast("CByte(o)", typeof(System.Byte)); - } - - [Test] - public void VBNetSpecializedInt16CastExpression() - { - TestSpecializedCast("CShort(o)", typeof(System.Int16)); - } - - [Test] - public void VBNetSpecializedInt32CastExpression() - { - TestSpecializedCast("CInt(o)", typeof(System.Int32)); - } - - [Test] - public void VBNetSpecializedInt64CastExpression() - { - TestSpecializedCast("CLng(o)", typeof(System.Int64)); - } - - [Test] - public void VBNetSpecializedSByteCastExpression() - { - TestSpecializedCast("CSByte(o)", typeof(System.SByte)); - } - - [Test] - public void VBNetSpecializedUInt16CastExpression() - { - TestSpecializedCast("CUShort(o)", typeof(System.UInt16)); - } - - [Test] - public void VBNetSpecializedUInt32CastExpression() - { - TestSpecializedCast("CUInt(o)", typeof(System.UInt32)); - } - - [Test] - public void VBNetSpecializedUInt64CastExpression() - { - TestSpecializedCast("CULng(o)", typeof(System.UInt64)); - } - - - [Test] - public void VBNetSpecializedObjectCastExpression() - { - TestSpecializedCast("CObj(o)", typeof(System.Object)); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs deleted file mode 100644 index b9b892956..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ClassReferenceExpressionTests.cs +++ /dev/null @@ -1,24 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ClassReferenceExpressionTests - { - #region VB.NET - [Test] - public void VBNetClassReferenceExpressionTest1() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("MyClass.myField"); - Assert.IsTrue(fre.TargetObject is ClassReferenceExpression); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs deleted file mode 100644 index 715d716f7..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ConditionalExpressionTests.cs +++ /dev/null @@ -1,29 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ConditionalExpressionTests - { - #region VB.NET - - [Test] - public void VBNetConditionalExpressionTest() - { - ConditionalExpression ce = ParseUtil.ParseExpression("If(x IsNot Nothing, x.Test, \"nothing\")"); - - Assert.IsTrue(ce.Condition is BinaryOperatorExpression); - Assert.IsTrue(ce.TrueExpression is MemberReferenceExpression); - Assert.IsTrue(ce.FalseExpression is PrimitiveExpression); - } - - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs deleted file mode 100644 index 54445299f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/GlobalReferenceExpressionTests.cs +++ /dev/null @@ -1,32 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class GlobalReferenceExpressionTests - { - [Test] - public void VBNetGlobalReferenceExpressionTest() - { - TypeReferenceExpression tre = ParseUtil.ParseExpression("Global.System"); - Assert.IsTrue(tre.TypeReference.IsGlobal); - Assert.AreEqual("System", tre.TypeReference.Type); - } - - [Test] - public void VBNetGlobalTypeDeclaration() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As Global.System.String"); - TypeReference typeRef = lvd.GetTypeForVariable(0); - Assert.IsTrue(typeRef.IsGlobal); - Assert.AreEqual("System.String", typeRef.Type); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs deleted file mode 100644 index 9c929a2e5..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/IdentifierExpressionTests.cs +++ /dev/null @@ -1,40 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class IdentifierExpressionTests - { - #region VB.NET - [Test] - public void VBNetIdentifierExpressionTest1() - { - IdentifierExpression ie = ParseUtil.ParseExpression("MyIdentifier"); - Assert.AreEqual("MyIdentifier", ie.Identifier); - } - - [Test] - public void VBNetIdentifierExpressionTest2() - { - IdentifierExpression ie = ParseUtil.ParseExpression("[Public]"); - Assert.AreEqual("Public", ie.Identifier); - } - - [Test] - public void VBNetContextKeywordsTest() - { - Assert.AreEqual("Assembly", ParseUtil.ParseExpression("Assembly").Identifier); - Assert.AreEqual("Custom", ParseUtil.ParseExpression("Custom").Identifier); - Assert.AreEqual("Off", ParseUtil.ParseExpression("Off").Identifier); - Assert.AreEqual("Explicit", ParseUtil.ParseExpression("Explicit").Identifier); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs deleted file mode 100644 index dcc4e731c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/InvocationExpressionTests.cs +++ /dev/null @@ -1,116 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class InvocationExpressionTests - { - void CheckSimpleInvoke(InvocationExpression ie) - { - Assert.AreEqual(0, ie.Arguments.Count); - Assert.IsTrue(ie.TargetObject is SimpleNameExpression); - Assert.AreEqual("myMethod", ((SimpleNameExpression)ie.TargetObject).Identifier); - } - - void CheckGenericInvoke(InvocationExpression expr) - { - Assert.AreEqual(1, expr.Arguments.Count); - Assert.IsTrue(expr.TargetObject is SimpleNameExpression); - SimpleNameExpression ident = (SimpleNameExpression)expr.TargetObject; - Assert.AreEqual("myMethod", ident.Identifier); - Assert.AreEqual(1, ident.TypeArguments.Count); - Assert.AreEqual("System.Char", ident.TypeArguments[0].Type); - } - - void CheckGenericInvoke2(InvocationExpression expr) - { - Assert.AreEqual(0, expr.Arguments.Count); - Assert.IsTrue(expr.TargetObject is SimpleNameExpression); - SimpleNameExpression ident = (SimpleNameExpression)expr.TargetObject; - Assert.AreEqual("myMethod", ident.Identifier); - Assert.AreEqual(2, ident.TypeArguments.Count); - Assert.AreEqual("T", ident.TypeArguments[0].Type); - Assert.IsFalse(ident.TypeArguments[0].IsKeyword); - Assert.AreEqual("System.Boolean", ident.TypeArguments[1].Type); - Assert.IsTrue(ident.TypeArguments[1].IsKeyword); - } - - #region VB.NET - [Test] - public void VBNetSimpleInvocationExpressionTest() - { - CheckSimpleInvoke(ParseUtil.ParseExpression("myMethod()")); - } - - [Test] - public void VBNetGenericInvocationExpressionTest() - { - CheckGenericInvoke(ParseUtil.ParseExpression("myMethod(Of Char)(\"a\"c)")); - } - - [Test] - public void VBNetGenericInvocation2ExpressionTest() - { - CheckGenericInvoke2(ParseUtil.ParseExpression("myMethod(Of T, Boolean)()")); - } - - [Test] - public void PrimitiveExpression1Test() - { - InvocationExpression ie = ParseUtil.ParseExpression("546.ToString()"); - Assert.AreEqual(0, ie.Arguments.Count); - } - - [Test] - public void VBInvocationOnGenericType() - { - InvocationExpression expr = ParseUtil.ParseExpression("A(Of T).Foo()"); - MemberReferenceExpression mre = (MemberReferenceExpression)expr.TargetObject; - Assert.AreEqual("Foo", mre.MemberName); - SimpleNameExpression tre = (SimpleNameExpression)mre.TargetObject; - Assert.AreEqual("A", tre.Identifier); - Assert.AreEqual("T", tre.TypeArguments[0].Type); - } - - [Test] - public void VBInvocationOnInnerClassInGenericType() - { - InvocationExpression expr = ParseUtil.ParseExpression("A(Of T).B.Foo()"); - MemberReferenceExpression mre = (MemberReferenceExpression)expr.TargetObject; - Assert.AreEqual("Foo", mre.MemberName); - MemberReferenceExpression mre2 = (MemberReferenceExpression)mre.TargetObject; - Assert.AreEqual("B", mre2.MemberName); - SimpleNameExpression tre = (SimpleNameExpression)mre2.TargetObject; - Assert.AreEqual("A", tre.Identifier); - Assert.AreEqual("T", tre.TypeArguments[0].Type); - } - - [Test] - public void VBInvocationOnGenericInnerClassInGenericType() - { - InvocationExpression expr = ParseUtil.ParseExpression("A(Of T).B.C(Of U).Foo()"); - MemberReferenceExpression mre = (MemberReferenceExpression)expr.TargetObject; - Assert.AreEqual("Foo", mre.MemberName); - - MemberReferenceExpression mre2 = (MemberReferenceExpression)mre.TargetObject; - Assert.AreEqual("C", mre2.MemberName); - Assert.AreEqual("U", mre2.TypeArguments[0].Type); - - MemberReferenceExpression mre3 = (MemberReferenceExpression)mre2.TargetObject; - Assert.AreEqual("B", mre3.MemberName); - - SimpleNameExpression tre = (SimpleNameExpression)mre3.TargetObject; - Assert.AreEqual("A", tre.Identifier); - Assert.AreEqual("T", tre.TypeArguments[0].Type); - } - - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs deleted file mode 100644 index b88297f04..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/LambdaExpressionTests.cs +++ /dev/null @@ -1,137 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class LambdaExpressionTests - { - static LambdaExpression Parse(string program) - { - return ParseUtil.ParseExpression(program); - } - - [Test] - public void LambdaWithParameters() - { - LambdaExpression e = Parse("Function(x As Boolean) x Or True"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.AreEqual("x", e.Parameters[0].ParameterName); - Assert.AreEqual("System.Boolean", e.Parameters[0].TypeReference.Type); - Assert.IsTrue(e.ExpressionBody is BinaryOperatorExpression); - Assert.IsTrue(e.ReturnType.IsNull); - } - - [Test] - public void LambdaWithoutParameters() - { - LambdaExpression e = Parse("Function() x Or True"); - Assert.AreEqual(0, e.Parameters.Count); - Assert.IsTrue(e.ExpressionBody is BinaryOperatorExpression); - Assert.IsTrue(e.ReturnType.IsNull, "ReturnType"); - } - - [Test] - public void NestedLambda() - { - LambdaExpression e = Parse("Function(x As Boolean) Function(y As Boolean) x And y"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.IsTrue(e.ExpressionBody is LambdaExpression); - Assert.IsTrue(e.ReturnType.IsNull, "ReturnType"); - } - - [Test] - public void SubLambda() - { - LambdaExpression e = Parse("Sub(x As Integer) Console.WriteLine(x)"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.IsTrue(e.StatementBody is ExpressionStatement); - Assert.IsNotNull(e.ReturnType); - Assert.AreEqual("System.Void", e.ReturnType.Type); - Assert.IsTrue(e.ReturnType.IsKeyword); - } - - [Test] - public void SubWithStatementLambda() - { - LambdaExpression e = Parse("Sub(x As Integer) Call Console.WriteLine(x)"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.IsTrue(e.StatementBody is ExpressionStatement); - Assert.IsNotNull(e.ReturnType); - Assert.AreEqual("System.Void", e.ReturnType.Type); - Assert.IsTrue(e.ReturnType.IsKeyword); - } - - [Test] - public void MultilineSubLambda() - { - LambdaExpression e = Parse("Sub(x As Integer)\n" + - " For i As Integer = 0 To x\n" + - " Console.WriteLine(i)\n" + - " Next\n" + - "End Sub"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.IsTrue(e.StatementBody is BlockStatement); - Assert.IsNotNull(e.ReturnType); - Assert.AreEqual("System.Void", e.ReturnType.Type); - Assert.IsTrue(e.ReturnType.IsKeyword); - - BlockStatement b = e.StatementBody as BlockStatement; - - Assert.AreEqual(1, b.Children.Count); - Assert.IsTrue(b.Children[0] is ForNextStatement); - } - - [Test] - public void MultilineFunctionLambda() - { - LambdaExpression e = Parse("Function(x As Integer)\n" + - " Dim prod As Integer = 1\n" + - " For i As Integer = 1 To x\n" + - " prod = prod * i\n" + - " Next\n" + - " Return prod\n" + - "End Function"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.IsTrue(e.StatementBody is BlockStatement); - Assert.IsTrue(e.ReturnType.IsNull); - - BlockStatement b = e.StatementBody as BlockStatement; - - Assert.AreEqual(3, b.Children.Count); - Assert.IsTrue(b.Children[0] is LocalVariableDeclaration); - Assert.IsTrue(b.Children[1] is ForNextStatement); - Assert.IsTrue(b.Children[2] is ReturnStatement); - } - - [Test] - public void MultilineFunctionWithReturnTypeLambda() - { - LambdaExpression e = Parse("Function(x As Integer) As Integer\n" + - " Dim prod As Integer = 1\n" + - " For i As Integer = 1 To x\n" + - " prod = prod * i\n" + - " Next\n" + - " Return prod\n" + - "End Function"); - Assert.AreEqual(1, e.Parameters.Count); - Assert.IsTrue(e.StatementBody is BlockStatement); - Assert.IsNotNull(e.ReturnType); - Assert.AreEqual("System.Int32", e.ReturnType.Type); - Assert.IsTrue(e.ReturnType.IsKeyword); - - BlockStatement b = e.StatementBody as BlockStatement; - - Assert.AreEqual(3, b.Children.Count); - Assert.IsTrue(b.Children[0] is LocalVariableDeclaration); - Assert.IsTrue(b.Children[1] is ForNextStatement); - Assert.IsTrue(b.Children[2] is ReturnStatement); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs deleted file mode 100644 index 94efda65b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/MemberReferenceExpressionTests.cs +++ /dev/null @@ -1,82 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class MemberReferenceExpressionTests - { - #region VB.NET - [Test] - public void VBNetSimpleFieldReferenceExpressionTest() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("myTargetObject.myField"); - Assert.AreEqual("myField", fre.MemberName); - Assert.IsTrue(fre.TargetObject is SimpleNameExpression); - Assert.AreEqual("myTargetObject", ((SimpleNameExpression)fre.TargetObject).Identifier); - } - - [Test] - public void VBNetFieldReferenceExpressionWithoutTargetTest() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression(".myField"); - Assert.AreEqual("myField", fre.MemberName); - Assert.IsTrue(fre.TargetObject.IsNull); - } - - [Test] - public void VBNetGenericFieldReferenceExpressionTest() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("SomeClass(of string).myField"); - Assert.AreEqual("myField", fre.MemberName); - Assert.IsInstanceOf(typeof(SimpleNameExpression), fre.TargetObject); - TypeReference tr = ((SimpleNameExpression)fre.TargetObject).TypeArguments[0]; - Assert.AreEqual("System.String", tr.Type); - } - - [Test] - public void VBNetFullNamespaceGenericFieldReferenceExpressionTest() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("System.Subnamespace.SomeClass(of string).myField"); - Assert.AreEqual("myField", fre.MemberName); - Assert.IsInstanceOf(typeof(MemberReferenceExpression), fre.TargetObject); - - MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject; - Assert.AreEqual("SomeClass", inner.MemberName); - Assert.AreEqual(1, inner.TypeArguments.Count); - Assert.AreEqual("System.String", inner.TypeArguments[0].Type); - } - - [Test] - public void VBNetGlobalFullNamespaceGenericFieldReferenceExpressionTest() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("Global.System.Subnamespace.SomeClass(of string).myField"); - Assert.AreEqual("myField", fre.MemberName); - Assert.IsInstanceOf(typeof(MemberReferenceExpression), fre.TargetObject); - MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject; - - Assert.AreEqual("SomeClass", inner.MemberName); - Assert.AreEqual(1, inner.TypeArguments.Count); - Assert.AreEqual("System.String", inner.TypeArguments[0].Type); - } - - [Test] - public void VBNetNestedGenericFieldReferenceExpressionTest() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("MyType(of string).InnerClass(of integer).myField"); - Assert.AreEqual("myField", fre.MemberName); - Assert.IsInstanceOf(typeof(MemberReferenceExpression), fre.TargetObject); - - MemberReferenceExpression inner = (MemberReferenceExpression)fre.TargetObject; - Assert.AreEqual("InnerClass", inner.MemberName); - } - - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs deleted file mode 100644 index 2b6a8f886..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ObjectCreateExpressionTests.cs +++ /dev/null @@ -1,114 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ObjectCreateExpressionTests - { - void CheckSimpleObjectCreateExpression(ObjectCreateExpression oce) - { - Assert.AreEqual("MyObject", oce.CreateType.Type); - Assert.AreEqual(3, oce.Parameters.Count); - Assert.IsTrue(oce.ObjectInitializer.IsNull); - - for (int i = 0; i < oce.Parameters.Count; ++i) { - Assert.IsTrue(oce.Parameters[i] is PrimitiveExpression); - } - } - - Expression CheckPropertyInitializationExpression(Expression e, string name) - { - Assert.IsInstanceOf(typeof(MemberInitializerExpression), e); - Assert.AreEqual(name, ((MemberInitializerExpression)e).Name); - return ((MemberInitializerExpression)e).Expression; - } - - [Test] - public void VBNetAnonymousType() - { - ObjectCreateExpression oce = ParseUtil.ParseExpression( - "New With {.Id = 1, .Name= \"Bill Gates\" }"); - - Assert.IsTrue(oce.CreateType.IsNull); - Assert.AreEqual(0, oce.Parameters.Count); - Assert.AreEqual(2, oce.ObjectInitializer.CreateExpressions.Count); - - Assert.IsInstanceOf(typeof(PrimitiveExpression), CheckPropertyInitializationExpression(oce.ObjectInitializer.CreateExpressions[0], "Id")); - Assert.IsInstanceOf(typeof(MemberInitializerExpression), oce.ObjectInitializer.CreateExpressions[1]); - } - - [Test] - public void VBNetAnonymousTypeWithoutProperty() - { - ObjectCreateExpression oce = ParseUtil.ParseExpression("New With { c }"); - - Assert.IsTrue(oce.CreateType.IsNull); - Assert.AreEqual(0, oce.Parameters.Count); - Assert.AreEqual(1, oce.ObjectInitializer.CreateExpressions.Count); - - Assert.IsInstanceOf(typeof(SimpleNameExpression), oce.ObjectInitializer.CreateExpressions[0]); - Assert.AreEqual("c", (oce.ObjectInitializer.CreateExpressions[0] as SimpleNameExpression).Identifier); - } - - [Test] - public void VBNetSimpleObjectCreateExpressionTest() - { - CheckSimpleObjectCreateExpression(ParseUtil.ParseExpression("New MyObject(1, 2, 3)")); - } - - [Test] - public void VBNetInvalidTypeArgumentListObjectCreateExpressionTest() - { - // this test was written because this bug caused the AbstractDomVisitor to crash - - InvocationExpression expr = ParseUtil.ParseExpression("WriteLine(New SomeGenericType(Of Integer, )())", true); - Assert.IsTrue(expr.TargetObject is SimpleNameExpression); - Assert.AreEqual("WriteLine", ((SimpleNameExpression)expr.TargetObject).Identifier); - Assert.AreEqual(1, expr.Arguments.Count); // here a second null parameter was added incorrectly - - Assert.IsTrue(expr.Arguments[0] is ObjectCreateExpression); - TypeReference typeRef = ((ObjectCreateExpression)expr.Arguments[0]).CreateType; - Assert.AreEqual("SomeGenericType", typeRef.Type); - Assert.AreEqual(1, typeRef.GenericTypes.Count); - Assert.AreEqual("System.Int32", typeRef.GenericTypes[0].Type); - } - - [Test] - public void VBNetMemberInitializationTest() - { - ObjectCreateExpression oce = ParseUtil.ParseExpression("new Contact() With { .FirstName = \"Bill\", .LastName = \"Gates\" }"); - Assert.AreEqual(2, oce.ObjectInitializer.CreateExpressions.Count); - - Assert.AreEqual("FirstName", ((MemberInitializerExpression)oce.ObjectInitializer.CreateExpressions[0]).Name); - Assert.AreEqual("LastName", ((MemberInitializerExpression)oce.ObjectInitializer.CreateExpressions[1]).Name); - - Assert.IsInstanceOf(typeof(PrimitiveExpression), ((MemberInitializerExpression)oce.ObjectInitializer.CreateExpressions[0]).Expression); - Assert.IsInstanceOf(typeof(PrimitiveExpression), ((MemberInitializerExpression)oce.ObjectInitializer.CreateExpressions[1]).Expression); - } - - [Test] - public void VBNetNullableObjectCreateExpressionTest() - { - ObjectCreateExpression oce = ParseUtil.ParseExpression("New Integer?"); - Assert.AreEqual("System.Nullable", oce.CreateType.Type); - Assert.AreEqual(1, oce.CreateType.GenericTypes.Count); - Assert.AreEqual("System.Int32", oce.CreateType.GenericTypes[0].Type); - } - - [Test] - public void VBNetNullableObjectArrayCreateExpressionTest() - { - ObjectCreateExpression oce = ParseUtil.ParseExpression("New Integer?()"); - Assert.AreEqual("System.Nullable", oce.CreateType.Type); - Assert.AreEqual(1, oce.CreateType.GenericTypes.Count); - Assert.AreEqual("System.Int32", oce.CreateType.GenericTypes[0].Type); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs deleted file mode 100644 index b3ed4f87a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ParenthesizedExpressionTest.cs +++ /dev/null @@ -1,26 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ParenthesizedExpressionTests - { - #region VB.NET - [Test] - public void VBNetPrimitiveParenthesizedExpression() - { - ParenthesizedExpression p = ParseUtil.ParseExpression("((1))"); - Assert.IsTrue(p.Expression is ParenthesizedExpression); - p = p.Expression as ParenthesizedExpression;; - Assert.IsTrue(p.Expression is PrimitiveExpression); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs deleted file mode 100644 index af197957f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/PrimitiveExpressionTests.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class PrimitiveExpressionTests - { - #region VB.NET - [Test] - public void PrimitiveExpression1Test() - { - InvocationExpression ie = ParseUtil.ParseExpression("546.ToString()"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs deleted file mode 100644 index 8d46f278e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/QueryExpressionTests.cs +++ /dev/null @@ -1,635 +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 System; -using System.IO; -using System.Linq; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class QueryExpressionTests - { - void RunTest(string expression, int expectedCount, Action constraint, params Type[] expectedTypes) - { - var expr = ParseUtil.ParseExpression(expression); - - Assert.AreEqual(expectedCount, expr.Clauses.Count); - - for (int i = 0; i < expectedTypes.Length; i++) { - Assert.IsTrue(expectedTypes[i] == expr.Clauses[i].GetType()); - } - - constraint(expr); - } - - [Test] - public void SimpleQueryTest() - { - RunTest("From o In db.Orders Select o.OrderID", 2, - expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var selectClause = expr.Clauses[1] as QueryExpressionSelectVBClause; - - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("o", var1.Identifier); - Assert.IsTrue(var1.Expression is MemberReferenceExpression); - var inExpr = var1.Expression as MemberReferenceExpression; - Assert.IsTrue(inExpr.MemberName == "Orders" && inExpr.TargetObject is IdentifierExpression && (inExpr.TargetObject as IdentifierExpression).Identifier == "db"); - - Assert.AreEqual(1, selectClause.Variables.Count); - Assert.IsTrue(selectClause.Variables[0].Expression is MemberReferenceExpression); - var member = selectClause.Variables[0].Expression as MemberReferenceExpression; - - Assert.IsTrue(member.MemberName == "OrderID" && member.TargetObject is IdentifierExpression && (member.TargetObject as IdentifierExpression).Identifier == "o"); - }, - typeof(QueryExpressionFromClause), typeof(QueryExpressionSelectVBClause) - ); - } - - [Test] - public void SkipTakeQueryTest() - { - RunTest("From o In db.Orders Select o.OrderID Skip 10 Take 5", 4, - expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var selectClause = expr.Clauses[1] as QueryExpressionSelectVBClause; - var skipClause = expr.Clauses[2] as QueryExpressionPartitionVBClause; - var takeClause = expr.Clauses[3] as QueryExpressionPartitionVBClause; - - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("o", var1.Identifier); - Assert.IsTrue(var1.Expression is MemberReferenceExpression); - var inExpr = var1.Expression as MemberReferenceExpression; - Assert.IsTrue(inExpr.MemberName == "Orders" && inExpr.TargetObject is IdentifierExpression && (inExpr.TargetObject as IdentifierExpression).Identifier == "db"); - - Assert.AreEqual(1, selectClause.Variables.Count); - Assert.IsTrue(selectClause.Variables[0].Expression is MemberReferenceExpression); - var member = selectClause.Variables[0].Expression as MemberReferenceExpression; - - Assert.IsTrue(member.MemberName == "OrderID" && member.TargetObject is IdentifierExpression && (member.TargetObject as IdentifierExpression).Identifier == "o"); - - Assert.AreEqual(QueryExpressionPartitionType.Skip, skipClause.PartitionType); - Assert.IsTrue(skipClause.Expression is PrimitiveExpression && - (skipClause.Expression as PrimitiveExpression).StringValue == "10"); - - Assert.AreEqual(QueryExpressionPartitionType.Take, takeClause.PartitionType); - Assert.IsTrue(takeClause.Expression is PrimitiveExpression && - (takeClause.Expression as PrimitiveExpression).StringValue == "5"); - }, - typeof(QueryExpressionFromClause), typeof(QueryExpressionSelectVBClause), - typeof(QueryExpressionPartitionVBClause), typeof(QueryExpressionPartitionVBClause) - ); - } - - [Test] - public void SkipWhileTakeWhileQueryTest() - { - RunTest("From o In db.Orders Select o.OrderID Skip While o.OrderId > 2 Take While o.OrderId < 5", 4, - expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var selectClause = expr.Clauses[1] as QueryExpressionSelectVBClause; - var skipClause = expr.Clauses[2] as QueryExpressionPartitionVBClause; - var takeClause = expr.Clauses[3] as QueryExpressionPartitionVBClause; - - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("o", var1.Identifier); - Assert.IsTrue(var1.Expression is MemberReferenceExpression); - var inExpr = var1.Expression as MemberReferenceExpression; - Assert.IsTrue(inExpr.MemberName == "Orders" && inExpr.TargetObject is IdentifierExpression && (inExpr.TargetObject as IdentifierExpression).Identifier == "db"); - - Assert.AreEqual(1, selectClause.Variables.Count); - Assert.IsTrue(selectClause.Variables[0].Expression is MemberReferenceExpression); - var member = selectClause.Variables[0].Expression as MemberReferenceExpression; - - Assert.IsTrue(member.MemberName == "OrderID" && member.TargetObject is IdentifierExpression && (member.TargetObject as IdentifierExpression).Identifier == "o"); - - Assert.AreEqual(QueryExpressionPartitionType.SkipWhile, skipClause.PartitionType); - Assert.IsTrue(skipClause.Expression is BinaryOperatorExpression); - - Assert.AreEqual(QueryExpressionPartitionType.TakeWhile, takeClause.PartitionType); - Assert.IsTrue(takeClause.Expression is BinaryOperatorExpression); - }, - typeof(QueryExpressionFromClause), typeof(QueryExpressionSelectVBClause), - typeof(QueryExpressionPartitionVBClause), typeof(QueryExpressionPartitionVBClause) - ); - } - - [Test] - public void MultipleValuesSelectTest() - { - RunTest(@"From i In list Select i, x2 = i^2", - 2, expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var selectClause = expr.Clauses[1] as QueryExpressionSelectVBClause; - - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("i", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression); - Assert.IsTrue((var1.Expression as IdentifierExpression).Identifier == "list"); - - Assert.AreEqual(2, selectClause.Variables.Count); - - var selectExpr1 = selectClause.Variables[0]; - var selectExpr2 = selectClause.Variables[1]; - - Assert.IsEmpty(selectExpr1.Identifier); - Assert.IsTrue(selectExpr1.Expression is IdentifierExpression && - (selectExpr1.Expression as IdentifierExpression).Identifier == "i"); - - Assert.AreEqual("x2", selectExpr2.Identifier); - Assert.IsTrue(selectExpr2.Type.IsNull); - Assert.IsTrue(selectExpr2.Expression is BinaryOperatorExpression); - - var binOp = selectExpr2.Expression as BinaryOperatorExpression; - - Assert.AreEqual(BinaryOperatorType.Power, binOp.Op); - Assert.IsTrue(binOp.Left is IdentifierExpression && (binOp.Left as IdentifierExpression).Identifier == "i"); - Assert.IsTrue(binOp.Right is PrimitiveExpression && (binOp.Right as PrimitiveExpression).StringValue == "2"); - }, - typeof(QueryExpressionFromClause), typeof(QueryExpressionSelectVBClause) - ); - } - - [Test] - public void GroupTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var groupClause = expr.Clauses[1] as QueryExpressionGroupVBClause; - var selectClause = expr.Clauses[2] as QueryExpressionSelectVBClause; - - Assert.AreEqual(1, fromClause.Sources.Count); - - var fromVar1 = fromClause.Sources.First(); - - Assert.AreEqual("p", fromVar1.Identifier); - Assert.IsTrue(fromVar1.Expression is IdentifierExpression); - Assert.IsTrue((fromVar1.Expression as IdentifierExpression).Identifier == "products"); - - Assert.AreEqual(1, groupClause.GroupVariables.Count); - Assert.AreEqual(1, groupClause.ByVariables.Count); - Assert.AreEqual(1, groupClause.IntoVariables.Count); - - var gv = groupClause.GroupVariables.First(); - var bv = groupClause.ByVariables.First(); - var iv = groupClause.IntoVariables.First(); - - Assert.IsTrue(gv.Expression is IdentifierExpression && (gv.Expression as IdentifierExpression).Identifier == "p"); - Assert.IsTrue(bv.Expression is MemberReferenceExpression && - (bv.Expression as MemberReferenceExpression).MemberName == "Category"); - Assert.IsTrue((bv.Expression as MemberReferenceExpression).TargetObject is IdentifierExpression && - ((bv.Expression as MemberReferenceExpression).TargetObject as IdentifierExpression).Identifier == "p"); - Assert.IsTrue(iv.Expression is IdentifierExpression && - (iv.Expression as IdentifierExpression).Identifier == "Group"); - - Assert.AreEqual(2, selectClause.Variables.Count); - - var var1 = selectClause.Variables.First(); - var var2 = selectClause.Variables.Skip(1).First(); - - Assert.IsTrue(var1.Expression is IdentifierExpression && - (var1.Expression as IdentifierExpression).Identifier == "Category"); - Assert.IsTrue(var2.Expression is InvocationExpression && - (var2.Expression as InvocationExpression).TargetObject is MemberReferenceExpression && - ((var2.Expression as InvocationExpression).TargetObject as MemberReferenceExpression).MemberName == "Average" && - ((var2.Expression as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject is IdentifierExpression && - (((var2.Expression as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject as IdentifierExpression).Identifier == "Group"); - }; - - RunTest(@"From p In products _ - Group p By p.Category Into Group _ - Select Category, AveragePrice = Group.Average(Function(p) p.UnitPrice)", 3, constraint, - typeof(QueryExpressionFromClause), typeof(QueryExpressionGroupVBClause), typeof(QueryExpressionSelectVBClause)); - } - - [Test] - public void LetTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var groupClause = expr.Clauses[1] as QueryExpressionGroupVBClause; - var letClause = expr.Clauses[2] as QueryExpressionLetClause; - var selectClause = expr.Clauses[3] as QueryExpressionSelectVBClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var fromVar1 = fromClause.Sources.First(); - - Assert.AreEqual("p", fromVar1.Identifier); - Assert.IsTrue(fromVar1.Expression is IdentifierExpression); - Assert.IsTrue((fromVar1.Expression as IdentifierExpression).Identifier == "products"); - - // Group By Into - Assert.AreEqual(1, groupClause.GroupVariables.Count); - Assert.AreEqual(1, groupClause.ByVariables.Count); - Assert.AreEqual(1, groupClause.IntoVariables.Count); - - var gv = groupClause.GroupVariables.First(); - var bv = groupClause.ByVariables.First(); - var iv = groupClause.IntoVariables.First(); - - Assert.IsTrue(gv.Expression is IdentifierExpression && (gv.Expression as IdentifierExpression).Identifier == "p"); - CheckMemberReferenceExpression(bv.Expression, "Category", "p"); - Assert.IsTrue(iv.Expression is IdentifierExpression && - (iv.Expression as IdentifierExpression).Identifier == "Group"); - - // Let - Assert.AreEqual(1, letClause.Variables.Count); - - var letVariable = letClause.Variables.First(); - - Assert.AreEqual("minPrice", letVariable.Identifier); - Assert.IsTrue(letVariable.Expression is InvocationExpression); - CheckMemberReferenceExpression((letVariable.Expression as InvocationExpression).TargetObject, "Min", "Group"); - - // Select - Assert.AreEqual(2, selectClause.Variables.Count); - - var var1 = selectClause.Variables.First(); - var var2 = selectClause.Variables.Skip(1).First(); - - Assert.IsTrue(var1.Expression is IdentifierExpression && - (var1.Expression as IdentifierExpression).Identifier == "Category"); - Assert.IsTrue(var2.Expression is InvocationExpression); - CheckMemberReferenceExpression((var2.Expression as InvocationExpression).TargetObject, "Where", "Group"); - }; - - RunTest(@"From p In products _ - Group p By p.Category Into Group _ - Let minPrice = Group.Min(Function(p) p.UnitPrice) _ - Select Category, CheapestProducts = Group.Where(Function(p) p.UnitPrice = minPrice)", 4, constraint, - typeof(QueryExpressionFromClause), typeof(QueryExpressionGroupVBClause), typeof(QueryExpressionLetClause), typeof(QueryExpressionSelectVBClause)); - } - - [Test] - public void CrossJoinTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var joinClause = expr.Clauses[1] as QueryExpressionJoinVBClause; - var selectClause = expr.Clauses[2] as QueryExpressionSelectVBClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var fromVar1 = fromClause.Sources.First(); - - Assert.AreEqual("c", fromVar1.Identifier); - Assert.IsTrue(fromVar1.Expression is IdentifierExpression); - Assert.IsTrue((fromVar1.Expression as IdentifierExpression).Identifier == "categories"); - - // Join In On Equals - var inClause = joinClause.JoinVariable as CollectionRangeVariable; - - Assert.AreEqual("p", inClause.Identifier); - Assert.IsTrue(inClause.Expression is IdentifierExpression && - (inClause.Expression as IdentifierExpression).Identifier == "products"); - - Assert.IsTrue(joinClause.SubJoin.IsNull); - - Assert.AreEqual(1, joinClause.Conditions.Count); - - var condition1 = joinClause.Conditions.First(); - - Assert.IsTrue(condition1.LeftSide is IdentifierExpression && (condition1.LeftSide as IdentifierExpression).Identifier == "c"); - - CheckMemberReferenceExpression(condition1.RightSide, "Category", "p"); - - // Select - Assert.AreEqual(2, selectClause.Variables.Count); - - var var1 = selectClause.Variables.First(); - var var2 = selectClause.Variables.Skip(1).First(); - - Assert.AreEqual("Category", var1.Identifier); - Assert.IsEmpty(var2.Identifier); - - Assert.IsTrue(var1.Expression is IdentifierExpression && - (var1.Expression as IdentifierExpression).Identifier == "c"); - CheckMemberReferenceExpression(var2.Expression, "ProductName", "p"); - }; - - RunTest(@"From c In categories _ - Join p In products On c Equals p.Category _ - Select Category = c, p.ProductName", 3, constraint, - typeof(QueryExpressionFromClause), typeof(QueryExpressionJoinVBClause), typeof(QueryExpressionSelectVBClause)); - } - - [Test] - public void OrderByTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var orderClause = expr.Clauses[1] as QueryExpressionOrderClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("i", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression); - Assert.IsTrue((var1.Expression as IdentifierExpression).Identifier == "list"); - - // Order By - Assert.AreEqual(1, orderClause.Orderings.Count); - - var ordering1 = orderClause.Orderings.First(); - - Assert.IsTrue(ordering1.Criteria is IdentifierExpression && - (ordering1.Criteria as IdentifierExpression).Identifier == "i"); - Assert.AreEqual(QueryExpressionOrderingDirection.None, ordering1.Direction); - }; - - RunTest(@"From i In list Order By i", 2, constraint, typeof(QueryExpressionFromClause), typeof(QueryExpressionOrderClause)); - } - - [Test] - public void OrderByTest2() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var orderClause = expr.Clauses[1] as QueryExpressionOrderClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("i", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression); - Assert.IsTrue((var1.Expression as IdentifierExpression).Identifier == "list"); - - // Order By - Assert.AreEqual(1, orderClause.Orderings.Count); - - var ordering1 = orderClause.Orderings.First(); - - Assert.IsTrue(ordering1.Criteria is IdentifierExpression && - (ordering1.Criteria as IdentifierExpression).Identifier == "i"); - Assert.AreEqual(QueryExpressionOrderingDirection.Ascending, ordering1.Direction); - }; - - RunTest(@"From i In list Order By i Ascending", 2, constraint, typeof(QueryExpressionFromClause), typeof(QueryExpressionOrderClause)); - } - - [Test] - public void OrderByTest3() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var orderClause = expr.Clauses[1] as QueryExpressionOrderClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("i", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression); - Assert.IsTrue((var1.Expression as IdentifierExpression).Identifier == "list"); - - // Order By - Assert.AreEqual(1, orderClause.Orderings.Count); - - var ordering1 = orderClause.Orderings.First(); - - Assert.IsTrue(ordering1.Criteria is IdentifierExpression && - (ordering1.Criteria as IdentifierExpression).Identifier == "i"); - Assert.AreEqual(QueryExpressionOrderingDirection.Descending, ordering1.Direction); - }; - - RunTest(@"From i In list Order By i Descending", 2, constraint, typeof(QueryExpressionFromClause), typeof(QueryExpressionOrderClause)); - } - - [Test] - public void OrderByThenByTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var orderClause = expr.Clauses[1] as QueryExpressionOrderClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("d", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression); - Assert.IsTrue((var1.Expression as IdentifierExpression).Identifier == "digits"); - - // Order By - Assert.AreEqual(2, orderClause.Orderings.Count); - - var ordering1 = orderClause.Orderings.First(); - var ordering2 = orderClause.Orderings.Skip(1).First(); - - CheckMemberReferenceExpression(ordering1.Criteria, "Length", "d"); - - Assert.IsTrue(ordering2.Criteria is IdentifierExpression && - (ordering2.Criteria as IdentifierExpression).Identifier == "d"); - - Assert.AreEqual(QueryExpressionOrderingDirection.None, ordering1.Direction); - Assert.AreEqual(QueryExpressionOrderingDirection.None, ordering2.Direction); - - }; - - RunTest(@"From d In digits _ - Order By d.Length, d", 2, constraint, - typeof(QueryExpressionFromClause), typeof(QueryExpressionOrderClause)); - } - - [Test] - public void DistinctTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - - // From - Assert.AreEqual(1, fromClause.Sources.Count); - - var var1 = fromClause.Sources.First(); - - Assert.AreEqual("d", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression); - Assert.IsTrue((var1.Expression as IdentifierExpression).Identifier == "digits"); - }; - - RunTest(@"From d In digits Distinct", 2, constraint, - typeof(QueryExpressionFromClause), typeof(QueryExpressionDistinctClause)); - } - - [Test] - public void AggregateTest() - { - Action constraint = expr => { - var clause = expr.Clauses[0] as QueryExpressionAggregateClause; - - Assert.AreEqual("p", clause.Source.Identifier); - CheckMemberReferenceExpression(clause.Source.Expression, "GetProcesses", "Process"); - - Assert.AreEqual(1, clause.IntoVariables.Count); - - var into1 = clause.IntoVariables.First(); - - Assert.AreEqual("virtualMemory", into1.Identifier); - - Assert.IsTrue(into1.Expression is InvocationExpression && - (into1.Expression as InvocationExpression).TargetObject is IdentifierExpression && - ((into1.Expression as InvocationExpression).TargetObject as IdentifierExpression).Identifier == "Sum"); - Assert.AreEqual(1, (into1.Expression as InvocationExpression).Arguments.Count); - CheckMemberReferenceExpression((into1.Expression as InvocationExpression).Arguments.First(), "VirtualMemorySize64", "p"); - }; - - RunTest(@"Aggregate p In Process.GetProcesses _ - Into virtualMemory = Sum(p.VirtualMemorySize64)", 1, constraint, typeof(QueryExpressionAggregateClause)); - } - - [Test] - public void GroupJoinTest() - { - Action constraint = expr => { - var fromClause1 = expr.Clauses[0] as QueryExpressionFromClause; - var groupJoinClause = expr.Clauses[1] as QueryExpressionGroupJoinVBClause; - var fromClause2 = expr.Clauses[2] as QueryExpressionFromClause; - var selectClause = expr.Clauses[3] as QueryExpressionSelectVBClause; - - // From 1 - Assert.AreEqual(1, fromClause1.Sources.Count); - - var var1 = fromClause1.Sources.First(); - - Assert.AreEqual("s", var1.Identifier); - Assert.IsTrue(var1.Expression is IdentifierExpression && - (var1.Expression as IdentifierExpression).Identifier == "fileList"); - - // From 2 - Assert.AreEqual(1, fromClause2.Sources.Count); - - var var2 = fromClause2.Sources.First(); - - Assert.AreEqual("p", var2.Identifier); - Assert.IsTrue(var2.Expression is IdentifierExpression && - (var2.Expression as IdentifierExpression).Identifier == "Group"); - - // Select - Assert.AreEqual(1, selectClause.Variables.Count); - - var var3 = selectClause.Variables.First(); - - Assert.IsEmpty(var3.Identifier); - Assert.IsTrue(var3.Expression is IdentifierExpression && - (var3.Expression as IdentifierExpression).Identifier == "s"); - - // Group Join - var joinClause = groupJoinClause.JoinClause; - - // Join In On Equals - var inClause = joinClause.JoinVariable as CollectionRangeVariable; - - Assert.AreEqual("p", inClause.Identifier); - Assert.IsTrue(inClause.Expression is IdentifierExpression && - (inClause.Expression as IdentifierExpression).Identifier == "IMAGES"); - - Assert.IsTrue(joinClause.SubJoin.IsNull); - - Assert.AreEqual(1, joinClause.Conditions.Count); - - var condition1 = joinClause.Conditions.First(); - - Assert.IsTrue(condition1.LeftSide is InvocationExpression); - Assert.IsTrue((condition1.LeftSide as InvocationExpression).TargetObject is MemberReferenceExpression); - Assert.IsTrue(((condition1.LeftSide as InvocationExpression).TargetObject as MemberReferenceExpression).MemberName == "ToUpper"); - Assert.IsTrue(((condition1.LeftSide as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject is MemberReferenceExpression); - Assert.IsTrue((((condition1.LeftSide as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject as MemberReferenceExpression).MemberName == "Extension"); - Assert.IsTrue((((condition1.LeftSide as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject as MemberReferenceExpression).TargetObject is IdentifierExpression); - Assert.IsTrue(((((condition1.LeftSide as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject as MemberReferenceExpression).TargetObject as IdentifierExpression).Identifier == "s"); - - Assert.IsTrue(condition1.RightSide is InvocationExpression); - Assert.IsTrue((condition1.RightSide as InvocationExpression).TargetObject is MemberReferenceExpression); - Assert.IsTrue(((condition1.RightSide as InvocationExpression).TargetObject as MemberReferenceExpression).MemberName == "ToUpper"); - Assert.IsTrue(((condition1.RightSide as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject is IdentifierExpression); - Assert.IsTrue((((condition1.RightSide as InvocationExpression).TargetObject as MemberReferenceExpression).TargetObject as IdentifierExpression).Identifier == "p"); - }; - - RunTest(@"From s In fileList _ -Group Join p In IMAGES On s.Extension.ToUpper() Equals p.ToUpper() Into Group _ -From p In Group _ -Select s", 4, constraint, - typeof(QueryExpressionFromClause), typeof(QueryExpressionGroupJoinVBClause), typeof(QueryExpressionFromClause), typeof(QueryExpressionSelectVBClause)); - } - - [Test] - public void SelectManyTest() - { - Action constraint = expr => { - var fromClause = expr.Clauses[0] as QueryExpressionFromClause; - var whereClause = expr.Clauses[1] as QueryExpressionWhereClause; - var selectClause = expr.Clauses[2] as QueryExpressionSelectVBClause; - - // From - Assert.AreEqual(2, fromClause.Sources.Count); - - var fromVar1 = fromClause.Sources.First(); - var fromVar2 = fromClause.Sources.Skip(1).First(); - - Assert.AreEqual("c", fromVar1.Identifier); - Assert.IsTrue(fromVar1.Expression is IdentifierExpression); - Assert.IsTrue((fromVar1.Expression as IdentifierExpression).Identifier == "customers"); - - Assert.AreEqual("o", fromVar2.Identifier); - CheckMemberReferenceExpression(fromVar2.Expression, "Orders", "c"); - - // Where - Assert.IsTrue(whereClause.Condition is BinaryOperatorExpression); - Assert.IsTrue((whereClause.Condition as BinaryOperatorExpression).Op == BinaryOperatorType.LessThan); - CheckMemberReferenceExpression((whereClause.Condition as BinaryOperatorExpression).Left, "Total", "o"); - Assert.IsTrue((whereClause.Condition as BinaryOperatorExpression).Right is PrimitiveExpression); - Assert.IsTrue((double)((whereClause.Condition as BinaryOperatorExpression).Right as PrimitiveExpression).Value == 500.0); - - // Select - foreach (var v in selectClause.Variables) { - Assert.IsEmpty(v.Identifier); - } - - var var1 = selectClause.Variables.First(); - var var2 = selectClause.Variables.Skip(1).First(); - var var3 = selectClause.Variables.Skip(2).First(); - - CheckMemberReferenceExpression(var1.Expression, "CustomerID", "c"); - CheckMemberReferenceExpression(var2.Expression, "OrderID", "o"); - CheckMemberReferenceExpression(var3.Expression, "Total", "o"); - }; - - RunTest(@"From c In customers, o In c.Orders _ - Where o.Total < 500.0 _ - Select c.CustomerID, o.OrderID, o.Total", 3, constraint, typeof(QueryExpressionFromClause), typeof(QueryExpressionWhereClause), typeof(QueryExpressionSelectVBClause)); - } - - void CheckMemberReferenceExpression(Expression expr, string memberName, string targetObjectIdentifier) - { - Assert.IsTrue(expr is MemberReferenceExpression); - Assert.IsTrue((expr as MemberReferenceExpression).MemberName == memberName && - (expr as MemberReferenceExpression).TargetObject is IdentifierExpression && - ((expr as MemberReferenceExpression).TargetObject as IdentifierExpression).Identifier == targetObjectIdentifier); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs deleted file mode 100644 index 4762bbeb0..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/ThisReferenceExpressionTests.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ThisReferenceExpressionTests - { - #region VB.NET - [Test] - public void VBNetThisReferenceExpressionTest1() - { - ThisReferenceExpression ie = ParseUtil.ParseExpression("Me"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs deleted file mode 100644 index a86a722a8..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfExpressionTests.cs +++ /dev/null @@ -1,87 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class TypeOfExpressionTests - { - #region VB.NET - [Test] - public void VBSimpleTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(MyNamespace.N1.MyType)"); - Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type); - } - - - [Test] - public void VBGlobalTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(Global.System.Console)"); - Assert.AreEqual("System.Console", toe.TypeReference.Type); - } - - [Test] - public void VBPrimitiveTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(integer)"); - Assert.AreEqual("System.Int32", toe.TypeReference.Type); - } - - [Test] - public void VBVoidTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(void)"); - Assert.AreEqual("void", toe.TypeReference.Type); - } - - [Test] - public void VBArrayTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(MyType())"); - Assert.AreEqual("MyType", toe.TypeReference.Type); - Assert.AreEqual(new int[] {0}, toe.TypeReference.RankSpecifier); - } - - [Test] - public void VBGenericTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(MyNamespace.N1.MyType(Of string))"); - Assert.AreEqual("MyNamespace.N1.MyType", toe.TypeReference.Type); - Assert.AreEqual("System.String", toe.TypeReference.GenericTypes[0].Type); - } - - [Test] - public void VBUnboundTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(MyType(Of ,))"); - Assert.AreEqual("MyType", toe.TypeReference.Type); - Assert.IsTrue(toe.TypeReference.GenericTypes[0].IsNull); - Assert.IsTrue(toe.TypeReference.GenericTypes[1].IsNull); - } - - [Test] - public void VBNestedGenericTypeOfExpressionTest() - { - TypeOfExpression toe = ParseUtil.ParseExpression("GetType(MyType(Of string).InnerClass(of integer).InnerInnerClass)"); - InnerClassTypeReference ic = (InnerClassTypeReference)toe.TypeReference; - Assert.AreEqual("InnerInnerClass", ic.Type); - Assert.AreEqual(0, ic.GenericTypes.Count); - ic = (InnerClassTypeReference)ic.BaseType; - Assert.AreEqual("InnerClass", ic.Type); - Assert.AreEqual(1, ic.GenericTypes.Count); - Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type); - Assert.AreEqual("MyType", ic.BaseType.Type); - Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs deleted file mode 100644 index 46f7e959e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeOfIsExpressionTests.cs +++ /dev/null @@ -1,34 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class TypeOfIsExpressionTests - { - #region VB.NET - [Test] - public void VBNetSimpleTypeOfIsExpression() - { - TypeOfIsExpression ce = ParseUtil.ParseExpression("TypeOf o Is MyObject"); - Assert.AreEqual("MyObject", ce.TypeReference.Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - } - - [Test] - public void VBNetGenericTypeOfIsExpression() - { - TypeOfIsExpression ce = ParseUtil.ParseExpression("TypeOf o Is List(of T)"); - Assert.AreEqual("List", ce.TypeReference.Type); - Assert.AreEqual("T", ce.TypeReference.GenericTypes[0].Type); - Assert.IsTrue(ce.Expression is SimpleNameExpression); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs deleted file mode 100644 index c002b4b54..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/TypeReferenceExpressionTests.cs +++ /dev/null @@ -1,47 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class TypeReferenceExpressionTests - { - #region VB.NET - [Test] - public void VBIntReferenceExpression() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("inTeGer.MaxValue"); - Assert.AreEqual("MaxValue", fre.MemberName); - Assert.AreEqual("System.Int32", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); - } - - [Test] - public void VBStandaloneIntReferenceExpression() - { - TypeReferenceExpression tre = ParseUtil.ParseExpression("inTeGer"); - Assert.AreEqual("System.Int32", tre.TypeReference.Type); - } - - [Test] - public void VBObjectReferenceExpression() - { - MemberReferenceExpression fre = ParseUtil.ParseExpression("Object.ReferenceEquals"); - Assert.AreEqual("ReferenceEquals", fre.MemberName); - Assert.AreEqual("System.Object", ((TypeReferenceExpression)fre.TargetObject).TypeReference.Type); - } - - [Test] - public void VBStandaloneObjectReferenceExpression() - { - TypeReferenceExpression tre = ParseUtil.ParseExpression("obJect"); - Assert.AreEqual("System.Object", tre.TypeReference.Type); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs deleted file mode 100644 index b5100b2cd..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/UnaryOperatorExpressionTests.cs +++ /dev/null @@ -1,61 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class UnaryOperatorExpressionTests - { - #region VB.NET - void VBNetTestUnaryOperatorExpressionTest(string program, UnaryOperatorType op) - { - UnaryOperatorExpression uoe = ParseUtil.ParseExpression(program); - Assert.AreEqual(op, uoe.Op); - - Assert.IsTrue(uoe.Expression is SimpleNameExpression); - } - - [Test] - public void VBNetNotTest() - { - VBNetTestUnaryOperatorExpressionTest("Not a", UnaryOperatorType.Not); - } - - [Test] - public void VBNetInEqualsNotTest() - { - BinaryOperatorExpression e = ParseUtil.ParseExpression("b <> Not a"); - Assert.AreEqual(BinaryOperatorType.InEquality, e.Op); - UnaryOperatorExpression ue = (UnaryOperatorExpression)e.Right; - Assert.AreEqual(UnaryOperatorType.Not, ue.Op); - } - - [Test] - public void VBNetNotEqualTest() - { - UnaryOperatorExpression e = ParseUtil.ParseExpression("Not a = b"); - Assert.AreEqual(UnaryOperatorType.Not, e.Op); - BinaryOperatorExpression boe = (BinaryOperatorExpression)e.Expression; - Assert.AreEqual(BinaryOperatorType.Equality, boe.Op); - } - - [Test] - public void VBNetPlusTest() - { - VBNetTestUnaryOperatorExpressionTest("+a", UnaryOperatorType.Plus); - } - - [Test] - public void VBNetMinusTest() - { - VBNetTestUnaryOperatorExpressionTest("-a", UnaryOperatorType.Minus); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs deleted file mode 100644 index e36b43b0d..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlExpressionTests.cs +++ /dev/null @@ -1,255 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class XmlExpressionTests - { - #region VB.NET - [Test] - public void VBNetSimpleCommentTest() - { - XmlContentExpression content = ParseUtil.ParseExpression(""); - Assert.AreEqual(XmlContentType.Comment, content.Type); - Assert.AreEqual(" test ", content.Content); - Assert.AreEqual(new Location(1,1), content.StartLocation); - Assert.AreEqual(new Location(14,1), content.EndLocation); - } - - [Test] - public void VBNetSimplePreprocessingInstructionTest() - { - XmlContentExpression content = ParseUtil.ParseExpression(""); - Assert.AreEqual(XmlContentType.ProcessingInstruction, content.Type); - Assert.AreEqual("xml version='1.0'", content.Content); - Assert.AreEqual(new Location(1,1), content.StartLocation); - Assert.AreEqual(new Location(22,1), content.EndLocation); - } - - [Test] - public void VBNetSimpleCDataTest() - { - XmlContentExpression content = ParseUtil.ParseExpression(" ]]>"); - Assert.AreEqual(XmlContentType.CData, content.Type); - Assert.AreEqual(" ", content.Content); - Assert.AreEqual(new Location(1,1), content.StartLocation); - Assert.AreEqual(new Location(29,1), content.EndLocation); - } - - [Test] - public void VBNetSimpleEmptyElementTest() - { - XmlElementExpression element = ParseUtil.ParseExpression(""); - Assert.IsFalse(element.NameIsExpression); - Assert.AreEqual("Test", element.XmlName); - Assert.IsEmpty(element.Attributes); - Assert.IsEmpty(element.Children); - Assert.AreEqual(new Location(1,1), element.StartLocation); - Assert.AreEqual(new Location(9,1), element.EndLocation); - } - - [Test] - public void VBNetSimpleEmptyElementWithAttributeTest() - { - XmlElementExpression element = ParseUtil.ParseExpression(""); - Assert.IsFalse(element.NameIsExpression); - Assert.AreEqual("Test", element.XmlName); - Assert.IsNotEmpty(element.Attributes); - Assert.AreEqual(1, element.Attributes.Count); - Assert.IsTrue(element.Attributes[0] is XmlAttributeExpression); - XmlAttributeExpression attribute = element.Attributes[0] as XmlAttributeExpression; - Assert.AreEqual("id", attribute.Name); - Assert.IsTrue(attribute.IsLiteralValue); - Assert.IsTrue(attribute.ExpressionValue.IsNull); - Assert.AreEqual("0", attribute.LiteralValue); - Assert.AreEqual(new Location(7,1), attribute.StartLocation); - Assert.AreEqual(new Location(13,1), attribute.EndLocation); - Assert.IsEmpty(element.Children); - Assert.AreEqual(new Location(1,1), element.StartLocation); - Assert.AreEqual(new Location(16,1), element.EndLocation); - } - - [Test] - public void VBNetSimpleEmptyElementWithAttributesTest() - { - XmlElementExpression element = ParseUtil.ParseExpression(" <%= contentData %> />"); Assert.IsFalse(element.NameIsExpression); - Assert.AreEqual("Test", element.XmlName); - Assert.IsNotEmpty(element.Attributes); - Assert.AreEqual(3, element.Attributes.Count); - - Assert.IsTrue(element.Attributes[0] is XmlAttributeExpression); - XmlAttributeExpression attribute = element.Attributes[0] as XmlAttributeExpression; - Assert.AreEqual("id", attribute.Name); - Assert.IsTrue(attribute.IsLiteralValue); - Assert.IsTrue(attribute.ExpressionValue.IsNull); - Assert.AreEqual("0", attribute.LiteralValue); - Assert.AreEqual(new Location(7,1), attribute.StartLocation); - Assert.AreEqual(new Location(13,1), attribute.EndLocation); - - Assert.IsTrue(element.Attributes[1] is XmlAttributeExpression); - XmlAttributeExpression attribute2 = element.Attributes[1] as XmlAttributeExpression; - Assert.AreEqual("name", attribute2.Name); - Assert.IsFalse(attribute2.IsLiteralValue); - Assert.IsFalse(attribute2.ExpressionValue.IsNull); - - Assert.IsTrue(attribute2.ExpressionValue is IdentifierExpression); - IdentifierExpression identifier = attribute2.ExpressionValue as IdentifierExpression; - Assert.AreEqual("name", identifier.Identifier); - Assert.AreEqual(new Location(23,1), identifier.StartLocation); - Assert.AreEqual(new Location(27,1), identifier.EndLocation); - - Assert.AreEqual(new Location(14,1), attribute2.StartLocation); - Assert.AreEqual(new Location(30,1), attribute2.EndLocation); - - Assert.IsTrue(element.Attributes[2] is XmlEmbeddedExpression); - XmlEmbeddedExpression attribute3 = element.Attributes[2] as XmlEmbeddedExpression; - - Assert.IsTrue(attribute3.InlineVBExpression is IdentifierExpression); - IdentifierExpression identifier2 = attribute3.InlineVBExpression as IdentifierExpression; - - Assert.AreEqual("contentData", identifier2.Identifier); - Assert.AreEqual(new Location(35,1), identifier2.StartLocation); - Assert.AreEqual(new Location(46,1), identifier2.EndLocation); - - Assert.AreEqual(new Location(31,1), attribute3.StartLocation); - Assert.AreEqual(new Location(49,1), attribute3.EndLocation); - - Assert.IsEmpty(element.Children); - Assert.AreEqual(new Location(1,1), element.StartLocation); - Assert.AreEqual(new Location(52,1), element.EndLocation); - } - - [Test] - public void VBNetElementWithAttributeTest() - { - XmlElementExpression element = ParseUtil.ParseExpression("\n" + - " \n" + - " \n" + - ""); - Assert.IsFalse(element.NameIsExpression); - Assert.AreEqual("Test", element.XmlName); - - Assert.IsNotEmpty(element.Attributes); - Assert.AreEqual(1, element.Attributes.Count); - Assert.IsTrue(element.Attributes[0] is XmlAttributeExpression); - XmlAttributeExpression attribute = element.Attributes[0] as XmlAttributeExpression; - Assert.AreEqual("id", attribute.Name); - Assert.IsTrue(attribute.IsLiteralValue); - Assert.IsTrue(attribute.ExpressionValue.IsNull); - Assert.AreEqual("0", attribute.LiteralValue); - Assert.AreEqual(new Location(7,1), attribute.StartLocation); - Assert.AreEqual(new Location(13,1), attribute.EndLocation); - - Assert.IsNotEmpty(element.Children); - Assert.AreEqual(5, element.Children.Count); - - CheckContent(element.Children[0], "\n\t", XmlContentType.Text, new Location(14,1), new Location(2,2)); - CheckContent(element.Children[2], "\n\t", XmlContentType.Text, new Location(10,2), new Location(2,3)); - CheckContent(element.Children[4], "\n", XmlContentType.Text, new Location(10,3), new Location(1,4)); - - CheckElement(element.Children[1], "Item", new Location(2,2), new Location(10,2)); - CheckElement(element.Children[3], "Item", new Location(2,3), new Location(10,3)); - - Assert.AreEqual(new Location(1,1), element.StartLocation); - Assert.AreEqual(new Location(8,4), element.EndLocation); - } - - [Test] - public void VBNetElementWithMixedContentTest() - { - XmlElementExpression element = ParseUtil.ParseExpression("\n" + - " \n" + - " \n" + - " \n" + - " section]]>\n" + - ""); - Assert.IsFalse(element.NameIsExpression); - Assert.AreEqual("Test", element.XmlName); - - Assert.IsNotEmpty(element.Attributes); - Assert.AreEqual(1, element.Attributes.Count); - Assert.IsTrue(element.Attributes[0] is XmlAttributeExpression); - XmlAttributeExpression attribute = element.Attributes[0] as XmlAttributeExpression; - Assert.AreEqual("id", attribute.Name); - Assert.IsTrue(attribute.IsLiteralValue); - Assert.IsTrue(attribute.ExpressionValue.IsNull); - Assert.AreEqual("0", attribute.LiteralValue); - Assert.AreEqual(new Location(7,1), attribute.StartLocation); - Assert.AreEqual(new Location(13,1), attribute.EndLocation); - - Assert.IsNotEmpty(element.Children); - Assert.AreEqual(9, element.Children.Count); - - CheckContent(element.Children[0], "\n\t", XmlContentType.Text, new Location(14,1), new Location(2,2)); - CheckContent(element.Children[2], "\n\t", XmlContentType.Text, new Location(15,2), new Location(2,3)); - CheckContent(element.Children[4], "\n\t", XmlContentType.Text, new Location(10,3), new Location(2,4)); - CheckContent(element.Children[6], "\n\t", XmlContentType.Text, new Location(10,4), new Location(2,5)); - CheckContent(element.Children[7], " section", XmlContentType.CData, new Location(2,5), new Location(29,5)); - CheckContent(element.Children[8], "\n", XmlContentType.Text, new Location(29,5), new Location(1,6)); - - CheckContent(element.Children[1], " test ", XmlContentType.Comment, new Location(2,2), new Location(15,2)); - CheckElement(element.Children[3], "Item", new Location(2,3), new Location(10,3)); - CheckElement(element.Children[5], "Item", new Location(2,4), new Location(10,4)); - - Assert.AreEqual(new Location(1,1), element.StartLocation); - Assert.AreEqual(new Location(8,6), element.EndLocation); - } - - [Test] - public void VBNetElementWithMixedContentTest2() - { - XmlElementExpression element = ParseUtil.ParseExpression(" aaaa "); - Assert.IsFalse(element.NameIsExpression); - Assert.AreEqual("Test", element.XmlName); - - Assert.IsNotEmpty(element.Children); - Assert.AreEqual(1, element.Children.Count); - - CheckContent(element.Children[0], " aaaa ", XmlContentType.Text, new Location(7,1), new Location(14,1)); - } - - [Test] - public void VBNetProcessingInstructionAndCommentAtEndTest() - { - XmlDocumentExpression document = ParseUtil.ParseExpression("\n" + - "\n" + - ""); - Assert.IsNotEmpty(document.Expressions); - Assert.AreEqual(3, document.Expressions.Count); - - CheckElement(document.Expressions[0], "Test", new Location(1,1), new Location(9,1)); - CheckContent(document.Expressions[1], " test ", XmlContentType.Comment, new Location(1,2), new Location(14,2)); - CheckContent(document.Expressions[2], "target some text", XmlContentType.ProcessingInstruction, new Location(1,3), new Location(21,3)); - } - #endregion - - void CheckElement(AstNode node, string name, AstLocation start, AstLocation end) - { - Assert.IsTrue(node is XmlElementExpression); - XmlElementExpression expr = node as XmlElementExpression; - Assert.IsEmpty(expr.Attributes); - Assert.IsEmpty(expr.Children); - Assert.IsFalse(expr.NameIsExpression); - Assert.AreEqual(name, expr.XmlName); - Assert.AreEqual(start, expr.StartLocation); - Assert.AreEqual(end, expr.EndLocation); - } - - void CheckContent(AstNode node, string content, XmlContentType type, AstLocation start, AstLocation end) - { - Assert.IsTrue(node is XmlContentExpression); - XmlContentExpression expr = node as XmlContentExpression; - Assert.AreEqual(type, expr.Type); - Assert.AreEqual(content, expr.Content); - Assert.AreEqual(start, expr.StartLocation); - Assert.AreEqual(end, expr.EndLocation); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs deleted file mode 100644 index 23f39194b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Expressions/XmlMemberAccessExpressionTests.cs +++ /dev/null @@ -1,101 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class XmlMemberAccessExpressionTests - { - #region VB.NET - [Test] - public void VBNetSimpleElementReferenceTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression("xml."); - Assert.AreEqual("ns:MyElement", xmae.Identifier); - Assert.IsTrue(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Element, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject is IdentifierExpression); - Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier); - } - - [Test] - public void VBNetSimpleAttributeReferenceTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression("xml.@attribute"); - Assert.AreEqual("attribute", xmae.Identifier); - Assert.IsFalse(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject is IdentifierExpression); - Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier); - } - - [Test] - public void VBNetXmlNameAttributeReferenceTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression("xml.@"); - Assert.AreEqual("ns:attribute", xmae.Identifier); - Assert.IsTrue(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject is IdentifierExpression); - Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier); - } - - [Test] - public void VBNetSimpleDescendentsReferenceTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression("xml..."); - Assert.AreEqual("ns:Element", xmae.Identifier); - Assert.IsTrue(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Descendents, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject is IdentifierExpression); - Assert.AreEqual("xml", ((IdentifierExpression)xmae.TargetObject).Identifier); - } - - [Test] - public void VBNetSimpleElementReferenceWithDotTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression("."); - Assert.AreEqual("ns:MyElement", xmae.Identifier); - Assert.IsTrue(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Element, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject.IsNull); - } - - [Test] - public void VBNetSimpleAttributeReferenceWithDotTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression(".@attribute"); - Assert.AreEqual("attribute", xmae.Identifier); - Assert.IsFalse(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject.IsNull); - } - - [Test] - public void VBNetXmlNameAttributeReferenceWithDotTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression(".@"); - Assert.AreEqual("ns:attribute", xmae.Identifier); - Assert.IsTrue(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Attribute, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject.IsNull); - } - - [Test] - public void VBNetSimpleDescendentsReferenceWithDotTest() - { - XmlMemberAccessExpression xmae = ParseUtil.ParseExpression("..."); - Assert.AreEqual("ns:Element", xmae.Identifier); - Assert.IsTrue(xmae.IsXmlIdentifier); - Assert.AreEqual(XmlAxisType.Descendents, xmae.AxisType); - Assert.IsTrue(xmae.TargetObject.IsNull); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs deleted file mode 100644 index 997e2dc11..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/AttributeSectionTests.cs +++ /dev/null @@ -1,74 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class AttributeSectionTests - { -// [Test] -// public void AttributeOnStructure() -// { -// string program = @" -// _ -//Public Structure MyUnion -// -// Public i As Integer -// < FieldOffset( 0 )> Public d As Double -// -//End Structure 'MyUnion -//"; -// TypeDeclaration decl = ParseUtil.ParseGlobal(program); -// Assert.AreEqual("StructLayout", decl.Attributes[0].Attributes[0].Type); -// } -// -// [Test] -// public void AttributeOnModule() -// { -// string program = @" -// _ -//Public Module MyExtra -// -// Public i As Integer -// Public d As Double -// -//End Module -//"; -// TypeDeclaration decl = ParseUtil.ParseGlobal(program); -// Assert.AreEqual("HideModule", decl.Attributes[0].Attributes[0].Type); -// } -// -// [Test] -// public void GlobalAttribute() -// { -// string program = @" _ -//Public Class Form1 -// -//End Class"; -// TypeDeclaration decl = ParseUtil.ParseGlobal(program); -// Assert.AreEqual("Microsoft.VisualBasic.CompilerServices.DesignerGenerated", decl.Attributes[0].Attributes[0].Type); -// } -// -// [Test] -// public void AssemblyAttribute() -// { -// string program = @""; -// AttributeSection decl = ParseUtil.ParseGlobal(program); -// Assert.AreEqual(new Location(1, 1), decl.StartLocation); -// Assert.AreEqual("assembly", decl.AttributeTarget); -// } -// -// [Test] -// public void ModuleAttributeTargetEscaped() -// { -// // check that this doesn't crash the parser: -// ParseUtil.ParseGlobal("<[Module]: SuppressMessageAttribute>", true); -// } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs deleted file mode 100644 index 1067561e3..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/ImportsStatementTests.cs +++ /dev/null @@ -1,170 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ImportsStatementTests - { - [Test] - public void InvalidImportsStatement() - { - string program = "Imports\n"; - ParseUtil.ParseGlobal(program, true); - } - - [Test] - public void InvalidImportsStatement2() - { - string program = "Imports ,\n"; - ParseUtil.ParseGlobal(program, true); - } - - [Test] - [Ignore("Collection pattern matching is not implemented")] - public void SimpleImportsStatement() - { - string program = "Imports System\n"; - - var clause1 = new MemberImportsClause { - Member = new SimpleType("System") - }; - - var node = new ImportsStatement(); - node.AddChild(clause1, ImportsStatement.ImportsClauseRole); - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - [Ignore("Collection pattern matching is not implemented")] - public void QualifiedTypeImportsStatement() - { - string program = "Imports My.Name.Space\n"; - - var clause2 = new MemberImportsClause { - Member = new QualifiedType(new QualifiedType(new SimpleType("My"), new Identifier ("Name", TextLocation.Empty)), new Identifier ("Space", TextLocation.Empty)) - }; - - var node = new ImportsStatement(); - node.AddChild(clause2, ImportsStatement.ImportsClauseRole); - - ParseUtil.AssertGlobal(program, node); - } -// -// [Test] -// public void VBNetUsingAliasDeclarationTest() -// { -// string program = "Imports TESTME=System\n" + -// "Imports myAlias=My.Name.Space\n" + -// "Imports StringCollection = System.Collections.Generic.List(Of string)\n"; -// VBParser parser = ParserFactory.CreateParser(new StringReader(program)); -// parser.Parse(); -// -// Assert.AreEqual("", parser.Errors.ErrorOutput); -// CheckAliases(parser.CompilationUnit); -// } -// -// [Test] -// public void VBNetComplexUsingAliasDeclarationTest() -// { -// string program = "Imports NS1, AL=NS2, NS3, AL2=NS4, NS5\n"; -// VBParser parser = ParserFactory.CreateParser(new StringReader(program)); -// parser.Parse(); -// -// Assert.AreEqual("", parser.Errors.ErrorOutput); -// // TODO : Extend test ... -// } -// -// [Test] -// public void VBNetXmlNamespaceUsingTest() -// { -// string program = "Imports "; -// VBParser parser = ParserFactory.CreateParser(new StringReader(program)); -// parser.Parse(); -// -// Assert.AreEqual("", parser.Errors.ErrorOutput); -// CompilationUnit unit = parser.CompilationUnit; -// -// Assert.AreEqual(1, unit.Children.Count); -// Assert.IsTrue(unit.Children[0] is ImportsStatement); -// ImportsStatement ud = (ImportsStatement)unit.Children[0]; -// Assert.AreEqual(1, ud.ImportsClauses.Count); -// Assert.IsFalse(ud.ImportsClauses[0].IsAlias); -// Assert.IsTrue(ud.ImportsClauses[0].IsXml); -// -// Assert.AreEqual("xmlns", ud.ImportsClauses[0].XmlPrefix); -// Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.ImportsClauses[0].Name); -// } -// -// [Test] -// public void VBNetXmlNamespaceWithPrefixUsingTest() -// { -// string program = "Imports "; -// VBParser parser = ParserFactory.CreateParser(new StringReader(program)); -// parser.Parse(); -// -// Assert.AreEqual("", parser.Errors.ErrorOutput); -// CompilationUnit unit = parser.CompilationUnit; -// -// Assert.AreEqual(1, unit.Children.Count); -// Assert.IsTrue(unit.Children[0] is ImportsStatement); -// ImportsStatement ud = (ImportsStatement)unit.Children[0]; -// Assert.AreEqual(1, ud.ImportsClauses.Count); -// Assert.IsFalse(ud.ImportsClauses[0].IsAlias); -// Assert.IsTrue(ud.ImportsClauses[0].IsXml); -// -// Assert.AreEqual("xmlns:avalonedit", ud.ImportsClauses[0].XmlPrefix); -// Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.ImportsClauses[0].Name); -// } -// -// [Test] -// public void VBNetXmlNamespaceSingleQuotedUsingTest() -// { -// string program = "Imports "; -// VBParser parser = ParserFactory.CreateParser(new StringReader(program)); -// parser.Parse(); -// -// Assert.AreEqual("", parser.Errors.ErrorOutput); -// CompilationUnit unit = parser.CompilationUnit; -// -// Assert.AreEqual(1, unit.Children.Count); -// Assert.IsTrue(unit.Children[0] is ImportsStatement); -// ImportsStatement ud = (ImportsStatement)unit.Children[0]; -// Assert.AreEqual(1, ud.ImportsClauses.Count); -// Assert.IsFalse(ud.ImportsClauses[0].IsAlias); -// Assert.IsTrue(ud.ImportsClauses[0].IsXml); -// -// Assert.AreEqual("xmlns", ud.ImportsClauses[0].XmlPrefix); -// Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.ImportsClauses[0].Name); -// } -// -// [Test] -// public void VBNetXmlNamespaceSingleQuotedWithPrefixUsingTest() -// { -// string program = "Imports "; -// VBParser parser = ParserFactory.CreateParser(new StringReader(program)); -// parser.Parse(); -// -// Assert.AreEqual("", parser.Errors.ErrorOutput); -// CompilationUnit unit = parser.CompilationUnit; -// -// Assert.AreEqual(1, unit.Children.Count); -// Assert.IsTrue(unit.Children[0] is ImportsStatement); -// ImportsStatement ud = (ImportsStatement)unit.Children[0]; -// Assert.AreEqual(1, ud.ImportsClauses.Count); -// Assert.IsFalse(ud.ImportsClauses[0].IsAlias); -// Assert.IsTrue(ud.ImportsClauses[0].IsXml); -// -// Assert.AreEqual("xmlns:avalonedit", ud.ImportsClauses[0].XmlPrefix); -// Assert.AreEqual("http://icsharpcode.net/sharpdevelop/avalonedit", ud.ImportsClauses[0].Name); -// } -// #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs deleted file mode 100644 index 33f994443..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/NamespaceDeclarationTests.cs +++ /dev/null @@ -1,43 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class NamespaceDeclarationTests - { -// #region VB.NET -// [Test] -// public void VBNetSimpleNamespaceTest() -// { -// string program = "Namespace TestNamespace" + Environment.NewLine + -// "End Namespace" +Environment.NewLine; -// NamespaceDeclaration ns = ParseUtil.ParseGlobal(program); -// Assert.AreEqual("TestNamespace", ns.Name); -// } -// -// [Test] -// public void VBNetJuggedNamespaceTest() -// { -// string program = "Namespace N1 'TestNamespace\n" + -// " Namespace N2 ' Declares a namespace named N2 within N1.\n" + -// " End Namespace\n" + -// "End Namespace\n"; -// -// NamespaceDeclaration ns = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("N1", ns.Name); -// -// Assert.IsTrue(ns.Children[0] is NamespaceDeclaration); -// -// ns = (NamespaceDeclaration)ns.Children[0]; -// -// Assert.AreEqual("N2", ns.Name); -// } -// #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionStatementTests.cs deleted file mode 100644 index a3b28897a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/OptionStatementTests.cs +++ /dev/null @@ -1,113 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class OptionStatementTests - { - [Test] - public void InvalidOptionSyntax() - { - string program = "Option\n"; - ParseUtil.ParseGlobal(program, true); - } - - [Test] - public void StrictOption() - { - string program = "Option Strict On\n"; - - var node = new OptionStatement { - OptionType = OptionType.Strict, - OptionValue = OptionValue.On - }; - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - public void ExplicitOption() - { - string program = "Option Explicit Off\n"; - - var node = new OptionStatement { - OptionType = OptionType.Explicit, - OptionValue = OptionValue.Off - }; - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - public void CompareBinaryOption() - { - string program = "Option Compare Binary\n"; - - var node = new OptionStatement { - OptionType = OptionType.Compare, - OptionValue = OptionValue.Binary - }; - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - public void CompareTextOption() - { - string program = "Option Compare Text\n"; - - var node = new OptionStatement { - OptionType = OptionType.Compare, - OptionValue = OptionValue.Text - }; - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - public void InferOnOption() - { - string program = "Option Infer On\n"; - - var node = new OptionStatement { - OptionType = OptionType.Infer, - OptionValue = OptionValue.On - }; - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - public void InferOffOption() - { - string program = "Option Infer Off\n"; - - var node = new OptionStatement { - OptionType = OptionType.Infer, - OptionValue = OptionValue.Off - }; - - ParseUtil.AssertGlobal(program, node); - } - - [Test] - public void InferOption() - { - string program = "Option Infer\n"; - - var node = new OptionStatement { - OptionType = OptionType.Infer, - OptionValue = OptionValue.On - }; - - ParseUtil.AssertGlobal(program, node); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs deleted file mode 100644 index cc71f4c09..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/GlobalScope/TypeDeclarationTests.cs +++ /dev/null @@ -1,203 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class TypeDeclarationTests - { -// #region VB.NET -// [Test] -// public void VBNetSimpleClassTypeDeclarationTest() -// { -// string program = "Class TestClass\n" + -// "End Class\n"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestClass", td.Name); -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual(1, td.StartLocation.Line, "start line"); -// Assert.AreEqual(1, td.BodyStartLocation.Line, "bodystart line"); -// Assert.AreEqual(16, td.BodyStartLocation.Column, "bodystart col"); -// Assert.AreEqual(2, td.EndLocation.Line, "end line"); -// Assert.AreEqual(10, td.EndLocation.Column, "end col"); -// } -// -// [Test] -// public void VBNetMissingBaseClassTest() -// { -// // SD2-1499: test that this invalid code doesn't crash -// TypeDeclaration td = ParseUtil.ParseGlobal("public class test inherits", true); -// Assert.AreEqual(0, td.BaseTypes.Count); -// } -// -// [Test] -// public void VBNetEnumWithBaseClassDeclarationTest() -// { -// string program = "Enum TestEnum As Byte\n" + -// "End Enum\n"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestEnum", td.Name); -// Assert.AreEqual(ClassType.Enum, td.Type); -// Assert.AreEqual("System.Byte", td.BaseTypes[0].Type); -// Assert.AreEqual(0, td.Children.Count); -// } -// -// [Test] -// public void VBNetEnumOnSingleLine() -// { -// string program = "Enum TestEnum : A : B = 1 : C : End Enum"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestEnum", td.Name); -// Assert.AreEqual(ClassType.Enum, td.Type); -// Assert.AreEqual(3, td.Children.Count); -// } -// -// [Test] -// public void VBNetEnumOnSingleLine2() -// { -// string program = "Enum TestEnum : A : : B = 1 :: C : End Enum"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestEnum", td.Name); -// Assert.AreEqual(ClassType.Enum, td.Type); -// Assert.AreEqual(3, td.Children.Count); -// } -// -// -// [Test] -// public void VBNetEnumWithSystemBaseClassDeclarationTest() -// { -// string program = "Enum TestEnum As System.UInt16\n" + -// "End Enum\n"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestEnum", td.Name); -// Assert.AreEqual(ClassType.Enum, td.Type); -// Assert.AreEqual("System.UInt16", td.BaseTypes[0].Type); -// Assert.AreEqual(0, td.Children.Count); -// } -// -// [Test] -// public void VBNetSimpleClassTypeDeclarationWithoutLastNewLineTest() -// { -// string program = "Class TestClass\n" + -// "End Class"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestClass", td.Name); -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual(1, td.StartLocation.Line, "start line"); -// Assert.AreEqual(2, td.EndLocation.Line, "end line"); -// } -// -// [Test] -// public void VBNetSimpleClassTypeDeclarationWithColon() -// { -// string program = "Class TestClass\n" + -// " : \n" + -// "End Class"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestClass", td.Name); -// Assert.AreEqual(ClassType.Class, td.Type); -// } -// -// [Test] -// public void VBNetSimplePartialClassTypeDeclarationTest() -// { -// string program = "Partial Class TestClass\n" + -// "End Class\n"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestClass", td.Name); -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual(Modifiers.Partial, td.Modifier); -// } -// -// [Test] -// public void VBNetPartialPublicClass() -// { -// string program = "Partial Public Class TestClass\nEnd Class\n"; -// TypeDeclaration td = ParseUtil.ParseGlobal(program); -// -// Assert.AreEqual("TestClass", td.Name); -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual(Modifiers.Partial | Modifiers.Public, td.Modifier); -// } -// -// [Test] -// public void VBNetGenericClassTypeDeclarationTest() -// { -// string declr = @" -//Public Class Test(Of T) -// -//End Class -//"; -// TypeDeclaration td = ParseUtil.ParseGlobal(declr); -// -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual("Test", td.Name); -// Assert.AreEqual(Modifiers.Public, td.Modifier); -// Assert.AreEqual(0, td.BaseTypes.Count); -// Assert.AreEqual(1, td.Templates.Count); -// Assert.AreEqual("T", td.Templates[0].Name); -// } -// -// [Test] -// public void VBNetGenericClassWithConstraint() -// { -// string declr = @" -//Public Class Test(Of T As IMyInterface) -// -//End Class -//"; -// TypeDeclaration td = ParseUtil.ParseGlobal(declr); -// -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual("Test", td.Name); -// -// Assert.AreEqual(1, td.Templates.Count); -// Assert.AreEqual("T", td.Templates[0].Name); -// Assert.AreEqual("IMyInterface", td.Templates[0].Bases[0].Type); -// } -// -// [Test] -// public void VBNetComplexGenericClassTypeDeclarationTest() -// { -// string declr = @" -//Public Class Generic(Of T As MyNamespace.IMyInterface, S As {G(Of T()), IAnotherInterface}) -// Implements System.IComparable -// -//End Class -//"; -// TypeDeclaration td = ParseUtil.ParseGlobal(declr); -// -// Assert.AreEqual(ClassType.Class, td.Type); -// Assert.AreEqual("Generic", td.Name); -// Assert.AreEqual(Modifiers.Public, td.Modifier); -// Assert.AreEqual(1, td.BaseTypes.Count); -// Assert.AreEqual("System.IComparable", td.BaseTypes[0].Type); -// -// Assert.AreEqual(2, td.Templates.Count); -// Assert.AreEqual("T", td.Templates[0].Name); -// Assert.AreEqual("MyNamespace.IMyInterface", td.Templates[0].Bases[0].Type); -// -// Assert.AreEqual("S", td.Templates[1].Name); -// Assert.AreEqual(2, td.Templates[1].Bases.Count); -// Assert.AreEqual("G", td.Templates[1].Bases[0].Type); -// Assert.AreEqual(1, td.Templates[1].Bases[0].GenericTypes.Count); -// Assert.IsTrue(td.Templates[1].Bases[0].GenericTypes[0].IsArrayType); -// Assert.AreEqual("T", td.Templates[1].Bases[0].GenericTypes[0].Type); -// Assert.AreEqual(new int[] {0}, td.Templates[1].Bases[0].GenericTypes[0].RankSpecifier); -// Assert.AreEqual("IAnotherInterface", td.Templates[1].Bases[1].Type); -// } -// #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs deleted file mode 100644 index 5704c031e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/ParseUtil.cs +++ /dev/null @@ -1,108 +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 System; -using System.IO; -using System.Linq; - -using ICSharpCode.NRefactory.PatternMatching; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - public class ParseUtil - { - public static T ParseGlobal(string code, bool expectErrors = false) where T : AstNode - { - VBParser parser = new VBParser(); - CompilationUnit cu = parser.Parse(new StringReader(code)); - - Assert.AreEqual(expectErrors, parser.HasErrors, "HasErrors"); - - AstNode node = cu.Children.Single(); - Type type = typeof(T); - Assert.IsTrue(type.IsAssignableFrom(node.GetType()), String.Format("Parsed node was {0} instead of {1} ({2})", node.GetType(), type, node)); - return (T)node; - } - - public static void AssertGlobal(string code, AstNode expectedNode) - { - var node = ParseGlobal(code); - if (!expectedNode.IsMatch(node)) { - Assert.Fail("Expected '{0}' but was '{1}'", ToVB(expectedNode), ToVB(node)); - } - } - -// public static T ParseStatement(string stmt, bool expectErrors = false) where T : AstNode -// { -// VBParser parser = new VBParser(); -// var statements = parser.ParseStatements(new StringReader(stmt)); -// -// Assert.AreEqual(expectErrors, parser.HasErrors, "HasErrors"); -// -// AstNode statement = statements.Single(); -// Type type = typeof(T); -// Assert.IsTrue(type.IsAssignableFrom(statement.GetType()), String.Format("Parsed statement was {0} instead of {1} ({2})", statement.GetType(), type, statement)); -// return (T)statement; -// } -// -// public static void AssertStatement(string code, VB.Ast.Statement expectedStmt) -// { -// var stmt = ParseStatement(code); -// if (!expectedStmt.IsMatch(stmt)) { -// Assert.Fail("Expected '{0}' but was '{1}'", ToCSharp(expectedStmt), ToCSharp(stmt)); -// } -// } -// -// public static T ParseExpression(string expr, bool expectErrors = false) where T : AstNode -// { -// VBParser parser = new VBParser(); -// AstNode parsedExpression = parser.ParseExpression(new StringReader(expr)); -// -// Assert.AreEqual(expectErrors, parser.HasErrors, "HasErrors"); -// if (expectErrors && parsedExpression == null) -// return default (T); -// Type type = typeof(T); -// Assert.IsTrue(type.IsAssignableFrom(parsedExpression.GetType()), String.Format("Parsed expression was {0} instead of {1} ({2})", parsedExpression.GetType(), type, parsedExpression)); -// return (T)parsedExpression; -// } -// -// public static void AssertExpression(string code, VB.Ast.Expression expectedExpr) -// { -// var expr = ParseExpression(code); -// if (!expectedExpr.IsMatch(expr)) { -// Assert.Fail("Expected '{0}' but was '{1}'", ToCSharp(expectedExpr), ToCSharp(expr)); -// } -// } -// -// public static T ParseTypeMember(string expr, bool expectErrors = false) where T : AttributedNode -// { -// VBParser parser = new VBParser(); -// var members = parser.ParseTypeMembers(new StringReader(expr)); -// -// Assert.AreEqual(expectErrors, parser.HasErrors, "HasErrors"); -// -// AttributedNode m = members.Single(); -// Type type = typeof(T); -// Assert.IsTrue(type.IsAssignableFrom(m.GetType()), String.Format("Parsed member was {0} instead of {1} ({2})", m.GetType(), type, m)); -// return (T)m; -// } -// -// public static void AssertTypeMember(string code, VB.Ast.AttributedNode expectedMember) -// { -// var member = ParseTypeMember(code); -// if (!expectedMember.IsMatch(member)) { -// Assert.Fail("Expected '{0}' but was '{1}'", ToVB(expectedMember), ToVB(member)); -// } -// } - - static string ToVB(AstNode node) - { - StringWriter w = new StringWriter(); - node.AcceptVisitor(new OutputVisitor(w, new VBFormattingOptions()), null); - return w.ToString(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs deleted file mode 100644 index bf64c982b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/SnippetParserTests.cs +++ /dev/null @@ -1,22 +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; -using System; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests -{ - [TestFixture] - public class SnippetParserTests - { -// [Test] -// public void InvalidExpressionSyntax() -// { -// // SD2-1584: ensure we don't crash on this invalid VB code -// SnippetParser parser = new SnippetParser(); -// INode node = parser.Parse("i == 5"); -// Assert.IsTrue(parser.Errors.Count > 0); -// } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs deleted file mode 100644 index 714476ef6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/AddHandlerStatementTests.cs +++ /dev/null @@ -1,22 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class AddHandlerStatementTests - { - [Test] - public void AddHandlerTest() - { - AddHandlerStatement addHandlerStatement = ParseUtil.ParseStatement("AddHandler Obj.Ev_Event, AddressOf EventHandler"); - // TODO : extend tests - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs deleted file mode 100644 index 85d2dd39b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/BlockStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class BlockStatementTests - { - // TODO create BlockStatementTests - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs deleted file mode 100644 index 630054149..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ContinueStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ContinueStatementTests - { - // TODO : add ContinueStatementTests - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs deleted file mode 100644 index 512e7f111..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/DoLoopStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class DoLoopStatementTests - { - // TODO write some DoLoopStatement tests - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs deleted file mode 100644 index 9041a2763..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EndStatementTests.cs +++ /dev/null @@ -1,29 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class EndStatementTests - { - #region VB.NET - [Test] - public void VBNetEndStatementTest() - { - EndStatement endStatement = ParseUtil.ParseStatement("End"); - } - - [Test] - public void VBNetEndStatementInIfThenTest2() - { - IfElseStatement endStatement = ParseUtil.ParseStatement("IF a THEN End"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs deleted file mode 100644 index 742c0fdc2..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/EraseStatementTests.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class EraseStatementTests - { - #region VB.NET - [Test] - public void VBNetEraseStatementTest() - { - EraseStatement eraseStatement = ParseUtil.ParseStatement("Erase a, b, c"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs deleted file mode 100644 index e5ae7289f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ErrorStatementTests.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ErrorStatementTests - { - #region VB.NET - [Test] - public void VBNetErrorStatementTest() - { - ErrorStatement errorStatement = ParseUtil.ParseStatement("Error a"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs deleted file mode 100644 index 926229402..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ExpressionStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ExpressionStatementTests - { - // TODO : Create ExpressionStatementTests - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs deleted file mode 100644 index 68433fd30..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForNextStatementTests.cs +++ /dev/null @@ -1,29 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ForNextStatementTests - { - #region VB.NET - [Test] - public void VBNetForNextStatementTest() - { - ForNextStatement forNextStatement = ParseUtil.ParseStatement("For i=0 To 10 Step 2 : Next i"); - } - - [Test] - public void VBNetForNextStatementWithComplexExpressionTest() - { - ForNextStatement forNextStatement = ParseUtil.ParseStatement("For SomeMethod().Property = 0 To 10 : Next SomeMethod().Property"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs deleted file mode 100644 index f6e874a96..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ForeachStatementTests.cs +++ /dev/null @@ -1,25 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ForeachStatementTests - { - #region VB.NET - [Test] - public void VBNetForeachStatementTest() - { - ForeachStatement foreachStmt = ParseUtil.ParseStatement("For Each i As Integer In myColl : Next"); - // TODO : Extend test. - } - #endregion - - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs deleted file mode 100644 index f4c2c5133..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/GotoStatementTests.cs +++ /dev/null @@ -1,24 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class GotoStatementTests - { - #region VB.NET - [Test] - public void VBNetGotoStatementTest() - { - GotoStatement gotoStmt = ParseUtil.ParseStatement("GoTo myLabel"); - Assert.AreEqual("myLabel", gotoStmt.Label); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs deleted file mode 100644 index dee85e7fd..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/IfElseStatementTests.cs +++ /dev/null @@ -1,142 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class IfElseStatementTests - { - #region VB.NET - [Test] - public void VBNetSimpleIfStatementTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN END"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.IsTrue(ifElseStatement.TrueStatement.Count == 1, "true count != 1:" + ifElseStatement.TrueStatement.Count); - Assert.IsTrue(ifElseStatement.FalseStatement.Count == 0, "false count != 0:" + ifElseStatement.FalseStatement.Count); - - Assert.IsTrue(ifElseStatement.TrueStatement[0] is EndStatement, "Statement was: " + ifElseStatement.TrueStatement[0]); - } - [Test] - public void VBNetSimpleIfStatementTest2() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN\n END\n END IF"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.IsTrue(ifElseStatement.TrueStatement.Count == 1, "true count != 1:" + ifElseStatement.TrueStatement.Count); - Assert.IsTrue(ifElseStatement.FalseStatement.Count == 0, "false count != 0:" + ifElseStatement.FalseStatement.Count); - - Assert.IsTrue(ifElseStatement.TrueStatement[0] is BlockStatement, "Statement was: " + ifElseStatement.TrueStatement[0]); - } - - // test for SD2-1201 - [Test] - public void VBNetIfStatementLocationTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN\n" + - "DoIt()\n" + - "ElseIf False Then\n" + - "DoIt()\n" + - "End If"); - Assert.AreEqual(3, (ifElseStatement.StartLocation).Line); - Assert.AreEqual(7, (ifElseStatement.EndLocation).Line); - Assert.AreEqual(5, (ifElseStatement.ElseIfSections[0].StartLocation).Line); - Assert.AreEqual(6, (ifElseStatement.ElseIfSections[0].EndLocation).Line); - Assert.IsNotNull(ifElseStatement.ElseIfSections[0].Parent); - - } - - [Test] - public void VBNetElseIfStatementTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN\n" + - "END\n" + - "ElseIf False Then\n" + - "Stop\n" + - "End If"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.IsTrue(ifElseStatement.TrueStatement.Count == 1, "true count != 1:" + ifElseStatement.TrueStatement.Count); - Assert.IsTrue(ifElseStatement.FalseStatement.Count == 0, "false count != 0:" + ifElseStatement.FalseStatement.Count); - Assert.IsFalse((bool)(ifElseStatement.ElseIfSections[0].Condition as PrimitiveExpression).Value); - - Assert.IsTrue(ifElseStatement.TrueStatement[0] is BlockStatement, "Statement was: " + ifElseStatement.TrueStatement[0]); - Assert.IsTrue(ifElseStatement.ElseIfSections[0].EmbeddedStatement.Children[0] is StopStatement, "Statement was: " + ifElseStatement.ElseIfSections[0].EmbeddedStatement.Children[0]); - } - [Test] - public void VBNetElse_IfStatementTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN\n" + - "END\n" + - "Else If False Then\n" + - "Stop\n" + - "End If"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.IsTrue(ifElseStatement.TrueStatement.Count == 1, "true count != 1:" + ifElseStatement.TrueStatement.Count); - Assert.IsTrue(ifElseStatement.FalseStatement.Count == 0, "false count != 0:" + ifElseStatement.FalseStatement.Count); - Assert.IsFalse((bool)(ifElseStatement.ElseIfSections[0].Condition as PrimitiveExpression).Value); - - Assert.IsTrue(ifElseStatement.TrueStatement[0] is BlockStatement, "Statement was: " + ifElseStatement.TrueStatement[0]); - Assert.IsTrue(ifElseStatement.ElseIfSections[0].EmbeddedStatement.Children[0] is StopStatement, "Statement was: " + ifElseStatement.ElseIfSections[0].EmbeddedStatement.Children[0]); - } - [Test] - public void VBNetMultiStatementIfStatementTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN Stop : b"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.AreEqual(2, ifElseStatement.TrueStatement.Count, "true count"); - Assert.AreEqual(0, ifElseStatement.FalseStatement.Count, "false count"); - - Assert.IsTrue(ifElseStatement.TrueStatement[0] is StopStatement); - Assert.IsTrue(ifElseStatement.TrueStatement[1] is ExpressionStatement); - } - [Test] - public void VBNetMultiStatementIfStatementWithEndStatementTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN Stop : End : b"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.AreEqual(3, ifElseStatement.TrueStatement.Count, "true count"); - Assert.AreEqual(0, ifElseStatement.FalseStatement.Count, "false count"); - - Assert.IsTrue(ifElseStatement.TrueStatement[0] is StopStatement); - Assert.IsTrue(ifElseStatement.TrueStatement[1] is EndStatement); - Assert.IsTrue(ifElseStatement.TrueStatement[2] is ExpressionStatement); - } - - [Test] - public void VBNetIfWithEmptyElseTest() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN a Else"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.AreEqual(1, ifElseStatement.TrueStatement.Count, "true count"); - Assert.AreEqual(0, ifElseStatement.FalseStatement.Count, "false count"); - } - - [Test] - public void VBNetIfWithMultipleColons() - { - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN a : : b"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.AreEqual(2, ifElseStatement.TrueStatement.Count, "true count"); - Assert.AreEqual(0, ifElseStatement.FalseStatement.Count, "false count"); - } - - [Test] - public void VBNetIfWithSingleLineElse() - { - // This isn't legal according to the VB spec, but the MS VB compiler seems to allow it. - IfElseStatement ifElseStatement = ParseUtil.ParseStatement("If True THEN\n" + - " x()\n" + - "Else y()\n" + - "End If"); - Assert.IsFalse(ifElseStatement.Condition.IsNull); - Assert.AreEqual(1, ifElseStatement.TrueStatement.Count, "true count"); - Assert.AreEqual(1, ifElseStatement.FalseStatement.Count, "false count"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs deleted file mode 100644 index 8bdd6f7fa..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LabelStatementTests.cs +++ /dev/null @@ -1,26 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class LabelStatementTests - { - #region VB.NET - [Test] - public void VBNetLabelStatementTest() - { - MethodDeclaration method = ParseUtil.ParseTypeMember("Sub Test \n myLabel: Console.WriteLine() \n End Sub"); - Assert.AreEqual(2, method.Body.Children.Count); - LabelStatement labelStmt = (LabelStatement)method.Body.Children[0]; - Assert.AreEqual("myLabel", labelStmt.Label); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs deleted file mode 100644 index d0b9ced62..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LocalVariableDeclarationTests.cs +++ /dev/null @@ -1,204 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class LocalVariableDeclarationTests - { - #region VB.NET - [Test] - public void VBNetLocalVariableDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As Integer = 5"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("a", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Int32", type.Type); - Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value); - } - - [Test] - public void VBNetLocalVariableNamedOverrideDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim override As Integer = 5"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("override", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Int32", type.Type); - Assert.AreEqual(5, ((PrimitiveExpression)lvd.Variables[0].Initializer).Value); - } - - [Test] - public void VBNetLocalArrayDeclarationWithInitializationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a(10) As Integer"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("a", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Int32", type.Type); - Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); - ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; - Assert.AreEqual(new int[] { 0 } , ace.CreateType.RankSpecifier); - Assert.AreEqual(1, ace.Arguments.Count); - Assert.AreEqual(10, ((PrimitiveExpression)ace.Arguments[0]).Value); - } - - [Test] - public void VBNetLocalArrayDeclarationWithInitializationAndLowerBoundTest() - { - // VB.NET allows only "0" as lower bound - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a(0 To 10) As Integer"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("a", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Int32", type.Type); - Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); - ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; - Assert.AreEqual(new int[] { 0 } , ace.CreateType.RankSpecifier); - Assert.AreEqual(1, ace.Arguments.Count); - Assert.AreEqual(10, ((PrimitiveExpression)ace.Arguments[0]).Value); - } - - [Test] - public void VBNetLocalArrayDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a() As Integer"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("a", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Int32", type.Type); - Assert.AreEqual(new int[] { 0 } , type.RankSpecifier); - } - - [Test] - public void VBNetLocalJaggedArrayDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a(10)() As Integer"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("a", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.Int32", type.Type); - Assert.AreEqual(new int[] { 0, 0 } , type.RankSpecifier); - ArrayCreateExpression ace = (ArrayCreateExpression)lvd.Variables[0].Initializer; - Assert.AreEqual(new int[] {0, 0}, ace.CreateType.RankSpecifier); - Assert.AreEqual(1, ace.Arguments.Count); - Assert.AreEqual(10, ((PrimitiveExpression)ace.Arguments[0]).Value); - } - - [Test] - public void VBNetComplexGenericLocalVariableDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim where As Generic(Of Printable, G(Of Printable()))"); - Assert.AreEqual(1, lvd.Variables.Count); - Assert.AreEqual("where", lvd.Variables[0].Name); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("Generic", type.Type); - Assert.AreEqual(2, type.GenericTypes.Count); - Assert.AreEqual("Printable", type.GenericTypes[0].Type); - Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); - Assert.AreEqual("G", type.GenericTypes[1].Type); - Assert.AreEqual(1, type.GenericTypes[1].GenericTypes.Count); - Assert.AreEqual("Printable", type.GenericTypes[1].GenericTypes[0].Type); - } - - [Test] - public void VBNetGenericWithArrayLocalVariableDeclarationTest1() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As G(Of Integer)()"); - Assert.AreEqual(1, lvd.Variables.Count); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("G", type.Type); - Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); - Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); - Assert.IsFalse(type.GenericTypes[0].IsArrayType); - Assert.AreEqual(new int[] { 0 }, type.RankSpecifier); - } - - [Test] - public void VBNetGenericWithArrayLocalVariableDeclarationTest2() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As G(Of Integer())"); - Assert.AreEqual(1, lvd.Variables.Count); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("G", type.Type); - Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); - Assert.AreEqual(0, type.GenericTypes[0].GenericTypes.Count); - Assert.IsFalse(type.IsArrayType); - Assert.AreEqual(1, type.GenericTypes[0].RankSpecifier.Length); - Assert.AreEqual(0, type.GenericTypes[0].RankSpecifier[0]); - } - - [Test] - public void VBNetGenericLocalVariableDeclarationTest2() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As G(Of G(Of Integer))"); - Assert.AreEqual(1, lvd.Variables.Count); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("G", type.Type); - Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("G", type.GenericTypes[0].Type); - Assert.AreEqual(1, type.GenericTypes[0].GenericTypes.Count); - Assert.AreEqual("System.Int32", type.GenericTypes[0].GenericTypes[0].Type); - } - - [Test] - public void VBNetGenericLocalVariableDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As G(Of Integer)"); - Assert.AreEqual(1, lvd.Variables.Count); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("G", type.Type); - Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); - } - - [Test] - public void VBNetGenericLocalVariableInitializationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a As New G(Of Integer)"); - Assert.AreEqual(1, lvd.Variables.Count); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("G", type.Type); - Assert.AreEqual(1, type.GenericTypes.Count); - Assert.AreEqual("System.Int32", type.GenericTypes[0].Type); - // TODO: Check initializer - } - - [Test] - public void VBNetNestedGenericLocalVariableDeclarationTest() - { - LocalVariableDeclaration lvd = ParseUtil.ParseStatement("Dim a as MyType(of string).InnerClass(of integer).InnerInnerClass"); - Assert.AreEqual(1, lvd.Variables.Count); - InnerClassTypeReference ic = (InnerClassTypeReference)lvd.GetTypeForVariable(0); - Assert.AreEqual("InnerInnerClass", ic.Type); - Assert.AreEqual(0, ic.GenericTypes.Count); - ic = (InnerClassTypeReference)ic.BaseType; - Assert.AreEqual("InnerClass", ic.Type); - Assert.AreEqual(1, ic.GenericTypes.Count); - Assert.AreEqual("System.Int32", ic.GenericTypes[0].Type); - Assert.AreEqual("MyType", ic.BaseType.Type); - Assert.AreEqual(1, ic.BaseType.GenericTypes.Count); - Assert.AreEqual("System.String", ic.BaseType.GenericTypes[0].Type); - } - - [Test] - public void VBNetDimInSingleLineIf() - { - IfElseStatement ifes = ParseUtil.ParseStatement("If a Then Dim b As String"); - LocalVariableDeclaration lvd = (LocalVariableDeclaration)ifes.TrueStatement[0]; - Assert.AreEqual(1, lvd.Variables.Count); - TypeReference type = lvd.GetTypeForVariable(0); - Assert.AreEqual("System.String", type.Type); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs deleted file mode 100644 index ec3501c75..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/LockStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class LockStatementTests - { - // TODO : write some tests on SyncLock - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs deleted file mode 100644 index db4c5ab96..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/OnErrorStatementTest.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class OnErrorStatementTest - { - #region VB.NET - [Test] - public void VBNetOnErrorStatementTest() - { - OnErrorStatement onErrorStatement = ParseUtil.ParseStatement("On Error Goto err"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs deleted file mode 100644 index 96bbd89e6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RaiseEventStatementTest.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class RaiseEventStatementTest - { - #region VB.NET - [Test] - public void VBNetRaiseEventStatementTest() - { - RaiseEventStatement raiseEventStatement = ParseUtil.ParseStatement("RaiseEvent MyEvent(a, 5, (6))"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs deleted file mode 100644 index 4a4ea8db1..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReDimStatementTests.cs +++ /dev/null @@ -1,77 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ReDimStatementTests - { - [Test] - public void VBNetReDimStatementTest() - { - ReDimStatement reDimStatement = ParseUtil.ParseStatement("ReDim Preserve MyArray(15)"); - Assert.AreEqual(1, reDimStatement.ReDimClauses.Count); - Assert.AreSame(reDimStatement, reDimStatement.ReDimClauses[0].Parent); - } - - [Test] - public void VBNetReDimStatementTest2() - { - ReDimStatement reDimStatement = ParseUtil.ParseStatement("ReDim calCheckData(channelNum, lambdaNum).ShiftFromLastFullCalPixels(CalCheckPeak.HighWavelength)"); - } - - [Test] - public void VBNetBigReDimStatementTest() - { - string program = @" -Class X - Sub x - ReDim sU(m - 1, n - 1) - ReDim sW(n - 1) - ReDim sV(n - 1, n - 1) - ReDim rv1(n - 1) - ReDim sMt(iNrCols - 1, 0) - ReDim Preserve sMt(iNrCols - 1, iRowNr) - ReDim sM(iRowNr - 1, iNrCols - 1) - If (IsNothing(ColLengths)) Then ReDim ColLengths(0) - If (ColLengths.Length = (SubItem + 1)) Then ReDim Preserve ColLengths(SubItem + 1) - ReDim sTransform(2, iTransformType - 1) - ReDim Preserve _Items(_Count) - ReDim Preserve _Items(nCapacity) - ReDim Preserve _Items(0 To _Count) - ReDim Preserve _Items(0 To nCapacity) - ReDim sU(m - 1, n - 1) - ReDim sW(n - 1) - ReDim sV(n - 1, n - 1) - ReDim rv1(n - 1) - ReDim sMt(iNrCols - 1, 0) - ReDim Preserve sMt(iNrCols - 1, iRowNr) - ReDim sM(iRowNr - 1, iNrCols - 1) - If (IsNothing(ColLengths)) Then ReDim ColLengths(0) - If (ColLengths.Length = (SubItem + 1)) Then ReDim Preserve ColLengths(SubItem + 1) - ReDim sTransform(2, iTransformType - 1) - ReDim Preserve Samples(Samples.GetUpperBound(0) + 1) - ReDim Samples(0) - ReDim BaseCssContent(BaseCssContentRows - 1) - ReDim mabtRxBuf(Bytes2Read - 1) - ReDim Preserve primarykey(primarykey.Length) - ReDim Preserve IntArray(10, 10, 15) - ReDim X(10, 10) - ReDim Preserve IntArray(0 To 10, 10, 0 To 20) - ReDim Preserve IntArray(10, 10, 15) - ReDim X(0 To 10, 0 To 10) - ReDim GetMe().IntArray(0 To 10, 10, 0 To 20) - ReDim GetMe(ExplicitParameter := 3).IntArray(0 To 10, 10, 0 To 20) - ReDim SomeType(Of Integer).IntArray(0 To 10, 10, 0 To 20) - End Sub -End Class"; - TypeDeclaration typeDeclaration = ParseUtil.ParseGlobal(program); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs deleted file mode 100644 index fb01666ae..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/RemoveHandlerStatement.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class RemoveHandlerStatementTests - { - #region VB.NET - [Test] - public void VBNetRemoveHandlerTest() - { - RemoveHandlerStatement removeHandlerStatement = ParseUtil.ParseStatement("RemoveHandler MyHandler, AddressOf MyMethod"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs deleted file mode 100644 index 85ab30a31..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ResumeStatement.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ResumeStatementTests - { - [Test] - public void ResumeStatementTest() - { - ResumeStatement resumeStatement = ParseUtil.ParseStatement("Resume"); - } - - // TODO : write some more - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs deleted file mode 100644 index f6403d5eb..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ReturnStatementTests.cs +++ /dev/null @@ -1,32 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ReturnStatementTests - { - #region VB.NET - [Test] - public void VBNetEmptyReturnStatementTest() - { - ReturnStatement returnStatement = ParseUtil.ParseStatement("Return"); - Assert.IsTrue(returnStatement.Expression.IsNull); - } - - [Test] - public void VBNetReturnStatementTest() - { - ReturnStatement returnStatement = ParseUtil.ParseStatement("Return 5"); - Assert.IsFalse(returnStatement.Expression.IsNull); - Assert.IsTrue(returnStatement.Expression is PrimitiveExpression); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs deleted file mode 100644 index 0a0d27595..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/StopStatementTests.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class StopStatementTests - { - #region VB.NET - [Test] - public void VBNetStopStatementTest() - { - StopStatement stopStatement = ParseUtil.ParseStatement("Stop"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs deleted file mode 100644 index 39f4a47a8..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/SwitchStatementTests.cs +++ /dev/null @@ -1,34 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class SwitchStatementTests - { - #region VB.NET - [Test] - public void VBSwitchStatementTest() - { - SwitchStatement switchStmt = ParseUtil.ParseStatement("Select Case a\n Case 4, 5\n Case 6\n Case Else\n End Select"); - Assert.AreEqual("a", ((SimpleNameExpression)switchStmt.SwitchExpression).Identifier); - // TODO: Extend test - } - - [Test] - public void InvalidVBSwitchStatementTest() - { - SwitchStatement switchStmt = ParseUtil.ParseStatement("Select Case a\n Case \n End Select", true); - Assert.AreEqual("a", ((SimpleNameExpression)switchStmt.SwitchExpression).Identifier); - SwitchSection sec = switchStmt.SwitchSections[0]; - Assert.AreEqual(0, sec.SwitchLabels.Count); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs deleted file mode 100644 index c9df1d692..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/ThrowStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ThrowStatementTests - { - // TODO : ThrowStatementTests - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs deleted file mode 100644 index 8d4b49289..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/TryCatchStatementTests.cs +++ /dev/null @@ -1,17 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class TryCatchStatementTests - { - // TODO : TryCatchStatementTests - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs deleted file mode 100644 index 059eb21a0..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/UsingStatementTests.cs +++ /dev/null @@ -1,47 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class UsingStatementTests - { - [Test] - public void UsingStatement() - { - string usingText = @" -Using nf As New System.Drawing.Font(""Arial"", 12.0F, FontStyle.Bold) - c.Font = nf - c.Text = ""This is 12-point Arial bold"" -End Using"; - UsingStatement usingStmt = ParseUtil.ParseStatement(usingText); - // TODO : Extend test. - } - [Test] - public void UsingStatement2() - { - string usingText = @" -Using nf As Font = New Font() - Bla(nf) -End Using"; - UsingStatement usingStmt = ParseUtil.ParseStatement(usingText); - // TODO : Extend test. - } - [Test] - public void UsingStatement3() - { - string usingText = @" -Using nf As New Font(), nf2 As New List(Of Font)(), nf3 = Nothing - Bla(nf) -End Using"; - UsingStatement usingStmt = ParseUtil.ParseStatement(usingText); - // TODO : Extend test. - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs deleted file mode 100644 index 7f0ce5c44..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/Statements/WithStatementTests.cs +++ /dev/null @@ -1,23 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class WithStatementTests - { - #region VB.NET - [Test] - public void VBNetWithStatementTest() - { - WithStatement withStatement = ParseUtil.ParseStatement("With MyObj : End With"); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs deleted file mode 100644 index 8c6d27a66..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs +++ /dev/null @@ -1,34 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class ConstructorDeclarationTests - { - #region VB.NET - [Test] - public void VBNetConstructorDeclarationTest1() - { - string program = @"Sub New() - End Sub"; - ConstructorDeclaration cd = ParseUtil.ParseTypeMember(program); - Assert.IsTrue(cd.ConstructorInitializer.IsNull); - } - - [Test] - public void VBNetConstructorDeclarationTest2() - { - ConstructorDeclaration cd = ParseUtil.ParseTypeMember("Sub New(x As Integer, Optional y As String) \nEnd Sub"); - Assert.AreEqual(2, cd.Parameters.Count); - Assert.AreEqual("System.Int32", cd.Parameters[0].TypeReference.Type); - Assert.AreEqual("System.String", cd.Parameters[1].TypeReference.Type); - Assert.AreEqual(ParameterModifiers.Optional, cd.Parameters[1].ParamModifier & ParameterModifiers.Optional); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs deleted file mode 100644 index 5634c982b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/CustomEventTests.cs +++ /dev/null @@ -1,44 +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 System; -using System.IO; -using NUnit.Framework; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class CustomEventTests - { - #region VB.NET - [Test] - public void VBNetCustomEventsStatementTest() - { - 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"; - EventDeclaration customEventDecl = ParseUtil.ParseTypeMember(code); - Assert.IsNotNull(customEventDecl); - Assert.AreEqual("TestEvent", customEventDecl.Name); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs deleted file mode 100644 index 3b1ae48c0..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/DeclareDeclarationTests.cs +++ /dev/null @@ -1,28 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class DeclareDeclarationTests - { - #region VB.NET - [Test] - public void VBNetDeclareDeclarationTest() - { - string program = "Declare Ansi Function GetUserName Lib \"advapi32.dll\" Alias \"GetUserNameA\" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer\n"; - DeclareDeclaration dd = ParseUtil.ParseTypeMember(program); - Assert.AreEqual("System.Int32", dd.TypeReference.Type); - Assert.AreEqual("GetUserName", dd.Name); - Assert.AreEqual("advapi32.dll", dd.Library); - Assert.AreEqual("GetUserNameA", dd.Alias); - Assert.AreEqual(CharsetModifier.Ansi, dd.Charset); - } - #endregion - - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs deleted file mode 100644 index f88e8e27f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/EventDeclarationTests.cs +++ /dev/null @@ -1,25 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class EventDeclarationTests - { - #region VB.NET - [Test] - public void VBNetSimpleEventDeclarationTest() - { - EventDeclaration ed = ParseUtil.ParseTypeMember("event MyEvent(x as Integer)"); - Assert.AreEqual(1, ed.Parameters.Count); - Assert.AreEqual("MyEvent", ed.Name); - Assert.IsFalse(ed.HasAddRegion); - Assert.IsFalse(ed.HasRemoveRegion); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs deleted file mode 100644 index 2aa54fdb2..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/FieldDeclarationTests.cs +++ /dev/null @@ -1,74 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class FieldDeclarationTests - { - #region VB.NET - [Test] - public void VBNetSimpleFieldDeclarationTest() - { - FieldDeclaration fd = ParseUtil.ParseTypeMember("myField As Integer(,,,)"); - Assert.AreEqual(1, fd.Fields.Count); - - Assert.AreEqual("System.Int32", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.AreEqual("System.Int32", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.AreEqual("myField", ((VariableDeclaration)fd.Fields[0]).Name); - Assert.AreEqual(new int[] { 3 } , ((VariableDeclaration)fd.Fields[0]).TypeReference.RankSpecifier); - } - - [Test] - public void VBNetMultiFieldDeclarationTest() - { - FieldDeclaration fd = ParseUtil.ParseTypeMember("a, b As String"); - Assert.AreEqual(2, fd.Fields.Count); - - Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); - Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); - Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); - } - - [Test] - public void VBNetMultiFieldsOnSingleLineTest() - { - string program = "Class TestClass : Dim a : Dim b : End Class"; - TypeDeclaration td = ParseUtil.ParseGlobal(program); - - Assert.AreEqual(2, td.Children.Count); - Assert.IsTrue(td.Children[0] is FieldDeclaration); - Assert.IsTrue(td.Children[1] is FieldDeclaration); - } - - [Test] - public void VBNetMultiFieldDeclarationTest2() - { - FieldDeclaration fd = ParseUtil.ParseTypeMember("Dim a, b() As String"); - Assert.AreEqual(2, fd.Fields.Count); - - Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); - Assert.IsFalse(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); - Assert.IsTrue(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); - } - - [Test] - public void VBNetMultiFieldDeclarationTest3() - { - FieldDeclaration fd = ParseUtil.ParseTypeMember("Dim a(), b As String"); - Assert.AreEqual(2, fd.Fields.Count); - - Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[0]).TypeReference.Type); - Assert.AreEqual("System.String", ((VariableDeclaration)fd.Fields[1]).TypeReference.Type); - Assert.IsTrue(((VariableDeclaration)fd.Fields[0]).TypeReference.IsArrayType); - Assert.IsFalse(((VariableDeclaration)fd.Fields[1]).TypeReference.IsArrayType); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs deleted file mode 100644 index 5be86af63..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/MethodDeclarationTests.cs +++ /dev/null @@ -1,199 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class MethodDeclarationTests - { - #region VB.NET - - [Test] - public void VBNetDefiningPartialMethodDeclarationTest() - { - MethodDeclaration md = ParseUtil.ParseTypeMember(@"Partial Sub MyMethod() - End Sub"); - Assert.AreEqual(0, md.Parameters.Count); - Assert.AreEqual("MyMethod", md.Name); - Assert.IsFalse(md.IsExtensionMethod); - Assert.AreEqual(Modifiers.Partial, md.Modifier); - } - - [Test] - public void VBNetMethodWithModifiersRegionTest() - { - const string program = @"public shared sub MyMethod() - OtherMethod() - end sub"; - - MethodDeclaration md = ParseUtil.ParseTypeMember(program); - Assert.AreEqual(Modifiers.Public | Modifiers.Static, md.Modifier); - Assert.AreEqual(2, md.StartLocation.Line, "StartLocation.Y"); - Assert.AreEqual(2, md.EndLocation.Line, "EndLocation.Y"); - Assert.AreEqual(2, md.StartLocation.Column, "StartLocation.X"); - } - - [Test] - public void VBNetFunctionMethodDeclarationTest() - { - const string program = @"public function MyFunction() as Integer - return 1 - end function"; - - MethodDeclaration md = ParseUtil.ParseTypeMember(program); - Assert.AreEqual(Modifiers.Public, md.Modifier); - Assert.AreEqual(2, md.StartLocation.Line, "StartLocation.Y"); - Assert.AreEqual(2, md.StartLocation.Column, "StartLocation.X"); - Assert.AreEqual(2, md.EndLocation.Line, "EndLocation.Y"); - } - - [Test] - public void VBNetSubroutineMethodDeclarationTest() - { - const string program = @"public Sub MyMethod() - OtherMethod() - end Sub"; - - MethodDeclaration md = ParseUtil.ParseTypeMember(program); - Assert.AreEqual(Modifiers.Public, md.Modifier); - Assert.AreEqual(2, md.StartLocation.Line, "StartLocation.Y"); - Assert.AreEqual(2, md.StartLocation.Column, "StartLocation.X"); - Assert.AreEqual(2, md.EndLocation.Line, "EndLocation.Y"); - } - - [Test] - public void VBNetGenericFunctionMethodDeclarationTest() - { - MethodDeclaration md = ParseUtil.ParseTypeMember("function MyMethod(Of T)(a As T) As Double\nEnd Function"); - Assert.AreEqual("System.Double", md.TypeReference.Type); - Assert.AreEqual(1, md.Parameters.Count); - Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); - Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); - - Assert.AreEqual(1, md.Templates.Count); - Assert.AreEqual("T", md.Templates[0].Name); - } - - [Test] - public void VBNetGenericMethodDeclarationTest() - { - MethodDeclaration md = ParseUtil.ParseTypeMember("Function MyMethod(Of T)(a As T) As T\nEnd Function "); - Assert.AreEqual("T", md.TypeReference.Type); - Assert.AreEqual(1, md.Parameters.Count); - Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); - Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); - - Assert.AreEqual(1, md.Templates.Count); - Assert.AreEqual("T", md.Templates[0].Name); - } - - [Test] - public void VBNetGenericMethodDeclarationWithConstraintTest() - { - string program = "Function MyMethod(Of T As { ISomeInterface })(a As T) As T\n End Function"; - MethodDeclaration md = ParseUtil.ParseTypeMember(program); - Assert.AreEqual("T", md.TypeReference.Type); - Assert.AreEqual(1, md.Parameters.Count); - Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); - Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); - - Assert.AreEqual(1, md.Templates.Count); - Assert.AreEqual("T", md.Templates[0].Name); - Assert.AreEqual(1, md.Templates[0].Bases.Count); - Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); - } - - [Test] - public void VBNetExtensionMethodDeclaration() - { - MethodDeclaration md = ParseUtil.ParseTypeMember( - @" _ - Sub Print(s As String) - Console.WriteLine(s) - End Sub"); - - Assert.AreEqual("Print", md.Name); - - // IsExtensionMethod is only valid for c#. - // Assert.IsTrue(md.IsExtensionMethod); - - Assert.AreEqual("s", md.Parameters[0].ParameterName); - Assert.AreEqual("System.String", md.Parameters[0].TypeReference.Type); - } - - [Test] - public void VBNetGenericMethodInInterface() - { - const string program = @"Interface MyInterface - Function MyMethod(Of T As {ISomeInterface})(a As T) As T - End Interface"; - TypeDeclaration td = ParseUtil.ParseGlobal(program); - MethodDeclaration md = (MethodDeclaration)td.Children[0]; - Assert.AreEqual("T", md.TypeReference.Type); - Assert.AreEqual(1, md.Parameters.Count); - Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); - Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); - - Assert.AreEqual(1, md.Templates.Count); - Assert.AreEqual("T", md.Templates[0].Name); - Assert.AreEqual(1, md.Templates[0].Bases.Count); - Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); - } - - [Test] - public void VBNetGenericVoidMethodInInterface() - { - const string program = @"interface MyInterface - Sub MyMethod(Of T As {ISomeInterface})(a as T) -End Interface -"; - TypeDeclaration td = ParseUtil.ParseGlobal(program); - MethodDeclaration md = (MethodDeclaration)td.Children[0]; - Assert.AreEqual("System.Void", md.TypeReference.Type); - Assert.AreEqual(1, md.Parameters.Count); - Assert.AreEqual("T", ((ParameterDeclarationExpression)md.Parameters[0]).TypeReference.Type); - Assert.AreEqual("a", ((ParameterDeclarationExpression)md.Parameters[0]).ParameterName); - - Assert.AreEqual(1, md.Templates.Count); - Assert.AreEqual("T", md.Templates[0].Name); - Assert.AreEqual(1, md.Templates[0].Bases.Count); - Assert.AreEqual("ISomeInterface", md.Templates[0].Bases[0].Type); - } - - [Test] - public void VBNetMethodWithHandlesClause() - { - MethodDeclaration md = ParseUtil.ParseTypeMember( - @"Public Sub MyMethod(sender As Object, e As EventArgs) Handles x.y - End Sub"); - Assert.AreEqual(new string[] { "x.y" }, md.HandlesClause.ToArray()); - - md = ParseUtil.ParseTypeMember( - @"Public Sub MyMethod() Handles Me.FormClosing - End Sub"); - Assert.AreEqual(new string[] { "Me.FormClosing" }, md.HandlesClause.ToArray()); - - md = ParseUtil.ParseTypeMember( - @"Public Sub MyMethod() Handles MyBase.Event, Button1.Click - End Sub"); - Assert.AreEqual(new string[] { "MyBase.Event", "Button1.Click" }, md.HandlesClause.ToArray()); - } - - [Test] - public void VBNetMethodWithTypeCharactersTest() - { - const string program = @"Public Function Func!(ByVal Param&) - Func! = CSingle(Param&) - End Function"; - - MethodDeclaration md = ParseUtil.ParseTypeMember(program); - Assert.AreEqual(Modifiers.Public, md.Modifier); - } - - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs deleted file mode 100644 index 049f7f464..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/OperatorDeclarationTests.cs +++ /dev/null @@ -1,30 +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 System; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class OperatorDeclarationTests - { - #region VB.NET - - [Test] - public void VBNetImplictOperatorDeclarationTest() - { - string programm = @"Public Shared Operator + (ByVal v As Complex) As Complex - Return v - End Operator"; - - OperatorDeclaration od = ParseUtil.ParseTypeMember(programm); - Assert.IsFalse(od.IsConversionOperator); - Assert.AreEqual(1, od.Parameters.Count); - Assert.AreEqual(ConversionType.None, od.ConversionType); - Assert.AreEqual("Complex", od.TypeReference.Type); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs deleted file mode 100644 index c31f7bb9d..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs +++ /dev/null @@ -1,107 +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 System; -using System.IO; -using ICSharpCode.NRefactory.VB.Ast; -using NUnit.Framework; - -namespace ICSharpCode.NRefactory.VB.Tests.Ast -{ - [TestFixture] - public class PropertyDeclarationTests - { - #region VB.NET - [Test] - public void VBNetSimpleGetSetPropertyDeclarationTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("Property MyProperty As Integer \n Get \n End Get \n Set \n End Set\nEnd Property"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - } - - [Test] - public void VBNetSimpleGetPropertyDeclarationTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("ReadOnly Property MyProperty \nGet\nEnd Get\nEnd Property"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsFalse(pd.HasSetRegion); - Assert.IsTrue((pd.Modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly); - } - - [Test] - public void VBNetSimpleSetPropertyDeclarationTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("WriteOnly Property MyProperty \n Set\nEnd Set\nEnd Property "); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsFalse(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - Assert.IsTrue((pd.Modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly); - } - - [Test] - public void VBNetAutoPropertyTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("Property MyProperty"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - Assert.AreEqual(pd.Initializer, Expression.Null); - } - - [Test] - public void VBNetReadOnlyAutoPropertyTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("ReadOnly Property MyProperty"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsFalse(pd.HasSetRegion); - Assert.AreEqual(pd.Initializer, Expression.Null); - } - - [Test] - public void VBNetWriteOnlyAutoPropertyTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("WriteOnly Property MyProperty"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsFalse(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - Assert.AreEqual(pd.Initializer, Expression.Null); - } - - [Test] - public void VBNetSimpleInitializerAutoPropertyTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("Property MyProperty = 5"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - Assert.AreEqual(pd.Initializer.ToString(), new PrimitiveExpression(5).ToString()); - } - - [Test] - public void VBNetSimpleInitializerAutoPropertyWithTypeTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("Property MyProperty As Integer = 5"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.AreEqual("System.Int32", pd.TypeReference.Type); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - Assert.AreEqual(pd.Initializer.ToString(), new PrimitiveExpression(5).ToString()); - } - - [Test] - public void VBNetSimpleObjectInitializerAutoPropertyTest() - { - PropertyDeclaration pd = ParseUtil.ParseTypeMember("Property MyProperty As New List"); - Assert.AreEqual("MyProperty", pd.Name); - Assert.AreEqual("List", pd.TypeReference.Type); - Assert.IsTrue(pd.HasGetRegion); - Assert.IsTrue(pd.HasSetRegion); - Assert.AreEqual(pd.Initializer.ToString(), new ObjectCreateExpression(new TypeReference("List"), null).ToString()); - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/AstNode.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/AstNode.cs deleted file mode 100644 index 39b439d74..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/AstNode.cs +++ /dev/null @@ -1,559 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using ICSharpCode.NRefactory.PatternMatching; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB -{ - public abstract class AstNode : AbstractAnnotatable, PatternMatching.INode - { - #region Null - public static readonly AstNode Null = new NullAstNode (); - - sealed class NullAstNode : AstNode - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - #region PatternPlaceholder - public static implicit operator AstNode(PatternMatching.Pattern pattern) - { - return pattern != null ? new PatternPlaceholder(pattern) : null; - } - - sealed class PatternPlaceholder : AstNode, PatternMatching.INode - { - readonly PatternMatching.Pattern child; - - public PatternPlaceholder(PatternMatching.Pattern child) - { - this.child = child; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPatternPlaceholder(this, child, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return child.DoMatch(other, match); - } - - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) - { - return child.DoMatchCollection(role, pos, match, backtrackingInfo); - } - } - #endregion - - AstNode parent; - AstNode prevSibling; - AstNode nextSibling; - AstNode firstChild; - AstNode lastChild; - Role role = RootRole; - - public virtual bool IsNull { - get { - return false; - } - } - - public virtual TextLocation StartLocation { - get { - var child = firstChild; - if (child == null) - return TextLocation.Empty; - return child.StartLocation; - } - } - - public virtual TextLocation EndLocation { - get { - var child = lastChild; - if (child == null) - return TextLocation.Empty; - return child.EndLocation; - } - } - - public AstNode Parent { - get { return parent; } - } - - public Role Role { - get { return role; } - } - - public AstNode NextSibling { - get { return nextSibling; } - } - - public AstNode PrevSibling { - get { return prevSibling; } - } - - public AstNode FirstChild { - get { return firstChild; } - } - - public AstNode LastChild { - get { return lastChild; } - } - - public IEnumerable Children { - get { - AstNode next; - for (AstNode cur = firstChild; cur != null; cur = next) { - Debug.Assert(cur.parent == this); - // Remember next before yielding cur. - // This allows removing/replacing nodes while iterating through the list. - next = cur.nextSibling; - yield return cur; - } - } - } - - /// - /// Gets the ancestors of this node (excluding this node itself) - /// - public IEnumerable Ancestors { - get { - for (AstNode cur = parent; cur != null; cur = cur.parent) { - yield return cur; - } - } - } - - /// - /// Gets all descendants of this node (excluding this node itself). - /// - public IEnumerable Descendants { - get { - return Utils.TreeTraversal.PreOrder(this.Children, n => n.Children); - } - } - - /// - /// Gets all descendants of this node (including this node itself). - /// - public IEnumerable DescendantsAndSelf { - get { - return Utils.TreeTraversal.PreOrder(this, n => n.Children); - } - } - - /// - /// Gets the first child with the specified role. - /// Returns the role's null object if the child is not found. - /// - public T GetChildByRole(Role role) where T : AstNode - { - if (role == null) - throw new ArgumentNullException("role"); - for (var cur = firstChild; cur != null; cur = cur.nextSibling) { - if (cur.role == role) - return (T)cur; - } - return role.NullObject; - } - - public AstNodeCollection GetChildrenByRole(Role role) where T : AstNode - { - return new AstNodeCollection(this, role); - } - - protected void SetChildByRole(Role role, T newChild) where T : AstNode - { - AstNode oldChild = GetChildByRole(role); - if (oldChild.IsNull) - AddChild(newChild, role); - else - oldChild.ReplaceWith(newChild); - } - - public void AddChild(T child, Role role) where T : AstNode - { - if (role == null) - throw new ArgumentNullException("role"); - if (child == null || child.IsNull) - return; - if (this.IsNull) - throw new InvalidOperationException("Cannot add children to null nodes"); - if (child.parent != null) - throw new ArgumentException ("Node is already used in another tree.", "child"); - AddChildUnsafe(child, role); - } - - internal void AddChildUntyped(AstNode child, Role role) - { - if (role == null) - throw new ArgumentNullException("role"); - if (child == null || child.IsNull) - return; - if (this.IsNull) - throw new InvalidOperationException("Cannot add children to null nodes"); - if (child.parent != null) - throw new ArgumentException ("Node is already used in another tree.", "child"); - AddChildUnsafe(child, role); - } - - /// - /// Adds a child without performing any safety checks. - /// - void AddChildUnsafe(AstNode child, Role role) - { - child.parent = this; - child.role = role; - if (firstChild == null) { - lastChild = firstChild = child; - } else { - lastChild.nextSibling = child; - child.prevSibling = lastChild; - lastChild = child; - } - } - - public void InsertChildBefore(AstNode nextSibling, T child, Role role) where T : AstNode - { - if (role == null) - throw new ArgumentNullException("role"); - if (nextSibling == null || nextSibling.IsNull) { - AddChild(child, role); - return; - } - - if (child == null || child.IsNull) - return; - if (child.parent != null) - throw new ArgumentException ("Node is already used in another tree.", "child"); - if (nextSibling.parent != this) - throw new ArgumentException ("NextSibling is not a child of this node.", "nextSibling"); - // No need to test for "Cannot add children to null nodes", - // as there isn't any valid nextSibling in null nodes. - InsertChildBeforeUnsafe(nextSibling, child, role); - } - - - void InsertChildBeforeUnsafe(AstNode nextSibling, AstNode child, Role role) - { - child.parent = this; - child.role = role; - child.nextSibling = nextSibling; - child.prevSibling = nextSibling.prevSibling; - - if (nextSibling.prevSibling != null) { - Debug.Assert(nextSibling.prevSibling.nextSibling == nextSibling); - nextSibling.prevSibling.nextSibling = child; - } else { - Debug.Assert(firstChild == nextSibling); - firstChild = child; - } - nextSibling.prevSibling = child; - } - - public void InsertChildAfter(AstNode prevSibling, T child, Role role) where T : AstNode - { - InsertChildBefore((prevSibling == null || prevSibling.IsNull) ? firstChild : prevSibling.nextSibling, child, role); - } - - /// - /// Removes this node from its parent. - /// - public void Remove() - { - if (parent != null) { - if (prevSibling != null) { - Debug.Assert(prevSibling.nextSibling == this); - prevSibling.nextSibling = nextSibling; - } else { - Debug.Assert(parent.firstChild == this); - parent.firstChild = nextSibling; - } - if (nextSibling != null) { - Debug.Assert(nextSibling.prevSibling == this); - nextSibling.prevSibling = prevSibling; - } else { - Debug.Assert(parent.lastChild == this); - parent.lastChild = prevSibling; - } - parent = null; - role = Roles.Root; - prevSibling = null; - nextSibling = null; - } - } - - /// - /// Replaces this node with the new node. - /// - public void ReplaceWith(AstNode newNode) - { - if (newNode == null || newNode.IsNull) { - Remove(); - return; - } - if (newNode == this) - return; // nothing to do... - if (parent == null) { - throw new InvalidOperationException(this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); - } - // Because this method doesn't statically check the new node's type with the role, - // we perform a runtime test: - if (!role.IsValid(newNode)) { - throw new ArgumentException (string.Format("The new node '{0}' is not valid in the role {1}", newNode.GetType().Name, role.ToString()), "newNode"); - } - if (newNode.parent != null) { - // newNode is used within this tree? - if (newNode.Ancestors.Contains(this)) { - // e.g. "parenthesizedExpr.ReplaceWith(parenthesizedExpr.Expression);" - // enable automatic removal - newNode.Remove(); - } else { - throw new ArgumentException ("Node is already used in another tree.", "newNode"); - } - } - - newNode.parent = parent; - newNode.role = role; - newNode.prevSibling = prevSibling; - newNode.nextSibling = nextSibling; - if (parent != null) { - if (prevSibling != null) { - Debug.Assert(prevSibling.nextSibling == this); - prevSibling.nextSibling = newNode; - } else { - Debug.Assert(parent.firstChild == this); - parent.firstChild = newNode; - } - if (nextSibling != null) { - Debug.Assert(nextSibling.prevSibling == this); - nextSibling.prevSibling = newNode; - } else { - Debug.Assert(parent.lastChild == this); - parent.lastChild = newNode; - } - parent = null; - prevSibling = null; - nextSibling = null; - role = Roles.Root; - } - } - - public AstNode ReplaceWith(Func replaceFunction) - { - if (replaceFunction == null) - throw new ArgumentNullException("replaceFunction"); - if (parent == null) { - throw new InvalidOperationException(this.IsNull ? "Cannot replace the null nodes" : "Cannot replace the root node"); - } - AstNode oldParent = parent; - AstNode oldSuccessor = nextSibling; - Role oldRole = role; - Remove(); - AstNode replacement = replaceFunction(this); - if (oldSuccessor != null && oldSuccessor.parent != oldParent) - throw new InvalidOperationException("replace function changed nextSibling of node being replaced?"); - if (!(replacement == null || replacement.IsNull)) { - if (replacement.parent != null) - throw new InvalidOperationException("replace function must return the root of a tree"); - if (!oldRole.IsValid(replacement)) { - throw new InvalidOperationException (string.Format("The new node '{0}' is not valid in the role {1}", replacement.GetType().Name, oldRole.ToString())); - } - - if (oldSuccessor != null) - oldParent.InsertChildBeforeUnsafe(oldSuccessor, replacement, oldRole); - else - oldParent.AddChildUnsafe(replacement, oldRole); - } - return replacement; - } - - /// - /// Clones the whole subtree starting at this AST node. - /// - /// Annotations are copied over to the new nodes; and any annotations implementating ICloneable will be cloned. - public AstNode Clone() - { - AstNode copy = (AstNode)MemberwiseClone(); - // First, reset the shallow pointer copies - copy.parent = null; - copy.role = Roles.Root; - copy.firstChild = null; - copy.lastChild = null; - copy.prevSibling = null; - copy.nextSibling = null; - - // Then perform a deep copy: - for (AstNode cur = firstChild; cur != null; cur = cur.nextSibling) { - copy.AddChildUnsafe(cur.Clone(), cur.role); - } - - // Finally, clone the annotation, if necessary - copy.CloneAnnotations(); - - return copy; - } - - public override void AddAnnotation (object annotation) - { - if (this.IsNull) - throw new InvalidOperationException("Cannot add annotations to the null node"); - base.AddAnnotation (annotation); - } - - public abstract S AcceptVisitor (IAstVisitor visitor, T data); - - #region Pattern Matching - protected static bool MatchString(string name1, string name2) - { - return string.IsNullOrEmpty(name1) || string.Equals(name1, name2, StringComparison.OrdinalIgnoreCase); - } - - protected static bool MatchStringXml(string name1, string name2) - { - return string.IsNullOrEmpty(name1) || string.Equals(name1, name2, StringComparison.Ordinal); - } - - protected internal abstract bool DoMatch(AstNode other, PatternMatching.Match match); - - bool PatternMatching.INode.DoMatch(PatternMatching.INode other, PatternMatching.Match match) - { - AstNode o = other as AstNode; - // try matching if other is null, or if other is an AstNode - return (other == null || o != null) && DoMatch(o, match); - } - - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) - { - AstNode o = pos as AstNode; - return (pos == null || o != null) && DoMatch (o, match); - } - - PatternMatching.INode PatternMatching.INode.NextSibling { - get { return nextSibling; } - } - - PatternMatching.INode PatternMatching.INode.FirstChild { - get { return firstChild; } - } - #endregion - - public AstNode GetNextNode () - { - if (NextSibling != null) - return NextSibling; - if (Parent != null) - return Parent.GetNextNode (); - return null; - } - - public AstNode GetPrevNode () - { - if (PrevSibling != null) - return PrevSibling; - if (Parent != null) - return Parent.GetPrevNode (); - return null; - } - - // filters all non VB nodes (comments, white spaces or pre processor directives) - public AstNode GetVBNodeBefore (AstNode node) - { - var n = node.PrevSibling; - while (n != null) { - if (n.Role != Roles.Comment) - return n; - n = n.GetPrevNode (); - } - return null; - } - - // the Root role must be available when creating the null nodes, so we can't put it in the Roles class - static readonly Role RootRole = new Role("Root"); - - public static class Roles - { - /// - /// Root of an abstract syntax tree. - /// - public static readonly Role Root = RootRole; - - // some pre defined constants for common roles - public static readonly Role Identifier = new Role("Identifier", Ast.Identifier.Null); - public static readonly Role XmlIdentifier = new Role("XmlIdentifier", Ast.XmlIdentifier.Null); - public static readonly Role XmlLiteralString = new Role("XmlLiteralString", Ast.XmlLiteralString.Null); - - public static readonly Role Body = new Role("Body", Ast.BlockStatement.Null); - 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", Ast.Expression.Null); - public readonly static Role Condition = new Role("Condition", Ast.Expression.Null); -// - public static readonly Role TypeParameter = new Role("TypeParameter"); - public static readonly Role TypeArgument = new Role("TypeArgument", AstType.Null); -// public static readonly Role Variable = new Role("Variable"); -// public static readonly Role EmbeddedStatement = new Role("EmbeddedStatement", CSharp.Statement.Null); -// - public static readonly Role Keyword = new Role("Keyword", VBTokenNode.Null); -// public static readonly Role InKeyword = new Role("InKeyword", VBTokenNode.Null); - - // some pre defined constants for most used punctuation - public static readonly Role LPar = new Role("LPar", VBTokenNode.Null); - public static readonly Role RPar = new Role("RPar", VBTokenNode.Null); - public static readonly Role LBracket = new Role("LBracket", VBTokenNode.Null); - public static readonly Role RBracket = new Role("RBracket", VBTokenNode.Null); - public static readonly Role LBrace = new Role("LBrace", VBTokenNode.Null); - public static readonly Role RBrace = new Role("RBrace", VBTokenNode.Null); - public static readonly Role LChevron = new Role("LChevron", VBTokenNode.Null); - public static readonly Role RChevron = new Role("RChevron", VBTokenNode.Null); - public static readonly Role Comma = new Role("Comma", VBTokenNode.Null); - public static readonly Role QuestionMark = new Role("QuestionMark", VBTokenNode.Null); - public static readonly Role Dot = new Role("Dot", VBTokenNode.Null); - public static readonly Role Semicolon = new Role("Semicolon", VBTokenNode.Null); - public static readonly Role Assign = new Role("Assign", VBTokenNode.Null); - public static readonly Role Colon = new Role("Colon", VBTokenNode.Null); - public static readonly Role StatementTerminator = new Role("StatementTerminator", VBTokenNode.Null); - - // XML - /// - /// Text: < - /// - public static readonly Role XmlOpenTag = new Role("XmlOpenTag", VBTokenNode.Null); - /// - /// Text: > - /// - public static readonly Role XmlCloseTag = new Role("XmlOpenTag", VBTokenNode.Null); - - public static readonly Role Comment = new Role("Comment"); - - } - } - - -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/AstNodeCollection.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/AstNodeCollection.cs deleted file mode 100644 index fd1265220..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/AstNodeCollection.cs +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; - -using ICSharpCode.NRefactory.PatternMatching; - -namespace ICSharpCode.NRefactory.VB -{ - /// - /// Represents the children of an AstNode that have a specific role. - /// - public class AstNodeCollection : ICollection where T : AstNode - { - readonly AstNode node; - readonly Role role; - - public AstNodeCollection(AstNode node, Role role) - { - if (node == null) - throw new ArgumentNullException("node"); - if (role == null) - throw new ArgumentNullException("role"); - this.node = node; - this.role = role; - } - - public int Count { - get { - int count = 0; - for (AstNode cur = node.FirstChild; cur != null; cur = cur.NextSibling) { - if (cur.Role == role) - count++; - } - return count; - } - } - - public void Add(T element) - { - node.AddChild(element, role); - } - - public void AddRange(IEnumerable nodes) - { - // Evaluate 'nodes' first, since it might change when we add the new children - // Example: collection.AddRange(collection); - if (nodes != null) { - foreach (T node in nodes.ToList()) - Add(node); - } - } - - public void AddRange(T[] nodes) - { - // Fast overload for arrays - we don't need to create a copy - if (nodes != null) { - foreach (T node in nodes) - Add(node); - } - } - - public void ReplaceWith(IEnumerable nodes) - { - // Evaluate 'nodes' first, since it might change when we call Clear() - // Example: collection.ReplaceWith(collection); - if (nodes != null) - nodes = nodes.ToList(); - Clear(); - foreach (T node in nodes) - Add(node); - } - - public void MoveTo(ICollection targetCollection) - { - foreach (T node in this) { - node.Remove(); - targetCollection.Add(node); - } - } - - public bool Contains(T element) - { - return element != null && element.Parent == node && element.Role == role; - } - - public bool Remove(T element) - { - if (Contains(element)) { - element.Remove(); - return true; - } else { - return false; - } - } - - public void CopyTo(T[] array, int arrayIndex) - { - foreach (T item in this) - array[arrayIndex++] = item; - } - - public void Clear() - { - foreach (T item in this) - item.Remove(); - } - - bool ICollection.IsReadOnly { - get { return false; } - } - - public IEnumerator GetEnumerator() - { - AstNode next; - for (AstNode cur = node.FirstChild; cur != null; cur = next) { - Debug.Assert(cur.Parent == node); - // Remember next before yielding cur. - // This allows removing/replacing nodes while iterating through the list. - next = cur.NextSibling; - if (cur.Role == role) - yield return (T)cur; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - #region Equals and GetHashCode implementation - public override int GetHashCode() - { - return node.GetHashCode() ^ role.GetHashCode(); - } - - public override bool Equals(object obj) - { - AstNodeCollection other = obj as AstNodeCollection; - if (other == null) - return false; - return this.node == other.node && this.role == other.role; - } - #endregion - - internal bool DoMatch(AstNodeCollection other, Match match) - { - // TODO : does not compile (ask Daniel)! -// Stack patternStack = new Stack(); -// Stack stack = new Stack(); -// patternStack.Push(this.node.FirstChild); -// stack.Push(new Pattern.PossibleMatch(other.node.FirstChild, match.CheckPoint())); -// while (stack.Count > 0) { -// AstNode cur1 = patternStack.Pop(); -// AstNode cur2 = stack.Peek().NextOther; -// match.RestoreCheckPoint(stack.Pop().Checkpoint); -// bool success = true; -// while (cur1 != null && success) { -// while (cur1 != null && cur1.Role != role) -// cur1 = cur1.NextSibling; -// while (cur2 != null && cur2.Role != role) -// cur2 = cur2.NextSibling; -// if (cur1 == null) -// break; -// -// Debug.Assert(stack.Count == patternStack.Count); -// success = cur1.DoMatchCollection(role, cur2, match, stack); -// Debug.Assert(stack.Count >= patternStack.Count); -// while (stack.Count > patternStack.Count) -// patternStack.Push(cur1.NextSibling); -// -// cur1 = cur1.NextSibling; -// if (cur2 != null) -// cur2 = cur2.NextSibling; -// } -// while (cur2 != null && cur2.Role != role) -// cur2 = cur2.NextSibling; -// if (success && cur2 == null) -// return true; -// } -// return false; - throw new NotImplementedException(); - } - - public void InsertAfter(T existingItem, T newItem) - { - node.InsertChildAfter(existingItem, newItem, role); - } - - public void InsertBefore(T existingItem, T newItem) - { - node.InsertChildBefore(existingItem, newItem, role); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Comment.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Comment.cs deleted file mode 100644 index fc3a600d8..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Comment.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Threading; -using ICSharpCode.NRefactory.PatternMatching; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB -{ - public class Comment : AstNode - { - public bool IsDocumentationComment { get; set; } - - public bool StartsLine { - get; - set; - } - - public string Content { - get; - set; - } - - TextLocation startLocation; - public override TextLocation StartLocation { - get { - return startLocation; - } - } - - TextLocation endLocation; - public override TextLocation EndLocation { - get { - return endLocation; - } - } - - public Comment (string content, bool isDocumentation = false) - { - this.IsDocumentationComment = isDocumentation; - this.Content = content; - } - - public Comment (bool isDocumentation, TextLocation startLocation, TextLocation endLocation) - { - this.IsDocumentationComment = isDocumentation; - this.startLocation = startLocation; - this.endLocation = endLocation; - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitComment(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - Comment o = other as Comment; - return o != null && this.IsDocumentationComment == o.IsDocumentationComment && MatchString(this.Content, o.Content); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Enums.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Enums.cs deleted file mode 100644 index 02df4d636..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Enums.cs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - [Flags] - public enum Modifiers - { - None = 0x0000, - - // Accessibility - Private = 0x0001, - Friend = 0x0002, - Protected = 0x0004, - Public = 0x0008, - - // Scope - MustInherit = 0x0010, // Types - MustOverride = 0x0020, // Members - Overridable = 0x0040, - NotInheritable = 0x0080, // Types - NotOverridable = 0x0100, // Members - Const = 0x0200, - Shared = 0x0400, - Static = 0x0800, - Overrides = 0x1000, - ReadOnly = 0x2000, - Shadows = 0x4000, - Partial = 0x8000, - - // Special - Overloads = 0x10000, // VB specific - WithEvents = 0x20000, // VB specific - Default = 0x40000, // VB specific - - Dim = 0x80000, // VB.NET SPECIFIC, for fields/local variables only - - /// Only for VB properties. - WriteOnly = 0x100000, // VB specific - - ByVal = 0x200000, - ByRef = 0x400000, - ParamArray = 0x800000, - Optional = 0x1000000, - - Narrowing = 0x2000000, - Widening = 0x4000000, - - Iterator = 0x8000000, - Async = 0x10000000, - - /// - /// Special value used to match any modifiers during pattern matching. - /// - Any = unchecked((int)0x80000000) - } - - public enum ParentType - { - ClassOrStruct, - InterfaceOrEnum, - Namespace, - Unknown - } - - public enum FieldDirection - { - None, - In, - Out, - Ref - } - - public enum AssignmentOperatorType - { - None, - Assign, - - Add, - Subtract, - Multiply, - Divide, - - Power, // (VB only) - DivideInteger, // (VB only) - ConcatString, // (VB only) - - ShiftLeft, - ShiftRight, - } - - public enum ContinueType - { - None, - Do, - For, - While - } - - public enum ConditionType - { - None, - LoopUntil, - LoopWhile, - DoUntil, - DoWhile - } - - public enum ConversionType - { - None, - Implicit, - Explicit - } - - /// - /// Specifies the ordering direction of a QueryExpressionOrdering node. - /// - public enum QueryOrderingDirection - { - None, - Ascending, - Descending - } - - /// - /// Specifies the partition type for a VB.NET - /// query expression. - /// - public enum PartitionKind - { - Take, - TakeWhile, - Skip, - SkipWhile - } - - public enum XmlAxisType - { - Element, // . - Attribute, // .@ - Descendents // ... - } - - public enum XmlContentType - { - Comment, - Text, - CData, - ProcessingInstruction - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/AnonymousObjectCreationExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/AnonymousObjectCreationExpression.cs deleted file mode 100644 index ac3f8d0da..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/AnonymousObjectCreationExpression.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class AnonymousObjectCreationExpression : Expression - { - public AstNodeCollection Initializer { - get { return GetChildrenByRole(Roles.Expression); } - } - - public AnonymousObjectCreationExpression () - { - } - - public AnonymousObjectCreationExpression (IEnumerable initializer) - { - foreach (var ini in initializer) { - AddChild (ini, Roles.Expression); - } - } - - public AnonymousObjectCreationExpression (params Expression[] initializer) : this ((IEnumerable)initializer) - { - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitAnonymousObjectCreationExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - var o = other as AnonymousObjectCreationExpression; - return o != null && this.Initializer.DoMatch(o.Initializer, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs deleted file mode 100644 index b3f580894..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayCreateExpression.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// New Type[Dimensions] - /// - public class ArrayCreateExpression : Expression - { - public readonly static Role AdditionalArraySpecifierRole = new Role("AdditionalArraySpecifier"); - public readonly static Role InitializerRole = new Role("Initializer", ArrayInitializerExpression.Null); - - public AstType Type { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole (Roles.Type, value); } - } - - public AstNodeCollection Arguments { - get { return GetChildrenByRole (Roles.Argument); } - } - - /// - /// Gets additional array ranks (those without size info). - /// Empty for "New Integer(5,1)"; will contain a single element for "New Integer(5)()". - /// - public AstNodeCollection AdditionalArraySpecifiers { - get { return GetChildrenByRole(AdditionalArraySpecifierRole); } - } - - public ArrayInitializerExpression Initializer { - get { return GetChildByRole (InitializerRole); } - set { SetChildByRole (InitializerRole, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitArrayCreateExpression (this, data); - } - - 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.AdditionalArraySpecifiers.DoMatch(o.AdditionalArraySpecifiers, match) && this.Initializer.DoMatch(o.Initializer, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayInitializerExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayInitializerExpression.cs deleted file mode 100644 index 785f2c19b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ArrayInitializerExpression.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// { Elements } - /// - public class ArrayInitializerExpression : Expression - { - #region Null - public new static readonly ArrayInitializerExpression Null = new NullArrayInitializerExpression (); - - sealed class NullArrayInitializerExpression : ArrayInitializerExpression - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - public readonly static Role InitializerRole = new Role("Initializer", ArrayInitializerExpression.Null); - - public AstNodeCollection Elements { - get { return GetChildrenByRole(Roles.Expression); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitArrayInitializerExpression (this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ArrayInitializerExpression o = other as ArrayInitializerExpression; - return o != null && this.Elements.DoMatch(o.Elements, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/AssignmentExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/AssignmentExpression.cs deleted file mode 100644 index bab517a57..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/AssignmentExpression.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class AssignmentExpression : Expression - { - public readonly static Role LeftExpressionRole = BinaryOperatorExpression.LeftExpressionRole; - public readonly static Role OperatorRole = BinaryOperatorExpression.OperatorRole; - public readonly static Role RightExpressionRole = BinaryOperatorExpression.RightExpressionRole; - - public AssignmentExpression(Expression left, AssignmentOperatorType type, Expression right) - { - AddChild(left, LeftExpressionRole); - AddChild(right, RightExpressionRole); - Operator = type; - } - - public Expression Left { - get { return GetChildByRole(LeftExpressionRole); } - set { SetChildByRole(LeftExpressionRole, value); } - } - - public AssignmentOperatorType Operator { get; set; } - - public Expression Right { - get { return GetChildByRole(RightExpressionRole); } - set { SetChildByRole(RightExpressionRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAssignmentExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/BinaryOperatorExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/BinaryOperatorExpression.cs deleted file mode 100644 index b83a0909f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/BinaryOperatorExpression.cs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class BinaryOperatorExpression : Expression - { - public readonly static Role LeftExpressionRole = new Role("Left"); - public readonly static Role OperatorRole = new Role("Operator"); - public readonly static Role RightExpressionRole = new Role("Right"); - - public BinaryOperatorExpression(Expression left, BinaryOperatorType type, Expression right) - { - AddChild(left, LeftExpressionRole); - AddChild(right, RightExpressionRole); - Operator = type; - } - - public Expression Left { - get { return GetChildByRole(LeftExpressionRole); } - set { SetChildByRole(LeftExpressionRole, value); } - } - - public BinaryOperatorType Operator { get; set; } - - public Expression Right { - get { return GetChildByRole(RightExpressionRole); } - set { SetChildByRole(RightExpressionRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitBinaryOperatorExpression(this, data); - } - } - - public enum BinaryOperatorType - { - None, - - /// '&' in C#, 'And' in VB. - BitwiseAnd, - /// '|' in C#, 'Or' in VB. - BitwiseOr, - /// '&&' in C#, 'AndAlso' in VB. - LogicalAnd, - /// '||' in C#, 'OrElse' in VB. - LogicalOr, - /// '^' in C#, 'Xor' in VB. - ExclusiveOr, - - /// > - GreaterThan, - /// >= - GreaterThanOrEqual, - /// '==' in C#, '=' in VB. - Equality, - /// '!=' in C#, '<>' in VB. - InEquality, - /// < - LessThan, - /// <= - LessThanOrEqual, - - /// + - Add, - /// - - Subtract, - /// * - Multiply, - /// / - Divide, - /// '%' in C#, 'Mod' in VB. - Modulus, - /// VB-only: \ - DivideInteger, - /// VB-only: ^ - Power, - /// VB-only: & - Concat, - - /// C#: << - ShiftLeft, - /// C#: >> - ShiftRight, - /// VB-only: Is - ReferenceEquality, - /// VB-only: IsNot - ReferenceInequality, - - /// VB-only: Like - Like, - /// - /// C#: ?? - /// VB: IF(x, y) - /// - NullCoalescing, - - /// VB-only: ! - DictionaryAccess - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/CastExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/CastExpression.cs deleted file mode 100644 index 5cdbd3fa6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/CastExpression.cs +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// CastType(Expression, AstType) - /// - public class CastExpression : Expression - { - public CastType CastType { get; set; } - - public VBTokenNode CastTypeToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public AstType Type { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole (Roles.Type, value); } - } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public CastExpression () - { - } - - public CastExpression (CastType castType, AstType castToType, Expression expression) - { - CastType = castType; - AddChild (castToType, Roles.Type); - AddChild (expression, Roles.Expression); - } - - public CastExpression (CastType castType, Expression expression) - { - CastType = castType; - AddChild (expression, Roles.Expression); - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitCastExpression (this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - CastExpression o = other as CastExpression; - return o != null && this.CastType == o.CastType && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); - } - } - - public enum CastType - { - DirectCast, - TryCast, - CType, - CBool, - CByte, - CChar, - CDate, - CDec, - CDbl, - CInt, - CLng, - CObj, - CSByte, - CShort, - CSng, - CStr, - CUInt, - CULng, - CUShort - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs deleted file mode 100644 index 711341d0c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/CollectionRangeVariableDeclaration.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Identifier As Type In Expression - /// - public class CollectionRangeVariableDeclaration : AstNode - { - public static readonly Role CollectionRangeVariableDeclarationRole = new Role("CollectionRangeVariableDeclaration"); - - public VariableIdentifier Identifier { - get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } - set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } - } - - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitCollectionRangeVariableDeclaration(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - CollectionRangeVariableDeclaration o = other as CollectionRangeVariableDeclaration; - return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ConditionalExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ConditionalExpression.cs deleted file mode 100644 index 4b53d5663..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ConditionalExpression.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class ConditionalExpression : Expression - { - public readonly static Role ConditionExpressionRole = new Role("ConditionExpressionRole", Expression.Null); - public readonly static Role TrueExpressionRole = new Role("TrueExpressionRole", Expression.Null); - public readonly static Role FalseExpressionRole = new Role("FalseExpressionRole", Expression.Null); - - public VBTokenNode IfToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public Expression ConditionExpression { - get { return GetChildByRole (ConditionExpressionRole); } - set { SetChildByRole (ConditionExpressionRole, value); } - } - - public Expression TrueExpression { - get { return GetChildByRole (TrueExpressionRole); } - set { SetChildByRole (TrueExpressionRole, value); } - } - - public Expression FalseExpression { - get { return GetChildByRole (FalseExpressionRole); } - set { SetChildByRole (FalseExpressionRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitConditionalExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/EmptyExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/EmptyExpression.cs deleted file mode 100644 index 01b2f140e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/EmptyExpression.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this -// software and associated documentation files (the "Software"), to deal in the Software -// without restriction, including without limitation the rights to use, copy, modify, merge, -// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons -// to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or -// substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR -// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE -// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class EmptyExpression : Expression - { - TextLocation location; - - public override TextLocation StartLocation { - get { - return location; - } - } - - public override TextLocation EndLocation { - get { - return location; - } - } - - public EmptyExpression() - { - } - - public EmptyExpression(TextLocation location) - { - this.location = location; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitEmptyExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - var o = other as EmptyExpression; - return o != null; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/Expression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/Expression.cs deleted file mode 100644 index dad5cd933..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/Expression.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public abstract class Expression : AstNode - { - #region Null - public new static readonly Expression Null = new NullExpression (); - - sealed class NullExpression : Expression - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - #region Builder methods - /// - /// Builds an member reference expression using this expression as target. - /// - public MemberAccessExpression Member(string memberName) - { - return new MemberAccessExpression { Target = this, MemberName = memberName }; - } - - /// - /// Builds an invocation expression using this expression as target. - /// - public InvocationExpression Invoke(string methodName, IEnumerable arguments) - { - return Invoke(methodName, null, arguments); - } - - /// - /// Builds an invocation expression using this expression as target. - /// - public InvocationExpression Invoke(string methodName, params Expression[] arguments) - { - return Invoke(methodName, null, arguments); - } - - /// - /// Builds an invocation expression using this expression as target. - /// - public InvocationExpression Invoke(string methodName, IEnumerable typeArguments, IEnumerable arguments) - { - InvocationExpression ie = new InvocationExpression(); - MemberAccessExpression mre = new MemberAccessExpression(); - mre.Target = this; - mre.MemberName = methodName; - mre.TypeArguments.AddRange(typeArguments); - ie.Target = mre; - ie.Arguments.AddRange(arguments); - return ie; - } - - /// - /// Builds an invocation expression using this expression as target. - /// - public InvocationExpression Invoke(IEnumerable arguments) - { - InvocationExpression ie = new InvocationExpression(); - ie.Target = this; - ie.Arguments.AddRange(arguments); - return ie; - } - - /// - /// Builds an invocation expression using this expression as target. - /// - public InvocationExpression Invoke(params Expression[] arguments) - { - InvocationExpression ie = new InvocationExpression(); - ie.Target = this; - ie.Arguments.AddRange(arguments); - return ie; - } - - public CastExpression CastTo(AstType type) - { - return new CastExpression { CastType = CastType.CType, Type = type, Expression = this }; - } - - public CastExpression CastTo(Type type) - { - return new CastExpression { CastType = CastType.CType, Type = AstType.Create(type), Expression = this }; - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/FieldInitializerExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/FieldInitializerExpression.cs deleted file mode 100644 index bc77666c8..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/FieldInitializerExpression.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 MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// [ Key ] .Identifier = Expression - /// - public class FieldInitializerExpression : Expression - { - public bool IsKey { get; set; } - - public VBTokenNode KeyToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public VBTokenNode DotToken { - get { return GetChildByRole (Roles.Dot); } - } - - public Identifier Identifier { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public VBTokenNode AssignToken { - get { return GetChildByRole (Roles.Assign); } - } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitFieldInitializerExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - FieldInitializerExpression o = other as FieldInitializerExpression; - return o != null && this.IsKey == o.IsKey && this.Identifier.DoMatch(o.Identifier, match) && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/GetTypeExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/GetTypeExpression.cs deleted file mode 100644 index 573d1cf8b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/GetTypeExpression.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class GetTypeExpression : Expression - { - public GetTypeExpression() - { - } - - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as GetTypeExpression; - return expr != null && - Type.DoMatch(expr.Type, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitGetTypeExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/GetXmlNamespaceExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/GetXmlNamespaceExpression.cs deleted file mode 100644 index 390281d3f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/GetXmlNamespaceExpression.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class GetXmlNamespaceExpression : Expression - { - public GetXmlNamespaceExpression(XmlIdentifier namespaceName) - { - SetChildByRole(Roles.XmlIdentifier, namespaceName); - } - - public XmlIdentifier NamespaceName { - get { return GetChildByRole(Roles.XmlIdentifier); } - set { SetChildByRole(Roles.XmlIdentifier, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as GetXmlNamespaceExpression; - return expr != null && - NamespaceName.DoMatch(expr.NamespaceName, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitGetXmlNamespaceExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/IdentifierExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/IdentifierExpression.cs deleted file mode 100644 index 6bd77cb9b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/IdentifierExpression.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class IdentifierExpression : Expression - { - public IdentifierExpression() - { - - } - - public IdentifierExpression(Identifier identifier) - { - this.Identifier = identifier; - } - - public Identifier Identifier { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public AstNodeCollection TypeArguments { - get { return GetChildrenByRole(Roles.TypeArgument); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitIdentifierExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/InstanceExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/InstanceExpression.cs deleted file mode 100644 index 321d387e9..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/InstanceExpression.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of InstanceExpression. - /// - public class InstanceExpression : Expression - { - TextLocation location; - - public InstanceExpression(InstanceExpressionType type, TextLocation location) - { - this.Type = type; - this.location = location; - } - - public override TextLocation StartLocation { - get { return location; } - } - - public override TextLocation EndLocation { - get { - switch (Type) { - case InstanceExpressionType.Me: - return new TextLocation(location.Line, location.Column + "Me".Length); - case InstanceExpressionType.MyBase: - return new TextLocation(location.Line, location.Column + "MyBase".Length); - case InstanceExpressionType.MyClass: - return new TextLocation(location.Line, location.Column + "MyClass".Length); - default: - throw new Exception("Invalid value for InstanceExpressionType"); - } - } - } - - public InstanceExpressionType Type { get; set; } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as InstanceExpression; - return expr != null && - Type == expr.Type; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitInstanceExpression(this, data); - } - } - - public enum InstanceExpressionType - { - Me, - MyBase, - MyClass - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/InvocationExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/InvocationExpression.cs deleted file mode 100644 index 6a81c0376..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/InvocationExpression.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Target(Arguments) - /// - public class InvocationExpression : Expression - { - public Expression Target { - get { return GetChildByRole (Roles.TargetExpression); } - set { SetChildByRole(Roles.TargetExpression, value); } - } - - public AstNodeCollection Arguments { - get { return GetChildrenByRole(Roles.Argument); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitInvocationExpression(this, data); - } - - public InvocationExpression () - { - } - - public InvocationExpression (Expression target, IEnumerable arguments) - { - AddChild (target, Roles.TargetExpression); - if (arguments != null) { - foreach (var arg in arguments) { - AddChild (arg, Roles.Argument); - } - } - } - - public InvocationExpression (Expression target, params Expression[] arguments) : this (target, (IEnumerable)arguments) - { - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - InvocationExpression o = other as InvocationExpression; - return o != null && this.Target.DoMatch(o.Target, match) && this.Arguments.DoMatch(o.Arguments, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/LambdaExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/LambdaExpression.cs deleted file mode 100644 index fe238367b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/LambdaExpression.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public abstract class LambdaExpression : Expression - { - public static readonly Role ModifierRole = AttributedNode.ModifierRole; - - public LambdaExpressionModifiers Modifiers { - get { return GetModifiers(this); } - set { SetModifiers(this, value); } - } - - public AstNodeCollection ModifierTokens { - get { return GetChildrenByRole (ModifierRole); } - } - - internal static LambdaExpressionModifiers GetModifiers(AstNode node) - { - LambdaExpressionModifiers m = 0; - foreach (VBModifierToken t in node.GetChildrenByRole (ModifierRole)) { - m |= (LambdaExpressionModifiers)t.Modifier; - } - return m; - } - - internal static void SetModifiers(AstNode node, LambdaExpressionModifiers newValue) - { - LambdaExpressionModifiers oldValue = GetModifiers(node); - AstNode insertionPos = null; - foreach (Modifiers m in VBModifierToken.AllModifiers) { - if ((m & (Modifiers)newValue) != 0) { - if ((m & (Modifiers)oldValue) == 0) { - // Modifier was added - var newToken = new VBModifierToken(TextLocation.Empty, m); - node.InsertChildAfter(insertionPos, newToken, ModifierRole); - insertionPos = newToken; - } else { - // Modifier already exists - insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m); - } - } else { - if ((m & (Modifiers)oldValue) != 0) { - // Modifier was removed - node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == m).Remove(); - } - } - } - } - - public AstNodeCollection Parameters { - get { return GetChildrenByRole(Roles.Parameter); } - } - } - - public class SingleLineSubLambdaExpression : LambdaExpression - { - public static readonly Role StatementRole = BlockStatement.StatementRole; - - public Statement EmbeddedStatement { - get { return GetChildByRole(StatementRole); } - set { SetChildByRole(StatementRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitSingleLineSubLambdaExpression(this, data); - } - } - - public class SingleLineFunctionLambdaExpression : LambdaExpression - { - public Expression EmbeddedExpression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitSingleLineFunctionLambdaExpression(this, data); - } - } - - public class MultiLineLambdaExpression : LambdaExpression - { - public bool IsSub { get; set; } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitMultiLineLambdaExpression(this, data); - } - } - - public enum LambdaExpressionModifiers - { - Async = Modifiers.Async, - Iterator = Modifiers.Iterator - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/MemberAccessExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/MemberAccessExpression.cs deleted file mode 100644 index 17e805775..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/MemberAccessExpression.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class MemberAccessExpression : Expression - { - public MemberAccessExpression() - { - } - - public Expression Target { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public Identifier MemberName { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public AstNodeCollection TypeArguments { - get { return GetChildrenByRole(Roles.TypeArgument); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as MemberAccessExpression; - return expr != null && - Target.DoMatch(expr.Target, match) && - MemberName.DoMatch(expr.MemberName, match) && - TypeArguments.DoMatch(expr.TypeArguments, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitMemberAccessExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/NamedArgumentExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/NamedArgumentExpression.cs deleted file mode 100644 index 730eaafaf..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/NamedArgumentExpression.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Represents a named argument passed to a method or attribute. - /// - public class NamedArgumentExpression : Expression - { - public Identifier Identifier { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public VBTokenNode AssignToken { - get { return GetChildByRole (Roles.Assign); } - } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitNamedArgumentExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - NamedArgumentExpression o = other as NamedArgumentExpression; - return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ObjectCreationExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ObjectCreationExpression.cs deleted file mode 100644 index 6e28b292d..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ObjectCreationExpression.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// New Type(Arguments) { Initializer } - /// - public class ObjectCreationExpression : Expression - { - public readonly static Role InitializerRole = ArrayInitializerExpression.InitializerRole; - - public AstType Type { - get { return GetChildByRole (Roles.Type); } - set { SetChildByRole (Roles.Type, value); } - } - - public AstNodeCollection Arguments { - get { return GetChildrenByRole (Roles.Argument); } - } - - public ArrayInitializerExpression Initializer { - get { return GetChildByRole (InitializerRole); } - set { SetChildByRole (InitializerRole, value); } - } - - public ObjectCreationExpression() - { - } - - public ObjectCreationExpression (AstType type, IEnumerable arguments = null) - { - AddChild (type, Roles.Type); - if (arguments != null) { - foreach (var arg in arguments) { - AddChild (arg, Roles.Argument); - } - } - } - - public ObjectCreationExpression (AstType type, params Expression[] arguments) : this (type, (IEnumerable)arguments) - { - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitObjectCreationExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ObjectCreationExpression o = other as ObjectCreationExpression; - return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.Initializer.DoMatch(o.Initializer, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ParenthesizedExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ParenthesizedExpression.cs deleted file mode 100644 index 31c234044..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/ParenthesizedExpression.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of ParenthesizedExpression. - /// - public class ParenthesizedExpression : Expression - { - public ParenthesizedExpression() - { - } - - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as ParenthesizedExpression; - return expr != null && - Expression.DoMatch(expr.Expression, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitParenthesizedExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/PrimitiveExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/PrimitiveExpression.cs deleted file mode 100644 index d1d5f2d1f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/PrimitiveExpression.cs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using ICSharpCode.NRefactory.VB.PrettyPrinter; -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Represents a literal value. - /// - public class PrimitiveExpression : Expression - { - public static readonly object AnyValue = new object(); - - TextLocation startLocation; - public override TextLocation StartLocation { - get { - return startLocation; - } - } - - int length; - public override TextLocation EndLocation { - get { - return new TextLocation(StartLocation.Line, StartLocation.Column + length); - } - } - - public object Value { get; private set; } - - string stringValue; - - public string StringValue { - get { return stringValue ?? OutputVisitor.ToVBNetString(this); } - } - - public PrimitiveExpression(object value) - { - this.Value = value; - } - - public PrimitiveExpression(object value, string stringValue) - { - this.Value = value; - this.stringValue = stringValue; - } - - public PrimitiveExpression(object value, TextLocation startLocation, int length) - { - this.Value = value; - this.startLocation = startLocation; - this.length = length; - } - - public PrimitiveExpression(object value, string stringValue, TextLocation startLocation, int length) - { - this.Value = value; - this.stringValue = stringValue; - this.startLocation = startLocation; - this.length = length; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPrimitiveExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - PrimitiveExpression o = other as PrimitiveExpression; - return o != null && (this.Value == AnyValue || object.Equals(this.Value, o.Value)); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs deleted file mode 100644 index 2701d4e89..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/QueryExpression.cs +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class QueryExpression : Expression - { - public AstNodeCollection QueryOperators { - get { return GetChildrenByRole(QueryOperator.QueryOperatorRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitQueryExpression(this, data); - } - } - - public abstract class QueryOperator : AstNode - { - #region Null - public new static readonly QueryOperator Null = new NullQueryOperator(); - - sealed class NullQueryOperator : QueryOperator - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - public static readonly Role QueryOperatorRole = new Role("QueryOperator", QueryOperator.Null); - } - - public class FromQueryOperator : QueryOperator - { - public AstNodeCollection Variables { - get { return GetChildrenByRole (CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitFromQueryOperator(this, data); - } - } - - public class AggregateQueryOperator : QueryOperator - { - public CollectionRangeVariableDeclaration Variable { - get { return GetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole); } - set { SetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole, value); } - } - - public AstNodeCollection SubQueryOperators { - get { return GetChildrenByRole(QueryOperatorRole); } - } - - public AstNodeCollection IntoExpressions { - get { return GetChildrenByRole(VariableInitializer.VariableInitializerRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAggregateQueryOperator(this, data); - } - } - - public class SelectQueryOperator : QueryOperator - { - public AstNodeCollection Variables { - get { return GetChildrenByRole(VariableInitializer.VariableInitializerRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitSelectQueryOperator(this, data); - } - } - - public class DistinctQueryOperator : QueryOperator - { - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitDistinctQueryOperator(this, data); - } - } - - public class WhereQueryOperator : QueryOperator - { - public Expression Condition { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitWhereQueryOperator(this, data); - } - } - - public class OrderExpression : AstNode - { - public static readonly Role OrderExpressionRole = new Role("OrderExpression"); - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public QueryOrderingDirection Direction { get; set; } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitOrderExpression(this, data); - } - } - - public class OrderByQueryOperator : QueryOperator - { - public AstNodeCollection Expressions { - get { return GetChildrenByRole(OrderExpression.OrderExpressionRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitOrderByQueryOperator(this, data); - } - } - - public class PartitionQueryOperator : QueryOperator - { - public PartitionKind Kind { get; set; } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPartitionQueryOperator(this, data); - } - } - - public class LetQueryOperator : QueryOperator - { - public AstNodeCollection Variables { - get { return GetChildrenByRole(VariableInitializer.VariableInitializerRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitLetQueryOperator(this, data); - } - } - - public class GroupByQueryOperator : QueryOperator - { - public static readonly Role GroupExpressionRole = new Role("GroupExpression"); - public static readonly Role ByExpressionRole = new Role("ByExpression"); - public static readonly Role IntoExpressionRole = new Role("IntoExpression"); - - public AstNodeCollection GroupExpressions { - get { return GetChildrenByRole(GroupExpressionRole); } - } - - public AstNodeCollection ByExpressions { - get { return GetChildrenByRole(ByExpressionRole); } - } - - public AstNodeCollection IntoExpressions { - get { return GetChildrenByRole(IntoExpressionRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitGroupByQueryOperator(this, data); - } - } - - public class JoinQueryOperator : QueryOperator - { - #region Null - public new static readonly JoinQueryOperator Null = new NullJoinQueryOperator(); - - sealed class NullJoinQueryOperator : JoinQueryOperator - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - public static readonly Role JoinQueryOperatorRole = new Role("JoinQueryOperator", JoinQueryOperator.Null); - - public CollectionRangeVariableDeclaration JoinVariable { - get { return GetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole); } - set { SetChildByRole(CollectionRangeVariableDeclaration.CollectionRangeVariableDeclarationRole, value); } - } - - public JoinQueryOperator SubJoinQuery { - get { return GetChildByRole(JoinQueryOperatorRole); } - set { SetChildByRole(JoinQueryOperatorRole, value); } - } - - public AstNodeCollection JoinConditions { - get { return GetChildrenByRole(JoinCondition.JoinConditionRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitJoinQueryOperator(this, data); - } - } - - public class JoinCondition : AstNode - { - public static readonly Role JoinConditionRole = new Role("JoinCondition"); - - public static readonly Role LeftExpressionRole = BinaryOperatorExpression.LeftExpressionRole; - public static readonly Role RightExpressionRole = BinaryOperatorExpression.RightExpressionRole; - - public Expression Left { - get { return GetChildByRole (LeftExpressionRole); } - set { SetChildByRole (LeftExpressionRole, value); } - } - - public Expression Right { - get { return GetChildByRole (RightExpressionRole); } - set { SetChildByRole (RightExpressionRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitJoinCondition(this, data); - } - } - - public class GroupJoinQueryOperator : JoinQueryOperator - { - public static readonly Role IntoExpressionRole = GroupByQueryOperator.IntoExpressionRole; - - public AstNodeCollection IntoExpressions { - get { return GetChildrenByRole(IntoExpressionRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitGroupJoinQueryOperator(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/SimpleNameExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/SimpleNameExpression.cs deleted file mode 100644 index 0face5c9e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/SimpleNameExpression.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of SimpleNameExpression. - /// - public class SimpleNameExpression : Expression - { - public Identifier Identifier { get; set; } - - public AstNodeCollection TypeArguments { - get { return GetChildrenByRole(Roles.TypeArgument); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var node = other as SimpleNameExpression; - return node != null - && Identifier.DoMatch(node.Identifier, match) - && TypeArguments.DoMatch(node.TypeArguments, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitSimpleNameExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeOfIsExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeOfIsExpression.cs deleted file mode 100644 index 54ef20f94..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeOfIsExpression.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class TypeOfIsExpression : Expression - { - public TypeOfIsExpression() - { - } - - public Expression TypeOfExpression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as TypeOfIsExpression; - return expr != null && - TypeOfExpression.DoMatch(expr.TypeOfExpression, match) && - Type.DoMatch(expr.Type, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitTypeOfIsExpression(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeReferenceExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeReferenceExpression.cs deleted file mode 100644 index d163fcd77..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/TypeReferenceExpression.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Represents an AstType as an expression. - /// This is used when calling a method on a primitive type: "Integer.Parse()" - /// - public class TypeReferenceExpression : Expression - { - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitTypeReferenceExpression(this, data); - } - - public TypeReferenceExpression () - { - } - - public TypeReferenceExpression (AstType type) - { - SetChildByRole(Roles.Type, type); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - TypeReferenceExpression o = other as TypeReferenceExpression; - return o != null && this.Type.DoMatch(o.Type, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/UnaryOperatorExpression.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/UnaryOperatorExpression.cs deleted file mode 100644 index 787698484..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/UnaryOperatorExpression.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Operator Expression - /// - public class UnaryOperatorExpression : Expression - { - public readonly static Role OperatorRole = BinaryOperatorExpression.OperatorRole; - - public UnaryOperatorExpression() - { - } - - public UnaryOperatorExpression(UnaryOperatorType op, Expression expression) - { - this.Operator = op; - this.Expression = expression; - } - - public UnaryOperatorType Operator { - get; - set; - } - - public VBTokenNode OperatorToken { - get { return GetChildByRole (OperatorRole); } - } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitUnaryOperatorExpression(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - UnaryOperatorExpression o = other as UnaryOperatorExpression; - return o != null && this.Operator == o.Operator && this.Expression.DoMatch(o.Expression, match); - } - - public static string GetOperatorSymbol(UnaryOperatorType op) - { - switch (op) { - case UnaryOperatorType.Not: - return "Not"; - case UnaryOperatorType.Minus: - return "-"; - case UnaryOperatorType.Plus: - return "+"; - default: - throw new NotSupportedException("Invalid value for UnaryOperatorType"); - } - } - } - - public enum UnaryOperatorType - { - /// Logical/Bitwise not (Not a) - Not, - /// Unary minus (-a) - Minus, - /// Unary plus (+a) - Plus, - /// AddressOf - AddressOf, - /// Await - Await - } - -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs deleted file mode 100644 index 7d1cb87e7..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/VariableInitializer.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Identifier As Type = Expression - /// - public class VariableInitializer : AstNode - { - public static readonly Role VariableInitializerRole = new Role("VariableInitializer"); - - public VariableIdentifier Identifier { - get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } - set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } - } - - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public VBTokenNode AssignToken { - get { return GetChildByRole (Roles.Assign); } - } - - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitVariableInitializer(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - VariableInitializer o = other as VariableInitializer; - return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/XmlIdentifier.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/XmlIdentifier.cs deleted file mode 100644 index 3b45d5a60..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/XmlIdentifier.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of XmlIdentifier. - /// - public class XmlIdentifier : AstNode - { - public static readonly new XmlIdentifier Null = new NullXmlIdentifier(); - - class NullXmlIdentifier : XmlIdentifier - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default(S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - - public string Name { get; set; } - - TextLocation startLocation; - public override TextLocation StartLocation { - get { return startLocation; } - } - - TextLocation endLocation; - public override TextLocation EndLocation { - get { return endLocation; } - } - - private XmlIdentifier() - { - this.Name = string.Empty; - } - - public XmlIdentifier(string name, TextLocation startLocation, TextLocation endLocation) - { - this.Name = name; - this.startLocation = startLocation; - this.endLocation = endLocation; - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var ident = other as XmlIdentifier; - return ident != null - && MatchStringXml(Name, ident.Name) - && ident.startLocation == startLocation - && ident.endLocation == endLocation; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitXmlIdentifier(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/XmlLiteralString.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/XmlLiteralString.cs deleted file mode 100644 index d2f89e805..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Expressions/XmlLiteralString.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class XmlLiteralString : AstNode - { - public static readonly new XmlLiteralString Null = new XmlLiteralString(); - - class NullXmlLiteralString : XmlLiteralString - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default(S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - - public string Value { get; set; } - - TextLocation startLocation; - public override TextLocation StartLocation { - get { return startLocation; } - } - - TextLocation endLocation; - public override TextLocation EndLocation { - get { return endLocation; } - } - - private XmlLiteralString() - { - this.Value = string.Empty; - } - - public XmlLiteralString(string value, TextLocation startLocation, TextLocation endLocation) - { - this.Value = value; - this.startLocation = startLocation; - this.endLocation = endLocation; - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var ident = other as XmlLiteralString; - return ident != null - && MatchStringXml(Value, ident.Value) - && ident.startLocation == startLocation - && ident.endLocation == endLocation; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitXmlLiteralString(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/Attribute.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/Attribute.cs deleted file mode 100644 index 3ad468609..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/Attribute.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class Attribute : AstNode - { - #region PatternPlaceholder - public static implicit operator Attribute(PatternMatching.Pattern pattern) - { - return pattern != null ? new PatternPlaceholder(pattern) : null; - } - - sealed class PatternPlaceholder : Attribute, PatternMatching.INode - { - readonly PatternMatching.Pattern child; - - public PatternPlaceholder(PatternMatching.Pattern child) - { - this.child = child; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPatternPlaceholder(this, child, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return child.DoMatch(other, match); - } - - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) - { - return child.DoMatchCollection(role, pos, match, backtrackingInfo); - } - } - #endregion - - public static readonly Role AttributeRole = new Role("Attribute"); - public static readonly Role TargetRole = new Role("Target", VBTokenNode.Null); - - public AttributeTarget Target { get; set; } - - public VBTokenNode TargetKeyword { - get { return GetChildByRole(TargetRole); } - set { SetChildByRole(TargetRole, value); } - } - - public VBTokenNode ColonToken { - get { return GetChildByRole(Roles.StatementTerminator); } - } - - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public VBTokenNode LParToken { - get { return GetChildByRole(Roles.LPar); } - } - - public AstNodeCollection Arguments { - get { return GetChildrenByRole(Roles.Argument); } - } - - public VBTokenNode RParToken { - get { return GetChildByRole(Roles.RPar); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAttribute(this, data); - } - -// public override string ToString() -// { -// return string.Format("[Attribute Type={0} Arguments={1}]", Type, GetCollectionString(Arguments)); -// } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var node = other as Attribute; - return node != null && node.Target == Target && node.TargetKeyword.DoMatch(this.TargetKeyword, match) && node.Type.DoMatch(this.Type, match) && node.Arguments.DoMatch(this.Arguments, match); - } - } - - public enum AttributeTarget - { - None, - Assembly, - Module - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs deleted file mode 100644 index 57d69db33..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/AttributeBlock.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -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); } - } - - public AstNodeCollection Attributes { - get { return GetChildrenByRole(Attribute.AttributeRole); } - } - - public VBTokenNode RChevron { - get { return GetChildByRole(Roles.RChevron); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var node = other as AttributeBlock; - return node != null && Attributes.DoMatch(node.Attributes, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAttributeBlock(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/AttributedNode.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/AttributedNode.cs deleted file mode 100644 index de1ccd254..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/AttributedNode.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public abstract class AttributedNode : AstNode - { - public AstNodeCollection Attributes { - get { return GetChildrenByRole(AttributeBlock.AttributeBlockRole); } - } - - public static readonly Role ModifierRole = new Role("Modifier"); - - public Modifiers Modifiers { - get { return GetModifiers(this); } - set { SetModifiers(this, value); } - } - - public AstNodeCollection ModifierTokens { - get { return GetChildrenByRole (ModifierRole); } - } - - internal static Modifiers GetModifiers(AstNode node) - { - Modifiers m = 0; - foreach (VBModifierToken t in node.GetChildrenByRole (ModifierRole)) { - m |= t.Modifier; - } - return m; - } - - internal static void SetModifiers(AstNode node, Modifiers newValue) - { - Modifiers oldValue = GetModifiers(node); - AstNode insertionPos = node.GetChildrenByRole(Attribute.AttributeRole).LastOrDefault(); - foreach (Modifiers m in VBModifierToken.AllModifiers) { - if ((m & newValue) != 0) { - if ((m & oldValue) == 0) { - // Modifier was added - var newToken = new VBModifierToken(TextLocation.Empty, m); - node.InsertChildAfter(insertionPos, newToken, ModifierRole); - insertionPos = newToken; - } else { - // Modifier already exists - insertionPos = node.GetChildrenByRole(ModifierRole).First(t => t.Modifier == m); - } - } else { - if ((m & oldValue) != 0) { - // Modifier was removed - node.GetChildrenByRole (ModifierRole).First(t => t.Modifier == m).Remove(); - } - } - } - } - - protected bool MatchAttributesAndModifiers(AttributedNode o, PatternMatching.Match match) - { - return (this.Modifiers == Modifiers.Any || this.Modifiers == o.Modifiers) && this.Attributes.DoMatch(o.Attributes, match); - } - } - - -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/CompilationUnit.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/CompilationUnit.cs deleted file mode 100644 index 558872c7d..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/CompilationUnit.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class CompilationUnit : AstNode - { - public static readonly Role MemberRole = new Role("Member", AstNode.Null); - - public CompilationUnit () - { - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - CompilationUnit o = other as CompilationUnit; - return o != null && GetChildrenByRole(MemberRole).DoMatch(o.GetChildrenByRole(MemberRole), match); - } - - public AstNode GetNodeAt (int line, int column) - { - return GetNodeAt (new TextLocation (line, column)); - } - - public AstNode GetNodeAt (TextLocation location) - { - AstNode node = this; - while (node.FirstChild != null) { - var child = node.FirstChild; - while (child != null) { - if (child.StartLocation <= location && location < child.EndLocation) { - node = child; - break; - } - child = child.NextSibling; - } - // found no better child node - therefore the parent is the right one. - if (child == null) - break; - } - return node; - } - - public IEnumerable GetNodesBetween (int startLine, int startColumn, int endLine, int endColumn) - { - return GetNodesBetween (new TextLocation (startLine, startColumn), new TextLocation (endLine, endColumn)); - } - - public IEnumerable GetNodesBetween (TextLocation start, TextLocation end) - { - AstNode node = this; - while (node != null) { - AstNode next; - if (start <= node.StartLocation && node.EndLocation <= end) { - // Remember next before yielding node. - // This allows iteration to continue when the caller removes/replaces the node. - next = node.NextSibling; - yield return node; - } else { - if (node.EndLocation < start) { - next = node.NextSibling; - } else { - next = node.FirstChild; - } - } - - if (next != null && next.StartLocation > end) - yield break; - node = next; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitCompilationUnit (this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/EventMemberSpecifier.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/EventMemberSpecifier.cs deleted file mode 100644 index da1e14cf4..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/EventMemberSpecifier.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class EventMemberSpecifier : AstNode - { - public static readonly Role EventMemberSpecifierRole = new Role("EventMemberSpecifier"); - - public EventMemberSpecifier() - { - } - - public Expression Target { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public Identifier Member { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as EventMemberSpecifier; - return expr != null && - Target.DoMatch(expr.Target, match) && - Member.DoMatch(expr.Member, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitEventMemberSpecifier(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/InterfaceMemberSpecifier.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/InterfaceMemberSpecifier.cs deleted file mode 100644 index d4e0090f2..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/InterfaceMemberSpecifier.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class InterfaceMemberSpecifier : AstNode - { - public static readonly Role InterfaceMemberSpecifierRole = new Role("InterfaceMemberSpecifier"); - - public InterfaceMemberSpecifier(Expression target, Identifier member) - { - Target = target; - Member = member; - } - - public InterfaceMemberSpecifier(AstType target, string member) - { - Target = new TypeReferenceExpression(target); - Member = new Identifier(member, TextLocation.Empty); - } - - public Expression Target { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public Identifier Member { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var expr = other as InterfaceMemberSpecifier; - return expr != null && - Target.DoMatch(expr.Target, match) && - Member.DoMatch(expr.Member, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitInterfaceMemberSpecifier(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs deleted file mode 100644 index 61b4f2ae3..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/ParameterDeclaration.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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 Type { - 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) && - Type.DoMatch(param.Type, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitParameterDeclaration(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs deleted file mode 100644 index 29396a9d9..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/General/TypeParameterDeclaration.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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 -{ - /// - /// [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, TextLocation.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/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Generated.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Generated.cs deleted file mode 100644 index dee6e4d96..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Generated.cs +++ /dev/null @@ -1,4866 +0,0 @@ -//// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -//// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -//using System; -//using System.Collections.Generic; -// -//namespace ICSharpCode.NRefactory.VB.Ast { -// public class AddHandlerStatement : Statement { -// -// Expression eventExpression; -// -// Expression handlerExpression; -// -// public Expression EventExpression { -// get { -// return eventExpression; -// } -// set { -// eventExpression = value ?? Expression.Null; -// if (!eventExpression.IsNull) eventExpression.Parent = this; -// } -// } -// -// public Expression HandlerExpression { -// get { -// return handlerExpression; -// } -// set { -// handlerExpression = value ?? Expression.Null; -// if (!handlerExpression.IsNull) handlerExpression.Parent = this; -// } -// } -// -// public AddHandlerStatement(Expression eventExpression, Expression handlerExpression) { -// EventExpression = eventExpression; -// HandlerExpression = handlerExpression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitAddHandlerStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[AddHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression); -// } -// } -// -// public class AddressOfExpression : Expression { -// -// Expression expression; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public AddressOfExpression(Expression expression) { -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitAddressOfExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[AddressOfExpression Expression={0}]", Expression); -// } -// } -// -// public class ArrayCreateExpression : Expression { -// -// TypeReference createType; -// -// List arguments; -// -// CollectionInitializerExpression arrayInitializer; -// -// public TypeReference CreateType { -// get { -// return createType; -// } -// set { -// createType = value ?? TypeReference.Null; -// if (!createType.IsNull) createType.Parent = this; -// } -// } -// -// public List Arguments { -// get { -// return arguments; -// } -// set { -// arguments = value ?? new List(); -// } -// } -// -// public CollectionInitializerExpression ArrayInitializer { -// get { -// return arrayInitializer; -// } -// set { -// arrayInitializer = value ?? CollectionInitializerExpression.Null; -// if (!arrayInitializer.IsNull) arrayInitializer.Parent = this; -// } -// } -// -// public ArrayCreateExpression(TypeReference createType) { -// CreateType = createType; -// arguments = new List(); -// arrayInitializer = CollectionInitializerExpression.Null; -// } -// -// public ArrayCreateExpression(TypeReference createType, List arguments) { -// CreateType = createType; -// Arguments = arguments; -// arrayInitializer = CollectionInitializerExpression.Null; -// } -// -// public ArrayCreateExpression(TypeReference createType, CollectionInitializerExpression arrayInitializer) { -// CreateType = createType; -// ArrayInitializer = arrayInitializer; -// arguments = new List(); -// } -// -// public bool IsImplicitlyTyped { -// get { -// return createType.IsNull || string.IsNullOrEmpty(createType.Type); -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitArrayCreateExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ArrayCreateExpression CreateType={0} Arguments={1} ArrayInitializer={2}]", CreateType, GetCollectionString(Arguments), ArrayInitializer); -// } -// } -// -// public class AssignmentExpression : Expression { -// -// Expression left; -// -// AssignmentOperatorType op; -// -// Expression right; -// -// public Expression Left { -// get { -// return left; -// } -// set { -// left = value ?? Expression.Null; -// if (!left.IsNull) left.Parent = this; -// } -// } -// -// public AssignmentOperatorType Op { -// get { -// return op; -// } -// set { -// op = value; -// } -// } -// -// public Expression Right { -// get { -// return right; -// } -// set { -// right = value ?? Expression.Null; -// if (!right.IsNull) right.Parent = this; -// } -// } -// -// public AssignmentExpression(Expression left, AssignmentOperatorType op, Expression right) { -// Left = left; -// Op = op; -// Right = right; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitAssignmentExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[AssignmentExpression Left={0} Op={1} Right={2}]", Left, Op, Right); -// } -// } -// -// public abstract class AttributedNode : AbstractNode { -// -// List attributes; -// -// Modifiers modifier; -// -// public List Attributes { -// get { -// return attributes; -// } -// set { -// attributes = value ?? new List(); -// } -// } -// -// public Modifiers Modifier { -// get { -// return modifier; -// } -// set { -// modifier = value; -// } -// } -// -// protected AttributedNode() { -// attributes = new List(); -// } -// -// protected AttributedNode(List attributes) { -// Attributes = attributes; -// } -// -// protected AttributedNode(Modifiers modifier, List attributes) { -// Modifier = modifier; -// Attributes = attributes; -// } -// } -// -// public class AttributeSection : AbstractNode { -// -// string attributeTarget; -// -// List attributes; -// -// public string AttributeTarget { -// get { -// return attributeTarget; -// } -// set { -// attributeTarget = value ?? ""; -// } -// } -// -// public List Attributes { -// get { -// return attributes; -// } -// set { -// attributes = value ?? new List(); -// } -// } -// -// public AttributeSection() { -// attributeTarget = ""; -// attributes = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitAttributeSection(this, data); -// } -// -// public override string ToString() { -// return string.Format("[AttributeSection AttributeTarget={0} Attributes={1}]", AttributeTarget, GetCollectionString(Attributes)); -// } -// } -// -// public class BaseReferenceExpression : Expression { -// -// public BaseReferenceExpression() { -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitBaseReferenceExpression(this, data); -// } -// -// public override string ToString() { -// return "[BaseReferenceExpression]"; -// } -// } -// -// public class BinaryOperatorExpression : Expression { -// -// Expression left; -// -// BinaryOperatorType op; -// -// Expression right; -// -// public Expression Left { -// get { -// return left; -// } -// set { -// left = value ?? Expression.Null; -// if (!left.IsNull) left.Parent = this; -// } -// } -// -// public BinaryOperatorType Op { -// get { -// return op; -// } -// set { -// op = value; -// } -// } -// -// public Expression Right { -// get { -// return right; -// } -// set { -// right = value ?? Expression.Null; -// if (!right.IsNull) right.Parent = this; -// } -// } -// -// public BinaryOperatorExpression() { -// left = Expression.Null; -// right = Expression.Null; -// } -// -// public BinaryOperatorExpression(Expression left, BinaryOperatorType op, Expression right) { -// Left = left; -// Op = op; -// Right = right; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitBinaryOperatorExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[BinaryOperatorExpression Left={0} Op={1} Right={2}]", Left, Op, Right); -// } -// } -// -// public class CaseLabel : AbstractNode { -// -// Expression label; -// -// BinaryOperatorType binaryOperatorType; -// -// Expression toExpression; -// -// public Expression Label { -// get { -// return label; -// } -// set { -// label = value ?? Expression.Null; -// if (!label.IsNull) label.Parent = this; -// } -// } -// -// public BinaryOperatorType BinaryOperatorType { -// get { -// return binaryOperatorType; -// } -// set { -// binaryOperatorType = value; -// } -// } -// -// public Expression ToExpression { -// get { -// return toExpression; -// } -// set { -// toExpression = value ?? Expression.Null; -// if (!toExpression.IsNull) toExpression.Parent = this; -// } -// } -// -// public CaseLabel() { -// label = Expression.Null; -// toExpression = Expression.Null; -// } -// -// public CaseLabel(Expression label) { -// Label = label; -// toExpression = Expression.Null; -// } -// -// public CaseLabel(Expression label, Expression toExpression) { -// Label = label; -// ToExpression = toExpression; -// } -// -// public CaseLabel(BinaryOperatorType binaryOperatorType, Expression label) { -// BinaryOperatorType = binaryOperatorType; -// Label = label; -// toExpression = Expression.Null; -// } -// -// public bool IsDefault { -// get { -// return label.IsNull; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitCaseLabel(this, data); -// } -// -// public override string ToString() { -// return string.Format("[CaseLabel Label={0} BinaryOperatorType={1} ToExpression={2}]", Label, BinaryOperatorType, ToExpression); -// } -// } -// -// public class CastExpression : Expression { -// -// TypeReference castTo; -// -// Expression expression; -// -// CastType castType; -// -// public TypeReference CastTo { -// get { -// return castTo; -// } -// set { -// castTo = value ?? TypeReference.Null; -// if (!castTo.IsNull) castTo.Parent = this; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public CastType CastType { -// get { -// return castType; -// } -// set { -// castType = value; -// } -// } -// -// public CastExpression(TypeReference castTo) { -// CastTo = castTo; -// expression = Expression.Null; -// } -// -// public CastExpression(TypeReference castTo, Expression expression, CastType castType) { -// CastTo = castTo; -// Expression = expression; -// CastType = castType; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitCastExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[CastExpression CastTo={0} Expression={1} CastType={2}]", CastTo, Expression, CastType); -// } -// } -// -// public class CatchClause : AbstractNode { -// -// TypeReference typeReference; -// -// string variableName; -// -// Statement statementBlock; -// -// Expression condition; -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public string VariableName { -// get { -// return variableName; -// } -// set { -// variableName = value ?? ""; -// } -// } -// -// public Statement StatementBlock { -// get { -// return statementBlock; -// } -// set { -// statementBlock = value ?? Statement.Null; -// if (!statementBlock.IsNull) statementBlock.Parent = this; -// } -// } -// -// public Expression Condition { -// get { -// return condition; -// } -// set { -// condition = value ?? Expression.Null; -// if (!condition.IsNull) condition.Parent = this; -// } -// } -// -// public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock) { -// TypeReference = typeReference; -// VariableName = variableName; -// StatementBlock = statementBlock; -// condition = Expression.Null; -// } -// -// public CatchClause(TypeReference typeReference, string variableName, Statement statementBlock, Expression condition) { -// TypeReference = typeReference; -// VariableName = variableName; -// StatementBlock = statementBlock; -// Condition = condition; -// } -// -// public CatchClause(Statement statementBlock) { -// StatementBlock = statementBlock; -// typeReference = TypeReference.Null; -// variableName = ""; -// condition = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitCatchClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[CatchClause TypeReference={0} VariableName={1} StatementBlock={2} Condition={3}]" + -// "", TypeReference, VariableName, StatementBlock, Condition); -// } -// } -// -// public class ClassReferenceExpression : Expression { -// -// public ClassReferenceExpression() { -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitClassReferenceExpression(this, data); -// } -// -// public override string ToString() { -// return "[ClassReferenceExpression]"; -// } -// } -// -// public class CollectionInitializerExpression : Expression { -// -// List createExpressions; -// -// public List CreateExpressions { -// get { -// return createExpressions; -// } -// set { -// createExpressions = value ?? new List(); -// } -// } -// -// public CollectionInitializerExpression() { -// createExpressions = new List(); -// } -// -// public CollectionInitializerExpression(List createExpressions) { -// CreateExpressions = createExpressions; -// } -// -// public new static CollectionInitializerExpression Null { -// get { -// return NullCollectionInitializerExpression.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitCollectionInitializerExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[CollectionInitializerExpression CreateExpressions={0}]", GetCollectionString(CreateExpressions)); -// } -// } -// -// internal sealed class NullCollectionInitializerExpression : CollectionInitializerExpression { -// -// internal static NullCollectionInitializerExpression Instance = new NullCollectionInitializerExpression(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullCollectionInitializerExpression]"; -// } -// } -// -// public class CollectionRangeVariable : AbstractNode, INullable { -// -// string identifier; -// -// Expression expression; -// -// TypeReference type; -// -// public string Identifier { -// get { -// return identifier; -// } -// set { -// identifier = value ?? ""; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public TypeReference Type { -// get { -// return type; -// } -// set { -// type = value ?? TypeReference.Null; -// if (!type.IsNull) type.Parent = this; -// } -// } -// -// public CollectionRangeVariable() { -// identifier = ""; -// expression = Expression.Null; -// type = TypeReference.Null; -// } -// -// public virtual bool IsNull { -// get { -// return false; -// } -// } -// -// public static CollectionRangeVariable Null { -// get { -// return NullCollectionRangeVariable.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitCollectionRangeVariable(this, data); -// } -// -// public override string ToString() { -// return string.Format("[CollectionRangeVariable Identifier={0} Expression={1} Type={2}]", Identifier, Expression, Type); -// } -// } -// -// internal sealed class NullCollectionRangeVariable : CollectionRangeVariable { -// -// internal static NullCollectionRangeVariable Instance = new NullCollectionRangeVariable(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullCollectionRangeVariable]"; -// } -// } -// -// public class ConditionalExpression : Expression { -// -// Expression condition; -// -// Expression trueExpression; -// -// Expression falseExpression; -// -// public Expression Condition { -// get { -// return condition; -// } -// set { -// condition = value ?? Expression.Null; -// if (!condition.IsNull) condition.Parent = this; -// } -// } -// -// public Expression TrueExpression { -// get { -// return trueExpression; -// } -// set { -// trueExpression = value ?? Expression.Null; -// if (!trueExpression.IsNull) trueExpression.Parent = this; -// } -// } -// -// public Expression FalseExpression { -// get { -// return falseExpression; -// } -// set { -// falseExpression = value ?? Expression.Null; -// if (!falseExpression.IsNull) falseExpression.Parent = this; -// } -// } -// -// public ConditionalExpression() { -// condition = Expression.Null; -// trueExpression = Expression.Null; -// falseExpression = Expression.Null; -// } -// -// public ConditionalExpression(Expression condition, Expression trueExpression, Expression falseExpression) { -// Condition = condition; -// TrueExpression = trueExpression; -// FalseExpression = falseExpression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitConditionalExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ConditionalExpression Condition={0} TrueExpression={1} FalseExpression={2}]", Condition, TrueExpression, FalseExpression); -// } -// } -// -// public class ConstructorDeclaration : ParametrizedNode { -// -// ConstructorInitializer constructorInitializer; -// -// BlockStatement body; -// -// public ConstructorInitializer ConstructorInitializer { -// get { -// return constructorInitializer; -// } -// set { -// constructorInitializer = value ?? ConstructorInitializer.Null; -// if (!constructorInitializer.IsNull) constructorInitializer.Parent = this; -// } -// } -// -// public BlockStatement Body { -// get { -// return body; -// } -// set { -// body = value ?? BlockStatement.Null; -// if (!body.IsNull) body.Parent = this; -// } -// } -// -// public ConstructorDeclaration(string name, Modifiers modifier, List parameters, List attributes) { -// Name = name; -// Modifier = modifier; -// Parameters = parameters; -// Attributes = attributes; -// constructorInitializer = ConstructorInitializer.Null; -// body = BlockStatement.Null; -// } -// -// public ConstructorDeclaration(string name, Modifiers modifier, List parameters, ConstructorInitializer constructorInitializer, List attributes) { -// Name = name; -// Modifier = modifier; -// Parameters = parameters; -// ConstructorInitializer = constructorInitializer; -// Attributes = attributes; -// body = BlockStatement.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitConstructorDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ConstructorDeclaration ConstructorInitializer={0} Body={1} Name={2} Parameters={" + -// "3} Attributes={4} Modifier={5}]", ConstructorInitializer, Body, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class ConstructorInitializer : AbstractNode, INullable { -// -// ConstructorInitializerType constructorInitializerType; -// -// List arguments; -// -// public ConstructorInitializerType ConstructorInitializerType { -// get { -// return constructorInitializerType; -// } -// set { -// constructorInitializerType = value; -// } -// } -// -// public List Arguments { -// get { -// return arguments; -// } -// set { -// arguments = value ?? new List(); -// } -// } -// -// public ConstructorInitializer() { -// arguments = new List(); -// } -// -// public virtual bool IsNull { -// get { -// return false; -// } -// } -// -// public static ConstructorInitializer Null { -// get { -// return NullConstructorInitializer.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitConstructorInitializer(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ConstructorInitializer ConstructorInitializerType={0} Arguments={1}]", ConstructorInitializerType, GetCollectionString(Arguments)); -// } -// } -// -// internal sealed class NullConstructorInitializer : ConstructorInitializer { -// -// internal static NullConstructorInitializer Instance = new NullConstructorInitializer(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullConstructorInitializer]"; -// } -// } -// -// public class ContinueStatement : Statement { -// -// ContinueType continueType; -// -// public ContinueType ContinueType { -// get { -// return continueType; -// } -// set { -// continueType = value; -// } -// } -// -// public ContinueStatement() { -// } -// -// public ContinueStatement(ContinueType continueType) { -// ContinueType = continueType; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitContinueStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ContinueStatement ContinueType={0}]", ContinueType); -// } -// } -// -// public class DeclareDeclaration : ParametrizedNode { -// -// string alias; -// -// string library; -// -// CharsetModifier charset; -// -// TypeReference typeReference; -// -// public string Alias { -// get { -// return alias; -// } -// set { -// alias = value ?? ""; -// } -// } -// -// public string Library { -// get { -// return library; -// } -// set { -// library = value ?? ""; -// } -// } -// -// public CharsetModifier Charset { -// get { -// return charset; -// } -// set { -// charset = value; -// } -// } -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public DeclareDeclaration(string name, Modifiers modifier, TypeReference typeReference, List parameters, List attributes, string library, string alias, CharsetModifier charset) { -// Name = name; -// Modifier = modifier; -// TypeReference = typeReference; -// Parameters = parameters; -// Attributes = attributes; -// Library = library; -// Alias = alias; -// Charset = charset; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitDeclareDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[DeclareDeclaration Alias={0} Library={1} Charset={2} TypeReference={3} Name={4} " + -// "Parameters={5} Attributes={6} Modifier={7}]", Alias, Library, Charset, TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class DefaultValueExpression : Expression { -// -// TypeReference typeReference; -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public DefaultValueExpression(TypeReference typeReference) { -// TypeReference = typeReference; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitDefaultValueExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[DefaultValueExpression TypeReference={0}]", TypeReference); -// } -// } -// -// public class DelegateDeclaration : AttributedNode { -// -// string name; -// -// TypeReference returnType; -// -// List parameters; -// -// List templates; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = string.IsNullOrEmpty(value) ? "?" : value; -// } -// } -// -// public TypeReference ReturnType { -// get { -// return returnType; -// } -// set { -// returnType = value ?? TypeReference.Null; -// if (!returnType.IsNull) returnType.Parent = this; -// } -// } -// -// public List Parameters { -// get { -// return parameters; -// } -// set { -// parameters = value ?? new List(); -// } -// } -// -// public List Templates { -// get { -// return templates; -// } -// set { -// templates = value ?? new List(); -// } -// } -// -// public DelegateDeclaration(Modifiers modifier, List attributes) { -// Modifier = modifier; -// Attributes = attributes; -// name = "?"; -// returnType = TypeReference.Null; -// parameters = new List(); -// templates = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitDelegateDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[DelegateDeclaration Name={0} ReturnType={1} Parameters={2} Templates={3} Attribu" + -// "tes={4} Modifier={5}]", Name, ReturnType, GetCollectionString(Parameters), GetCollectionString(Templates), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class DirectionExpression : Expression { -// -// FieldDirection fieldDirection; -// -// Expression expression; -// -// public FieldDirection FieldDirection { -// get { -// return fieldDirection; -// } -// set { -// fieldDirection = value; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public DirectionExpression(FieldDirection fieldDirection, Expression expression) { -// FieldDirection = fieldDirection; -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitDirectionExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[DirectionExpression FieldDirection={0} Expression={1}]", FieldDirection, Expression); -// } -// } -// -// public class DoLoopStatement : StatementWithEmbeddedStatement { -// -// Expression condition; -// -// ConditionType conditionType; -// -// ConditionPosition conditionPosition; -// -// public Expression Condition { -// get { -// return condition; -// } -// set { -// condition = value ?? Expression.Null; -// if (!condition.IsNull) condition.Parent = this; -// } -// } -// -// public ConditionType ConditionType { -// get { -// return conditionType; -// } -// set { -// conditionType = value; -// } -// } -// -// public ConditionPosition ConditionPosition { -// get { -// return conditionPosition; -// } -// set { -// conditionPosition = value; -// } -// } -// -// public DoLoopStatement(Expression condition, Statement embeddedStatement, ConditionType conditionType, ConditionPosition conditionPosition) { -// Condition = condition; -// EmbeddedStatement = embeddedStatement; -// ConditionType = conditionType; -// ConditionPosition = conditionPosition; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitDoLoopStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[DoLoopStatement Condition={0} ConditionType={1} ConditionPosition={2} EmbeddedSt" + -// "atement={3}]", Condition, ConditionType, ConditionPosition, EmbeddedStatement); -// } -// } -// -// public class ElseIfSection : StatementWithEmbeddedStatement { -// -// Expression condition; -// -// public Expression Condition { -// get { -// return condition; -// } -// set { -// condition = value ?? Expression.Null; -// if (!condition.IsNull) condition.Parent = this; -// } -// } -// -// public ElseIfSection(Expression condition, Statement embeddedStatement) { -// Condition = condition; -// EmbeddedStatement = embeddedStatement; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitElseIfSection(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ElseIfSection Condition={0} EmbeddedStatement={1}]", Condition, EmbeddedStatement); -// } -// } -// -// public class EndStatement : Statement { -// -// public EndStatement() { -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitEndStatement(this, data); -// } -// -// public override string ToString() { -// return "[EndStatement]"; -// } -// } -// -// public class EraseStatement : Statement { -// -// List expressions; -// -// public List Expressions { -// get { -// return expressions; -// } -// set { -// expressions = value ?? new List(); -// } -// } -// -// public EraseStatement() { -// expressions = new List(); -// } -// -// public EraseStatement(List expressions) { -// Expressions = expressions; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitEraseStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[EraseStatement Expressions={0}]", GetCollectionString(Expressions)); -// } -// } -// -// public class ErrorStatement : Statement { -// -// Expression expression; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public ErrorStatement(Expression expression) { -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitErrorStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ErrorStatement Expression={0}]", Expression); -// } -// } -// -// public class EventAddRegion : EventAddRemoveRegion { -// -// public EventAddRegion(List attributes) : -// base(attributes) { -// } -// -// public static EventAddRegion Null { -// get { -// return NullEventAddRegion.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitEventAddRegion(this, data); -// } -// -// public override string ToString() { -// return string.Format("[EventAddRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// internal sealed class NullEventAddRegion : EventAddRegion { -// -// private NullEventAddRegion() : -// base(null) { -// } -// -// internal static NullEventAddRegion Instance = new NullEventAddRegion(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullEventAddRegion]"; -// } -// } -// -// public abstract class EventAddRemoveRegion : AttributedNode, INullable { -// -// BlockStatement block; -// -// List parameters; -// -// public BlockStatement Block { -// get { -// return block; -// } -// set { -// block = value ?? BlockStatement.Null; -// if (!block.IsNull) block.Parent = this; -// } -// } -// -// public List Parameters { -// get { -// return parameters; -// } -// set { -// parameters = value ?? new List(); -// } -// } -// -// protected EventAddRemoveRegion(List attributes) { -// Attributes = attributes; -// block = BlockStatement.Null; -// parameters = new List(); -// } -// -// public virtual bool IsNull { -// get { -// return false; -// } -// } -// } -// -// public class EventDeclaration : MemberNode { -// -// EventAddRegion addRegion; -// -// EventRemoveRegion removeRegion; -// -// EventRaiseRegion raiseRegion; -// -// Location bodyStart; -// -// Location bodyEnd; -// -// Expression initializer; -// -// public EventAddRegion AddRegion { -// get { -// return addRegion; -// } -// set { -// addRegion = value ?? EventAddRegion.Null; -// if (!addRegion.IsNull) addRegion.Parent = this; -// } -// } -// -// public EventRemoveRegion RemoveRegion { -// get { -// return removeRegion; -// } -// set { -// removeRegion = value ?? EventRemoveRegion.Null; -// if (!removeRegion.IsNull) removeRegion.Parent = this; -// } -// } -// -// public EventRaiseRegion RaiseRegion { -// get { -// return raiseRegion; -// } -// set { -// raiseRegion = value ?? EventRaiseRegion.Null; -// if (!raiseRegion.IsNull) raiseRegion.Parent = this; -// } -// } -// -// public Location BodyStart { -// get { -// return bodyStart; -// } -// set { -// bodyStart = value; -// } -// } -// -// public Location BodyEnd { -// get { -// return bodyEnd; -// } -// set { -// bodyEnd = value; -// } -// } -// -// public Expression Initializer { -// get { -// return initializer; -// } -// set { -// initializer = value ?? Expression.Null; -// if (!initializer.IsNull) initializer.Parent = this; -// } -// } -// -// public EventDeclaration() { -// addRegion = EventAddRegion.Null; -// removeRegion = EventRemoveRegion.Null; -// raiseRegion = EventRaiseRegion.Null; -// bodyStart = Location.Empty; -// bodyEnd = Location.Empty; -// initializer = Expression.Null; -// } -// -// public bool HasAddRegion { -// get { -// return !addRegion.IsNull; -// } -// } -// -// public bool HasRemoveRegion { -// get { -// return !removeRegion.IsNull; -// } -// } -// -// public bool HasRaiseRegion { -// get { -// return !raiseRegion.IsNull; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitEventDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[EventDeclaration AddRegion={0} RemoveRegion={1} RaiseRegion={2} BodyStart={3} Bo" + -// "dyEnd={4} Initializer={5} InterfaceImplementations={6} TypeReference={7} Name={8" + -// "} Parameters={9} Attributes={10} Modifier={11}]", AddRegion, RemoveRegion, RaiseRegion, BodyStart, BodyEnd, Initializer, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class EventRaiseRegion : EventAddRemoveRegion { -// -// public EventRaiseRegion(List attributes) : -// base(attributes) { -// } -// -// public static EventRaiseRegion Null { -// get { -// return NullEventRaiseRegion.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitEventRaiseRegion(this, data); -// } -// -// public override string ToString() { -// return string.Format("[EventRaiseRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// internal sealed class NullEventRaiseRegion : EventRaiseRegion { -// -// private NullEventRaiseRegion() : -// base(null) { -// } -// -// internal static NullEventRaiseRegion Instance = new NullEventRaiseRegion(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullEventRaiseRegion]"; -// } -// } -// -// public class EventRemoveRegion : EventAddRemoveRegion { -// -// public EventRemoveRegion(List attributes) : -// base(attributes) { -// } -// -// public static EventRemoveRegion Null { -// get { -// return NullEventRemoveRegion.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitEventRemoveRegion(this, data); -// } -// -// public override string ToString() { -// return string.Format("[EventRemoveRegion Block={0} Parameters={1} Attributes={2} Modifier={3}]", Block, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// internal sealed class NullEventRemoveRegion : EventRemoveRegion { -// -// private NullEventRemoveRegion() : -// base(null) { -// } -// -// internal static NullEventRemoveRegion Instance = new NullEventRemoveRegion(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullEventRemoveRegion]"; -// } -// } -// -// public class ExitStatement : Statement { -// -// ExitType exitType; -// -// public ExitType ExitType { -// get { -// return exitType; -// } -// set { -// exitType = value; -// } -// } -// -// public ExitStatement(ExitType exitType) { -// ExitType = exitType; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitExitStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ExitStatement ExitType={0}]", ExitType); -// } -// } -// -// public class ExpressionRangeVariable : AbstractNode, INullable { -// -// string identifier; -// -// Expression expression; -// -// TypeReference type; -// -// public string Identifier { -// get { -// return identifier; -// } -// set { -// identifier = value ?? ""; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public TypeReference Type { -// get { -// return type; -// } -// set { -// type = value ?? TypeReference.Null; -// if (!type.IsNull) type.Parent = this; -// } -// } -// -// public ExpressionRangeVariable() { -// identifier = ""; -// expression = Expression.Null; -// type = TypeReference.Null; -// } -// -// public virtual bool IsNull { -// get { -// return false; -// } -// } -// -// public static ExpressionRangeVariable Null { -// get { -// return NullExpressionRangeVariable.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitExpressionRangeVariable(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ExpressionRangeVariable Identifier={0} Expression={1} Type={2}]", Identifier, Expression, Type); -// } -// } -// -// internal sealed class NullExpressionRangeVariable : ExpressionRangeVariable { -// -// internal static NullExpressionRangeVariable Instance = new NullExpressionRangeVariable(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullExpressionRangeVariable]"; -// } -// } -// -// public class ExpressionStatement : Statement { -// -// Expression expression; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public ExpressionStatement(Expression expression) { -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitExpressionStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ExpressionStatement Expression={0}]", Expression); -// } -// } -// -// public class ExternAliasDirective : AbstractNode { -// -// string name; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public ExternAliasDirective() { -// name = ""; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitExternAliasDirective(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ExternAliasDirective Name={0}]", Name); -// } -// } -// -// public class FieldDeclaration : AttributedNode { -// -// TypeReference typeReference; -// -// List fields; -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public List Fields { -// get { -// return fields; -// } -// set { -// fields = value ?? new List(); -// } -// } -// -// public FieldDeclaration(List attributes) { -// Attributes = attributes; -// typeReference = TypeReference.Null; -// fields = new List(); -// } -// -// public FieldDeclaration(List attributes, TypeReference typeReference, Modifiers modifier) { -// Attributes = attributes; -// TypeReference = typeReference; -// Modifier = modifier; -// fields = new List(); -// } -// -// -// public TypeReference GetTypeForField(int fieldIndex) -// { -// if (!typeReference.IsNull) { -// return typeReference; -// } -// return ((VariableDeclaration)Fields[fieldIndex]).TypeReference; -// } -// -// -// public VariableDeclaration GetVariableDeclaration(string variableName) -// { -// foreach (VariableDeclaration variableDeclaration in Fields) { -// if (variableDeclaration.Name == variableName) { -// return variableDeclaration; -// } -// } -// return null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitFieldDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[FieldDeclaration TypeReference={0} Fields={1} Attributes={2} Modifier={3}]", TypeReference, GetCollectionString(Fields), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class ForeachStatement : StatementWithEmbeddedStatement { -// -// TypeReference typeReference; -// -// string variableName; -// -// Expression expression; -// -// Expression nextExpression; -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public string VariableName { -// get { -// return variableName; -// } -// set { -// variableName = value ?? ""; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public Expression NextExpression { -// get { -// return nextExpression; -// } -// set { -// nextExpression = value ?? Expression.Null; -// if (!nextExpression.IsNull) nextExpression.Parent = this; -// } -// } -// -// public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement) { -// TypeReference = typeReference; -// VariableName = variableName; -// Expression = expression; -// EmbeddedStatement = embeddedStatement; -// nextExpression = Expression.Null; -// } -// -// public ForeachStatement(TypeReference typeReference, string variableName, Expression expression, Statement embeddedStatement, Expression nextExpression) { -// TypeReference = typeReference; -// VariableName = variableName; -// Expression = expression; -// EmbeddedStatement = embeddedStatement; -// NextExpression = nextExpression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitForeachStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ForeachStatement TypeReference={0} VariableName={1} Expression={2} NextExpressio" + -// "n={3} EmbeddedStatement={4}]", TypeReference, VariableName, Expression, NextExpression, EmbeddedStatement); -// } -// } -// -// public class ForNextStatement : StatementWithEmbeddedStatement { -// -// Expression start; -// -// Expression end; -// -// Expression step; -// -// List nextExpressions; -// -// TypeReference typeReference; -// -// string variableName; -// -// Expression loopVariableExpression; -// -// public Expression Start { -// get { -// return start; -// } -// set { -// start = value ?? Expression.Null; -// if (!start.IsNull) start.Parent = this; -// } -// } -// -// public Expression End { -// get { -// return end; -// } -// set { -// end = value ?? Expression.Null; -// if (!end.IsNull) end.Parent = this; -// } -// } -// -// public Expression Step { -// get { -// return step; -// } -// set { -// step = value ?? Expression.Null; -// if (!step.IsNull) step.Parent = this; -// } -// } -// -// public List NextExpressions { -// get { -// return nextExpressions; -// } -// set { -// nextExpressions = value ?? new List(); -// } -// } -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public string VariableName { -// get { -// return variableName; -// } -// set { -// variableName = value ?? ""; -// } -// } -// -// public Expression LoopVariableExpression { -// get { -// return loopVariableExpression; -// } -// set { -// loopVariableExpression = value ?? Expression.Null; -// if (!loopVariableExpression.IsNull) loopVariableExpression.Parent = this; -// } -// } -// -// public ForNextStatement() { -// start = Expression.Null; -// end = Expression.Null; -// step = Expression.Null; -// nextExpressions = new List(); -// typeReference = TypeReference.Null; -// variableName = ""; -// loopVariableExpression = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitForNextStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ForNextStatement Start={0} End={1} Step={2} NextExpressions={3} TypeReference={4" + -// "} VariableName={5} LoopVariableExpression={6} EmbeddedStatement={7}]", Start, End, Step, GetCollectionString(NextExpressions), TypeReference, VariableName, LoopVariableExpression, EmbeddedStatement); -// } -// } -// -// public class GotoStatement : Statement { -// -// string label; -// -// public string Label { -// get { -// return label; -// } -// set { -// label = value ?? ""; -// } -// } -// -// public GotoStatement(string label) { -// Label = label; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitGotoStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[GotoStatement Label={0}]", Label); -// } -// } -// -// public class IfElseStatement : Statement { -// -// Expression condition; -// -// List trueStatement; -// -// List falseStatement; -// -// List elseIfSections; -// -// public Expression Condition { -// get { -// return condition; -// } -// set { -// condition = value ?? Expression.Null; -// if (!condition.IsNull) condition.Parent = this; -// } -// } -// -// public List TrueStatement { -// get { -// return trueStatement; -// } -// set { -// trueStatement = value ?? new List(); -// } -// } -// -// public List FalseStatement { -// get { -// return falseStatement; -// } -// set { -// falseStatement = value ?? new List(); -// } -// } -// -// public List ElseIfSections { -// get { -// return elseIfSections; -// } -// set { -// elseIfSections = value ?? new List(); -// } -// } -// -// public IfElseStatement(Expression condition) { -// Condition = condition; -// trueStatement = new List(); -// falseStatement = new List(); -// elseIfSections = new List(); -// } -// -// -// public IfElseStatement(Expression condition, Statement trueStatement) -// : this(condition) { -// this.trueStatement.Add(Statement.CheckNull(trueStatement)); -// if (trueStatement != null) trueStatement.Parent = this; -// } -// -// public bool HasElseStatements { -// get { -// return falseStatement.Count > 0; -// } -// } -// -// public bool HasElseIfSections { -// get { -// return elseIfSections.Count > 0; -// } -// } -// -// -// public IfElseStatement(Expression condition, Statement trueStatement, Statement falseStatement) -// : this(condition) { -// this.trueStatement.Add(Statement.CheckNull(trueStatement)); -// this.falseStatement.Add(Statement.CheckNull(falseStatement)); -// if (trueStatement != null) trueStatement.Parent = this; -// if (falseStatement != null) falseStatement.Parent = this; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitIfElseStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[IfElseStatement Condition={0} TrueStatement={1} FalseStatement={2} ElseIfSection" + -// "s={3}]", Condition, GetCollectionString(TrueStatement), GetCollectionString(FalseStatement), GetCollectionString(ElseIfSections)); -// } -// } -// -// public class InterfaceImplementation : AbstractNode { -// -// TypeReference interfaceType; -// -// string memberName; -// -// public TypeReference InterfaceType { -// get { -// return interfaceType; -// } -// set { -// interfaceType = value ?? TypeReference.Null; -// if (!interfaceType.IsNull) interfaceType.Parent = this; -// } -// } -// -// public string MemberName { -// get { -// return memberName; -// } -// set { -// memberName = string.IsNullOrEmpty(value) ? "?" : value; -// } -// } -// -// public InterfaceImplementation(TypeReference interfaceType, string memberName) { -// InterfaceType = interfaceType; -// MemberName = memberName; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitInterfaceImplementation(this, data); -// } -// -// public override string ToString() { -// return string.Format("[InterfaceImplementation InterfaceType={0} MemberName={1}]", InterfaceType, MemberName); -// } -// } -// -// public class InvocationExpression : Expression { -// -// Expression targetObject; -// -// List arguments; -// -// public Expression TargetObject { -// get { -// return targetObject; -// } -// set { -// targetObject = value ?? Expression.Null; -// if (!targetObject.IsNull) targetObject.Parent = this; -// } -// } -// -// public List Arguments { -// get { -// return arguments; -// } -// set { -// arguments = value ?? new List(); -// } -// } -// -// public InvocationExpression(Expression targetObject) { -// TargetObject = targetObject; -// arguments = new List(); -// } -// -// public InvocationExpression(Expression targetObject, List arguments) { -// TargetObject = targetObject; -// Arguments = arguments; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitInvocationExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[InvocationExpression TargetObject={0} Arguments={1}]", TargetObject, GetCollectionString(Arguments)); -// } -// } -// -// public class LabelStatement : Statement { -// -// string label; -// -// public string Label { -// get { -// return label; -// } -// set { -// label = value ?? ""; -// } -// } -// -// public LabelStatement(string label) { -// Label = label; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitLabelStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[LabelStatement Label={0}]", Label); -// } -// } -// -// public class LambdaExpression : Expression { -// -// List parameters; -// -// Statement statementBody; -// -// Expression expressionBody; -// -// TypeReference returnType; -// -// public List Parameters { -// get { -// return parameters; -// } -// set { -// parameters = value ?? new List(); -// } -// } -// -// public Statement StatementBody { -// get { -// return statementBody; -// } -// set { -// statementBody = value ?? Statement.Null; -// if (!statementBody.IsNull) statementBody.Parent = this; -// } -// } -// -// public Expression ExpressionBody { -// get { -// return expressionBody; -// } -// set { -// expressionBody = value ?? Expression.Null; -// if (!expressionBody.IsNull) expressionBody.Parent = this; -// } -// } -// -// public TypeReference ReturnType { -// get { -// return returnType; -// } -// set { -// returnType = value ?? TypeReference.Null; -// if (!returnType.IsNull) returnType.Parent = this; -// } -// } -// -// public LambdaExpression() { -// parameters = new List(); -// statementBody = Statement.Null; -// expressionBody = Expression.Null; -// returnType = TypeReference.Null; -// } -// -// public Location ExtendedEndLocation { get; set; } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitLambdaExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[LambdaExpression Parameters={0} StatementBody={1} ExpressionBody={2} ReturnType=" + -// "{3}]", GetCollectionString(Parameters), StatementBody, ExpressionBody, ReturnType); -// } -// } -// -// public class LockStatement : StatementWithEmbeddedStatement { -// -// Expression lockExpression; -// -// public Expression LockExpression { -// get { -// return lockExpression; -// } -// set { -// lockExpression = value ?? Expression.Null; -// if (!lockExpression.IsNull) lockExpression.Parent = this; -// } -// } -// -// public LockStatement(Expression lockExpression, Statement embeddedStatement) { -// LockExpression = lockExpression; -// EmbeddedStatement = embeddedStatement; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitLockStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[LockStatement LockExpression={0} EmbeddedStatement={1}]", LockExpression, EmbeddedStatement); -// } -// } -// -// public class MemberInitializerExpression : Expression { -// -// string name; -// -// bool isKey; -// -// Expression expression; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public bool IsKey { -// get { -// return isKey; -// } -// set { -// isKey = value; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public MemberInitializerExpression() { -// name = ""; -// expression = Expression.Null; -// } -// -// public MemberInitializerExpression(string name, Expression expression) { -// Name = name; -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitMemberInitializerExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[MemberInitializerExpression Name={0} IsKey={1} Expression={2}]", Name, IsKey, Expression); -// } -// } -// -// public abstract class MemberNode : ParametrizedNode { -// -// List interfaceImplementations; -// -// TypeReference typeReference; -// -// public List InterfaceImplementations { -// get { -// return interfaceImplementations; -// } -// set { -// interfaceImplementations = value ?? new List(); -// } -// } -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// protected MemberNode() { -// interfaceImplementations = new List(); -// typeReference = TypeReference.Null; -// } -// -// protected MemberNode(Modifiers modifier, List attributes, string name, List parameters) { -// Modifier = modifier; -// Attributes = attributes; -// Name = name; -// Parameters = parameters; -// interfaceImplementations = new List(); -// typeReference = TypeReference.Null; -// } -// } -// -// public class MemberReferenceExpression : Expression { -// -// Expression targetObject; -// -// string memberName; -// -// List typeArguments; -// -// public Expression TargetObject { -// get { -// return targetObject; -// } -// set { -// targetObject = value ?? Expression.Null; -// if (!targetObject.IsNull) targetObject.Parent = this; -// } -// } -// -// public string MemberName { -// get { -// return memberName; -// } -// set { -// memberName = value ?? ""; -// } -// } -// -// public List TypeArguments { -// get { -// return typeArguments; -// } -// set { -// typeArguments = value ?? new List(); -// } -// } -// -// public MemberReferenceExpression(Expression targetObject, string memberName) { -// TargetObject = targetObject; -// MemberName = memberName; -// typeArguments = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitMemberReferenceExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[MemberReferenceExpression TargetObject={0} MemberName={1} TypeArguments={2}]", TargetObject, MemberName, GetCollectionString(TypeArguments)); -// } -// } -// -// public class MethodDeclaration : MemberNode { -// -// BlockStatement body; -// -// List handlesClause; -// -// List templates; -// -// bool isExtensionMethod; -// -// public BlockStatement Body { -// get { -// return body; -// } -// set { -// body = value ?? BlockStatement.Null; -// if (!body.IsNull) body.Parent = this; -// } -// } -// -// public List HandlesClause { -// get { -// return handlesClause; -// } -// set { -// handlesClause = value ?? new List(); -// } -// } -// -// public List Templates { -// get { -// return templates; -// } -// set { -// templates = value ?? new List(); -// } -// } -// -// public bool IsExtensionMethod { -// get { -// return isExtensionMethod; -// } -// set { -// isExtensionMethod = value; -// } -// } -// -// public MethodDeclaration() { -// body = BlockStatement.Null; -// handlesClause = new List(); -// templates = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitMethodDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[MethodDeclaration Body={0} HandlesClause={1} Templates={2} IsExtensionMethod={3}" + -// " InterfaceImplementations={4} TypeReference={5} Name={6} Parameters={7} Attribut" + -// "es={8} Modifier={9}]", Body, GetCollectionString(HandlesClause), GetCollectionString(Templates), IsExtensionMethod, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class NamedArgumentExpression : Expression { -// -// string name; -// -// Expression expression; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public NamedArgumentExpression() { -// name = ""; -// expression = Expression.Null; -// } -// -// public NamedArgumentExpression(string name, Expression expression) { -// Name = name; -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitNamedArgumentExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[NamedArgumentExpression Name={0} Expression={1}]", Name, Expression); -// } -// } -// -// public class NamespaceDeclaration : AbstractNode { -// -// string name; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public NamespaceDeclaration(string name) { -// Name = name; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitNamespaceDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[NamespaceDeclaration Name={0}]", Name); -// } -// } -// -// public class ObjectCreateExpression : Expression { -// -// TypeReference createType; -// -// List parameters; -// -// CollectionInitializerExpression objectInitializer; -// -// public TypeReference CreateType { -// get { -// return createType; -// } -// set { -// createType = value ?? TypeReference.Null; -// if (!createType.IsNull) createType.Parent = this; -// } -// } -// -// public List Parameters { -// get { -// return parameters; -// } -// set { -// parameters = value ?? new List(); -// } -// } -// -// public CollectionInitializerExpression ObjectInitializer { -// get { -// return objectInitializer; -// } -// set { -// objectInitializer = value ?? CollectionInitializerExpression.Null; -// if (!objectInitializer.IsNull) objectInitializer.Parent = this; -// } -// } -// -// public ObjectCreateExpression(TypeReference createType, List parameters) { -// CreateType = createType; -// Parameters = parameters; -// objectInitializer = CollectionInitializerExpression.Null; -// } -// -// public bool IsAnonymousType { -// get { -// return createType.IsNull || string.IsNullOrEmpty(createType.Type); -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitObjectCreateExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ObjectCreateExpression CreateType={0} Parameters={1} ObjectInitializer={2}]", CreateType, GetCollectionString(Parameters), ObjectInitializer); -// } -// } -// -// public class OnErrorStatement : StatementWithEmbeddedStatement { -// -// public OnErrorStatement(Statement embeddedStatement) { -// EmbeddedStatement = embeddedStatement; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitOnErrorStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[OnErrorStatement EmbeddedStatement={0}]", EmbeddedStatement); -// } -// } -// -// public class OperatorDeclaration : MethodDeclaration { -// -// ConversionType conversionType; -// -// OverloadableOperatorType overloadableOperator; -// -// public ConversionType ConversionType { -// get { -// return conversionType; -// } -// set { -// conversionType = value; -// } -// } -// -// public OverloadableOperatorType OverloadableOperator { -// get { -// return overloadableOperator; -// } -// set { -// overloadableOperator = value; -// } -// } -// -// public OperatorDeclaration() { -// } -// -// public bool IsConversionOperator { -// get { -// return conversionType != ConversionType.None; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitOperatorDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[OperatorDeclaration ConversionType={0} OverloadableOperator={1} Body={2} Handles" + -// "Clause={3} Templates={4} IsExtensionMethod={5} InterfaceImplementations={6} Type" + -// "Reference={7} Name={8} Parameters={9} Attributes={10} Modifier={11}]", ConversionType, OverloadableOperator, Body, GetCollectionString(HandlesClause), GetCollectionString(Templates), IsExtensionMethod, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class ParameterDeclarationExpression : Expression { -// -// List attributes; -// -// string parameterName; -// -// TypeReference typeReference; -// -// ParameterModifiers paramModifier; -// -// Expression defaultValue; -// -// public List Attributes { -// get { -// return attributes; -// } -// set { -// attributes = value ?? new List(); -// } -// } -// -// public string ParameterName { -// get { -// return parameterName; -// } -// set { -// parameterName = string.IsNullOrEmpty(value) ? "?" : value; -// } -// } -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public ParameterModifiers ParamModifier { -// get { -// return paramModifier; -// } -// set { -// paramModifier = value; -// } -// } -// -// public Expression DefaultValue { -// get { -// return defaultValue; -// } -// set { -// defaultValue = value ?? Expression.Null; -// if (!defaultValue.IsNull) defaultValue.Parent = this; -// } -// } -// -// public ParameterDeclarationExpression(TypeReference typeReference, string parameterName) { -// TypeReference = typeReference; -// ParameterName = parameterName; -// attributes = new List(); -// defaultValue = Expression.Null; -// } -// -// public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier) { -// TypeReference = typeReference; -// ParameterName = parameterName; -// ParamModifier = paramModifier; -// attributes = new List(); -// defaultValue = Expression.Null; -// } -// -// public ParameterDeclarationExpression(TypeReference typeReference, string parameterName, ParameterModifiers paramModifier, Expression defaultValue) { -// TypeReference = typeReference; -// ParameterName = parameterName; -// ParamModifier = paramModifier; -// DefaultValue = defaultValue; -// attributes = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitParameterDeclarationExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ParameterDeclarationExpression Attributes={0} ParameterName={1} TypeReference={2" + -// "} ParamModifier={3} DefaultValue={4}]", GetCollectionString(Attributes), ParameterName, TypeReference, ParamModifier, DefaultValue); -// } -// } -// -// public abstract class ParametrizedNode : AttributedNode { -// -// string name; -// -// List parameters; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public List Parameters { -// get { -// return parameters; -// } -// set { -// parameters = value ?? new List(); -// } -// } -// -// protected ParametrizedNode() { -// name = ""; -// parameters = new List(); -// } -// -// protected ParametrizedNode(Modifiers modifier, List attributes, string name, List parameters) { -// Modifier = modifier; -// Attributes = attributes; -// Name = name; -// Parameters = parameters; -// } -// } -// -// public class ParenthesizedExpression : Expression { -// -// Expression expression; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public ParenthesizedExpression(Expression expression) { -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitParenthesizedExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ParenthesizedExpression Expression={0}]", Expression); -// } -// } -// -// public class PropertyDeclaration : MemberNode { -// -// Location bodyStart; -// -// Location bodyEnd; -// -// PropertyGetRegion getRegion; -// -// PropertySetRegion setRegion; -// -// Expression initializer; -// -// public Location BodyStart { -// get { -// return bodyStart; -// } -// set { -// bodyStart = value; -// } -// } -// -// public Location BodyEnd { -// get { -// return bodyEnd; -// } -// set { -// bodyEnd = value; -// } -// } -// -// public PropertyGetRegion GetRegion { -// get { -// return getRegion; -// } -// set { -// getRegion = value ?? PropertyGetRegion.Null; -// if (!getRegion.IsNull) getRegion.Parent = this; -// } -// } -// -// public PropertySetRegion SetRegion { -// get { -// return setRegion; -// } -// set { -// setRegion = value ?? PropertySetRegion.Null; -// if (!setRegion.IsNull) setRegion.Parent = this; -// } -// } -// -// public Expression Initializer { -// get { -// return initializer; -// } -// set { -// initializer = value ?? Expression.Null; -// if (!initializer.IsNull) initializer.Parent = this; -// } -// } -// -// public PropertyDeclaration(Modifiers modifier, List attributes, string name, List parameters) { -// Modifier = modifier; -// Attributes = attributes; -// Name = name; -// Parameters = parameters; -// bodyStart = Location.Empty; -// bodyEnd = Location.Empty; -// getRegion = PropertyGetRegion.Null; -// setRegion = PropertySetRegion.Null; -// initializer = Expression.Null; -// } -// -// public bool IsReadOnly { -// get { -// return HasGetRegion && !HasSetRegion; -// } -// } -// -// public bool HasGetRegion { -// get { -// return !getRegion.IsNull; -// } -// } -// -// public bool IsWriteOnly { -// get { -// return !HasGetRegion && HasSetRegion; -// } -// } -// -// public bool IsIndexer { -// get { -// return (Modifier & Modifiers.Default) != 0; -// } -// } -// -// -// internal PropertyDeclaration(string name, TypeReference typeReference, Modifiers modifier, List attributes) : this(modifier, attributes, name, null) -// { -// this.TypeReference = typeReference; -// if ((modifier & Modifiers.ReadOnly) != Modifiers.ReadOnly) { -// this.SetRegion = new PropertySetRegion(null, null); -// } -// if ((modifier & Modifiers.WriteOnly) != Modifiers.WriteOnly) { -// this.GetRegion = new PropertyGetRegion(null, null); -// } -// } -// -// public bool HasSetRegion { -// get { -// return !setRegion.IsNull; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitPropertyDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[PropertyDeclaration BodyStart={0} BodyEnd={1} GetRegion={2} SetRegion={3} Initia" + -// "lizer={4} InterfaceImplementations={5} TypeReference={6} Name={7} Parameters={8}" + -// " Attributes={9} Modifier={10}]", BodyStart, BodyEnd, GetRegion, SetRegion, Initializer, GetCollectionString(InterfaceImplementations), TypeReference, Name, GetCollectionString(Parameters), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class PropertyGetRegion : PropertyGetSetRegion { -// -// public PropertyGetRegion(BlockStatement block, List attributes) : -// base(block, attributes) { -// } -// -// public static PropertyGetRegion Null { -// get { -// return NullPropertyGetRegion.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitPropertyGetRegion(this, data); -// } -// -// public override string ToString() { -// return string.Format("[PropertyGetRegion Block={0} Attributes={1} Modifier={2}]", Block, GetCollectionString(Attributes), Modifier); -// } -// } -// -// internal sealed class NullPropertyGetRegion : PropertyGetRegion { -// -// private NullPropertyGetRegion() : -// base(null, null) { -// } -// -// internal static NullPropertyGetRegion Instance = new NullPropertyGetRegion(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullPropertyGetRegion]"; -// } -// } -// -// public abstract class PropertyGetSetRegion : AttributedNode, INullable { -// -// BlockStatement block; -// -// public BlockStatement Block { -// get { -// return block; -// } -// set { -// block = value ?? BlockStatement.Null; -// if (!block.IsNull) block.Parent = this; -// } -// } -// -// protected PropertyGetSetRegion(BlockStatement block, List attributes) { -// Block = block; -// Attributes = attributes; -// } -// -// public virtual bool IsNull { -// get { -// return false; -// } -// } -// } -// -// public class PropertySetRegion : PropertyGetSetRegion { -// -// List parameters; -// -// public List Parameters { -// get { -// return parameters; -// } -// set { -// parameters = value ?? new List(); -// } -// } -// -// public PropertySetRegion(BlockStatement block, List attributes) : -// base(block, attributes) { -// parameters = new List(); -// } -// -// public static PropertySetRegion Null { -// get { -// return NullPropertySetRegion.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitPropertySetRegion(this, data); -// } -// -// public override string ToString() { -// return string.Format("[PropertySetRegion Parameters={0} Block={1} Attributes={2} Modifier={3}]", GetCollectionString(Parameters), Block, GetCollectionString(Attributes), Modifier); -// } -// } -// -// internal sealed class NullPropertySetRegion : PropertySetRegion { -// -// private NullPropertySetRegion() : -// base(null, null) { -// } -// -// internal static NullPropertySetRegion Instance = new NullPropertySetRegion(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullPropertySetRegion]"; -// } -// } -// -// public class QueryExpression : Expression { -// -// List clauses; -// -// public List Clauses { -// get { -// return clauses; -// } -// set { -// clauses = value ?? new List(); -// } -// } -// -// public QueryExpression() { -// clauses = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpression Clauses={0}]", GetCollectionString(Clauses)); -// } -// } -// -// public class QueryExpressionAggregateClause : QueryExpressionClause { -// -// CollectionRangeVariable source; -// -// List middleClauses; -// -// List intoVariables; -// -// public CollectionRangeVariable Source { -// get { -// return source; -// } -// set { -// source = value ?? CollectionRangeVariable.Null; -// if (!source.IsNull) source.Parent = this; -// } -// } -// -// public List MiddleClauses { -// get { -// return middleClauses; -// } -// set { -// middleClauses = value ?? new List(); -// } -// } -// -// public List IntoVariables { -// get { -// return intoVariables; -// } -// set { -// intoVariables = value ?? new List(); -// } -// } -// -// public QueryExpressionAggregateClause() { -// source = CollectionRangeVariable.Null; -// middleClauses = new List(); -// intoVariables = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionAggregateClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionAggregateClause Source={0} MiddleClauses={1} IntoVariables={2}]", Source, GetCollectionString(MiddleClauses), GetCollectionString(IntoVariables)); -// } -// } -// -// public abstract class QueryExpressionClause : AbstractNode, INullable { -// -// protected QueryExpressionClause() { -// } -// -// public virtual bool IsNull { -// get { -// return false; -// } -// } -// -// public static QueryExpressionClause Null { -// get { -// return NullQueryExpressionClause.Instance; -// } -// } -// } -// -// internal sealed class NullQueryExpressionClause : QueryExpressionClause { -// -// internal static NullQueryExpressionClause Instance = new NullQueryExpressionClause(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullQueryExpressionClause]"; -// } -// } -// -// public class QueryExpressionDistinctClause : QueryExpressionClause { -// -// public QueryExpressionDistinctClause() { -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionDistinctClause(this, data); -// } -// -// public override string ToString() { -// return "[QueryExpressionDistinctClause]"; -// } -// } -// -// public class QueryExpressionFromClause : QueryExpressionClause { -// -// List sources; -// -// public List Sources { -// get { -// return sources; -// } -// set { -// sources = value ?? new List(); -// } -// } -// -// public QueryExpressionFromClause() { -// sources = new List(); -// } -// -// public new static QueryExpressionFromClause Null { -// get { -// return NullQueryExpressionFromClause.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionFromClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionFromClause Sources={0}]", GetCollectionString(Sources)); -// } -// } -// -// internal sealed class NullQueryExpressionFromClause : QueryExpressionFromClause { -// -// internal static NullQueryExpressionFromClause Instance = new NullQueryExpressionFromClause(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullQueryExpressionFromClause]"; -// } -// } -// -// public class QueryExpressionGroupClause : QueryExpressionClause { -// -// Expression projection; -// -// Expression groupBy; -// -// public Expression Projection { -// get { -// return projection; -// } -// set { -// projection = value ?? Expression.Null; -// if (!projection.IsNull) projection.Parent = this; -// } -// } -// -// public Expression GroupBy { -// get { -// return groupBy; -// } -// set { -// groupBy = value ?? Expression.Null; -// if (!groupBy.IsNull) groupBy.Parent = this; -// } -// } -// -// public QueryExpressionGroupClause() { -// projection = Expression.Null; -// groupBy = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionGroupClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionGroupClause Projection={0} GroupBy={1}]", Projection, GroupBy); -// } -// } -// -// public class QueryExpressionGroupJoinVBClause : QueryExpressionClause { -// -// QueryExpressionJoinVBClause joinClause; -// -// List intoVariables; -// -// public QueryExpressionJoinVBClause JoinClause { -// get { -// return joinClause; -// } -// set { -// joinClause = value ?? QueryExpressionJoinVBClause.Null; -// if (!joinClause.IsNull) joinClause.Parent = this; -// } -// } -// -// public List IntoVariables { -// get { -// return intoVariables; -// } -// set { -// intoVariables = value ?? new List(); -// } -// } -// -// public QueryExpressionGroupJoinVBClause() { -// joinClause = QueryExpressionJoinVBClause.Null; -// intoVariables = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionGroupJoinVBClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionGroupJoinVBClause JoinClause={0} IntoVariables={1}]", JoinClause, GetCollectionString(IntoVariables)); -// } -// } -// -// public class QueryExpressionGroupVBClause : QueryExpressionClause { -// -// List groupVariables; -// -// List byVariables; -// -// List intoVariables; -// -// public List GroupVariables { -// get { -// return groupVariables; -// } -// set { -// groupVariables = value ?? new List(); -// } -// } -// -// public List ByVariables { -// get { -// return byVariables; -// } -// set { -// byVariables = value ?? new List(); -// } -// } -// -// public List IntoVariables { -// get { -// return intoVariables; -// } -// set { -// intoVariables = value ?? new List(); -// } -// } -// -// public QueryExpressionGroupVBClause() { -// groupVariables = new List(); -// byVariables = new List(); -// intoVariables = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionGroupVBClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionGroupVBClause GroupVariables={0} ByVariables={1} IntoVariables={2" + -// "}]", GetCollectionString(GroupVariables), GetCollectionString(ByVariables), GetCollectionString(IntoVariables)); -// } -// } -// -// public class QueryExpressionJoinClause : QueryExpressionClause { -// -// Expression onExpression; -// -// Expression equalsExpression; -// -// CollectionRangeVariable source; -// -// string intoIdentifier; -// -// public Expression OnExpression { -// get { -// return onExpression; -// } -// set { -// onExpression = value ?? Expression.Null; -// if (!onExpression.IsNull) onExpression.Parent = this; -// } -// } -// -// public Expression EqualsExpression { -// get { -// return equalsExpression; -// } -// set { -// equalsExpression = value ?? Expression.Null; -// if (!equalsExpression.IsNull) equalsExpression.Parent = this; -// } -// } -// -// public CollectionRangeVariable Source { -// get { -// return source; -// } -// set { -// source = value ?? CollectionRangeVariable.Null; -// if (!source.IsNull) source.Parent = this; -// } -// } -// -// public string IntoIdentifier { -// get { -// return intoIdentifier; -// } -// set { -// intoIdentifier = value ?? ""; -// } -// } -// -// public QueryExpressionJoinClause() { -// onExpression = Expression.Null; -// equalsExpression = Expression.Null; -// source = CollectionRangeVariable.Null; -// intoIdentifier = ""; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionJoinClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionJoinClause OnExpression={0} EqualsExpression={1} Source={2} IntoI" + -// "dentifier={3}]", OnExpression, EqualsExpression, Source, IntoIdentifier); -// } -// } -// -// public class QueryExpressionJoinConditionVB : AbstractNode { -// -// Expression leftSide; -// -// Expression rightSide; -// -// public Expression LeftSide { -// get { -// return leftSide; -// } -// set { -// leftSide = value ?? Expression.Null; -// if (!leftSide.IsNull) leftSide.Parent = this; -// } -// } -// -// public Expression RightSide { -// get { -// return rightSide; -// } -// set { -// rightSide = value ?? Expression.Null; -// if (!rightSide.IsNull) rightSide.Parent = this; -// } -// } -// -// public QueryExpressionJoinConditionVB() { -// leftSide = Expression.Null; -// rightSide = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionJoinConditionVB(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionJoinConditionVB LeftSide={0} RightSide={1}]", LeftSide, RightSide); -// } -// } -// -// public class QueryExpressionJoinVBClause : QueryExpressionClause { -// -// CollectionRangeVariable joinVariable; -// -// QueryExpressionJoinVBClause subJoin; -// -// List conditions; -// -// public CollectionRangeVariable JoinVariable { -// get { -// return joinVariable; -// } -// set { -// joinVariable = value ?? CollectionRangeVariable.Null; -// if (!joinVariable.IsNull) joinVariable.Parent = this; -// } -// } -// -// public QueryExpressionJoinVBClause SubJoin { -// get { -// return subJoin; -// } -// set { -// subJoin = value ?? QueryExpressionJoinVBClause.Null; -// if (!subJoin.IsNull) subJoin.Parent = this; -// } -// } -// -// public List Conditions { -// get { -// return conditions; -// } -// set { -// conditions = value ?? new List(); -// } -// } -// -// public QueryExpressionJoinVBClause() { -// joinVariable = CollectionRangeVariable.Null; -// subJoin = QueryExpressionJoinVBClause.Null; -// conditions = new List(); -// } -// -// public new static QueryExpressionJoinVBClause Null { -// get { -// return NullQueryExpressionJoinVBClause.Instance; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionJoinVBClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionJoinVBClause JoinVariable={0} SubJoin={1} Conditions={2}]", JoinVariable, SubJoin, GetCollectionString(Conditions)); -// } -// } -// -// internal sealed class NullQueryExpressionJoinVBClause : QueryExpressionJoinVBClause { -// -// internal static NullQueryExpressionJoinVBClause Instance = new NullQueryExpressionJoinVBClause(); -// -// public override bool IsNull { -// get { -// return true; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return null; -// } -// -// public override string ToString() { -// return "[NullQueryExpressionJoinVBClause]"; -// } -// } -// -// public class QueryExpressionLetClause : QueryExpressionClause { -// -// List variables; -// -// public List Variables { -// get { -// return variables; -// } -// set { -// variables = value ?? new List(); -// } -// } -// -// public QueryExpressionLetClause() { -// variables = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionLetVBClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionLetVBClause Variables={0}]", GetCollectionString(Variables)); -// } -// } -// -// public class QueryExpressionOrderClause : QueryExpressionClause { -// -// List orderings; -// -// public List Orderings { -// get { -// return orderings; -// } -// set { -// orderings = value ?? new List(); -// } -// } -// -// public QueryExpressionOrderClause() { -// orderings = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionOrderClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionOrderClause Orderings={0}]", GetCollectionString(Orderings)); -// } -// } -// -// public class QueryExpressionOrdering : AbstractNode { -// -// Expression criteria; -// -// QueryExpressionOrderingDirection direction; -// -// public Expression Criteria { -// get { -// return criteria; -// } -// set { -// criteria = value ?? Expression.Null; -// if (!criteria.IsNull) criteria.Parent = this; -// } -// } -// -// public QueryExpressionOrderingDirection Direction { -// get { -// return direction; -// } -// set { -// direction = value; -// } -// } -// -// public QueryExpressionOrdering() { -// criteria = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionOrdering(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionOrdering Criteria={0} Direction={1}]", Criteria, Direction); -// } -// } -// -// public class QueryExpressionPartitionVBClause : QueryExpressionClause { -// -// Expression expression; -// -// QueryExpressionPartitionType partitionType; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public QueryExpressionPartitionType PartitionType { -// get { -// return partitionType; -// } -// set { -// partitionType = value; -// } -// } -// -// public QueryExpressionPartitionVBClause() { -// expression = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionPartitionVBClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionPartitionVBClause Expression={0} PartitionType={1}]", Expression, PartitionType); -// } -// } -// -// public class QueryExpressionSelectClause : QueryExpressionClause { -// -// Expression projection; -// -// public Expression Projection { -// get { -// return projection; -// } -// set { -// projection = value ?? Expression.Null; -// if (!projection.IsNull) projection.Parent = this; -// } -// } -// -// public QueryExpressionSelectClause() { -// projection = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionSelectClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionSelectClause Projection={0}]", Projection); -// } -// } -// -// public class QueryExpressionSelectVBClause : QueryExpressionClause { -// -// List variables; -// -// public List Variables { -// get { -// return variables; -// } -// set { -// variables = value ?? new List(); -// } -// } -// -// public QueryExpressionSelectVBClause() { -// variables = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionSelectVBClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionSelectVBClause Variables={0}]", GetCollectionString(Variables)); -// } -// } -// -// public class QueryExpressionWhereClause : QueryExpressionClause { -// -// Expression condition; -// -// public Expression Condition { -// get { -// return condition; -// } -// set { -// condition = value ?? Expression.Null; -// if (!condition.IsNull) condition.Parent = this; -// } -// } -// -// public QueryExpressionWhereClause() { -// condition = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitQueryExpressionWhereClause(this, data); -// } -// -// public override string ToString() { -// return string.Format("[QueryExpressionWhereClause Condition={0}]", Condition); -// } -// } -// -// public class RaiseEventStatement : Statement { -// -// string eventName; -// -// List arguments; -// -// public string EventName { -// get { -// return eventName; -// } -// set { -// eventName = value ?? ""; -// } -// } -// -// public List Arguments { -// get { -// return arguments; -// } -// set { -// arguments = value ?? new List(); -// } -// } -// -// public RaiseEventStatement(string eventName, List arguments) { -// EventName = eventName; -// Arguments = arguments; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitRaiseEventStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[RaiseEventStatement EventName={0} Arguments={1}]", EventName, GetCollectionString(Arguments)); -// } -// } -// -// public class ReDimStatement : Statement { -// -// List reDimClauses; -// -// bool isPreserve; -// -// public List ReDimClauses { -// get { -// return reDimClauses; -// } -// set { -// reDimClauses = value ?? new List(); -// } -// } -// -// public bool IsPreserve { -// get { -// return isPreserve; -// } -// set { -// isPreserve = value; -// } -// } -// -// public ReDimStatement(bool isPreserve) { -// IsPreserve = isPreserve; -// reDimClauses = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitReDimStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ReDimStatement ReDimClauses={0} IsPreserve={1}]", GetCollectionString(ReDimClauses), IsPreserve); -// } -// } -// -// public class RemoveHandlerStatement : Statement { -// -// Expression eventExpression; -// -// Expression handlerExpression; -// -// public Expression EventExpression { -// get { -// return eventExpression; -// } -// set { -// eventExpression = value ?? Expression.Null; -// if (!eventExpression.IsNull) eventExpression.Parent = this; -// } -// } -// -// public Expression HandlerExpression { -// get { -// return handlerExpression; -// } -// set { -// handlerExpression = value ?? Expression.Null; -// if (!handlerExpression.IsNull) handlerExpression.Parent = this; -// } -// } -// -// public RemoveHandlerStatement(Expression eventExpression, Expression handlerExpression) { -// EventExpression = eventExpression; -// HandlerExpression = handlerExpression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitRemoveHandlerStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[RemoveHandlerStatement EventExpression={0} HandlerExpression={1}]", EventExpression, HandlerExpression); -// } -// } -// -// public class ResumeStatement : Statement { -// -// string labelName; -// -// bool isResumeNext; -// -// public string LabelName { -// get { -// return labelName; -// } -// set { -// labelName = value ?? ""; -// } -// } -// -// public bool IsResumeNext { -// get { -// return isResumeNext; -// } -// set { -// isResumeNext = value; -// } -// } -// -// public ResumeStatement(bool isResumeNext) { -// IsResumeNext = isResumeNext; -// labelName = ""; -// } -// -// public ResumeStatement(string labelName) { -// LabelName = labelName; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitResumeStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ResumeStatement LabelName={0} IsResumeNext={1}]", LabelName, IsResumeNext); -// } -// } -// -// public class ReturnStatement : Statement { -// -// Expression expression; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public ReturnStatement(Expression expression) { -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitReturnStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ReturnStatement Expression={0}]", Expression); -// } -// } -// -// public class StopStatement : Statement { -// -// public StopStatement() { -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitStopStatement(this, data); -// } -// -// public override string ToString() { -// return "[StopStatement]"; -// } -// } -// -// public class SwitchSection : BlockStatement { -// -// List switchLabels; -// -// public List SwitchLabels { -// get { -// return switchLabels; -// } -// set { -// switchLabels = value ?? new List(); -// } -// } -// -// public SwitchSection() { -// switchLabels = new List(); -// } -// -// public SwitchSection(List switchLabels) { -// SwitchLabels = switchLabels; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitSwitchSection(this, data); -// } -// -// public override string ToString() { -// return string.Format("[SwitchSection SwitchLabels={0}]", GetCollectionString(SwitchLabels)); -// } -// } -// -// public class SwitchStatement : Statement { -// -// Expression switchExpression; -// -// List switchSections; -// -// public Expression SwitchExpression { -// get { -// return switchExpression; -// } -// set { -// switchExpression = value ?? Expression.Null; -// if (!switchExpression.IsNull) switchExpression.Parent = this; -// } -// } -// -// public List SwitchSections { -// get { -// return switchSections; -// } -// set { -// switchSections = value ?? new List(); -// } -// } -// -// public SwitchStatement(Expression switchExpression, List switchSections) { -// SwitchExpression = switchExpression; -// SwitchSections = switchSections; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitSwitchStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[SwitchStatement SwitchExpression={0} SwitchSections={1}]", SwitchExpression, GetCollectionString(SwitchSections)); -// } -// } -// -// public class TemplateDefinition : AttributedNode { -// -// string name; -// -// VarianceModifier varianceModifier; -// -// List bases; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = string.IsNullOrEmpty(value) ? "?" : value; -// } -// } -// -// public VarianceModifier VarianceModifier { -// get { -// return varianceModifier; -// } -// set { -// varianceModifier = value; -// } -// } -// -// public List Bases { -// get { -// return bases; -// } -// set { -// bases = value ?? new List(); -// } -// } -// -// public TemplateDefinition() { -// name = "?"; -// bases = new List(); -// } -// -// public TemplateDefinition(string name, List attributes) { -// Name = name; -// Attributes = attributes; -// bases = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitTemplateDefinition(this, data); -// } -// -// public override string ToString() { -// return string.Format("[TemplateDefinition Name={0} VarianceModifier={1} Bases={2} Attributes={3} Modifi" + -// "er={4}]", Name, VarianceModifier, GetCollectionString(Bases), GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class ThisReferenceExpression : Expression { -// -// public ThisReferenceExpression() { -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitThisReferenceExpression(this, data); -// } -// -// public override string ToString() { -// return "[ThisReferenceExpression]"; -// } -// } -// -// public class ThrowStatement : Statement { -// -// Expression expression; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public ThrowStatement(Expression expression) { -// Expression = expression; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitThrowStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[ThrowStatement Expression={0}]", Expression); -// } -// } -// -// public class TryCatchStatement : Statement { -// -// Statement statementBlock; -// -// List catchClauses; -// -// Statement finallyBlock; -// -// public Statement StatementBlock { -// get { -// return statementBlock; -// } -// set { -// statementBlock = value ?? Statement.Null; -// if (!statementBlock.IsNull) statementBlock.Parent = this; -// } -// } -// -// public List CatchClauses { -// get { -// return catchClauses; -// } -// set { -// catchClauses = value ?? new List(); -// } -// } -// -// public Statement FinallyBlock { -// get { -// return finallyBlock; -// } -// set { -// finallyBlock = value ?? Statement.Null; -// if (!finallyBlock.IsNull) finallyBlock.Parent = this; -// } -// } -// -// public TryCatchStatement(Statement statementBlock, List catchClauses, Statement finallyBlock) { -// StatementBlock = statementBlock; -// CatchClauses = catchClauses; -// FinallyBlock = finallyBlock; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitTryCatchStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[TryCatchStatement StatementBlock={0} CatchClauses={1} FinallyBlock={2}]", StatementBlock, GetCollectionString(CatchClauses), FinallyBlock); -// } -// } -// -// public class TypeDeclaration : AttributedNode { -// -// string name; -// -// ClassType type; -// -// List baseTypes; -// -// List templates; -// -// Location bodyStartLocation; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public ClassType Type { -// get { -// return type; -// } -// set { -// type = value; -// } -// } -// -// public List BaseTypes { -// get { -// return baseTypes; -// } -// set { -// baseTypes = value ?? new List(); -// } -// } -// -// public List Templates { -// get { -// return templates; -// } -// set { -// templates = value ?? new List(); -// } -// } -// -// public Location BodyStartLocation { -// get { -// return bodyStartLocation; -// } -// set { -// bodyStartLocation = value; -// } -// } -// -// public TypeDeclaration(Modifiers modifier, List attributes) { -// Modifier = modifier; -// Attributes = attributes; -// name = ""; -// baseTypes = new List(); -// templates = new List(); -// bodyStartLocation = Location.Empty; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitTypeDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[TypeDeclaration Name={0} Type={1} BaseTypes={2} Templates={3} BodyStartLocation=" + -// "{4} Attributes={5} Modifier={6}]", Name, Type, GetCollectionString(BaseTypes), GetCollectionString(Templates), BodyStartLocation, GetCollectionString(Attributes), Modifier); -// } -// } -// -// public class TypeOfExpression : Expression { -// -// TypeReference typeReference; -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public TypeOfExpression(TypeReference typeReference) { -// TypeReference = typeReference; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitTypeOfExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[TypeOfExpression TypeReference={0}]", TypeReference); -// } -// } -// -// public class TypeOfIsExpression : Expression { -// -// Expression expression; -// -// TypeReference typeReference; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public TypeOfIsExpression(Expression expression, TypeReference typeReference) { -// Expression = expression; -// TypeReference = typeReference; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitTypeOfIsExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[TypeOfIsExpression Expression={0} TypeReference={1}]", Expression, TypeReference); -// } -// } -// -// public class TypeReferenceExpression : Expression { -// -// TypeReference typeReference; -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public TypeReferenceExpression(TypeReference typeReference) { -// TypeReference = typeReference; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitTypeReferenceExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[TypeReferenceExpression TypeReference={0}]", TypeReference); -// } -// } -// -// public class UnaryOperatorExpression : Expression { -// -// UnaryOperatorType op; -// -// Expression expression; -// -// public UnaryOperatorType Op { -// get { -// return op; -// } -// set { -// op = value; -// } -// } -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public UnaryOperatorExpression(UnaryOperatorType op) { -// Op = op; -// expression = Expression.Null; -// } -// -// public UnaryOperatorExpression(Expression expression, UnaryOperatorType op) { -// Expression = expression; -// Op = op; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitUnaryOperatorExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[UnaryOperatorExpression Op={0} Expression={1}]", Op, Expression); -// } -// } -// -// public class UsingStatement : StatementWithEmbeddedStatement { -// -// Statement resourceAcquisition; -// -// public Statement ResourceAcquisition { -// get { -// return resourceAcquisition; -// } -// set { -// resourceAcquisition = value ?? Statement.Null; -// if (!resourceAcquisition.IsNull) resourceAcquisition.Parent = this; -// } -// } -// -// public UsingStatement(Statement resourceAcquisition, Statement embeddedStatement) { -// ResourceAcquisition = resourceAcquisition; -// EmbeddedStatement = embeddedStatement; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitUsingStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[UsingStatement ResourceAcquisition={0} EmbeddedStatement={1}]", ResourceAcquisition, EmbeddedStatement); -// } -// } -// -// public class VariableDeclaration : AbstractNode { -// -// string name; -// -// Expression initializer; -// -// TypeReference typeReference; -// -// Expression fixedArrayInitialization; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public Expression Initializer { -// get { -// return initializer; -// } -// set { -// initializer = value ?? Expression.Null; -// if (!initializer.IsNull) initializer.Parent = this; -// } -// } -// -// public TypeReference TypeReference { -// get { -// return typeReference; -// } -// set { -// typeReference = value ?? TypeReference.Null; -// if (!typeReference.IsNull) typeReference.Parent = this; -// } -// } -// -// public Expression FixedArrayInitialization { -// get { -// return fixedArrayInitialization; -// } -// set { -// fixedArrayInitialization = value ?? Expression.Null; -// if (!fixedArrayInitialization.IsNull) fixedArrayInitialization.Parent = this; -// } -// } -// -// public VariableDeclaration(string name) { -// Name = name; -// initializer = Expression.Null; -// typeReference = TypeReference.Null; -// fixedArrayInitialization = Expression.Null; -// } -// -// public VariableDeclaration(string name, Expression initializer) { -// Name = name; -// Initializer = initializer; -// typeReference = TypeReference.Null; -// fixedArrayInitialization = Expression.Null; -// } -// -// public VariableDeclaration(string name, Expression initializer, TypeReference typeReference) { -// Name = name; -// Initializer = initializer; -// TypeReference = typeReference; -// fixedArrayInitialization = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitVariableDeclaration(this, data); -// } -// -// public override string ToString() { -// return string.Format("[VariableDeclaration Name={0} Initializer={1} TypeReference={2} FixedArrayInitial" + -// "ization={3}]", Name, Initializer, TypeReference, FixedArrayInitialization); -// } -// } -// -// public class WithStatement : Statement { -// -// Expression expression; -// -// BlockStatement body; -// -// public Expression Expression { -// get { -// return expression; -// } -// set { -// expression = value ?? Expression.Null; -// if (!expression.IsNull) expression.Parent = this; -// } -// } -// -// public BlockStatement Body { -// get { -// return body; -// } -// set { -// body = value ?? BlockStatement.Null; -// if (!body.IsNull) body.Parent = this; -// } -// } -// -// public WithStatement(Expression expression) { -// Expression = expression; -// body = BlockStatement.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitWithStatement(this, data); -// } -// -// public override string ToString() { -// return string.Format("[WithStatement Expression={0} Body={1}]", Expression, Body); -// } -// } -// -// public class XmlAttributeExpression : XmlExpression { -// -// string name; -// -// string literalValue; -// -// bool useDoubleQuotes; -// -// Expression expressionValue; -// -// public string Name { -// get { -// return name; -// } -// set { -// name = value ?? ""; -// } -// } -// -// public string LiteralValue { -// get { -// return literalValue; -// } -// set { -// literalValue = value ?? ""; -// } -// } -// -// public bool UseDoubleQuotes { -// get { -// return useDoubleQuotes; -// } -// set { -// useDoubleQuotes = value; -// } -// } -// -// public Expression ExpressionValue { -// get { -// return expressionValue; -// } -// set { -// expressionValue = value ?? Expression.Null; -// if (!expressionValue.IsNull) expressionValue.Parent = this; -// } -// } -// -// public XmlAttributeExpression() { -// name = ""; -// literalValue = ""; -// expressionValue = Expression.Null; -// } -// -// public bool IsLiteralValue { -// get { -// return expressionValue.IsNull; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitXmlAttributeExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[XmlAttributeExpression Name={0} LiteralValue={1} UseDoubleQuotes={2} ExpressionV" + -// "alue={3}]", Name, LiteralValue, UseDoubleQuotes, ExpressionValue); -// } -// } -// -// public class XmlContentExpression : XmlExpression { -// -// string content; -// -// XmlContentType type; -// -// public string Content { -// get { -// return content; -// } -// set { -// content = value ?? ""; -// } -// } -// -// public XmlContentType Type { -// get { -// return type; -// } -// set { -// type = value; -// } -// } -// -// public XmlContentExpression(string content, XmlContentType type) { -// Content = content; -// Type = type; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitXmlContentExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[XmlContentExpression Content={0} Type={1}]", Content, Type); -// } -// } -// -// public class XmlDocumentExpression : XmlExpression { -// -// List expressions; -// -// public List Expressions { -// get { -// return expressions; -// } -// set { -// expressions = value ?? new List(); -// } -// } -// -// public XmlDocumentExpression() { -// expressions = new List(); -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitXmlDocumentExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[XmlDocumentExpression Expressions={0}]", GetCollectionString(Expressions)); -// } -// } -// -// public class XmlElementExpression : XmlExpression { -// -// Expression content; -// -// Expression nameExpression; -// -// string xmlName; -// -// List attributes; -// -// public Expression Content { -// get { -// return content; -// } -// set { -// content = value ?? Expression.Null; -// if (!content.IsNull) content.Parent = this; -// } -// } -// -// public Expression NameExpression { -// get { -// return nameExpression; -// } -// set { -// nameExpression = value ?? Expression.Null; -// if (!nameExpression.IsNull) nameExpression.Parent = this; -// } -// } -// -// public string XmlName { -// get { -// return xmlName; -// } -// set { -// xmlName = value ?? ""; -// } -// } -// -// public List Attributes { -// get { -// return attributes; -// } -// set { -// attributes = value ?? new List(); -// } -// } -// -// public XmlElementExpression() { -// content = Expression.Null; -// nameExpression = Expression.Null; -// xmlName = ""; -// attributes = new List(); -// } -// -// public bool IsExpression { -// get { -// return !content.IsNull; -// } -// } -// -// public bool NameIsExpression { -// get { -// return !nameExpression.IsNull; -// } -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitXmlElementExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[XmlElementExpression Content={0} NameExpression={1} XmlName={2} Attributes={3}]", Content, NameExpression, XmlName, GetCollectionString(Attributes)); -// } -// } -// -// public class XmlEmbeddedExpression : XmlExpression { -// -// Expression inlineVBExpression; -// -// public Expression InlineVBExpression { -// get { -// return inlineVBExpression; -// } -// set { -// inlineVBExpression = value ?? Expression.Null; -// if (!inlineVBExpression.IsNull) inlineVBExpression.Parent = this; -// } -// } -// -// public XmlEmbeddedExpression() { -// inlineVBExpression = Expression.Null; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitXmlEmbeddedExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[XmlEmbeddedExpression InlineVBExpression={0}]", InlineVBExpression); -// } -// } -// -// public abstract class XmlExpression : Expression { -// -// protected XmlExpression() { -// } -// } -// -// public class XmlMemberAccessExpression : Expression { -// -// Expression targetObject; -// -// XmlAxisType axisType; -// -// bool isXmlIdentifier; -// -// string identifier; -// -// public Expression TargetObject { -// get { -// return targetObject; -// } -// set { -// targetObject = value ?? Expression.Null; -// if (!targetObject.IsNull) targetObject.Parent = this; -// } -// } -// -// public XmlAxisType AxisType { -// get { -// return axisType; -// } -// set { -// axisType = value; -// } -// } -// -// public bool IsXmlIdentifier { -// get { -// return isXmlIdentifier; -// } -// set { -// isXmlIdentifier = value; -// } -// } -// -// public string Identifier { -// get { -// return identifier; -// } -// set { -// identifier = value ?? ""; -// } -// } -// -// public XmlMemberAccessExpression(Expression targetObject, XmlAxisType axisType, string identifier, bool isXmlIdentifier) { -// TargetObject = targetObject; -// AxisType = axisType; -// Identifier = identifier; -// IsXmlIdentifier = isXmlIdentifier; -// } -// -// public override object AcceptVisitor(IAstVisitor visitor, object data) { -// return visitor.VisitXmlMemberAccessExpression(this, data); -// } -// -// public override string ToString() { -// return string.Format("[XmlMemberAccessExpression TargetObject={0} AxisType={1} IsXmlIdentifier={2} Iden" + -// "tifier={3}]", TargetObject, AxisType, IsXmlIdentifier, Identifier); -// } -// } -//} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs deleted file mode 100644 index 8a88c9135..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/DelegateDeclaration.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs deleted file mode 100644 index 736d579ff..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumDeclaration.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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 Members { - 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) && - Members.DoMatch(decl.Members, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitEnumDeclaration(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs deleted file mode 100644 index 72e757c60..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/EnumMemberDeclaration.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsClause.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsClause.cs deleted file mode 100644 index a9d7f45bf..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsClause.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public abstract class ImportsClause : AstNode - { - public new static readonly ImportsClause Null = new NullImportsClause(); - - class NullImportsClause : ImportsClause - { - public override bool IsNull { - get { return true; } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - return other != null && other.IsNull; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return default(S); - } - } - } - - public class AliasImportsClause : ImportsClause - { - public Identifier Name { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public AstType Alias { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var clause = other as AliasImportsClause; - return clause != null - && Name.DoMatch(clause.Name, match) - && Alias.DoMatch(clause.Alias, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAliasImportsClause(this, data); - } - - public override string ToString() { - return string.Format("[AliasImportsClause Name={0} Alias={1}]", Name, Alias); - } - } - - public class MemberImportsClause : ImportsClause - { - public AstType Member { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var node = other as MemberImportsClause; - return node != null - && Member.DoMatch(node.Member, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitMemberImportsClause(this, data); - } - - public override string ToString() - { - return string.Format("[MemberImportsClause Member={0}]", Member); - } - } - - public class XmlNamespaceImportsClause : ImportsClause - { - public XmlIdentifier Prefix { - get { return GetChildByRole(Roles.XmlIdentifier); } - set { SetChildByRole(Roles.XmlIdentifier, value); } - } - - public XmlLiteralString Namespace { - get { return GetChildByRole(Roles.XmlLiteralString); } - set { SetChildByRole(Roles.XmlLiteralString, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var clause = other as XmlNamespaceImportsClause; - return clause != null && Namespace.DoMatch(clause.Namespace, match) && Prefix.DoMatch(clause.Prefix, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitXmlNamespaceImportsClause(this, data); - } - - public override string ToString() - { - return string.Format("[XmlNamespaceImportsClause Prefix={0}, Namespace={1}]", Prefix, Namespace); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsStatement.cs deleted file mode 100644 index 24ea944d6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/ImportsStatement.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -using System; -using System.Collections.Generic; -using ICSharpCode.NRefactory.PatternMatching; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class ImportsStatement : AstNode - { - public static readonly Role ImportsClauseRole = new Role("ImportsClause", ImportsClause.Null); - - public VBTokenNode Imports { - get { return GetChildByRole(Roles.Keyword); } - } - - public AstNodeCollection ImportsClauses { - get { return GetChildrenByRole(ImportsClauseRole); } - } - -// public override string ToString() { -// return string.Format("[ImportsStatement ImportsClauses={0}]", GetCollectionString(ImportsClauses)); -// } - - protected internal override bool DoMatch(AstNode other, Match match) - { - ImportsStatement stmt = other as ImportsStatement; - return stmt != null && stmt.ImportsClauses.DoMatch(ImportsClauses, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitImportsStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs deleted file mode 100644 index 84016b45a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/NamespaceDeclaration.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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, TextLocation.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/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/OptionStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/OptionStatement.cs deleted file mode 100644 index 299cc5b01..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/OptionStatement.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -using System; -using System.Collections.Generic; -using ICSharpCode.NRefactory.PatternMatching; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class OptionStatement : AstNode - { - public static readonly Role OptionTypeRole = new Role("OptionType"); - public static readonly Role OptionValueRole = new Role("OptionValue"); - - public VBTokenNode OptionKeyword { - get { return GetChildByRole(Roles.Keyword); } - } - - public VBTokenNode OptionTypeKeyword { - get { return GetChildByRole(OptionTypeRole); } - } - - public VBTokenNode OptionValueKeyword { - get { return GetChildByRole(OptionValueRole); } - } - - public OptionType OptionType { get; set; } - - public OptionValue OptionValue { get; set; } - - protected internal override bool DoMatch(AstNode other, Match match) - { - var stmt = other as OptionStatement; - return stmt != null && stmt.OptionType == this.OptionType - && stmt.OptionValue == this.OptionValue; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitOptionStatement(this, data); - } - - public override string ToString() { - return string.Format("[OptionStatement OptionType={0} OptionValue={1}]", OptionType, OptionValue); - } - } - - public enum OptionType - { - Explicit, - Strict, - Compare, - Infer - } - - public enum OptionValue - { - On, Off, - Text, Binary - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs deleted file mode 100644 index 13ccf5563..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/GlobalScope/TypeDeclaration.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (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 enum ClassType - { - Class, - Struct, - Interface, - Module - } - - 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); } - set { SetChildByRole(InheritsTypeRole, value); } - } - - 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/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/INullable.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/INullable.cs deleted file mode 100644 index 1ce646f6b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/INullable.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public interface INullable - { - bool IsNull { - get; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Identifier.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Identifier.cs deleted file mode 100644 index e7cd4424a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Identifier.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Represents an identifier in VB. - /// - public class Identifier : AstNode - { - public static readonly new Identifier Null = new NullIdentifier (); - class NullIdentifier : Identifier - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - - string name; - - public string Name { - get { return name; } - set { - if (value == null) - throw new ArgumentNullException("value"); - name = value; - } - } - - public TypeCode TypeCharacter { get; set; } - - TextLocation startLocation; - public override TextLocation StartLocation { - get { - return startLocation; - } - } - - public override TextLocation EndLocation { - get { - return new TextLocation (StartLocation.Line, StartLocation.Column + Name.Length); - } - } - - private Identifier() - { - this.name = string.Empty; - } - - public Identifier (string name, TextLocation location) - { - if (name == null) - throw new ArgumentNullException("name"); - this.Name = name; - this.startLocation = location; - } - - public static implicit operator Identifier(string name) - { - return new Identifier(name, TextLocation.Empty); - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var node = other as Identifier; - return node != null - && MatchString(node.name, name) - && node.TypeCharacter == TypeCharacter; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitIdentifier(this, data); - } - - public override string ToString() - { - return string.Format("{0}", - name); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/AddRemoveHandlerStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/AddRemoveHandlerStatement.cs deleted file mode 100644 index 7a46c8c66..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/AddRemoveHandlerStatement.cs +++ /dev/null @@ -1,38 +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 System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// ( AddHandler | RemoveHandler ) Expression, Expression - /// - public class AddRemoveHandlerStatement : Statement - { - public static readonly Role EventExpressionRole = new Role("EventExpression", Expression.Null); - public static readonly Role DelegateExpressionRole = new Role("DelegateExpression", Expression.Null); - - public bool IsAddHandler { get; set; } - - public Expression EventExpression { - get { return GetChildByRole(EventExpressionRole); } - set { SetChildByRole(EventExpressionRole, value); } - } - - public Expression DelegateExpression { - get { return GetChildByRole(DelegateExpressionRole); } - set { SetChildByRole(DelegateExpressionRole, value); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAddRemoveHandlerStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/BlockStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/BlockStatement.cs deleted file mode 100644 index 1cce01649..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/BlockStatement.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// { Statements } - /// - public class BlockStatement : Statement, IEnumerable - { - public static readonly Role StatementRole = new Role("Statement", Statement.Null); - - #region Null - public static readonly new BlockStatement Null = new NullBlockStatement(); - sealed class NullBlockStatement : BlockStatement - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default(S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - #region PatternPlaceholder - public static implicit operator BlockStatement(PatternMatching.Pattern pattern) - { - return pattern != null ? new PatternPlaceholder(pattern) : null; - } - - sealed class PatternPlaceholder : BlockStatement, PatternMatching.INode - { - readonly PatternMatching.Pattern child; - - public PatternPlaceholder(PatternMatching.Pattern child) - { - this.child = child; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPatternPlaceholder(this, child, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return child.DoMatch(other, match); - } - - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) - { - return child.DoMatchCollection(role, pos, match, backtrackingInfo); - } - } - #endregion - - public AstNodeCollection Statements { - get { return GetChildrenByRole (StatementRole); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitBlockStatement (this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - BlockStatement o = other as BlockStatement; - return o != null && !(o is CatchBlock) && !o.IsNull && this.Statements.DoMatch(o.Statements, match); - } - - #region Builder methods - public void Add(Statement statement) - { - AddChild(statement, StatementRole); - } - - public void Add(Expression expression) - { - AddChild(new ExpressionStatement { Expression = expression }, StatementRole); - } - - public void AddRange(IEnumerable statements) - { - foreach (Statement st in statements) - AddChild(st, StatementRole); - } - - public void AddAssignment(Expression left, Expression right) - { - Add(new AssignmentExpression(left, AssignmentOperatorType.Assign, right)); - } - - public void AddReturnStatement(Expression expression) - { - Add(new ReturnStatement { Expression = expression }); - } - #endregion - - IEnumerator IEnumerable.GetEnumerator() - { - return this.Statements.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.Statements.GetEnumerator(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs deleted file mode 100644 index 4ec41f628..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ContinueStatement.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Continue ( Do | For | While ) - /// - public class ContinueStatement : Statement - { - public static readonly Role ContinueKindTokenRole = new Role("ContinueKindToken"); - - public ContinueKind ContinueKind { get; set; } - - public VBTokenNode ContinueToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public VBTokenNode ContinueKindToken { - get { return GetChildByRole (ContinueKindTokenRole); } - } - - public ContinueStatement(ContinueKind kind) - { - this.ContinueKind = kind; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitContinueStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ContinueStatement o = other as ContinueStatement; - return o != null && this.ContinueKind == o.ContinueKind; - } - } - - public enum ContinueKind - { - None, - Do, - For, - While - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/DoLoopStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/DoLoopStatement.cs deleted file mode 100644 index 9335926f8..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/DoLoopStatement.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class DoLoopStatement : Statement - { - public ConditionType ConditionType { get; set; } - - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitDoLoopStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs deleted file mode 100644 index b5f7c0ff3..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ExitStatement.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Exit ( Do | For | While | Select | Sub | Function | Property | Try ) - /// - public class ExitStatement : Statement - { - public static readonly Role ExitKindTokenRole = new Role("ExitKindToken"); - - public ExitKind ExitKind { get; set; } - - public VBTokenNode ExitToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public VBTokenNode ExitKindToken { - get { return GetChildByRole (ExitKindTokenRole); } - } - - public ExitStatement(ExitKind kind) - { - this.ExitKind = kind; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitExitStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ExitStatement o = other as ExitStatement; - return o != null && this.ExitKind == o.ExitKind; - } - } - - public enum ExitKind - { - None, - Sub, - Function, - Property, - Do, - For, - While, - Select, - Try - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ExpressionStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ExpressionStatement.cs deleted file mode 100644 index 67e8952d6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ExpressionStatement.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Expression - /// - // TODO this does not directly reflect the VB grammar! - public class ExpressionStatement : Statement - { - public Expression Expression { - get { return GetChildByRole (Roles.Expression); } - set { SetChildByRole (Roles.Expression, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitExpressionStatement(this, data); - } - - public ExpressionStatement() - { - } - - public ExpressionStatement(Expression expression) - { - this.Expression = expression; - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ExpressionStatement o = other as ExpressionStatement; - return o != null && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ForEachStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ForEachStatement.cs deleted file mode 100644 index 7c0cd90b1..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ForEachStatement.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class ForEachStatement : Statement - { - public static readonly Role VariableRole = new Role("Variable", AstNode.Null); - - public AstNode Variable { - get { return GetChildByRole(VariableRole); } - set { SetChildByRole(VariableRole, value); } - } - - public Expression InExpression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitForEachStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ForStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ForStatement.cs deleted file mode 100644 index c28ea0fd5..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ForStatement.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class ForStatement : Statement - { - public static readonly Role VariableRole = new Role("Variable", AstNode.Null); - public static readonly Role ToExpressionRole = new Role("ToExpression", Expression.Null); - public static readonly Role StepExpressionRole = new Role("StepExpression", Expression.Null); - - public AstNode Variable { - get { return GetChildByRole(VariableRole); } - set { SetChildByRole(VariableRole, value); } - } - - public Expression ToExpression { - get { return GetChildByRole(ToExpressionRole); } - set { SetChildByRole(ToExpressionRole, value); } - } - - public Expression StepExpression { - get { return GetChildByRole(StepExpressionRole); } - set { SetChildByRole(StepExpressionRole, value); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitForStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs deleted file mode 100644 index 32dc7d745..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/GoToStatement.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class GoToStatement : Statement - { - /// either PrimitiveExpression or IdentifierExpression - public Expression Label { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitGoToStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/IfElseStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/IfElseStatement.cs deleted file mode 100644 index 08738789a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/IfElseStatement.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class IfElseStatement : Statement - { - public static readonly Role FalseStatementRole = new Role("False", Ast.Statement.Null); - public static readonly Role TrueStatementRole = new Role("True", Ast.Statement.Null); - - public Expression Condition { - get { return GetChildByRole(Roles.Condition); } - set { SetChildByRole(Roles.Condition, value); } - } - - public Statement Body { - get { return GetChildByRole(TrueStatementRole); } - set { SetChildByRole(TrueStatementRole, value); } - } - - public Statement ElseBlock { - get { return GetChildByRole(FalseStatementRole); } - set { SetChildByRole(FalseStatementRole, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitIfElseStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs deleted file mode 100644 index 589fea5a6..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/LabelDeclarationStatement.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Label: - /// - public class LabelDeclarationStatement : Statement - { - /// either PrimitiveExpression or IdentifierExpression - public Expression Label { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public VBTokenNode Colon { - get { return GetChildByRole(Roles.Colon); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitLabelDeclarationStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - LabelDeclarationStatement o = other as LabelDeclarationStatement; - return o != null && this.Label.DoMatch(o.Label, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/LocalDeclarationStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/LocalDeclarationStatement.cs deleted file mode 100644 index 40c19b2ab..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/LocalDeclarationStatement.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// ( Dim | Static | Const ) VariableDeclarator { , VariableDeclarator } - /// - public class LocalDeclarationStatement : Statement - { - public AstNodeCollection Variables { - get { return GetChildrenByRole(VariableDeclarator.VariableDeclaratorRole); } - } - - public Modifiers Modifiers { - get { return AttributedNode.GetModifiers(this); } - set { AttributedNode.SetModifiers(this, value); } - } - - public VBModifierToken ModifierToken { - get { return GetChildByRole(AttributedNode.ModifierRole); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitLocalDeclarationStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ReturnStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ReturnStatement.cs deleted file mode 100644 index 26deb1ab2..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ReturnStatement.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Return Expression - /// - public class ReturnStatement : Statement - { - public VBTokenNode ReturnToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public ReturnStatement() - { - } - - public ReturnStatement(Expression expression) - { - AddChild (expression, Roles.Expression); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitReturnStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ReturnStatement o = other as ReturnStatement; - return o != null && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/SelectStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/SelectStatement.cs deleted file mode 100644 index 70f2dd720..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/SelectStatement.cs +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class SelectStatement : Statement - { - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public AstNodeCollection Cases { - get { return GetChildrenByRole(CaseStatement.CaseStatementRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitSelectStatement(this, data); - } - } - - public class CaseStatement : Statement - { - public static readonly Role CaseStatementRole = new Role("CaseStatement"); - - public AstNodeCollection Clauses { - get { return GetChildrenByRole(CaseClause.CaseClauseRole); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitCaseStatement(this, data); - } - } - - public abstract class CaseClause : AstNode - { - #region Null - public new static readonly CaseClause Null = new NullCaseClause(); - - sealed class NullCaseClause : CaseClause - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - public static readonly Role CaseClauseRole = new Role("CaseClause", CaseClause.Null); - - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - } - - public class SimpleCaseClause : CaseClause - { - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitSimpleCaseClause(this, data); - } - } - - public class RangeCaseClause : CaseClause - { - public static readonly Role ToExpressionRole = ForStatement.ToExpressionRole; - - public Expression ToExpression { - get { return GetChildByRole(ToExpressionRole); } - set { SetChildByRole(ToExpressionRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitRangeCaseClause(this, data); - } - } - - public class ComparisonCaseClause : CaseClause - { - public static readonly Role OperatorRole = BinaryOperatorExpression.OperatorRole; - - public ComparisonOperator Operator { get; set; } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitComparisonCaseClause(this, data); - } - } - - public enum ComparisonOperator - { - Equality = BinaryOperatorType.Equality, - InEquality = BinaryOperatorType.InEquality, - LessThan = BinaryOperatorType.LessThan, - GreaterThan = BinaryOperatorType.GreaterThan, - LessThanOrEqual = BinaryOperatorType.LessThanOrEqual, - GreaterThanOrEqual = BinaryOperatorType.GreaterThanOrEqual - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/Statement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/Statement.cs deleted file mode 100644 index 4eee3903e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/Statement.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Base class for statements. - /// - /// - /// This class is useful even though it doesn't provide any additional functionality: - /// It can be used to communicate more information in APIs, e.g. "this subnode will always be a statement" - /// - public abstract class Statement : AstNode - { - #region Null - public new static readonly Statement Null = new NullStatement (); - - sealed class NullStatement : Statement - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - #region PatternPlaceholder - public static implicit operator Statement(PatternMatching.Pattern pattern) - { - return pattern != null ? new PatternPlaceholder(pattern) : null; - } - - sealed class PatternPlaceholder : Statement, PatternMatching.INode - { - readonly PatternMatching.Pattern child; - - public PatternPlaceholder(PatternMatching.Pattern child) - { - this.child = child; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPatternPlaceholder(this, child, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return child.DoMatch(other, match); - } - - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) - { - return child.DoMatchCollection(role, pos, match, backtrackingInfo); - } - } - #endregion - - /// - /// Gets the previous statement within the current block. - /// This is usually equivalent to , but will skip any non-statements (e.g. comments) - /// - public Statement PreviousStatement { - get { - AstNode node = this; - while ((node = node.PrevSibling) != null) { - Statement stmt = node as Statement; - if (stmt != null) - return stmt; - } - return null; - } - } - - /// - /// Gets the next statement within the current block. - /// This is usually equivalent to , but will skip any non-statements (e.g. comments) - /// - public Statement NextStatement { - get { - AstNode node = this; - while ((node = node.NextSibling) != null) { - Statement stmt = node as Statement; - if (stmt != null) - return stmt; - } - return null; - } - } - - public new Statement Clone() - { - return (Statement)base.Clone(); - } - - public Statement ReplaceWith(Func replaceFunction) - { - if (replaceFunction == null) - throw new ArgumentNullException("replaceFunction"); - return (Statement)base.ReplaceWith(node => replaceFunction((Statement)node)); - } - - // Make debugging easier by giving Statements a ToString() implementation -// public override string ToString() -// { -//// if (IsNull) -//// return "Null"; -//// StringWriter w = new StringWriter(); -//// AcceptVisitor(new OutputVisitor(w, FormattingOptionsFactory.CreateMonoOptions ()), null); -//// string text = w.ToString().TrimEnd().Replace("\t", "").Replace(w.NewLine, " "); -//// if (text.Length > 100) -//// return text.Substring(0, 97) + "..."; -//// else -//// return text; -// throw new NotImplementedException(); -// } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/SyncLockStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/SyncLockStatement.cs deleted file mode 100644 index 7fd317eb0..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/SyncLockStatement.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// SyncLock Expression
- /// Block
- /// End SyncLock - ///
- public class SyncLockStatement : Statement - { - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitSyncLockStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ThrowStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ThrowStatement.cs deleted file mode 100644 index c4c1634b5..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/ThrowStatement.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Throw Expression - /// - public class ThrowStatement : Statement - { - public VBTokenNode ThrowToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public ThrowStatement() - { - } - - public ThrowStatement(Expression expression) - { - AddChild (expression, Roles.Expression); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitThrowStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ThrowStatement o = other as ThrowStatement; - return o != null && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/TryStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/TryStatement.cs deleted file mode 100644 index 7e5eb94da..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/TryStatement.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class TryStatement : Statement - { - public static readonly Role FinallyBlockRole = new Role("FinallyBlock", Ast.BlockStatement.Null); - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - public AstNodeCollection CatchBlocks { - get { return GetChildrenByRole(CatchBlock.CatchBlockRole); } - } - - public BlockStatement FinallyBlock { - get { return GetChildByRole(FinallyBlockRole); } - set { SetChildByRole(FinallyBlockRole, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitTryStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } - - public class CatchBlock : BlockStatement - { - public static readonly Role CatchBlockRole = new Role("CatchBlockRole"); - - public Identifier ExceptionVariable { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public AstType ExceptionType { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public Expression WhenExpression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitCatchBlock(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/UsingStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/UsingStatement.cs deleted file mode 100644 index c2147e447..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/UsingStatement.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class UsingStatement : Statement - { - public static readonly Role ResourceRole = new Role("Resource", AstNode.Null); - - /// either multiple VariableInitializers or one Expression - public AstNodeCollection Resources { - get { return GetChildrenByRole(ResourceRole); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitUsingStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/WhileStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/WhileStatement.cs deleted file mode 100644 index e5c9ec24c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/WhileStatement.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class WhileStatement : Statement - { - public Expression Condition { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitWhileStatement(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/WithStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/WithStatement.cs deleted file mode 100644 index b915a9081..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/WithStatement.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// With Expression
- /// Block
- /// End With - ///
- public class WithStatement : Statement - { - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitWithStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - throw new NotImplementedException(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/YieldStatement.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/YieldStatement.cs deleted file mode 100644 index 895382aa1..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/Statements/YieldStatement.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Yield Expression - /// - /// VB 11 - public class YieldStatement : Statement - { - public VBTokenNode YieldToken { - get { return GetChildByRole (Roles.Keyword); } - } - - public Expression Expression { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - public YieldStatement() - { - } - - public YieldStatement(Expression expression) - { - AddChild (expression, Roles.Expression); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitYieldStatement(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - YieldStatement o = other as YieldStatement; - return o != null && this.Expression.DoMatch(o.Expression, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/Accessor.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/Accessor.cs deleted file mode 100644 index 7eb287c26..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/Accessor.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 MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Get/Set/AddHandler/RemoveHandler/RaiseEvent - /// - public class Accessor : AttributedNode - { - public static readonly new Accessor Null = new NullAccessor (); - sealed class NullAccessor : Accessor - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - public AstNodeCollection Parameters { - get { return GetChildrenByRole(Roles.Parameter); } - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitAccessor(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - Accessor o = other as Accessor; - return o != null && !o.IsNull && this.MatchAttributesAndModifiers(o, match) && - this.Body.DoMatch(o.Body, match) && Parameters.DoMatch(o.Parameters, match); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ConstructorDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ConstructorDeclaration.cs deleted file mode 100644 index 9e57fc572..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ConstructorDeclaration.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public abstract class MemberDeclaration : AttributedNode - { - - } - - /// - /// Description of ConstructorDeclaration. - /// - public class ConstructorDeclaration : MemberDeclaration - { - public ConstructorDeclaration() - { - } - - public AstNodeCollection Parameters { - get { return GetChildrenByRole(Roles.Parameter); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var ctor = other as ConstructorDeclaration; - return ctor != null && - MatchAttributesAndModifiers(ctor, match) && - Parameters.DoMatch(ctor.Parameters, match) && - Body.DoMatch(ctor.Body, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitConstructorDeclaration(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/EventDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/EventDeclaration.cs deleted file mode 100644 index ce0181964..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/EventDeclaration.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class EventDeclaration : MemberDeclaration - { - public bool IsCustom { get; set; } - - public static readonly Role AddHandlerRole = new Role("AddHandler", Accessor.Null); - public static readonly Role RemoveHandlerRole = new Role("RemoveHandler", Accessor.Null); - public static readonly Role RaiseEventRole = new Role("RaiseEvent", Accessor.Null); - - public Identifier Name { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public AstType ReturnType { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public AstNodeCollection Parameters { - get { return GetChildrenByRole(Roles.Parameter); } - } - - public AstNodeCollection ImplementsClause { - get { return GetChildrenByRole(InterfaceMemberSpecifier.InterfaceMemberSpecifierRole); } - } - - public Accessor AddHandlerBlock { - get { return GetChildByRole(AddHandlerRole); } - set { SetChildByRole(AddHandlerRole, value); } - } - - public Accessor RemoveHandlerBlock { - get { return GetChildByRole(RemoveHandlerRole); } - set { SetChildByRole(RemoveHandlerRole, value); } - } - - public Accessor RaiseEventBlock { - get { return GetChildByRole(RaiseEventRole); } - set { SetChildByRole(RaiseEventRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitEventDeclaration(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ExternalMethodDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ExternalMethodDeclaration.cs deleted file mode 100644 index d5d975447..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/ExternalMethodDeclaration.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Runtime.InteropServices; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class ExternalMethodDeclaration : MemberDeclaration - { - public ExternalMethodDeclaration() - { - } - - public CharsetModifier CharsetModifier { get; set; } - - public bool IsSub { get; set; } - - public Identifier Name { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public string Library { get; set; } - - public string Alias { get; set; } - - 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) - { - // TODO : finish - var method = other as ExternalMethodDeclaration; - return method != null && - MatchAttributesAndModifiers(method, match) && - IsSub == method.IsSub && - Name.DoMatch(method.Name, match) && - Parameters.DoMatch(method.Parameters, match) && - ReturnTypeAttributes.DoMatch(method.ReturnTypeAttributes, match) && - ReturnType.DoMatch(method.ReturnType, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitExternalMethodDeclaration(this, data); - } - } - - /// - /// Charset types, used in external methods - /// declarations (VB only). - /// - public enum CharsetModifier - { - None, - Auto, - Unicode, - Ansi - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/FieldDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/FieldDeclaration.cs deleted file mode 100644 index a41c29e80..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/FieldDeclaration.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Attributes? VariableModifier+ VariableDeclarators StatementTerminator - /// - public class FieldDeclaration : MemberDeclaration - { - public AstNodeCollection Variables { - get { return GetChildrenByRole(VariableDeclarator.VariableDeclaratorRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitFieldDeclaration(this, data); - } - } - - - - /// - /// Identifier IdentifierModifiers - /// - public class VariableIdentifier : AstNode - { - #region Null - public new static readonly VariableIdentifier Null = new NullVariableIdentifier(); - - sealed class NullVariableIdentifier : VariableIdentifier - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - public static readonly Role VariableIdentifierRole = new Role("VariableIdentifier", VariableIdentifier.Null); - - public Identifier Name { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public bool HasNullableSpecifier { get; set; } - - public AstNodeCollection ArraySizeSpecifiers { - get { return GetChildrenByRole (Roles.Argument); } - } - - public AstNodeCollection ArraySpecifiers { - get { return GetChildrenByRole(ComposedType.ArraySpecifierRole); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitVariableIdentifier(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/MethodDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/MethodDeclaration.cs deleted file mode 100644 index a6dd87159..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/MethodDeclaration.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class MethodDeclaration : MemberDeclaration - { - public MethodDeclaration() - { - } - - public bool IsSub { get; set; } - - public Identifier Name { - get { return GetChildByRole(Roles.Identifier); } - set { SetChildByRole(Roles.Identifier, value); } - } - - public AstNodeCollection TypeParameters { - get { return GetChildrenByRole(Roles.TypeParameter); } - } - - 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); } - } - - public AstNodeCollection HandlesClause { - get { return GetChildrenByRole(EventMemberSpecifier.EventMemberSpecifierRole); } - } - - public AstNodeCollection ImplementsClause { - get { return GetChildrenByRole(InterfaceMemberSpecifier.InterfaceMemberSpecifierRole); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - var method = other as MethodDeclaration; - return method != null && - MatchAttributesAndModifiers(method, match) && - IsSub == method.IsSub && - Name.DoMatch(method.Name, match) && - TypeParameters.DoMatch(method.TypeParameters, match) && - Parameters.DoMatch(method.Parameters, match) && - ReturnTypeAttributes.DoMatch(method.ReturnTypeAttributes, match) && - ReturnType.DoMatch(method.ReturnType, match) && - HandlesClause.DoMatch(method.HandlesClause, match) && - ImplementsClause.DoMatch(method.ImplementsClause, match) && - Body.DoMatch(method.Body, match); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitMethodDeclaration(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/OperatorDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/OperatorDeclaration.cs deleted file mode 100644 index f6591e4a4..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/OperatorDeclaration.cs +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class OperatorDeclaration : MemberDeclaration - { - public OperatorDeclaration() - { - } - - public OverloadableOperatorType Operator { get; set; } - - 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); } - } - - public BlockStatement Body { - get { return GetChildByRole(Roles.Body); } - set { SetChildByRole(Roles.Body, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitOperatorDeclaration(this, data); - } - } - - public enum OverloadableOperatorType - { - None, - - Add, - Subtract, - Multiply, - Divide, - Modulus, - Concat, - - UnaryPlus, - UnaryMinus, - - Not, - - BitwiseAnd, - BitwiseOr, - ExclusiveOr, - - ShiftLeft, - ShiftRight, - - GreaterThan, - GreaterThanOrEqual, - Equality, - InEquality, - LessThan, - LessThanOrEqual, - - IsTrue, - IsFalse, - - Like, - Power, - CType, - DivideInteger - }// -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/PropertyDeclaration.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/PropertyDeclaration.cs deleted file mode 100644 index 6fdab3842..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/PropertyDeclaration.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class PropertyDeclaration : MemberDeclaration - { - // TODO : support automatic properties - - public static readonly Role GetterRole = new Role("Getter", Accessor.Null); - public static readonly Role SetterRole = new Role("Setter", Accessor.Null); - - 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); } - } - - public AstNodeCollection ImplementsClause { - get { return GetChildrenByRole(InterfaceMemberSpecifier.InterfaceMemberSpecifierRole); } - } - - public Accessor Getter { - get { return GetChildByRole(GetterRole); } - set { SetChildByRole(GetterRole, value); } - } - - public Accessor Setter { - get { return GetChildByRole(SetterRole); } - set { SetChildByRole(SetterRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPropertyDeclaration(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/VariableDeclarator.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/VariableDeclarator.cs deleted file mode 100644 index a3ad2892a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeMembers/VariableDeclarator.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// VariableIdentifiers As ObjectCreationExpression
- /// VariableIdentifiers ( As TypeName )? ( Equals Expression )? - ///
- public abstract class VariableDeclarator : AstNode - { - public static readonly Role VariableDeclaratorRole = new Role("VariableDeclarator"); - - public AstNodeCollection Identifiers { - get { return GetChildrenByRole(VariableIdentifier.VariableIdentifierRole); } - } - } - - public class VariableDeclaratorWithTypeAndInitializer : VariableDeclarator - { - public AstType Type { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public Expression Initializer { - get { return GetChildByRole(Roles.Expression); } - set { SetChildByRole(Roles.Expression, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitVariableDeclaratorWithTypeAndInitializer(this, data); - } - } - - public class VariableDeclaratorWithObjectCreation : VariableDeclarator - { - public static readonly Role InitializerRole = new Role("InitializerRole"); - - public ObjectCreationExpression Initializer { - get { return GetChildByRole(InitializerRole); } - set { SetChildByRole(InitializerRole, value); } - } - - protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) - { - throw new NotImplementedException(); - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitVariableDeclaratorWithObjectCreation(this, data); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/AstType.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/AstType.cs deleted file mode 100644 index ca39bd369..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/AstType.cs +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -using System; -using System.Collections.Generic; -using System.Linq; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// A type reference in the VB AST. - /// - public abstract class AstType : AstNode - { - #region Null - public new static readonly AstType Null = new NullAstType(); - - sealed class NullAstType : AstType - { - public override bool IsNull { - get { - return true; - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - #endregion - - #region PatternPlaceholder - public static implicit operator AstType(PatternMatching.Pattern pattern) - { - return pattern != null ? new PatternPlaceholder(pattern) : null; - } - - sealed class PatternPlaceholder : AstType, PatternMatching.INode - { - readonly PatternMatching.Pattern child; - - public PatternPlaceholder(PatternMatching.Pattern child) - { - this.child = child; - } - - public override S AcceptVisitor(IAstVisitor visitor, T data) - { - return visitor.VisitPatternPlaceholder(this, child, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return child.DoMatch(other, match); - } - - bool PatternMatching.INode.DoMatchCollection(Role role, PatternMatching.INode pos, PatternMatching.Match match, PatternMatching.BacktrackingInfo backtrackingInfo) - { - return child.DoMatchCollection(role, pos, match, backtrackingInfo); - } - } - #endregion - - public virtual AstType MakeArrayType(int rank = 1) - { - return new ComposedType { BaseType = this }.MakeArrayType(rank); - } - - public static AstType FromName(string fullName) - { - if (string.IsNullOrEmpty(fullName)) - throw new ArgumentNullException("fullName"); - fullName = fullName.Trim(); - if (!fullName.Contains(".")) - return new SimpleType(fullName); - string[] parts = fullName.Split('.'); - - AstType type = new SimpleType(parts.First()); - - foreach (var part in parts.Skip(1)) { - type = new QualifiedType(type, part); - } - - return type; - } - - /// - /// Builds an expression that can be used to access a static member on this type. - /// - public MemberAccessExpression Member(string memberName) - { - return new TypeReferenceExpression { Type = this }.Member(memberName); - } - - /// - /// Builds an invocation expression using this type as target. - /// - public InvocationExpression Invoke(string methodName, IEnumerable arguments) - { - return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments); - } - - /// - /// Builds an invocation expression using this type as target. - /// - public InvocationExpression Invoke(string methodName, params Expression[] arguments) - { - return new TypeReferenceExpression { Type = this }.Invoke(methodName, arguments); - } - - /// - /// Builds an invocation expression using this type as target. - /// - public InvocationExpression Invoke(string methodName, IEnumerable typeArguments, IEnumerable arguments) - { - return new TypeReferenceExpression { Type = this }.Invoke(methodName, typeArguments, arguments); - } - - public static AstType Create(Type type) - { - switch (Type.GetTypeCode(type)) { - case TypeCode.Object: - return new PrimitiveType("Object"); - case TypeCode.Boolean: - return new PrimitiveType("Boolean"); - case TypeCode.Char: - return new PrimitiveType("Char"); - case TypeCode.SByte: - return new PrimitiveType("SByte"); - case TypeCode.Byte: - return new PrimitiveType("Byte"); - case TypeCode.Int16: - return new PrimitiveType("Short"); - case TypeCode.UInt16: - return new PrimitiveType("UShort"); - case TypeCode.Int32: - return new PrimitiveType("Integer"); - case TypeCode.UInt32: - return new PrimitiveType("UInteger"); - case TypeCode.Int64: - return new PrimitiveType("Long"); - case TypeCode.UInt64: - return new PrimitiveType("ULong"); - case TypeCode.Single: - return new PrimitiveType("Single"); - case TypeCode.Double: - return new PrimitiveType("Double"); - case TypeCode.Decimal: - return new PrimitiveType("Decimal"); - case TypeCode.String: - return new PrimitiveType("String"); - case TypeCode.DateTime: - return new PrimitiveType("Date"); - } - return new SimpleType(type.FullName); // TODO: implement this correctly - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/ComposedType.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/ComposedType.cs deleted file mode 100644 index 3f23d791c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/ComposedType.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class ComposedType : AstType - { - public static readonly Role NullableRole = new Role("Nullable", VBTokenNode.Null); - public static readonly Role ArraySpecifierRole = new Role("ArraySpecifier"); - - public AstType BaseType { - get { return GetChildByRole(Roles.Type); } - set { SetChildByRole(Roles.Type, value); } - } - - public bool HasNullableSpecifier { - get { - return !GetChildByRole(NullableRole).IsNull; - } - set { - SetChildByRole(NullableRole, value ? new VBTokenNode(TextLocation.Empty, 1) : null); - } - } - - public AstNodeCollection ArraySpecifiers { - get { return GetChildrenByRole (ArraySpecifierRole); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitComposedType (this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ComposedType o = other as ComposedType; - return o != null && this.HasNullableSpecifier == o.HasNullableSpecifier && this.ArraySpecifiers.DoMatch(o.ArraySpecifiers, match); - } - - public override string ToString() - { - StringBuilder b = new StringBuilder(); - b.Append(this.BaseType.ToString()); - if (this.HasNullableSpecifier) - b.Append('?'); - foreach (var arraySpecifier in this.ArraySpecifiers) { - b.Append('('); - b.Append(',', arraySpecifier.Dimensions - 1); - b.Append(')'); - } - return b.ToString(); - } - - public override AstType MakeArrayType(int dimensions) - { - InsertChildBefore(this.ArraySpecifiers.FirstOrDefault(), new ArraySpecifier(dimensions), ArraySpecifierRole); - return this; - } - } - - /// - /// [,,,] - /// - public class ArraySpecifier : AstNode - { - public ArraySpecifier() - { - } - - public ArraySpecifier(int dimensions) - { - this.Dimensions = dimensions; - } - - public VBTokenNode LParToken { - get { return GetChildByRole (Roles.LPar); } - } - - public int Dimensions { - get { return 1 + GetChildrenByRole(Roles.Comma).Count(); } - set { - int d = this.Dimensions; - while (d > value) { - GetChildByRole(Roles.Comma).Remove(); - d--; - } - while (d < value) { - InsertChildBefore(GetChildByRole(Roles.Comma), new VBTokenNode(TextLocation.Empty, 1), Roles.Comma); - d++; - } - } - } - - public VBTokenNode RParToken { - get { return GetChildByRole (Roles.LPar); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitArraySpecifier(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - ArraySpecifier o = other as ArraySpecifier; - return o != null && this.Dimensions == o.Dimensions; - } - - public override string ToString() - { - return "(" + new string(',', this.Dimensions - 1) + ")"; - } - } -} - diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/PrimitiveType.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/PrimitiveType.cs deleted file mode 100644 index 092705d53..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/PrimitiveType.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) -using System; -using System.Collections.Generic; -using System.Linq; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class PrimitiveType : AstType - { - public string Keyword { get; set; } - public TextLocation Location { get; set; } - - public PrimitiveType() - { - } - - public PrimitiveType(string keyword) - { - this.Keyword = keyword; - } - - public PrimitiveType(string keyword, TextLocation location) - { - this.Keyword = keyword; - this.Location = location; - } - - public override TextLocation StartLocation { - get { - return Location; - } - } - public override TextLocation EndLocation { - get { - return new TextLocation (Location.Line, Location.Column + (Keyword != null ? Keyword.Length : 0)); - } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitPrimitiveType(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - PrimitiveType o = other as PrimitiveType; - return o != null && MatchString(this.Keyword, o.Keyword); - } - - public override string ToString() - { - return Keyword ?? base.ToString(); - } - } -} - diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs deleted file mode 100644 index 3ee783d63..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/QualifiedType.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of QualifiedType. - /// - public class QualifiedType : AstType - { - public static readonly Role TargetRole = new Role("Target", AstType.Null); - - public AstType Target { - get { return GetChildByRole(TargetRole); } - set { SetChildByRole(TargetRole, value); } - } - - public string Name { - get { - return GetChildByRole (Roles.Identifier).Name; - } - set { - SetChildByRole (Roles.Identifier, new Identifier (value, TextLocation.Empty)); - } - } - - public QualifiedType(AstType target, Identifier name) - { - Target = target; - SetChildByRole(Roles.Identifier, name); - } - - public AstNodeCollection TypeArguments { - get { return GetChildrenByRole (Roles.TypeArgument); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitQualifiedType(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - var o = other as QualifiedType; - return o != null && MatchString(this.Name, o.Name) && this.Target.DoMatch(o.Target, match); - } - - public override string ToString() - { - StringBuilder b = new StringBuilder(); - b.Append(this.Target); - b.Append('.'); - b.Append(this.Name); - if (this.TypeArguments.Any()) { - b.Append('('); - b.Append(string.Join(", ", this.TypeArguments)); - b.Append(')'); - } - return b.ToString(); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs deleted file mode 100644 index 5f86fa871..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/TypeName/SimpleType.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -// FullTypeName.cs -// -// Author: -// Mike Krüger -// -// Copyright (c) 2010 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - public class SimpleType : AstType - { - public SimpleType() - { - } - - public SimpleType(string identifier) - { - this.Identifier = identifier; - } - - public SimpleType(string identifier, TextLocation location) - { - SetChildByRole (Roles.Identifier, new Identifier (identifier, location)); - } - - public string Identifier { - get { - return GetChildByRole (Roles.Identifier).Name; - } - set { - SetChildByRole (Roles.Identifier, new Identifier (value, TextLocation.Empty)); - } - } - - public AstNodeCollection TypeArguments { - get { return GetChildrenByRole (Roles.TypeArgument); } - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitSimpleType(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - SimpleType o = other as SimpleType; - return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match); - } - - public override string ToString() - { - StringBuilder b = new StringBuilder(this.Identifier); - if (this.TypeArguments.Any()) { - b.Append('('); - b.Append("Of "); - b.Append(string.Join(", ", this.TypeArguments)); - b.Append(')'); - } - return b.ToString(); - } - } -} - diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs deleted file mode 100644 index b38fc3e51..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/VBModifierToken.cs +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of VBModifierToken. - /// - public class VBModifierToken : VBTokenNode - { - Modifiers modifier; - - public Modifiers Modifier { - get { return modifier; } - set { - for (int i = 0; i < lengthTable.Count; i++) { - if (lengthTable[i].Key == value) { - this.modifier = value; - this.tokenLength = lengthTable[i].Value; - return; - } - } - throw new ArgumentException ("Modifier " + value + " is invalid."); - } - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - VBModifierToken o = other as VBModifierToken; - return o != null && this.modifier == o.modifier; - } - - // Not worth using a dictionary for such few elements. - // This table is sorted in the order that modifiers should be output when generating code. - static readonly List> lengthTable = new List> () { - new KeyValuePair(Modifiers.Public, "Public".Length), - new KeyValuePair(Modifiers.Protected, "Protected".Length), - new KeyValuePair(Modifiers.Private, "Private".Length), - new KeyValuePair(Modifiers.Friend, "Friend".Length), - new KeyValuePair(Modifiers.MustInherit, "MustInherit".Length), - new KeyValuePair(Modifiers.MustOverride, "MustOverride".Length), - new KeyValuePair(Modifiers.Overridable, "Overridable".Length), - new KeyValuePair(Modifiers.NotInheritable, "NotInheritable".Length), - new KeyValuePair(Modifiers.NotOverridable, "NotOverridable".Length), - new KeyValuePair(Modifiers.Dim, "Dim".Length), - new KeyValuePair(Modifiers.Const, "Const".Length), - new KeyValuePair(Modifiers.Shared, "Shared".Length), - new KeyValuePair(Modifiers.Static, "Static".Length), - new KeyValuePair(Modifiers.Overrides, "Overrides".Length), - new KeyValuePair(Modifiers.ReadOnly, "ReadOnly".Length), - new KeyValuePair(Modifiers.WriteOnly, "WriteOnly".Length), - new KeyValuePair(Modifiers.Shadows, "Shadows".Length), - new KeyValuePair(Modifiers.Partial, "Partial".Length), - new KeyValuePair(Modifiers.Overloads, "Overloads".Length), - new KeyValuePair(Modifiers.WithEvents, "WithEvents".Length), - new KeyValuePair(Modifiers.Default, "Default".Length), - // parameter modifiers - new KeyValuePair(Modifiers.Optional, "Optional".Length), - new KeyValuePair(Modifiers.ByVal, "ByVal".Length), - new KeyValuePair(Modifiers.ByRef, "ByRef".Length), - new KeyValuePair(Modifiers.ParamArray, "ParamArray".Length), - // operator modifiers - new KeyValuePair(Modifiers.Narrowing, "Narrowing".Length), - new KeyValuePair(Modifiers.Widening, "Widening".Length), - // VB 11 modifiers - new KeyValuePair(Modifiers.Async, "Async".Length), - new KeyValuePair(Modifiers.Iterator, "Iterator".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) - }; - - public static IEnumerable AllModifiers { - get { return lengthTable.Select(p => p.Key); } - } - - public VBModifierToken(TextLocation location, Modifiers modifier) : base (location, 0) - { - this.Modifier = modifier; - } - - public static string GetModifierName(Modifiers modifier) - { - switch (modifier) { - case Modifiers.Private: - return "Private"; - case Modifiers.Friend: - return "Friend"; - case Modifiers.Protected: - return "Protected"; - case Modifiers.Public: - return "Public"; - case Modifiers.MustInherit: - return "MustInherit"; - case Modifiers.MustOverride: - return "MustOverride"; - case Modifiers.Overridable: - return "Overridable"; - case Modifiers.NotInheritable: - return "NotInheritable"; - case Modifiers.NotOverridable: - return "NotOverridable"; - case Modifiers.Const: - return "Const"; - case Modifiers.Shared: - return "Shared"; - case Modifiers.Static: - return "Static"; - case Modifiers.Overrides: - return "Overrides"; - case Modifiers.ReadOnly: - return "ReadOnly"; - case Modifiers.Shadows: - return "Shadows"; - case Modifiers.Partial: - return "Partial"; - case Modifiers.Overloads: - return "Overloads"; - case Modifiers.WithEvents: - return "WithEvents"; - case Modifiers.Default: - return "Default"; - case Modifiers.Dim: - return "Dim"; - case Modifiers.WriteOnly: - return "WriteOnly"; - case Modifiers.Optional: - return "Optional"; - case Modifiers.ByVal: - return "ByVal"; - case Modifiers.ByRef: - return "ByRef"; - case Modifiers.ParamArray: - return "ParamArray"; - case Modifiers.Widening: - return "Widening"; - case Modifiers.Narrowing: - return "Narrowing"; - case Modifiers.Async: - return "Async"; - case Modifiers.Iterator: - return "Iterator"; - default: - throw new NotSupportedException("Invalid value for Modifiers: " + modifier); - } - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/VBTokenNode.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/VBTokenNode.cs deleted file mode 100644 index d98a820af..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Ast/VBTokenNode.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Created by SharpDevelop. - * User: Siegfried - * Date: 11.04.2011 - * Time: 20:44 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ -using System; - -namespace ICSharpCode.NRefactory.VB.Ast -{ - /// - /// Description of VBTokenNode. - /// - public class VBTokenNode : AstNode - { - public static new readonly VBTokenNode Null = new NullVBTokenNode(); - - class NullVBTokenNode : VBTokenNode - { - public override bool IsNull { - get { - return true; - } - } - - public NullVBTokenNode() : base (TextLocation.Empty, 0) - { - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return default (S); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - return other == null || other.IsNull; - } - } - - TextLocation startLocation; - public override TextLocation StartLocation { - get { - return startLocation; - } - } - - protected int tokenLength = -1; - - TextLocation endLocation; - public override TextLocation EndLocation { - get { - return tokenLength < 0 ? endLocation : new TextLocation(startLocation.Line, startLocation.Column + tokenLength); - } - } - - public VBTokenNode(TextLocation location, int tokenLength) - { - this.startLocation = location; - this.tokenLength = tokenLength; - } - - public VBTokenNode(TextLocation startLocation, TextLocation endLocation) - { - this.startLocation = startLocation; - this.endLocation = endLocation; - } - - public override S AcceptVisitor (IAstVisitor visitor, T data) - { - return visitor.VisitVBTokenNode(this, data); - } - - protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) - { - var node = other as VBTokenNode; - return node != null && !node.IsNull; - } - - public override string ToString () - { - return string.Format ("[VBTokenNode: StartLocation={0}, EndLocation={1}, Role={2}]", StartLocation, EndLocation, Role); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/IAstVisitor.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/IAstVisitor.cs deleted file mode 100644 index 2726c6106..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/IAstVisitor.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using ICSharpCode.NRefactory.VB.Ast; -using Attribute = ICSharpCode.NRefactory.VB.Ast.Attribute; - -namespace ICSharpCode.NRefactory.VB { - public interface IAstVisitor - { - S VisitBlockStatement(BlockStatement blockStatement, T data); - S VisitComment(Comment comment, 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 VisitEventMemberSpecifier(EventMemberSpecifier eventMemberSpecifier, T data); - S VisitInterfaceMemberSpecifier(InterfaceMemberSpecifier interfaceMemberSpecifier, T data); - - // Global scope - S VisitAliasImportsClause(AliasImportsClause aliasImportsClause, T data); - S VisitAttribute(Attribute attribute, T data); - S VisitAttributeBlock(AttributeBlock attributeBlock, T data); - S VisitImportsStatement(ImportsStatement importsStatement, T data); - S VisitMemberImportsClause(MemberImportsClause memberImportsClause, 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); - - // TypeMember scope - S VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, T data); - S VisitMethodDeclaration(MethodDeclaration methodDeclaration, T data); - S VisitExternalMethodDeclaration(ExternalMethodDeclaration externalMethodDeclaration, T data); - S VisitFieldDeclaration(FieldDeclaration fieldDeclaration, T data); - S VisitVariableDeclaratorWithTypeAndInitializer(VariableDeclaratorWithTypeAndInitializer variableDeclaratorWithTypeAndInitializer, T data); - S VisitVariableDeclaratorWithObjectCreation(VariableDeclaratorWithObjectCreation variableDeclaratorWithObjectCreation, T data); - S VisitVariableIdentifier(VariableIdentifier variableIdentifier, T data); - S VisitAccessor(Accessor accessor, T data); - S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data); - S VisitEventDeclaration(EventDeclaration eventDeclaration, T data); - S VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, T data); - - // Expression scope - S VisitIdentifier(Identifier identifier, T data); - S VisitXmlIdentifier(XmlIdentifier xmlIdentifier, T data); - S VisitXmlLiteralString(XmlLiteralString xmlLiteralString, T data); - S VisitSimpleNameExpression(SimpleNameExpression identifierExpression, T data); - S VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, T data); - S VisitInstanceExpression(InstanceExpression instanceExpression, T data); - S VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, T data); - S VisitGetTypeExpression(GetTypeExpression getTypeExpression, T data); - S VisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, T data); - S VisitGetXmlNamespaceExpression(GetXmlNamespaceExpression getXmlNamespaceExpression, T data); - S VisitMemberAccessExpression(MemberAccessExpression memberAccessExpression, T data); - S VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, T data); - S VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, T data); - S VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, T data); - S VisitAssignmentExpression(AssignmentExpression assignmentExpression, T data); - S VisitIdentifierExpression(IdentifierExpression identifierExpression, T data); - S VisitInvocationExpression(InvocationExpression invocationExpression, T data); - S VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, T data); - S VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, T data); - S VisitObjectCreationExpression(ObjectCreationExpression objectCreationExpression, T data); - S VisitCastExpression(CastExpression castExpression, T data); - S VisitFieldInitializerExpression(FieldInitializerExpression fieldInitializerExpression, T data); - S VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, T data); - S VisitConditionalExpression(ConditionalExpression conditionalExpression, T data); - - // Statement scope - S VisitLabelDeclarationStatement(LabelDeclarationStatement labelDeclarationStatement, T data); - S VisitLocalDeclarationStatement(LocalDeclarationStatement localDeclarationStatement, T data); - S VisitExpressionStatement(ExpressionStatement expressionStatement, T data); - S VisitAddRemoveHandlerStatement(AddRemoveHandlerStatement addRemoveHandlerStatement, T data); - S VisitWithStatement(WithStatement withStatement, T data); - S VisitSyncLockStatement(SyncLockStatement syncLockStatement, T data); - S VisitIfElseStatement(IfElseStatement ifElseStatement, T data); - S VisitTryStatement(TryStatement tryStatement, T data); - S VisitThrowStatement(ThrowStatement throwStatement, T data); - S VisitCatchBlock(CatchBlock catchBlock, T data); - S VisitReturnStatement(ReturnStatement returnStatement, T data); - S VisitWhileStatement(WhileStatement whileStatement, T data); - S VisitForStatement(ForStatement forStatement, T data); - S VisitForEachStatement(ForEachStatement forEachStatement, T data); - S VisitExitStatement(ExitStatement exitStatement, T data); - S VisitContinueStatement(ContinueStatement continueStatement, T data); - S VisitSelectStatement(SelectStatement selectStatement, T data); - S VisitYieldStatement(YieldStatement yieldStatement, T data); - S VisitVariableInitializer(VariableInitializer variableInitializer, T data); - S VisitRangeCaseClause(RangeCaseClause rangeCaseClause, T data); - S VisitComparisonCaseClause(ComparisonCaseClause comparisonCaseClause, T data); - S VisitSimpleCaseClause(SimpleCaseClause simpleCaseClause, T data); - S VisitCaseStatement(CaseStatement caseStatement, T data); - S VisitDoLoopStatement(DoLoopStatement doLoopStatement, T data); - S VisitUsingStatement(UsingStatement usingStatement, T data); - - // TypeName - S VisitPrimitiveType(PrimitiveType primitiveType, T data); - S VisitQualifiedType(QualifiedType qualifiedType, T data); - S VisitComposedType(ComposedType composedType, T data); - S VisitArraySpecifier(ArraySpecifier arraySpecifier, T data); - S VisitSimpleType(SimpleType simpleType, T data); - - S VisitGoToStatement(GoToStatement goToStatement, T data); - - S VisitSingleLineSubLambdaExpression(SingleLineSubLambdaExpression singleLineSubLambdaExpression, T data); - S VisitMultiLineLambdaExpression(MultiLineLambdaExpression multiLineLambdaExpression, T data); - S VisitSingleLineFunctionLambdaExpression(SingleLineFunctionLambdaExpression singleLineFunctionLambdaExpression, T data); - - S VisitQueryExpression(QueryExpression queryExpression, T data); - - S VisitEmptyExpression(EmptyExpression emptyExpression, T data); - - S VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpression anonymousObjectCreationExpression, T data); - - S VisitCollectionRangeVariableDeclaration(CollectionRangeVariableDeclaration collectionRangeVariableDeclaration, T data); - - S VisitFromQueryOperator(FromQueryOperator fromQueryOperator, T data); - S VisitAggregateQueryOperator(AggregateQueryOperator aggregateQueryOperator, T data); - S VisitSelectQueryOperator(SelectQueryOperator selectQueryOperator, T data); - S VisitDistinctQueryOperator(DistinctQueryOperator distinctQueryOperator, T data); - S VisitWhereQueryOperator(WhereQueryOperator whereQueryOperator, T data); - S VisitOrderExpression(OrderExpression orderExpression, T data); - S VisitOrderByQueryOperator(OrderByQueryOperator orderByQueryOperator, T data); - S VisitPartitionQueryOperator(PartitionQueryOperator partitionQueryOperator, T data); - S VisitLetQueryOperator(LetQueryOperator letQueryOperator, T data); - S VisitGroupByQueryOperator(GroupByQueryOperator groupByQueryOperator, T data); - S VisitJoinQueryOperator(JoinQueryOperator joinQueryOperator, T data); - S VisitJoinCondition(JoinCondition joinCondition, T data); - S VisitGroupJoinQueryOperator(GroupJoinQueryOperator groupJoinQueryOperator, T data); - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj b/NRefactory.VB/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj deleted file mode 100644 index 44e599d12..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/ICSharpCode.NRefactory.VB.csproj +++ /dev/null @@ -1,223 +0,0 @@ - - - - {7B82B671-419F-45F4-B778-D9286F996EFA} - Debug - AnyCPU - Library - ICSharpCode.NRefactory.VB - ICSharpCode.NRefactory.VB - Properties - False - False - 4 - false - True - ..\..\NRefactory\ICSharpCode.NRefactory.snk - False - File - - - AnyCPU - - - bin\Debug\ - True - Full - False - True - DEBUG;TRACE - - - bin\Release\ - False - None - True - False - TRACE - - - - - 3.5 - - - - 3.5 - - - - - Properties\GlobalAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ExpressionFinder.atg - - - - - - - - - - - - - - - - - - - - vb.atg - - - - - - - - - - - - - - - - - - - - - CocoParserGenerator - ICSharpCode.NRefactory.VB.Parser - Parser.cs - - - - ExpressionFinder.atg - - - vb.atg - - - ICSharpCode.NRefactory.VB.Parser - CocoParserGenerator - Parser.cs - - - - - {53dca265-3c3c-42f9-b647-f72ba678122b} - ICSharpCode.NRefactory.CSharp - - - {3b2a5653-ec97-4001-bb9b-d90f1af2c371} - ICSharpCode.NRefactory - - - - \ No newline at end of file diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Block.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Block.cs deleted file mode 100644 index 6b4218e7c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Block.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public enum Context - { - Global, - TypeDeclaration, - ObjectCreation, - ObjectInitializer, - CollectionInitializer, - Type, - Member, - Parameter, - Identifier, - Body, - Xml, - Attribute, - Importable, - Query, - Expression, - Debug, - Default - } - - public class Block : ICloneable - { - public static readonly Block Default = new Block() { - context = Context.Global, - lastExpressionStart = TextLocation.Empty - }; - - public Context context; - public TextLocation lastExpressionStart; - public bool isClosed; - - public override string ToString() - { - return string.Format("[Block Context={0}, LastExpressionStart={1}, IsClosed={2}]", context, lastExpressionStart, isClosed); - } - - public object Clone() - { - return new Block() { - context = this.context, - lastExpressionStart = this.lastExpressionStart, - isClosed = this.isClosed - }; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg deleted file mode 100644 index b2768890d..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.atg +++ /dev/null @@ -1,1375 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -PUSHCOMPILER WITH EXPECTEDSETS ExpressionFinder - -/* START AUTOGENERATED TOKENS SECTION */ -TOKENS - /* ----- terminal classes ----- */ - /* EOF is 0 */ - EOL - ident - LiteralString - LiteralCharacter - LiteralInteger - LiteralDouble - LiteralSingle - LiteralDecimal - LiteralDate - XmlOpenTag - XmlCloseTag - XmlStartInlineVB - XmlEndInlineVB - XmlCloseTagEmptyElement - XmlOpenEndTag - XmlContent - XmlComment - XmlCData - XmlProcessingInstruction - - /* ----- special character ----- */ - "=" - ":" - "," - "&" - "/" - "\\" - "." - "..." - ".@" - "!" - "-" - "+" - "^" - "?" - "*" - "{" - "}" - "(" - ")" - ">" - "<" - "<>" - ">=" - "<=" - "<<" - ">>" - "+=" - "^=" - "-=" - "*=" - "/=" - "\\=" - "<<=" - ">>=" - "&=" - ":=" - - /* ----- keywords ----- */ - "AddHandler" - "AddressOf" - "Aggregate" - "Alias" - "And" - "AndAlso" - "Ansi" - "As" - "Ascending" - "Assembly" - "Auto" - "Binary" - "Boolean" - "ByRef" - "By" - "Byte" - "ByVal" - "Call" - "Case" - "Catch" - "CBool" - "CByte" - "CChar" - "CDate" - "CDbl" - "CDec" - "Char" - "CInt" - "Class" - "CLng" - "CObj" - "Compare" - "Const" - "Continue" - "CSByte" - "CShort" - "CSng" - "CStr" - "CType" - "CUInt" - "CULng" - "CUShort" - "Custom" - "Date" - "Decimal" - "Declare" - "Default" - "Delegate" - "Descending" - "Dim" - "DirectCast" - "Distinct" - "Do" - "Double" - "Each" - "Else" - "ElseIf" - "End" - "EndIf" - "Enum" - "Equals" - "Erase" - "Error" - "Event" - "Exit" - "Explicit" - "False" - "Finally" - "For" - "Friend" - "From" - "Function" - "Get" - "GetType" - "Global" - "GoSub" - "GoTo" - "Group" - "Handles" - "If" - "Implements" - "Imports" - "In" - "Infer" - "Inherits" - "Integer" - "Interface" - "Into" - "Is" - "IsNot" - "Join" - "Key" - "Let" - "Lib" - "Like" - "Long" - "Loop" - "Me" - "Mod" - "Module" - "MustInherit" - "MustOverride" - "MyBase" - "MyClass" - "Namespace" - "Narrowing" - "New" - "Next" - "Not" - "Nothing" - "NotInheritable" - "NotOverridable" - "Object" - "Of" - "Off" - "On" - "Operator" - "Option" - "Optional" - "Or" - "Order" - "OrElse" - "Out" - "Overloads" - "Overridable" - "Overrides" - "ParamArray" - "Partial" - "Preserve" - "Private" - "Property" - "Protected" - "Public" - "RaiseEvent" - "ReadOnly" - "ReDim" - "Rem" - "RemoveHandler" - "Resume" - "Return" - "SByte" - "Select" - "Set" - "Shadows" - "Shared" - "Short" - "Single" - "Skip" - "Static" - "Step" - "Stop" - "Strict" - "String" - "Structure" - "Sub" - "SyncLock" - "Take" - "Text" - "Then" - "Throw" - "To" - "True" - "Try" - "TryCast" - "TypeOf" - "UInteger" - "ULong" - "Unicode" - "Until" - "UShort" - "Using" - "Variant" - "Wend" - "When" - "Where" - "While" - "Widening" - "With" - "WithEvents" - "WriteOnly" - "Xor" - "GetXmlNamespace" -/* END AUTOGENERATED TOKENS SECTION */ - -PRODUCTIONS -/*------------------------------------------------------------------------*/ -ExpressionFinder = - (. PushContext(Context.Global, la, t); .) - { OptionStatement } - { ImportsStatement } - { EXPECTEDCONFLICT("<") AttributeBlock } /* Expected LL(1) conflict: we can't tell global attributes */ - /* from those on types. */ - /* This isn't a problem, we can just treat all as global attributes */ - { NamespaceMemberDeclaration } - (. PopContext(); .) -. - -StatementTerminator - (. if (la != null) CurrentBlock.lastExpressionStart = la.Location; .) -= - EOL | ":" -. - -OptionStatement = - "Option" ( ( "Explicit" | "Strict" | "Infer" ) [ "Off" | "On" ] | "Compare" ( "Text" | "Binary" ) ) StatementTerminator -. - -ImportsStatement = - "Imports" (. PushContext(Context.Importable, la, t); .) - (. nextTokenIsStartOfImportsOrAccessExpression = true; .) - ( - ( "Global" | Identifier | PrimitiveTypeName ) { TypeSuffix } [ ( "." | "=" ) TypeName ] - | XmlOpenTag Identifier "=" LiteralString XmlCloseTag - ) - { "," - (. nextTokenIsStartOfImportsOrAccessExpression = true; .) - ( - ( "Global" | Identifier | PrimitiveTypeName ) { TypeSuffix } [ ( "." | "=" ) TypeName ] - | XmlOpenTag Identifier "=" LiteralString XmlCloseTag - ) - } - (. PopContext(); .) - StatementTerminator - -. - -AttributeBlock = - "<" (. wasNormalAttribute = true; PushContext(Context.Attribute, la, t); .) [ ( "Assembly" | "Module" ) ":" (. wasNormalAttribute = false; .) ] { ANY } ">" (. PopContext(); .) [ EOL ] -. - -NamespaceMemberDeclaration = - NamespaceDeclaration - | TypeDeclaration -. - -NamespaceDeclaration = - "Namespace" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) { ANY } (. PopContext(); .) StatementTerminator - { NamespaceMemberDeclaration } - "End" "Namespace" StatementTerminator -. - -TypeDeclaration = - { AttributeBlock } - { TypeModifier } - ( ClassOrModuleOrStructureTypeDeclaration | - DelegateTypeDeclaration | - EnumTypeDeclaration | - InterfaceDeclaration ) -. - -ClassOrModuleOrStructureTypeDeclaration = - (. PushContext(Context.TypeDeclaration, la, t); .) - ( "Module" | "Class" | "Structure" ) (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "(" "Of" GenericTypeParameterDeclaration ")" ] StatementTerminator - [ (. isMissingModifier = false; .) "Inherits" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) StatementTerminator ] - [ (. isMissingModifier = false; .) "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) } StatementTerminator ] - { - { AttributeBlock } (.OnEachPossiblePath: isMissingModifier = true; .) - { TypeOrMemberModifier (. isMissingModifier = false; .) } (. isMissingModifier = false; .) - ( ClassOrModuleOrStructureTypeDeclaration | DelegateTypeDeclaration | EnumTypeDeclaration - | InterfaceDeclaration | MemberDeclaration ) - } - (. isMissingModifier = false; .) - "End" ( "Module" | "Class" | "Structure" ) StatementTerminator - (. PopContext(); .) -. - -EnumTypeDeclaration = - (. PushContext(Context.TypeDeclaration, la, t); .) - "Enum" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminator - { - { AttributeBlock } - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "=" Expression ] - StatementTerminator - } - "End" "Enum" StatementTerminator - (. PopContext(); .) -. - -InterfaceDeclaration = - (. PushContext(Context.TypeDeclaration, la, t); .) - "Interface" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "(" "Of" GenericTypeParameterDeclaration ")" ] StatementTerminator - [ "Inherits" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) } StatementTerminator ] - { - { AttributeBlock } (.OnEachPossiblePath: isMissingModifier = true; .) - { TypeOrMemberModifier (. isMissingModifier = false; .) } (. isMissingModifier = false; .) - ( ClassOrModuleOrStructureTypeDeclaration | DelegateTypeDeclaration | EnumTypeDeclaration - | InterfaceDeclaration | InterfaceMemberDeclaration ) - } - (. isMissingModifier = false; .) - "End" "Interface" StatementTerminator - (. PopContext(); .) -. - -InterfaceMemberDeclaration = - InterfaceEvent | InterfaceProperty | InterfaceSubOrFunction -. - -TypeOrMemberModifier = - MemberModifier /* contains all modifiers for types */ -. - -InterfaceEvent = - "Event" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | ParameterListInParenthesis ] - StatementTerminator -. - -InterfaceProperty = - "Property" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ ParameterListInParenthesis ] [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ] - StatementTerminator -. - -InterfaceSubOrFunction = - ("Sub" | "Function") - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) - { "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" } - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - StatementTerminator -. - -GenericConstraint = - TypeName | "New" | "Class" | "Structure" -. - -GenericConstraintList = - GenericConstraint | "{" GenericConstraint { "," GenericConstraint } "}" -. - -GenericTypeParameterDeclaration = - [ "Out" | "In" ] (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierExceptOut (. PopContext(); .) [ "As" (. PushContext(Context.Type, la, t); .) GenericConstraintList (. PopContext(); .) ] - { "," [ "Out" | "In" ] (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierExceptOut (. PopContext(); .) [ "As" (. PushContext(Context.Type, la, t); .) GenericConstraintList (. PopContext(); .) ] } -. - -DelegateTypeDeclaration = - "Delegate" ("Sub" | "Function") - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) - { "(" [ "Of" GenericTypeParameterDeclaration | ParameterList ] ")" } - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - StatementTerminator -. - -MemberDeclaration = - (. PushContext(Context.Member, la, t); .) - ( - MemberVariableOrConstantDeclaration | - SubOrFunctionDeclaration | - ExternalMemberDeclaration | - EventMemberDeclaration | - CustomEventMemberDeclaration | - PropertyDeclaration | - OperatorDeclaration - ) - (. PopContext(); .) -. - -SubOrFunctionDeclaration = - ("Sub" | "Function") - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) - { "(" [ ( "Of" GenericTypeParameterDeclaration | ParameterList ) ] ")" } - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - [ ( "Implements" | "Handles" ) [ ( "Me" | "MyClass" | "MyBase" ) "." ] TypeName ] - StatementTerminatorAndBlock - "End" ("Sub" | "Function") StatementTerminator -. - -ExternalMemberDeclaration = - "Declare" [ "Ansi" | "Unicode" | "Auto" ] ( "Sub" | "Function" ) - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - "Lib" LiteralString - [ "Alias" LiteralString ] - [ ParameterListInParenthesis ] - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - StatementTerminator -. - -EventMemberDeclaration = - "Event" - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) | [ ParameterListInParenthesis ] ) - [ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ - { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ] - /* the TypeName production already allows the "." IdentifierOrKeyword syntax, so to avoid an ambiguous grammar we just leave that out */ - StatementTerminator -. - -CustomEventMemberDeclaration = - "Custom" EventMemberDeclaration - { - { AttributeBlock } ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) "(" ParameterList ")" - StatementTerminatorAndBlock - "End" ( "AddHandler" | "RemoveHandler" | "RaiseEvent" ) StatementTerminator - } - "End" "Event" StatementTerminator -. - -PropertyDeclaration = - "Property" - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ ParameterListInParenthesis ] - [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } ( NewExpression | TypeName ) (. PopContext(); .) ] - [ "Implements" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ - { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) /*"." IdentifierOrKeyword*/ } ] - [ "=" Expression ] StatementTerminator - (. PopContext(); .) { EXPECTEDCONFLICT("<") AttributeBlock } - { EXPECTEDCONFLICT("Public", "Protected", "Private", "Friend") AccessModifier - // HACK : OnEachPossiblePath cannot detect that this might be the end of an auto property - // so we need to simulate it - (.OnEachPossiblePath: SetIdentifierExpected(la); .) } - [ (. PushContext(Context.Member, la, t); .) - ( "Get" | "Set" ) [ ParameterListInParenthesis ] - StatementTerminatorAndBlock - "End" ( "Get" | "Set" ) StatementTerminator - [ { AttributeBlock } { AccessModifier } ( "Get" | "Set" ) [ ParameterListInParenthesis ] - StatementTerminatorAndBlock - "End" ( "Get" | "Set" ) StatementTerminator ] - - "End" "Property" StatementTerminator ] -. - -OperatorDeclaration = - "Operator" (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) ANY (. PopContext(); .) - "(" ParameterList ")" - [ "As" (. PushContext(Context.Type, la, t); .) { AttributeBlock } TypeName (. PopContext(); .) ] - StatementTerminatorAndBlock - "End" "Operator" StatementTerminator -. - -MemberVariableOrConstantDeclaration = - MemberVariableOrConstantDeclarator { "," MemberVariableOrConstantDeclarator } StatementTerminator -. - -MemberVariableOrConstantDeclarator = - [ "Const" ] - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) IdentifierForFieldDeclaration (. PopContext(); .) - [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } - [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] - [ "=" Expression ] -. - -ParameterList = - Parameter { "," Parameter } -. - -Parameter = - (. PushContext(Context.Parameter, la, t); .) - { AttributeBlock } { ParameterModifier } - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "?" ] { "(" { "," } ")" } - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - [ "=" Expression ] - (. PopContext(); .) -. - -StatementTerminatorAndBlock = - (. PushContext(Context.Body, la, t); .) - StatementTerminator - { EXPECTEDCONFLICT("End") - ( - [ Statement] StatementTerminator - | "End" - ( StatementTerminator /* End+StatementTerminator is end statement */ - | /* End+anything else is the end of this block. */ - (. - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process End again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - .) - ANY /* never reached due to goto above: */ - /* this ANY is just so that Coco knows this branch isn't empty */ - ) - ) - } - (.NamedState:endOfStatementTerminatorAndBlock.) - (. PopContext(); .) -. - -Expression - (.NamedState:startOfExpression.) -= - (. PushContext(Context.Expression, la, t); .) - SimpleExpressionWithSuffix { BinaryOperator SimpleExpressionWithSuffix } - (. PopContext(); .) -. - -BinaryOperator = - "+" | "-" | "*" | "\\" | "/" | "^" | "Mod" - | "=" | "<>" | "<" | ">" (. wasNormalAttribute = false; .) | "<=" | ">=" - | "Like" | "&" | "And" | "AndAlso" | "Or" | "OrElse" - | "Xor" | "<<" | ">>" | "Is" | "IsNot" - | "^=" | "*=" | "/=" | "\\=" | "+=" | "-=" | "&=" | "<<=" | ">>=" | "To" | ":=" -. - -UnaryOperator = - "+" | "-" | "Not" | "AddressOf" -. - -SimpleExpressionWithSuffix = - (. PushContext(Context.Expression, la, t); .) - { UnaryOperator } - ( - SimpleExpression { ExpressionSuffix } - | "TypeOf" SimpleExpressionWithSuffix "Is" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) - | NewExpression - | CollectionInitializer - ) - (. PopContext(); .) -. - -SimpleExpression = - (. PushContext(Context.Expression, la, t); .) - ( Literal - | ( "(" (. activeArgument = 0; .) Expression // HACK in ExpressionRangeVariable Identifier is consumed before start - // of Expression so this can be an argument list too - { "," (. activeArgument++; .) Expression } ")" ) - | IdentifierForExpressionStart - | PrimitiveTypeName - | ( "." | "!" | ".@" | "..." ) (. nextTokenIsStartOfImportsOrAccessExpression = true; wasQualifierTokenAtStart = true; .) [ XmlOpenTag ] IdentifierOrKeyword [ XmlCloseTag ] - | "GetType" "(" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ")" - | "GetXmlNamespace" "(" (. readXmlIdentifier = true; .) Identifier ")" - | XmlLiteral - | LambdaExpression - | GREEDY QueryExpression - | CastExpression - | ConditionalExpression - ) - (. PopContext(); .) -. - -NewExpression = - "New" (. PushContext(Context.ObjectCreation, la, t); .) - ( - TypeName - [ - EXPECTEDCONFLICT("From") - ( - (. PushContext(Context.CollectionInitializer, la, t); .) - "From" - ( - CollectionInitializer /* From + CollectionInitializer is a NewExpression */ - | - (. - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process From again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - .) - ANY /* never reached due to goto above: */ - /* this ANY is just so that Coco knows this branch isn't empty */ - ) - (. PopContext(); .) - | - /* handle array initializer after New */ - (. PushContext(Context.CollectionInitializer, la, t); .) - CollectionInitializer - (. PopContext(); .) - | - (. PushContext(Context.ObjectInitializer, la, t); .) - "With" ObjectInitializer - (. PopContext(); .) - ) - ] - | - (. PushContext(Context.ObjectInitializer, la, t); .) - "With" ObjectInitializer - (. PopContext(); .) - ) - (. PopContext(); .) -. - -ObjectInitializer = - "{" [ [ "Key" ] "." IdentifierOrKeyword "=" Expression { "," [ "Key" ] "." IdentifierOrKeyword "=" Expression } ] "}" -. - -CollectionInitializer = - "{" [ Expression { "," Expression } ] "}" -. - -ExpressionSuffix = - "(" (. PushContext(Context.Expression, la, t); .) - ( "Of" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) - { "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) } - | [ ArgumentList ] ) (. PopContext(); .) ")" -| ( "." | "!" | ".@" | "..." ) (. nextTokenIsStartOfImportsOrAccessExpression = true; .) [ XmlOpenTag ] IdentifierOrKeyword [ XmlCloseTag ] -. - -CastExpression = - SimpleCastExpression | ("DirectCast" | "TryCast" | "CType") "(" Expression "," (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ")" -. - -SimpleCastExpression = - ( - "CBool" | - "CByte" | - "CChar" | - "CDate" | - "CDec" | - "CDbl" | - "CInt" | - "CLng" | - "CObj" | - "CSByte" | - "CShort" | - "CSng" | - "CStr" | - "CUInt" | - "CULng" | - "CUShort" - ) - "(" Expression ")" -. - -ConditionalExpression = - "If" "(" Expression "," Expression [ "," Expression ] ")" -. - -LambdaExpression = - SubLambdaExpression | - FunctionLambdaExpression -. - -SubLambdaExpression = - "Sub" ParameterListInParenthesis - ( GREEDY Statement | StatementTerminatorAndBlock "End" "Sub" ) -. - -FunctionLambdaExpression = - "Function" ParameterListInParenthesis - ( GREEDY Expression | [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] StatementTerminatorAndBlock "End" "Function" ) -. - -ParameterListInParenthesis = - "(" (. PushContext(Context.Default, la, t); .) [ ParameterList ] (. PopContext(); .) ")" -. - -QueryExpression - (. PushContext(Context.Query, la, t); .) -= - ( FromQueryOperator | AggregateQueryOperator ) - { QueryOperator } - (. PopContext(); .) -. - -QueryOperator = - FromQueryOperator - | AggregateQueryOperator - | SelectQueryOperator - | DistinctQueryOperator - | WhereQueryOperator - | OrderByQueryOperator - | PartitionQueryOperator - | LetQueryOperator - | GroupByOrGroupJoinQueryOperator - | JoinQueryOperator -. - -FromQueryOperator = - "From" CollectionRangeVariable { "," CollectionRangeVariable } -. - -AggregateQueryOperator = - "Aggregate" CollectionRangeVariable { QueryOperator } "Into" ExpressionRangeVariable { "," ExpressionRangeVariable } -. - -SelectQueryOperator = - "Select" ExpressionRangeVariable { "," ExpressionRangeVariable } -. - -DistinctQueryOperator = - "Distinct" -. - -WhereQueryOperator = - "Where" Expression -. - -OrderByQueryOperator = - "Order" "By" Expression ( "Ascending" | "Descending" ) { "," Expression ( "Ascending" | "Descending" ) } -. - -PartitionQueryOperator = - ( "Take" | "Skip" ) [ "While" ] Expression -. - -LetQueryOperator = - "Let" ExpressionRangeVariable { "," ExpressionRangeVariable } -. - -GroupByOrGroupJoinQueryOperator = - "Group" - ( - EXPECTEDCONFLICT("Join") - JoinQueryOperator { ( "Group" JoinQueryOperator GroupJoinSuffix | JoinQueryOperator ) } - GroupJoinSuffix - | - ( EXPECTEDCONFLICT("By") () | ExpressionRangeVariable { "," ExpressionRangeVariable } ) - "By" ExpressionRangeVariable { "," ExpressionRangeVariable } - "Into" ExpressionRangeVariable { "," ExpressionRangeVariable } - ) -. - -JoinQueryOperator = - "Join" CollectionRangeVariable - "On" Expression "Equals" Expression { "," Expression "Equals" Expression } -. - -GroupJoinSuffix = - "Into" ExpressionRangeVariable { "," ExpressionRangeVariable } -. - -ExpressionRangeVariable = - [ - EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", - "Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From", - "Explicit", "Equals", "Distinct", "Descending", "Compare", "By", - "Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) - ( - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier - // HACK: needs to be optional because Expression can start with Identifier too - [ (. PopContext(); isAlreadyInExpr = true; .) - ( "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) "=" - | "=" - | (. - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process Identifier again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - .) - ANY /* never reached due to goto above: */ - /* this ANY is just so that Coco knows this branch isn't empty */ - ) - ] - ) - ] - Expression - (. if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; .) -. - -CollectionRangeVariable = - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - "In" Expression -. - -/* semantic action will be inserted on all paths that possibly lead to XmlLiteral */ -XmlLiteral - (.OnEachPossiblePath: nextTokenIsPotentialStartOfExpression = true; .) -= - (. PushContext(Context.Xml, la, t); .) - ( - ( XmlComment | XmlProcessingInstruction | XmlCData ) [ XmlContent ] { ( XmlComment | XmlProcessingInstruction ) [ XmlContent ] } [ XmlElement { XmlComment [ XmlContent ] } ] - | - XmlElement { XmlComment [ XmlContent ] } - ) - (. PopContext(); .) -. - -XmlElement = - (. PushContext(Context.Xml, la, t); .) - XmlOpenTag { ANY | XmlEmbeddedExpression } ( XmlCloseTagEmptyElement | XmlCloseTag { ANY | XmlEmbeddedExpression | XmlElement } XmlOpenEndTag { ANY | XmlEmbeddedExpression } XmlCloseTag ) - (. PopContext(); .) -. - -XmlEmbeddedExpression = - XmlStartInlineVB Expression XmlEndInlineVB -. - -PrimitiveTypeName = - "Byte" | - "SByte" | - "UShort" | - "Short" | - "UInteger" | - "Integer" | - "ULong" | - "Long" | - "Single" | - "Double" | - "Decimal" | - "Boolean" | - "Date" | - "Char" | - "String" | - "Object" -. - -TypeName = ( "Global" | Identifier | PrimitiveTypeName | "?" /* used for ? = completion */ ) { TypeSuffix } { "." IdentifierOrKeyword { TypeSuffix } } . - -TypeSuffix = "(" (. PushContext(Context.Expression, la, t); .) ( "Of" [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] { "," [ (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] } | [ ArgumentList ] ) (. PopContext(); .) ")" . - -IdentifierOrKeyword = ident -| "AddHandler" -| "AddressOf" -| "Aggregate" -| "Alias" -| "And" -| "AndAlso" -| "Ansi" -| "As" -| "Ascending" -| "Assembly" -| "Auto" -| "Binary" -| "Boolean" -| "ByRef" -| "By" -| "Byte" -| "ByVal" -| "Call" -| "Case" -| "Catch" -| "CBool" -| "CByte" -| "CChar" -| "CDate" -| "CDbl" -| "CDec" -| "Char" -| "CInt" -| "Class" -| "CLng" -| "CObj" -| "Compare" -| "Const" -| "Continue" -| "CSByte" -| "CShort" -| "CSng" -| "CStr" -| "CType" -| "CUInt" -| "CULng" -| "CUShort" -| "Custom" -| "Date" -| "Decimal" -| "Declare" -| "Default" -| "Delegate" -| "Descending" -| "Dim" -| "DirectCast" -| "Distinct" -| "Do" -| "Double" -| "Each" -| "Else" -| "ElseIf" -| "End" -| "EndIf" -| "Enum" -| "Equals" -| "Erase" -| "Error" -| "Event" -| "Exit" -| "Explicit" -| "False" -| "Finally" -| "For" -| "Friend" -| "From" -| "Function" -| "Get" -| "GetType" -| "Global" -| "GoSub" -| "GoTo" -| "Group" -| "Handles" -| "If" -| "Implements" -| "Imports" -| "In" -| "Infer" -| "Inherits" -| "Integer" -| "Interface" -| "Into" -| "Is" -| "IsNot" -| "Join" -| "Key" -| "Let" -| "Lib" -| "Like" -| "Long" -| "Loop" -| "Me" -| "Mod" -| "Module" -| "MustInherit" -| "MustOverride" -| "MyBase" -| "MyClass" -| "Namespace" -| "Narrowing" -| "New" -| "Next" -| "Not" -| "Nothing" -| "NotInheritable" -| "NotOverridable" -| "Object" -| "Of" -| "Off" -| "On" -| "Operator" -| "Option" -| "Optional" -| "Or" -| "Order" -| "OrElse" -| "Out" -| "Overloads" -| "Overridable" -| "Overrides" -| "ParamArray" -| "Partial" -| "Preserve" -| "Private" -| "Property" -| "Protected" -| "Public" -| "RaiseEvent" -| "ReadOnly" -| "ReDim" -| "Rem" -| "RemoveHandler" -| "Resume" -| "Return" -| "SByte" -| "Select" -| "Set" -| "Shadows" -| "Shared" -| "Short" -| "Single" -| "Skip" -| "Static" -| "Step" -| "Stop" -| "Strict" -| "String" -| "Structure" -| "Sub" -| "SyncLock" -| "Take" -| "Text" -| "Then" -| "Throw" -| "To" -| "True" -| "Try" -| "TryCast" -| "TypeOf" -| "UInteger" -| "ULong" -| "Unicode" -| "Until" -| "UShort" -| "Using" -| "Variant" -| "Wend" -| "When" -| "Where" -| "While" -| "Widening" -| "With" -| "WithEvents" -| "WriteOnly" -| "Xor" -| "GetXmlNamespace" -. - -Literal = - LiteralString | - LiteralCharacter | - LiteralInteger | - LiteralDouble | - LiteralSingle | - LiteralDecimal | - LiteralDate | - "True" | - "False" | - "Nothing" | - /* from InstanceExpression */ - "Me" | - "MyBase" | - "MyClass" -. - -Statement = - VariableDeclarationStatement - | WithOrLockStatement - | AddOrRemoveHandlerStatement - | RaiseEventStatement - | EXPECTEDCONFLICT("If") IfStatement /* prefer if-statement to if-expression */ - | SelectStatement - | WhileStatement - | DoLoopStatement - | ForStatement - | ErrorHandlingStatement - | ThrowStatement - | TryStatement - | BranchStatement - | ReDimStatement - | EraseStatement - | UsingStatement - | InvocationStatement -. - -VariableDeclarationStatement = - ( "Dim" | "Static" | "Const" ) - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) - Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } - [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] - [ "=" Expression ] - { "," - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) - Identifier (. PopContext(); .) [ "?" ] { "(" [ Expression ] { "," [ Expression ] } ")" } - [ "As" (. PushContext(Context.Type, la, t); .) ( NewExpression | TypeName ) (. PopContext(); .) ] - [ "=" Expression ] - } -. - -WithOrLockStatement = - ( "With" | "SyncLock" ) Expression StatementTerminatorAndBlock "End" ( "With" | "SyncLock" ) -. - -AddOrRemoveHandlerStatement = - ( "AddHandler" | "RemoveHandler" ) Expression "," Expression -. - -RaiseEventStatement = - "RaiseEvent" IdentifierOrKeyword [ "(" (. PushContext(Context.Expression, la, t); .) [ ArgumentList ] (. PopContext(); .) ")" ] -. - -IfStatement = - "If" Expression - ( "Then" - ( Statement { EXPECTEDCONFLICT(":") ":" [Statement] } [ EXPECTEDCONFLICT("Else") "Else" [Statement] { EXPECTEDCONFLICT(":") ":" [Statement] } ] - | MultilineIfRemainder - ) - | MultilineIfRemainder - ) -. - -MultilineIfRemainder = - StatementTerminatorAndBlock - { - ("Else" [ "If" Expression [ "Then" ] ] - | "ElseIf" Expression [ "Then" ] - ) - StatementTerminatorAndBlock - } - "End" "If" -. - -SelectStatement = - "Select" [ "Case" ] Expression StatementTerminator - { - "Case" ( - "Else" | - ( [ "Is" ] ComparisonOperator SimpleExpressionWithSuffix | Expression ) - { "," ( [ "Is" ] ComparisonOperator SimpleExpressionWithSuffix | Expression ) } - ) - StatementTerminatorAndBlock - } - "End" "Select" -. - -ComparisonOperator = - "=" | "<>" | "<" | ">" (. wasNormalAttribute = false; .) | ">=" | "<=" -. - -WhileStatement = - "While" Expression StatementTerminatorAndBlock "End" "While" -. - -DoLoopStatement = - "Do" ( DoTopLoopStatement | DoBottomLoopStatement ) -. - -DoTopLoopStatement = - ( "While" | "Until" ) Expression - StatementTerminatorAndBlock - "Loop" -. - -DoBottomLoopStatement = - StatementTerminatorAndBlock - "Loop" [ ( "While" | "Until" ) Expression ] -. - -ForStatement = - "For" ( ForLoopStatement | ForEachLoopStatement ) -. - -ForLoopStatement = - ForLoopVariable "=" Expression /* "To" is binary operator */ [ "Step" Expression ] - StatementTerminatorAndBlock - "Next" [ Expression { "," Expression } ] -. - -ForEachLoopStatement = - "Each" ForLoopVariable "In" Expression - StatementTerminatorAndBlock - "Next" [ Expression { "," Expression } ] -. - -ForLoopVariable = - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) SimpleExpression (. PopContext(); .) - [ "?" ] { ExpressionSuffix } - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] -. - -ErrorHandlingStatement = - [ "On" ] "Error" ( Expression | "GoTo" ( LiteralInteger | Identifier ) | "Resume" "Next" ) - | "Resume" ( "Next" | LiteralInteger | Identifier ) -. - -ThrowStatement = - "Throw" [ Expression ] -. - -TryStatement = - "Try" - StatementTerminatorAndBlock - { - "Catch" - [ (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier (. PopContext(); .) - [ "As" (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) ] - ] - [ "When" Expression ] - StatementTerminatorAndBlock - } - [ - "Finally" - StatementTerminatorAndBlock - ] - "End" "Try" -. - -BranchStatement = - "GoTo" ( Identifier | LiteralInteger ) - | "Exit" ( "Do" | "For" | "While" | "Select" | "Sub" | "Function" | "Property" | "Try" ) - | "Continue" ( "Do" | "For" | "While" ) - | "Stop" - /*| "End" HACK End-Statements has special handling in Block */ - | "Return" (. PushContext(Context.Expression, la, t); .) [ Expression ] (. PopContext(); .) -. - -ReDimStatement = - "ReDim" - [ EXPECTEDCONFLICT("Preserve") "Preserve" ] /* Preserve is context-dependend keyword */ - Expression -. - -EraseStatement = - "Erase" Expression { "," Expression } -. - -UsingVariable = - [ - EXPECTEDCONFLICT("Where", "Until", "Unicode", "Text", "Take", "Skip", "Preserve", - "Order", "Off", "Out", "Key", "Join", "Into", "Infer", "Group", "From", - "Explicit", "Equals", "Distinct", "Descending", "Compare", "By", - "Binary", "Auto", "Assembly", "Ascending", "Ansi", "Aggregate", ident) - ( - (. PushContext(Context.Identifier, la, t); .) (.OnEachPossiblePath: SetIdentifierExpected(la); .) Identifier - // HACK: needs to be optional because Expression can start with Identifier too - [ (. PopContext(); isAlreadyInExpr = true; .) - ( "As" [ EXPECTEDCONFLICT("Where", "UShort", "Until", "Unicode", "ULong", "UInteger", "Text", "Take", - "String", "Skip", "Single", "Short", "SByte", "Preserve", "Out", "Order", - "Off", "Object", "Long", "Key", "Join", "Into", "Integer", "Infer", "Group", - "From", "Explicit", "Equals", "Double", "Distinct", "Descending", "Decimal", - "Date", "Compare", "Char", "Byte", "By", "Boolean", "Binary", "Binary", "Auto", - "Assembly", "Ascending", "Ansi", "Aggregate", ident) - (. PushContext(Context.Type, la, t); .) TypeName (. PopContext(); .) "=" ] - | "=" - | (. - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process Identifier again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - .) - ANY /* never reached due to goto above: */ - /* this ANY is just so that Coco knows this branch isn't empty */ - ) - ] - ) - ] - Expression - (. if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; .) -. - -UsingStatement = - "Using" UsingVariable { "," UsingVariable } - StatementTerminatorAndBlock - "End" "Using" -. - -InvocationStatement = - [ "Call" ] Expression -. - -ArgumentList = - (. activeArgument = 0; .) Expression { "," (. activeArgument++; .) [ Expression ] } -| (. activeArgument = 0; .) "," (. activeArgument++; .) [ Expression ] { "," (. activeArgument++; .) [ Expression ] } -. - -/* This production handles pseudo keywords that are needed in the grammar */ -Identifier = - IdentifierForFieldDeclaration - | "Custom" -. - -IdentifierForFieldDeclaration = - IdentifierForExpressionStart - | "Aggregate" - | "From" -. - -IdentifierForExpressionStart = - IdentifierExceptOut - | "Out" -. - -IdentifierExceptOut = - ident - | "Ansi" - | "Ascending" - | "Assembly" - | "Auto" - | "Binary" - | "By" - | "Compare" - | "Descending" - | "Distinct" - | "Equals" - | "Explicit" - | "Group" - | "Infer" - | "Into" - | "Join" - | "Key" - | "Off" - | "Order" - | "Preserve" - | "Skip" - | "Take" - | "Text" - | "Unicode" - | "Until" - | "Where" -. - -AccessModifier = - "Public" | - "Friend" | - "Protected" | - "Private" -. - -TypeModifier = - AccessModifier | - "MustInherit" | - "NotInheritable" | - "Shadows" | - "Partial" -. - -MemberModifier = - AccessModifier | - "Shadows" | - "Shared" | - "Overridable" | - "NotOverridable" | - "NotInheritable" | - "Overrides" | - "Overloads" | - "Partial" | - "WithEvents" | - "MustOverride" | - "Widening" | - "Narrowing" | - "ReadOnly" | - "WriteOnly" | - "Default" | - "Dim" -. - -ParameterModifier = - "ByVal" | - "ByRef" | - "Optional" | - "ParamArray" -. - -END ExpressionFinder . diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.cs deleted file mode 100644 index 42b6e05c4..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinder.cs +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public partial class ExpressionFinder - { - Stack stack = new Stack(); - StringBuilder output = new StringBuilder(); - - void PopContext() - { - if (stack.Any()) { - string indent = new string('\t', stack.Count - 1); - var item = stack.Pop(); - item.isClosed = true; - Print(indent + "exit " + item.context); - } else { - Print("empty stack"); - } - } - - void PushContext(Context context, Token la, Token t) - { - string indent = new string('\t', stack.Count); - TextLocation l = la == null ? (t == null ? TextLocation.Empty : t.EndLocation) : la.Location; - - stack.Push(new Block() { context = context, lastExpressionStart = l }); - Print(indent + "enter " + context); - } - - public ExpressionFinder(ExpressionFinderState state) - { - wasQualifierTokenAtStart = state.WasQualifierTokenAtStart; - nextTokenIsPotentialStartOfExpression = state.NextTokenIsPotentialStartOfExpression; - nextTokenIsStartOfImportsOrAccessExpression = state.NextTokenIsStartOfImportsOrAccessExpression; - readXmlIdentifier = state.ReadXmlIdentifier; - identifierExpected = state.IdentifierExpected; - stateStack = new Stack(state.StateStack.Reverse()); - stack = new Stack(state.BlockStack.Select(x => (Block)x.Clone()).Reverse()); - currentState = state.CurrentState; - output = new StringBuilder(); - } - - void Print(string text) - { - //Console.WriteLine(text); - output.AppendLine(text); - } - - public void SetContext(SnippetType type) - { - switch (type) { - case SnippetType.Expression: - currentState = startOfExpression; - break; - } - - Advance(); - } - - public string Output { - get { return output.ToString(); } - } - - public string Stacktrace { - get { - string text = ""; - - foreach (Block b in stack) { - text += b.ToString() + "\n"; - } - - return text; - } - } - - public Block CurrentBlock { - get { return stack.Any() ? stack.Peek() : Block.Default; } - } - - public bool IsIdentifierExpected { - get { return identifierExpected; } - } - - void SetIdentifierExpected(Token la) - { - identifierExpected = true; - if (la != null) - CurrentBlock.lastExpressionStart = la.Location; - else if (t != null) - CurrentBlock.lastExpressionStart = t.EndLocation; - } - - public bool InContext(Context expected) - { - return stack - .SkipWhile(f => f.context == Context.Expression) - .IsElement(fx => fx.context == expected); - } - - public bool NextTokenIsPotentialStartOfExpression { - get { return nextTokenIsPotentialStartOfExpression; } - } - - public bool ReadXmlIdentifier { - get { return readXmlIdentifier; } - set { readXmlIdentifier = value; } - } - - public bool NextTokenIsStartOfImportsOrAccessExpression { - get { return nextTokenIsStartOfImportsOrAccessExpression; } - } - - public bool WasQualifierTokenAtStart { - get { return wasQualifierTokenAtStart; } - } - - public bool IsMissingModifier { - get { return isMissingModifier; } - } - - public bool WasNormalAttribute { - get { return wasNormalAttribute; } - } - - public int ActiveArgument { - get { return activeArgument; } - } - - public List Errors { - get { return errors; } - } - - public ExpressionFinderState Export() - { - return new ExpressionFinderState() { - WasQualifierTokenAtStart = wasQualifierTokenAtStart, - NextTokenIsPotentialStartOfExpression = nextTokenIsPotentialStartOfExpression, - NextTokenIsStartOfImportsOrAccessExpression = nextTokenIsStartOfImportsOrAccessExpression, - ReadXmlIdentifier = readXmlIdentifier, - IdentifierExpected = identifierExpected, - StateStack = new Stack(stateStack.Reverse()), - BlockStack = new Stack(stack.Select(x => (Block)x.Clone()).Reverse()), - CurrentState = currentState - }; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinderState.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinderState.cs deleted file mode 100644 index 0feda1f93..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/ExpressionFinderState.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public class ExpressionFinderState - { - public bool WasQualifierTokenAtStart { get; set; } - public bool NextTokenIsPotentialStartOfExpression { get; set; } - public bool ReadXmlIdentifier { get; set; } - public bool IdentifierExpected { get; set; } - public bool NextTokenIsStartOfImportsOrAccessExpression { get; set; } - public Stack StateStack { get; set; } - public Stack BlockStack { get; set; } - public int CurrentState { get; set; } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Extensions.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Extensions.cs deleted file mode 100644 index 0107d3f08..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Extensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public static class Extensions - { - public static bool IsElement(this IEnumerable items, Func check) - { - T item = items.FirstOrDefault(); - - if (item != null) - return check(item); - return false; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/KeywordList.txt b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/KeywordList.txt deleted file mode 100644 index a2a29b670..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/KeywordList.txt +++ /dev/null @@ -1,284 +0,0 @@ -# this list is used for autogeneration of: -# - Keywords.cs -# - Tokens.cs -# - ATGTokensSection.txt - the TOKENS section of the ATG file - -# use BuildKeywords to generate the different lists. - -$Namespace=ICSharpCode.NRefactory.VB.Parser -$UpperCaseKeywords=True - -# TERMINAL_CLASSES -EOF -EOL -Identifier -LiteralString -LiteralCharacter -LiteralInteger -LiteralDouble -LiteralSingle -LiteralDecimal -LiteralDate - -# XML_TERMINALS -XmlOpenTag -XmlCloseTag -XmlStartInlineVB -XmlEndInlineVB -XmlCloseTagEmptyElement -XmlOpenEndTag -XmlContent -XmlComment -XmlCData -XmlProcessingInstruction - -# SPECIAL_CHARACTERS -Assign = "=" -Colon =":" -Comma = "," -ConcatString = "&" -Div ="/" -DivInteger = "\\" -Dot = "." -TripleDot = "..." -DotAt = ".@" -# Exclamation mark = Dictionary access operator (not always a token, sometimes it's a type character) -ExclamationMark = "!" -Minus = "-" -Plus = "+" -Power = "^" -QuestionMark = "?" -Times = "*" - -OpenCurlyBrace = "{" -CloseCurlyBrace = "}" - -OpenParenthesis = "(" -CloseParenthesis = ")" - -GreaterThan = ">" -LessThan = "<" - -NotEqual = "<>" -GreaterEqual = ">=" -LessEqual = "<=" - -ShiftLeft = "<<" -ShiftRight = ">>" - -PlusAssign = "+=" -PowerAssign = "^=" -MinusAssign = "-=" -TimesAssign = "*=" -DivAssign = "/=" -DivIntegerAssign = "\\=" -ShiftLeftAssign = "<<=" -ShiftRightAssign = ">>=" -ConcatStringAssign = "&=" -ColonAssign = ":=" - -# keywords according to the spec: -# Keywordlist -"AddHandler" -"AddressOf" -"Aggregate" -"Alias" -"And" -"AndAlso" -"Ansi" -"As" -"Ascending" -"Assembly" -"Auto" -"Binary" -"Boolean" -"ByRef" -"By" -"Byte" -"ByVal" -"Call" -"Case" -"Catch" -"CBool" -"CByte" -"CChar" -"CDate" -"CDbl" -"CDec" -"Char" -"CInt" -"Class" -"CLng" -"CObj" -"Compare" -"Const" -"Continue" -"CSByte" -"CShort" -"CSng" -"CStr" -"CType" -"CUInt" -"CULng" -"CUShort" -"Custom" -"Date" -"Decimal" -"Declare" -"Default" -"Delegate" -"Descending" -"Dim" -"DirectCast" -"Distinct" -"Do" -"Double" -"Each" -"Else" -"ElseIf" -"End" -"EndIf" -"Enum" -"Equals" -"Erase" -"Error" -"Event" -"Exit" -"Explicit" -"False" -"Finally" -"For" -"Friend" -"From" -"Function" -"Get" -"GetType" -"Global" -"GoSub" -"GoTo" -"Group" -"Handles" -"If" -"Implements" -"Imports" -"In" -"Infer" -"Inherits" -"Integer" -"Interface" -"Into" -"Is" -"IsNot" -# Note: IsTrue and IsFalse are 'NOT' keywords they're only valid in Operator declarations (like get/set/value are no C# 'keywords') -"Join" -"Key" -"Let" -"Lib" -"Like" -"Long" -"Loop" -"Me" -"Mod" -"Module" -"MustInherit" -"MustOverride" -"MyBase" -"MyClass" -"Namespace" -"Narrowing" -"New" -"Next" -"Not" -"Nothing" -"NotInheritable" -"NotOverridable" -"Object" -"Of" -"Off" -"On" -"Operator" -"Option" -"Optional" -"Or" -"Order" -"OrElse" -"Out" -"Overloads" -"Overridable" -"Overrides" -"ParamArray" -"Partial" -"Preserve" -"Private" -"Property" -"Protected" -"Public" -"RaiseEvent" -"ReadOnly" -"ReDim" -# has to be in the keyword list for the output formatter -"Rem" -"RemoveHandler" -"Resume" -"Return" -"SByte" -"Select" -"Set" -"Shadows" -"Shared" -"Short" -"Single" -"Skip" -"Static" -"Step" -"Stop" -"Strict" -"String" -"Structure" -"Sub" -"SyncLock" -"Take" -"Text" -"Then" -"Throw" -"To" -"True" -"Try" -"TryCast" -"TypeOf" -"UInteger" -"ULong" -"Unicode" -"Until" -"UShort" -"Using" -"Variant" -"Wend" -"When" -"Where" -"While" -"Widening" -"With" -"WithEvents" -"WriteOnly" -"Xor" - -#XML specific keywords -"GetXmlNamespace" - -#Sets -Null("Nothing") -BlockSucc("Case", "Catch", "Else", "ElseIf", "End", "Finally", "Loop", "Next") -GlobalLevel("Namespace", "Module", "Class", "Structure", "Imports", "Option") -TypeLevel("Sub", "Function", "Property") - -# List of keywords that are valid identifiers, must be the same as the "Identifier" production in VBNET.ATG -IdentifierTokens("Text", "Binary", "Compare", "Assembly", "Ansi", "Auto", "Preserve", "Unicode", "Until", "Off", "Out", "Key", "Explicit", "Infer", "From", "Join", "Equals", "Distinct", "Where", "Take", "Skip", "Order", "By", "Ascending", "Descending", "Group", "Into", "Aggregate") -ExpressionStart("Me", "MyBase", "MyClass", @BooleanExpressions, @OperatorsAtStart, "New", @Null, "AddressOf", "GetType", "TypeOf", "GetXmlNamespace", "Global", @TypeKW, @LambdaStart, @CastExpressions) -StatementStart(@Null, @ExpressionStart, "Dim", "Const", "Static", "For", "While", "Do", "Select") -SimpleTypeName(@TypeKW, @IdentifierTokens) -CastExpressions("DirectCast", "TryCast", "CType", "CBool", "CByte", "CChar", "CDate", "CDec", "CDbl", "CInt", "CLng", "CObj", "CSByte", "CShort", "CSng", "CStr", "CUInt", "CULng", "CUShort") -BooleanExpressions("True", "False") -LambdaStart("Sub", "Function") -OperatorsAtStart("Not", "From", "Aggregate") -TypeKW("Boolean", "Date", "Char", "String", "Decimal", "Byte", "Short", "Integer", "Long", "Single", "Double", "UInteger", "ULong", "UShort", "SByte") \ No newline at end of file diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Keywords.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Keywords.cs deleted file mode 100644 index 507ab10b4..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Keywords.cs +++ /dev/null @@ -1,215 +0,0 @@ -// this file was autogenerated by a tool. -using System; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public static class Keywords - { - static readonly string[] keywordList = { - "ADDHANDLER", - "ADDRESSOF", - "AGGREGATE", - "ALIAS", - "AND", - "ANDALSO", - "ANSI", - "AS", - "ASCENDING", - "ASSEMBLY", - "AUTO", - "BINARY", - "BOOLEAN", - "BYREF", - "BY", - "BYTE", - "BYVAL", - "CALL", - "CASE", - "CATCH", - "CBOOL", - "CBYTE", - "CCHAR", - "CDATE", - "CDBL", - "CDEC", - "CHAR", - "CINT", - "CLASS", - "CLNG", - "COBJ", - "COMPARE", - "CONST", - "CONTINUE", - "CSBYTE", - "CSHORT", - "CSNG", - "CSTR", - "CTYPE", - "CUINT", - "CULNG", - "CUSHORT", - "CUSTOM", - "DATE", - "DECIMAL", - "DECLARE", - "DEFAULT", - "DELEGATE", - "DESCENDING", - "DIM", - "DIRECTCAST", - "DISTINCT", - "DO", - "DOUBLE", - "EACH", - "ELSE", - "ELSEIF", - "END", - "ENDIF", - "ENUM", - "EQUALS", - "ERASE", - "ERROR", - "EVENT", - "EXIT", - "EXPLICIT", - "FALSE", - "FINALLY", - "FOR", - "FRIEND", - "FROM", - "FUNCTION", - "GET", - "GETTYPE", - "GLOBAL", - "GOSUB", - "GOTO", - "GROUP", - "HANDLES", - "IF", - "IMPLEMENTS", - "IMPORTS", - "IN", - "INFER", - "INHERITS", - "INTEGER", - "INTERFACE", - "INTO", - "IS", - "ISNOT", - "JOIN", - "KEY", - "LET", - "LIB", - "LIKE", - "LONG", - "LOOP", - "ME", - "MOD", - "MODULE", - "MUSTINHERIT", - "MUSTOVERRIDE", - "MYBASE", - "MYCLASS", - "NAMESPACE", - "NARROWING", - "NEW", - "NEXT", - "NOT", - "NOTHING", - "NOTINHERITABLE", - "NOTOVERRIDABLE", - "OBJECT", - "OF", - "OFF", - "ON", - "OPERATOR", - "OPTION", - "OPTIONAL", - "OR", - "ORDER", - "ORELSE", - "OUT", - "OVERLOADS", - "OVERRIDABLE", - "OVERRIDES", - "PARAMARRAY", - "PARTIAL", - "PRESERVE", - "PRIVATE", - "PROPERTY", - "PROTECTED", - "PUBLIC", - "RAISEEVENT", - "READONLY", - "REDIM", - "REM", - "REMOVEHANDLER", - "RESUME", - "RETURN", - "SBYTE", - "SELECT", - "SET", - "SHADOWS", - "SHARED", - "SHORT", - "SINGLE", - "SKIP", - "STATIC", - "STEP", - "STOP", - "STRICT", - "STRING", - "STRUCTURE", - "SUB", - "SYNCLOCK", - "TAKE", - "TEXT", - "THEN", - "THROW", - "TO", - "TRUE", - "TRY", - "TRYCAST", - "TYPEOF", - "UINTEGER", - "ULONG", - "UNICODE", - "UNTIL", - "USHORT", - "USING", - "VARIANT", - "WEND", - "WHEN", - "WHERE", - "WHILE", - "WIDENING", - "WITH", - "WITHEVENTS", - "WRITEONLY", - "XOR", - "GETXMLNAMESPACE" - }; - - static LookupTable keywords = new LookupTable(false); - - static Keywords() - { - for (int i = 0; i < keywordList.Length; ++i) { - keywords[keywordList[i]] = i + Tokens.AddHandler; - } - } - - public static int GetToken(string keyword) - { - return keywords[keyword]; - } - - public static bool IsNonIdentifierKeyword(string word) - { - int token = GetToken(word); - if (token < 0) - return false; - return !Tokens.IdentifierTokens[token]; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/LATextReader.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/LATextReader.cs deleted file mode 100644 index eff8b821e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/LATextReader.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.IO; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public class LATextReader : TextReader - { - List buffer; - TextReader reader; - - public LATextReader(TextReader reader) - { - this.buffer = new List(); - this.reader = reader; - } - - public override int Peek() - { - return Peek(0); - } - - public override int Read() - { - int c = Peek(); - buffer.RemoveAt(0); - return c; - } - - public int Peek(int step) - { - while (step >= buffer.Count) { - buffer.Add(reader.Read()); - } - - if (step < 0) - return -1; - - return buffer[step]; - } - - protected override void Dispose(bool disposing) - { - if (disposing) - reader.Dispose(); - base.Dispose(disposing); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/LookupTable.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/LookupTable.cs deleted file mode 100644 index eb2c94dfc..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/LookupTable.cs +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Globalization; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - /// - /// This class implements a keyword map. It implements a digital search trees (tries) to find - /// a word. - /// - internal class LookupTable - { - Node root = new Node(-1, null); - bool casesensitive; - int length; - - /// - /// The number of elements in the table - /// - public int Count { - get { - return length; - } - } - - /// - /// Inserts an int in the tree, under keyword - /// - public int this[string keyword] { - get { - Node next = root; - - if (!casesensitive) { - keyword = keyword.ToUpper(CultureInfo.InvariantCulture); - } - - for (int i = 0; i < keyword.Length; ++i) { - int index = ((int)keyword[i]) % 256; - next = next.leaf[index]; - - if (next == null) { - return -1; - } - - if (keyword == next.word) { - return next.val; - } - } - return -1; - } - set { - Node node = root; - Node next = root; - - if (!casesensitive) { - keyword = keyword.ToUpper(CultureInfo.InvariantCulture); - } - - ++length; - - // insert word into the tree - for (int i = 0; i < keyword.Length; ++i) { - int index = ((int)keyword[i]) % 256; // index of curchar - bool d = keyword[i] == '\\'; - - next = next.leaf[index]; // get node to this index - - if (next == null) { // no node created -> insert word here - node.leaf[index] = new Node(value, keyword); - break; - } - - if (next.word != null && next.word.Length != i) { // node there, take node content and insert them again - string tmpword = next.word; // this word will be inserted 1 level deeper (better, don't need too much - int tmpval = next.val; // string comparisons for finding.) - next.val = -1; - next.word = null; - this[tmpword] = tmpval; - } - - if (i == keyword.Length - 1) { // end of keyword reached, insert node there, if a node was here it was - next.word = keyword; // reinserted, if it has the same length (keyword EQUALS this word) it will be overwritten - next.val = value; - break; - } - - node = next; - } - } - } - - /// - /// Creates a new instance of - /// - public LookupTable(bool casesensitive) - { - this.casesensitive = casesensitive; - } - - class Node - { - public Node(int val, string word) - { - this.word = word; - this.val = val; - } - - public string word; - public int val; - - public Node[] leaf = new Node[256]; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Parser.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Parser.cs deleted file mode 100644 index 9fd64e952..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Parser.cs +++ /dev/null @@ -1,8631 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - - - -namespace ICSharpCode.NRefactory.VB.Parser { - - - -partial class ExpressionFinder { - const int startOfExpression = 55; - const int endOfStatementTerminatorAndBlock = 263; - static BitArray GetExpectedSet(int state) - { - switch (state) { - case 0: - case 1: - return set[0]; - case 2: - return set[1]; - case 3: - case 4: - return set[2]; - case 5: - return set[3]; - case 6: - case 88: - case 264: - case 530: - { - BitArray a = new BitArray(239); - return a; - } - case 7: - return set[4]; - case 8: - return set[5]; - case 9: - case 10: - case 20: - { - BitArray a = new BitArray(239); - a.Set(142, true); - return a; - } - case 11: - case 193: - case 199: - case 205: - case 244: - case 248: - case 295: - case 399: - case 405: - case 474: - case 520: - case 527: - case 535: - case 565: - case 601: - case 650: - case 664: - case 743: - return set[6]; - case 12: - case 13: - case 566: - case 567: - case 612: - case 622: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(37, true); - return a; - } - case 14: - case 21: - case 23: - case 24: - case 36: - case 256: - case 259: - case 260: - case 296: - case 300: - case 322: - case 337: - case 348: - case 351: - case 357: - case 362: - case 372: - case 373: - case 396: - case 423: - case 526: - case 532: - case 538: - case 542: - case 550: - case 558: - case 568: - case 577: - case 594: - case 599: - case 607: - case 613: - case 616: - case 623: - case 626: - case 645: - case 648: - case 672: - case 680: - case 716: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - return a; - } - case 15: - case 16: - return set[7]; - case 17: - case 18: - return set[8]; - case 19: - case 257: - case 271: - case 298: - case 352: - case 397: - case 454: - case 575: - case 595: - case 614: - case 618: - case 624: - case 646: - case 681: - { - BitArray a = new BitArray(239); - a.Set(113, true); - return a; - } - case 22: - case 543: - case 578: - return set[9]; - case 25: - { - BitArray a = new BitArray(239); - a.Set(1, true); - return a; - } - case 26: - case 27: - return set[10]; - case 28: - case 720: - return set[11]; - case 29: - return set[12]; - case 30: - return set[13]; - case 31: - case 32: - case 152: - case 217: - case 218: - case 265: - case 276: - case 277: - case 444: - case 445: - case 462: - case 463: - case 464: - case 465: - case 553: - case 554: - case 587: - case 588: - case 675: - case 676: - case 729: - case 730: - return set[14]; - case 33: - case 34: - case 521: - case 522: - case 528: - case 529: - case 555: - case 556: - case 669: - return set[15]; - case 35: - case 37: - case 157: - case 168: - case 171: - case 187: - case 203: - case 221: - case 307: - case 332: - case 422: - case 440: - case 477: - case 531: - case 549: - case 557: - case 629: - case 632: - case 654: - case 657: - case 659: - case 671: - case 684: - case 686: - case 709: - case 712: - case 715: - case 721: - case 724: - case 742: - return set[16]; - case 38: - case 41: - return set[17]; - case 39: - return set[18]; - case 40: - case 97: - case 101: - case 163: - case 388: - case 481: - return set[19]; - case 42: - case 177: - case 184: - case 189: - case 253: - case 424: - case 451: - case 473: - case 476: - case 589: - case 590: - case 642: - { - BitArray a = new BitArray(239); - a.Set(37, true); - return a; - } - case 43: - case 44: - case 165: - case 166: - return set[20]; - case 45: - case 46: - case 167: - case 188: - case 392: - case 427: - case 475: - case 478: - case 498: - case 561: - case 592: - case 644: - case 690: - case 719: - case 728: - { - BitArray a = new BitArray(239); - a.Set(38, true); - return a; - } - case 47: - case 48: - return set[21]; - case 49: - case 179: - case 186: - case 394: - { - BitArray a = new BitArray(239); - a.Set(22, true); - return a; - } - case 50: - case 51: - case 52: - case 54: - case 390: - case 391: - case 412: - case 413: - case 419: - case 420: - case 489: - case 490: - case 703: - case 704: - return set[22]; - case 53: - case 169: - case 170: - case 172: - case 181: - case 414: - case 421: - case 429: - case 438: - case 442: - case 485: - case 488: - case 492: - case 494: - case 495: - case 505: - case 512: - case 519: - case 705: - { - BitArray a = new BitArray(239); - a.Set(22, true); - a.Set(38, true); - return a; - } - case 55: - case 56: - case 70: - case 75: - case 76: - case 77: - case 83: - case 99: - case 155: - case 178: - case 180: - case 182: - case 185: - case 195: - case 197: - case 215: - case 239: - case 274: - case 284: - case 286: - case 287: - case 304: - case 321: - case 326: - case 335: - case 341: - case 343: - case 347: - case 350: - case 356: - case 367: - case 369: - case 370: - case 376: - case 393: - case 395: - case 415: - case 439: - case 467: - case 483: - case 484: - case 486: - case 487: - case 548: - case 628: - return set[23]; - case 57: - case 78: - case 158: - return set[24]; - case 58: - return set[25]; - case 59: - { - BitArray a = new BitArray(239); - a.Set(216, true); - return a; - } - case 60: - { - BitArray a = new BitArray(239); - a.Set(145, true); - return a; - } - case 61: - case 156: - { - BitArray a = new BitArray(239); - a.Set(144, true); - return a; - } - case 62: - { - BitArray a = new BitArray(239); - a.Set(236, true); - return a; - } - case 63: - { - BitArray a = new BitArray(239); - a.Set(177, true); - return a; - } - case 64: - { - BitArray a = new BitArray(239); - a.Set(175, true); - return a; - } - case 65: - { - BitArray a = new BitArray(239); - a.Set(61, true); - return a; - } - case 66: - { - BitArray a = new BitArray(239); - a.Set(60, true); - return a; - } - case 67: - { - BitArray a = new BitArray(239); - a.Set(150, true); - return a; - } - case 68: - { - BitArray a = new BitArray(239); - a.Set(42, true); - return a; - } - case 69: - { - BitArray a = new BitArray(239); - a.Set(43, true); - return a; - } - case 71: - case 443: - { - BitArray a = new BitArray(239); - a.Set(40, true); - return a; - } - case 72: - { - BitArray a = new BitArray(239); - a.Set(41, true); - return a; - } - case 73: - case 98: - case 222: - case 223: - case 282: - case 283: - case 334: - case 744: - { - BitArray a = new BitArray(239); - a.Set(20, true); - return a; - } - case 74: - { - BitArray a = new BitArray(239); - a.Set(154, true); - return a; - } - case 79: - case 91: - case 93: - case 148: - { - BitArray a = new BitArray(239); - a.Set(35, true); - return a; - } - case 80: - case 81: - return set[26]; - case 82: - { - BitArray a = new BitArray(239); - a.Set(36, true); - return a; - } - case 84: - case 100: - case 515: - { - BitArray a = new BitArray(239); - a.Set(22, true); - a.Set(36, true); - return a; - } - case 85: - case 121: - { - BitArray a = new BitArray(239); - a.Set(162, true); - return a; - } - case 86: - case 87: - return set[27]; - case 89: - case 92: - case 149: - case 150: - case 153: - return set[28]; - case 90: - case 102: - case 147: - { - BitArray a = new BitArray(239); - a.Set(233, true); - return a; - } - case 94: - { - BitArray a = new BitArray(239); - a.Set(26, true); - a.Set(36, true); - a.Set(147, true); - return a; - } - case 95: - { - BitArray a = new BitArray(239); - a.Set(26, true); - a.Set(147, true); - return a; - } - case 96: - case 685: - { - BitArray a = new BitArray(239); - a.Set(26, true); - return a; - } - case 103: - case 353: - { - BitArray a = new BitArray(239); - a.Set(231, true); - return a; - } - case 104: - { - BitArray a = new BitArray(239); - a.Set(230, true); - return a; - } - case 105: - { - BitArray a = new BitArray(239); - a.Set(224, true); - return a; - } - case 106: - { - BitArray a = new BitArray(239); - a.Set(223, true); - return a; - } - case 107: - case 299: - { - BitArray a = new BitArray(239); - a.Set(218, true); - return a; - } - case 108: - { - BitArray a = new BitArray(239); - a.Set(213, true); - return a; - } - case 109: - { - BitArray a = new BitArray(239); - a.Set(212, true); - return a; - } - case 110: - { - BitArray a = new BitArray(239); - a.Set(211, true); - return a; - } - case 111: - case 455: - { - BitArray a = new BitArray(239); - a.Set(210, true); - return a; - } - case 112: - { - BitArray a = new BitArray(239); - a.Set(209, true); - return a; - } - case 113: - { - BitArray a = new BitArray(239); - a.Set(206, true); - return a; - } - case 114: - { - BitArray a = new BitArray(239); - a.Set(203, true); - return a; - } - case 115: - case 359: - { - BitArray a = new BitArray(239); - a.Set(197, true); - return a; - } - case 116: - case 600: - case 619: - { - BitArray a = new BitArray(239); - a.Set(186, true); - return a; - } - case 117: - { - BitArray a = new BitArray(239); - a.Set(184, true); - return a; - } - case 118: - { - BitArray a = new BitArray(239); - a.Set(176, true); - return a; - } - case 119: - { - BitArray a = new BitArray(239); - a.Set(170, true); - return a; - } - case 120: - case 316: - case 323: - case 338: - { - BitArray a = new BitArray(239); - a.Set(163, true); - return a; - } - case 122: - { - BitArray a = new BitArray(239); - a.Set(147, true); - return a; - } - case 123: - case 226: - case 231: - case 233: - { - BitArray a = new BitArray(239); - a.Set(146, true); - return a; - } - case 124: - case 228: - case 232: - { - BitArray a = new BitArray(239); - a.Set(143, true); - return a; - } - case 125: - { - BitArray a = new BitArray(239); - a.Set(139, true); - return a; - } - case 126: - { - BitArray a = new BitArray(239); - a.Set(133, true); - return a; - } - case 127: - case 258: - { - BitArray a = new BitArray(239); - a.Set(127, true); - return a; - } - case 128: - case 151: - case 251: - { - BitArray a = new BitArray(239); - a.Set(126, true); - return a; - } - case 129: - { - BitArray a = new BitArray(239); - a.Set(124, true); - return a; - } - case 130: - { - BitArray a = new BitArray(239); - a.Set(121, true); - return a; - } - case 131: - case 196: - { - BitArray a = new BitArray(239); - a.Set(116, true); - return a; - } - case 132: - { - BitArray a = new BitArray(239); - a.Set(108, true); - return a; - } - case 133: - { - BitArray a = new BitArray(239); - a.Set(107, true); - return a; - } - case 134: - { - BitArray a = new BitArray(239); - a.Set(104, true); - return a; - } - case 135: - case 637: - { - BitArray a = new BitArray(239); - a.Set(98, true); - return a; - } - case 136: - { - BitArray a = new BitArray(239); - a.Set(87, true); - return a; - } - case 137: - { - BitArray a = new BitArray(239); - a.Set(84, true); - return a; - } - case 138: - case 208: - case 238: - { - BitArray a = new BitArray(239); - a.Set(70, true); - return a; - } - case 139: - { - BitArray a = new BitArray(239); - a.Set(67, true); - return a; - } - case 140: - { - BitArray a = new BitArray(239); - a.Set(66, true); - return a; - } - case 141: - { - BitArray a = new BitArray(239); - a.Set(65, true); - return a; - } - case 142: - { - BitArray a = new BitArray(239); - a.Set(64, true); - return a; - } - case 143: - { - BitArray a = new BitArray(239); - a.Set(62, true); - return a; - } - case 144: - case 250: - { - BitArray a = new BitArray(239); - a.Set(58, true); - return a; - } - case 145: - { - BitArray a = new BitArray(239); - a.Set(2, true); - return a; - } - case 146: - return set[29]; - case 154: - return set[30]; - case 159: - return set[31]; - case 160: - return set[32]; - case 161: - case 162: - case 479: - case 480: - return set[33]; - case 164: - return set[34]; - case 173: - case 174: - case 319: - case 328: - return set[35]; - case 175: - case 457: - return set[36]; - case 176: - case 375: - { - BitArray a = new BitArray(239); - a.Set(135, true); - return a; - } - case 183: - return set[37]; - case 190: - { - BitArray a = new BitArray(239); - a.Set(58, true); - a.Set(126, true); - return a; - } - case 191: - case 192: - return set[38]; - case 194: - { - BitArray a = new BitArray(239); - a.Set(171, true); - return a; - } - case 198: - case 212: - case 230: - case 235: - case 241: - case 243: - case 247: - case 249: - return set[39]; - case 200: - case 201: - { - BitArray a = new BitArray(239); - a.Set(63, true); - a.Set(138, true); - return a; - } - case 202: - case 204: - case 320: - { - BitArray a = new BitArray(239); - a.Set(138, true); - return a; - } - case 206: - case 207: - case 209: - case 211: - case 213: - case 214: - case 224: - case 229: - case 234: - case 242: - case 246: - case 269: - case 273: - return set[40]; - case 210: - { - BitArray a = new BitArray(239); - a.Set(22, true); - a.Set(143, true); - return a; - } - case 216: - return set[41]; - case 219: - case 278: - return set[42]; - case 220: - case 279: - return set[43]; - case 225: - { - BitArray a = new BitArray(239); - a.Set(22, true); - a.Set(70, true); - return a; - } - case 227: - { - BitArray a = new BitArray(239); - a.Set(133, true); - a.Set(143, true); - a.Set(146, true); - return a; - } - case 236: - case 237: - return set[44]; - case 240: - { - BitArray a = new BitArray(239); - a.Set(64, true); - a.Set(104, true); - return a; - } - case 245: - return set[45]; - case 252: - case 552: - case 663: - case 674: - case 682: - { - BitArray a = new BitArray(239); - a.Set(127, true); - a.Set(210, true); - return a; - } - case 254: - case 255: - return set[46]; - case 261: - case 262: - return set[47]; - case 263: - return set[48]; - case 266: - return set[49]; - case 267: - case 268: - case 381: - return set[50]; - case 270: - case 275: - case 365: - case 655: - case 656: - case 658: - case 693: - case 710: - case 711: - case 713: - case 722: - case 723: - case 725: - case 737: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(22, true); - return a; - } - case 272: - { - BitArray a = new BitArray(239); - a.Set(226, true); - return a; - } - case 280: - case 281: - return set[51]; - case 285: - case 327: - case 342: - case 404: - return set[52]; - case 288: - case 289: - case 309: - case 310: - case 324: - case 325: - case 339: - case 340: - return set[53]; - case 290: - case 382: - case 385: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(111, true); - return a; - } - case 291: - { - BitArray a = new BitArray(239); - a.Set(108, true); - a.Set(124, true); - a.Set(231, true); - return a; - } - case 292: - return set[54]; - case 293: - case 312: - return set[55]; - case 294: - { - BitArray a = new BitArray(239); - a.Set(5, true); - return a; - } - case 297: - { - BitArray a = new BitArray(239); - a.Set(75, true); - a.Set(113, true); - a.Set(123, true); - return a; - } - case 301: - case 302: - return set[56]; - case 303: - case 308: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(229, true); - return a; - } - case 305: - case 306: - return set[57]; - case 311: - return set[58]; - case 313: - { - BitArray a = new BitArray(239); - a.Set(118, true); - return a; - } - case 314: - case 315: - return set[59]; - case 317: - case 318: - return set[60]; - case 329: - case 330: - return set[61]; - case 331: - return set[62]; - case 333: - { - BitArray a = new BitArray(239); - a.Set(20, true); - a.Set(138, true); - return a; - } - case 336: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(205, true); - return a; - } - case 344: - return set[63]; - case 345: - case 349: - { - BitArray a = new BitArray(239); - a.Set(152, true); - return a; - } - case 346: - return set[64]; - case 354: - case 355: - return set[65]; - case 358: - { - BitArray a = new BitArray(239); - a.Set(74, true); - a.Set(113, true); - return a; - } - case 360: - case 361: - return set[66]; - case 363: - case 364: - return set[67]; - case 366: - case 368: - return set[68]; - case 371: - case 377: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(214, true); - return a; - } - case 374: - { - BitArray a = new BitArray(239); - a.Set(111, true); - a.Set(112, true); - a.Set(113, true); - return a; - } - case 378: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(135, true); - return a; - } - case 379: - case 380: - case 452: - case 453: - return set[69]; - case 383: - case 384: - case 386: - case 387: - return set[70]; - case 389: - return set[71]; - case 398: - { - BitArray a = new BitArray(239); - a.Set(211, true); - a.Set(233, true); - return a; - } - case 400: - case 401: - case 406: - case 407: - return set[72]; - case 402: - case 408: - return set[73]; - case 403: - case 411: - case 418: - return set[74]; - case 409: - case 410: - case 416: - case 417: - case 700: - case 701: - return set[75]; - case 425: - case 426: - return set[76]; - case 428: - case 430: - case 431: - case 591: - case 643: - return set[77]; - case 432: - case 433: - return set[78]; - case 434: - case 435: - return set[79]; - case 436: - return set[80]; - case 437: - case 441: - { - BitArray a = new BitArray(239); - a.Set(20, true); - a.Set(22, true); - a.Set(38, true); - return a; - } - case 446: - case 450: - return set[81]; - case 447: - case 448: - return set[82]; - case 449: - { - BitArray a = new BitArray(239); - a.Set(21, true); - return a; - } - case 456: - return set[83]; - case 458: - case 471: - return set[84]; - case 459: - case 472: - return set[85]; - case 460: - case 461: - case 736: - { - BitArray a = new BitArray(239); - a.Set(10, true); - return a; - } - case 466: - { - BitArray a = new BitArray(239); - a.Set(12, true); - return a; - } - case 468: - { - BitArray a = new BitArray(239); - a.Set(13, true); - return a; - } - case 469: - return set[86]; - case 470: - return set[87]; - case 482: - return set[88]; - case 491: - case 493: - return set[89]; - case 496: - case 497: - case 559: - case 560: - case 688: - case 689: - return set[90]; - case 499: - case 500: - case 501: - case 506: - case 507: - case 562: - case 691: - case 718: - case 727: - return set[91]; - case 502: - case 508: - case 517: - return set[92]; - case 503: - case 504: - case 509: - case 510: - { - BitArray a = new BitArray(239); - a.Set(22, true); - a.Set(38, true); - a.Set(63, true); - return a; - } - case 511: - case 513: - case 518: - return set[93]; - case 514: - case 516: - return set[94]; - case 523: - case 536: - case 537: - case 593: - case 670: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(63, true); - return a; - } - case 524: - case 525: - case 597: - case 598: - return set[95]; - case 533: - case 534: - case 541: - { - BitArray a = new BitArray(239); - a.Set(115, true); - return a; - } - case 539: - case 540: - return set[96]; - case 544: - case 545: - return set[97]; - case 546: - case 547: - case 606: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(20, true); - a.Set(21, true); - return a; - } - case 551: - { - BitArray a = new BitArray(239); - a.Set(103, true); - return a; - } - case 563: - case 564: - case 576: - { - BitArray a = new BitArray(239); - a.Set(84, true); - a.Set(155, true); - a.Set(209, true); - return a; - } - case 569: - case 570: - return set[98]; - case 571: - case 572: - return set[99]; - case 573: - case 574: - case 585: - return set[100]; - case 579: - case 580: - return set[101]; - case 581: - case 582: - case 707: - return set[102]; - case 583: - return set[103]; - case 584: - return set[104]; - case 586: - case 596: - { - BitArray a = new BitArray(239); - a.Set(172, true); - return a; - } - case 602: - case 603: - return set[105]; - case 604: - return set[106]; - case 605: - case 636: - return set[107]; - case 608: - case 609: - case 610: - case 627: - return set[108]; - case 611: - case 615: - case 625: - { - BitArray a = new BitArray(239); - a.Set(128, true); - a.Set(198, true); - return a; - } - case 617: - return set[109]; - case 620: - return set[110]; - case 621: - return set[111]; - case 630: - case 631: - case 633: - case 699: - case 702: - return set[112]; - case 634: - case 635: - return set[113]; - case 638: - case 640: - case 649: - { - BitArray a = new BitArray(239); - a.Set(119, true); - return a; - } - case 639: - return set[114]; - case 641: - return set[115]; - case 647: - { - BitArray a = new BitArray(239); - a.Set(56, true); - a.Set(189, true); - a.Set(193, true); - return a; - } - case 651: - case 652: - return set[116]; - case 653: - case 660: - { - BitArray a = new BitArray(239); - a.Set(1, true); - a.Set(21, true); - a.Set(136, true); - return a; - } - case 661: - { - BitArray a = new BitArray(239); - a.Set(101, true); - return a; - } - case 662: - return set[117]; - case 665: - case 666: - { - BitArray a = new BitArray(239); - a.Set(149, true); - return a; - } - case 667: - case 673: - case 745: - { - BitArray a = new BitArray(239); - a.Set(3, true); - return a; - } - case 668: - return set[118]; - case 677: - case 678: - return set[119]; - case 679: - case 687: - return set[120]; - case 683: - return set[121]; - case 692: - case 694: - return set[122]; - case 695: - case 706: - return set[123]; - case 696: - case 697: - return set[124]; - case 698: - return set[125]; - case 708: - { - BitArray a = new BitArray(239); - a.Set(136, true); - return a; - } - case 714: - { - BitArray a = new BitArray(239); - a.Set(140, true); - return a; - } - case 717: - case 726: - { - BitArray a = new BitArray(239); - a.Set(169, true); - return a; - } - case 731: - return set[126]; - case 732: - { - BitArray a = new BitArray(239); - a.Set(160, true); - return a; - } - case 733: - { - BitArray a = new BitArray(239); - a.Set(137, true); - return a; - } - case 734: - case 735: - case 738: - case 739: - return set[127]; - case 740: - case 747: - return set[128]; - case 741: - return set[129]; - case 746: - { - BitArray a = new BitArray(239); - a.Set(11, true); - return a; - } - case 748: - { - BitArray a = new BitArray(239); - a.Set(173, true); - return a; - } - case 749: - return set[130]; - case 750: - { - BitArray a = new BitArray(239); - a.Set(67, true); - a.Set(213, true); - return a; - } - case 751: - return set[131]; - default: throw new InvalidOperationException(); - } - } - - const bool T = true; - const bool x = false; - - int currentState = 0; - - readonly Stack stateStack = new Stack(); - bool wasQualifierTokenAtStart = false; - bool nextTokenIsPotentialStartOfExpression = false; - bool readXmlIdentifier = false; - bool identifierExpected = false; - bool nextTokenIsStartOfImportsOrAccessExpression = false; - bool isMissingModifier = false; - bool isAlreadyInExpr = false; - bool wasNormalAttribute = false; - int activeArgument = 0; - List errors = new List(); - - public ExpressionFinder() - { - stateStack.Push(-1); // required so that we don't crash when leaving the root production - } - - void Expect(int expectedKind, Token la) - { - if (la.kind != expectedKind) { - Error(la); - output.AppendLine("expected: " + expectedKind); - //Console.WriteLine("expected: " + expectedKind); - } - } - - void Error(Token la) - { - output.AppendLine("not expected: " + la); - //Console.WriteLine("not expected: " + la); - errors.Add(la); - } - - Token t; - - public void InformToken(Token la) - { - switchlbl: switch (currentState) { - case 0: { - PushContext(Context.Global, la, t); - goto case 1; - } - case 1: { - if (la == null) { currentState = 1; break; } - if (la.kind == 173) { - stateStack.Push(1); - goto case 748; - } else { - goto case 2; - } - } - case 2: { - if (la == null) { currentState = 2; break; } - if (la.kind == 137) { - stateStack.Push(2); - goto case 733; - } else { - goto case 3; - } - } - case 3: { - if (la == null) { currentState = 3; break; } - if (la.kind == 40) { - stateStack.Push(3); - goto case 443; - } else { - goto case 4; - } - } - case 4: { - if (la == null) { currentState = 4; break; } - if (set[3].Get(la.kind)) { - stateStack.Push(4); - goto case 5; - } else { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 5: { - if (la == null) { currentState = 5; break; } - if (la.kind == 160) { - currentState = 729; - break; - } else { - if (set[4].Get(la.kind)) { - goto case 7; - } else { - goto case 6; - } - } - } - case 6: { - Error(la); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 7: { - if (la == null) { currentState = 7; break; } - if (la.kind == 40) { - stateStack.Push(7); - goto case 443; - } else { - goto case 8; - } - } - case 8: { - if (la == null) { currentState = 8; break; } - if (set[132].Get(la.kind)) { - currentState = 8; - break; - } else { - if (la.kind == 84 || la.kind == 155 || la.kind == 209) { - goto case 563; - } else { - if (la.kind == 103) { - currentState = 552; - break; - } else { - if (la.kind == 115) { - goto case 533; - } else { - if (la.kind == 142) { - goto case 9; - } else { - goto case 6; - } - } - } - } - } - } - case 9: { - PushContext(Context.TypeDeclaration, la, t); - goto case 10; - } - case 10: { - if (la == null) { currentState = 10; break; } - Expect(142, la); // "Interface" - currentState = 11; - break; - } - case 11: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(12); - goto case 205; - } - case 12: { - PopContext(); - goto case 13; - } - case 13: { - if (la == null) { currentState = 13; break; } - if (la.kind == 37) { - currentState = 726; - break; - } else { - goto case 14; - } - } - case 14: { - stateStack.Push(15); - goto case 23; - } - case 15: { - isMissingModifier = true; - goto case 16; - } - case 16: { - if (la == null) { currentState = 16; break; } - if (la.kind == 140) { - currentState = 721; - break; - } else { - goto case 17; - } - } - case 17: { - isMissingModifier = true; - goto case 18; - } - case 18: { - if (la == null) { currentState = 18; break; } - if (set[10].Get(la.kind)) { - goto case 26; - } else { - isMissingModifier = false; - goto case 19; - } - } - case 19: { - if (la == null) { currentState = 19; break; } - Expect(113, la); // "End" - currentState = 20; - break; - } - case 20: { - if (la == null) { currentState = 20; break; } - Expect(142, la); // "Interface" - currentState = 21; - break; - } - case 21: { - stateStack.Push(22); - goto case 23; - } - case 22: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 23: { - if (la != null) CurrentBlock.lastExpressionStart = la.Location; - goto case 24; - } - case 24: { - if (la == null) { currentState = 24; break; } - if (la.kind == 1) { - goto case 25; - } else { - if (la.kind == 21) { - currentState = stateStack.Pop(); - break; - } else { - goto case 6; - } - } - } - case 25: { - if (la == null) { currentState = 25; break; } - currentState = stateStack.Pop(); - break; - } - case 26: { - isMissingModifier = true; - goto case 27; - } - case 27: { - if (la == null) { currentState = 27; break; } - if (la.kind == 40) { - stateStack.Push(26); - goto case 443; - } else { - isMissingModifier = true; - goto case 28; - } - } - case 28: { - if (la == null) { currentState = 28; break; } - if (set[133].Get(la.kind)) { - currentState = 720; - break; - } else { - isMissingModifier = false; - goto case 29; - } - } - case 29: { - if (la == null) { currentState = 29; break; } - if (la.kind == 84 || la.kind == 155 || la.kind == 209) { - stateStack.Push(17); - goto case 563; - } else { - if (la.kind == 103) { - stateStack.Push(17); - goto case 551; - } else { - if (la.kind == 115) { - stateStack.Push(17); - goto case 533; - } else { - if (la.kind == 142) { - stateStack.Push(17); - goto case 9; - } else { - if (set[13].Get(la.kind)) { - stateStack.Push(17); - goto case 30; - } else { - Error(la); - goto case 17; - } - } - } - } - } - } - case 30: { - if (la == null) { currentState = 30; break; } - if (la.kind == 119) { - currentState = 527; - break; - } else { - if (la.kind == 186) { - currentState = 520; - break; - } else { - if (la.kind == 127 || la.kind == 210) { - currentState = 31; - break; - } else { - goto case 6; - } - } - } - } - case 31: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - goto case 32; - } - case 32: { - if (la == null) { currentState = 32; break; } - currentState = 33; - break; - } - case 33: { - PopContext(); - goto case 34; - } - case 34: { - if (la == null) { currentState = 34; break; } - if (la.kind == 37) { - currentState = 496; - break; - } else { - if (la.kind == 63) { - currentState = 35; - break; - } else { - goto case 23; - } - } - } - case 35: { - PushContext(Context.Type, la, t); - stateStack.Push(36); - goto case 37; - } - case 36: { - PopContext(); - goto case 23; - } - case 37: { - if (la == null) { currentState = 37; break; } - if (la.kind == 130) { - currentState = 38; - break; - } else { - if (set[6].Get(la.kind)) { - currentState = 38; - break; - } else { - if (set[134].Get(la.kind)) { - currentState = 38; - break; - } else { - if (la.kind == 33) { - currentState = 38; - break; - } else { - Error(la); - goto case 38; - } - } - } - } - } - case 38: { - if (la == null) { currentState = 38; break; } - if (la.kind == 37) { - stateStack.Push(38); - goto case 42; - } else { - goto case 39; - } - } - case 39: { - if (la == null) { currentState = 39; break; } - if (la.kind == 26) { - currentState = 40; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 40: { - stateStack.Push(41); - goto case 101; - } - case 41: { - if (la == null) { currentState = 41; break; } - if (la.kind == 37) { - stateStack.Push(41); - goto case 42; - } else { - goto case 39; - } - } - case 42: { - if (la == null) { currentState = 42; break; } - Expect(37, la); // "(" - currentState = 43; - break; - } - case 43: { - PushContext(Context.Expression, la, t); - nextTokenIsPotentialStartOfExpression = true; - goto case 44; - } - case 44: { - if (la == null) { currentState = 44; break; } - if (la.kind == 169) { - currentState = 491; - break; - } else { - if (set[22].Get(la.kind)) { - if (set[21].Get(la.kind)) { - stateStack.Push(45); - goto case 47; - } else { - goto case 45; - } - } else { - Error(la); - goto case 45; - } - } - } - case 45: { - PopContext(); - goto case 46; - } - case 46: { - if (la == null) { currentState = 46; break; } - Expect(38, la); // ")" - currentState = stateStack.Pop(); - break; - } - case 47: { - nextTokenIsPotentialStartOfExpression = true; - goto case 48; - } - case 48: { - if (la == null) { currentState = 48; break; } - if (set[23].Get(la.kind)) { - activeArgument = 0; - goto case 487; - } else { - if (la.kind == 22) { - activeArgument = 0; - goto case 49; - } else { - goto case 6; - } - } - } - case 49: { - if (la == null) { currentState = 49; break; } - Expect(22, la); // "," - currentState = 50; - break; - } - case 50: { - activeArgument++; - goto case 51; - } - case 51: { - nextTokenIsPotentialStartOfExpression = true; - goto case 52; - } - case 52: { - if (la == null) { currentState = 52; break; } - if (set[23].Get(la.kind)) { - stateStack.Push(53); - goto case 55; - } else { - goto case 53; - } - } - case 53: { - if (la == null) { currentState = 53; break; } - if (la.kind == 22) { - currentState = 54; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 54: { - activeArgument++; - goto case 51; - } - case 55: { - PushContext(Context.Expression, la, t); - goto case 56; - } - case 56: { - stateStack.Push(57); - goto case 75; - } - case 57: { - if (la == null) { currentState = 57; break; } - if (set[25].Get(la.kind)) { - stateStack.Push(56); - goto case 58; - } else { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 58: { - if (la == null) { currentState = 58; break; } - if (la.kind == 31) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 30) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 34) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 25) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 24) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 32) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 154) { - goto case 74; - } else { - if (la.kind == 20) { - goto case 73; - } else { - if (la.kind == 41) { - goto case 72; - } else { - if (la.kind == 40) { - goto case 71; - } else { - if (la.kind == 39) { - currentState = 70; - break; - } else { - if (la.kind == 43) { - goto case 69; - } else { - if (la.kind == 42) { - goto case 68; - } else { - if (la.kind == 150) { - goto case 67; - } else { - if (la.kind == 23) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 60) { - goto case 66; - } else { - if (la.kind == 61) { - goto case 65; - } else { - if (la.kind == 175) { - goto case 64; - } else { - if (la.kind == 177) { - goto case 63; - } else { - if (la.kind == 236) { - goto case 62; - } else { - if (la.kind == 44) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 45) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 144) { - goto case 61; - } else { - if (la.kind == 145) { - goto case 60; - } else { - if (la.kind == 47) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 49) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 50) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 51) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 46) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 48) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 54) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 52) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 53) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 216) { - goto case 59; - } else { - if (la.kind == 55) { - currentState = stateStack.Pop(); - break; - } else { - goto case 6; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - case 59: { - if (la == null) { currentState = 59; break; } - currentState = stateStack.Pop(); - break; - } - case 60: { - if (la == null) { currentState = 60; break; } - currentState = stateStack.Pop(); - break; - } - case 61: { - if (la == null) { currentState = 61; break; } - currentState = stateStack.Pop(); - break; - } - case 62: { - if (la == null) { currentState = 62; break; } - currentState = stateStack.Pop(); - break; - } - case 63: { - if (la == null) { currentState = 63; break; } - currentState = stateStack.Pop(); - break; - } - case 64: { - if (la == null) { currentState = 64; break; } - currentState = stateStack.Pop(); - break; - } - case 65: { - if (la == null) { currentState = 65; break; } - currentState = stateStack.Pop(); - break; - } - case 66: { - if (la == null) { currentState = 66; break; } - currentState = stateStack.Pop(); - break; - } - case 67: { - if (la == null) { currentState = 67; break; } - currentState = stateStack.Pop(); - break; - } - case 68: { - if (la == null) { currentState = 68; break; } - currentState = stateStack.Pop(); - break; - } - case 69: { - if (la == null) { currentState = 69; break; } - currentState = stateStack.Pop(); - break; - } - case 70: { - wasNormalAttribute = false; - currentState = stateStack.Pop(); - goto switchlbl; - } - case 71: { - if (la == null) { currentState = 71; break; } - currentState = stateStack.Pop(); - break; - } - case 72: { - if (la == null) { currentState = 72; break; } - currentState = stateStack.Pop(); - break; - } - case 73: { - if (la == null) { currentState = 73; break; } - currentState = stateStack.Pop(); - break; - } - case 74: { - if (la == null) { currentState = 74; break; } - currentState = stateStack.Pop(); - break; - } - case 75: { - PushContext(Context.Expression, la, t); - goto case 76; - } - case 76: { - nextTokenIsPotentialStartOfExpression = true; - goto case 77; - } - case 77: { - if (la == null) { currentState = 77; break; } - if (set[135].Get(la.kind)) { - currentState = 76; - break; - } else { - if (set[35].Get(la.kind)) { - stateStack.Push(159); - goto case 173; - } else { - if (la.kind == 220) { - currentState = 155; - break; - } else { - if (la.kind == 162) { - stateStack.Push(78); - goto case 85; - } else { - if (la.kind == 35) { - stateStack.Push(78); - goto case 79; - } else { - Error(la); - goto case 78; - } - } - } - } - } - } - case 78: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 79: { - if (la == null) { currentState = 79; break; } - Expect(35, la); // "{" - currentState = 80; - break; - } - case 80: { - nextTokenIsPotentialStartOfExpression = true; - goto case 81; - } - case 81: { - if (la == null) { currentState = 81; break; } - if (set[23].Get(la.kind)) { - goto case 83; - } else { - goto case 82; - } - } - case 82: { - if (la == null) { currentState = 82; break; } - Expect(36, la); // "}" - currentState = stateStack.Pop(); - break; - } - case 83: { - stateStack.Push(84); - goto case 55; - } - case 84: { - if (la == null) { currentState = 84; break; } - if (la.kind == 22) { - currentState = 83; - break; - } else { - goto case 82; - } - } - case 85: { - if (la == null) { currentState = 85; break; } - Expect(162, la); // "New" - currentState = 86; - break; - } - case 86: { - PushContext(Context.ObjectCreation, la, t); - goto case 87; - } - case 87: { - if (la == null) { currentState = 87; break; } - if (set[16].Get(la.kind)) { - stateStack.Push(146); - goto case 37; - } else { - if (la.kind == 233) { - PushContext(Context.ObjectInitializer, la, t); - goto case 90; - } else { - goto case 88; - } - } - } - case 88: { - Error(la); - goto case 89; - } - case 89: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 90: { - if (la == null) { currentState = 90; break; } - Expect(233, la); // "With" - currentState = 91; - break; - } - case 91: { - stateStack.Push(92); - goto case 93; - } - case 92: { - PopContext(); - goto case 89; - } - case 93: { - if (la == null) { currentState = 93; break; } - Expect(35, la); // "{" - currentState = 94; - break; - } - case 94: { - if (la == null) { currentState = 94; break; } - if (la.kind == 26 || la.kind == 147) { - goto case 95; - } else { - goto case 82; - } - } - case 95: { - if (la == null) { currentState = 95; break; } - if (la.kind == 147) { - currentState = 96; - break; - } else { - goto case 96; - } - } - case 96: { - if (la == null) { currentState = 96; break; } - Expect(26, la); // "." - currentState = 97; - break; - } - case 97: { - stateStack.Push(98); - goto case 101; - } - case 98: { - if (la == null) { currentState = 98; break; } - Expect(20, la); // "=" - currentState = 99; - break; - } - case 99: { - stateStack.Push(100); - goto case 55; - } - case 100: { - if (la == null) { currentState = 100; break; } - if (la.kind == 22) { - currentState = 95; - break; - } else { - goto case 82; - } - } - case 101: { - if (la == null) { currentState = 101; break; } - if (la.kind == 2) { - goto case 145; - } else { - if (la.kind == 56) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 57) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 58) { - goto case 144; - } else { - if (la.kind == 59) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 60) { - goto case 66; - } else { - if (la.kind == 61) { - goto case 65; - } else { - if (la.kind == 62) { - goto case 143; - } else { - if (la.kind == 63) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 64) { - goto case 142; - } else { - if (la.kind == 65) { - goto case 141; - } else { - if (la.kind == 66) { - goto case 140; - } else { - if (la.kind == 67) { - goto case 139; - } else { - if (la.kind == 68) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 69) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 70) { - goto case 138; - } else { - if (la.kind == 71) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 72) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 73) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 74) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 75) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 76) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 77) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 78) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 79) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 80) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 81) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 82) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 83) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 84) { - goto case 137; - } else { - if (la.kind == 85) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 86) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 87) { - goto case 136; - } else { - if (la.kind == 88) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 89) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 90) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 91) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 92) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 93) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 94) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 95) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 96) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 97) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 98) { - goto case 135; - } else { - if (la.kind == 99) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 100) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 101) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 102) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 103) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 104) { - goto case 134; - } else { - if (la.kind == 105) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 106) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 107) { - goto case 133; - } else { - if (la.kind == 108) { - goto case 132; - } else { - if (la.kind == 109) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 110) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 111) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 112) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 113) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 114) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 115) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 116) { - goto case 131; - } else { - if (la.kind == 117) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 118) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 119) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 120) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 121) { - goto case 130; - } else { - if (la.kind == 122) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 123) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 124) { - goto case 129; - } else { - if (la.kind == 125) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 126) { - goto case 128; - } else { - if (la.kind == 127) { - goto case 127; - } else { - if (la.kind == 128) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 129) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 130) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 131) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 132) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 133) { - goto case 126; - } else { - if (la.kind == 134) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 135) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 136) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 137) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 138) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 139) { - goto case 125; - } else { - if (la.kind == 140) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 141) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 142) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 143) { - goto case 124; - } else { - if (la.kind == 144) { - goto case 61; - } else { - if (la.kind == 145) { - goto case 60; - } else { - if (la.kind == 146) { - goto case 123; - } else { - if (la.kind == 147) { - goto case 122; - } else { - if (la.kind == 148) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 149) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 150) { - goto case 67; - } else { - if (la.kind == 151) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 152) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 153) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 154) { - goto case 74; - } else { - if (la.kind == 155) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 156) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 157) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 158) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 159) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 160) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 161) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 162) { - goto case 121; - } else { - if (la.kind == 163) { - goto case 120; - } else { - if (la.kind == 164) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 165) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 166) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 167) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 168) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 169) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 170) { - goto case 119; - } else { - if (la.kind == 171) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 172) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 173) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 174) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 175) { - goto case 64; - } else { - if (la.kind == 176) { - goto case 118; - } else { - if (la.kind == 177) { - goto case 63; - } else { - if (la.kind == 178) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 179) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 180) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 181) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 182) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 183) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 184) { - goto case 117; - } else { - if (la.kind == 185) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 186) { - goto case 116; - } else { - if (la.kind == 187) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 188) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 189) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 190) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 191) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 192) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 193) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 194) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 195) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 196) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 197) { - goto case 115; - } else { - if (la.kind == 198) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 199) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 200) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 201) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 202) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 203) { - goto case 114; - } else { - if (la.kind == 204) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 205) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 206) { - goto case 113; - } else { - if (la.kind == 207) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 208) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 209) { - goto case 112; - } else { - if (la.kind == 210) { - goto case 111; - } else { - if (la.kind == 211) { - goto case 110; - } else { - if (la.kind == 212) { - goto case 109; - } else { - if (la.kind == 213) { - goto case 108; - } else { - if (la.kind == 214) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 215) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 216) { - goto case 59; - } else { - if (la.kind == 217) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 218) { - goto case 107; - } else { - if (la.kind == 219) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 220) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 221) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 222) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 223) { - goto case 106; - } else { - if (la.kind == 224) { - goto case 105; - } else { - if (la.kind == 225) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 226) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 227) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 228) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 229) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 230) { - goto case 104; - } else { - if (la.kind == 231) { - goto case 103; - } else { - if (la.kind == 232) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 233) { - goto case 102; - } else { - if (la.kind == 234) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 235) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 236) { - goto case 62; - } else { - if (la.kind == 237) { - currentState = stateStack.Pop(); - break; - } else { - goto case 6; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - case 102: { - if (la == null) { currentState = 102; break; } - currentState = stateStack.Pop(); - break; - } - case 103: { - if (la == null) { currentState = 103; break; } - currentState = stateStack.Pop(); - break; - } - case 104: { - if (la == null) { currentState = 104; break; } - currentState = stateStack.Pop(); - break; - } - case 105: { - if (la == null) { currentState = 105; break; } - currentState = stateStack.Pop(); - break; - } - case 106: { - if (la == null) { currentState = 106; break; } - currentState = stateStack.Pop(); - break; - } - case 107: { - if (la == null) { currentState = 107; break; } - currentState = stateStack.Pop(); - break; - } - case 108: { - if (la == null) { currentState = 108; break; } - currentState = stateStack.Pop(); - break; - } - case 109: { - if (la == null) { currentState = 109; break; } - currentState = stateStack.Pop(); - break; - } - case 110: { - if (la == null) { currentState = 110; break; } - currentState = stateStack.Pop(); - break; - } - case 111: { - if (la == null) { currentState = 111; break; } - currentState = stateStack.Pop(); - break; - } - case 112: { - if (la == null) { currentState = 112; break; } - currentState = stateStack.Pop(); - break; - } - case 113: { - if (la == null) { currentState = 113; break; } - currentState = stateStack.Pop(); - break; - } - case 114: { - if (la == null) { currentState = 114; break; } - currentState = stateStack.Pop(); - break; - } - case 115: { - if (la == null) { currentState = 115; break; } - currentState = stateStack.Pop(); - break; - } - case 116: { - if (la == null) { currentState = 116; break; } - currentState = stateStack.Pop(); - break; - } - case 117: { - if (la == null) { currentState = 117; break; } - currentState = stateStack.Pop(); - break; - } - case 118: { - if (la == null) { currentState = 118; break; } - currentState = stateStack.Pop(); - break; - } - case 119: { - if (la == null) { currentState = 119; break; } - currentState = stateStack.Pop(); - break; - } - case 120: { - if (la == null) { currentState = 120; break; } - currentState = stateStack.Pop(); - break; - } - case 121: { - if (la == null) { currentState = 121; break; } - currentState = stateStack.Pop(); - break; - } - case 122: { - if (la == null) { currentState = 122; break; } - currentState = stateStack.Pop(); - break; - } - case 123: { - if (la == null) { currentState = 123; break; } - currentState = stateStack.Pop(); - break; - } - case 124: { - if (la == null) { currentState = 124; break; } - currentState = stateStack.Pop(); - break; - } - case 125: { - if (la == null) { currentState = 125; break; } - currentState = stateStack.Pop(); - break; - } - case 126: { - if (la == null) { currentState = 126; break; } - currentState = stateStack.Pop(); - break; - } - case 127: { - if (la == null) { currentState = 127; break; } - currentState = stateStack.Pop(); - break; - } - case 128: { - if (la == null) { currentState = 128; break; } - currentState = stateStack.Pop(); - break; - } - case 129: { - if (la == null) { currentState = 129; break; } - currentState = stateStack.Pop(); - break; - } - case 130: { - if (la == null) { currentState = 130; break; } - currentState = stateStack.Pop(); - break; - } - case 131: { - if (la == null) { currentState = 131; break; } - currentState = stateStack.Pop(); - break; - } - case 132: { - if (la == null) { currentState = 132; break; } - currentState = stateStack.Pop(); - break; - } - case 133: { - if (la == null) { currentState = 133; break; } - currentState = stateStack.Pop(); - break; - } - case 134: { - if (la == null) { currentState = 134; break; } - currentState = stateStack.Pop(); - break; - } - case 135: { - if (la == null) { currentState = 135; break; } - currentState = stateStack.Pop(); - break; - } - case 136: { - if (la == null) { currentState = 136; break; } - currentState = stateStack.Pop(); - break; - } - case 137: { - if (la == null) { currentState = 137; break; } - currentState = stateStack.Pop(); - break; - } - case 138: { - if (la == null) { currentState = 138; break; } - currentState = stateStack.Pop(); - break; - } - case 139: { - if (la == null) { currentState = 139; break; } - currentState = stateStack.Pop(); - break; - } - case 140: { - if (la == null) { currentState = 140; break; } - currentState = stateStack.Pop(); - break; - } - case 141: { - if (la == null) { currentState = 141; break; } - currentState = stateStack.Pop(); - break; - } - case 142: { - if (la == null) { currentState = 142; break; } - currentState = stateStack.Pop(); - break; - } - case 143: { - if (la == null) { currentState = 143; break; } - currentState = stateStack.Pop(); - break; - } - case 144: { - if (la == null) { currentState = 144; break; } - currentState = stateStack.Pop(); - break; - } - case 145: { - if (la == null) { currentState = 145; break; } - currentState = stateStack.Pop(); - break; - } - case 146: { - if (la == null) { currentState = 146; break; } - if (la.kind == 35 || la.kind == 126 || la.kind == 233) { - if (la.kind == 126) { - PushContext(Context.CollectionInitializer, la, t); - goto case 151; - } else { - if (la.kind == 35) { - PushContext(Context.CollectionInitializer, la, t); - stateStack.Push(150); - goto case 79; - } else { - if (la.kind == 233) { - PushContext(Context.ObjectInitializer, la, t); - goto case 147; - } else { - goto case 88; - } - } - } - } else { - goto case 89; - } - } - case 147: { - if (la == null) { currentState = 147; break; } - Expect(233, la); // "With" - currentState = 148; - break; - } - case 148: { - stateStack.Push(149); - goto case 93; - } - case 149: { - PopContext(); - goto case 89; - } - case 150: { - PopContext(); - goto case 89; - } - case 151: { - if (la == null) { currentState = 151; break; } - Expect(126, la); // "From" - currentState = 152; - break; - } - case 152: { - if (la == null) { currentState = 152; break; } - if (la.kind == 35) { - stateStack.Push(153); - goto case 79; - } else { - if (set[30].Get(la.kind)) { - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process From again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - - } else { - Error(la); - goto case 153; - } - } - } - case 153: { - PopContext(); - goto case 89; - } - case 154: { - if (la == null) { currentState = 154; break; } - currentState = 153; - break; - } - case 155: { - stateStack.Push(156); - goto case 75; - } - case 156: { - if (la == null) { currentState = 156; break; } - Expect(144, la); // "Is" - currentState = 157; - break; - } - case 157: { - PushContext(Context.Type, la, t); - stateStack.Push(158); - goto case 37; - } - case 158: { - PopContext(); - goto case 78; - } - case 159: { - if (la == null) { currentState = 159; break; } - if (set[32].Get(la.kind)) { - stateStack.Push(159); - goto case 160; - } else { - goto case 78; - } - } - case 160: { - if (la == null) { currentState = 160; break; } - if (la.kind == 37) { - currentState = 165; - break; - } else { - if (set[136].Get(la.kind)) { - currentState = 161; - break; - } else { - goto case 6; - } - } - } - case 161: { - nextTokenIsStartOfImportsOrAccessExpression = true; - goto case 162; - } - case 162: { - if (la == null) { currentState = 162; break; } - if (la.kind == 10) { - currentState = 163; - break; - } else { - goto case 163; - } - } - case 163: { - stateStack.Push(164); - goto case 101; - } - case 164: { - if (la == null) { currentState = 164; break; } - if (la.kind == 11) { - currentState = stateStack.Pop(); - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 165: { - PushContext(Context.Expression, la, t); - nextTokenIsPotentialStartOfExpression = true; - goto case 166; - } - case 166: { - if (la == null) { currentState = 166; break; } - if (la.kind == 169) { - currentState = 168; - break; - } else { - if (set[22].Get(la.kind)) { - if (set[21].Get(la.kind)) { - stateStack.Push(167); - goto case 47; - } else { - goto case 167; - } - } else { - Error(la); - goto case 167; - } - } - } - case 167: { - PopContext(); - goto case 46; - } - case 168: { - PushContext(Context.Type, la, t); - stateStack.Push(169); - goto case 37; - } - case 169: { - PopContext(); - goto case 170; - } - case 170: { - if (la == null) { currentState = 170; break; } - if (la.kind == 22) { - currentState = 171; - break; - } else { - goto case 167; - } - } - case 171: { - PushContext(Context.Type, la, t); - stateStack.Push(172); - goto case 37; - } - case 172: { - PopContext(); - goto case 170; - } - case 173: { - PushContext(Context.Expression, la, t); - nextTokenIsPotentialStartOfExpression = true; - goto case 174; - } - case 174: { - if (la == null) { currentState = 174; break; } - if (set[137].Get(la.kind)) { - currentState = 175; - break; - } else { - if (la.kind == 37) { - currentState = 483; - break; - } else { - if (set[138].Get(la.kind)) { - currentState = 175; - break; - } else { - if (set[134].Get(la.kind)) { - currentState = 175; - break; - } else { - if (set[136].Get(la.kind)) { - currentState = 479; - break; - } else { - if (la.kind == 129) { - currentState = 476; - break; - } else { - if (la.kind == 237) { - currentState = 473; - break; - } else { - if (set[83].Get(la.kind)) { - stateStack.Push(175); - nextTokenIsPotentialStartOfExpression = true; - PushContext(Context.Xml, la, t); - goto case 456; - } else { - if (la.kind == 127 || la.kind == 210) { - stateStack.Push(175); - goto case 252; - } else { - if (la.kind == 58 || la.kind == 126) { - stateStack.Push(175); - PushContext(Context.Query, la, t); - goto case 190; - } else { - if (set[37].Get(la.kind)) { - stateStack.Push(175); - goto case 183; - } else { - if (la.kind == 135) { - stateStack.Push(175); - goto case 176; - } else { - Error(la); - goto case 175; - } - } - } - } - } - } - } - } - } - } - } - } - } - case 175: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 176: { - if (la == null) { currentState = 176; break; } - Expect(135, la); // "If" - currentState = 177; - break; - } - case 177: { - if (la == null) { currentState = 177; break; } - Expect(37, la); // "(" - currentState = 178; - break; - } - case 178: { - stateStack.Push(179); - goto case 55; - } - case 179: { - if (la == null) { currentState = 179; break; } - Expect(22, la); // "," - currentState = 180; - break; - } - case 180: { - stateStack.Push(181); - goto case 55; - } - case 181: { - if (la == null) { currentState = 181; break; } - if (la.kind == 22) { - currentState = 182; - break; - } else { - goto case 46; - } - } - case 182: { - stateStack.Push(46); - goto case 55; - } - case 183: { - if (la == null) { currentState = 183; break; } - if (set[139].Get(la.kind)) { - currentState = 189; - break; - } else { - if (la.kind == 94 || la.kind == 106 || la.kind == 219) { - currentState = 184; - break; - } else { - goto case 6; - } - } - } - case 184: { - if (la == null) { currentState = 184; break; } - Expect(37, la); // "(" - currentState = 185; - break; - } - case 185: { - stateStack.Push(186); - goto case 55; - } - case 186: { - if (la == null) { currentState = 186; break; } - Expect(22, la); // "," - currentState = 187; - break; - } - case 187: { - PushContext(Context.Type, la, t); - stateStack.Push(188); - goto case 37; - } - case 188: { - PopContext(); - goto case 46; - } - case 189: { - if (la == null) { currentState = 189; break; } - Expect(37, la); // "(" - currentState = 182; - break; - } - case 190: { - if (la == null) { currentState = 190; break; } - if (la.kind == 126) { - stateStack.Push(191); - goto case 251; - } else { - if (la.kind == 58) { - stateStack.Push(191); - goto case 250; - } else { - Error(la); - goto case 191; - } - } - } - case 191: { - if (la == null) { currentState = 191; break; } - if (set[38].Get(la.kind)) { - stateStack.Push(191); - goto case 192; - } else { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 192: { - if (la == null) { currentState = 192; break; } - if (la.kind == 126) { - currentState = 248; - break; - } else { - if (la.kind == 58) { - currentState = 244; - break; - } else { - if (la.kind == 197) { - currentState = 242; - break; - } else { - if (la.kind == 107) { - goto case 133; - } else { - if (la.kind == 230) { - currentState = 55; - break; - } else { - if (la.kind == 176) { - currentState = 238; - break; - } else { - if (la.kind == 203 || la.kind == 212) { - currentState = 236; - break; - } else { - if (la.kind == 148) { - currentState = 234; - break; - } else { - if (la.kind == 133) { - currentState = 206; - break; - } else { - if (la.kind == 146) { - currentState = 193; - break; - } else { - goto case 6; - } - } - } - } - } - } - } - } - } - } - } - case 193: { - stateStack.Push(194); - goto case 199; - } - case 194: { - if (la == null) { currentState = 194; break; } - Expect(171, la); // "On" - currentState = 195; - break; - } - case 195: { - stateStack.Push(196); - goto case 55; - } - case 196: { - if (la == null) { currentState = 196; break; } - Expect(116, la); // "Equals" - currentState = 197; - break; - } - case 197: { - stateStack.Push(198); - goto case 55; - } - case 198: { - if (la == null) { currentState = 198; break; } - if (la.kind == 22) { - currentState = 195; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 199: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(200); - goto case 205; - } - case 200: { - PopContext(); - goto case 201; - } - case 201: { - if (la == null) { currentState = 201; break; } - if (la.kind == 63) { - currentState = 203; - break; - } else { - goto case 202; - } - } - case 202: { - if (la == null) { currentState = 202; break; } - Expect(138, la); // "In" - currentState = 55; - break; - } - case 203: { - PushContext(Context.Type, la, t); - stateStack.Push(204); - goto case 37; - } - case 204: { - PopContext(); - goto case 202; - } - case 205: { - if (la == null) { currentState = 205; break; } - if (set[123].Get(la.kind)) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 98) { - goto case 135; - } else { - goto case 6; - } - } - } - case 206: { - SetIdentifierExpected(la); - nextTokenIsPotentialStartOfExpression = true; - goto case 207; - } - case 207: { - if (la == null) { currentState = 207; break; } - if (la.kind == 146) { - goto case 226; - } else { - if (set[40].Get(la.kind)) { - if (la.kind == 70) { - currentState = 209; - break; - } else { - if (set[40].Get(la.kind)) { - goto case 224; - } else { - Error(la); - goto case 208; - } - } - } else { - goto case 6; - } - } - } - case 208: { - if (la == null) { currentState = 208; break; } - Expect(70, la); // "By" - currentState = 209; - break; - } - case 209: { - stateStack.Push(210); - goto case 213; - } - case 210: { - if (la == null) { currentState = 210; break; } - if (la.kind == 22) { - currentState = 209; - break; - } else { - Expect(143, la); // "Into" - currentState = 211; - break; - } - } - case 211: { - stateStack.Push(212); - goto case 213; - } - case 212: { - if (la == null) { currentState = 212; break; } - if (la.kind == 22) { - currentState = 211; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 213: { - SetIdentifierExpected(la); - nextTokenIsPotentialStartOfExpression = true; - goto case 214; - } - case 214: { - if (la == null) { currentState = 214; break; } - if (set[6].Get(la.kind)) { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(217); - goto case 205; - } else { - goto case 215; - } - } - case 215: { - stateStack.Push(216); - goto case 55; - } - case 216: { - if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; - currentState = stateStack.Pop(); - goto switchlbl; - } - case 217: { - nextTokenIsPotentialStartOfExpression = true; - goto case 218; - } - case 218: { - if (la == null) { currentState = 218; break; } - if (set[42].Get(la.kind)) { - PopContext(); isAlreadyInExpr = true; - goto case 219; - } else { - goto case 215; - } - } - case 219: { - if (la == null) { currentState = 219; break; } - if (la.kind == 63) { - currentState = 221; - break; - } else { - if (la.kind == 20) { - currentState = 215; - break; - } else { - if (set[43].Get(la.kind)) { - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process Identifier again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - - } else { - Error(la); - goto case 215; - } - } - } - } - case 220: { - if (la == null) { currentState = 220; break; } - currentState = 215; - break; - } - case 221: { - PushContext(Context.Type, la, t); - stateStack.Push(222); - goto case 37; - } - case 222: { - PopContext(); - goto case 223; - } - case 223: { - if (la == null) { currentState = 223; break; } - Expect(20, la); // "=" - currentState = 215; - break; - } - case 224: { - stateStack.Push(225); - goto case 213; - } - case 225: { - if (la == null) { currentState = 225; break; } - if (la.kind == 22) { - currentState = 224; - break; - } else { - goto case 208; - } - } - case 226: { - stateStack.Push(227); - goto case 233; - } - case 227: { - if (la == null) { currentState = 227; break; } - if (la.kind == 133 || la.kind == 146) { - if (la.kind == 133) { - currentState = 231; - break; - } else { - if (la.kind == 146) { - goto case 226; - } else { - Error(la); - goto case 227; - } - } - } else { - goto case 228; - } - } - case 228: { - if (la == null) { currentState = 228; break; } - Expect(143, la); // "Into" - currentState = 229; - break; - } - case 229: { - stateStack.Push(230); - goto case 213; - } - case 230: { - if (la == null) { currentState = 230; break; } - if (la.kind == 22) { - currentState = 229; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 231: { - stateStack.Push(232); - goto case 233; - } - case 232: { - stateStack.Push(227); - goto case 228; - } - case 233: { - if (la == null) { currentState = 233; break; } - Expect(146, la); // "Join" - currentState = 193; - break; - } - case 234: { - stateStack.Push(235); - goto case 213; - } - case 235: { - if (la == null) { currentState = 235; break; } - if (la.kind == 22) { - currentState = 234; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 236: { - nextTokenIsPotentialStartOfExpression = true; - goto case 237; - } - case 237: { - if (la == null) { currentState = 237; break; } - if (la.kind == 231) { - currentState = 55; - break; - } else { - goto case 55; - } - } - case 238: { - if (la == null) { currentState = 238; break; } - Expect(70, la); // "By" - currentState = 239; - break; - } - case 239: { - stateStack.Push(240); - goto case 55; - } - case 240: { - if (la == null) { currentState = 240; break; } - if (la.kind == 64) { - currentState = 241; - break; - } else { - if (la.kind == 104) { - currentState = 241; - break; - } else { - Error(la); - goto case 241; - } - } - } - case 241: { - if (la == null) { currentState = 241; break; } - if (la.kind == 22) { - currentState = 239; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 242: { - stateStack.Push(243); - goto case 213; - } - case 243: { - if (la == null) { currentState = 243; break; } - if (la.kind == 22) { - currentState = 242; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 244: { - stateStack.Push(245); - goto case 199; - } - case 245: { - if (la == null) { currentState = 245; break; } - if (set[38].Get(la.kind)) { - stateStack.Push(245); - goto case 192; - } else { - Expect(143, la); // "Into" - currentState = 246; - break; - } - } - case 246: { - stateStack.Push(247); - goto case 213; - } - case 247: { - if (la == null) { currentState = 247; break; } - if (la.kind == 22) { - currentState = 246; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 248: { - stateStack.Push(249); - goto case 199; - } - case 249: { - if (la == null) { currentState = 249; break; } - if (la.kind == 22) { - currentState = 248; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 250: { - if (la == null) { currentState = 250; break; } - Expect(58, la); // "Aggregate" - currentState = 244; - break; - } - case 251: { - if (la == null) { currentState = 251; break; } - Expect(126, la); // "From" - currentState = 248; - break; - } - case 252: { - if (la == null) { currentState = 252; break; } - if (la.kind == 210) { - currentState = 451; - break; - } else { - if (la.kind == 127) { - currentState = 253; - break; - } else { - goto case 6; - } - } - } - case 253: { - stateStack.Push(254); - goto case 424; - } - case 254: { - nextTokenIsPotentialStartOfExpression = true; - goto case 255; - } - case 255: { - if (la == null) { currentState = 255; break; } - if (set[23].Get(la.kind)) { - goto case 55; - } else { - if (la.kind == 1 || la.kind == 21 || la.kind == 63) { - if (la.kind == 63) { - currentState = 422; - break; - } else { - goto case 256; - } - } else { - goto case 6; - } - } - } - case 256: { - stateStack.Push(257); - goto case 259; - } - case 257: { - if (la == null) { currentState = 257; break; } - Expect(113, la); // "End" - currentState = 258; - break; - } - case 258: { - if (la == null) { currentState = 258; break; } - Expect(127, la); // "Function" - currentState = stateStack.Pop(); - break; - } - case 259: { - PushContext(Context.Body, la, t); - goto case 260; - } - case 260: { - stateStack.Push(261); - goto case 23; - } - case 261: { - nextTokenIsPotentialStartOfExpression = true; - goto case 262; - } - case 262: { - if (la == null) { currentState = 262; break; } - if (set[140].Get(la.kind)) { - if (set[69].Get(la.kind)) { - if (set[50].Get(la.kind)) { - stateStack.Push(260); - goto case 267; - } else { - goto case 260; - } - } else { - if (la.kind == 113) { - currentState = 265; - break; - } else { - goto case 264; - } - } - } else { - goto case 263; - } - } - case 263: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 264: { - Error(la); - goto case 261; - } - case 265: { - if (la == null) { currentState = 265; break; } - if (la.kind == 1 || la.kind == 21) { - goto case 260; - } else { - if (set[49].Get(la.kind)) { - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process End again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - - } else { - goto case 264; - } - } - } - case 266: { - if (la == null) { currentState = 266; break; } - currentState = 261; - break; - } - case 267: { - nextTokenIsPotentialStartOfExpression = true; - goto case 268; - } - case 268: { - if (la == null) { currentState = 268; break; } - if (la.kind == 88 || la.kind == 105 || la.kind == 204) { - currentState = 399; - break; - } else { - if (la.kind == 211 || la.kind == 233) { - currentState = 395; - break; - } else { - if (la.kind == 56 || la.kind == 193) { - currentState = 393; - break; - } else { - if (la.kind == 189) { - currentState = 388; - break; - } else { - if (la.kind == 135) { - currentState = 370; - break; - } else { - if (la.kind == 197) { - currentState = 354; - break; - } else { - if (la.kind == 231) { - currentState = 350; - break; - } else { - if (la.kind == 108) { - currentState = 344; - break; - } else { - if (la.kind == 124) { - currentState = 317; - break; - } else { - if (la.kind == 118 || la.kind == 171 || la.kind == 194) { - if (la.kind == 118 || la.kind == 171) { - if (la.kind == 171) { - currentState = 313; - break; - } else { - goto case 313; - } - } else { - if (la.kind == 194) { - currentState = 311; - break; - } else { - goto case 6; - } - } - } else { - if (la.kind == 215) { - currentState = 309; - break; - } else { - if (la.kind == 218) { - currentState = 296; - break; - } else { - if (set[141].Get(la.kind)) { - if (la.kind == 132) { - currentState = 293; - break; - } else { - if (la.kind == 120) { - currentState = 292; - break; - } else { - if (la.kind == 89) { - currentState = 291; - break; - } else { - if (la.kind == 206) { - goto case 113; - } else { - if (la.kind == 195) { - currentState = 288; - break; - } else { - goto case 6; - } - } - } - } - } - } else { - if (la.kind == 191) { - currentState = 286; - break; - } else { - if (la.kind == 117) { - currentState = 284; - break; - } else { - if (la.kind == 226) { - currentState = 269; - break; - } else { - if (set[142].Get(la.kind)) { - if (la.kind == 73) { - currentState = 55; - break; - } else { - goto case 55; - } - } else { - goto case 6; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - case 269: { - stateStack.Push(270); - SetIdentifierExpected(la); - nextTokenIsPotentialStartOfExpression = true; - goto case 273; - } - case 270: { - if (la == null) { currentState = 270; break; } - if (la.kind == 22) { - currentState = 269; - break; - } else { - stateStack.Push(271); - goto case 259; - } - } - case 271: { - if (la == null) { currentState = 271; break; } - Expect(113, la); // "End" - currentState = 272; - break; - } - case 272: { - if (la == null) { currentState = 272; break; } - Expect(226, la); // "Using" - currentState = stateStack.Pop(); - break; - } - case 273: { - if (la == null) { currentState = 273; break; } - if (set[6].Get(la.kind)) { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(276); - goto case 205; - } else { - goto case 274; - } - } - case 274: { - stateStack.Push(275); - goto case 55; - } - case 275: { - if (!isAlreadyInExpr) PopContext(); isAlreadyInExpr = false; - currentState = stateStack.Pop(); - goto switchlbl; - } - case 276: { - nextTokenIsPotentialStartOfExpression = true; - goto case 277; - } - case 277: { - if (la == null) { currentState = 277; break; } - if (set[42].Get(la.kind)) { - PopContext(); isAlreadyInExpr = true; - goto case 278; - } else { - goto case 274; - } - } - case 278: { - if (la == null) { currentState = 278; break; } - if (la.kind == 63) { - currentState = 280; - break; - } else { - if (la.kind == 20) { - currentState = 274; - break; - } else { - if (set[43].Get(la.kind)) { - currentState = endOfStatementTerminatorAndBlock; /* leave this block */ - InformToken(t); /* process Identifier again*/ - /* for processing current token (la): go to the position after processing End */ - goto switchlbl; - - } else { - Error(la); - goto case 274; - } - } - } - } - case 279: { - if (la == null) { currentState = 279; break; } - currentState = 274; - break; - } - case 280: { - nextTokenIsPotentialStartOfExpression = true; - goto case 281; - } - case 281: { - if (la == null) { currentState = 281; break; } - if (set[16].Get(la.kind)) { - PushContext(Context.Type, la, t); - stateStack.Push(282); - goto case 37; - } else { - goto case 274; - } - } - case 282: { - PopContext(); - goto case 283; - } - case 283: { - if (la == null) { currentState = 283; break; } - Expect(20, la); // "=" - currentState = 274; - break; - } - case 284: { - stateStack.Push(285); - goto case 55; - } - case 285: { - if (la == null) { currentState = 285; break; } - if (la.kind == 22) { - currentState = 284; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 286: { - nextTokenIsPotentialStartOfExpression = true; - goto case 287; - } - case 287: { - if (la == null) { currentState = 287; break; } - if (la.kind == 184) { - currentState = 55; - break; - } else { - goto case 55; - } - } - case 288: { - PushContext(Context.Expression, la, t); - nextTokenIsPotentialStartOfExpression = true; - goto case 289; - } - case 289: { - if (la == null) { currentState = 289; break; } - if (set[23].Get(la.kind)) { - stateStack.Push(290); - goto case 55; - } else { - goto case 290; - } - } - case 290: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 291: { - if (la == null) { currentState = 291; break; } - if (la.kind == 108) { - goto case 132; - } else { - if (la.kind == 124) { - goto case 129; - } else { - if (la.kind == 231) { - goto case 103; - } else { - goto case 6; - } - } - } - } - case 292: { - if (la == null) { currentState = 292; break; } - if (la.kind == 108) { - goto case 132; - } else { - if (la.kind == 124) { - goto case 129; - } else { - if (la.kind == 231) { - goto case 103; - } else { - if (la.kind == 197) { - goto case 115; - } else { - if (la.kind == 210) { - goto case 111; - } else { - if (la.kind == 127) { - goto case 127; - } else { - if (la.kind == 186) { - goto case 116; - } else { - if (la.kind == 218) { - goto case 107; - } else { - goto case 6; - } - } - } - } - } - } - } - } - } - case 293: { - if (la == null) { currentState = 293; break; } - if (set[6].Get(la.kind)) { - goto case 295; - } else { - if (la.kind == 5) { - goto case 294; - } else { - goto case 6; - } - } - } - case 294: { - if (la == null) { currentState = 294; break; } - currentState = stateStack.Pop(); - break; - } - case 295: { - if (la == null) { currentState = 295; break; } - currentState = stateStack.Pop(); - break; - } - case 296: { - stateStack.Push(297); - goto case 259; - } - case 297: { - if (la == null) { currentState = 297; break; } - if (la.kind == 75) { - currentState = 301; - break; - } else { - if (la.kind == 123) { - currentState = 300; - break; - } else { - goto case 298; - } - } - } - case 298: { - if (la == null) { currentState = 298; break; } - Expect(113, la); // "End" - currentState = 299; - break; - } - case 299: { - if (la == null) { currentState = 299; break; } - Expect(218, la); // "Try" - currentState = stateStack.Pop(); - break; - } - case 300: { - stateStack.Push(298); - goto case 259; - } - case 301: { - SetIdentifierExpected(la); - goto case 302; - } - case 302: { - if (la == null) { currentState = 302; break; } - if (set[6].Get(la.kind)) { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(305); - goto case 205; - } else { - goto case 303; - } - } - case 303: { - if (la == null) { currentState = 303; break; } - if (la.kind == 229) { - currentState = 304; - break; - } else { - goto case 296; - } - } - case 304: { - stateStack.Push(296); - goto case 55; - } - case 305: { - PopContext(); - goto case 306; - } - case 306: { - if (la == null) { currentState = 306; break; } - if (la.kind == 63) { - currentState = 307; - break; - } else { - goto case 303; - } - } - case 307: { - PushContext(Context.Type, la, t); - stateStack.Push(308); - goto case 37; - } - case 308: { - PopContext(); - goto case 303; - } - case 309: { - nextTokenIsPotentialStartOfExpression = true; - goto case 310; - } - case 310: { - if (la == null) { currentState = 310; break; } - if (set[23].Get(la.kind)) { - goto case 55; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 311: { - if (la == null) { currentState = 311; break; } - if (la.kind == 163) { - goto case 120; - } else { - goto case 312; - } - } - case 312: { - if (la == null) { currentState = 312; break; } - if (la.kind == 5) { - goto case 294; - } else { - if (set[6].Get(la.kind)) { - goto case 295; - } else { - goto case 6; - } - } - } - case 313: { - if (la == null) { currentState = 313; break; } - Expect(118, la); // "Error" - currentState = 314; - break; - } - case 314: { - nextTokenIsPotentialStartOfExpression = true; - goto case 315; - } - case 315: { - if (la == null) { currentState = 315; break; } - if (set[23].Get(la.kind)) { - goto case 55; - } else { - if (la.kind == 132) { - currentState = 312; - break; - } else { - if (la.kind == 194) { - currentState = 316; - break; - } else { - goto case 6; - } - } - } - } - case 316: { - if (la == null) { currentState = 316; break; } - Expect(163, la); // "Next" - currentState = stateStack.Pop(); - break; - } - case 317: { - nextTokenIsPotentialStartOfExpression = true; - SetIdentifierExpected(la); - goto case 318; - } - case 318: { - if (la == null) { currentState = 318; break; } - if (set[35].Get(la.kind)) { - stateStack.Push(334); - goto case 328; - } else { - if (la.kind == 110) { - currentState = 319; - break; - } else { - goto case 6; - } - } - } - case 319: { - stateStack.Push(320); - goto case 328; - } - case 320: { - if (la == null) { currentState = 320; break; } - Expect(138, la); // "In" - currentState = 321; - break; - } - case 321: { - stateStack.Push(322); - goto case 55; - } - case 322: { - stateStack.Push(323); - goto case 259; - } - case 323: { - if (la == null) { currentState = 323; break; } - Expect(163, la); // "Next" - currentState = 324; - break; - } - case 324: { - nextTokenIsPotentialStartOfExpression = true; - goto case 325; - } - case 325: { - if (la == null) { currentState = 325; break; } - if (set[23].Get(la.kind)) { - goto case 326; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 326: { - stateStack.Push(327); - goto case 55; - } - case 327: { - if (la == null) { currentState = 327; break; } - if (la.kind == 22) { - currentState = 326; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 328: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(329); - goto case 173; - } - case 329: { - PopContext(); - goto case 330; - } - case 330: { - if (la == null) { currentState = 330; break; } - if (la.kind == 33) { - currentState = 331; - break; - } else { - goto case 331; - } - } - case 331: { - if (la == null) { currentState = 331; break; } - if (set[32].Get(la.kind)) { - stateStack.Push(331); - goto case 160; - } else { - if (la.kind == 63) { - currentState = 332; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - } - case 332: { - PushContext(Context.Type, la, t); - stateStack.Push(333); - goto case 37; - } - case 333: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 334: { - if (la == null) { currentState = 334; break; } - Expect(20, la); // "=" - currentState = 335; - break; - } - case 335: { - stateStack.Push(336); - goto case 55; - } - case 336: { - if (la == null) { currentState = 336; break; } - if (la.kind == 205) { - currentState = 343; - break; - } else { - goto case 337; - } - } - case 337: { - stateStack.Push(338); - goto case 259; - } - case 338: { - if (la == null) { currentState = 338; break; } - Expect(163, la); // "Next" - currentState = 339; - break; - } - case 339: { - nextTokenIsPotentialStartOfExpression = true; - goto case 340; - } - case 340: { - if (la == null) { currentState = 340; break; } - if (set[23].Get(la.kind)) { - goto case 341; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 341: { - stateStack.Push(342); - goto case 55; - } - case 342: { - if (la == null) { currentState = 342; break; } - if (la.kind == 22) { - currentState = 341; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 343: { - stateStack.Push(337); - goto case 55; - } - case 344: { - if (la == null) { currentState = 344; break; } - if (la.kind == 224 || la.kind == 231) { - currentState = 347; - break; - } else { - if (la.kind == 1 || la.kind == 21) { - stateStack.Push(345); - goto case 259; - } else { - goto case 6; - } - } - } - case 345: { - if (la == null) { currentState = 345; break; } - Expect(152, la); // "Loop" - currentState = 346; - break; - } - case 346: { - if (la == null) { currentState = 346; break; } - if (la.kind == 224 || la.kind == 231) { - currentState = 55; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 347: { - stateStack.Push(348); - goto case 55; - } - case 348: { - stateStack.Push(349); - goto case 259; - } - case 349: { - if (la == null) { currentState = 349; break; } - Expect(152, la); // "Loop" - currentState = stateStack.Pop(); - break; - } - case 350: { - stateStack.Push(351); - goto case 55; - } - case 351: { - stateStack.Push(352); - goto case 259; - } - case 352: { - if (la == null) { currentState = 352; break; } - Expect(113, la); // "End" - currentState = 353; - break; - } - case 353: { - if (la == null) { currentState = 353; break; } - Expect(231, la); // "While" - currentState = stateStack.Pop(); - break; - } - case 354: { - nextTokenIsPotentialStartOfExpression = true; - goto case 355; - } - case 355: { - if (la == null) { currentState = 355; break; } - if (la.kind == 74) { - currentState = 356; - break; - } else { - goto case 356; - } - } - case 356: { - stateStack.Push(357); - goto case 55; - } - case 357: { - stateStack.Push(358); - goto case 23; - } - case 358: { - if (la == null) { currentState = 358; break; } - if (la.kind == 74) { - currentState = 360; - break; - } else { - Expect(113, la); // "End" - currentState = 359; - break; - } - } - case 359: { - if (la == null) { currentState = 359; break; } - Expect(197, la); // "Select" - currentState = stateStack.Pop(); - break; - } - case 360: { - nextTokenIsPotentialStartOfExpression = true; - goto case 361; - } - case 361: { - if (la == null) { currentState = 361; break; } - if (la.kind == 111) { - currentState = 362; - break; - } else { - if (set[67].Get(la.kind)) { - goto case 363; - } else { - Error(la); - goto case 362; - } - } - } - case 362: { - stateStack.Push(358); - goto case 259; - } - case 363: { - nextTokenIsPotentialStartOfExpression = true; - goto case 364; - } - case 364: { - if (la == null) { currentState = 364; break; } - if (set[143].Get(la.kind)) { - if (la.kind == 144) { - currentState = 366; - break; - } else { - goto case 366; - } - } else { - if (set[23].Get(la.kind)) { - stateStack.Push(365); - goto case 55; - } else { - Error(la); - goto case 365; - } - } - } - case 365: { - if (la == null) { currentState = 365; break; } - if (la.kind == 22) { - currentState = 363; - break; - } else { - goto case 362; - } - } - case 366: { - stateStack.Push(367); - goto case 368; - } - case 367: { - stateStack.Push(365); - goto case 75; - } - case 368: { - if (la == null) { currentState = 368; break; } - if (la.kind == 20) { - goto case 73; - } else { - if (la.kind == 41) { - goto case 72; - } else { - if (la.kind == 40) { - goto case 71; - } else { - if (la.kind == 39) { - currentState = 369; - break; - } else { - if (la.kind == 42) { - goto case 68; - } else { - if (la.kind == 43) { - goto case 69; - } else { - goto case 6; - } - } - } - } - } - } - } - case 369: { - wasNormalAttribute = false; - currentState = stateStack.Pop(); - goto switchlbl; - } - case 370: { - stateStack.Push(371); - goto case 55; - } - case 371: { - if (la == null) { currentState = 371; break; } - if (la.kind == 214) { - currentState = 379; - break; - } else { - goto case 372; - } - } - case 372: { - if (la == null) { currentState = 372; break; } - if (la.kind == 1 || la.kind == 21) { - goto case 373; - } else { - goto case 6; - } - } - case 373: { - stateStack.Push(374); - goto case 259; - } - case 374: { - if (la == null) { currentState = 374; break; } - if (la.kind == 111 || la.kind == 112) { - if (la.kind == 111) { - currentState = 378; - break; - } else { - if (la.kind == 112) { - currentState = 376; - break; - } else { - Error(la); - goto case 373; - } - } - } else { - Expect(113, la); // "End" - currentState = 375; - break; - } - } - case 375: { - if (la == null) { currentState = 375; break; } - Expect(135, la); // "If" - currentState = stateStack.Pop(); - break; - } - case 376: { - stateStack.Push(377); - goto case 55; - } - case 377: { - if (la == null) { currentState = 377; break; } - if (la.kind == 214) { - currentState = 373; - break; - } else { - goto case 373; - } - } - case 378: { - if (la == null) { currentState = 378; break; } - if (la.kind == 135) { - currentState = 376; - break; - } else { - goto case 373; - } - } - case 379: { - nextTokenIsPotentialStartOfExpression = true; - goto case 380; - } - case 380: { - if (la == null) { currentState = 380; break; } - if (set[50].Get(la.kind)) { - goto case 381; - } else { - goto case 372; - } - } - case 381: { - stateStack.Push(382); - goto case 267; - } - case 382: { - if (la == null) { currentState = 382; break; } - if (la.kind == 21) { - currentState = 386; - break; - } else { - if (la.kind == 111) { - currentState = 383; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - } - case 383: { - nextTokenIsPotentialStartOfExpression = true; - goto case 384; - } - case 384: { - if (la == null) { currentState = 384; break; } - if (set[50].Get(la.kind)) { - stateStack.Push(385); - goto case 267; - } else { - goto case 385; - } - } - case 385: { - if (la == null) { currentState = 385; break; } - if (la.kind == 21) { - currentState = 383; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 386: { - nextTokenIsPotentialStartOfExpression = true; - goto case 387; - } - case 387: { - if (la == null) { currentState = 387; break; } - if (set[50].Get(la.kind)) { - goto case 381; - } else { - goto case 382; - } - } - case 388: { - stateStack.Push(389); - goto case 101; - } - case 389: { - if (la == null) { currentState = 389; break; } - if (la.kind == 37) { - currentState = 390; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 390: { - PushContext(Context.Expression, la, t); - nextTokenIsPotentialStartOfExpression = true; - goto case 391; - } - case 391: { - if (la == null) { currentState = 391; break; } - if (set[21].Get(la.kind)) { - stateStack.Push(392); - goto case 47; - } else { - goto case 392; - } - } - case 392: { - PopContext(); - goto case 46; - } - case 393: { - stateStack.Push(394); - goto case 55; - } - case 394: { - if (la == null) { currentState = 394; break; } - Expect(22, la); // "," - currentState = 55; - break; - } - case 395: { - stateStack.Push(396); - goto case 55; - } - case 396: { - stateStack.Push(397); - goto case 259; - } - case 397: { - if (la == null) { currentState = 397; break; } - Expect(113, la); // "End" - currentState = 398; - break; - } - case 398: { - if (la == null) { currentState = 398; break; } - if (la.kind == 233) { - goto case 102; - } else { - if (la.kind == 211) { - goto case 110; - } else { - goto case 6; - } - } - } - case 399: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(400); - goto case 205; - } - case 400: { - PopContext(); - goto case 401; - } - case 401: { - if (la == null) { currentState = 401; break; } - if (la.kind == 33) { - currentState = 402; - break; - } else { - goto case 402; - } - } - case 402: { - if (la == null) { currentState = 402; break; } - if (la.kind == 37) { - currentState = 419; - break; - } else { - if (la.kind == 63) { - currentState = 416; - break; - } else { - goto case 403; - } - } - } - case 403: { - if (la == null) { currentState = 403; break; } - if (la.kind == 20) { - currentState = 415; - break; - } else { - goto case 404; - } - } - case 404: { - if (la == null) { currentState = 404; break; } - if (la.kind == 22) { - currentState = 405; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 405: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(406); - goto case 205; - } - case 406: { - PopContext(); - goto case 407; - } - case 407: { - if (la == null) { currentState = 407; break; } - if (la.kind == 33) { - currentState = 408; - break; - } else { - goto case 408; - } - } - case 408: { - if (la == null) { currentState = 408; break; } - if (la.kind == 37) { - currentState = 412; - break; - } else { - if (la.kind == 63) { - currentState = 409; - break; - } else { - goto case 403; - } - } - } - case 409: { - PushContext(Context.Type, la, t); - goto case 410; - } - case 410: { - if (la == null) { currentState = 410; break; } - if (la.kind == 162) { - stateStack.Push(411); - goto case 85; - } else { - if (set[16].Get(la.kind)) { - stateStack.Push(411); - goto case 37; - } else { - Error(la); - goto case 411; - } - } - } - case 411: { - PopContext(); - goto case 403; - } - case 412: { - nextTokenIsPotentialStartOfExpression = true; - goto case 413; - } - case 413: { - if (la == null) { currentState = 413; break; } - if (set[23].Get(la.kind)) { - stateStack.Push(414); - goto case 55; - } else { - goto case 414; - } - } - case 414: { - if (la == null) { currentState = 414; break; } - if (la.kind == 22) { - currentState = 412; - break; - } else { - Expect(38, la); // ")" - currentState = 408; - break; - } - } - case 415: { - stateStack.Push(404); - goto case 55; - } - case 416: { - PushContext(Context.Type, la, t); - goto case 417; - } - case 417: { - if (la == null) { currentState = 417; break; } - if (la.kind == 162) { - stateStack.Push(418); - goto case 85; - } else { - if (set[16].Get(la.kind)) { - stateStack.Push(418); - goto case 37; - } else { - Error(la); - goto case 418; - } - } - } - case 418: { - PopContext(); - goto case 403; - } - case 419: { - nextTokenIsPotentialStartOfExpression = true; - goto case 420; - } - case 420: { - if (la == null) { currentState = 420; break; } - if (set[23].Get(la.kind)) { - stateStack.Push(421); - goto case 55; - } else { - goto case 421; - } - } - case 421: { - if (la == null) { currentState = 421; break; } - if (la.kind == 22) { - currentState = 419; - break; - } else { - Expect(38, la); // ")" - currentState = 402; - break; - } - } - case 422: { - PushContext(Context.Type, la, t); - stateStack.Push(423); - goto case 37; - } - case 423: { - PopContext(); - goto case 256; - } - case 424: { - if (la == null) { currentState = 424; break; } - Expect(37, la); // "(" - currentState = 425; - break; - } - case 425: { - PushContext(Context.Default, la, t); - SetIdentifierExpected(la); - goto case 426; - } - case 426: { - if (la == null) { currentState = 426; break; } - if (set[77].Get(la.kind)) { - stateStack.Push(427); - goto case 428; - } else { - goto case 427; - } - } - case 427: { - PopContext(); - goto case 46; - } - case 428: { - stateStack.Push(429); - PushContext(Context.Parameter, la, t); - goto case 430; - } - case 429: { - if (la == null) { currentState = 429; break; } - if (la.kind == 22) { - currentState = 428; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 430: { - SetIdentifierExpected(la); - goto case 431; - } - case 431: { - if (la == null) { currentState = 431; break; } - if (la.kind == 40) { - stateStack.Push(430); - goto case 443; - } else { - goto case 432; - } - } - case 432: { - SetIdentifierExpected(la); - goto case 433; - } - case 433: { - if (la == null) { currentState = 433; break; } - if (set[144].Get(la.kind)) { - currentState = 432; - break; - } else { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(434); - goto case 205; - } - } - case 434: { - PopContext(); - goto case 435; - } - case 435: { - if (la == null) { currentState = 435; break; } - if (la.kind == 33) { - currentState = 436; - break; - } else { - goto case 436; - } - } - case 436: { - if (la == null) { currentState = 436; break; } - if (la.kind == 37) { - currentState = 442; - break; - } else { - if (la.kind == 63) { - currentState = 440; - break; - } else { - goto case 437; - } - } - } - case 437: { - if (la == null) { currentState = 437; break; } - if (la.kind == 20) { - currentState = 439; - break; - } else { - goto case 438; - } - } - case 438: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 439: { - stateStack.Push(438); - goto case 55; - } - case 440: { - PushContext(Context.Type, la, t); - stateStack.Push(441); - goto case 37; - } - case 441: { - PopContext(); - goto case 437; - } - case 442: { - if (la == null) { currentState = 442; break; } - if (la.kind == 22) { - currentState = 442; - break; - } else { - Expect(38, la); // ")" - currentState = 436; - break; - } - } - case 443: { - if (la == null) { currentState = 443; break; } - Expect(40, la); // "<" - currentState = 444; - break; - } - case 444: { - wasNormalAttribute = true; PushContext(Context.Attribute, la, t); - goto case 445; - } - case 445: { - if (la == null) { currentState = 445; break; } - if (la.kind == 65 || la.kind == 155) { - currentState = 449; - break; - } else { - goto case 446; - } - } - case 446: { - if (la == null) { currentState = 446; break; } - if (set[145].Get(la.kind)) { - currentState = 446; - break; - } else { - Expect(39, la); // ">" - currentState = 447; - break; - } - } - case 447: { - PopContext(); - goto case 448; - } - case 448: { - if (la == null) { currentState = 448; break; } - if (la.kind == 1) { - goto case 25; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 449: { - if (la == null) { currentState = 449; break; } - Expect(21, la); // ":" - currentState = 450; - break; - } - case 450: { - wasNormalAttribute = false; - goto case 446; - } - case 451: { - stateStack.Push(452); - goto case 424; - } - case 452: { - nextTokenIsPotentialStartOfExpression = true; - goto case 453; - } - case 453: { - if (la == null) { currentState = 453; break; } - if (set[50].Get(la.kind)) { - goto case 267; - } else { - if (la.kind == 1 || la.kind == 21) { - stateStack.Push(454); - goto case 259; - } else { - goto case 6; - } - } - } - case 454: { - if (la == null) { currentState = 454; break; } - Expect(113, la); // "End" - currentState = 455; - break; - } - case 455: { - if (la == null) { currentState = 455; break; } - Expect(210, la); // "Sub" - currentState = stateStack.Pop(); - break; - } - case 456: { - if (la == null) { currentState = 456; break; } - if (la.kind == 17 || la.kind == 18 || la.kind == 19) { - currentState = 469; - break; - } else { - if (la.kind == 10) { - stateStack.Push(458); - goto case 460; - } else { - Error(la); - goto case 457; - } - } - } - case 457: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 458: { - if (la == null) { currentState = 458; break; } - if (la.kind == 17) { - currentState = 459; - break; - } else { - goto case 457; - } - } - case 459: { - if (la == null) { currentState = 459; break; } - if (la.kind == 16) { - currentState = 458; - break; - } else { - goto case 458; - } - } - case 460: { - PushContext(Context.Xml, la, t); - goto case 461; - } - case 461: { - if (la == null) { currentState = 461; break; } - Expect(10, la); // XmlOpenTag - currentState = 462; - break; - } - case 462: { - if (la == null) { currentState = 462; break; } - if (set[146].Get(la.kind)) { - if (set[147].Get(la.kind)) { - currentState = 462; - break; - } else { - if (la.kind == 12) { - stateStack.Push(462); - goto case 466; - } else { - Error(la); - goto case 462; - } - } - } else { - if (la.kind == 14) { - currentState = 463; - break; - } else { - if (la.kind == 11) { - currentState = 464; - break; - } else { - Error(la); - goto case 463; - } - } - } - } - case 463: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 464: { - if (la == null) { currentState = 464; break; } - if (set[148].Get(la.kind)) { - if (set[149].Get(la.kind)) { - currentState = 464; - break; - } else { - if (la.kind == 12) { - stateStack.Push(464); - goto case 466; - } else { - if (la.kind == 10) { - stateStack.Push(464); - goto case 460; - } else { - Error(la); - goto case 464; - } - } - } - } else { - Expect(15, la); // XmlOpenEndTag - currentState = 465; - break; - } - } - case 465: { - if (la == null) { currentState = 465; break; } - if (set[150].Get(la.kind)) { - if (set[151].Get(la.kind)) { - currentState = 465; - break; - } else { - if (la.kind == 12) { - stateStack.Push(465); - goto case 466; - } else { - Error(la); - goto case 465; - } - } - } else { - Expect(11, la); // XmlCloseTag - currentState = 463; - break; - } - } - case 466: { - if (la == null) { currentState = 466; break; } - Expect(12, la); // XmlStartInlineVB - currentState = 467; - break; - } - case 467: { - stateStack.Push(468); - goto case 55; - } - case 468: { - if (la == null) { currentState = 468; break; } - Expect(13, la); // XmlEndInlineVB - currentState = stateStack.Pop(); - break; - } - case 469: { - if (la == null) { currentState = 469; break; } - if (la.kind == 16) { - currentState = 470; - break; - } else { - goto case 470; - } - } - case 470: { - if (la == null) { currentState = 470; break; } - if (la.kind == 17 || la.kind == 19) { - currentState = 469; - break; - } else { - if (la.kind == 10) { - stateStack.Push(471); - goto case 460; - } else { - goto case 457; - } - } - } - case 471: { - if (la == null) { currentState = 471; break; } - if (la.kind == 17) { - currentState = 472; - break; - } else { - goto case 457; - } - } - case 472: { - if (la == null) { currentState = 472; break; } - if (la.kind == 16) { - currentState = 471; - break; - } else { - goto case 471; - } - } - case 473: { - if (la == null) { currentState = 473; break; } - Expect(37, la); // "(" - currentState = 474; - break; - } - case 474: { - readXmlIdentifier = true; - stateStack.Push(475); - goto case 205; - } - case 475: { - if (la == null) { currentState = 475; break; } - Expect(38, la); // ")" - currentState = 175; - break; - } - case 476: { - if (la == null) { currentState = 476; break; } - Expect(37, la); // "(" - currentState = 477; - break; - } - case 477: { - PushContext(Context.Type, la, t); - stateStack.Push(478); - goto case 37; - } - case 478: { - PopContext(); - goto case 475; - } - case 479: { - nextTokenIsStartOfImportsOrAccessExpression = true; wasQualifierTokenAtStart = true; - goto case 480; - } - case 480: { - if (la == null) { currentState = 480; break; } - if (la.kind == 10) { - currentState = 481; - break; - } else { - goto case 481; - } - } - case 481: { - stateStack.Push(482); - goto case 101; - } - case 482: { - if (la == null) { currentState = 482; break; } - if (la.kind == 11) { - currentState = 175; - break; - } else { - goto case 175; - } - } - case 483: { - activeArgument = 0; - goto case 484; - } - case 484: { - stateStack.Push(485); - goto case 55; - } - case 485: { - if (la == null) { currentState = 485; break; } - if (la.kind == 22) { - currentState = 486; - break; - } else { - goto case 475; - } - } - case 486: { - activeArgument++; - goto case 484; - } - case 487: { - stateStack.Push(488); - goto case 55; - } - case 488: { - if (la == null) { currentState = 488; break; } - if (la.kind == 22) { - currentState = 489; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 489: { - activeArgument++; - nextTokenIsPotentialStartOfExpression = true; - goto case 490; - } - case 490: { - if (la == null) { currentState = 490; break; } - if (set[23].Get(la.kind)) { - goto case 487; - } else { - goto case 488; - } - } - case 491: { - if (la == null) { currentState = 491; break; } - if (set[16].Get(la.kind)) { - PushContext(Context.Type, la, t); - stateStack.Push(495); - goto case 37; - } else { - goto case 492; - } - } - case 492: { - if (la == null) { currentState = 492; break; } - if (la.kind == 22) { - currentState = 493; - break; - } else { - goto case 45; - } - } - case 493: { - if (la == null) { currentState = 493; break; } - if (set[16].Get(la.kind)) { - PushContext(Context.Type, la, t); - stateStack.Push(494); - goto case 37; - } else { - goto case 492; - } - } - case 494: { - PopContext(); - goto case 492; - } - case 495: { - PopContext(); - goto case 492; - } - case 496: { - SetIdentifierExpected(la); - goto case 497; - } - case 497: { - if (la == null) { currentState = 497; break; } - if (set[152].Get(la.kind)) { - if (la.kind == 169) { - currentState = 499; - break; - } else { - if (set[77].Get(la.kind)) { - stateStack.Push(498); - goto case 428; - } else { - Error(la); - goto case 498; - } - } - } else { - goto case 498; - } - } - case 498: { - if (la == null) { currentState = 498; break; } - Expect(38, la); // ")" - currentState = 34; - break; - } - case 499: { - stateStack.Push(498); - goto case 500; - } - case 500: { - SetIdentifierExpected(la); - goto case 501; - } - case 501: { - if (la == null) { currentState = 501; break; } - if (la.kind == 138 || la.kind == 178) { - currentState = 502; - break; - } else { - goto case 502; - } - } - case 502: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(503); - goto case 517; - } - case 503: { - PopContext(); - goto case 504; - } - case 504: { - if (la == null) { currentState = 504; break; } - if (la.kind == 63) { - currentState = 518; - break; - } else { - goto case 505; - } - } - case 505: { - if (la == null) { currentState = 505; break; } - if (la.kind == 22) { - currentState = 506; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 506: { - SetIdentifierExpected(la); - goto case 507; - } - case 507: { - if (la == null) { currentState = 507; break; } - if (la.kind == 138 || la.kind == 178) { - currentState = 508; - break; - } else { - goto case 508; - } - } - case 508: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(509); - goto case 517; - } - case 509: { - PopContext(); - goto case 510; - } - case 510: { - if (la == null) { currentState = 510; break; } - if (la.kind == 63) { - currentState = 511; - break; - } else { - goto case 505; - } - } - case 511: { - PushContext(Context.Type, la, t); - stateStack.Push(512); - goto case 513; - } - case 512: { - PopContext(); - goto case 505; - } - case 513: { - if (la == null) { currentState = 513; break; } - if (set[94].Get(la.kind)) { - goto case 516; - } else { - if (la.kind == 35) { - currentState = 514; - break; - } else { - goto case 6; - } - } - } - case 514: { - stateStack.Push(515); - goto case 516; - } - case 515: { - if (la == null) { currentState = 515; break; } - if (la.kind == 22) { - currentState = 514; - break; - } else { - goto case 82; - } - } - case 516: { - if (la == null) { currentState = 516; break; } - if (set[16].Get(la.kind)) { - currentState = 38; - break; - } else { - if (la.kind == 162) { - goto case 121; - } else { - if (la.kind == 84) { - goto case 137; - } else { - if (la.kind == 209) { - goto case 112; - } else { - goto case 6; - } - } - } - } - } - case 517: { - if (la == null) { currentState = 517; break; } - if (la.kind == 2) { - goto case 145; - } else { - if (la.kind == 62) { - goto case 143; - } else { - if (la.kind == 64) { - goto case 142; - } else { - if (la.kind == 65) { - goto case 141; - } else { - if (la.kind == 66) { - goto case 140; - } else { - if (la.kind == 67) { - goto case 139; - } else { - if (la.kind == 70) { - goto case 138; - } else { - if (la.kind == 87) { - goto case 136; - } else { - if (la.kind == 104) { - goto case 134; - } else { - if (la.kind == 107) { - goto case 133; - } else { - if (la.kind == 116) { - goto case 131; - } else { - if (la.kind == 121) { - goto case 130; - } else { - if (la.kind == 133) { - goto case 126; - } else { - if (la.kind == 139) { - goto case 125; - } else { - if (la.kind == 143) { - goto case 124; - } else { - if (la.kind == 146) { - goto case 123; - } else { - if (la.kind == 147) { - goto case 122; - } else { - if (la.kind == 170) { - goto case 119; - } else { - if (la.kind == 176) { - goto case 118; - } else { - if (la.kind == 184) { - goto case 117; - } else { - if (la.kind == 203) { - goto case 114; - } else { - if (la.kind == 212) { - goto case 109; - } else { - if (la.kind == 213) { - goto case 108; - } else { - if (la.kind == 223) { - goto case 106; - } else { - if (la.kind == 224) { - goto case 105; - } else { - if (la.kind == 230) { - goto case 104; - } else { - goto case 6; - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - case 518: { - PushContext(Context.Type, la, t); - stateStack.Push(519); - goto case 513; - } - case 519: { - PopContext(); - goto case 505; - } - case 520: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(521); - goto case 205; - } - case 521: { - PopContext(); - goto case 522; - } - case 522: { - if (la == null) { currentState = 522; break; } - if (la.kind == 37) { - stateStack.Push(523); - goto case 424; - } else { - goto case 523; - } - } - case 523: { - if (la == null) { currentState = 523; break; } - if (la.kind == 63) { - currentState = 524; - break; - } else { - goto case 23; - } - } - case 524: { - PushContext(Context.Type, la, t); - goto case 525; - } - case 525: { - if (la == null) { currentState = 525; break; } - if (la.kind == 40) { - stateStack.Push(525); - goto case 443; - } else { - stateStack.Push(526); - goto case 37; - } - } - case 526: { - PopContext(); - goto case 23; - } - case 527: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(528); - goto case 205; - } - case 528: { - PopContext(); - goto case 529; - } - case 529: { - if (la == null) { currentState = 529; break; } - if (la.kind == 37 || la.kind == 63) { - if (la.kind == 63) { - currentState = 531; - break; - } else { - if (la.kind == 37) { - stateStack.Push(23); - goto case 424; - } else { - goto case 530; - } - } - } else { - goto case 23; - } - } - case 530: { - Error(la); - goto case 23; - } - case 531: { - PushContext(Context.Type, la, t); - stateStack.Push(532); - goto case 37; - } - case 532: { - PopContext(); - goto case 23; - } - case 533: { - PushContext(Context.TypeDeclaration, la, t); - goto case 534; - } - case 534: { - if (la == null) { currentState = 534; break; } - Expect(115, la); // "Enum" - currentState = 535; - break; - } - case 535: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(536); - goto case 205; - } - case 536: { - PopContext(); - goto case 537; - } - case 537: { - if (la == null) { currentState = 537; break; } - if (la.kind == 63) { - currentState = 549; - break; - } else { - goto case 538; - } - } - case 538: { - stateStack.Push(539); - goto case 23; - } - case 539: { - SetIdentifierExpected(la); - goto case 540; - } - case 540: { - if (la == null) { currentState = 540; break; } - if (set[97].Get(la.kind)) { - goto case 544; - } else { - Expect(113, la); // "End" - currentState = 541; - break; - } - } - case 541: { - if (la == null) { currentState = 541; break; } - Expect(115, la); // "Enum" - currentState = 542; - break; - } - case 542: { - stateStack.Push(543); - goto case 23; - } - case 543: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 544: { - SetIdentifierExpected(la); - goto case 545; - } - case 545: { - if (la == null) { currentState = 545; break; } - if (la.kind == 40) { - stateStack.Push(544); - goto case 443; - } else { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(546); - goto case 205; - } - } - case 546: { - PopContext(); - goto case 547; - } - case 547: { - if (la == null) { currentState = 547; break; } - if (la.kind == 20) { - currentState = 548; - break; - } else { - goto case 538; - } - } - case 548: { - stateStack.Push(538); - goto case 55; - } - case 549: { - PushContext(Context.Type, la, t); - stateStack.Push(550); - goto case 37; - } - case 550: { - PopContext(); - goto case 538; - } - case 551: { - if (la == null) { currentState = 551; break; } - Expect(103, la); // "Delegate" - currentState = 552; - break; - } - case 552: { - if (la == null) { currentState = 552; break; } - if (la.kind == 210) { - currentState = 553; - break; - } else { - if (la.kind == 127) { - currentState = 553; - break; - } else { - Error(la); - goto case 553; - } - } - } - case 553: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - goto case 554; - } - case 554: { - if (la == null) { currentState = 554; break; } - currentState = 555; - break; - } - case 555: { - PopContext(); - goto case 556; - } - case 556: { - if (la == null) { currentState = 556; break; } - if (la.kind == 37) { - currentState = 559; - break; - } else { - if (la.kind == 63) { - currentState = 557; - break; - } else { - goto case 23; - } - } - } - case 557: { - PushContext(Context.Type, la, t); - stateStack.Push(558); - goto case 37; - } - case 558: { - PopContext(); - goto case 23; - } - case 559: { - SetIdentifierExpected(la); - goto case 560; - } - case 560: { - if (la == null) { currentState = 560; break; } - if (set[152].Get(la.kind)) { - if (la.kind == 169) { - currentState = 562; - break; - } else { - if (set[77].Get(la.kind)) { - stateStack.Push(561); - goto case 428; - } else { - Error(la); - goto case 561; - } - } - } else { - goto case 561; - } - } - case 561: { - if (la == null) { currentState = 561; break; } - Expect(38, la); // ")" - currentState = 556; - break; - } - case 562: { - stateStack.Push(561); - goto case 500; - } - case 563: { - PushContext(Context.TypeDeclaration, la, t); - goto case 564; - } - case 564: { - if (la == null) { currentState = 564; break; } - if (la.kind == 155) { - currentState = 565; - break; - } else { - if (la.kind == 84) { - currentState = 565; - break; - } else { - if (la.kind == 209) { - currentState = 565; - break; - } else { - Error(la); - goto case 565; - } - } - } - } - case 565: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(566); - goto case 205; - } - case 566: { - PopContext(); - goto case 567; - } - case 567: { - if (la == null) { currentState = 567; break; } - if (la.kind == 37) { - currentState = 717; - break; - } else { - goto case 568; - } - } - case 568: { - stateStack.Push(569); - goto case 23; - } - case 569: { - SetIdentifierExpected(la); - isMissingModifier = true; - goto case 570; - } - case 570: { - if (la == null) { currentState = 570; break; } - if (la.kind == 140) { - isMissingModifier = false; - goto case 714; - } else { - goto case 571; - } - } - case 571: { - SetIdentifierExpected(la); - isMissingModifier = true; - goto case 572; - } - case 572: { - if (la == null) { currentState = 572; break; } - if (la.kind == 136) { - isMissingModifier = false; - goto case 708; - } else { - goto case 573; - } - } - case 573: { - SetIdentifierExpected(la); - isMissingModifier = true; - goto case 574; - } - case 574: { - if (la == null) { currentState = 574; break; } - if (set[101].Get(la.kind)) { - goto case 579; - } else { - isMissingModifier = false; - goto case 575; - } - } - case 575: { - if (la == null) { currentState = 575; break; } - Expect(113, la); // "End" - currentState = 576; - break; - } - case 576: { - if (la == null) { currentState = 576; break; } - if (la.kind == 155) { - currentState = 577; - break; - } else { - if (la.kind == 84) { - currentState = 577; - break; - } else { - if (la.kind == 209) { - currentState = 577; - break; - } else { - Error(la); - goto case 577; - } - } - } - } - case 577: { - stateStack.Push(578); - goto case 23; - } - case 578: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 579: { - SetIdentifierExpected(la); - isMissingModifier = true; - goto case 580; - } - case 580: { - if (la == null) { currentState = 580; break; } - if (la.kind == 40) { - stateStack.Push(579); - goto case 443; - } else { - isMissingModifier = true; - goto case 581; - } - } - case 581: { - SetIdentifierExpected(la); - goto case 582; - } - case 582: { - if (la == null) { currentState = 582; break; } - if (set[133].Get(la.kind)) { - currentState = 707; - break; - } else { - isMissingModifier = false; - SetIdentifierExpected(la); - goto case 583; - } - } - case 583: { - if (la == null) { currentState = 583; break; } - if (la.kind == 84 || la.kind == 155 || la.kind == 209) { - stateStack.Push(573); - goto case 563; - } else { - if (la.kind == 103) { - stateStack.Push(573); - goto case 551; - } else { - if (la.kind == 115) { - stateStack.Push(573); - goto case 533; - } else { - if (la.kind == 142) { - stateStack.Push(573); - goto case 9; - } else { - if (set[104].Get(la.kind)) { - stateStack.Push(573); - PushContext(Context.Member, la, t); - SetIdentifierExpected(la); - goto case 584; - } else { - Error(la); - goto case 573; - } - } - } - } - } - } - case 584: { - if (la == null) { currentState = 584; break; } - if (set[122].Get(la.kind)) { - stateStack.Push(585); - goto case 692; - } else { - if (la.kind == 127 || la.kind == 210) { - stateStack.Push(585); - goto case 674; - } else { - if (la.kind == 101) { - stateStack.Push(585); - goto case 661; - } else { - if (la.kind == 119) { - stateStack.Push(585); - goto case 649; - } else { - if (la.kind == 98) { - stateStack.Push(585); - goto case 637; - } else { - if (la.kind == 186) { - stateStack.Push(585); - goto case 600; - } else { - if (la.kind == 172) { - stateStack.Push(585); - goto case 586; - } else { - Error(la); - goto case 585; - } - } - } - } - } - } - } - } - case 585: { - PopContext(); - currentState = stateStack.Pop(); - goto switchlbl; - } - case 586: { - if (la == null) { currentState = 586; break; } - Expect(172, la); // "Operator" - currentState = 587; - break; - } - case 587: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - goto case 588; - } - case 588: { - if (la == null) { currentState = 588; break; } - currentState = 589; - break; - } - case 589: { - PopContext(); - goto case 590; - } - case 590: { - if (la == null) { currentState = 590; break; } - Expect(37, la); // "(" - currentState = 591; - break; - } - case 591: { - stateStack.Push(592); - goto case 428; - } - case 592: { - if (la == null) { currentState = 592; break; } - Expect(38, la); // ")" - currentState = 593; - break; - } - case 593: { - if (la == null) { currentState = 593; break; } - if (la.kind == 63) { - currentState = 597; - break; - } else { - goto case 594; - } - } - case 594: { - stateStack.Push(595); - goto case 259; - } - case 595: { - if (la == null) { currentState = 595; break; } - Expect(113, la); // "End" - currentState = 596; - break; - } - case 596: { - if (la == null) { currentState = 596; break; } - Expect(172, la); // "Operator" - currentState = 23; - break; - } - case 597: { - PushContext(Context.Type, la, t); - goto case 598; - } - case 598: { - if (la == null) { currentState = 598; break; } - if (la.kind == 40) { - stateStack.Push(598); - goto case 443; - } else { - stateStack.Push(599); - goto case 37; - } - } - case 599: { - PopContext(); - goto case 594; - } - case 600: { - if (la == null) { currentState = 600; break; } - Expect(186, la); // "Property" - currentState = 601; - break; - } - case 601: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(602); - goto case 205; - } - case 602: { - PopContext(); - goto case 603; - } - case 603: { - if (la == null) { currentState = 603; break; } - if (la.kind == 37) { - stateStack.Push(604); - goto case 424; - } else { - goto case 604; - } - } - case 604: { - if (la == null) { currentState = 604; break; } - if (la.kind == 63) { - currentState = 634; - break; - } else { - goto case 605; - } - } - case 605: { - if (la == null) { currentState = 605; break; } - if (la.kind == 136) { - currentState = 629; - break; - } else { - goto case 606; - } - } - case 606: { - if (la == null) { currentState = 606; break; } - if (la.kind == 20) { - currentState = 628; - break; - } else { - goto case 607; - } - } - case 607: { - stateStack.Push(608); - goto case 23; - } - case 608: { - PopContext(); - goto case 609; - } - case 609: { - if (la == null) { currentState = 609; break; } - if (la.kind == 40) { - stateStack.Push(609); - goto case 443; - } else { - goto case 610; - } - } - case 610: { - if (la == null) { currentState = 610; break; } - if (set[153].Get(la.kind)) { - currentState = 627; - break; - } else { - if (la.kind == 128 || la.kind == 198) { - PushContext(Context.Member, la, t); - goto case 611; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - } - case 611: { - if (la == null) { currentState = 611; break; } - if (la.kind == 128) { - currentState = 612; - break; - } else { - if (la.kind == 198) { - currentState = 612; - break; - } else { - Error(la); - goto case 612; - } - } - } - case 612: { - if (la == null) { currentState = 612; break; } - if (la.kind == 37) { - stateStack.Push(613); - goto case 424; - } else { - goto case 613; - } - } - case 613: { - stateStack.Push(614); - goto case 259; - } - case 614: { - if (la == null) { currentState = 614; break; } - Expect(113, la); // "End" - currentState = 615; - break; - } - case 615: { - if (la == null) { currentState = 615; break; } - if (la.kind == 128) { - currentState = 616; - break; - } else { - if (la.kind == 198) { - currentState = 616; - break; - } else { - Error(la); - goto case 616; - } - } - } - case 616: { - stateStack.Push(617); - goto case 23; - } - case 617: { - if (la == null) { currentState = 617; break; } - if (set[110].Get(la.kind)) { - goto case 620; - } else { - goto case 618; - } - } - case 618: { - if (la == null) { currentState = 618; break; } - Expect(113, la); // "End" - currentState = 619; - break; - } - case 619: { - if (la == null) { currentState = 619; break; } - Expect(186, la); // "Property" - currentState = 23; - break; - } - case 620: { - if (la == null) { currentState = 620; break; } - if (la.kind == 40) { - stateStack.Push(620); - goto case 443; - } else { - goto case 621; - } - } - case 621: { - if (la == null) { currentState = 621; break; } - if (set[153].Get(la.kind)) { - currentState = 621; - break; - } else { - if (la.kind == 128) { - currentState = 622; - break; - } else { - if (la.kind == 198) { - currentState = 622; - break; - } else { - Error(la); - goto case 622; - } - } - } - } - case 622: { - if (la == null) { currentState = 622; break; } - if (la.kind == 37) { - stateStack.Push(623); - goto case 424; - } else { - goto case 623; - } - } - case 623: { - stateStack.Push(624); - goto case 259; - } - case 624: { - if (la == null) { currentState = 624; break; } - Expect(113, la); // "End" - currentState = 625; - break; - } - case 625: { - if (la == null) { currentState = 625; break; } - if (la.kind == 128) { - currentState = 626; - break; - } else { - if (la.kind == 198) { - currentState = 626; - break; - } else { - Error(la); - goto case 626; - } - } - } - case 626: { - stateStack.Push(618); - goto case 23; - } - case 627: { - SetIdentifierExpected(la); - goto case 610; - } - case 628: { - stateStack.Push(607); - goto case 55; - } - case 629: { - PushContext(Context.Type, la, t); - stateStack.Push(630); - goto case 37; - } - case 630: { - PopContext(); - goto case 631; - } - case 631: { - if (la == null) { currentState = 631; break; } - if (la.kind == 22) { - currentState = 632; - break; - } else { - goto case 606; - } - } - case 632: { - PushContext(Context.Type, la, t); - stateStack.Push(633); - goto case 37; - } - case 633: { - PopContext(); - goto case 631; - } - case 634: { - PushContext(Context.Type, la, t); - goto case 635; - } - case 635: { - if (la == null) { currentState = 635; break; } - if (la.kind == 40) { - stateStack.Push(635); - goto case 443; - } else { - if (la.kind == 162) { - stateStack.Push(636); - goto case 85; - } else { - if (set[16].Get(la.kind)) { - stateStack.Push(636); - goto case 37; - } else { - Error(la); - goto case 636; - } - } - } - } - case 636: { - PopContext(); - goto case 605; - } - case 637: { - if (la == null) { currentState = 637; break; } - Expect(98, la); // "Custom" - currentState = 638; - break; - } - case 638: { - stateStack.Push(639); - goto case 649; - } - case 639: { - if (la == null) { currentState = 639; break; } - if (set[115].Get(la.kind)) { - goto case 641; - } else { - Expect(113, la); // "End" - currentState = 640; - break; - } - } - case 640: { - if (la == null) { currentState = 640; break; } - Expect(119, la); // "Event" - currentState = 23; - break; - } - case 641: { - if (la == null) { currentState = 641; break; } - if (la.kind == 40) { - stateStack.Push(641); - goto case 443; - } else { - if (la.kind == 56) { - currentState = 642; - break; - } else { - if (la.kind == 193) { - currentState = 642; - break; - } else { - if (la.kind == 189) { - currentState = 642; - break; - } else { - Error(la); - goto case 642; - } - } - } - } - } - case 642: { - if (la == null) { currentState = 642; break; } - Expect(37, la); // "(" - currentState = 643; - break; - } - case 643: { - stateStack.Push(644); - goto case 428; - } - case 644: { - if (la == null) { currentState = 644; break; } - Expect(38, la); // ")" - currentState = 645; - break; - } - case 645: { - stateStack.Push(646); - goto case 259; - } - case 646: { - if (la == null) { currentState = 646; break; } - Expect(113, la); // "End" - currentState = 647; - break; - } - case 647: { - if (la == null) { currentState = 647; break; } - if (la.kind == 56) { - currentState = 648; - break; - } else { - if (la.kind == 193) { - currentState = 648; - break; - } else { - if (la.kind == 189) { - currentState = 648; - break; - } else { - Error(la); - goto case 648; - } - } - } - } - case 648: { - stateStack.Push(639); - goto case 23; - } - case 649: { - if (la == null) { currentState = 649; break; } - Expect(119, la); // "Event" - currentState = 650; - break; - } - case 650: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(651); - goto case 205; - } - case 651: { - PopContext(); - goto case 652; - } - case 652: { - if (la == null) { currentState = 652; break; } - if (la.kind == 63) { - currentState = 659; - break; - } else { - if (set[154].Get(la.kind)) { - if (la.kind == 37) { - stateStack.Push(653); - goto case 424; - } else { - goto case 653; - } - } else { - Error(la); - goto case 653; - } - } - } - case 653: { - if (la == null) { currentState = 653; break; } - if (la.kind == 136) { - currentState = 654; - break; - } else { - goto case 23; - } - } - case 654: { - PushContext(Context.Type, la, t); - stateStack.Push(655); - goto case 37; - } - case 655: { - PopContext(); - goto case 656; - } - case 656: { - if (la == null) { currentState = 656; break; } - if (la.kind == 22) { - currentState = 657; - break; - } else { - goto case 23; - } - } - case 657: { - PushContext(Context.Type, la, t); - stateStack.Push(658); - goto case 37; - } - case 658: { - PopContext(); - goto case 656; - } - case 659: { - PushContext(Context.Type, la, t); - stateStack.Push(660); - goto case 37; - } - case 660: { - PopContext(); - goto case 653; - } - case 661: { - if (la == null) { currentState = 661; break; } - Expect(101, la); // "Declare" - currentState = 662; - break; - } - case 662: { - if (la == null) { currentState = 662; break; } - if (la.kind == 62 || la.kind == 66 || la.kind == 223) { - currentState = 663; - break; - } else { - goto case 663; - } - } - case 663: { - if (la == null) { currentState = 663; break; } - if (la.kind == 210) { - currentState = 664; - break; - } else { - if (la.kind == 127) { - currentState = 664; - break; - } else { - Error(la); - goto case 664; - } - } - } - case 664: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(665); - goto case 205; - } - case 665: { - PopContext(); - goto case 666; - } - case 666: { - if (la == null) { currentState = 666; break; } - Expect(149, la); // "Lib" - currentState = 667; - break; - } - case 667: { - if (la == null) { currentState = 667; break; } - Expect(3, la); // LiteralString - currentState = 668; - break; - } - case 668: { - if (la == null) { currentState = 668; break; } - if (la.kind == 59) { - currentState = 673; - break; - } else { - goto case 669; - } - } - case 669: { - if (la == null) { currentState = 669; break; } - if (la.kind == 37) { - stateStack.Push(670); - goto case 424; - } else { - goto case 670; - } - } - case 670: { - if (la == null) { currentState = 670; break; } - if (la.kind == 63) { - currentState = 671; - break; - } else { - goto case 23; - } - } - case 671: { - PushContext(Context.Type, la, t); - stateStack.Push(672); - goto case 37; - } - case 672: { - PopContext(); - goto case 23; - } - case 673: { - if (la == null) { currentState = 673; break; } - Expect(3, la); // LiteralString - currentState = 669; - break; - } - case 674: { - if (la == null) { currentState = 674; break; } - if (la.kind == 210) { - currentState = 675; - break; - } else { - if (la.kind == 127) { - currentState = 675; - break; - } else { - Error(la); - goto case 675; - } - } - } - case 675: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - goto case 676; - } - case 676: { - if (la == null) { currentState = 676; break; } - currentState = 677; - break; - } - case 677: { - PopContext(); - goto case 678; - } - case 678: { - if (la == null) { currentState = 678; break; } - if (la.kind == 37) { - currentState = 688; - break; - } else { - if (la.kind == 63) { - currentState = 686; - break; - } else { - goto case 679; - } - } - } - case 679: { - if (la == null) { currentState = 679; break; } - if (la.kind == 134 || la.kind == 136) { - currentState = 683; - break; - } else { - goto case 680; - } - } - case 680: { - stateStack.Push(681); - goto case 259; - } - case 681: { - if (la == null) { currentState = 681; break; } - Expect(113, la); // "End" - currentState = 682; - break; - } - case 682: { - if (la == null) { currentState = 682; break; } - if (la.kind == 210) { - currentState = 23; - break; - } else { - if (la.kind == 127) { - currentState = 23; - break; - } else { - goto case 530; - } - } - } - case 683: { - if (la == null) { currentState = 683; break; } - if (la.kind == 153 || la.kind == 158 || la.kind == 159) { - currentState = 685; - break; - } else { - goto case 684; - } - } - case 684: { - stateStack.Push(680); - goto case 37; - } - case 685: { - if (la == null) { currentState = 685; break; } - Expect(26, la); // "." - currentState = 684; - break; - } - case 686: { - PushContext(Context.Type, la, t); - stateStack.Push(687); - goto case 37; - } - case 687: { - PopContext(); - goto case 679; - } - case 688: { - SetIdentifierExpected(la); - goto case 689; - } - case 689: { - if (la == null) { currentState = 689; break; } - if (set[152].Get(la.kind)) { - if (la.kind == 169) { - currentState = 691; - break; - } else { - if (set[77].Get(la.kind)) { - stateStack.Push(690); - goto case 428; - } else { - Error(la); - goto case 690; - } - } - } else { - goto case 690; - } - } - case 690: { - if (la == null) { currentState = 690; break; } - Expect(38, la); // ")" - currentState = 678; - break; - } - case 691: { - stateStack.Push(690); - goto case 500; - } - case 692: { - stateStack.Push(693); - SetIdentifierExpected(la); - goto case 694; - } - case 693: { - if (la == null) { currentState = 693; break; } - if (la.kind == 22) { - currentState = 692; - break; - } else { - goto case 23; - } - } - case 694: { - if (la == null) { currentState = 694; break; } - if (la.kind == 88) { - currentState = 695; - break; - } else { - goto case 695; - } - } - case 695: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - stateStack.Push(696); - goto case 706; - } - case 696: { - PopContext(); - goto case 697; - } - case 697: { - if (la == null) { currentState = 697; break; } - if (la.kind == 33) { - currentState = 698; - break; - } else { - goto case 698; - } - } - case 698: { - if (la == null) { currentState = 698; break; } - if (la.kind == 37) { - currentState = 703; - break; - } else { - if (la.kind == 63) { - currentState = 700; - break; - } else { - goto case 699; - } - } - } - case 699: { - if (la == null) { currentState = 699; break; } - if (la.kind == 20) { - currentState = 55; - break; - } else { - currentState = stateStack.Pop(); - goto switchlbl; - } - } - case 700: { - PushContext(Context.Type, la, t); - goto case 701; - } - case 701: { - if (la == null) { currentState = 701; break; } - if (la.kind == 162) { - stateStack.Push(702); - goto case 85; - } else { - if (set[16].Get(la.kind)) { - stateStack.Push(702); - goto case 37; - } else { - Error(la); - goto case 702; - } - } - } - case 702: { - PopContext(); - goto case 699; - } - case 703: { - nextTokenIsPotentialStartOfExpression = true; - goto case 704; - } - case 704: { - if (la == null) { currentState = 704; break; } - if (set[23].Get(la.kind)) { - stateStack.Push(705); - goto case 55; - } else { - goto case 705; - } - } - case 705: { - if (la == null) { currentState = 705; break; } - if (la.kind == 22) { - currentState = 703; - break; - } else { - Expect(38, la); // ")" - currentState = 698; - break; - } - } - case 706: { - if (la == null) { currentState = 706; break; } - if (set[138].Get(la.kind)) { - currentState = stateStack.Pop(); - break; - } else { - if (la.kind == 58) { - goto case 144; - } else { - if (la.kind == 126) { - goto case 128; - } else { - goto case 6; - } - } - } - } - case 707: { - isMissingModifier = false; - goto case 581; - } - case 708: { - if (la == null) { currentState = 708; break; } - Expect(136, la); // "Implements" - currentState = 709; - break; - } - case 709: { - PushContext(Context.Type, la, t); - stateStack.Push(710); - goto case 37; - } - case 710: { - PopContext(); - goto case 711; - } - case 711: { - if (la == null) { currentState = 711; break; } - if (la.kind == 22) { - currentState = 712; - break; - } else { - stateStack.Push(573); - goto case 23; - } - } - case 712: { - PushContext(Context.Type, la, t); - stateStack.Push(713); - goto case 37; - } - case 713: { - PopContext(); - goto case 711; - } - case 714: { - if (la == null) { currentState = 714; break; } - Expect(140, la); // "Inherits" - currentState = 715; - break; - } - case 715: { - PushContext(Context.Type, la, t); - stateStack.Push(716); - goto case 37; - } - case 716: { - PopContext(); - stateStack.Push(571); - goto case 23; - } - case 717: { - if (la == null) { currentState = 717; break; } - Expect(169, la); // "Of" - currentState = 718; - break; - } - case 718: { - stateStack.Push(719); - goto case 500; - } - case 719: { - if (la == null) { currentState = 719; break; } - Expect(38, la); // ")" - currentState = 568; - break; - } - case 720: { - isMissingModifier = false; - goto case 28; - } - case 721: { - PushContext(Context.Type, la, t); - stateStack.Push(722); - goto case 37; - } - case 722: { - PopContext(); - goto case 723; - } - case 723: { - if (la == null) { currentState = 723; break; } - if (la.kind == 22) { - currentState = 724; - break; - } else { - stateStack.Push(17); - goto case 23; - } - } - case 724: { - PushContext(Context.Type, la, t); - stateStack.Push(725); - goto case 37; - } - case 725: { - PopContext(); - goto case 723; - } - case 726: { - if (la == null) { currentState = 726; break; } - Expect(169, la); // "Of" - currentState = 727; - break; - } - case 727: { - stateStack.Push(728); - goto case 500; - } - case 728: { - if (la == null) { currentState = 728; break; } - Expect(38, la); // ")" - currentState = 14; - break; - } - case 729: { - PushContext(Context.Identifier, la, t); - SetIdentifierExpected(la); - goto case 730; - } - case 730: { - if (la == null) { currentState = 730; break; } - if (set[49].Get(la.kind)) { - currentState = 730; - break; - } else { - PopContext(); - stateStack.Push(731); - goto case 23; - } - } - case 731: { - if (la == null) { currentState = 731; break; } - if (set[3].Get(la.kind)) { - stateStack.Push(731); - goto case 5; - } else { - Expect(113, la); // "End" - currentState = 732; - break; - } - } - case 732: { - if (la == null) { currentState = 732; break; } - Expect(160, la); // "Namespace" - currentState = 23; - break; - } - case 733: { - if (la == null) { currentState = 733; break; } - Expect(137, la); // "Imports" - currentState = 734; - break; - } - case 734: { - PushContext(Context.Importable, la, t); - nextTokenIsStartOfImportsOrAccessExpression = true; - goto case 735; - } - case 735: { - if (la == null) { currentState = 735; break; } - if (set[155].Get(la.kind)) { - currentState = 747; - break; - } else { - goto case 736; - } - } - case 736: { - if (la == null) { currentState = 736; break; } - if (la.kind == 10) { - currentState = 743; - break; - } else { - Error(la); - goto case 737; - } - } - case 737: { - if (la == null) { currentState = 737; break; } - if (la.kind == 22) { - currentState = 738; - break; - } else { - PopContext(); - goto case 23; - } - } - case 738: { - nextTokenIsStartOfImportsOrAccessExpression = true; - goto case 739; - } - case 739: { - if (la == null) { currentState = 739; break; } - if (set[155].Get(la.kind)) { - currentState = 740; - break; - } else { - goto case 736; - } - } - case 740: { - if (la == null) { currentState = 740; break; } - if (la.kind == 37) { - stateStack.Push(740); - goto case 42; - } else { - goto case 741; - } - } - case 741: { - if (la == null) { currentState = 741; break; } - if (la.kind == 20 || la.kind == 26) { - currentState = 742; - break; - } else { - goto case 737; - } - } - case 742: { - stateStack.Push(737); - goto case 37; - } - case 743: { - stateStack.Push(744); - goto case 205; - } - case 744: { - if (la == null) { currentState = 744; break; } - Expect(20, la); // "=" - currentState = 745; - break; - } - case 745: { - if (la == null) { currentState = 745; break; } - Expect(3, la); // LiteralString - currentState = 746; - break; - } - case 746: { - if (la == null) { currentState = 746; break; } - Expect(11, la); // XmlCloseTag - currentState = 737; - break; - } - case 747: { - if (la == null) { currentState = 747; break; } - if (la.kind == 37) { - stateStack.Push(747); - goto case 42; - } else { - goto case 741; - } - } - case 748: { - if (la == null) { currentState = 748; break; } - Expect(173, la); // "Option" - currentState = 749; - break; - } - case 749: { - if (la == null) { currentState = 749; break; } - if (la.kind == 121 || la.kind == 139 || la.kind == 207) { - currentState = 751; - break; - } else { - if (la.kind == 87) { - currentState = 750; - break; - } else { - goto case 530; - } - } - } - case 750: { - if (la == null) { currentState = 750; break; } - if (la.kind == 213) { - currentState = 23; - break; - } else { - if (la.kind == 67) { - currentState = 23; - break; - } else { - goto case 530; - } - } - } - case 751: { - if (la == null) { currentState = 751; break; } - if (la.kind == 170 || la.kind == 171) { - currentState = 23; - break; - } else { - goto case 23; - } - } - } - - if (la != null) { - t = la; - nextTokenIsPotentialStartOfExpression = false; - readXmlIdentifier = false; - nextTokenIsStartOfImportsOrAccessExpression = false; - wasQualifierTokenAtStart = false; - identifierExpected = false; - } - } - - public void Advance() - { - //Console.WriteLine("Advance"); - InformToken(null); - } - - public BitArray GetExpectedSet() { return GetExpectedSet(currentState); } - - static readonly BitArray[] set = { - new BitArray(new int[] {1, 256, 1048576, 537395328, 402670080, 444604481, 131200, 0}), - new BitArray(new int[] {1, 256, 1048576, 537395328, 402670080, 444596289, 131200, 0}), - new BitArray(new int[] {1, 256, 1048576, 537395328, 402669568, 444596289, 131200, 0}), - new BitArray(new int[] {0, 256, 1048576, 537395328, 402669568, 444596289, 131200, 0}), - new BitArray(new int[] {0, 256, 1048576, 537395328, 402669568, 444596288, 131200, 0}), - new BitArray(new int[] {0, 0, 1048576, 537395328, 402669568, 444596288, 131200, 0}), - new BitArray(new int[] {4, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {0, 256, 1048576, -1601568064, 671109120, 1589117122, 393600, 3328}), - new BitArray(new int[] {0, 256, 1048576, -1601568064, 671105024, 1589117122, 393600, 3328}), - new BitArray(new int[] {5, 1140850944, 26214479, -493220892, 940361760, 1606227139, -2143942272, 3393}), - new BitArray(new int[] {0, 256, 1048576, -1601699136, 671105024, 1589117122, 393600, 3328}), - new BitArray(new int[] {0, 0, 1048576, -1601699136, 671105024, 1589117122, 393600, 3328}), - new BitArray(new int[] {0, 0, 1048576, -2138570624, 134234112, 67108864, 393216, 0}), - new BitArray(new int[] {0, 0, 0, -2139095040, 0, 67108864, 262144, 0}), - new BitArray(new int[] {-2, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {2097154, -2147483616, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), - new BitArray(new int[] {-940564478, 889192445, 65, 1074825472, 72844640, 231424, 22030368, 4704}), - new BitArray(new int[] {-940564478, 889192413, 65, 1074825472, 72844640, 231424, 22030368, 4704}), - new BitArray(new int[] {4, -16777216, -1, -1, -1, -1, -1, 16383}), - new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106740, -97186288, 8259}), - new BitArray(new int[] {-61995012, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {-61995012, 1174405224, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {-1007673342, 889192405, 65, 1074825472, 72843296, 231424, 22030368, 4160}), - new BitArray(new int[] {-1013972992, 822083461, 0, 0, 71499776, 163840, 16777216, 4096}), - new BitArray(new int[] {-66189316, 1174405176, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106176, -533656048, 579}), - new BitArray(new int[] {-1007673342, 889192405, 65, 1074825472, 72843552, 231424, 22030368, 4160}), - new BitArray(new int[] {-1007673342, 889192413, 65, 1074825472, 72843552, 231424, 22030368, 4672}), - new BitArray(new int[] {-2, -9, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-1040382, 889192437, 65, 1074825472, 72843296, 231424, 22030368, 4160}), - new BitArray(new int[] {1006632960, 32, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {1028, -16777216, -1, -1, -1, -1, -1, 16383}), - new BitArray(new int[] {-1038334, -1258291211, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {1007552508, 1140850720, -51384097, -972018405, -1030969182, 17106208, -365621744, 8259}), - new BitArray(new int[] {-1040382, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {0, 0, -60035072, 1027, 0, 0, 134217728, 0}), - new BitArray(new int[] {0, 67108864, 0, 1073743872, 1310752, 65536, 1050656, 64}), - new BitArray(new int[] {4194304, 67108864, 0, 1073743872, 1343520, 65536, 1050656, 64}), - new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018401, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {4194304, 67108864, 64, 1073743872, 1343520, 65536, 1050656, 64}), - new BitArray(new int[] {66189314, -1174405161, 51384096, 972018404, 1030969181, -17106229, 97186287, -8260}), - new BitArray(new int[] {65140738, 973078487, 51384096, 972018404, 1030969181, -17106229, 97186287, -8260}), - new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969182, 17106228, -97186288, 8387}), - new BitArray(new int[] {0, 67108864, 0, 1073743872, 1343520, 65536, 1050656, 64}), - new BitArray(new int[] {-64092162, -973078488, -51384097, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {-64092162, 1191182376, -1048865, -546062565, -1014191950, -1593504452, -21144002, 8903}), - new BitArray(new int[] {0, 0, 3072, 134447104, 16777216, 8, 0, 0}), - new BitArray(new int[] {-2097156, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-66189316, 1191182376, -1051937, -680509669, -1030969166, -1593504460, -21144002, 8903}), - new BitArray(new int[] {-66189316, 1174405162, -51384097, -972018401, -1030969178, 17106228, -97186288, 8259}), - new BitArray(new int[] {6291458, 0, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {-64092162, 1174405160, -51384097, -971985637, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {0, 0, 0, -1879044096, 0, 67108864, 67371040, 128}), - new BitArray(new int[] {36, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {2097158, 1140850688, 8388687, 1108347140, 821280, 17105920, -2144335872, 97}), - new BitArray(new int[] {2097154, -2147483648, 0, 0, 0, 0, 0, 32}), - new BitArray(new int[] {36, 1140850688, 8388687, 1108347140, 821280, 17105928, -2144335872, 65}), - new BitArray(new int[] {-66189316, 1174405160, -51384097, -972018405, -1030969166, 17106228, -97186284, 8259}), - new BitArray(new int[] {1007552508, 1140850720, -51384097, -972002021, -1030969182, 17106208, -365621744, 8259}), - new BitArray(new int[] {1007681536, -2147483614, 0, 0, 1024, 0, 0, 0}), - new BitArray(new int[] {1007681536, -2147483616, 0, 0, 1024, 0, 0, 0}), - new BitArray(new int[] {2097154, 0, 0, 0, 0, 0, 0, 129}), - new BitArray(new int[] {2097154, 0, 0, 32768, 0, 0, 0, 129}), - new BitArray(new int[] {-66189316, 1174405160, -51383073, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {-65140740, 1174409128, -51384097, -971985637, -1030903646, 17106228, -97186288, 8259}), - new BitArray(new int[] {-65140740, 1174409128, -51384097, -972018405, -1030903646, 17106228, -97186288, 8259}), - new BitArray(new int[] {1048576, 3968, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {-64092162, 1191182376, -1051937, -680509669, -1030969166, -1593504460, -21144002, 8903}), - new BitArray(new int[] {-64092162, 1191182376, -1051937, -680476901, -1030969166, -1593504460, -21144002, 8903}), - new BitArray(new int[] {2097154, 32, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {7340034, -2147483614, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {7340034, -2147483616, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {7340034, 0, 0, 32768, 0, 0, 0, 0}), - new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, 9218084, 17106180, -533656048, 67}), - new BitArray(new int[] {4, 1140851008, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), - new BitArray(new int[] {4, 1140850944, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), - new BitArray(new int[] {4, 1140850688, 8388975, 1108347140, 821280, 21316608, -2144335872, 65}), - new BitArray(new int[] {5242880, -2147483550, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {5242880, -2147483552, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {-2, -1, -3, -1, -134217729, -1, -1, -1}), - new BitArray(new int[] {7, 1157628162, 26477055, -493212676, 948758565, 2147308999, -533262382, 3395}), - new BitArray(new int[] {918528, 0, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {-909310, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {-843774, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {-318462, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {-383998, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {-1038334, -1258291209, 65, 1074825472, 72844320, 231424, 22030368, 4160}), - new BitArray(new int[] {4194308, 1140850754, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), - new BitArray(new int[] {4, 1140851008, 8388975, 1108347140, 821280, 21317120, -2144335872, 65}), - new BitArray(new int[] {4, 1073741824, 8388687, 34605312, 822304, 17105920, -2144335872, 65}), - new BitArray(new int[] {4, 1073741824, 8388687, 34605312, 821280, 16843776, -2144335872, 65}), - new BitArray(new int[] {4, 1140850698, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}), - new BitArray(new int[] {4, 1140850690, 9699551, 1108355356, 9218084, 17106180, -533524976, 67}), - new BitArray(new int[] {4, 1140850946, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), - new BitArray(new int[] {4, 1140850944, 8388687, 1108478212, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {4, 1140850944, 8388687, 1108347140, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671930656, 1606227138, -2143942272, 3393}), - new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671926560, 1606227138, -2143942272, 3393}), - new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671926304, 1606227138, -2143942272, 3393}), - new BitArray(new int[] {4, 1140850944, 26214479, -493351964, 671926304, 1606227138, -2143942272, 3393}), - new BitArray(new int[] {4, 1140850688, 26214479, -493351964, 671926304, 1606227138, -2143942272, 3393}), - new BitArray(new int[] {4, 1140850688, 26214479, -1030223452, 135055392, 84218880, -2143942656, 65}), - new BitArray(new int[] {4, 1140850688, 25165903, -1030747868, 821280, 84218880, -2144073728, 65}), - new BitArray(new int[] {3145730, -2147483616, 0, 0, 256, 0, 0, 0}), - new BitArray(new int[] {3145730, -2147483648, 0, 0, 256, 0, 0, 0}), - new BitArray(new int[] {3145730, 0, 0, 0, 256, 0, 0, 0}), - new BitArray(new int[] {4, 1140850944, 26214479, -493220892, 671926305, 1606227138, -2143942208, 3393}), - new BitArray(new int[] {0, 256, 0, 537001984, 1, 436207616, 64, 0}), - new BitArray(new int[] {0, 256, 0, 536870912, 1, 436207616, 64, 0}), - new BitArray(new int[] {0, 0, 0, 536870912, 1, 436207616, 64, 0}), - new BitArray(new int[] {7340034, 0, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {4, 1140850946, 8650975, 1108355356, 9218084, 17106180, -533656048, 67}), - new BitArray(new int[] {0, 16777472, 0, 131072, 0, 536870912, 2, 0}), - new BitArray(new int[] {0, 16777472, 0, 0, 0, 536870912, 2, 0}), - new BitArray(new int[] {2097154, -2147483616, 0, 0, 256, 0, 0, 0}), - new BitArray(new int[] {0, 1073741824, 4, -2147483648, 0, 0, -2147221504, 0}), - new BitArray(new int[] {2097154, -2013265888, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {2097154, -2147483616, 0, 0, 320, 0, 0, 0}), - new BitArray(new int[] {2097154, 0, 0, 0, 320, 0, 0, 0}), - new BitArray(new int[] {4, 1140850690, 8650975, 1108355356, -1030969308, 17106176, -533656048, 67}), - new BitArray(new int[] {4, 1140850688, 25165903, 1108347136, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {4, 1140850688, 8388687, 1108347136, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {7340034, -2147483614, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {7340034, -2147483616, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {0, 256, 1048576, 537526400, 402669568, 444596289, 131200, 0}), - new BitArray(new int[] {1028, 1140850688, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}), - new BitArray(new int[] {74448898, 32, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {74448898, 0, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {0, 0, 8388608, 33554432, 2048, 0, 32768, 0}), - new BitArray(new int[] {2097154, 0, 0, 0, 0, 3072, 0, 0}), - new BitArray(new int[] {0, 0, 0, 536870912, 268435456, 444596288, 128, 0}), - new BitArray(new int[] {0, 0, 0, 536871488, 536870912, 1522008258, 384, 3328}), - new BitArray(new int[] {0, 0, 262288, 8216, 8396800, 256, 1610679824, 2}), - new BitArray(new int[] {-1073741824, 33554432, 0, 0, 0, 16, 0, 0}), - new BitArray(new int[] {1006632960, 0, 0, 0, 0, 0, 0, 0}), - new BitArray(new int[] {1016, 0, 0, 67108864, -1040187392, 32, 33554432, 0}), - new BitArray(new int[] {4, 1073741824, 8388687, 34605312, 821280, 17105920, -2144335872, 65}), - new BitArray(new int[] {0, 0, -1133776896, 3, 0, 0, 0, 0}), - new BitArray(new int[] {-64092162, 1191182376, -1051937, -680378597, -1030969166, -1593504460, -21144002, 8903}), - new BitArray(new int[] {0, 0, 33554432, 16777216, 16, 0, 16392, 0}), - new BitArray(new int[] {-66189316, 1174405160, -51383585, -972018405, -1030969182, 17106228, -97186288, 8259}), - new BitArray(new int[] {1048576, 3968, 0, 0, 65536, 0, 0, 0}), - new BitArray(new int[] {0, 0, 288, 0, 0, 4210688, 0, 0}), - new BitArray(new int[] {-2, -129, -3, -1, -134217729, -1, -1, -1}), - new BitArray(new int[] {-18434, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-22530, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-32770, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-37890, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-2050, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {-6146, -1, -1, -1, -1, -1, -1, -1}), - new BitArray(new int[] {4, 1140850944, 8388975, 1108347140, 821280, 21317120, -2144335872, 65}), - new BitArray(new int[] {0, 0, 0, 536870912, 0, 436207616, 0, 0}), - new BitArray(new int[] {2097154, 32, 0, 0, 256, 0, 0, 0}), - new BitArray(new int[] {4, 1140850688, 8650975, 1108355356, 9218084, 17106176, -533656048, 67}) - - }; - -} // end Parser - - -} \ No newline at end of file diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame deleted file mode 100644 index 1bf369d5e..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/PushParser.frame +++ /dev/null @@ -1,100 +0,0 @@ -/*---------------------------------------------------------------------- -Compiler Generator Coco/R, -Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz -extended by M. Loeberbauer & A. Woess, Univ. of Linz -with improvements by Pat Terry, Rhodes University - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -As an exception, it is allowed to write an extension of Coco/R that is -used as a plugin in non-free software. - -If not otherwise stated, any source code generated by Coco/R (other than -Coco/R itself) does not fall under the GNU General Public License. -----------------------------------------------------------------------*/ --->begin --->namespace - -partial class ExpressionFinder { --->constants - const bool T = true; - const bool x = false; - --->declarations - readonly Stack stateStack = new Stack(); - bool wasQualifierTokenAtStart = false; - bool nextTokenIsPotentialStartOfExpression = false; - bool readXmlIdentifier = false; - bool identifierExpected = false; - bool nextTokenIsStartOfImportsOrAccessExpression = false; - bool isMissingModifier = false; - bool isAlreadyInExpr = false; - bool wasNormalAttribute = false; - int lambdaNestingDepth = 0; - int activeArgument = 0; - List errors = new List(); - - public ExpressionFinder() - { - stateStack.Push(-1); // required so that we don't crash when leaving the root production - } - - void Expect(int expectedKind, Token la) - { - if (la.kind != expectedKind) { - Error(la); - output.AppendLine("expected: " + expectedKind); - //Console.WriteLine("expected: " + expectedKind); - } - } - - void Error(Token la) - { - output.AppendLine("not expected: " + la); - //Console.WriteLine("not expected: " + la); - errors.Add(la); - } - - Token t; - - public void InformToken(Token la) - { - -->informToken - if (la != null) { - t = la; - nextTokenIsPotentialStartOfExpression = false; - readXmlIdentifier = false; - nextTokenIsStartOfImportsOrAccessExpression = false; - wasQualifierTokenAtStart = false; - identifierExpected = false; - } - } - - public void Advance() - { - //Console.WriteLine("Advance"); - InformToken(null); - } - - public BitArray GetExpectedSet() { return GetExpectedSet(currentState); } - - static readonly BitArray[] set = { --->initialization - }; - -} // end Parser - - -$$$ \ No newline at end of file diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/SavepointEventArgs.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/SavepointEventArgs.cs deleted file mode 100644 index c599ca7f5..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/SavepointEventArgs.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public class SavepointEventArgs : EventArgs - { - public TextLocation SavepointLocation { get; private set; } - public VBLexerMemento State { get; private set; } - - public SavepointEventArgs(TextLocation savepointLocation, VBLexerMemento state) - { - this.SavepointLocation = savepointLocation; - this.State = state; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/BlankLine.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/BlankLine.cs deleted file mode 100644 index 5821ca6a9..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/BlankLine.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB -{ -// public class BlankLine : AbstractSpecial -// { -// public BlankLine(Location point) : base(point) -// { -// } -// -// public override object AcceptVisitor(ISpecialVisitor visitor, object data) -// { -// return visitor.Visit(this, data); -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/Comment.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/Comment.cs deleted file mode 100644 index ecfc393fa..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/Comment.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB -{ -// public class Comment : AbstractSpecial -// { -// CommentType commentType; -// string comment; -// -// public CommentType CommentType { -// get { -// return commentType; -// } -// set { -// commentType = value; -// } -// } -// -// public string CommentText { -// get { -// return comment; -// } -// set { -// comment = value; -// } -// } -// -// /// -// /// Is true, when the comment is at line start or only whitespaces -// /// between line and comment start. -// /// -// public bool CommentStartsLine { -// get; -// set; -// } -// -// public Comment(CommentType commentType, string comment, bool commentStartsLine, Location startPosition, Location endPosition) -// : base(startPosition, endPosition) -// { -// this.commentType = commentType; -// this.comment = comment; -// this.CommentStartsLine = commentStartsLine; -// } -// -// public override string ToString() -// { -// return String.Format("[{0}: Type = {1}, Text = {2}, Start = {3}, End = {4}]", -// GetType().Name, CommentType, CommentText, StartPosition, EndPosition); -// } -// -// public override object AcceptVisitor(ISpecialVisitor visitor, object data) -// { -// return visitor.Visit(this, data); -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/CommentType.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/CommentType.cs deleted file mode 100644 index 7eac974d5..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/CommentType.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB -{ -// public enum CommentType -// { -// Block, -// SingleLine, -// Documentation -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/ISpecial.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/ISpecial.cs deleted file mode 100644 index 52c1abb37..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/ISpecial.cs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB -{ -// /// -// /// Interface for all specials. -// /// -// public interface ISpecial -// { -// Location StartPosition { get; } -// Location EndPosition { get; } -// -// object AcceptVisitor(ISpecialVisitor visitor, object data); -// } -// -// public interface ISpecialVisitor -// { -// object Visit(ISpecial special, object data); -// object Visit(BlankLine special, object data); -// object Visit(Comment special, object data); -// object Visit(PreprocessingDirective special, object data); -// } -// -// public abstract class AbstractSpecial : ISpecial -// { -// public abstract object AcceptVisitor(ISpecialVisitor visitor, object data); -// -// protected AbstractSpecial(Location position) -// { -// this.StartPosition = position; -// this.EndPosition = position; -// } -// -// protected AbstractSpecial(Location startPosition, Location endPosition) -// { -// this.StartPosition = startPosition; -// this.EndPosition = endPosition; -// } -// -// public Location StartPosition { get; set; } -// public Location EndPosition { get; set; } -// -// public override string ToString() -// { -// return String.Format("[{0}: Start = {1}, End = {2}]", -// GetType().Name, StartPosition, EndPosition); -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs deleted file mode 100644 index 4b9222190..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/PreProcessingDirective.cs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB -{ -// public class PreprocessingDirective : AbstractSpecial -// { -// #region Conversion C# <-> VB -// public static void VBToCSharp(IList list) -// { -// for (int i = 0; i < list.Count; ++i) { -// if (list[i] is PreprocessingDirective) -// list[i] = VBToCSharp((PreprocessingDirective)list[i]); -// } -// } -// -// public static PreprocessingDirective VBToCSharp(PreprocessingDirective dir) -// { -// string cmd = dir.Cmd; -// string arg = dir.Arg; -// if (cmd.Equals("#End", StringComparison.InvariantCultureIgnoreCase)) { -// if (arg.ToLowerInvariant().StartsWith("region")) { -// cmd = "#endregion"; -// arg = ""; -// } else if ("if".Equals(arg, StringComparison.InvariantCultureIgnoreCase)) { -// cmd = "#endif"; -// arg = ""; -// } -// } else if (cmd.Equals("#Region", StringComparison.InvariantCultureIgnoreCase)) { -// cmd = "#region"; -// } else if (cmd.Equals("#If", StringComparison.InvariantCultureIgnoreCase)) { -// cmd = "#if"; -// if (arg.ToLowerInvariant().EndsWith(" then")) -// arg = arg.Substring(0, arg.Length - 5); -// } else if (cmd.Equals("#Else", StringComparison.InvariantCultureIgnoreCase)) { -// if (dir.Expression != null) -// cmd = "#elif"; -// else -// cmd = "#else"; -// } else if (cmd.Equals("#ElseIf", StringComparison.InvariantCultureIgnoreCase)) { -// cmd = "#elif"; -// } -// return new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition) { -// Expression = dir.Expression -// }; -// } -// -// public static void CSharpToVB(List list) -// { -// for (int i = 0; i < list.Count; ++i) { -// if (list[i] is PreprocessingDirective) -// list[i] = CSharpToVB((PreprocessingDirective)list[i]); -// } -// } -// -// public static PreprocessingDirective CSharpToVB(PreprocessingDirective dir) -// { -// string cmd = dir.Cmd; -// string arg = dir.Arg; -// switch (cmd) { -// case "#region": -// cmd = "#Region"; -// if (!arg.StartsWith("\"")) { -// arg = "\"" + arg.Trim() + "\""; -// } -// break; -// case "#endregion": -// cmd = "#End"; -// arg = "Region"; -// break; -// case "#endif": -// cmd = "#End"; -// arg = "If"; -// break; -// case "#if": -// arg += " Then"; -// break; -// } -// if (cmd.Length > 1) { -// cmd = cmd.Substring(0, 2).ToUpperInvariant() + cmd.Substring(2); -// } -// return new PreprocessingDirective(cmd, arg, dir.StartPosition, dir.EndPosition) { -// Expression = dir.Expression -// }; -// } -// #endregion -// -// string cmd; -// string arg; -// Ast.Expression expression = Ast.Expression.Null; -// -// /// -// /// Gets the directive name, including '#'. -// /// -// public string Cmd { -// get { -// return cmd; -// } -// set { -// cmd = value ?? string.Empty; -// } -// } -// -// /// -// /// Gets the directive argument. -// /// -// public string Arg { -// get { -// return arg; -// } -// set { -// arg = value ?? string.Empty; -// } -// } -// -// /// -// /// Gets/sets the expression (for directives that take an expression, e.g. #if and #elif). -// /// -// public Ast.Expression Expression { -// get { return expression; } -// set { expression = value ?? Ast.Expression.Null; } -// } -// -// /// -// /// The end position of the pre processor directive line. -// /// May be != EndPosition. -// /// -// public Location LastLineEnd { -// get; -// set; -// } -// -// -// public override string ToString() -// { -// return String.Format("[PreProcessingDirective: Cmd = {0}, Arg = {1}]", -// Cmd, -// Arg); -// } -// -// public PreprocessingDirective(string cmd, string arg, Location start, Location end) -// : base(start, end) -// { -// this.Cmd = cmd; -// this.Arg = arg; -// } -// -// public override object AcceptVisitor(ISpecialVisitor visitor, object data) -// { -// return visitor.Visit(this, data); -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/SpecialTracker.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/SpecialTracker.cs deleted file mode 100644 index 6ae334b2f..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/SpecialTracker.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Parser -{ -// public class SpecialTracker -// { -// List currentSpecials = new List(); -// -// CommentType currentCommentType; -// StringBuilder sb = new StringBuilder(); -// Location startPosition; -// bool commentStartsLine; -// -// public List CurrentSpecials { -// get { -// return currentSpecials; -// } -// } -// -// /// -// /// Gets the specials from the SpecialTracker and resets the lists. -// /// -// public List RetrieveSpecials() -// { -// List tmp = currentSpecials; -// currentSpecials = new List(); -// return tmp; -// } -// -// public void AddEndOfLine(Location point) -// { -// currentSpecials.Add(new BlankLine(point)); -// } -// -// public void AddPreprocessingDirective(PreprocessingDirective directive) -// { -// if (directive == null) -// throw new ArgumentNullException("directive"); -// currentSpecials.Add(directive); -// } -// -// // used for comment tracking -// public void StartComment(CommentType commentType, bool commentStartsLine, Location startPosition) -// { -// this.currentCommentType = commentType; -// this.startPosition = startPosition; -// this.sb.Length = 0; -// this.commentStartsLine = commentStartsLine; -// } -// -// public void AddChar(char c) -// { -// sb.Append(c); -// } -// -// public void AddString(string s) -// { -// sb.Append(s); -// } -// -// public void FinishComment(Location endPosition) -// { -// currentSpecials.Add(new Comment(currentCommentType, sb.ToString(), commentStartsLine, startPosition, endPosition)); -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/TagComment.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/TagComment.cs deleted file mode 100644 index 39863d125..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Special/TagComment.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - /// - /// Description of TagComment. - /// -// public class TagComment : Comment -// { -// string tag; -// -// public string Tag { -// get { -// return tag; -// } -// set { -// tag = value; -// } -// } -// -// public TagComment(string tag, string comment, bool commentStartsLine, Location startPosition, Location endPosition) : base(CommentType.SingleLine, comment, commentStartsLine, startPosition, endPosition) -// { -// this.tag = tag; -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Token.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Token.cs deleted file mode 100644 index 423c56a93..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Token.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public class Token - { - internal readonly int kind; - - internal readonly int col; - internal readonly int line; - - internal readonly object literalValue; - internal readonly string val; - internal Token next; - readonly TextLocation endLocation; - - public int Kind { - get { return kind; } - } - - public object LiteralValue { - get { return literalValue; } - } - - public string Value { - get { return val; } - } - - public TextLocation EndLocation { - get { return endLocation; } - } - - public TextLocation Location { - get { - return new TextLocation(line, col); - } - } - - public Token() - : this(0, 1, 1) - { - } - - public Token(int kind, int col, int line) : this (kind, col, line, null) - { - } - - public Token(int kind, TextLocation startLocation, TextLocation endLocation) : this(kind, startLocation, endLocation, "", null) - { - } - - public Token(int kind, int col, int line, string val) - { - this.kind = kind; - this.col = col; - this.line = line; - this.val = val; - this.endLocation = new TextLocation(line, col + (val == null ? 1 : val.Length)); - } - - internal Token(int kind, int x, int y, string val, object literalValue) - : this(kind, new TextLocation(y, x), new TextLocation(y, x + val.Length), val, literalValue) - { - } - - public Token(int kind, TextLocation startLocation, TextLocation endLocation, string val, object literalValue) - { - this.kind = kind; - this.col = startLocation.Column; - this.line = startLocation.Line; - this.endLocation = endLocation; - this.val = val; - this.literalValue = literalValue; - } - - public override string ToString() - { - string vbToken; - - try { - vbToken = Tokens.GetTokenString(kind); - } catch (NotSupportedException) { - vbToken = ""; - } - - return string.Format("[Token {0} Location={1} EndLocation={2} val={3}]", - vbToken, Location, EndLocation, val); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Tokens.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Tokens.cs deleted file mode 100644 index 484534a15..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/Tokens.cs +++ /dev/null @@ -1,527 +0,0 @@ -// this file was autogenerated by a tool. -using System; -using System.Collections; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public static class Tokens - { - // ----- terminal classes ----- - public const int EOF = 0; - public const int EOL = 1; - public const int Identifier = 2; - public const int LiteralString = 3; - public const int LiteralCharacter = 4; - public const int LiteralInteger = 5; - public const int LiteralDouble = 6; - public const int LiteralSingle = 7; - public const int LiteralDecimal = 8; - public const int LiteralDate = 9; - public const int XmlOpenTag = 10; - public const int XmlCloseTag = 11; - public const int XmlStartInlineVB = 12; - public const int XmlEndInlineVB = 13; - public const int XmlCloseTagEmptyElement = 14; - public const int XmlOpenEndTag = 15; - public const int XmlContent = 16; - public const int XmlComment = 17; - public const int XmlCData = 18; - public const int XmlProcessingInstruction = 19; - - // ----- special character ----- - public const int Assign = 20; - public const int Colon = 21; - public const int Comma = 22; - public const int ConcatString = 23; - public const int Div = 24; - public const int DivInteger = 25; - public const int Dot = 26; - public const int TripleDot = 27; - public const int DotAt = 28; - public const int ExclamationMark = 29; - public const int Minus = 30; - public const int Plus = 31; - public const int Power = 32; - public const int QuestionMark = 33; - public const int Times = 34; - public const int OpenCurlyBrace = 35; - public const int CloseCurlyBrace = 36; - public const int OpenParenthesis = 37; - public const int CloseParenthesis = 38; - public const int GreaterThan = 39; - public const int LessThan = 40; - public const int NotEqual = 41; - public const int GreaterEqual = 42; - public const int LessEqual = 43; - public const int ShiftLeft = 44; - public const int ShiftRight = 45; - public const int PlusAssign = 46; - public const int PowerAssign = 47; - public const int MinusAssign = 48; - public const int TimesAssign = 49; - public const int DivAssign = 50; - public const int DivIntegerAssign = 51; - public const int ShiftLeftAssign = 52; - public const int ShiftRightAssign = 53; - public const int ConcatStringAssign = 54; - public const int ColonAssign = 55; - - // ----- keywords ----- - public const int AddHandler = 56; - public const int AddressOf = 57; - public const int Aggregate = 58; - public const int Alias = 59; - public const int And = 60; - public const int AndAlso = 61; - public const int Ansi = 62; - public const int As = 63; - public const int Ascending = 64; - public const int Assembly = 65; - public const int Auto = 66; - public const int Binary = 67; - public const int Boolean = 68; - public const int ByRef = 69; - public const int By = 70; - public const int Byte = 71; - public const int ByVal = 72; - public const int Call = 73; - public const int Case = 74; - public const int Catch = 75; - public const int CBool = 76; - public const int CByte = 77; - public const int CChar = 78; - public const int CDate = 79; - public const int CDbl = 80; - public const int CDec = 81; - public const int Char = 82; - public const int CInt = 83; - public const int Class = 84; - public const int CLng = 85; - public const int CObj = 86; - public const int Compare = 87; - public const int Const = 88; - public const int Continue = 89; - public const int CSByte = 90; - public const int CShort = 91; - public const int CSng = 92; - public const int CStr = 93; - public const int CType = 94; - public const int CUInt = 95; - public const int CULng = 96; - public const int CUShort = 97; - public const int Custom = 98; - public const int Date = 99; - public const int Decimal = 100; - public const int Declare = 101; - public const int Default = 102; - public const int Delegate = 103; - public const int Descending = 104; - public const int Dim = 105; - public const int DirectCast = 106; - public const int Distinct = 107; - public const int Do = 108; - public const int Double = 109; - public const int Each = 110; - public const int Else = 111; - public const int ElseIf = 112; - public const int End = 113; - public const int EndIf = 114; - public const int Enum = 115; - new public const int Equals = 116; - public const int Erase = 117; - public const int Error = 118; - public const int Event = 119; - public const int Exit = 120; - public const int Explicit = 121; - public const int False = 122; - public const int Finally = 123; - public const int For = 124; - public const int Friend = 125; - public const int From = 126; - public const int Function = 127; - public const int Get = 128; - new public const int GetType = 129; - public const int Global = 130; - public const int GoSub = 131; - public const int GoTo = 132; - public const int Group = 133; - public const int Handles = 134; - public const int If = 135; - public const int Implements = 136; - public const int Imports = 137; - public const int In = 138; - public const int Infer = 139; - public const int Inherits = 140; - public const int Integer = 141; - public const int Interface = 142; - public const int Into = 143; - public const int Is = 144; - public const int IsNot = 145; - public const int Join = 146; - public const int Key = 147; - public const int Let = 148; - public const int Lib = 149; - public const int Like = 150; - public const int Long = 151; - public const int Loop = 152; - public const int Me = 153; - public const int Mod = 154; - public const int Module = 155; - public const int MustInherit = 156; - public const int MustOverride = 157; - public const int MyBase = 158; - public const int MyClass = 159; - public const int Namespace = 160; - public const int Narrowing = 161; - public const int New = 162; - public const int Next = 163; - public const int Not = 164; - public const int Nothing = 165; - public const int NotInheritable = 166; - public const int NotOverridable = 167; - public const int Object = 168; - public const int Of = 169; - public const int Off = 170; - public const int On = 171; - public const int Operator = 172; - public const int Option = 173; - public const int Optional = 174; - public const int Or = 175; - public const int Order = 176; - public const int OrElse = 177; - public const int Out = 178; - public const int Overloads = 179; - public const int Overridable = 180; - public const int Overrides = 181; - public const int ParamArray = 182; - public const int Partial = 183; - public const int Preserve = 184; - public const int Private = 185; - public const int Property = 186; - public const int Protected = 187; - public const int Public = 188; - public const int RaiseEvent = 189; - public const int ReadOnly = 190; - public const int ReDim = 191; - public const int Rem = 192; - public const int RemoveHandler = 193; - public const int Resume = 194; - public const int Return = 195; - public const int SByte = 196; - public const int Select = 197; - public const int Set = 198; - public const int Shadows = 199; - public const int Shared = 200; - public const int Short = 201; - public const int Single = 202; - public const int Skip = 203; - public const int Static = 204; - public const int Step = 205; - public const int Stop = 206; - public const int Strict = 207; - public const int String = 208; - public const int Structure = 209; - public const int Sub = 210; - public const int SyncLock = 211; - public const int Take = 212; - public const int Text = 213; - public const int Then = 214; - public const int Throw = 215; - public const int To = 216; - public const int True = 217; - public const int Try = 218; - public const int TryCast = 219; - public const int TypeOf = 220; - public const int UInteger = 221; - public const int ULong = 222; - public const int Unicode = 223; - public const int Until = 224; - public const int UShort = 225; - public const int Using = 226; - public const int Variant = 227; - public const int Wend = 228; - public const int When = 229; - public const int Where = 230; - public const int While = 231; - public const int Widening = 232; - public const int With = 233; - public const int WithEvents = 234; - public const int WriteOnly = 235; - public const int Xor = 236; - public const int GetXmlNamespace = 237; - - public const int MaxToken = 238; - static BitArray NewSet(params int[] values) - { - BitArray bitArray = new BitArray(MaxToken); - foreach (int val in values) { - bitArray[val] = true; - } - return bitArray; - } - public static BitArray Null = NewSet(Nothing); - public static BitArray BlockSucc = NewSet(Case, Catch, Else, ElseIf, End, Finally, Loop, Next); - public static BitArray GlobalLevel = NewSet(Namespace, Module, Class, Structure, Imports, Option); - public static BitArray TypeLevel = NewSet(Sub, Function, Property); - public static BitArray IdentifierTokens = NewSet(Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate); - public static BitArray ExpressionStart = NewSet(Me, MyBase, MyClass, True, False, Not, From, Aggregate, New, Nothing, AddressOf, GetType, TypeOf, GetXmlNamespace, Global, Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Sub, Function, DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort); - public static BitArray StatementStart = NewSet(Nothing, Me, MyBase, MyClass, True, False, Not, From, Aggregate, New, Nothing, AddressOf, GetType, TypeOf, GetXmlNamespace, Global, Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Sub, Function, DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort, Dim, Const, Static, For, While, Do, Select); - public static BitArray SimpleTypeName = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte, Text, Binary, Compare, Assembly, Ansi, Auto, Preserve, Unicode, Until, Off, Out, Key, Explicit, Infer, From, Join, Equals, Distinct, Where, Take, Skip, Order, By, Ascending, Descending, Group, Into, Aggregate); - public static BitArray CastExpressions = NewSet(DirectCast, TryCast, CType, CBool, CByte, CChar, CDate, CDec, CDbl, CInt, CLng, CObj, CSByte, CShort, CSng, CStr, CUInt, CULng, CUShort); - public static BitArray BooleanExpressions = NewSet(True, False); - public static BitArray LambdaStart = NewSet(Sub, Function); - public static BitArray OperatorsAtStart = NewSet(Not, From, Aggregate); - public static BitArray TypeKW = NewSet(Boolean, Date, Char, String, Decimal, Byte, Short, Integer, Long, Single, Double, UInteger, ULong, UShort, SByte); - - static string[] tokenList = new string[] { - // ----- terminal classes ----- - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - // ----- special character ----- - "=", - ":", - ",", - "&", - "/", - "\\", - ".", - "...", - ".@", - "!", - "-", - "+", - "^", - "?", - "*", - "{", - "}", - "(", - ")", - ">", - "<", - "<>", - ">=", - "<=", - "<<", - ">>", - "+=", - "^=", - "-=", - "*=", - "/=", - "\\=", - "<<=", - ">>=", - "&=", - ":=", - // ----- keywords ----- - "AddHandler", - "AddressOf", - "Aggregate", - "Alias", - "And", - "AndAlso", - "Ansi", - "As", - "Ascending", - "Assembly", - "Auto", - "Binary", - "Boolean", - "ByRef", - "By", - "Byte", - "ByVal", - "Call", - "Case", - "Catch", - "CBool", - "CByte", - "CChar", - "CDate", - "CDbl", - "CDec", - "Char", - "CInt", - "Class", - "CLng", - "CObj", - "Compare", - "Const", - "Continue", - "CSByte", - "CShort", - "CSng", - "CStr", - "CType", - "CUInt", - "CULng", - "CUShort", - "Custom", - "Date", - "Decimal", - "Declare", - "Default", - "Delegate", - "Descending", - "Dim", - "DirectCast", - "Distinct", - "Do", - "Double", - "Each", - "Else", - "ElseIf", - "End", - "EndIf", - "Enum", - "Equals", - "Erase", - "Error", - "Event", - "Exit", - "Explicit", - "False", - "Finally", - "For", - "Friend", - "From", - "Function", - "Get", - "GetType", - "Global", - "GoSub", - "GoTo", - "Group", - "Handles", - "If", - "Implements", - "Imports", - "In", - "Infer", - "Inherits", - "Integer", - "Interface", - "Into", - "Is", - "IsNot", - "Join", - "Key", - "Let", - "Lib", - "Like", - "Long", - "Loop", - "Me", - "Mod", - "Module", - "MustInherit", - "MustOverride", - "MyBase", - "MyClass", - "Namespace", - "Narrowing", - "New", - "Next", - "Not", - "Nothing", - "NotInheritable", - "NotOverridable", - "Object", - "Of", - "Off", - "On", - "Operator", - "Option", - "Optional", - "Or", - "Order", - "OrElse", - "Out", - "Overloads", - "Overridable", - "Overrides", - "ParamArray", - "Partial", - "Preserve", - "Private", - "Property", - "Protected", - "Public", - "RaiseEvent", - "ReadOnly", - "ReDim", - "Rem", - "RemoveHandler", - "Resume", - "Return", - "SByte", - "Select", - "Set", - "Shadows", - "Shared", - "Short", - "Single", - "Skip", - "Static", - "Step", - "Stop", - "Strict", - "String", - "Structure", - "Sub", - "SyncLock", - "Take", - "Text", - "Then", - "Throw", - "To", - "True", - "Try", - "TryCast", - "TypeOf", - "UInteger", - "ULong", - "Unicode", - "Until", - "UShort", - "Using", - "Variant", - "Wend", - "When", - "Where", - "While", - "Widening", - "With", - "WithEvents", - "WriteOnly", - "Xor", - "GetXmlNamespace", - }; - public static string GetTokenString(int token) - { - if (token >= 0 && token < tokenList.Length) { - return tokenList[token]; - } - throw new System.NotSupportedException("Unknown token:" + token); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/VBLexer.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/VBLexer.cs deleted file mode 100644 index a8e316309..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/VBLexer.cs +++ /dev/null @@ -1,1487 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; -using System.Xml; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public class VBLexer : IDisposable - { - bool lineEnd = true; - bool isAtLineBegin = false; // TODO: handle line begin, if neccessarry - bool misreadExclamationMarkAsTypeCharacter; - bool encounteredLineContinuation; - - ExpressionFinder ef; - - bool inXmlMode; - - Stack xmlModeStack = new Stack(); - - public VBLexer(TextReader reader) - { - this.reader = new LATextReader(reader); - ef = new ExpressionFinder(); - } - - public VBLexer(TextReader reader, VBLexerMemento state) : this(reader) - { - SetInitialLocation(new TextLocation(state.Line, state.Column)); - lastToken = new Token(state.PrevTokenKind, 0, 0); - ef = new ExpressionFinder(state.ExpressionFinder); - lineEnd = state.LineEnd; - isAtLineBegin = state.IsAtLineBegin; - encounteredLineContinuation = state.EncounteredLineContinuation; - misreadExclamationMarkAsTypeCharacter = state.MisreadExclamationMarkAsTypeCharacter; - xmlModeStack = new Stack(state.XmlModeInfoStack.Select(i => (XmlModeInfo)i.Clone()).Reverse()); - inXmlMode = state.InXmlMode; - } - - Token NextInternal() - { - if (misreadExclamationMarkAsTypeCharacter) { - misreadExclamationMarkAsTypeCharacter = false; - return new Token(Tokens.ExclamationMark, Col - 1, Line); - } - - unchecked { - while (true) { - TextLocation startLocation = new TextLocation(Line, Col); - int nextChar = ReaderRead(); - if (nextChar == -1) - return new Token(Tokens.EOF, Col, Line, string.Empty); - char ch = (char)nextChar; - #region XML mode - CheckXMLState(startLocation); - if (inXmlMode && xmlModeStack.Peek().level <= 0 && !xmlModeStack.Peek().isDocumentStart && !xmlModeStack.Peek().inXmlTag) { - XmlModeInfo info = xmlModeStack.Peek(); - int peek = nextChar; - while (true) { - int step = -1; - while (peek != -1 && XmlConvert.IsWhitespaceChar((char)peek)) { - step++; - peek = ReaderPeek(step); - } - - if (peek == '<' && (ReaderPeek(step + 1) == '!' || ReaderPeek(step + 1) == '?')) { - char lastCh = '\0'; - for (int i = 0; i < step + 2; i++) - lastCh = (char)ReaderRead(); - - if (lastCh == '!') - return ReadXmlCommentOrCData(Col - 2, Line); - else - return ReadXmlProcessingInstruction(Col - 2, Line); - } - - break; - } - inXmlMode = false; - xmlModeStack.Pop(); - } - if (inXmlMode) { - XmlModeInfo info = xmlModeStack.Peek(); - int x = Col - 1; - int y = Line; - switch (ch) { - case '<': - if (ReaderPeek() == '/') { - ReaderRead(); - info.inXmlCloseTag = true; - return new Token(Tokens.XmlOpenEndTag, new TextLocation(y, x), new TextLocation(Line, Col)); - } - if (ReaderPeek() == '%' && ReaderPeek(1) == '=') { - inXmlMode = false; - ReaderRead(); ReaderRead(); - return new Token(Tokens.XmlStartInlineVB, new TextLocation(y, x), new TextLocation(Line, Col)); - } - if (ReaderPeek() == '?') { - ReaderRead(); - Token t = ReadXmlProcessingInstruction(x, y); - return t; - } - if (ReaderPeek() == '!') { - ReaderRead(); - Token token = ReadXmlCommentOrCData(x, y); - return token; - } - info.level++; - info.isDocumentStart = false; - info.inXmlTag = true; - return new Token(Tokens.XmlOpenTag, x, y); - case '/': - if (ReaderPeek() == '>') { - ReaderRead(); - info.inXmlTag = false; - info.level--; - return new Token(Tokens.XmlCloseTagEmptyElement, new TextLocation(y, x), new TextLocation(Line, Col)); - } - break; - case '>': - if (info.inXmlCloseTag) - info.level--; - info.inXmlTag = info.inXmlCloseTag = false; - return new Token(Tokens.XmlCloseTag, x, y); - case '=': - return new Token(Tokens.Assign, x, y); - case '\'': - case '"': - string s = ReadXmlString(ch); - return new Token(Tokens.LiteralString, x, y, ch + s + ch, s); - default: - if (info.inXmlCloseTag || info.inXmlTag) { - if (XmlConvert.IsWhitespaceChar(ch)) - continue; - return new Token(Tokens.Identifier, x, y, ReadXmlIdent(ch)); - } else { - string content = ReadXmlContent(ch); - return new Token(Tokens.XmlContent, startLocation, new TextLocation(Line, Col), content, null); - } - } - #endregion - } else { - #region Standard Mode - if (Char.IsWhiteSpace(ch)) { - if (HandleLineEnd(ch)) { - if (lineEnd) { - // second line end before getting to a token - // -> here was a blank line -// specialTracker.AddEndOfLine(startLocation); - } else { - lineEnd = true; - return new Token(Tokens.EOL, startLocation, new TextLocation(Line, Col), null, null); - } - } - continue; - } - if (ch == '_') { - if (ReaderPeek() == -1) { - errors.Error(Line, Col, String.Format("No EOF expected after _")); - return new Token(Tokens.EOF, Col, Line, string.Empty); - } - if (!Char.IsWhiteSpace((char)ReaderPeek())) { - int x = Col - 1; - int y = Line; - string s = ReadIdent('_'); - lineEnd = false; - return new Token(Tokens.Identifier, x, y, s); - } - encounteredLineContinuation = true; - ch = (char)ReaderRead(); - - bool oldLineEnd = lineEnd; - lineEnd = false; - while (Char.IsWhiteSpace(ch)) { - if (HandleLineEnd(ch)) { - lineEnd = true; - break; - } - if (ReaderPeek() != -1) { - ch = (char)ReaderRead(); - } else { - errors.Error(Line, Col, String.Format("No EOF expected after _")); - return new Token(Tokens.EOF, Col, Line, string.Empty); - } - } - if (!lineEnd) { - errors.Error(Line, Col, String.Format("NewLine expected")); - } - lineEnd = oldLineEnd; - continue; - } - - if (ch == '#') { - while (Char.IsWhiteSpace((char)ReaderPeek())) { - ReaderRead(); - } - if (Char.IsDigit((char)ReaderPeek())) { - int x = Col - 1; - int y = Line; - string s = ReadDate(); - DateTime time = new DateTime(1, 1, 1, 0, 0, 0); - try { - time = DateTime.Parse(s, System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.NoCurrentDateDefault); - } catch (Exception e) { - errors.Error(Line, Col, String.Format("Invalid date time {0}", e)); - } - return new Token(Tokens.LiteralDate, x, y, s, time); - } else { - ReadPreprocessorDirective(); - continue; - } - } - - if (ch == '[') { // Identifier - lineEnd = false; - if (ReaderPeek() == -1) { - errors.Error(Line, Col, String.Format("Identifier expected")); - } - ch = (char)ReaderRead(); - if (ch == ']' || Char.IsWhiteSpace(ch)) { - errors.Error(Line, Col, String.Format("Identifier expected")); - } - int x = Col - 1; - int y = Line; - string s = ReadIdent(ch); - if (ReaderPeek() == -1) { - errors.Error(Line, Col, String.Format("']' expected")); - } - ch = (char)ReaderRead(); - if (!(ch == ']')) { - errors.Error(Line, Col, String.Format("']' expected")); - } - return new Token(Tokens.Identifier, x, y, s); - } - if (Char.IsLetter(ch)) { - int x = Col - 1; - int y = Line; - char typeCharacter; - string s = ReadIdent(ch, out typeCharacter); - if (typeCharacter == '\0') { - int keyWordToken = Keywords.GetToken(s); - if (keyWordToken >= 0) { - // handle 'REM' comments - if (keyWordToken == Tokens.Rem) { - ReadComment(); - if (!lineEnd) { - lineEnd = true; - return new Token(Tokens.EOL, Col, Line, "\n"); - } - continue; - } - - lineEnd = false; - return new Token(keyWordToken, x, y, s); - } - } - - lineEnd = false; - return new Token(Tokens.Identifier, x, y, s); - - } - if (Char.IsDigit(ch)) { - lineEnd = false; - return ReadDigit(ch, Col - 1); - } - if (ch == '&') { - lineEnd = false; - if (ReaderPeek() == -1) { - return ReadOperator('&'); - } - ch = (char)ReaderPeek(); - if (Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'H' || Char.ToUpper(ch, CultureInfo.InvariantCulture) == 'O') { - return ReadDigit('&', Col - 1); - } - return ReadOperator('&'); - } - if (ch == '\'' || ch == '\u2018' || ch == '\u2019') { - int x = Col - 1; - int y = Line; - ReadComment(); - if (!lineEnd) { - lineEnd = true; - return new Token(Tokens.EOL, x, y, "\n"); - } - continue; - } - if (ch == '"') { - lineEnd = false; - int x = Col - 1; - int y = Line; - string s = ReadString(); - if (ReaderPeek() != -1 && (ReaderPeek() == 'C' || ReaderPeek() == 'c')) { - ReaderRead(); - if (s.Length != 1) { - errors.Error(Line, Col, String.Format("Chars can only have Length 1 ")); - } - if (s.Length == 0) { - s = "\0"; - } - return new Token(Tokens.LiteralCharacter, x, y, '"' + s + "\"C", s[0]); - } - return new Token(Tokens.LiteralString, x, y, '"' + s + '"', s); - } - if (ch == '%' && ReaderPeek() == '>') { - int x = Col - 1; - int y = Line; - inXmlMode = true; - ReaderRead(); - return new Token(Tokens.XmlEndInlineVB, new TextLocation(y, x), new TextLocation(Line, Col)); - } - #endregion - if (ch == '<' && (ef.NextTokenIsPotentialStartOfExpression || ef.NextTokenIsStartOfImportsOrAccessExpression)) { - xmlModeStack.Push(new XmlModeInfo(ef.NextTokenIsStartOfImportsOrAccessExpression)); - XmlModeInfo info = xmlModeStack.Peek(); - int x = Col - 1; - int y = Line; - inXmlMode = true; - if (ReaderPeek() == '/') { - ReaderRead(); - info.inXmlCloseTag = true; - return new Token(Tokens.XmlOpenEndTag, new TextLocation(y, x), new TextLocation(Line, Col)); - } - // should we allow <%= at start of an expression? not valid with vbc ... - if (ReaderPeek() == '%' && ReaderPeek(1) == '=') { - inXmlMode = false; - ReaderRead(); ReaderRead(); - return new Token(Tokens.XmlStartInlineVB, new TextLocation(y, x), new TextLocation(Line, Col)); - } - if (ReaderPeek() == '!') { - ReaderRead(); - Token t = ReadXmlCommentOrCData(x, y); - return t; - } - if (ReaderPeek() == '?') { - ReaderRead(); - Token t = ReadXmlProcessingInstruction(x, y); - info.isDocumentStart = t.val.Trim().StartsWith("xml", StringComparison.OrdinalIgnoreCase); - return t; - } - info.inXmlTag = true; - info.level++; - return new Token(Tokens.XmlOpenTag, x, y); - } - Token token = ReadOperator(ch); - if (token != null) { - lineEnd = false; - return token; - } - } - - errors.Error(Line, Col, String.Format("Unknown char({0}) which can't be read", ch)); - } - } - } - - void CheckXMLState(TextLocation startLocation) - { - if (inXmlMode && !xmlModeStack.Any()) - throw new InvalidOperationException("invalid XML stack state at " + startLocation); - } - - Token prevToken; - - Token Next() - { - Token t = NextInternal(); - if (t.kind == Tokens.EOL) { - Debug.Assert(t.next == null); // NextInternal() must return only 1 token - t.next = NextInternal(); - Debug.Assert(t.next.next == null); - if (SkipEOL(prevToken.kind, t.next.kind)) { - t = t.next; - } - } else - encounteredLineContinuation = false; - // inform EF only once we're sure it's really a token - // this means we inform it about EOL tokens "1 token too late", but that's not a problem because - // XML literals cannot start immediately after an EOL token - ef.InformToken(t); - if (t.next != null) { - // Next() isn't called again when it returns 2 tokens, so we need to process both tokens - ef.InformToken(t.next); - prevToken = t.next; - } else { - prevToken = t; - } - ef.Advance(); - Debug.Assert(t != null); - return t; - } - - /// see VB language specification 10; pg. 6 - bool SkipEOL(int prevTokenKind, int nextTokenKind) - { - // exception directly after _ - if (encounteredLineContinuation) { - return encounteredLineContinuation = false; - } - - // 1st rule - // after a comma (,), open parenthesis ((), open curly brace ({), or open embedded expression (<%=) - if (new[] { Tokens.Comma, Tokens.OpenParenthesis, Tokens.OpenCurlyBrace, Tokens.XmlStartInlineVB } - .Contains(prevTokenKind)) - return true; - - // 2nd rule - // after a member qualifier (. or .@ or ...), provided that something is being qualified (i.e. is not - // using an implicit With context) - if (new[] { Tokens.Dot, Tokens.DotAt, Tokens.TripleDot }.Contains(prevTokenKind) - && !ef.WasQualifierTokenAtStart) - return true; - - // 3rd rule - // before a close parenthesis ()), close curly brace (}), or close embedded expression (%>) - if (new[] { Tokens.CloseParenthesis, Tokens.CloseCurlyBrace, Tokens.XmlEndInlineVB } - .Contains(nextTokenKind)) - return true; - - // 4th rule - // after a less-than (<) in an attribute context - if (prevTokenKind == Tokens.LessThan && ef.InContext(Context.Attribute)) - return true; - - // 5th rule - // before a greater-than (>) in an attribute context - if (nextTokenKind == Tokens.GreaterThan && ef.InContext(Context.Attribute)) - return true; - - // 6th rule - // after a greater-than (>) in a non-file-level attribute context - if (ef.WasNormalAttribute && prevTokenKind == Tokens.GreaterThan) - return true; - - // 7th rule - // before and after query operators (Where, Order, Select, etc.) - var queryOperators = new int[] { Tokens.From, Tokens.Aggregate, Tokens.Select, Tokens.Distinct, - Tokens.Where, Tokens.Order, Tokens.By, Tokens.Ascending, Tokens.Descending, Tokens.Take, - Tokens.Skip, Tokens.Let, Tokens.Group, Tokens.Into, Tokens.On, Tokens.While, Tokens.Join }; - if (ef.InContext(Context.Query)) { - // Ascending, Descending, Distinct are special - // fixes http://community.sharpdevelop.net/forums/p/12068/32893.aspx#32893 - var specialQueryOperators = new int[] { Tokens.Ascending, Tokens.Descending, Tokens.Distinct }; - if (specialQueryOperators.Contains(prevTokenKind) && !queryOperators.Contains(nextTokenKind)) - return false; - - if ((queryOperators.Contains(prevTokenKind) || queryOperators.Contains(nextTokenKind))) - return true; - } - - // 8th rule - // after binary operators (+, -, /, *, etc.) in an expression context - if (new[] { Tokens.Plus, Tokens.Minus, Tokens.Div, Tokens.DivInteger, Tokens.Times, Tokens.Mod, Tokens.Power, - Tokens.Assign, Tokens.NotEqual, Tokens.LessThan, Tokens.LessEqual, Tokens.GreaterThan, Tokens.GreaterEqual, - Tokens.Like, Tokens.ConcatString, Tokens.AndAlso, Tokens.OrElse, Tokens.And, Tokens.Or, Tokens.Xor, - Tokens.ShiftLeft, Tokens.ShiftRight }.Contains(prevTokenKind) && ef.CurrentBlock.context == Context.Expression) - return true; - - // 9th rule - // after assignment operators (=, :=, +=, -=, etc.) in any context. - if (new[] { Tokens.Assign, Tokens.ColonAssign, Tokens.ConcatStringAssign, Tokens.DivAssign, - Tokens.DivIntegerAssign, Tokens.MinusAssign, Tokens.PlusAssign, Tokens.PowerAssign, - Tokens.ShiftLeftAssign, Tokens.ShiftRightAssign, Tokens.TimesAssign }.Contains(prevTokenKind)) - return true; - - return false; - } - - /// - /// Reads the next token. - /// - /// A object. - public Token NextToken() - { - if (curToken == null) { // first call of NextToken() - curToken = Next(); - //Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val); - return curToken; - } - - lastToken = curToken; - - if (curToken.next == null) { - curToken.next = Next(); - } - - curToken = curToken.next; - - if (curToken.kind == Tokens.EOF && !(lastToken.kind == Tokens.EOL)) { // be sure that before EOF there is an EOL token - curToken = new Token(Tokens.EOL, curToken.col, curToken.line, string.Empty); - curToken.next = new Token(Tokens.EOF, curToken.col, curToken.line, string.Empty); - } - //Console.WriteLine("Tok:" + Tokens.GetTokenString(curToken.kind) + " --- " + curToken.val); - return curToken; - } - - #region VB Readers - string ReadIdent(char ch) - { - char typeCharacter; - return ReadIdent(ch, out typeCharacter); - } - - string ReadIdent(char ch, out char typeCharacter) - { - typeCharacter = '\0'; - - if (ef.ReadXmlIdentifier) { - ef.ReadXmlIdentifier = false; - return ReadXmlIdent(ch); - } - - sb.Length = 0; - sb.Append(ch); - int peek; - while ((peek = ReaderPeek()) != -1 && (Char.IsLetterOrDigit(ch = (char)peek) || ch == '_')) { - ReaderRead(); - sb.Append(ch.ToString()); - } - if (peek == -1) { - return sb.ToString(); - } - - if ("%&@!#$".IndexOf((char)peek) != -1) { - typeCharacter = (char)peek; - ReaderRead(); - if (typeCharacter == '!') { - peek = ReaderPeek(); - if (peek != -1 && (peek == '_' || peek == '[' || char.IsLetter((char)peek))) { - misreadExclamationMarkAsTypeCharacter = true; - } - } - } - return sb.ToString(); - } - - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1818:DoNotConcatenateStringsInsideLoops")] - Token ReadDigit(char ch, int x) - { - sb.Length = 0; - sb.Append(ch); - - int y = Line; - string digit = ""; - if (ch != '&') { - digit += ch; - } - - bool isHex = false; - bool isOct = false; - bool isSingle = false; - bool isDouble = false; - bool isDecimal = false; - - if (ReaderPeek() == -1) { - if (ch == '&') { - errors.Error(Line, Col, String.Format("digit expected")); - } - return new Token(Tokens.LiteralInteger, x, y, sb.ToString() ,ch - '0'); - } - if (ch == '.') { - if (Char.IsDigit((char)ReaderPeek())) { - isDouble = true; // double is default - if (isHex || isOct) { - errors.Error(Line, Col, String.Format("No hexadecimal or oktadecimal floating point values allowed")); - } - while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())){ // read decimal digits beyond the dot - digit += (char)ReaderRead(); - } - } - } else if (ch == '&' && PeekUpperChar() == 'H') { - const string hex = "0123456789ABCDEF"; - sb.Append((char)ReaderRead()); // skip 'H' - while (ReaderPeek() != -1 && hex.IndexOf(PeekUpperChar()) != -1) { - ch = (char)ReaderRead(); - sb.Append(ch); - digit += Char.ToUpper(ch, CultureInfo.InvariantCulture); - } - isHex = true; - } else if (ReaderPeek() != -1 && ch == '&' && PeekUpperChar() == 'O') { - const string okt = "01234567"; - sb.Append((char)ReaderRead()); // skip 'O' - while (ReaderPeek() != -1 && okt.IndexOf(PeekUpperChar()) != -1) { - ch = (char)ReaderRead(); - sb.Append(ch); - digit += Char.ToUpper(ch, CultureInfo.InvariantCulture); - } - isOct = true; - } else { - while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())) { - ch = (char)ReaderRead();; - digit += ch; - sb.Append(ch); - } - } - - if (digit.Length == 0) { - errors.Error(Line, Col, String.Format("digit expected")); - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0); - } - - if (ReaderPeek() != -1 && "%&SILU".IndexOf(PeekUpperChar()) != -1 || isHex || isOct) { - bool unsigned = false; - if (ReaderPeek() != -1) { - ch = (char)ReaderPeek(); - sb.Append(ch); - ch = Char.ToUpper(ch, CultureInfo.InvariantCulture); - unsigned = ch == 'U'; - if (unsigned) { - ReaderRead(); // read the U - ch = (char)ReaderPeek(); - sb.Append(ch); - ch = Char.ToUpper(ch, CultureInfo.InvariantCulture); - if (ch != 'I' && ch != 'L' && ch != 'S') { - errors.Error(Line, Col, "Invalid type character: U" + ch); - } - } - } - try { - if (isOct) { - ReaderRead(); - ulong number = 0L; - for (int i = 0; i < digit.Length; ++i) { - number = number * 8 + digit[i] - '0'; - } - if (ch == 'S') { - if (unsigned) - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (ushort)number); - else - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (short)number); - } else if (ch == '%' || ch == 'I') { - if (unsigned) - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (uint)number); - else - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (int)number); - } else if (ch == '&' || ch == 'L') { - if (unsigned) - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (ulong)number); - else - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), (long)number); - } else { - if (number > uint.MaxValue) { - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((long)number)); - } else { - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((int)number)); - } - } - } - if (ch == 'S') { - ReaderRead(); - if (unsigned) - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), UInt16.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - else - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int16.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - } else if (ch == '%' || ch == 'I') { - ReaderRead(); - if (unsigned) - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), UInt32.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - else - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int32.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - } else if (ch == '&' || ch == 'L') { - ReaderRead(); - if (unsigned) - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), UInt64.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - else - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int64.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - } else if (isHex) { - ulong number = UInt64.Parse(digit, NumberStyles.HexNumber); - if (number > uint.MaxValue) { - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((long)number)); - } else { - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), unchecked((int)number)); - } - } - } catch (OverflowException ex) { - errors.Error(Line, Col, ex.Message); - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0); - } catch (FormatException) { - errors.Error(Line, Col, String.Format("{0} is not a parseable number", digit)); - return new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0); - } - } - Token nextToken = null; // if we accidently read a 'dot' - if (!isDouble && ReaderPeek() == '.') { // read floating point number - ReaderRead(); - if (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())) { - isDouble = true; // double is default - if (isHex || isOct) { - errors.Error(Line, Col, String.Format("No hexadecimal or oktadecimal floating point values allowed")); - } - digit += '.'; - while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())){ // read decimal digits beyond the dot - digit += (char)ReaderRead(); - } - } else { - nextToken = new Token(Tokens.Dot, Col - 1, Line); - } - } - - if (ReaderPeek() != -1 && PeekUpperChar() == 'E') { // read exponent - isDouble = true; - digit += (char)ReaderRead(); - if (ReaderPeek() != -1 && (ReaderPeek() == '-' || ReaderPeek() == '+')) { - digit += (char)ReaderRead(); - } - while (ReaderPeek() != -1 && Char.IsDigit((char)ReaderPeek())) { // read exponent value - digit += (char)ReaderRead(); - } - } - - if (ReaderPeek() != -1) { - switch (PeekUpperChar()) { - case 'R': - case '#': - ReaderRead(); - isDouble = true; - break; - case 'D': - case '@': - ReaderRead(); - isDecimal = true; - break; - case 'F': - case '!': - ReaderRead(); - isSingle = true; - break; - } - } - - try { - if (isSingle) { - return new Token(Tokens.LiteralSingle, x, y, sb.ToString(), Single.Parse(digit, CultureInfo.InvariantCulture)); - } - if (isDecimal) { - return new Token(Tokens.LiteralDecimal, x, y, sb.ToString(), Decimal.Parse(digit, NumberStyles.Currency | NumberStyles.AllowExponent, CultureInfo.InvariantCulture)); - } - if (isDouble) { - return new Token(Tokens.LiteralDouble, x, y, sb.ToString(), Double.Parse(digit, CultureInfo.InvariantCulture)); - } - } catch (FormatException) { - errors.Error(Line, Col, String.Format("{0} is not a parseable number", digit)); - if (isSingle) - return new Token(Tokens.LiteralSingle, x, y, sb.ToString(), 0f); - if (isDecimal) - return new Token(Tokens.LiteralDecimal, x, y, sb.ToString(), 0m); - if (isDouble) - return new Token(Tokens.LiteralDouble, x, y, sb.ToString(), 0.0); - } - Token token; - try { - token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int32.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - } catch (Exception) { - try { - token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), Int64.Parse(digit, isHex ? NumberStyles.HexNumber : NumberStyles.Number)); - } catch (FormatException) { - errors.Error(Line, Col, String.Format("{0} is not a parseable number", digit)); - // fallback, when nothing helps :) - token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0); - } catch (OverflowException) { - errors.Error(Line, Col, String.Format("{0} is too long for a integer literal", digit)); - // fallback, when nothing helps :) - token = new Token(Tokens.LiteralInteger, x, y, sb.ToString(), 0); - } - } - token.next = nextToken; - return token; - } - - void ReadPreprocessorDirective() - { - TextLocation start = new TextLocation(Line, Col - 1); - string directive = ReadIdent('#'); - // TODO : expression parser for PP directives - // needed for proper conversion to e. g. C# - string argument = ReadToEndOfLine(); -// this.specialTracker.AddPreprocessingDirective(new PreprocessingDirective(directive, argument.Trim(), start, new AstLocation(start.Line, start.Column + directive.Length + argument.Length))); - } - - string ReadDate() - { - char ch = '\0'; - sb.Length = 0; - int nextChar; - while ((nextChar = ReaderRead()) != -1) { - ch = (char)nextChar; - if (ch == '#') { - break; - } else if (ch == '\n') { - errors.Error(Line, Col, String.Format("No return allowed inside Date literal")); - } else { - sb.Append(ch); - } - } - if (ch != '#') { - errors.Error(Line, Col, String.Format("End of File reached before Date literal terminated")); - } - return sb.ToString(); - } - - string ReadString() - { - char ch = '\0'; - sb.Length = 0; - int nextChar; - while ((nextChar = ReaderRead()) != -1) { - ch = (char)nextChar; - if (ch == '"') { - if (ReaderPeek() != -1 && ReaderPeek() == '"') { - sb.Append('"'); - ReaderRead(); - } else { - break; - } - } else if (ch == '\n') { - errors.Error(Line, Col, String.Format("No return allowed inside String literal")); - } else { - sb.Append(ch); - } - } - if (ch != '"') { - errors.Error(Line, Col, String.Format("End of File reached before String terminated ")); - } - return sb.ToString(); - } - - void ReadComment() - { - TextLocation startPos = new TextLocation(Line, Col); - sb.Length = 0; - StringBuilder curWord = specialCommentHash != null ? new StringBuilder() : null; - int missingApostrophes = 2; // no. of ' missing until it is a documentation comment - int nextChar; - while ((nextChar = ReaderRead()) != -1) { - char ch = (char)nextChar; - - if (HandleLineEnd(ch)) { - break; - } - - sb.Append(ch); - - if (missingApostrophes > 0) { - if (ch == '\'' || ch == '\u2018' || ch == '\u2019') { - if (--missingApostrophes == 0) { -// specialTracker.StartComment(CommentType.Documentation, isAtLineBegin, startPos); - sb.Length = 0; - } - } else { -// specialTracker.StartComment(CommentType.SingleLine, isAtLineBegin, startPos); - missingApostrophes = 0; - } - } - - if (specialCommentHash != null) { - if (Char.IsLetter(ch)) { - curWord.Append(ch); - } else { - string tag = curWord.ToString(); - curWord.Length = 0; - if (specialCommentHash.ContainsKey(tag)) { - TextLocation p = new TextLocation(Line, Col); - string comment = ch + ReadToEndOfLine(); -// this.TagComments.Add(new TagComment(tag, comment, isAtLineBegin, p, new Location(Col, Line))); - sb.Append(comment); - break; - } - } - } - } -// if (missingApostrophes > 0) { -// specialTracker.StartComment(CommentType.SingleLine, isAtLineBegin, startPos); -// } -// specialTracker.AddString(sb.ToString()); -// specialTracker.FinishComment(new Location(Col, Line)); - } - - Token ReadOperator(char ch) - { - int x = Col - 1; - int y = Line; - switch(ch) { - case '+': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.PlusAssign, x, y); - default: - break; - } - return new Token(Tokens.Plus, x, y); - case '-': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.MinusAssign, x, y); - default: - break; - } - return new Token(Tokens.Minus, x, y); - case '*': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.TimesAssign, x, y); - default: - break; - } - return new Token(Tokens.Times, x, y, "*"); - case '/': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.DivAssign, x, y); - default: - break; - } - return new Token(Tokens.Div, x, y); - case '\\': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.DivIntegerAssign, x, y); - default: - break; - } - return new Token(Tokens.DivInteger, x, y); - case '&': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.ConcatStringAssign, x, y); - default: - break; - } - return new Token(Tokens.ConcatString, x, y); - case '^': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.PowerAssign, x, y); - default: - break; - } - return new Token(Tokens.Power, x, y); - case ':': - if (ReaderPeek() == '=') { - ReaderRead(); - return new Token(Tokens.ColonAssign, x, y); - } - return new Token(Tokens.Colon, x, y); - case '=': - return new Token(Tokens.Assign, x, y); - case '<': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.LessEqual, x, y); - case '>': - ReaderRead(); - return new Token(Tokens.NotEqual, x, y); - case '<': - ReaderRead(); - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.ShiftLeftAssign, x, y); - default: - break; - } - return new Token(Tokens.ShiftLeft, x, y); - } - return new Token(Tokens.LessThan, x, y); - case '>': - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.GreaterEqual, x, y); - case '>': - ReaderRead(); - if (ReaderPeek() != -1) { - switch (ReaderPeek()) { - case '=': - ReaderRead(); - return new Token(Tokens.ShiftRightAssign, x, y); - default: - break; - } - } - return new Token(Tokens.ShiftRight, x, y); - } - return new Token(Tokens.GreaterThan, x, y); - case ',': - return new Token(Tokens.Comma, x, y); - case '.': - // Prevent OverflowException when Peek returns -1 - int tmp = ReaderPeek(); int tmp2 = ReaderPeek(1); - if (tmp > 0) { - if (char.IsDigit((char)tmp)) - return ReadDigit('.', Col); - else if ((char)tmp == '@') { - ReaderRead(); - return new Token(Tokens.DotAt, x, y); - } else if ((char)tmp == '.' && tmp2 > 0 && (char)tmp2 == '.') { - ReaderRead(); ReaderRead(); - return new Token(Tokens.TripleDot, x, y); - } - } - return new Token(Tokens.Dot, x, y); - case '(': - return new Token(Tokens.OpenParenthesis, x, y); - case ')': - return new Token(Tokens.CloseParenthesis, x, y); - case '{': - return new Token(Tokens.OpenCurlyBrace, x, y); - case '}': - return new Token(Tokens.CloseCurlyBrace, x, y); - case '?': - return new Token(Tokens.QuestionMark, x, y); - case '!': - return new Token(Tokens.ExclamationMark, x, y); - } - return null; - } - #endregion - - #region XML Readers - Token ReadXmlProcessingInstruction(int x, int y) - { - sb.Length = 0; - int nextChar = -1; - - while (ReaderPeek() != '?' || ReaderPeek(1) != '>') { - nextChar = ReaderRead(); - if (nextChar == -1) - break; - sb.Append((char)nextChar); - } - - ReaderSkip("?>".Length); - - return new Token(Tokens.XmlProcessingInstruction, new TextLocation(y, x), new TextLocation(Line, Col), sb.ToString(), null); - } - - Token ReadXmlCommentOrCData(int x, int y) - { - sb.Length = 0; - int nextChar = -1; - - if (string.CompareOrdinal(ReaderPeekString("--".Length), "--") == 0) { - ReaderSkip("--".Length); - while ((nextChar = ReaderRead()) != -1) { - sb.Append((char)nextChar); - if (string.CompareOrdinal(ReaderPeekString("-->".Length), "-->") == 0) { - ReaderSkip("-->".Length); - return new Token(Tokens.XmlComment, new TextLocation(y, x), new TextLocation(Line, Col), sb.ToString(), null); - } - } - } - - if (string.CompareOrdinal(ReaderPeekString("[CDATA[".Length), "[CDATA[") == 0) { - ReaderSkip("[CDATA[".Length); - while ((nextChar = ReaderRead()) != -1) { - sb.Append((char)nextChar); - if (string.CompareOrdinal(ReaderPeekString("]]>".Length), "]]>") == 0) { - ReaderSkip("]]>".Length); - return new Token(Tokens.XmlCData, new TextLocation(y, x), new TextLocation(Line, Col), sb.ToString(), null); - } - } - } - - return new Token(Tokens.XmlComment, new TextLocation(y, x), new TextLocation(Line, Col), sb.ToString(), null); - } - - string ReadXmlContent(char ch) - { - sb.Length = 0; - while (true) { - sb.Append(ch); - int next = ReaderPeek(); - - if (next == -1 || next == '<') - break; - ch = (char)ReaderRead(); - } - - return sb.ToString(); - } - - string ReadXmlString(char terminator) - { - char ch = '\0'; - sb.Length = 0; - int nextChar; - while ((nextChar = ReaderRead()) != -1) { - ch = (char)nextChar; - if (ch == terminator) { - break; - } else if (ch == '\n') { - errors.Error(Line, Col, String.Format("No return allowed inside String literal")); - } else { - sb.Append(ch); - } - } - if (ch != terminator) { - errors.Error(Line, Col, String.Format("End of File reached before String terminated ")); - } - return sb.ToString(); - } - - string ReadXmlIdent(char ch) - { - sb.Length = 0; - sb.Append(ch); - - int peek; - - while ((peek = ReaderPeek()) != -1 && (peek == ':' || XmlConvert.IsNCNameChar((char)peek))) { - sb.Append((char)ReaderRead()); - } - - return sb.ToString(); - } - #endregion - - char PeekUpperChar() - { - return Char.ToUpper((char)ReaderPeek(), CultureInfo.InvariantCulture); - } - - /// - /// Skips to the end of the current code block. - /// For this, the lexer must have read the next token AFTER the token opening the - /// block (so that Lexer.Token is the block-opening token, not Lexer.LookAhead). - /// After the call, Lexer.LookAhead will be the block-closing token. - /// - public void SkipCurrentBlock(int targetToken) - { - int lastKind = -1; - int kind = lastToken.kind; - while (kind != Tokens.EOF && - !(lastKind == Tokens.End && kind == targetToken)) - { - lastKind = kind; - NextToken(); - kind = lastToken.kind; - } - } - - public void SetInitialContext(SnippetType type) - { - ef.SetContext(type); - } - - public VBLexerMemento Export() - { - return new VBLexerMemento() { - Column = Col, - Line = Line, - EncounteredLineContinuation = encounteredLineContinuation, - ExpressionFinder = ef.Export(), - InXmlMode = inXmlMode, - IsAtLineBegin = isAtLineBegin, - LineEnd = lineEnd, - PrevTokenKind = prevToken.kind, - MisreadExclamationMarkAsTypeCharacter = misreadExclamationMarkAsTypeCharacter, - XmlModeInfoStack = new Stack(xmlModeStack.Select(i => (XmlModeInfo)i.Clone()).Reverse()) - }; - } - - LATextReader reader; - int col = 1; - int line = 1; - - protected Errors errors = new Errors(); - - protected Token lastToken = null; - protected Token curToken = null; - protected Token peekToken = null; - - string[] specialCommentTags = null; - protected Hashtable specialCommentHash = null; -// List tagComments = new List(); - protected StringBuilder sb = new StringBuilder(); -// protected SpecialTracker specialTracker = new SpecialTracker(); - - // used for the original value of strings (with escape sequences). - protected StringBuilder originalValue = new StringBuilder(); - - public bool SkipAllComments { get; set; } - public bool EvaluateConditionalCompilation { get; set; } - public virtual IDictionary ConditionalCompilationSymbols { - get { throw new NotSupportedException(); } - } - - protected static IEnumerable GetSymbols (string symbols) - { - if (!string.IsNullOrEmpty(symbols)) { - foreach (string symbol in symbols.Split (';', ' ', '\t')) { - string s = symbol.Trim (); - if (s.Length == 0) - continue; - yield return s; - } - } - } - - public void SetConditionalCompilationSymbols (string symbols) - { - throw new NotSupportedException (); - } - - protected int Line { - get { - return line; - } - } - protected int Col { - get { - return col; - } - } - - protected bool recordRead = false; - protected StringBuilder recordedText = new StringBuilder (); - - protected int ReaderRead() - { - int val = reader.Read(); - if (recordRead && val >= 0) - recordedText.Append ((char)val); - if ((val == '\r' && reader.Peek() != '\n') || val == '\n') { - ++line; - col = 1; - LineBreak(); - } else if (val >= 0) { - col++; - } - return val; - } - - protected int ReaderPeek() - { - return reader.Peek(); - } - - protected int ReaderPeek(int step) - { - return reader.Peek(step); - } - - protected void ReaderSkip(int steps) - { - for (int i = 0; i < steps; i++) { - ReaderRead(); - } - } - - protected string ReaderPeekString(int length) - { - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < length; i++) { - int peek = ReaderPeek(i); - if (peek != -1) - builder.Append((char)peek); - } - - return builder.ToString(); - } - - public void SetInitialLocation(TextLocation location) - { - if (lastToken != null || curToken != null || peekToken != null) - throw new InvalidOperationException(); - this.line = location.Line; - this.col = location.Column; - } - - public Errors Errors { - get { - return errors; - } - } - - /// - /// Returns the comments that had been read and containing tag key words. - /// -// public List TagComments { -// get { -// return tagComments; -// } -// } - -// public SpecialTracker SpecialTracker { -// get { -// return specialTracker; -// } -// } - - /// - /// Special comment tags are tags like TODO, HACK or UNDONE which are read by the lexer and stored in . - /// - public string[] SpecialCommentTags { - get { - return specialCommentTags; - } - set { - specialCommentTags = value; - specialCommentHash = null; - if (specialCommentTags != null && specialCommentTags.Length > 0) { - specialCommentHash = new Hashtable(); - foreach (string str in specialCommentTags) { - specialCommentHash.Add(str, null); - } - } - } - } - - /// - /// The current Token. - /// - public Token Token { - get { -// Console.WriteLine("Call to Token"); - return lastToken; - } - } - - /// - /// The next Token (The after call) . - /// - public Token LookAhead { - get { -// Console.WriteLine("Call to LookAhead"); - return curToken; - } - } - - #region System.IDisposable interface implementation - public virtual void Dispose() - { - reader.Close(); - reader = null; - errors = null; - lastToken = curToken = peekToken = null; - specialCommentHash = null; - sb = originalValue = null; - } - #endregion - - /// - /// Must be called before a peek operation. - /// - public void StartPeek() - { - peekToken = curToken; - } - - /// - /// Gives back the next token. A second call to Peek() gives the next token after the last call for Peek() and so on. - /// - /// An object. - public Token Peek() - { -// Console.WriteLine("Call to Peek"); - if (peekToken.next == null) { - peekToken.next = Next(); - } - peekToken = peekToken.next; - return peekToken; - } - - protected static bool IsIdentifierPart(int ch) - { - if (ch == 95) return true; // 95 = '_' - if (ch == -1) return false; - return char.IsLetterOrDigit((char)ch); // accept unicode letters - } - - protected static bool IsHex(char digit) - { - return Char.IsDigit(digit) || ('A' <= digit && digit <= 'F') || ('a' <= digit && digit <= 'f'); - } - - protected int GetHexNumber(char digit) - { - if (Char.IsDigit(digit)) { - return digit - '0'; - } - if ('A' <= digit && digit <= 'F') { - return digit - 'A' + 0xA; - } - if ('a' <= digit && digit <= 'f') { - return digit - 'a' + 0xA; - } - errors.Error(line, col, String.Format("Invalid hex number '" + digit + "'")); - return 0; - } - protected TextLocation lastLineEnd = new TextLocation(1, 1); - protected TextLocation curLineEnd = new TextLocation(1, 1); - protected void LineBreak () - { - lastLineEnd = curLineEnd; - curLineEnd = new TextLocation (line, col - 1); - } - protected bool HandleLineEnd(char ch) - { - // Handle MS-DOS or MacOS line ends. - if (ch == '\r') { - if (reader.Peek() == '\n') { // MS-DOS line end '\r\n' - ReaderRead(); // LineBreak (); called by ReaderRead (); - return true; - } else { // assume MacOS line end which is '\r' - LineBreak (); - return true; - } - } - if (ch == '\n') { - LineBreak (); - return true; - } - return false; - } - - protected void SkipToEndOfLine() - { - int nextChar; - while ((nextChar = reader.Read()) != -1) { - if (nextChar == '\r') { - if (reader.Peek() == '\n') - reader.Read(); - nextChar = '\n'; - } - if (nextChar == '\n') { - ++line; - col = 1; - break; - } - } - } - - protected string ReadToEndOfLine() - { - sb.Length = 0; - int nextChar; - while ((nextChar = reader.Read()) != -1) { - char ch = (char)nextChar; - - if (nextChar == '\r') { - if (reader.Peek() == '\n') - reader.Read(); - nextChar = '\n'; - } - // Return read string, if EOL is reached - if (nextChar == '\n') { - ++line; - col = 1; - return sb.ToString(); - } - - sb.Append(ch); - } - - // Got EOF before EOL - string retStr = sb.ToString(); - col += retStr.Length; - return retStr; - } - - public event EventHandler SavepointReached; - - protected virtual void OnSavepointReached(SavepointEventArgs e) - { - if (SavepointReached != null) { - SavepointReached(this, e); - } - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/VBLexerMemento.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/VBLexerMemento.cs deleted file mode 100644 index 30e9d0f8c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/VBLexerMemento.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public sealed class VBLexerMemento - { - public int Line { get; set; } - public int Column { get; set; } - public int PrevTokenKind { get; set; } - public bool LineEnd { get; set; } - public bool IsAtLineBegin { get; set; } - public bool MisreadExclamationMarkAsTypeCharacter { get; set; } - public bool EncounteredLineContinuation { get; set; } - public ExpressionFinderState ExpressionFinder { get; set; } - public Stack XmlModeInfoStack { get; set; } - public bool InXmlMode { get; set; } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/XmlModeInfo.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/XmlModeInfo.cs deleted file mode 100644 index 2141ac353..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Lexer/XmlModeInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public class XmlModeInfo : ICloneable - { - public bool inXmlTag, inXmlCloseTag, isDocumentStart; - public int level; - - public XmlModeInfo(bool isSpecial) - { - level = isSpecial ? -1 : 0; - inXmlTag = inXmlCloseTag = isDocumentStart = false; - } - - public object Clone() - { - return new XmlModeInfo(false) { - inXmlCloseTag = this.inXmlCloseTag, - inXmlTag = this.inXmlTag, - isDocumentStart = this.isDocumentStart, - level = this.level - }; - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/IOutputFormatter.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/IOutputFormatter.cs deleted file mode 100644 index 056b0d1cd..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/IOutputFormatter.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB -{ - /// - /// Output formatter for the Output visitor. - /// - public interface IOutputFormatter - { - void StartNode(AstNode node); - void EndNode(AstNode node); - - /// - /// Writes an identifier. - /// If the identifier conflicts with a keyword, the output visitor will - /// call WriteToken("[") before and WriteToken("]") after calling WriteIdentifier(). - /// - void WriteIdentifier(string identifier); - - /// - /// Writes a keyword to the output. - /// - void WriteKeyword(string keyword); - - /// - /// Writes a token to the output. - /// - void WriteToken(string token); - void Space(); - - void Indent(); - void Unindent(); - - void NewLine(); - - void WriteComment(bool isDocumentation, string content); - - void MarkFoldStart(); - void MarkFoldEnd(); - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs deleted file mode 100644 index 495768131..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs +++ /dev/null @@ -1,2642 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; - -using ICSharpCode.NRefactory.PatternMatching; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB -{ - /// - /// Description of OutputVisitor. - /// - public class OutputVisitor : IAstVisitor - { - readonly IOutputFormatter formatter; - readonly VBFormattingOptions policy; - - readonly Stack containerStack = new Stack(); - readonly Stack positionStack = new Stack(); - - /// - /// Used to insert the minimal amount of spaces so that the lexer recognizes the tokens that were written. - /// - LastWritten lastWritten; - - enum LastWritten - { - Whitespace, - Other, - KeywordOrIdentifier - } - - public OutputVisitor(TextWriter textWriter, VBFormattingOptions formattingPolicy) - { - if (textWriter == null) - throw new ArgumentNullException("textWriter"); - if (formattingPolicy == null) - throw new ArgumentNullException("formattingPolicy"); - this.formatter = new TextWriterOutputFormatter(textWriter); - this.policy = formattingPolicy; - } - - public OutputVisitor(IOutputFormatter formatter, VBFormattingOptions formattingPolicy) - { - if (formatter == null) - throw new ArgumentNullException("formatter"); - if (formattingPolicy == null) - throw new ArgumentNullException("formattingPolicy"); - this.formatter = formatter; - this.policy = formattingPolicy; - } - - public object VisitCompilationUnit(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) - { - // prepare new block - NewLine(); - Indent(); - - StartNode(blockStatement); - foreach (var stmt in blockStatement) { - stmt.AcceptVisitor(this, data); - NewLine(); - } - // finish block - Unindent(); - return EndNode(blockStatement); - } - - public object VisitPatternPlaceholder(AstNode placeholder, Pattern pattern, object data) - { - throw new NotImplementedException(); - } - - public object VisitTypeParameterDeclaration(TypeParameterDeclaration typeParameterDeclaration, object data) - { - StartNode(typeParameterDeclaration); - - switch (typeParameterDeclaration.Variance) { - case ICSharpCode.NRefactory.TypeSystem.VarianceModifier.Invariant: - break; - case ICSharpCode.NRefactory.TypeSystem.VarianceModifier.Covariant: - WriteKeyword("Out"); - break; - case ICSharpCode.NRefactory.TypeSystem.VarianceModifier.Contravariant: - WriteKeyword("In"); - break; - default: - throw new Exception("Invalid value for VarianceModifier"); - } - - WriteIdentifier(typeParameterDeclaration.Name); - if (typeParameterDeclaration.Constraints.Any()) { - WriteKeyword("As"); - if (typeParameterDeclaration.Constraints.Count > 1) - WriteToken("{", TypeParameterDeclaration.Roles.LBrace); - WriteCommaSeparatedList(typeParameterDeclaration.Constraints); - if (typeParameterDeclaration.Constraints.Count > 1) - WriteToken("}", TypeParameterDeclaration.Roles.RBrace); - } - - return EndNode(typeParameterDeclaration); - } - - public object VisitParameterDeclaration(ParameterDeclaration parameterDeclaration, object data) - { - StartNode(parameterDeclaration); - WriteAttributes(parameterDeclaration.Attributes); - WriteModifiers(parameterDeclaration.ModifierTokens); - WriteIdentifier(parameterDeclaration.Name.Name); - if (!parameterDeclaration.Type.IsNull) { - WriteKeyword("As"); - parameterDeclaration.Type.AcceptVisitor(this, data); - } - if (!parameterDeclaration.OptionalValue.IsNull) { - WriteToken("=", ParameterDeclaration.Roles.Assign); - parameterDeclaration.OptionalValue.AcceptVisitor(this, data); - } - return EndNode(parameterDeclaration); - } - - public object VisitVBTokenNode(VBTokenNode vBTokenNode, object data) - { - var mod = vBTokenNode as VBModifierToken; - if (mod != null) { - StartNode(vBTokenNode); - WriteKeyword(VBModifierToken.GetModifierName(mod.Modifier)); - return EndNode(vBTokenNode); - } else { - throw new NotSupportedException("Should never visit individual tokens"); - } - } - - public object VisitAliasImportsClause(AliasImportsClause aliasImportsClause, object data) - { - throw new NotImplementedException(); - } - - public object VisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) - { - StartNode(attribute); - - if (attribute.Target != AttributeTarget.None) { - switch (attribute.Target) { - case AttributeTarget.None: - break; - case AttributeTarget.Assembly: - WriteKeyword("Assembly"); - break; - case AttributeTarget.Module: - WriteKeyword("Module"); - break; - default: - throw new Exception("Invalid value for AttributeTarget"); - } - WriteToken(":", Ast.Attribute.Roles.Colon); - Space(); - } - attribute.Type.AcceptVisitor(this, data); - WriteCommaSeparatedListInParenthesis(attribute.Arguments, false); - - return EndNode(attribute); - } - - public object VisitAttributeBlock(AttributeBlock attributeBlock, object data) - { - StartNode(attributeBlock); - - WriteToken("<", AttributeBlock.Roles.LChevron); - WriteCommaSeparatedList(attributeBlock.Attributes); - WriteToken(">", AttributeBlock.Roles.RChevron); - if (attributeBlock.Parent is ParameterDeclaration) - Space(); - else - NewLine(); - - return EndNode(attributeBlock); - } - - public object VisitImportsStatement(ImportsStatement importsStatement, object data) - { - StartNode(importsStatement); - - WriteKeyword("Imports", AstNode.Roles.Keyword); - Space(); - WriteCommaSeparatedList(importsStatement.ImportsClauses); - NewLine(); - - return EndNode(importsStatement); - } - - public object VisitMemberImportsClause(MemberImportsClause memberImportsClause, object data) - { - StartNode(memberImportsClause); - memberImportsClause.Member.AcceptVisitor(this, data); - return EndNode(memberImportsClause); - } - - public object VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) - { - StartNode(namespaceDeclaration); - NewLine(); - WriteKeyword("Namespace"); - bool isFirst = true; - foreach (Identifier node in namespaceDeclaration.Identifiers) { - if (isFirst) { - isFirst = false; - } else { - WriteToken(".", NamespaceDeclaration.Roles.Dot); - } - node.AcceptVisitor(this, null); - } - NewLine(); - WriteMembers(namespaceDeclaration.Members); - WriteKeyword("End"); - WriteKeyword("Namespace"); - NewLine(); - return EndNode(namespaceDeclaration); - } - - public object VisitOptionStatement(OptionStatement optionStatement, object data) - { - throw new NotImplementedException(); - } - - public object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) - { - StartNode(typeDeclaration); - WriteAttributes(typeDeclaration.Attributes); - WriteModifiers(typeDeclaration.ModifierTokens); - WriteClassTypeKeyword(typeDeclaration); - WriteIdentifier(typeDeclaration.Name.Name); - WriteTypeParameters(typeDeclaration.TypeParameters); - MarkFoldStart(); - NewLine(); - - if (!typeDeclaration.InheritsType.IsNull) { - Indent(); - WriteKeyword("Inherits"); - typeDeclaration.InheritsType.AcceptVisitor(this, data); - Unindent(); - NewLine(); - } - if (typeDeclaration.ImplementsTypes.Any()) { - Indent(); - WriteImplementsClause(typeDeclaration.ImplementsTypes); - Unindent(); - NewLine(); - } - - if (!typeDeclaration.InheritsType.IsNull || typeDeclaration.ImplementsTypes.Any()) - NewLine(); - - WriteMembers(typeDeclaration.Members); - - WriteKeyword("End"); - WriteClassTypeKeyword(typeDeclaration); - MarkFoldEnd(); - NewLine(); - return EndNode(typeDeclaration); - } - - void WriteClassTypeKeyword(TypeDeclaration typeDeclaration) - { - switch (typeDeclaration.ClassType) { - case ClassType.Class: - WriteKeyword("Class"); - break; - case ClassType.Interface: - WriteKeyword("Interface"); - break; - case ClassType.Struct: - WriteKeyword("Structure"); - break; - case ClassType.Module: - WriteKeyword("Module"); - break; - default: - throw new Exception("Invalid value for ClassType"); - } - } - - public object VisitXmlNamespaceImportsClause(XmlNamespaceImportsClause xmlNamespaceImportsClause, object data) - { - throw new NotImplementedException(); - } - - public object VisitEnumDeclaration(EnumDeclaration enumDeclaration, object data) - { - StartNode(enumDeclaration); - - WriteAttributes(enumDeclaration.Attributes); - WriteModifiers(enumDeclaration.ModifierTokens); - WriteKeyword("Enum"); - WriteIdentifier(enumDeclaration.Name.Name); - if (!enumDeclaration.UnderlyingType.IsNull) { - Space(); - WriteKeyword("As"); - enumDeclaration.UnderlyingType.AcceptVisitor(this, data); - } - MarkFoldStart(); - NewLine(); - - Indent(); - foreach (var member in enumDeclaration.Members) { - member.AcceptVisitor(this, null); - } - Unindent(); - - WriteKeyword("End"); - WriteKeyword("Enum"); - MarkFoldEnd(); - NewLine(); - - return EndNode(enumDeclaration); - } - - public object VisitEnumMemberDeclaration(EnumMemberDeclaration enumMemberDeclaration, object data) - { - StartNode(enumMemberDeclaration); - - WriteAttributes(enumMemberDeclaration.Attributes); - WriteIdentifier(enumMemberDeclaration.Name.Name); - - if (!enumMemberDeclaration.Value.IsNull) { - Space(); - WriteToken("=", EnumMemberDeclaration.Roles.Assign); - Space(); - enumMemberDeclaration.Value.AcceptVisitor(this, data); - } - NewLine(); - - return EndNode(enumMemberDeclaration); - } - - public object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data) - { - StartNode(delegateDeclaration); - - WriteAttributes(delegateDeclaration.Attributes); - WriteModifiers(delegateDeclaration.ModifierTokens); - WriteKeyword("Delegate"); - if (delegateDeclaration.IsSub) - WriteKeyword("Sub"); - else - WriteKeyword("Function"); - WriteIdentifier(delegateDeclaration.Name.Name); - WriteTypeParameters(delegateDeclaration.TypeParameters); - WriteCommaSeparatedListInParenthesis(delegateDeclaration.Parameters, false); - if (!delegateDeclaration.IsSub) { - Space(); - WriteKeyword("As"); - WriteAttributes(delegateDeclaration.ReturnTypeAttributes); - delegateDeclaration.ReturnType.AcceptVisitor(this, data); - } - NewLine(); - - return EndNode(delegateDeclaration); - } - - public object VisitIdentifier(Identifier identifier, object data) - { - StartNode(identifier); - WriteIdentifier(identifier.Name); - WriteTypeCharacter(identifier.TypeCharacter); - return EndNode(identifier); - } - - public object VisitXmlIdentifier(XmlIdentifier xmlIdentifier, object data) - { - throw new NotImplementedException(); - } - - public object VisitXmlLiteralString(XmlLiteralString xmlLiteralString, object data) - { - throw new NotImplementedException(); - } - - public object VisitSimpleNameExpression(SimpleNameExpression simpleNameExpression, object data) - { - StartNode(simpleNameExpression); - - simpleNameExpression.Identifier.AcceptVisitor(this, data); - WriteTypeArguments(simpleNameExpression.TypeArguments); - - return EndNode(simpleNameExpression); - } - - public object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) - { - StartNode(primitiveExpression); - - if (lastWritten == LastWritten.KeywordOrIdentifier) - Space(); - WritePrimitiveValue(primitiveExpression.Value); - - return EndNode(primitiveExpression); - } - - public object VisitInstanceExpression(InstanceExpression instanceExpression, object data) - { - StartNode(instanceExpression); - - switch (instanceExpression.Type) { - case InstanceExpressionType.Me: - WriteKeyword("Me"); - break; - case InstanceExpressionType.MyBase: - WriteKeyword("MyBase"); - break; - case InstanceExpressionType.MyClass: - WriteKeyword("MyClass"); - break; - default: - throw new Exception("Invalid value for InstanceExpressionType"); - } - - return EndNode(instanceExpression); - } - - public object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) - { - StartNode(parenthesizedExpression); - - LPar(); - parenthesizedExpression.Expression.AcceptVisitor(this, data); - RPar(); - - return EndNode(parenthesizedExpression); - } - - public object VisitGetTypeExpression(GetTypeExpression getTypeExpression, object data) - { - StartNode(getTypeExpression); - - WriteKeyword("GetType"); - LPar(); - getTypeExpression.Type.AcceptVisitor(this, data); - RPar(); - - return EndNode(getTypeExpression); - } - - public object VisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data) - { - StartNode(typeOfIsExpression); - - WriteKeyword("TypeOf"); - typeOfIsExpression.TypeOfExpression.AcceptVisitor(this, data); - WriteKeyword("Is"); - typeOfIsExpression.Type.AcceptVisitor(this, data); - - return EndNode(typeOfIsExpression); - } - - public object VisitGetXmlNamespaceExpression(GetXmlNamespaceExpression getXmlNamespaceExpression, object data) - { - throw new NotImplementedException(); - } - - public object VisitMemberAccessExpression(MemberAccessExpression memberAccessExpression, object data) - { - StartNode(memberAccessExpression); - - memberAccessExpression.Target.AcceptVisitor(this, data); - WriteToken(".", MemberAccessExpression.Roles.Dot); - memberAccessExpression.MemberName.AcceptVisitor(this, data); - WriteTypeArguments(memberAccessExpression.TypeArguments); - - return EndNode(memberAccessExpression); - } - - public object VisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) - { - StartNode(typeReferenceExpression); - - typeReferenceExpression.Type.AcceptVisitor(this, data); - - return EndNode(typeReferenceExpression); - } - - public object VisitEventMemberSpecifier(EventMemberSpecifier eventMemberSpecifier, object data) - { - StartNode(eventMemberSpecifier); - - eventMemberSpecifier.Target.AcceptVisitor(this, data); - WriteToken(".", EventMemberSpecifier.Roles.Dot); - eventMemberSpecifier.Member.AcceptVisitor(this, data); - - return EndNode(eventMemberSpecifier); - } - - public object VisitInterfaceMemberSpecifier(InterfaceMemberSpecifier interfaceMemberSpecifier, object data) - { - StartNode(interfaceMemberSpecifier); - - interfaceMemberSpecifier.Target.AcceptVisitor(this, data); - WriteToken(".", EventMemberSpecifier.Roles.Dot); - interfaceMemberSpecifier.Member.AcceptVisitor(this, data); - - return EndNode(interfaceMemberSpecifier); - } - - #region TypeMembers - public object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) - { - StartNode(constructorDeclaration); - - WriteAttributes(constructorDeclaration.Attributes); - WriteModifiers(constructorDeclaration.ModifierTokens); - WriteKeyword("Sub"); - WriteKeyword("New"); - WriteCommaSeparatedListInParenthesis(constructorDeclaration.Parameters, false); - MarkFoldStart(); - WriteBlock(constructorDeclaration.Body); - WriteKeyword("End"); - WriteKeyword("Sub"); - MarkFoldEnd(); - NewLine(); - - return EndNode(constructorDeclaration); - } - - public object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) - { - StartNode(methodDeclaration); - - WriteAttributes(methodDeclaration.Attributes); - WriteModifiers(methodDeclaration.ModifierTokens); - if (methodDeclaration.IsSub) - WriteKeyword("Sub"); - else - WriteKeyword("Function"); - methodDeclaration.Name.AcceptVisitor(this, data); - WriteTypeParameters(methodDeclaration.TypeParameters); - WriteCommaSeparatedListInParenthesis(methodDeclaration.Parameters, false); - if (!methodDeclaration.IsSub && !methodDeclaration.ReturnType.IsNull) { - Space(); - WriteKeyword("As"); - WriteAttributes(methodDeclaration.ReturnTypeAttributes); - methodDeclaration.ReturnType.AcceptVisitor(this, data); - } - WriteHandlesClause(methodDeclaration.HandlesClause); - WriteImplementsClause(methodDeclaration.ImplementsClause); - if (!methodDeclaration.Body.IsNull) { - MarkFoldStart(); - WriteBlock(methodDeclaration.Body); - WriteKeyword("End"); - if (methodDeclaration.IsSub) - WriteKeyword("Sub"); - else - WriteKeyword("Function"); - MarkFoldEnd(); - } - NewLine(); - - return EndNode(methodDeclaration); - } - - public object VisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) - { - StartNode(fieldDeclaration); - - WriteAttributes(fieldDeclaration.Attributes); - WriteModifiers(fieldDeclaration.ModifierTokens); - WriteCommaSeparatedList(fieldDeclaration.Variables); - NewLine(); - - return EndNode(fieldDeclaration); - } - - public object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) - { - StartNode(propertyDeclaration); - - WriteAttributes(propertyDeclaration.Attributes); - WriteModifiers(propertyDeclaration.ModifierTokens); - WriteKeyword("Property"); - WriteIdentifier(propertyDeclaration.Name.Name); - WriteCommaSeparatedListInParenthesis(propertyDeclaration.Parameters, false); - if (!propertyDeclaration.ReturnType.IsNull) { - Space(); - WriteKeyword("As"); - WriteAttributes(propertyDeclaration.ReturnTypeAttributes); - propertyDeclaration.ReturnType.AcceptVisitor(this, data); - } - - bool needsBody = !propertyDeclaration.Getter.Body.IsNull || !propertyDeclaration.Setter.Body.IsNull; - - if (needsBody) { - MarkFoldStart(); - NewLine(); - Indent(); - - if (!propertyDeclaration.Getter.Body.IsNull) { - propertyDeclaration.Getter.AcceptVisitor(this, data); - } - - if (!propertyDeclaration.Setter.Body.IsNull) { - propertyDeclaration.Setter.AcceptVisitor(this, data); - } - Unindent(); - - WriteKeyword("End"); - WriteKeyword("Property"); - MarkFoldEnd(); - } - NewLine(); - - return EndNode(propertyDeclaration); - } - #endregion - - #region TypeName - public object VisitPrimitiveType(PrimitiveType primitiveType, object data) - { - StartNode(primitiveType); - - WriteKeyword(primitiveType.Keyword); - - return EndNode(primitiveType); - } - - public object VisitQualifiedType(QualifiedType qualifiedType, object data) - { - StartNode(qualifiedType); - - qualifiedType.Target.AcceptVisitor(this, data); - WriteToken(".", AstNode.Roles.Dot); - WriteIdentifier(qualifiedType.Name); - WriteTypeArguments(qualifiedType.TypeArguments); - - return EndNode(qualifiedType); - } - - public object VisitComposedType(ComposedType composedType, object data) - { - StartNode(composedType); - - composedType.BaseType.AcceptVisitor(this, data); - if (composedType.HasNullableSpecifier) - WriteToken("?", ComposedType.Roles.QuestionMark); - WriteArraySpecifiers(composedType.ArraySpecifiers); - - return EndNode(composedType); - } - - public object VisitArraySpecifier(ArraySpecifier arraySpecifier, object data) - { - StartNode(arraySpecifier); - - LPar(); - for (int i = 0; i < arraySpecifier.Dimensions - 1; i++) { - WriteToken(",", ArraySpecifier.Roles.Comma); - } - RPar(); - - return EndNode(arraySpecifier); - } - - public object VisitSimpleType(SimpleType simpleType, object data) - { - StartNode(simpleType); - - WriteIdentifier(simpleType.Identifier); - WriteTypeArguments(simpleType.TypeArguments); - - return EndNode(simpleType); - } - #endregion - - #region StartNode/EndNode - void StartNode(AstNode node) - { - // Ensure that nodes are visited in the proper nested order. - // Jumps to different subtrees are allowed only for the child of a placeholder node. - Debug.Assert(containerStack.Count == 0 || node.Parent == containerStack.Peek()); - if (positionStack.Count > 0) - WriteSpecialsUpToNode(node); - containerStack.Push(node); - positionStack.Push(node.FirstChild); - formatter.StartNode(node); - } - - object EndNode(AstNode node) - { - Debug.Assert(node == containerStack.Peek()); - AstNode pos = positionStack.Pop(); - Debug.Assert(pos == null || pos.Parent == node); - WriteSpecials(pos, null); - containerStack.Pop(); - formatter.EndNode(node); - return null; - } - #endregion - - #region WriteSpecials - /// - /// Writes all specials from start to end (exclusive). Does not touch the positionStack. - /// - void WriteSpecials(AstNode start, AstNode end) - { - for (AstNode pos = start; pos != end; pos = pos.NextSibling) { - if (pos.Role == AstNode.Roles.Comment) { - pos.AcceptVisitor(this, null); - } - } - } - - /// - /// Writes all specials between the current position (in the positionStack) and the next - /// node with the specified role. Advances the current position. - /// - void WriteSpecialsUpToRole(Role role) - { - for (AstNode pos = positionStack.Peek(); pos != null; pos = pos.NextSibling) { - if (pos.Role == role) { - WriteSpecials(positionStack.Pop(), pos); - positionStack.Push(pos); - break; - } - } - } - - /// - /// Writes all specials between the current position (in the positionStack) and the specified node. - /// Advances the current position. - /// - void WriteSpecialsUpToNode(AstNode node) - { - for (AstNode pos = positionStack.Peek(); pos != null; pos = pos.NextSibling) { - if (pos == node) { - WriteSpecials(positionStack.Pop(), pos); - positionStack.Push(pos); - break; - } - } - } - - void WriteSpecialsUpToRole(Role role, AstNode nextNode) - { - // Look for the role between the current position and the nextNode. - for (AstNode pos = positionStack.Peek(); pos != null && pos != nextNode; pos = pos.NextSibling) { - if (pos.Role == AstNode.Roles.Comma) { - WriteSpecials(positionStack.Pop(), pos); - positionStack.Push(pos); - break; - } - } - } - #endregion - - #region Comma - /// - /// Writes a comma. - /// - /// The next node after the comma. - /// When set prevents printing a space after comma. - void Comma(AstNode nextNode, bool noSpaceAfterComma = false) - { - WriteSpecialsUpToRole(AstNode.Roles.Comma, nextNode); - formatter.WriteToken(","); - lastWritten = LastWritten.Other; - Space(!noSpaceAfterComma); // TODO: Comma policy has changed. - } - - void WriteCommaSeparatedList(IEnumerable list) - { - bool isFirst = true; - foreach (AstNode node in list) { - if (isFirst) { - isFirst = false; - } else { - Comma(node); - } - node.AcceptVisitor(this, null); - } - } - - void WriteCommaSeparatedListInParenthesis(IEnumerable list, bool spaceWithin) - { - LPar(); - if (list.Any()) { - Space(spaceWithin); - WriteCommaSeparatedList(list); - Space(spaceWithin); - } - RPar(); - } - - #if DOTNET35 - void WriteCommaSeparatedList(IEnumerable list) - { - WriteCommaSeparatedList(list); - } - - void WriteCommaSeparatedList(IEnumerable list) - { - WriteCommaSeparatedList(list); - } - - void WriteCommaSeparatedListInParenthesis(IEnumerable list, bool spaceWithin) - { - WriteCommaSeparatedListInParenthesis(list.SafeCast(), spaceWithin); - } - - void WriteCommaSeparatedListInParenthesis(IEnumerable list, bool spaceWithin) - { - WriteCommaSeparatedListInParenthesis(list.SafeCast(), spaceWithin); - } - - #endif - - void WriteCommaSeparatedListInBrackets(IEnumerable list, bool spaceWithin) - { - WriteToken("[", AstNode.Roles.LBracket); - if (list.Any()) { - Space(spaceWithin); - WriteCommaSeparatedList(list); - Space(spaceWithin); - } - WriteToken("]", AstNode.Roles.RBracket); - } - #endregion - - #region Write tokens - /// - /// Writes a keyword, and all specials up to - /// - void WriteKeyword(string keyword, Role tokenRole = null) - { - WriteSpecialsUpToRole(tokenRole ?? AstNode.Roles.Keyword); - if (lastWritten == LastWritten.KeywordOrIdentifier) - formatter.Space(); - formatter.WriteKeyword(keyword); - lastWritten = LastWritten.KeywordOrIdentifier; - } - - void WriteIdentifier(string identifier, Role identifierRole = null) - { - WriteSpecialsUpToRole(identifierRole ?? AstNode.Roles.Identifier); - - if (lastWritten == LastWritten.KeywordOrIdentifier) - Space(); // this space is not strictly required, so we call Space() - - if (IsKeyword(identifier, containerStack.Peek())) - formatter.WriteToken("["); - - formatter.WriteIdentifier(identifier); - if (IsKeyword(identifier, containerStack.Peek())) - formatter.WriteToken("]"); - - lastWritten = LastWritten.KeywordOrIdentifier; - } - - void WriteToken(string token, Role tokenRole) - { - WriteSpecialsUpToRole(tokenRole); - // Avoid that two +, - or ? tokens are combined into a ++, -- or ?? token. - // Note that we don't need to handle tokens like = because there's no valid - // C# program that contains the single token twice in a row. - // (for +, - and &, this can happen with unary operators; - // for ?, this can happen in "a is int? ? b : c" or "a as int? ?? 0"; - // and for /, this can happen with "1/ *ptr" or "1/ //comment".) -// if (lastWritten == LastWritten.Plus && token[0] == '+' -// || lastWritten == LastWritten.Minus && token[0] == '-' -// || lastWritten == LastWritten.Ampersand && token[0] == '&' -// || lastWritten == LastWritten.QuestionMark && token[0] == '?' -// || lastWritten == LastWritten.Division && token[0] == '*') -// { -// formatter.Space(); -// } - formatter.WriteToken(token); -// if (token == "+") -// lastWritten = LastWritten.Plus; -// else if (token == "-") -// lastWritten = LastWritten.Minus; -// else if (token == "&") -// lastWritten = LastWritten.Ampersand; -// else if (token == "?") -// lastWritten = LastWritten.QuestionMark; -// else if (token == "/") -// lastWritten = LastWritten.Division; -// else - lastWritten = LastWritten.Other; - } - - void WriteTypeCharacter(TypeCode typeCharacter) - { - switch (typeCharacter) { - case TypeCode.Empty: - case TypeCode.Object: - case TypeCode.DBNull: - case TypeCode.Boolean: - case TypeCode.Char: - - break; - case TypeCode.SByte: - - break; - case TypeCode.Byte: - - break; - case TypeCode.Int16: - - break; - case TypeCode.UInt16: - - break; - case TypeCode.Int32: - WriteToken("%", null); - break; - case TypeCode.UInt32: - - break; - case TypeCode.Int64: - WriteToken("&", null); - break; - case TypeCode.UInt64: - - break; - case TypeCode.Single: - WriteToken("!", null); - break; - case TypeCode.Double: - WriteToken("#", null); - break; - case TypeCode.Decimal: - WriteToken("@", null); - break; - case TypeCode.DateTime: - - break; - case TypeCode.String: - WriteToken("$", null); - break; - default: - throw new Exception("Invalid value for TypeCode"); - } - } - - void LPar() - { - WriteToken("(", AstNode.Roles.LPar); - } - - void RPar() - { - WriteToken(")", AstNode.Roles.LPar); - } - - /// - /// Writes a space depending on policy. - /// - void Space(bool addSpace = true) - { - if (addSpace) { - formatter.Space(); - lastWritten = LastWritten.Whitespace; - } - } - - void NewLine() - { - formatter.NewLine(); - lastWritten = LastWritten.Whitespace; - } - - void Indent() - { - formatter.Indent(); - } - - void Unindent() - { - formatter.Unindent(); - } - - void MarkFoldStart() - { - formatter.MarkFoldStart(); - } - - void MarkFoldEnd() - { - formatter.MarkFoldEnd(); - } - #endregion - - #region IsKeyword Test - static readonly HashSet unconditionalKeywords = new HashSet(StringComparer.OrdinalIgnoreCase) { - "AddHandler", "AddressOf", "Alias", "And", "AndAlso", "As", "Boolean", "ByRef", "Byte", - "ByVal", "Call", "Case", "Catch", "CBool", "CByte", "CChar", "CInt", "Class", "CLng", - "CObj", "Const", "Continue", "CSByte", "CShort", "CSng", "CStr", "CType", "CUInt", - "CULng", "CUShort", "Date", "Decimal", "Declare", "Default", "Delegate", "Dim", - "DirectCast", "Do", "Double", "Each", "Else", "ElseIf", "End", "EndIf", "Enum", "Erase", - "Error", "Event", "Exit", "False", "Finally", "For", "Friend", "Function", "Get", - "GetType", "GetXmlNamespace", "Global", "GoSub", "GoTo", "Handles", "If", "Implements", - "Imports", "In", "Inherits", "Integer", "Interface", "Is", "IsNot", "Let", "Lib", "Like", - "Long", "Loop", "Me", "Mod", "Module", "MustInherit", "MustOverride", "MyBase", "MyClass", - "Namespace", "Narrowing", "Next", "Not", "Nothing", "NotInheritable", "NotOverridable", - "Object", "Of", "On", "Operator", "Option", "Optional", "Or", "OrElse", "Overloads", - "Overridable", "Overrides", "ParamArray", "Partial", "Private", "Property", "Protected", - "Public", "RaiseEvent", "ReadOnly", "ReDim", "REM", "RemoveHandler", "Resume", "Return", - "SByte", "Select", "Set", "Shadows", "Shared", "Short", "Single", "Static", "Step", "Stop", - "String", "Structure", "Sub", "SyncLock", "Then", "Throw", "To", "True", "Try", "TryCast", - "TypeOf", "UInteger", "ULong", "UShort", "Using", "Variant", "Wend", "When", "While", - "Widening", "With", "WithEvents", "WriteOnly", "Xor" - }; - - static readonly HashSet queryKeywords = new HashSet { - - }; - - /// - /// Determines whether the specified identifier is a keyword in the given context. - /// - public static bool IsKeyword(string identifier, AstNode context) - { - if (identifier == "New") { - if (context.PrevSibling is InstanceExpression) - return false; - return true; - } - if (unconditionalKeywords.Contains(identifier)) - return true; -// if (context.Ancestors.Any(a => a is QueryExpression)) { -// if (queryKeywords.Contains(identifier)) -// return true; -// } - return false; - } - #endregion - - #region Write constructs - void WriteTypeArguments(IEnumerable typeArguments) - { - if (typeArguments.Any()) { - LPar(); - WriteKeyword("Of"); - WriteCommaSeparatedList(typeArguments); - RPar(); - } - } - - void WriteTypeParameters(IEnumerable typeParameters) - { - if (typeParameters.Any()) { - LPar(); - WriteKeyword("Of"); - WriteCommaSeparatedList(typeParameters); - RPar(); - } - } - - void WriteModifiers(IEnumerable modifierTokens) - { - foreach (VBModifierToken modifier in modifierTokens) { - modifier.AcceptVisitor(this, null); - } - } - - void WriteArraySpecifiers(IEnumerable arraySpecifiers) - { - foreach (ArraySpecifier specifier in arraySpecifiers) { - specifier.AcceptVisitor(this, null); - } - } - - void WriteQualifiedIdentifier(IEnumerable identifiers) - { - bool first = true; - foreach (Identifier ident in identifiers) { - if (first) { - first = false; - if (lastWritten == LastWritten.KeywordOrIdentifier) - formatter.Space(); - } else { - WriteSpecialsUpToRole(AstNode.Roles.Dot, ident); - formatter.WriteToken("."); - lastWritten = LastWritten.Other; - } - WriteSpecialsUpToNode(ident); - formatter.WriteIdentifier(ident.Name); - lastWritten = LastWritten.KeywordOrIdentifier; - } - } - - void WriteEmbeddedStatement(Statement embeddedStatement) - { - if (embeddedStatement.IsNull) - return; - BlockStatement block = embeddedStatement as BlockStatement; - if (block != null) - VisitBlockStatement(block, null); - else - embeddedStatement.AcceptVisitor(this, null); - } - - void WriteBlock(BlockStatement body) - { - if (body.IsNull) { - NewLine(); - Indent(); - NewLine(); - Unindent(); - } else - VisitBlockStatement(body, null); - } - - void WriteMembers(IEnumerable members) - { - Indent(); - bool isFirst = true; - foreach (var member in members) { - if (isFirst) { - isFirst = false; - } else { - NewLine(); - } - member.AcceptVisitor(this, null); - } - Unindent(); - } - - void WriteAttributes(IEnumerable attributes) - { - foreach (AttributeBlock attr in attributes) { - attr.AcceptVisitor(this, null); - } - } - - void WritePrivateImplementationType(AstType privateImplementationType) - { - if (!privateImplementationType.IsNull) { - privateImplementationType.AcceptVisitor(this, null); - WriteToken(".", AstNode.Roles.Dot); - } - } - - void WriteImplementsClause(AstNodeCollection implementsClause) - { - if (implementsClause.Any()) { - Space(); - WriteKeyword("Implements"); - WriteCommaSeparatedList(implementsClause); - } - } - - void WriteImplementsClause(AstNodeCollection implementsClause) - { - if (implementsClause.Any()) { - WriteKeyword("Implements"); - WriteCommaSeparatedList(implementsClause); - } - } - - void WriteHandlesClause(AstNodeCollection handlesClause) - { - if (handlesClause.Any()) { - Space(); - WriteKeyword("Handles"); - WriteCommaSeparatedList(handlesClause); - } - } - - void WritePrimitiveValue(object val) - { - if (val == null) { - WriteKeyword("Nothing"); - return; - } - - if (val is bool) { - if ((bool)val) { - WriteKeyword("True"); - } else { - WriteKeyword("False"); - } - return; - } - - if (val is string) { - formatter.WriteToken("\"" + ConvertString(val.ToString()) + "\""); - lastWritten = LastWritten.Other; - } else if (val is char) { - formatter.WriteToken("\"" + ConvertCharLiteral((char)val) + "\"c"); - lastWritten = LastWritten.Other; - } else if (val is decimal) { - formatter.WriteToken(((decimal)val).ToString(NumberFormatInfo.InvariantInfo) + "D"); - lastWritten = LastWritten.Other; - } else if (val is float) { - float f = (float)val; - if (float.IsInfinity(f) || float.IsNaN(f)) { - // Strictly speaking, these aren't PrimitiveExpressions; - // but we still support writing these to make life easier for code generators. - WriteKeyword("Single"); - WriteToken(".", AstNode.Roles.Dot); - if (float.IsPositiveInfinity(f)) - WriteIdentifier("PositiveInfinity"); - else if (float.IsNegativeInfinity(f)) - WriteIdentifier("NegativeInfinity"); - else - WriteIdentifier("NaN"); - return; - } - formatter.WriteToken(f.ToString("R", NumberFormatInfo.InvariantInfo) + "F"); - lastWritten = LastWritten.Other; - } else if (val is double) { - double f = (double)val; - if (double.IsInfinity(f) || double.IsNaN(f)) { - // Strictly speaking, these aren't PrimitiveExpressions; - // but we still support writing these to make life easier for code generators. - WriteKeyword("Double"); - WriteToken(".", AstNode.Roles.Dot); - if (double.IsPositiveInfinity(f)) - WriteIdentifier("PositiveInfinity"); - else if (double.IsNegativeInfinity(f)) - WriteIdentifier("NegativeInfinity"); - else - WriteIdentifier("NaN"); - return; - } - string number = f.ToString("R", NumberFormatInfo.InvariantInfo); - if (number.IndexOf('.') < 0 && number.IndexOf('E') < 0) - number += ".0"; - formatter.WriteToken(number); - // needs space if identifier follows number; this avoids mistaking the following identifier as type suffix - lastWritten = LastWritten.KeywordOrIdentifier; - } else if (val is IFormattable) { - StringBuilder b = new StringBuilder(); - b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo)); - if (val is ushort || val is ulong) { - b.Append("U"); - } - if (val is short || val is ushort) { - b.Append("S"); - } else if (val is uint) { - b.Append("UI"); - } else if (val is long || val is ulong) { - b.Append("L"); - } - formatter.WriteToken(b.ToString()); - // needs space if identifier follows number; this avoids mistaking the following identifier as type suffix - lastWritten = LastWritten.KeywordOrIdentifier; - } else { - formatter.WriteToken(val.ToString()); - lastWritten = LastWritten.Other; - } - } - #endregion - - #region ConvertLiteral - static string ConvertCharLiteral(char ch) - { - if (ch == '"') return "\"\""; - return ch.ToString(); - } - - static string ConvertString(string str) - { - StringBuilder sb = new StringBuilder(); - foreach (char ch in str) { - sb.Append(ConvertCharLiteral(ch)); - } - return sb.ToString(); - } - #endregion - - public object VisitVariableIdentifier(VariableIdentifier variableIdentifier, object data) - { - StartNode(variableIdentifier); - - WriteIdentifier(variableIdentifier.Name.Name); - if (variableIdentifier.HasNullableSpecifier) - WriteToken("?", VariableIdentifier.Roles.QuestionMark); - if (variableIdentifier.ArraySizeSpecifiers.Count > 0) - WriteCommaSeparatedListInParenthesis(variableIdentifier.ArraySizeSpecifiers, false); - WriteArraySpecifiers(variableIdentifier.ArraySpecifiers); - - return EndNode(variableIdentifier); - } - - public object VisitAccessor(Accessor accessor, object data) - { - StartNode(accessor); - WriteAttributes(accessor.Attributes); - WriteModifiers(accessor.ModifierTokens); - if (accessor.Role == PropertyDeclaration.GetterRole) { - WriteKeyword("Get"); - } else if (accessor.Role == PropertyDeclaration.SetterRole) { - WriteKeyword("Set"); - } else if (accessor.Role == EventDeclaration.AddHandlerRole) { - WriteKeyword("AddHandler"); - } else if (accessor.Role == EventDeclaration.RemoveHandlerRole) { - WriteKeyword("RemoveHandler"); - } else if (accessor.Role == EventDeclaration.RaiseEventRole) { - WriteKeyword("RaiseEvent"); - } - if (accessor.Parameters.Any()) - WriteCommaSeparatedListInParenthesis(accessor.Parameters, false); - WriteBlock(accessor.Body); - WriteKeyword("End"); - - if (accessor.Role == PropertyDeclaration.GetterRole) { - WriteKeyword("Get"); - } else if (accessor.Role == PropertyDeclaration.SetterRole) { - WriteKeyword("Set"); - } else if (accessor.Role == EventDeclaration.AddHandlerRole) { - WriteKeyword("AddHandler"); - } else if (accessor.Role == EventDeclaration.RemoveHandlerRole) { - WriteKeyword("RemoveHandler"); - } else if (accessor.Role == EventDeclaration.RaiseEventRole) { - WriteKeyword("RaiseEvent"); - } - NewLine(); - - return EndNode(accessor); - } - - - public object VisitLabelDeclarationStatement(LabelDeclarationStatement labelDeclarationStatement, object data) - { - StartNode(labelDeclarationStatement); - - labelDeclarationStatement.Label.AcceptVisitor(this, data); - WriteToken(":", LabelDeclarationStatement.Roles.Colon); - - return EndNode(labelDeclarationStatement); - } - - public object VisitLocalDeclarationStatement(LocalDeclarationStatement localDeclarationStatement, object data) - { - StartNode(localDeclarationStatement); - - if (localDeclarationStatement.ModifierToken != null && !localDeclarationStatement.ModifierToken.IsNull) - WriteModifiers(new [] { localDeclarationStatement.ModifierToken }); - WriteCommaSeparatedList(localDeclarationStatement.Variables); - - return EndNode(localDeclarationStatement); - } - - public object VisitWithStatement(WithStatement withStatement, object data) - { - StartNode(withStatement); - WriteKeyword("With"); - withStatement.Expression.AcceptVisitor(this, data); - withStatement.Body.AcceptVisitor(this, data); - WriteKeyword("End"); - WriteKeyword("With"); - return EndNode(withStatement); - } - - public object VisitSyncLockStatement(SyncLockStatement syncLockStatement, object data) - { - StartNode(syncLockStatement); - WriteKeyword("SyncLock"); - syncLockStatement.Expression.AcceptVisitor(this, data); - syncLockStatement.Body.AcceptVisitor(this, data); - WriteKeyword("End"); - WriteKeyword("SyncLock"); - return EndNode(syncLockStatement); - } - - public object VisitTryStatement(TryStatement tryStatement, object data) - { - StartNode(tryStatement); - WriteKeyword("Try"); - tryStatement.Body.AcceptVisitor(this, data); - foreach (var clause in tryStatement.CatchBlocks) { - clause.AcceptVisitor(this, data); - } - if (!tryStatement.FinallyBlock.IsNull) { - WriteKeyword("Finally"); - tryStatement.FinallyBlock.AcceptVisitor(this, data); - } - WriteKeyword("End"); - WriteKeyword("Try"); - return EndNode(tryStatement); - } - - public object VisitCatchBlock(CatchBlock catchBlock, object data) - { - StartNode(catchBlock); - WriteKeyword("Catch"); - catchBlock.ExceptionVariable.AcceptVisitor(this, data); - if (!catchBlock.ExceptionType.IsNull) { - WriteKeyword("As"); - catchBlock.ExceptionType.AcceptVisitor(this, data); - } - NewLine(); - Indent(); - foreach (var stmt in catchBlock) { - stmt.AcceptVisitor(this, data); - NewLine(); - } - Unindent(); - return EndNode(catchBlock); - } - - public object VisitExpressionStatement(ExpressionStatement expressionStatement, object data) - { - StartNode(expressionStatement); - expressionStatement.Expression.AcceptVisitor(this, data); - return EndNode(expressionStatement); - } - - public object VisitThrowStatement(ThrowStatement throwStatement, object data) - { - StartNode(throwStatement); - - WriteKeyword("Throw"); - throwStatement.Expression.AcceptVisitor(this, data); - - return EndNode(throwStatement); - } - - public object VisitIfElseStatement(IfElseStatement ifElseStatement, object data) - { - StartNode(ifElseStatement); - WriteKeyword("If"); - ifElseStatement.Condition.AcceptVisitor(this, data); - Space(); - WriteKeyword("Then"); - bool needsEndIf = ifElseStatement.Body is BlockStatement; - ifElseStatement.Body.AcceptVisitor(this, data); - if (!ifElseStatement.ElseBlock.IsNull) { - WriteKeyword("Else"); - needsEndIf = ifElseStatement.ElseBlock is BlockStatement; - ifElseStatement.ElseBlock.AcceptVisitor(this, data); - } - if (needsEndIf) { - WriteKeyword("End"); - WriteKeyword("If"); - } - return EndNode(ifElseStatement); - } - - public object VisitReturnStatement(ReturnStatement returnStatement, object data) - { - StartNode(returnStatement); - WriteKeyword("Return"); - returnStatement.Expression.AcceptVisitor(this, data); - return EndNode(returnStatement); - } - - public object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) - { - StartNode(binaryOperatorExpression); - binaryOperatorExpression.Left.AcceptVisitor(this, data); - Space(); - switch (binaryOperatorExpression.Operator) { - case BinaryOperatorType.BitwiseAnd: - WriteKeyword("And"); - break; - case BinaryOperatorType.BitwiseOr: - WriteKeyword("Or"); - break; - case BinaryOperatorType.LogicalAnd: - WriteKeyword("AndAlso"); - break; - case BinaryOperatorType.LogicalOr: - WriteKeyword("OrElse"); - break; - case BinaryOperatorType.ExclusiveOr: - WriteKeyword("Xor"); - break; - case BinaryOperatorType.GreaterThan: - WriteToken(">", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.GreaterThanOrEqual: - WriteToken(">=", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Equality: - WriteToken("=", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.InEquality: - WriteToken("<>", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.LessThan: - WriteToken("<", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.LessThanOrEqual: - WriteToken("<=", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Add: - WriteToken("+", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Subtract: - WriteToken("-", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Multiply: - WriteToken("*", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Divide: - WriteToken("/", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Modulus: - WriteKeyword("Mod"); - break; - case BinaryOperatorType.DivideInteger: - WriteToken("\\", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Power: - WriteToken("*", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.Concat: - WriteToken("&", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.ShiftLeft: - WriteToken("<<", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.ShiftRight: - WriteToken(">>", BinaryOperatorExpression.OperatorRole); - break; - case BinaryOperatorType.ReferenceEquality: - WriteKeyword("Is"); - break; - case BinaryOperatorType.ReferenceInequality: - WriteKeyword("IsNot"); - break; - case BinaryOperatorType.Like: - WriteKeyword("Like"); - break; - case BinaryOperatorType.DictionaryAccess: - WriteToken("!", BinaryOperatorExpression.OperatorRole); - break; - default: - throw new Exception("Invalid value for BinaryOperatorType: " + binaryOperatorExpression.Operator); - } - Space(); - binaryOperatorExpression.Right.AcceptVisitor(this, data); - return EndNode(binaryOperatorExpression); - } - - public object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) - { - StartNode(identifierExpression); - identifierExpression.Identifier.AcceptVisitor(this, data); - WriteTypeArguments(identifierExpression.TypeArguments); - return EndNode(identifierExpression); - } - - public object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) - { - StartNode(assignmentExpression); - assignmentExpression.Left.AcceptVisitor(this, data); - Space(); - switch (assignmentExpression.Operator) { - case AssignmentOperatorType.Assign: - WriteToken("=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.Add: - WriteToken("+=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.Subtract: - WriteToken("-=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.Multiply: - WriteToken("*=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.Divide: - WriteToken("/=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.Power: - WriteToken("^=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.DivideInteger: - WriteToken("\\=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.ConcatString: - WriteToken("&=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.ShiftLeft: - WriteToken("<<=", AssignmentExpression.OperatorRole); - break; - case AssignmentOperatorType.ShiftRight: - WriteToken(">>=", AssignmentExpression.OperatorRole); - break; - default: - throw new Exception("Invalid value for AssignmentOperatorType: " + assignmentExpression.Operator); - } - Space(); - assignmentExpression.Right.AcceptVisitor(this, data); - return EndNode(assignmentExpression); - } - - public object VisitInvocationExpression(InvocationExpression invocationExpression, object data) - { - StartNode(invocationExpression); - invocationExpression.Target.AcceptVisitor(this, data); - WriteCommaSeparatedListInParenthesis(invocationExpression.Arguments, false); - return EndNode(invocationExpression); - } - - public object VisitArrayInitializerExpression(ArrayInitializerExpression arrayInitializerExpression, object data) - { - StartNode(arrayInitializerExpression); - WriteToken("{", ArrayInitializerExpression.Roles.LBrace); - Space(); - WriteCommaSeparatedList(arrayInitializerExpression.Elements); - Space(); - WriteToken("}", ArrayInitializerExpression.Roles.RBrace); - return EndNode(arrayInitializerExpression); - } - - public object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) - { - StartNode(arrayCreateExpression); - WriteKeyword("New"); - Space(); - arrayCreateExpression.Type.AcceptVisitor(this, data); - if (arrayCreateExpression.Arguments.Any()) - WriteCommaSeparatedListInParenthesis(arrayCreateExpression.Arguments, false); - foreach (var specifier in arrayCreateExpression.AdditionalArraySpecifiers) { - specifier.AcceptVisitor(this, data); - } - if (lastWritten != LastWritten.Whitespace) - Space(); - if (arrayCreateExpression.Initializer.IsNull) { - WriteToken("{", ArrayInitializerExpression.Roles.LBrace); - WriteToken("}", ArrayInitializerExpression.Roles.RBrace); - } else { - arrayCreateExpression.Initializer.AcceptVisitor(this, data); - } - return EndNode(arrayCreateExpression); - } - - public object VisitObjectCreationExpression(ObjectCreationExpression objectCreationExpression, object data) - { - StartNode(objectCreationExpression); - - WriteKeyword("New"); - objectCreationExpression.Type.AcceptVisitor(this, data); - WriteCommaSeparatedListInParenthesis(objectCreationExpression.Arguments, false); - if (!objectCreationExpression.Initializer.IsNull) { - Space(); - if (objectCreationExpression.Initializer.Elements.Any(x => x is FieldInitializerExpression)) - WriteKeyword("With"); - else - WriteKeyword("From"); - Space(); - objectCreationExpression.Initializer.AcceptVisitor(this, data); - } - - return EndNode(objectCreationExpression); - } - - public object VisitCastExpression(CastExpression castExpression, object data) - { - StartNode(castExpression); - - switch (castExpression.CastType) { - case CastType.DirectCast: - WriteKeyword("DirectCast"); - break; - case CastType.TryCast: - WriteKeyword("TryCast"); - break; - case CastType.CType: - WriteKeyword("CType"); - break; - case CastType.CBool: - WriteKeyword("CBool"); - break; - case CastType.CByte: - WriteKeyword("CByte"); - break; - case CastType.CChar: - WriteKeyword("CChar"); - break; - case CastType.CDate: - WriteKeyword("CDate"); - break; - case CastType.CDec: - WriteKeyword("CType"); - break; - case CastType.CDbl: - WriteKeyword("CDec"); - break; - case CastType.CInt: - WriteKeyword("CInt"); - break; - case CastType.CLng: - WriteKeyword("CLng"); - break; - case CastType.CObj: - WriteKeyword("CObj"); - break; - case CastType.CSByte: - WriteKeyword("CSByte"); - break; - case CastType.CShort: - WriteKeyword("CShort"); - break; - case CastType.CSng: - WriteKeyword("CSng"); - break; - case CastType.CStr: - WriteKeyword("CStr"); - break; - case CastType.CUInt: - WriteKeyword("CUInt"); - break; - case CastType.CULng: - WriteKeyword("CULng"); - break; - case CastType.CUShort: - WriteKeyword("CUShort"); - break; - default: - throw new Exception("Invalid value for CastType"); - } - - WriteToken("(", CastExpression.Roles.LPar); - castExpression.Expression.AcceptVisitor(this, data); - - if (castExpression.CastType == CastType.CType || - castExpression.CastType == CastType.DirectCast || - castExpression.CastType == CastType.TryCast) { - WriteToken(",", CastExpression.Roles.Comma); - Space(); - castExpression.Type.AcceptVisitor(this, data); - } - - WriteToken(")", CastExpression.Roles.RPar); - - return EndNode(castExpression); - } - - public object VisitComment(Comment comment, object data) - { - formatter.WriteComment(comment.IsDocumentationComment, comment.Content); - return null; - } - - public object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) - { - StartNode(eventDeclaration); - - WriteAttributes(eventDeclaration.Attributes); - WriteModifiers(eventDeclaration.ModifierTokens); - if (eventDeclaration.IsCustom) - WriteKeyword("Custom"); - WriteKeyword("Event"); - WriteIdentifier(eventDeclaration.Name.Name); - if (!eventDeclaration.IsCustom && eventDeclaration.ReturnType.IsNull) - WriteCommaSeparatedListInParenthesis(eventDeclaration.Parameters, false); - if (!eventDeclaration.ReturnType.IsNull) { - Space(); - WriteKeyword("As"); - eventDeclaration.ReturnType.AcceptVisitor(this, data); - } - WriteImplementsClause(eventDeclaration.ImplementsClause); - - if (eventDeclaration.IsCustom) { - MarkFoldStart(); - NewLine(); - Indent(); - - eventDeclaration.AddHandlerBlock.AcceptVisitor(this, data); - eventDeclaration.RemoveHandlerBlock.AcceptVisitor(this, data); - eventDeclaration.RaiseEventBlock.AcceptVisitor(this, data); - - Unindent(); - WriteKeyword("End"); - WriteKeyword("Event"); - MarkFoldEnd(); - } - NewLine(); - - return EndNode(eventDeclaration); - } - - public object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) - { - StartNode(unaryOperatorExpression); - - switch (unaryOperatorExpression.Operator) { - case UnaryOperatorType.Not: - WriteKeyword("Not"); - break; - case UnaryOperatorType.Minus: - WriteToken("-", UnaryOperatorExpression.OperatorRole); - break; - case UnaryOperatorType.Plus: - WriteToken("+", UnaryOperatorExpression.OperatorRole); - break; - case UnaryOperatorType.AddressOf: - WriteKeyword("AddressOf"); - break; - case UnaryOperatorType.Await: - WriteKeyword("Await"); - break; - default: - throw new Exception("Invalid value for UnaryOperatorType"); - } - - unaryOperatorExpression.Expression.AcceptVisitor(this, data); - - return EndNode(unaryOperatorExpression); - } - - public object VisitFieldInitializerExpression(FieldInitializerExpression fieldInitializerExpression, object data) - { - StartNode(fieldInitializerExpression); - - if (fieldInitializerExpression.IsKey && fieldInitializerExpression.Parent is AnonymousObjectCreationExpression) { - WriteKeyword("Key"); - Space(); - } - - WriteToken(".", FieldInitializerExpression.Roles.Dot); - fieldInitializerExpression.Identifier.AcceptVisitor(this, data); - - Space(); - WriteToken("=", FieldInitializerExpression.Roles.Assign); - Space(); - fieldInitializerExpression.Expression.AcceptVisitor(this, data); - - return EndNode(fieldInitializerExpression); - } - - public object VisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data) - { - throw new NotImplementedException(); - } - - public object VisitConditionalExpression(ConditionalExpression conditionalExpression, object data) - { - StartNode(conditionalExpression); - - WriteKeyword("If"); - WriteToken("(", ConditionalExpression.Roles.LPar); - - conditionalExpression.ConditionExpression.AcceptVisitor(this, data); - WriteToken(",", ConditionalExpression.Roles.Comma); - Space(); - - if (!conditionalExpression.TrueExpression.IsNull) { - conditionalExpression.TrueExpression.AcceptVisitor(this, data); - WriteToken(",", ConditionalExpression.Roles.Comma); - Space(); - } - - conditionalExpression.FalseExpression.AcceptVisitor(this, data); - - WriteToken(")", ConditionalExpression.Roles.RPar); - - return EndNode(conditionalExpression); - } - - public object VisitWhileStatement(WhileStatement whileStatement, object data) - { - StartNode(whileStatement); - - WriteKeyword("While"); - Space(); - whileStatement.Condition.AcceptVisitor(this, data); - whileStatement.Body.AcceptVisitor(this, data); - WriteKeyword("End"); - WriteKeyword("While"); - - return EndNode(whileStatement); - } - - public object VisitExitStatement(ExitStatement exitStatement, object data) - { - StartNode(exitStatement); - - WriteKeyword("Exit"); - - switch (exitStatement.ExitKind) { - case ExitKind.Sub: - WriteKeyword("Sub"); - break; - case ExitKind.Function: - WriteKeyword("Function"); - break; - case ExitKind.Property: - WriteKeyword("Property"); - break; - case ExitKind.Do: - WriteKeyword("Do"); - break; - case ExitKind.For: - WriteKeyword("For"); - break; - case ExitKind.While: - WriteKeyword("While"); - break; - case ExitKind.Select: - WriteKeyword("Select"); - break; - case ExitKind.Try: - WriteKeyword("Try"); - break; - default: - throw new Exception("Invalid value for ExitKind"); - } - - return EndNode(exitStatement); - } - - public object VisitForStatement(ForStatement forStatement, object data) - { - StartNode(forStatement); - - WriteKeyword("For"); - forStatement.Variable.AcceptVisitor(this, data); - WriteKeyword("To"); - forStatement.ToExpression.AcceptVisitor(this, data); - if (!forStatement.StepExpression.IsNull) { - WriteKeyword("Step"); - Space(); - forStatement.StepExpression.AcceptVisitor(this, data); - } - forStatement.Body.AcceptVisitor(this, data); - WriteKeyword("Next"); - - return EndNode(forStatement); - } - - public object VisitForEachStatement(ForEachStatement forEachStatement, object data) - { - StartNode(forEachStatement); - - WriteKeyword("For"); - WriteKeyword("Each"); - forEachStatement.Variable.AcceptVisitor(this, data); - Space(); - WriteKeyword("In"); - forEachStatement.InExpression.AcceptVisitor(this, data); - forEachStatement.Body.AcceptVisitor(this, data); - WriteKeyword("Next"); - - return EndNode(forEachStatement); - } - - public object VisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) - { - StartNode(operatorDeclaration); - - WriteAttributes(operatorDeclaration.Attributes); - WriteModifiers(operatorDeclaration.ModifierTokens); - WriteKeyword("Operator"); - switch (operatorDeclaration.Operator) { - case OverloadableOperatorType.Add: - case OverloadableOperatorType.UnaryPlus: - WriteToken("+", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.Subtract: - case OverloadableOperatorType.UnaryMinus: - WriteToken("-", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.Multiply: - WriteToken("*", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.Divide: - WriteToken("/", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.Modulus: - WriteKeyword("Mod"); - break; - case OverloadableOperatorType.Concat: - WriteToken("&", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.Not: - WriteKeyword("Not"); - break; - case OverloadableOperatorType.BitwiseAnd: - WriteKeyword("And"); - break; - case OverloadableOperatorType.BitwiseOr: - WriteKeyword("Or"); - break; - case OverloadableOperatorType.ExclusiveOr: - WriteKeyword("Xor"); - break; - case OverloadableOperatorType.ShiftLeft: - WriteToken("<<", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.ShiftRight: - WriteToken(">>", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.GreaterThan: - WriteToken(">", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.GreaterThanOrEqual: - WriteToken(">=", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.Equality: - WriteToken("=", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.InEquality: - WriteToken("<>", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.LessThan: - WriteToken("<", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.LessThanOrEqual: - WriteToken("<=", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.IsTrue: - WriteKeyword("IsTrue"); - break; - case OverloadableOperatorType.IsFalse: - WriteKeyword("IsFalse"); - break; - case OverloadableOperatorType.Like: - WriteKeyword("Like"); - break; - case OverloadableOperatorType.Power: - WriteToken("^", OperatorDeclaration.Roles.Keyword); - break; - case OverloadableOperatorType.CType: - WriteKeyword("CType"); - break; - case OverloadableOperatorType.DivideInteger: - WriteToken("\\", OperatorDeclaration.Roles.Keyword); - break; - default: - throw new Exception("Invalid value for OverloadableOperatorType"); - } - WriteCommaSeparatedListInParenthesis(operatorDeclaration.Parameters, false); - if (!operatorDeclaration.ReturnType.IsNull) { - Space(); - WriteKeyword("As"); - WriteAttributes(operatorDeclaration.ReturnTypeAttributes); - operatorDeclaration.ReturnType.AcceptVisitor(this, data); - } - if (!operatorDeclaration.Body.IsNull) { - MarkFoldStart(); - WriteBlock(operatorDeclaration.Body); - WriteKeyword("End"); - WriteKeyword("Operator"); - MarkFoldEnd(); - } - NewLine(); - - return EndNode(operatorDeclaration); - } - - public object VisitSelectStatement(SelectStatement selectStatement, object data) - { - StartNode(selectStatement); - - WriteKeyword("Select"); - WriteKeyword("Case"); - selectStatement.Expression.AcceptVisitor(this, data); - NewLine(); - Indent(); - - foreach (CaseStatement stmt in selectStatement.Cases) { - stmt.AcceptVisitor(this, data); - } - - Unindent(); - WriteKeyword("End"); - WriteKeyword("Select"); - - return EndNode(selectStatement); - } - - public object VisitCaseStatement(CaseStatement caseStatement, object data) - { - StartNode(caseStatement); - - WriteKeyword("Case"); - if (caseStatement.Clauses.Count == 1 && caseStatement.Clauses.First().Expression.IsNull) - WriteKeyword("Else"); - else { - Space(); - WriteCommaSeparatedList(caseStatement.Clauses); - } - caseStatement.Body.AcceptVisitor(this, data); - - return EndNode(caseStatement); - } - - public object VisitSimpleCaseClause(SimpleCaseClause simpleCaseClause, object data) - { - StartNode(simpleCaseClause); - simpleCaseClause.Expression.AcceptVisitor(this, data); - return EndNode(simpleCaseClause); - } - - public object VisitRangeCaseClause(RangeCaseClause rangeCaseClause, object data) - { - StartNode(rangeCaseClause); - rangeCaseClause.Expression.AcceptVisitor(this, data); - WriteKeyword("To"); - rangeCaseClause.ToExpression.AcceptVisitor(this, data); - return EndNode(rangeCaseClause); - } - - public object VisitComparisonCaseClause(ComparisonCaseClause comparisonCaseClause, object data) - { - StartNode(comparisonCaseClause); - switch (comparisonCaseClause.Operator) { - case ComparisonOperator.Equality: - WriteToken("=", ComparisonCaseClause.OperatorRole); - break; - case ComparisonOperator.InEquality: - WriteToken("<>", ComparisonCaseClause.OperatorRole); - break; - case ComparisonOperator.LessThan: - WriteToken("<", ComparisonCaseClause.OperatorRole); - break; - case ComparisonOperator.GreaterThan: - WriteToken(">", ComparisonCaseClause.OperatorRole); - break; - case ComparisonOperator.LessThanOrEqual: - WriteToken("<=", ComparisonCaseClause.OperatorRole); - break; - case ComparisonOperator.GreaterThanOrEqual: - WriteToken(">=", ComparisonCaseClause.OperatorRole); - break; - default: - throw new Exception("Invalid value for ComparisonOperator"); - } - Space(); - comparisonCaseClause.Expression.AcceptVisitor(this, data); - return EndNode(comparisonCaseClause); - } - - - public object VisitYieldStatement(YieldStatement yieldStatement, object data) - { - StartNode(yieldStatement); - WriteKeyword("Yield"); - yieldStatement.Expression.AcceptVisitor(this, data); - return EndNode(yieldStatement); - } - - public object VisitVariableInitializer(VariableInitializer variableInitializer, object data) - { - StartNode(variableInitializer); - - variableInitializer.Identifier.AcceptVisitor(this, data); - if (!variableInitializer.Type.IsNull) { - if (lastWritten != LastWritten.Whitespace) - Space(); - WriteKeyword("As"); - variableInitializer.Type.AcceptVisitor(this, data); - } - if (!variableInitializer.Expression.IsNull) { - Space(); - WriteToken("=", VariableInitializer.Roles.Assign); - Space(); - variableInitializer.Expression.AcceptVisitor(this, data); - } - - return EndNode(variableInitializer); - } - - public object VisitVariableDeclaratorWithTypeAndInitializer(VariableDeclaratorWithTypeAndInitializer variableDeclaratorWithTypeAndInitializer, object data) - { - StartNode(variableDeclaratorWithTypeAndInitializer); - - WriteCommaSeparatedList(variableDeclaratorWithTypeAndInitializer.Identifiers); - if (lastWritten != LastWritten.Whitespace) - Space(); - WriteKeyword("As"); - variableDeclaratorWithTypeAndInitializer.Type.AcceptVisitor(this, data); - if (!variableDeclaratorWithTypeAndInitializer.Initializer.IsNull) { - Space(); - WriteToken("=", VariableDeclarator.Roles.Assign); - Space(); - variableDeclaratorWithTypeAndInitializer.Initializer.AcceptVisitor(this, data); - } - - return EndNode(variableDeclaratorWithTypeAndInitializer); - } - - public object VisitVariableDeclaratorWithObjectCreation(VariableDeclaratorWithObjectCreation variableDeclaratorWithObjectCreation, object data) - { - StartNode(variableDeclaratorWithObjectCreation); - - WriteCommaSeparatedList(variableDeclaratorWithObjectCreation.Identifiers); - if (lastWritten != LastWritten.Whitespace) - Space(); - WriteKeyword("As"); - variableDeclaratorWithObjectCreation.Initializer.AcceptVisitor(this, data); - - return EndNode(variableDeclaratorWithObjectCreation); - } - - public object VisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) - { - StartNode(doLoopStatement); - - WriteKeyword("Do"); - if (doLoopStatement.ConditionType == ConditionType.DoUntil) { - WriteKeyword("Until"); - doLoopStatement.Expression.AcceptVisitor(this, data); - } - if (doLoopStatement.ConditionType == ConditionType.DoWhile) { - WriteKeyword("While"); - doLoopStatement.Expression.AcceptVisitor(this, data); - } - doLoopStatement.Body.AcceptVisitor(this, data); - WriteKeyword("Loop"); - if (doLoopStatement.ConditionType == ConditionType.LoopUntil) { - WriteKeyword("Until"); - doLoopStatement.Expression.AcceptVisitor(this, data); - } - if (doLoopStatement.ConditionType == ConditionType.LoopWhile) { - WriteKeyword("While"); - doLoopStatement.Expression.AcceptVisitor(this, data); - } - - return EndNode(doLoopStatement); - } - - public object VisitUsingStatement(UsingStatement usingStatement, object data) - { - StartNode(usingStatement); - - WriteKeyword("Using"); - WriteCommaSeparatedList(usingStatement.Resources); - usingStatement.Body.AcceptVisitor(this, data); - WriteKeyword("End"); - WriteKeyword("Using"); - - return EndNode(usingStatement); - } - - public object VisitGoToStatement(GoToStatement goToStatement, object data) - { - StartNode(goToStatement); - - WriteKeyword("GoTo"); - goToStatement.Label.AcceptVisitor(this, data); - - return EndNode(goToStatement); - } - - public object VisitSingleLineSubLambdaExpression(SingleLineSubLambdaExpression singleLineSubLambdaExpression, object data) - { - StartNode(singleLineSubLambdaExpression); - - WriteModifiers(singleLineSubLambdaExpression.ModifierTokens); - WriteKeyword("Sub"); - WriteCommaSeparatedListInParenthesis(singleLineSubLambdaExpression.Parameters, false); - Space(); - singleLineSubLambdaExpression.EmbeddedStatement.AcceptVisitor(this, data); - - return EndNode(singleLineSubLambdaExpression); - } - - public object VisitSingleLineFunctionLambdaExpression(SingleLineFunctionLambdaExpression singleLineFunctionLambdaExpression, object data) - { - StartNode(singleLineFunctionLambdaExpression); - - WriteModifiers(singleLineFunctionLambdaExpression.ModifierTokens); - WriteKeyword("Function"); - WriteCommaSeparatedListInParenthesis(singleLineFunctionLambdaExpression.Parameters, false); - Space(); - singleLineFunctionLambdaExpression.EmbeddedExpression.AcceptVisitor(this, data); - - return EndNode(singleLineFunctionLambdaExpression); - } - - public object VisitMultiLineLambdaExpression(MultiLineLambdaExpression multiLineLambdaExpression, object data) - { - StartNode(multiLineLambdaExpression); - - WriteModifiers(multiLineLambdaExpression.ModifierTokens); - if (multiLineLambdaExpression.IsSub) - WriteKeyword("Sub"); - else - WriteKeyword("Function"); - WriteCommaSeparatedListInParenthesis(multiLineLambdaExpression.Parameters, false); - multiLineLambdaExpression.Body.AcceptVisitor(this, data); - WriteKeyword("End"); - if (multiLineLambdaExpression.IsSub) - WriteKeyword("Sub"); - else - WriteKeyword("Function"); - - return EndNode(multiLineLambdaExpression); - } - - public object VisitQueryExpression(QueryExpression queryExpression, object data) - { - StartNode(queryExpression); - - foreach (var op in queryExpression.QueryOperators) { - op.AcceptVisitor(this, data); - } - - return EndNode(queryExpression); - } - - public object VisitContinueStatement(ContinueStatement continueStatement, object data) - { - StartNode(continueStatement); - - WriteKeyword("Continue"); - - switch (continueStatement.ContinueKind) { - case ContinueKind.Do: - WriteKeyword("Do"); - break; - case ContinueKind.For: - WriteKeyword("For"); - break; - case ContinueKind.While: - WriteKeyword("While"); - break; - default: - throw new Exception("Invalid value for ContinueKind"); - } - - return EndNode(continueStatement); - } - - public object VisitExternalMethodDeclaration(ExternalMethodDeclaration externalMethodDeclaration, object data) - { - StartNode(externalMethodDeclaration); - - WriteAttributes(externalMethodDeclaration.Attributes); - WriteModifiers(externalMethodDeclaration.ModifierTokens); - WriteKeyword("Declare"); - switch (externalMethodDeclaration.CharsetModifier) { - case CharsetModifier.None: - break; - case CharsetModifier.Auto: - WriteKeyword("Auto"); - break; - case CharsetModifier.Unicode: - WriteKeyword("Unicode"); - break; - case CharsetModifier.Ansi: - WriteKeyword("Ansi"); - break; - default: - throw new Exception("Invalid value for CharsetModifier"); - } - if (externalMethodDeclaration.IsSub) - WriteKeyword("Sub"); - else - WriteKeyword("Function"); - externalMethodDeclaration.Name.AcceptVisitor(this, data); - WriteKeyword("Lib"); - Space(); - WritePrimitiveValue(externalMethodDeclaration.Library); - Space(); - if (externalMethodDeclaration.Alias != null) { - WriteKeyword("Alias"); - Space(); - WritePrimitiveValue(externalMethodDeclaration.Alias); - Space(); - } - WriteCommaSeparatedListInParenthesis(externalMethodDeclaration.Parameters, false); - if (!externalMethodDeclaration.IsSub && !externalMethodDeclaration.ReturnType.IsNull) { - Space(); - WriteKeyword("As"); - WriteAttributes(externalMethodDeclaration.ReturnTypeAttributes); - externalMethodDeclaration.ReturnType.AcceptVisitor(this, data); - } - NewLine(); - - return EndNode(externalMethodDeclaration); - } - - public static string ToVBNetString(PrimitiveExpression primitiveExpression) - { - var writer = new StringWriter(); - new OutputVisitor(writer, new VBFormattingOptions()).WritePrimitiveValue(primitiveExpression.Value); - return writer.ToString(); - } - - public object VisitEmptyExpression(EmptyExpression emptyExpression, object data) - { - StartNode(emptyExpression); - - return EndNode(emptyExpression); - } - - public object VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpression anonymousObjectCreationExpression, object data) - { - StartNode(anonymousObjectCreationExpression); - - WriteKeyword("New"); - WriteKeyword("With"); - - WriteToken("{", AnonymousObjectCreationExpression.Roles.LBrace); - Space(); - WriteCommaSeparatedList(anonymousObjectCreationExpression.Initializer); - Space(); - WriteToken("}", AnonymousObjectCreationExpression.Roles.RBrace); - - return EndNode(anonymousObjectCreationExpression); - } - - public object VisitCollectionRangeVariableDeclaration(CollectionRangeVariableDeclaration collectionRangeVariableDeclaration, object data) - { - StartNode(collectionRangeVariableDeclaration); - - collectionRangeVariableDeclaration.Identifier.AcceptVisitor(this, data); - if (!collectionRangeVariableDeclaration.Type.IsNull) { - WriteKeyword("As"); - collectionRangeVariableDeclaration.Type.AcceptVisitor(this, data); - } - WriteKeyword("In"); - collectionRangeVariableDeclaration.Expression.AcceptVisitor(this, data); - - return EndNode(collectionRangeVariableDeclaration); - } - - public object VisitFromQueryOperator(FromQueryOperator fromQueryOperator, object data) - { - StartNode(fromQueryOperator); - - WriteKeyword("From"); - WriteCommaSeparatedList(fromQueryOperator.Variables); - - return EndNode(fromQueryOperator); - } - - public object VisitAggregateQueryOperator(AggregateQueryOperator aggregateQueryOperator, object data) - { - StartNode(aggregateQueryOperator); - - WriteKeyword("Aggregate"); - aggregateQueryOperator.Variable.AcceptVisitor(this, data); - - foreach (var operators in aggregateQueryOperator.SubQueryOperators) { - operators.AcceptVisitor(this, data); - } - - WriteKeyword("Into"); - WriteCommaSeparatedList(aggregateQueryOperator.IntoExpressions); - - return EndNode(aggregateQueryOperator); - } - - public object VisitSelectQueryOperator(SelectQueryOperator selectQueryOperator, object data) - { - StartNode(selectQueryOperator); - - WriteKeyword("Select"); - WriteCommaSeparatedList(selectQueryOperator.Variables); - - return EndNode(selectQueryOperator); - } - - public object VisitDistinctQueryOperator(DistinctQueryOperator distinctQueryOperator, object data) - { - StartNode(distinctQueryOperator); - - WriteKeyword("Distinct"); - - return EndNode(distinctQueryOperator); - } - - public object VisitWhereQueryOperator(WhereQueryOperator whereQueryOperator, object data) - { - StartNode(whereQueryOperator); - - WriteKeyword("Where"); - whereQueryOperator.Condition.AcceptVisitor(this, data); - - return EndNode(whereQueryOperator); - } - - public object VisitPartitionQueryOperator(PartitionQueryOperator partitionQueryOperator, object data) - { - StartNode(partitionQueryOperator); - - switch (partitionQueryOperator.Kind) { - case PartitionKind.Take: - WriteKeyword("Take"); - break; - case PartitionKind.TakeWhile: - WriteKeyword("Take"); - WriteKeyword("While"); - break; - case PartitionKind.Skip: - WriteKeyword("Skip"); - break; - case PartitionKind.SkipWhile: - WriteKeyword("Skip"); - WriteKeyword("While"); - break; - default: - throw new Exception("Invalid value for PartitionKind"); - } - - partitionQueryOperator.Expression.AcceptVisitor(this, data); - - return EndNode(partitionQueryOperator); - } - - public object VisitOrderExpression(OrderExpression orderExpression, object data) - { - StartNode(orderExpression); - - orderExpression.Expression.AcceptVisitor(this, data); - - switch (orderExpression.Direction) { - case QueryOrderingDirection.None: - break; - case QueryOrderingDirection.Ascending: - WriteKeyword("Ascending"); - break; - case QueryOrderingDirection.Descending: - WriteKeyword("Descending"); - break; - default: - throw new Exception("Invalid value for QueryExpressionOrderingDirection"); - } - - return EndNode(orderExpression); - } - - public object VisitOrderByQueryOperator(OrderByQueryOperator orderByQueryOperator, object data) - { - StartNode(orderByQueryOperator); - - WriteKeyword("Order"); - WriteKeyword("By"); - WriteCommaSeparatedList(orderByQueryOperator.Expressions); - - return EndNode(orderByQueryOperator); - } - - public object VisitLetQueryOperator(LetQueryOperator letQueryOperator, object data) - { - StartNode(letQueryOperator); - - WriteKeyword("Let"); - WriteCommaSeparatedList(letQueryOperator.Variables); - - return EndNode(letQueryOperator); - } - - public object VisitGroupByQueryOperator(GroupByQueryOperator groupByQueryOperator, object data) - { - StartNode(groupByQueryOperator); - - WriteKeyword("Group"); - WriteCommaSeparatedList(groupByQueryOperator.GroupExpressions); - WriteKeyword("By"); - WriteCommaSeparatedList(groupByQueryOperator.ByExpressions); - WriteKeyword("Into"); - WriteCommaSeparatedList(groupByQueryOperator.IntoExpressions); - - return EndNode(groupByQueryOperator); - } - - public object VisitJoinQueryOperator(JoinQueryOperator joinQueryOperator, object data) - { - StartNode(joinQueryOperator); - - WriteKeyword("Join"); - joinQueryOperator.JoinVariable.AcceptVisitor(this, data); - if (!joinQueryOperator.SubJoinQuery.IsNull) { - joinQueryOperator.SubJoinQuery.AcceptVisitor(this, data); - } - WriteKeyword("On"); - bool first = true; - foreach (var cond in joinQueryOperator.JoinConditions) { - if (first) - first = false; - else - WriteKeyword("And"); - cond.AcceptVisitor(this, data); - } - - return EndNode(joinQueryOperator); - } - - public object VisitJoinCondition(JoinCondition joinCondition, object data) - { - StartNode(joinCondition); - - joinCondition.Left.AcceptVisitor(this, data); - WriteKeyword("Equals"); - joinCondition.Right.AcceptVisitor(this, data); - - return EndNode(joinCondition); - } - - public object VisitGroupJoinQueryOperator(GroupJoinQueryOperator groupJoinQueryOperator, object data) - { - StartNode(groupJoinQueryOperator); - - WriteKeyword("Group"); - WriteKeyword("Join"); - groupJoinQueryOperator.JoinVariable.AcceptVisitor(this, data); - if (!groupJoinQueryOperator.SubJoinQuery.IsNull) { - groupJoinQueryOperator.SubJoinQuery.AcceptVisitor(this, data); - } - WriteKeyword("On"); - bool first = true; - foreach (var cond in groupJoinQueryOperator.JoinConditions) { - if (first) - first = false; - else - WriteKeyword("And"); - cond.AcceptVisitor(this, data); - } - WriteKeyword("Into"); - WriteCommaSeparatedList(groupJoinQueryOperator.IntoExpressions); - - return EndNode(groupJoinQueryOperator); - } - - public object VisitAddRemoveHandlerStatement(AddRemoveHandlerStatement addRemoveHandlerStatement, object data) - { - StartNode(addRemoveHandlerStatement); - - if (addRemoveHandlerStatement.IsAddHandler) - WriteKeyword("AddHandler"); - else - WriteKeyword("RemoveHandler"); - - addRemoveHandlerStatement.EventExpression.AcceptVisitor(this, data); - Comma(addRemoveHandlerStatement.DelegateExpression); - addRemoveHandlerStatement.DelegateExpression.AcceptVisitor(this, data); - - return EndNode(addRemoveHandlerStatement); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/TextWriterOutputFormatter.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/TextWriterOutputFormatter.cs deleted file mode 100644 index f5b610d16..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/TextWriterOutputFormatter.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.IO; - -namespace ICSharpCode.NRefactory.VB -{ - /// - /// Writes VB code into a TextWriter. - /// - public class TextWriterOutputFormatter : IOutputFormatter - { - readonly TextWriter textWriter; - int indentation; - bool needsIndent = true; - - public TextWriterOutputFormatter(TextWriter textWriter) - { - if (textWriter == null) - throw new ArgumentNullException("textWriter"); - this.textWriter = textWriter; - } - - public void WriteIdentifier(string ident) - { - WriteIndentation(); - textWriter.Write(ident); - } - - public void WriteKeyword(string keyword) - { - WriteIndentation(); - textWriter.Write(keyword); - } - - public void WriteToken(string token) - { - WriteIndentation(); - textWriter.Write(token); - } - - public void Space() - { - WriteIndentation(); - textWriter.Write(' '); - } - - void WriteIndentation() - { - if (needsIndent) { - needsIndent = false; - for (int i = 0; i < indentation; i++) { - textWriter.Write('\t'); - } - } - } - - public void NewLine() - { - textWriter.WriteLine(); - needsIndent = true; - } - - public void Indent() - { - indentation++; - } - - public void Unindent() - { - indentation--; - } - - public virtual void StartNode(AstNode node) - { - } - - public virtual void EndNode(AstNode node) - { - } - - public void WriteComment(bool isDocumentation, string content) - { - WriteIndentation(); - if (isDocumentation) - textWriter.Write("'''"); - else - textWriter.Write("'"); - textWriter.WriteLine(content); - } - - public void MarkFoldStart() - { - } - - public void MarkFoldEnd() - { - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/VBFormattingOptions.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/VBFormattingOptions.cs deleted file mode 100644 index 5dbf95054..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/OutputVisitor/VBFormattingOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB -{ - /// - /// Description of VBFormattingOptions. - /// - public class VBFormattingOptions - { - public VBFormattingOptions() - { - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Errors.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Errors.cs deleted file mode 100644 index ab9e615bd..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Errors.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - public delegate void ErrorCodeProc(int line, int col, int n); - public delegate void ErrorMsgProc(int line, int col, string msg); - - public class Errors - { - int count = 0; // number of errors detected - public ErrorCodeProc SynErr; - public ErrorCodeProc SemErr; - public ErrorMsgProc Error; - StringBuilder errorText = new StringBuilder(); - - public string ErrorOutput { - get { - return errorText.ToString(); - } - } - - public Errors() - { - SynErr = new ErrorCodeProc(DefaultCodeError); // syntactic errors - SemErr = new ErrorCodeProc(DefaultCodeError); // semantic errors - Error = new ErrorMsgProc(DefaultMsgError); // user defined string based errors - } - - public int Count { - get { - return count; - } - } - - void DefaultCodeError(int line, int col, int n) - { - errorText.AppendLine(String.Format("-- line {0} col {1}: error {2}", line, col, n)); - count++; - } - - void DefaultMsgError(int line, int col, string s) { - errorText.AppendLine(String.Format("-- line {0} col {1}: {2}", line, col, s)); - count++; - } - } // Errors -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Parser.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Parser.cs deleted file mode 100644 index aa12c27f3..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Parser.cs +++ /dev/null @@ -1,760 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Text; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using ASTAttribute = ICSharpCode.NRefactory.VB.Ast.Attribute; -using Roles = ICSharpCode.NRefactory.VB.AstNode.Roles; - - - - -namespace ICSharpCode.NRefactory.VB.Parser { - - -// ---------------------------------------------------------------------------- -// Parser -// ---------------------------------------------------------------------------- -//! A Coco/R Parser -partial class VBParser -{ - public const int _EOF = 0; - public const int _EOL = 1; - public const int _ident = 2; - public const int _LiteralString = 3; - public const int _LiteralCharacter = 4; - public const int _LiteralInteger = 5; - public const int _LiteralDouble = 6; - public const int _LiteralSingle = 7; - public const int _LiteralDecimal = 8; - public const int _LiteralDate = 9; - public const int _XmlOpenTag = 10; - public const int _XmlCloseTag = 11; - public const int _XmlStartInlineVB = 12; - public const int _XmlEndInlineVB = 13; - public const int _XmlCloseTagEmptyElement = 14; - public const int _XmlOpenEndTag = 15; - public const int _XmlContent = 16; - public const int _XmlComment = 17; - public const int _XmlCData = 18; - public const int _XmlProcessingInstruction = 19; - public const int maxT = 238; //\" expected"; - case 40: return "\"<\" expected"; - case 41: return "\"<>\" expected"; - case 42: return "\">=\" expected"; - case 43: return "\"<=\" expected"; - case 44: return "\"<<\" expected"; - case 45: return "\">>\" expected"; - case 46: return "\"+=\" expected"; - case 47: return "\"^=\" expected"; - case 48: return "\"-=\" expected"; - case 49: return "\"*=\" expected"; - case 50: return "\"/=\" expected"; - case 51: return "\"\\\\=\" expected"; - case 52: return "\"<<=\" expected"; - case 53: return "\">>=\" expected"; - case 54: return "\"&=\" expected"; - case 55: return "\":=\" expected"; - case 56: return "\"AddHandler\" expected"; - case 57: return "\"AddressOf\" expected"; - case 58: return "\"Aggregate\" expected"; - case 59: return "\"Alias\" expected"; - case 60: return "\"And\" expected"; - case 61: return "\"AndAlso\" expected"; - case 62: return "\"Ansi\" expected"; - case 63: return "\"As\" expected"; - case 64: return "\"Ascending\" expected"; - case 65: return "\"Assembly\" expected"; - case 66: return "\"Auto\" expected"; - case 67: return "\"Binary\" expected"; - case 68: return "\"Boolean\" expected"; - case 69: return "\"ByRef\" expected"; - case 70: return "\"By\" expected"; - case 71: return "\"Byte\" expected"; - case 72: return "\"ByVal\" expected"; - case 73: return "\"Call\" expected"; - case 74: return "\"Case\" expected"; - case 75: return "\"Catch\" expected"; - case 76: return "\"CBool\" expected"; - case 77: return "\"CByte\" expected"; - case 78: return "\"CChar\" expected"; - case 79: return "\"CDate\" expected"; - case 80: return "\"CDbl\" expected"; - case 81: return "\"CDec\" expected"; - case 82: return "\"Char\" expected"; - case 83: return "\"CInt\" expected"; - case 84: return "\"Class\" expected"; - case 85: return "\"CLng\" expected"; - case 86: return "\"CObj\" expected"; - case 87: return "\"Compare\" expected"; - case 88: return "\"Const\" expected"; - case 89: return "\"Continue\" expected"; - case 90: return "\"CSByte\" expected"; - case 91: return "\"CShort\" expected"; - case 92: return "\"CSng\" expected"; - case 93: return "\"CStr\" expected"; - case 94: return "\"CType\" expected"; - case 95: return "\"CUInt\" expected"; - case 96: return "\"CULng\" expected"; - case 97: return "\"CUShort\" expected"; - case 98: return "\"Custom\" expected"; - case 99: return "\"Date\" expected"; - case 100: return "\"Decimal\" expected"; - case 101: return "\"Declare\" expected"; - case 102: return "\"Default\" expected"; - case 103: return "\"Delegate\" expected"; - case 104: return "\"Descending\" expected"; - case 105: return "\"Dim\" expected"; - case 106: return "\"DirectCast\" expected"; - case 107: return "\"Distinct\" expected"; - case 108: return "\"Do\" expected"; - case 109: return "\"Double\" expected"; - case 110: return "\"Each\" expected"; - case 111: return "\"Else\" expected"; - case 112: return "\"ElseIf\" expected"; - case 113: return "\"End\" expected"; - case 114: return "\"EndIf\" expected"; - case 115: return "\"Enum\" expected"; - case 116: return "\"Equals\" expected"; - case 117: return "\"Erase\" expected"; - case 118: return "\"Error\" expected"; - case 119: return "\"Event\" expected"; - case 120: return "\"Exit\" expected"; - case 121: return "\"Explicit\" expected"; - case 122: return "\"False\" expected"; - case 123: return "\"Finally\" expected"; - case 124: return "\"For\" expected"; - case 125: return "\"Friend\" expected"; - case 126: return "\"From\" expected"; - case 127: return "\"Function\" expected"; - case 128: return "\"Get\" expected"; - case 129: return "\"GetType\" expected"; - case 130: return "\"Global\" expected"; - case 131: return "\"GoSub\" expected"; - case 132: return "\"GoTo\" expected"; - case 133: return "\"Group\" expected"; - case 134: return "\"Handles\" expected"; - case 135: return "\"If\" expected"; - case 136: return "\"Implements\" expected"; - case 137: return "\"Imports\" expected"; - case 138: return "\"In\" expected"; - case 139: return "\"Infer\" expected"; - case 140: return "\"Inherits\" expected"; - case 141: return "\"Integer\" expected"; - case 142: return "\"Interface\" expected"; - case 143: return "\"Into\" expected"; - case 144: return "\"Is\" expected"; - case 145: return "\"IsNot\" expected"; - case 146: return "\"Join\" expected"; - case 147: return "\"Key\" expected"; - case 148: return "\"Let\" expected"; - case 149: return "\"Lib\" expected"; - case 150: return "\"Like\" expected"; - case 151: return "\"Long\" expected"; - case 152: return "\"Loop\" expected"; - case 153: return "\"Me\" expected"; - case 154: return "\"Mod\" expected"; - case 155: return "\"Module\" expected"; - case 156: return "\"MustInherit\" expected"; - case 157: return "\"MustOverride\" expected"; - case 158: return "\"MyBase\" expected"; - case 159: return "\"MyClass\" expected"; - case 160: return "\"Namespace\" expected"; - case 161: return "\"Narrowing\" expected"; - case 162: return "\"New\" expected"; - case 163: return "\"Next\" expected"; - case 164: return "\"Not\" expected"; - case 165: return "\"Nothing\" expected"; - case 166: return "\"NotInheritable\" expected"; - case 167: return "\"NotOverridable\" expected"; - case 168: return "\"Object\" expected"; - case 169: return "\"Of\" expected"; - case 170: return "\"Off\" expected"; - case 171: return "\"On\" expected"; - case 172: return "\"Operator\" expected"; - case 173: return "\"Option\" expected"; - case 174: return "\"Optional\" expected"; - case 175: return "\"Or\" expected"; - case 176: return "\"Order\" expected"; - case 177: return "\"OrElse\" expected"; - case 178: return "\"Out\" expected"; - case 179: return "\"Overloads\" expected"; - case 180: return "\"Overridable\" expected"; - case 181: return "\"Overrides\" expected"; - case 182: return "\"ParamArray\" expected"; - case 183: return "\"Partial\" expected"; - case 184: return "\"Preserve\" expected"; - case 185: return "\"Private\" expected"; - case 186: return "\"Property\" expected"; - case 187: return "\"Protected\" expected"; - case 188: return "\"Public\" expected"; - case 189: return "\"RaiseEvent\" expected"; - case 190: return "\"ReadOnly\" expected"; - case 191: return "\"ReDim\" expected"; - case 192: return "\"Rem\" expected"; - case 193: return "\"RemoveHandler\" expected"; - case 194: return "\"Resume\" expected"; - case 195: return "\"Return\" expected"; - case 196: return "\"SByte\" expected"; - case 197: return "\"Select\" expected"; - case 198: return "\"Set\" expected"; - case 199: return "\"Shadows\" expected"; - case 200: return "\"Shared\" expected"; - case 201: return "\"Short\" expected"; - case 202: return "\"Single\" expected"; - case 203: return "\"Skip\" expected"; - case 204: return "\"Static\" expected"; - case 205: return "\"Step\" expected"; - case 206: return "\"Stop\" expected"; - case 207: return "\"Strict\" expected"; - case 208: return "\"String\" expected"; - case 209: return "\"Structure\" expected"; - case 210: return "\"Sub\" expected"; - case 211: return "\"SyncLock\" expected"; - case 212: return "\"Take\" expected"; - case 213: return "\"Text\" expected"; - case 214: return "\"Then\" expected"; - case 215: return "\"Throw\" expected"; - case 216: return "\"To\" expected"; - case 217: return "\"True\" expected"; - case 218: return "\"Try\" expected"; - case 219: return "\"TryCast\" expected"; - case 220: return "\"TypeOf\" expected"; - case 221: return "\"UInteger\" expected"; - case 222: return "\"ULong\" expected"; - case 223: return "\"Unicode\" expected"; - case 224: return "\"Until\" expected"; - case 225: return "\"UShort\" expected"; - case 226: return "\"Using\" expected"; - case 227: return "\"Variant\" expected"; - case 228: return "\"Wend\" expected"; - case 229: return "\"When\" expected"; - case 230: return "\"Where\" expected"; - case 231: return "\"While\" expected"; - case 232: return "\"Widening\" expected"; - case 233: return "\"With\" expected"; - case 234: return "\"WithEvents\" expected"; - case 235: return "\"WriteOnly\" expected"; - case 236: return "\"Xor\" expected"; - case 237: return "\"GetXmlNamespace\" expected"; - case 238: return "??? expected"; - case 239: return "this symbol not expected in StatementTerminator"; - case 240: return "invalid StatementTerminator"; - case 241: return "invalid OptionStatement"; - case 242: return "invalid Identifier"; - case 243: return "invalid IdentifierForFieldDeclaration"; - case 244: return "invalid TypeName"; - case 245: return "invalid PrimitiveTypeName"; - case 246: return "invalid QualifiedTypeName"; - case 247: return "invalid OnOff"; - case 248: return "invalid BinaryText"; - case 249: return "invalid ImportsClause"; - case 250: return "this symbol not expected in ImportsClause"; - - default: return "error " + errorNumber; - } - } -} // end Parser - -} // end namespace diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Parser.frame b/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Parser.frame deleted file mode 100644 index 4abbfccef..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/Parser.frame +++ /dev/null @@ -1,119 +0,0 @@ -/*---------------------------------------------------------------------------*\ - Compiler Generator Coco/R, - Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz - extended by M. Loeberbauer & A. Woess, Univ. of Linz - with improvements by Pat Terry, Rhodes University -------------------------------------------------------------------------------- -License - This file is part of Compiler Generator Coco/R - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - As an exception, it is allowed to write an extension of Coco/R that is - used as a plugin in non-free software. - - If not otherwise stated, any source code generated by Coco/R (other than - Coco/R itself) does not fall under the GNU General Public License. - -About this file - This is a so-called 'frame' file that contains skeleton code for - generating a final Scanner/Parser code. - - The '-->TAG' text markers are used to delimit code chunks and typically - correspond to places where additional information is added by the - DFA or ParserGen code. - - All information prior to the first 'begin' text marker is discarded. - If the grammar contains a '[copy]' .. '[/copy]' section, its contents - will added instead. -\*---------------------------------------------------------------------------*/ --->begin - --->namespace - -// ---------------------------------------------------------------------------- -// Parser -// ---------------------------------------------------------------------------- -//! A Coco/R Parser -partial class VBParser -{ --->constants - const bool T = true; - const bool x = false; - const int minErrDist = 2; - - public Errors errors; - - --->declarations - - void Get () { - lexer.NextToken(); --->pragmas - } - - bool StartOf (int s) { - return set[s].Get(la.kind); - } - - void ExpectWeak (int n, int follow) { - if (la.kind == n) Get(); - else { - SynErr(n); - while (!StartOf(follow)) Get(); - } - } - - - bool WeakSeparator(int n, int syFol, int repFol) { - int kind = la.kind; - if (kind == n) {Get(); return true;} - else if (StartOf(repFol)) {return false;} - else { - SynErr(n); - while (!(set[syFol].Get(kind) || set[repFol].Get(kind) || set[0].Get(kind))) { - Get(); - kind = la.kind; - } - return StartOf(syFol); - } - } - - --->productions - - public void ParseRoot() { --->parseRoot - } - - static readonly BitArray[] set = { --->initialization - }; - - void SynErr(int line, int col, int errorNumber) - { - this.Errors.Error(line, col, GetMessage(errorNumber)); - } - - string GetMessage(int errorNumber) - { - switch (errorNumber) { - -->errors - default: return "error " + errorNumber; - } - } -} // end Parser - -$$$ diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/VBParser.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/VBParser.cs deleted file mode 100644 index bb3516cb2..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/VBParser.cs +++ /dev/null @@ -1,436 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Visitors; - -namespace ICSharpCode.NRefactory.VB.Parser -{ - internal partial class VBParser : IDisposable - { - VBLexer lexer; - Stack stack; - CompilationUnit compilationUnit; - int errDist = MinErrDist; - - const int MinErrDist = 2; - const string ErrMsgFormat = "-- line {0} col {1}: {2}"; // 0=line, 1=column, 2=text - - public VBParser(VBLexer lexer) - { - this.errors = lexer.Errors; - errors.SynErr = new ErrorCodeProc(SynErr); - this.lexer = (VBLexer)lexer; - this.stack = new Stack(); - } - - #region Infrastructure - void NodeStart(AstNode node) - { - stack.Push(node); - } - - void NodeEnd(AstNode currentNode, Role role) - { - AstNode node = stack.Pop(); - Debug.Assert(currentNode == node); - stack.Peek().AddChildUntyped(node, role); - } - - void AddTerminal(Role role) - { - stack.Peek().AddChild(new VBTokenNode(t.Location, t.EndLocation), role); - } - - void AddChild(T childNode, Role role) where T : AstNode - { - if (childNode != null) { - stack.Peek().AddChild(childNode, role); - } - } - - StringBuilder qualidentBuilder = new StringBuilder(); - - Token t - { - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.Token; - } - } - - Token la - { - [System.Diagnostics.DebuggerStepThrough] - get { - return lexer.LookAhead; - } - } - - Token Peek(int n) - { - lexer.StartPeek(); - Token x = la; - while (n > 0) { - x = lexer.Peek(); - n--; - } - return x; - } - - public void Error(string s) - { - if (errDist >= MinErrDist) { - this.Errors.Error(la.line, la.col, s); - } - errDist = 0; - } - #endregion - - #region Parse - public void Parse() - { - ParseRoot(); - } - - public AstType ParseAstType() - { - // TODO - return null; - } - -// public Expression ParseExpression() -// { -// lexer.SetInitialContext(SnippetType.Expression); -// lexer.NextToken(); -// Location startLocation = la.Location; -// Expression expr; -// Expr(out expr); -// while (la.kind == Tokens.EOL) lexer.NextToken(); -// if (expr != null) { -// expr.StartLocation = startLocation; -// expr.EndLocation = t.EndLocation; -// expr.AcceptVisitor(new SetParentVisitor(), null); -// } -// Expect(Tokens.EOF); -// return expr; -// } - -// public BlockStatement ParseBlock() -// { -// lexer.NextToken(); -// compilationUnit = new CompilationUnit(); -// -// Location startLocation = la.Location; -// Statement st; -// Block(out st); -// if (st != null) { -// st.StartLocation = startLocation; -// if (t != null) -// st.EndLocation = t.EndLocation; -// else -// st.EndLocation = la.Location; -// st.AcceptVisitor(new SetParentVisitor(), null); -// } -// Expect(Tokens.EOF); -// return st as BlockStatement; -// } - -// public List ParseTypeMembers() -// { -// lexer.NextToken(); -// TypeDeclaration newType = new TypeDeclaration(Modifiers.None, null); -// BlockStart(newType); -// ClassBody(newType); -// BlockEnd(); -// Expect(Tokens.EOF); -// newType.AcceptVisitor(new SetParentVisitor(), null); -// return newType.Children; -// } - #endregion - - #region Conflict Resolvers - bool IsAliasImportsClause() - { - return IsIdentifierToken(la) && Peek(1).Kind == Tokens.Assign; - } - - static bool IsIdentifierToken(Token tk) - { - return Tokens.IdentifierTokens[tk.kind] || tk.kind == Tokens.Identifier; - } - #endregion - - /* True, if "." is followed by an ident */ - bool DotAndIdentOrKw () { - int peek = Peek(1).kind; - return la.kind == Tokens.Dot && (peek == Tokens.Identifier || peek >= Tokens.AddHandler); - } - - bool IsIdentifiedExpressionRange() - { - // t = Select - // la = Identifier - // Peek(1) = As or Assign - Token token = Peek(1); - return IsIdentifierToken(la) && (token.kind == Tokens.As || token.kind == Tokens.Assign); - } - - bool IsQueryExpression() - { - return (la.kind == Tokens.From || la.kind == Tokens.Aggregate) && IsIdentifierToken(Peek(1)); - } - - bool IsEndStmtAhead() - { - int peek = Peek(1).kind; - return la.kind == Tokens.End && (peek == Tokens.EOL || peek == Tokens.Colon); - } - - bool IsNotClosingParenthesis() { - return la.kind != Tokens.CloseParenthesis; - } - - /* - True, if ident is followed by "=" or by ":" and "=" - */ - bool IsNamedAssign() { - return Peek(1).kind == Tokens.ColonAssign; - } - - bool IsObjectCreation() { - return la.kind == Tokens.As && Peek(1).kind == Tokens.New; - } - - bool IsNewExpression() { - return la.kind == Tokens.New; - } - - /* - True, if "<" is followed by the ident "assembly" or "module" - */ - bool IsGlobalAttrTarget () { - Token pt = Peek(1); - return la.kind == Tokens.LessThan && ( string.Equals(pt.val, "assembly", StringComparison.InvariantCultureIgnoreCase) || string.Equals(pt.val, "module", StringComparison.InvariantCultureIgnoreCase)); - } - - /* - True if the next token is a "(" and is followed by "," or ")" - */ - bool IsDims() - { - int peek = Peek(1).kind; - return la.kind == Tokens.OpenParenthesis - && (peek == Tokens.Comma || peek == Tokens.CloseParenthesis); - } - - /* - True if the next token is an identifier - */ - bool IsLoopVariableDeclaration() - { - if (!IsIdentifierToken(la)) - return false; - lexer.StartPeek(); - Token x = lexer.Peek(); - if (x.kind == Tokens.OpenParenthesis) { - do { - x = lexer.Peek(); - } while (x.kind == Tokens.Comma); - if (x.kind != Tokens.CloseParenthesis) - return false; - x = lexer.Peek(); - } - return x.kind == Tokens.As || x.kind == Tokens.Assign; - } - - bool IsSize() - { - return la.kind == Tokens.OpenParenthesis; - } - - /* - True, if the comma is not a trailing one, - like the last one in: a, b, c, - */ - bool NotFinalComma() { - int peek = Peek(1).kind; - return la.kind == Tokens.Comma && - peek != Tokens.CloseCurlyBrace; - } - - /* - True, if the next token is "Else" and this one - if followed by "If" - */ - bool IsElseIf() - { - int peek = Peek(1).kind; - return la.kind == Tokens.Else && peek == Tokens.If; - } - - /* - True if the next token is goto and this one is - followed by minus ("-") (this is allowd in in - error clauses) - */ - bool IsNegativeLabelName() - { - int peek = Peek(1).kind; - return la.kind == Tokens.GoTo && peek == Tokens.Minus; - } - - /* - True if the next statement is a "Resume next" statement - */ - bool IsResumeNext() - { - int peek = Peek(1).kind; - return la.kind == Tokens.Resume && peek == Tokens.Next; - } - - /// - /// Returns True, if ident/literal integer is followed by ":" - /// - bool IsLabel() - { - return (la.kind == Tokens.Identifier || la.kind == Tokens.LiteralInteger) - && Peek(1).kind == Tokens.Colon; - } - - /// - /// Returns true if a property declaration is an automatic property. - /// - bool IsAutomaticProperty() - { - lexer.StartPeek(); - Token tn = la; - int braceCount = 0; - - // look for attributes - while (tn.kind == Tokens.LessThan) { - while (braceCount > 0 || tn.kind != Tokens.GreaterThan) { - tn = lexer.Peek(); - if (tn.kind == Tokens.OpenParenthesis) - braceCount++; - if (tn.kind == Tokens.CloseParenthesis) - braceCount--; - } - Debug.Assert(tn.kind == Tokens.GreaterThan); - tn = lexer.Peek(); - } - - // look for modifiers - var allowedTokens = new[] { - Tokens.Public, Tokens.Protected, - Tokens.Friend, Tokens.Private - }; - - while (allowedTokens.Contains(tn.kind)) - tn = lexer.Peek(); - - if (tn.Kind != Tokens.Get && tn.Kind != Tokens.Set) - return true; - - return false; - } - - bool IsNotStatementSeparator() - { - return la.kind == Tokens.Colon && Peek(1).kind == Tokens.EOL; - } - - static bool IsMustOverride(AttributedNode node) - { - return node.Modifiers.HasFlag(Modifiers.MustOverride); - } - - /* Writes the type name represented through the expression into the string builder. */ - /* Returns true when the expression was converted successfully, returns false when */ - /* There was an unknown expression (e.g. TypeReferenceExpression) in it */ -// bool WriteFullTypeName(StringBuilder b, Expression expr) -// { -// MemberReferenceExpression fre = expr as MemberReferenceExpression; -// if (fre != null) { -// bool result = WriteFullTypeName(b, fre.TargetObject); -// if (b.Length > 0) b.Append('.'); -// b.Append(fre.MemberName); -// return result; -// } else if (expr is SimpleNameExpression) { -// b.Append(((SimpleNameExpression)expr).Identifier); -// return true; -// } else { -// return false; -// } -// } - - void EnsureIsZero(Expression expr) - { - if (!(expr is PrimitiveExpression) || (expr as PrimitiveExpression).StringValue != "0") - Error("lower bound of array must be zero"); - } - - public bool ParseMethodBodies { get; set; } - - public VBLexer Lexer { - get { - return lexer; - } - } - - public Errors Errors { - get { - return errors; - } - } - - public CompilationUnit CompilationUnit { - get { - return compilationUnit; - } - } - - void SynErr(int n) - { - if (errDist >= MinErrDist) { - errors.SynErr(lexer.LookAhead.line, lexer.LookAhead.col, n); - } - errDist = 0; - } - - void SemErr(string msg) - { - if (errDist >= MinErrDist) { - errors.Error(lexer.Token.line, lexer.Token.col, msg); - } - errDist = 0; - } - - void Expect(int n) - { - if (lexer.LookAhead.kind == n) { - lexer.NextToken(); - } else { - SynErr(n); - } - } - - #region System.IDisposable interface implementation - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")] - public void Dispose() - { - errors = null; - if (lexer != null) { - lexer.Dispose(); - } - lexer = null; - } - #endregion - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/vb.atg b/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/vb.atg deleted file mode 100644 index f6787ab95..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Parser/vb.atg +++ /dev/null @@ -1,460 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Text; -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using ASTAttribute = ICSharpCode.NRefactory.VB.Ast.Attribute; -using Roles = ICSharpCode.NRefactory.VB.AstNode.Roles; - -COMPILER VB - -#region AUTOGENERATED TOKENS SECTION -TOKENS - /* ----- terminal classes ----- */ - /* EOF is 0 */ - EOL - ident - LiteralString - LiteralCharacter - LiteralInteger - LiteralDouble - LiteralSingle - LiteralDecimal - LiteralDate - XmlOpenTag // < - XmlCloseTag // > - XmlStartInlineVB // <%= - XmlEndInlineVB // %> - XmlCloseTagEmptyElement // /> - XmlOpenEndTag // - XmlCData // - XmlProcessingInstruction - - /* ----- special character ----- */ - "=" - ":" - "," - "&" - "/" - "\\" - "." - "..." - ".@" - "!" - "-" - "+" - "^" - "?" - "*" - "{" - "}" - "(" - ")" - ">" - "<" - "<>" - ">=" - "<=" - "<<" - ">>" - "+=" - "^=" - "-=" - "*=" - "/=" - "\\=" - "<<=" - ">>=" - "&=" - ":=" - - /* ----- keywords ----- */ - "AddHandler" - "AddressOf" - "Aggregate" - "Alias" - "And" - "AndAlso" - "Ansi" - "As" - "Ascending" - "Assembly" - "Auto" - "Binary" - "Boolean" - "ByRef" - "By" - "Byte" - "ByVal" - "Call" - "Case" - "Catch" - "CBool" - "CByte" - "CChar" - "CDate" - "CDbl" - "CDec" - "Char" - "CInt" - "Class" - "CLng" - "CObj" - "Compare" - "Const" - "Continue" - "CSByte" - "CShort" - "CSng" - "CStr" - "CType" - "CUInt" - "CULng" - "CUShort" - "Custom" - "Date" - "Decimal" - "Declare" - "Default" - "Delegate" - "Descending" - "Dim" - "DirectCast" - "Distinct" - "Do" - "Double" - "Each" - "Else" - "ElseIf" - "End" - "EndIf" - "Enum" - "Equals" - "Erase" - "Error" - "Event" - "Exit" - "Explicit" - "False" - "Finally" - "For" - "Friend" - "From" - "Function" - "Get" - "GetType" - "Global" - "GoSub" - "GoTo" - "Group" - "Handles" - "If" - "Implements" - "Imports" - "In" - "Infer" - "Inherits" - "Integer" - "Interface" - "Into" - "Is" - "IsNot" - "Join" - "Key" - "Let" - "Lib" - "Like" - "Long" - "Loop" - "Me" - "Mod" - "Module" - "MustInherit" - "MustOverride" - "MyBase" - "MyClass" - "Namespace" - "Narrowing" - "New" - "Next" - "Not" - "Nothing" - "NotInheritable" - "NotOverridable" - "Object" - "Of" - "Off" - "On" - "Operator" - "Option" - "Optional" - "Or" - "Order" - "OrElse" - "Out" - "Overloads" - "Overridable" - "Overrides" - "ParamArray" - "Partial" - "Preserve" - "Private" - "Property" - "Protected" - "Public" - "RaiseEvent" - "ReadOnly" - "ReDim" - "Rem" - "RemoveHandler" - "Resume" - "Return" - "SByte" - "Select" - "Set" - "Shadows" - "Shared" - "Short" - "Single" - "Skip" - "Static" - "Step" - "Stop" - "Strict" - "String" - "Structure" - "Sub" - "SyncLock" - "Take" - "Text" - "Then" - "Throw" - "To" - "True" - "Try" - "TryCast" - "TypeOf" - "UInteger" - "ULong" - "Unicode" - "Until" - "UShort" - "Using" - "Variant" - "Wend" - "When" - "Where" - "While" - "Widening" - "With" - "WithEvents" - "WriteOnly" - "Xor" - "GetXmlNamespace" -#endregion - -PRODUCTIONS - -#region General - -VB = -(. - compilationUnit = new CompilationUnit(); - NodeStart(compilationUnit); - Get(); -.) - { StatementTerminator } - { OptionStatement { StatementTerminator } } - { ImportsStatement { StatementTerminator } } -/* { IF (IsGlobalAttrTarget()) GlobalAttributeSection { StatementTerminator } } - { NamespaceMemberDecl { StatementTerminator } } */ -. - -StatementTerminator = SYNC ( EOL | ":" ) . - -#region Identifier - -//IdentifierOrKeyword = ANY (. identifier = t.val; .) . - -// This production handles pseudo keywords that are needed in the grammar -Identifier = - IdentifierForFieldDeclaration - | "Custom" -. - -IdentifierForFieldDeclaration = - ident - | "Aggregate" - | "Ansi" - | "Ascending" - | "Assembly" - | "Auto" - | "Binary" - | "By" - | "Compare" - | "Descending" - | "Distinct" - | "Equals" - | "Explicit" - | "From" - | "Group" - | "Infer" - | "Into" - | "Join" - | "Key" - | "Off" - | "Order" - | "Out" - | "Preserve" - | "Skip" - | "Take" - | "Text" - | "Unicode" - | "Until" - | "Where" -. -#endregion - -TypeName (. type = null; .) = - PrimitiveTypeName | - QualifiedTypeName -. -QualifiedTypeName = - ( "Global" | Identifier ) (. type = new SimpleType(t.val, t.Location); .) - { "." Identifier (. type = new QualifiedType(type, new Identifier(t.val, t.Location)); .) } - // TODO : add TypeArguments -. - -PrimitiveTypeName (. type = null; .) = - "Object" (. type = new PrimitiveType("Object", t.Location); .) - | "Boolean" (. type = new PrimitiveType("Boolean", t.Location); .) - | "Date" (. type = new PrimitiveType("Date", t.Location); .) - | "Char" (. type = new PrimitiveType("Char", t.Location); .) - | "String" (. type = new PrimitiveType("String", t.Location); .) - | "Decimal" (. type = new PrimitiveType("Decimal", t.Location); .) - | "Byte" (. type = new PrimitiveType("Byte", t.Location); .) - | "Short" (. type = new PrimitiveType("Short", t.Location); .) - | "Integer" (. type = new PrimitiveType("Integer", t.Location); .) - | "Long" (. type = new PrimitiveType("Long", t.Location); .) - | "Single" (. type = new PrimitiveType("Single", t.Location); .) - | "Double" (. type = new PrimitiveType("Double", t.Location); .) - | "UInteger" (. type = new PrimitiveType("UInteger", t.Location); .) - | "ULong" (. type = new PrimitiveType("ULong", t.Location); .) - | "UShort" (. type = new PrimitiveType("UShort", t.Location); .) - | "SByte" (. type = new PrimitiveType("SByte", t.Location); .) -. - -/* -ParameterModifier = - "ByVal" (. m.Add(ParameterModifiers.In); .) - | "ByRef" (. m.Add(ParameterModifiers.Ref); .) - | "Optional" (. m.Add(ParameterModifiers.Optional); .) - | "ParamArray" (. m.Add(ParameterModifiers.Params); .) -. - -TypeModifier = - "Public" (. m.Add(Modifiers.Public, t.Location); .) - | "Protected" (. m.Add(Modifiers.Protected, t.Location); .) - | "Friend" (. m.Add(Modifiers.Internal, t.Location); .) - | "Private" (. m.Add(Modifiers.Private, t.Location); .) - | "Shared" (. m.Add(Modifiers.Static, t.Location); .) - | "Shadows" (. m.Add(Modifiers.New, t.Location); .) - | "MustInherit" (. m.Add(Modifiers.Abstract, t.Location); .) - | "NotInheritable" (. m.Add(Modifiers.Sealed, t.Location); .) - | "Partial" (. m.Add(Modifiers.Partial, t.Location); .) -. - -MemberModifier = - "MustInherit" (.m.Add(Modifiers.Abstract, t.Location);.) - | "Default" (.m.Add(Modifiers.Default, t.Location);.) - | "Friend" (.m.Add(Modifiers.Internal, t.Location);.) - | "Shadows" (.m.Add(Modifiers.New, t.Location);.) - | "Overrides" (.m.Add(Modifiers.Override, t.Location);.) - | "MustOverride" (.m.Add(Modifiers.Abstract, t.Location);.) - | "Private" (.m.Add(Modifiers.Private, t.Location);.) - | "Protected" (.m.Add(Modifiers.Protected, t.Location);.) - | "Public" (.m.Add(Modifiers.Public, t.Location);.) - | "NotInheritable" (.m.Add(Modifiers.Sealed, t.Location);.) - | "NotOverridable" (.m.Add(Modifiers.Sealed, t.Location);.) - | "Shared" (.m.Add(Modifiers.Static, t.Location);.) - | "Overridable" (.m.Add(Modifiers.Virtual, t.Location);.) - | "Overloads" (.m.Add(Modifiers.Overloads, t.Location);.) - | "ReadOnly" (.m.Add(Modifiers.ReadOnly, t.Location);.) - | "WriteOnly" (.m.Add(Modifiers.WriteOnly, t.Location);.) - | "WithEvents" (.m.Add(Modifiers.WithEvents, t.Location);.) - | "Dim" (.m.Add(Modifiers.Dim, t.Location);.) - | "Partial" (.m.Add(Modifiers.Partial, t.Location);.) -. - -PropertyAccessorAccessModifier = - (. m = Modifiers.None; .) - { - "Public" (. m |= Modifiers.Public; .) - | "Protected" (. m |= Modifiers.Protected; .) - | "Friend" (. m |= Modifiers.Internal; .) - | "Private" (. m |= Modifiers.Private; .) - } -. -*/ -#endregion - -#region Global - -#region OptionStatement - -OptionStatement = - "Option" ( - "Explicit" (. result.OptionType = OptionType.Explicit; .) [ OnOff ] - | "Strict" (. result.OptionType = OptionType.Strict; .) [ OnOff ] - | "Infer" (. result.OptionType = OptionType.Infer; .) [ OnOff ] - | "Compare" (. result.OptionType = OptionType.Compare; .) BinaryText - ) StatementTerminator -. - -OnOff = - "On" (. os.OptionValue = OptionValue.On; .) - | "Off" (. os.OptionValue = OptionValue.Off; .) -. - -BinaryText = - "Text" (. os.OptionValue = OptionValue.Text; .) - | "Binary" (. os.OptionValue = OptionValue.Binary; .) -. - -#endregion - -#region ImportsStatement - -ImportsStatement = - "Imports" ImportsClause { "," ImportsClause } StatementTerminator -. - -ImportsClause = - ( IF (IsAliasImportsClause()) - AliasImportsClause | - MemberImportsClause | - XmlNamespaceImportsClause ) SYNC . - -AliasImportsClause (. AstType alias; .) = - // Type characters are not allowed in identifiers here - Identifier (. result.Name = new Identifier(t.val, t.Location); .) "=" TypeName (. result.Alias = alias; .) -. - -MemberImportsClause (. AstType member; .) = - TypeName (. result.Member = member; .) -. - -XmlNamespaceImportsClause = - XmlOpenTag Identifier/**/ "=" LiteralString/**/ XmlCloseTag -. - -#endregion - -#endregion - -END VB . diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractOutputFormatter.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractOutputFormatter.cs deleted file mode 100644 index c858d664b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractOutputFormatter.cs +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections; -using System.Text; - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ - /// - /// Base class of output formatters. - /// - public abstract class AbstractOutputFormatter : IOutputFormatter - { - StringBuilder text = new StringBuilder(); - - int indentationLevel = 0; - bool indent = true; - bool doNewLine = true; - AbstractPrettyPrintOptions prettyPrintOptions; - - public bool IsInMemberBody { get; set; } - - public int IndentationLevel { - get { - return indentationLevel; - } - set { - indentationLevel = value; - } - } - - public string Text { - get { - return text.ToString(); - } - } - - public int TextLength { - get { - return text.Length; - } - } - - - public bool DoIndent { - get { - return indent; - } - set { - indent = value; - } - } - - public bool DoNewLine { - get { - return doNewLine; - } - set { - doNewLine = value; - } - } - - protected AbstractOutputFormatter(AbstractPrettyPrintOptions prettyPrintOptions) - { - this.prettyPrintOptions = prettyPrintOptions; - } - - internal bool isIndented = false; - public void Indent() - { - if (DoIndent) { - int indent = 0; - while (indent < prettyPrintOptions.IndentSize * indentationLevel) { - char ch = prettyPrintOptions.IndentationChar; - if (ch == '\t' && indent + prettyPrintOptions.TabSize > prettyPrintOptions.IndentSize * indentationLevel) { - ch = ' '; - } - text.Append(ch); - if (ch == '\t') { - indent += prettyPrintOptions.TabSize; - } else { - ++indent; - } - } - isIndented = true; - } - } - - public void Reset () - { - text.Length = 0; - isIndented = false; - } - - public void Space() - { - text.Append(' '); - isIndented = false; - } - - internal int lastLineStart = 0; - internal int lineBeforeLastStart = 0; - - public bool LastCharacterIsNewLine { - get { - return text.Length == lastLineStart; - } - } - - public bool LastCharacterIsWhiteSpace { - get { - return text.Length == 0 || char.IsWhiteSpace(text[text.Length - 1]); - } - } - - public virtual void NewLine() - { - if (DoNewLine) { - if (!LastCharacterIsNewLine) { - lineBeforeLastStart = lastLineStart; - } - text.AppendLine(); - lastLineStart = text.Length; - isIndented = false; - } - } - - public virtual void EndFile() - { - } - - protected void WriteLineInPreviousLine(string txt, bool forceWriteInPreviousBlock) - { - WriteInPreviousLine(txt + Environment.NewLine, forceWriteInPreviousBlock); - } - protected void WriteLineInPreviousLine(string txt, bool forceWriteInPreviousBlock, bool indent) - { - WriteInPreviousLine(txt + Environment.NewLine, forceWriteInPreviousBlock, indent); - } - - protected void WriteInPreviousLine(string txt, bool forceWriteInPreviousBlock) - { - WriteInPreviousLine(txt, forceWriteInPreviousBlock, true); - } - protected void WriteInPreviousLine(string txt, bool forceWriteInPreviousBlock, bool indent) - { - if (txt.Length == 0) return; - - bool lastCharacterWasNewLine = LastCharacterIsNewLine; - if (lastCharacterWasNewLine) { - if (forceWriteInPreviousBlock == false) { - if (indent && txt != Environment.NewLine) Indent(); - text.Append(txt); - lineBeforeLastStart = lastLineStart; - lastLineStart = text.Length; - return; - } - lastLineStart = lineBeforeLastStart; - } - string lastLine = text.ToString(lastLineStart, text.Length - lastLineStart); - text.Remove(lastLineStart, text.Length - lastLineStart); - if (indent && txt != Environment.NewLine) { - if (forceWriteInPreviousBlock) ++indentationLevel; - Indent(); - if (forceWriteInPreviousBlock) --indentationLevel; - } - text.Append(txt); - lineBeforeLastStart = lastLineStart; - lastLineStart = text.Length; - text.Append(lastLine); - if (lastCharacterWasNewLine) { - lineBeforeLastStart = lastLineStart; - lastLineStart = text.Length; - } - isIndented = false; - } - - /// - /// Prints a text that cannot be inserted before using WriteInPreviousLine - /// into the current line - /// - protected void PrintSpecialText(string specialText) - { - lineBeforeLastStart = text.Length; - text.Append(specialText); - lastLineStart = text.Length; - isIndented = false; - } - - public void PrintTokenList(ArrayList tokenList) - { - foreach (int token in tokenList) { - PrintToken(token); - Space(); - } - } - -// public abstract void PrintComment(Comment comment, bool forceWriteInPreviousBlock); - -// public virtual void PrintPreprocessingDirective(PreprocessingDirective directive, bool forceWriteInPreviousBlock) -// { -// if (!directive.Expression.IsNull) { -//// CSharpOutputVisitor visitor = new CSharpOutputVisitor(); -//// directive.Expression.AcceptVisitor(visitor, null); -//// WriteLineInPreviousLine(directive.Cmd + " " + visitor.Text, forceWriteInPreviousBlock); -// } else if (string.IsNullOrEmpty(directive.Arg)) -// WriteLineInPreviousLine(directive.Cmd, forceWriteInPreviousBlock); -// else -// WriteLineInPreviousLine(directive.Cmd + " " + directive.Arg, forceWriteInPreviousBlock); -// } - - public void PrintBlankLine(bool forceWriteInPreviousBlock) - { - WriteInPreviousLine(Environment.NewLine, forceWriteInPreviousBlock); - } - - public abstract void PrintToken(int token); - - public void PrintText(string text) - { - this.text.Append(text); - isIndented = false; - } - - public abstract void PrintIdentifier(string identifier); - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractPrettyPrintOptions.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractPrettyPrintOptions.cs deleted file mode 100644 index 7da8a578c..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/AbstractPrettyPrintOptions.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ - /// - /// Description of PrettyPrintOptions. - /// - public class AbstractPrettyPrintOptions - { - char indentationChar = '\t'; - int tabSize = 4; - int indentSize = 4; - - public char IndentationChar { - get { - return indentationChar; - } - set { - indentationChar = value; - } - } - - public int TabSize { - get { - return tabSize; - } - set { - tabSize = value; - } - } - - public int IndentSize { - get { - return indentSize; - } - set { - indentSize = value; - } - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs deleted file mode 100644 index 049696dad..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/IOutputAstVisitor.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ -// public interface IOutputDomVisitor : IAstVisitor -// { -// event Action BeforeNodeVisit; -// event Action AfterNodeVisit; -// -// string Text { -// get; -// } -// -// Errors Errors { -// get; -// } -// -// AbstractPrettyPrintOptions Options { -// get; -// } -// IOutputFormatter OutputFormatter { -// get; -// } -// } - - public interface IOutputFormatter - { - int IndentationLevel { - get; - set; - } - string Text { - get; - } - bool IsInMemberBody { - get; - set; - } - void NewLine(); - void Indent(); -// void PrintComment(Comment comment, bool forceWriteInPreviousBlock); -// void PrintPreprocessingDirective(PreprocessingDirective directive, bool forceWriteInPreviousBlock); - void PrintBlankLine(bool forceWriteInPreviousBlock); - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs deleted file mode 100644 index f44d91263..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/SpecialNodesInserter.cs +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ -// public class SpecialOutputVisitor : ISpecialVisitor -// { -// readonly IOutputFormatter formatter; -// -// public SpecialOutputVisitor(IOutputFormatter formatter) -// { -// this.formatter = formatter; -// } -// -// public bool ForceWriteInPreviousLine; -// -// public object Visit(ISpecial special, object data) -// { -// Console.WriteLine("Warning: SpecialOutputVisitor.Visit(ISpecial) called with " + special); -// return data; -// } -// -// public object Visit(BlankLine special, object data) -// { -// formatter.PrintBlankLine(ForceWriteInPreviousLine); -// return data; -// } -// -// public object Visit(Comment special, object data) -// { -// formatter.PrintComment(special, ForceWriteInPreviousLine); -// return data; -// } -// -// public object Visit(PreprocessingDirective special, object data) -// { -// formatter.PrintPreprocessingDirective(special, ForceWriteInPreviousLine); -// return data; -// } -// } -// -// /// -// /// This class inserts specials between INodes. -// /// -// public sealed class SpecialNodesInserter : IDisposable -// { -// IEnumerator enumerator; -// SpecialOutputVisitor visitor; -// bool available; // true when more specials are available -// -// public SpecialNodesInserter(IEnumerable specials, SpecialOutputVisitor visitor) -// { -// if (specials == null) throw new ArgumentNullException("specials"); -// if (visitor == null) throw new ArgumentNullException("visitor"); -// enumerator = specials.GetEnumerator(); -// this.visitor = visitor; -// available = enumerator.MoveNext(); -// } -// -// void WriteCurrent() -// { -// enumerator.Current.AcceptVisitor(visitor, null); -// available = enumerator.MoveNext(); -// } -// -// AttributedNode currentAttributedNode; -// -// /// -// /// Writes all specials up to the start position of the node. -// /// -// public void AcceptNodeStart(INode node) -// { -// if (node is AttributedNode) { -// currentAttributedNode = node as AttributedNode; -// if (currentAttributedNode.Attributes.Count == 0) { -// AcceptPoint(node.StartLocation); -// currentAttributedNode = null; -// } -// } else { -// AcceptPoint(node.StartLocation); -// } -// } -// -// /// -// /// Writes all specials up to the end position of the node. -// /// -// public void AcceptNodeEnd(INode node) -// { -// visitor.ForceWriteInPreviousLine = true; -// AcceptPoint(node.EndLocation); -// visitor.ForceWriteInPreviousLine = false; -// if (currentAttributedNode != null) { -// if (node == currentAttributedNode.Attributes[currentAttributedNode.Attributes.Count - 1]) { -// AcceptPoint(currentAttributedNode.StartLocation); -// currentAttributedNode = null; -// } -// } -// } -// -// /// -// /// Writes all specials up to the specified location. -// /// -// public void AcceptPoint(Location loc) -// { -// while (available && enumerator.Current.StartPosition <= loc) { -// WriteCurrent(); -// } -// } -// -// /// -// /// Outputs all missing specials to the writer. -// /// -// public void Finish() -// { -// while (available) { -// WriteCurrent(); -// } -// } -// -// void IDisposable.Dispose() -// { -// Finish(); -// } -// -// /// -// /// Registers a new SpecialNodesInserter with the output visitor. -// /// Make sure to call Finish() (or Dispose()) on the returned SpecialNodesInserter -// /// when the output is finished. -// /// -// public static SpecialNodesInserter Install(IEnumerable specials, IOutputDomVisitor outputVisitor) -// { -// SpecialNodesInserter sni = new SpecialNodesInserter(specials, new SpecialOutputVisitor(outputVisitor.OutputFormatter)); -// outputVisitor.BeforeNodeVisit += sni.AcceptNodeStart; -// outputVisitor.AfterNodeVisit += sni.AcceptNodeEnd; -// return sni; -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputFormatter.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputFormatter.cs deleted file mode 100644 index aadd790af..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputFormatter.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using ICSharpCode.NRefactory.VB.Parser; - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ - /// - /// Description of VBNetOutputFormatter. - /// - public sealed class VBNetOutputFormatter : AbstractOutputFormatter - { - public VBNetOutputFormatter(VBNetPrettyPrintOptions prettyPrintOptions) : base(prettyPrintOptions) - { - } - - public override void PrintToken(int token) - { - PrintText(Tokens.GetTokenString(token)); - } - - public override void PrintIdentifier(string identifier) - { - if (Keywords.IsNonIdentifierKeyword(identifier)) { - PrintText("["); - PrintText(identifier); - PrintText("]"); - } else { - PrintText(identifier); - } - } - -// public override void PrintComment(Comment comment, bool forceWriteInPreviousBlock) -// { -// switch (comment.CommentType) { -// case CommentType.Block: -// WriteLineInPreviousLine("'" + comment.CommentText.Replace("\n", "\n'"), forceWriteInPreviousBlock); -// break; -// case CommentType.Documentation: -// WriteLineInPreviousLine("'''" + comment.CommentText, forceWriteInPreviousBlock); -// break; -// default: -// WriteLineInPreviousLine("'" + comment.CommentText, forceWriteInPreviousBlock); -// break; -// } -// } - -// public override void PrintPreprocessingDirective(PreprocessingDirective directive, bool forceWriteInPreviousBlock) -// { -// if (IsInMemberBody -// && (string.Equals(directive.Cmd, "#Region", StringComparison.InvariantCultureIgnoreCase) -// || string.Equals(directive.Cmd, "#End", StringComparison.InvariantCultureIgnoreCase) -// && directive.Arg.StartsWith("Region", StringComparison.InvariantCultureIgnoreCase))) -// { -// WriteLineInPreviousLine("'" + directive.Cmd + " " + directive.Arg, forceWriteInPreviousBlock); -// } else if (!directive.Expression.IsNull) { -// VBNetOutputVisitor visitor = new VBNetOutputVisitor(); -// directive.Expression.AcceptVisitor(visitor, null); -// WriteLineInPreviousLine(directive.Cmd + " " + visitor.Text + " Then", forceWriteInPreviousBlock); -// } else { -// base.PrintPreprocessingDirective(directive, forceWriteInPreviousBlock); -// } -// } - - public void PrintLineContinuation() - { - if (!LastCharacterIsWhiteSpace) - Space(); - PrintText("_" + Environment.NewLine); - } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs deleted file mode 100644 index d4635d1d1..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetOutputVisitor.cs +++ /dev/null @@ -1,3023 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Linq; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Text; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; -using ICSharpCode.NRefactory.VB.Visitors; - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ -// public sealed class VBNetOutputVisitor : NodeTrackingAstVisitor, IOutputDomVisitor -// { -// Errors errors = new Errors(); -// VBNetOutputFormatter outputFormatter; -// VBNetPrettyPrintOptions prettyPrintOptions = new VBNetPrettyPrintOptions(); -// TypeDeclaration currentType; -// -// Stack exitTokenStack = new Stack(); -// -// public string Text { -// get { -// return outputFormatter.Text; -// } -// } -// -// public Errors Errors { -// get { -// return errors; -// } -// } -// -// AbstractPrettyPrintOptions IOutputDomVisitor.Options { -// get { return prettyPrintOptions; } -// } -// -// public VBNetPrettyPrintOptions Options { -// get { return prettyPrintOptions; } -// } -// -// public IOutputFormatter OutputFormatter { -// get { -// return outputFormatter; -// } -// } -// -// public VBNetOutputVisitor() -// { -// outputFormatter = new VBNetOutputFormatter(prettyPrintOptions); -// } -// -// public event Action BeforeNodeVisit; -// public event Action AfterNodeVisit; -// -// protected override void BeginVisit(INode node) -// { -// if (BeforeNodeVisit != null) { -// BeforeNodeVisit(node); -// } -// base.BeginVisit(node); -// } -// -// protected override void EndVisit(INode node) -// { -// base.EndVisit(node); -// if (AfterNodeVisit != null) { -// AfterNodeVisit(node); -// } -// } -// -// object TrackedVisit(INode node, object data) -// { -// return node.AcceptVisitor(this, data); -// } -// -// void Error(string text, Location position) -// { -// errors.Error(position.Line, position.Column, text); -// } -// -// void UnsupportedNode(INode node) -// { -// Error(node.GetType().Name + " is unsupported", node.StartLocation); -// } -// -// #region ICSharpCode.NRefactory.Parser.IAstVisitor interface implementation -// public override object TrackedVisitCompilationUnit(CompilationUnit compilationUnit, object data) -// { -// compilationUnit.AcceptChildren(this, data); -// outputFormatter.EndFile(); -// return null; -// } -// -// /// -// /// Converts type name to primitive type name. Returns typeString if typeString is not -// /// a primitive type. -// /// -// static string ConvertTypeString(string typeString) -// { -// string primitiveType; -// if (TypeReference.PrimitiveTypesVBReverse.TryGetValue(typeString, out primitiveType)) -// return primitiveType; -// else -// return typeString; -// } -// -// public override object TrackedVisitTypeReference(TypeReference typeReference, object data) -// { -// if (typeReference == TypeReference.ClassConstraint) { -// outputFormatter.PrintToken(Tokens.Class); -// } else if (typeReference == TypeReference.StructConstraint) { -// outputFormatter.PrintToken(Tokens.Structure); -// } else if (typeReference == TypeReference.NewConstraint) { -// outputFormatter.PrintToken(Tokens.New); -// } else { -// PrintTypeReferenceWithoutArray(typeReference); -// if (typeReference.IsArrayType) { -// PrintArrayRank(typeReference.RankSpecifier, 0); -// } -// } -// return null; -// } -// -// void PrintTypeReferenceWithoutArray(TypeReference typeReference) -// { -// if (typeReference.IsGlobal) { -// outputFormatter.PrintToken(Tokens.Global); -// outputFormatter.PrintToken(Tokens.Dot); -// } -// bool printGenerics = true; -// if (typeReference.IsKeyword) { -// outputFormatter.PrintText(ConvertTypeString(typeReference.Type)); -// } else { -// outputFormatter.PrintIdentifier(typeReference.Type); -// } -// if (printGenerics && typeReference.GenericTypes != null && typeReference.GenericTypes.Count > 0) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// outputFormatter.PrintToken(Tokens.Of); -// outputFormatter.Space(); -// AppendCommaSeparatedList(typeReference.GenericTypes); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// for (int i = 0; i < typeReference.PointerNestingLevel; ++i) { -// outputFormatter.PrintToken(Tokens.Times); -// } -// } -// -// void PrintArrayRank(int[] rankSpecifier, int startRank) -// { -// for (int i = startRank; i < rankSpecifier.Length; ++i) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// for (int j = 0; j < rankSpecifier[i]; ++j) { -// outputFormatter.PrintToken(Tokens.Comma); -// } -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// } -// -// public override object TrackedVisitInnerClassTypeReference(InnerClassTypeReference innerClassTypeReference, object data) -// { -// TrackedVisit(innerClassTypeReference.BaseType, data); -// outputFormatter.PrintToken(Tokens.Dot); -// return VisitTypeReference((TypeReference)innerClassTypeReference, data); -// } -// -// #region Global scope -// bool printAttributeSectionInline; // is set to true when printing parameter's attributes -// -// public override object TrackedVisitAttributeSection(AttributeSection attributeSection, object data) -// { -// if (!printAttributeSectionInline) -// outputFormatter.Indent(); -// outputFormatter.PrintText("<"); -// if (!string.IsNullOrEmpty(attributeSection.AttributeTarget) && !string.Equals(attributeSection.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) { -// outputFormatter.PrintText(char.ToUpperInvariant(attributeSection.AttributeTarget[0]) + attributeSection.AttributeTarget.Substring(1)); -// outputFormatter.PrintToken(Tokens.Colon); -// outputFormatter.Space(); -// } -// Debug.Assert(attributeSection.Attributes != null); -// AppendCommaSeparatedList(attributeSection.Attributes); -// -// outputFormatter.PrintText(">"); -// -// if ("assembly".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase) -// || "module".Equals(attributeSection.AttributeTarget, StringComparison.InvariantCultureIgnoreCase)) { -// outputFormatter.NewLine(); -// } else { -// if (printAttributeSectionInline) -// outputFormatter.Space(); -// else -// outputFormatter.PrintLineContinuation(); -// } -// -// return null; -// } -// -// public override object TrackedVisitAttribute(ICSharpCode.NRefactory.VB.Ast.Attribute attribute, object data) -// { -// outputFormatter.PrintIdentifier(attribute.Type); -// if (attribute.PositionalArguments.Count > 0 || attribute.NamedArguments.Count > 0) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(attribute.PositionalArguments); -// -// if (attribute.NamedArguments.Count > 0) { -// if (attribute.PositionalArguments.Count > 0) { -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// } -// AppendCommaSeparatedList(attribute.NamedArguments); -// } -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// return null; -// } -// -// public override object TrackedVisitNamedArgumentExpression(NamedArgumentExpression namedArgumentExpression, object data) -// { -// outputFormatter.PrintIdentifier(namedArgumentExpression.Name); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Colon); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(namedArgumentExpression.Expression, data); -// return null; -// } -// -// public override object TrackedVisitUsing(ImportsClause @using, object data) -// { -// Debug.Fail("Should never be called. The usings should be handled in Visit(UsingDeclaration)"); -// return null; -// } -// -// public override object TrackedVisitUsingDeclaration(ImportsStatement usingDeclaration, object data) -// { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Imports); -// outputFormatter.Space(); -// for (int i = 0; i < usingDeclaration.ImportsClauses.Count; ++i) { -// outputFormatter.PrintIdentifier(((ImportsClause)usingDeclaration.ImportsClauses[i]).Name); -// if (((ImportsClause)usingDeclaration.ImportsClauses[i]).IsAlias) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(((ImportsClause)usingDeclaration.ImportsClauses[i]).Alias, data); -// } -// if (i + 1 < usingDeclaration.ImportsClauses.Count) { -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// } -// } -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data) -// { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Namespace); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(namespaceDeclaration.Name); -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// namespaceDeclaration.AcceptChildren(this, data); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Namespace); -// outputFormatter.NewLine(); -// return null; -// } -// -// static int GetTypeToken(TypeDeclaration typeDeclaration) -// { -// switch (typeDeclaration.Type) { -// case ClassType.Class: -// return Tokens.Class; -// case ClassType.Enum: -// return Tokens.Enum; -// case ClassType.Interface: -// return Tokens.Interface; -// case ClassType.Struct: -// return Tokens.Structure; -// case ClassType.Module: -// return Tokens.Module; -// default: -// return Tokens.Class; -// } -// } -// -// void PrintTemplates(List templates) -// { -// if (templates != null && templates.Count > 0) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// outputFormatter.PrintToken(Tokens.Of); -// outputFormatter.Space(); -// AppendCommaSeparatedList(templates); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// } -// -// public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) -// { -// VisitAttributes(typeDeclaration.Attributes, data); -// -// outputFormatter.Indent(); -// OutputModifier(typeDeclaration.Modifier, true, false); -// -// int typeToken = GetTypeToken(typeDeclaration); -// outputFormatter.PrintToken(typeToken); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(typeDeclaration.Name); -// -// PrintTemplates(typeDeclaration.Templates); -// -// if (typeDeclaration.Type == ClassType.Enum -// && typeDeclaration.BaseTypes != null && typeDeclaration.BaseTypes.Count > 0) -// { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) { -// TrackedVisit(baseTypeRef, data); -// } -// } -// -// outputFormatter.NewLine(); -// ++outputFormatter.IndentationLevel; -// -// if (typeDeclaration.BaseTypes != null && typeDeclaration.Type != ClassType.Enum) { -// foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) { -// outputFormatter.Indent(); -// -// string baseType = baseTypeRef.Type; -// if (baseType.IndexOf('.') >= 0) { -// baseType = baseType.Substring(baseType.LastIndexOf('.') + 1); -// } -// bool baseTypeIsInterface = baseType.Length >= 2 && baseType[0] == 'I' && Char.IsUpper(baseType[1]); -// -// if (!baseTypeIsInterface || typeDeclaration.Type == ClassType.Interface) { -// outputFormatter.PrintToken(Tokens.Inherits); -// } else { -// outputFormatter.PrintToken(Tokens.Implements); -// } -// outputFormatter.Space(); -// TrackedVisit(baseTypeRef, data); -// outputFormatter.NewLine(); -// } -// } -// -// TypeDeclaration oldType = currentType; -// currentType = typeDeclaration; -// -// if (typeDeclaration.Type == ClassType.Enum) { -// OutputEnumMembers(typeDeclaration, data); -// } else { -// typeDeclaration.AcceptChildren(this, data); -// } -// currentType = oldType; -// -// --outputFormatter.IndentationLevel; -// -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(typeToken); -// outputFormatter.NewLine(); -// return null; -// } -// -// void OutputEnumMembers(TypeDeclaration typeDeclaration, object data) -// { -// foreach (FieldDeclaration fieldDeclaration in typeDeclaration.Children) { -// BeginVisit(fieldDeclaration); -// VariableDeclaration f = (VariableDeclaration)fieldDeclaration.Fields[0]; -// VisitAttributes(fieldDeclaration.Attributes, data); -// outputFormatter.Indent(); -// outputFormatter.PrintIdentifier(f.Name); -// if (f.Initializer != null && !f.Initializer.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(f.Initializer, data); -// } -// outputFormatter.NewLine(); -// EndVisit(fieldDeclaration); -// } -// } -// -// public override object TrackedVisitTemplateDefinition(TemplateDefinition templateDefinition, object data) -// { -// VisitAttributes(templateDefinition.Attributes, data); -// switch (templateDefinition.VarianceModifier) { -// case VarianceModifier.Invariant: -// // nothing -// break; -// case VarianceModifier.Covariant: -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Out); -// outputFormatter.Space(); -// break; -// case VarianceModifier.Contravariant: -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.In); -// outputFormatter.Space(); -// break; -// default: -// throw new Exception("Invalid value for VarianceModifier"); -// } -// outputFormatter.PrintIdentifier(templateDefinition.Name); -// if (templateDefinition.Bases.Count > 0) { -// outputFormatter.PrintText(" As "); -// VisitReturnTypeAttributes(templateDefinition.Attributes, data); -// if (templateDefinition.Bases.Count == 1) { -// TrackedVisit(templateDefinition.Bases[0], data); -// } else { -// outputFormatter.PrintToken(Tokens.OpenCurlyBrace); -// AppendCommaSeparatedList(templateDefinition.Bases); -// outputFormatter.PrintToken(Tokens.CloseCurlyBrace); -// } -// } -// return null; -// } -// -// public override object TrackedVisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data) -// { -// VisitAttributes(delegateDeclaration.Attributes, data); -// -// outputFormatter.Indent(); -// OutputModifier(delegateDeclaration.Modifier, true, false); -// outputFormatter.PrintToken(Tokens.Delegate); -// outputFormatter.Space(); -// -// bool isFunction = (delegateDeclaration.ReturnType.Type != "System.Void"); -// if (isFunction) { -// outputFormatter.PrintToken(Tokens.Function); -// outputFormatter.Space(); -// } else { -// outputFormatter.PrintToken(Tokens.Sub); -// outputFormatter.Space(); -// } -// outputFormatter.PrintIdentifier(delegateDeclaration.Name); -// -// PrintTemplates(delegateDeclaration.Templates); -// -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(delegateDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// if (isFunction) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// VisitReturnTypeAttributes(delegateDeclaration.Attributes, data); -// TrackedVisit(delegateDeclaration.ReturnType, data); -// } -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitOptionDeclaration(OptionDeclaration optionDeclaration, object data) -// { -// outputFormatter.PrintToken(Tokens.Option); -// outputFormatter.Space(); -// switch (optionDeclaration.OptionType) { -// case OptionType.Strict: -// outputFormatter.PrintToken(Tokens.Strict); -// outputFormatter.Space(); -// outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off); -// break; -// case OptionType.Explicit: -// outputFormatter.PrintToken(Tokens.Explicit); -// outputFormatter.Space(); -// outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off); -// break; -// case OptionType.Infer: -// outputFormatter.PrintToken(Tokens.Infer); -// outputFormatter.Space(); -// outputFormatter.PrintToken(optionDeclaration.OptionValue ? Tokens.On : Tokens.Off); -// break; -// case OptionType.CompareBinary: -// outputFormatter.PrintToken(Tokens.Compare); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Binary); -// break; -// case OptionType.CompareText: -// outputFormatter.PrintToken(Tokens.Compare); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Text); -// break; -// } -// outputFormatter.NewLine(); -// return null; -// } -// #endregion -// -// #region Type level -// TypeReference currentVariableType; -// public override object TrackedVisitFieldDeclaration(FieldDeclaration fieldDeclaration, object data) -// { -// -// VisitAttributes(fieldDeclaration.Attributes, data); -// outputFormatter.Indent(); -// if (fieldDeclaration.Modifier == Modifiers.None) { -// outputFormatter.PrintToken(Tokens.Private); -// outputFormatter.Space(); -// } else { -// OutputModifier(fieldDeclaration.Modifier, false, true); -// } -// currentVariableType = fieldDeclaration.TypeReference; -// AppendCommaSeparatedList(fieldDeclaration.Fields); -// currentVariableType = null; -// -// outputFormatter.NewLine(); -// -// return null; -// } -// -// public override object TrackedVisitVariableDeclaration(VariableDeclaration variableDeclaration, object data) -// { -// outputFormatter.PrintIdentifier(variableDeclaration.Name); -// -// TypeReference varType = currentVariableType; -// if (varType != null && varType.IsNull) -// varType = null; -// if (varType == null && !variableDeclaration.TypeReference.IsNull) -// varType = variableDeclaration.TypeReference; -// -// if (varType != null) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// ObjectCreateExpression init = variableDeclaration.Initializer as ObjectCreateExpression; -// if (init != null && TypeReference.AreEqualReferences(init.CreateType, varType)) { -// TrackedVisit(variableDeclaration.Initializer, data); -// return null; -// } else { -// TrackedVisit(varType, data); -// } -// } -// -// if (!variableDeclaration.Initializer.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(variableDeclaration.Initializer, data); -// } -// return null; -// } -// -// public override object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data) -// { -// VisitAttributes(propertyDeclaration.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(propertyDeclaration.Modifier); -// -// if ((propertyDeclaration.Modifier & (Modifiers.ReadOnly | Modifiers.WriteOnly)) == Modifiers.None) { -// if (propertyDeclaration.IsReadOnly) { -// outputFormatter.PrintToken(Tokens.ReadOnly); -// outputFormatter.Space(); -// } else if (propertyDeclaration.IsWriteOnly) { -// outputFormatter.PrintToken(Tokens.WriteOnly); -// outputFormatter.Space(); -// } -// } -// -// outputFormatter.PrintToken(Tokens.Property); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(propertyDeclaration.Name); -// -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(propertyDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// if (!propertyDeclaration.TypeReference.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// -// VisitReturnTypeAttributes(propertyDeclaration.Attributes, data); -// -// ObjectCreateExpression init = propertyDeclaration.Initializer as ObjectCreateExpression; -// if (init != null && TypeReference.AreEqualReferences(init.CreateType, propertyDeclaration.TypeReference)) { -// TrackedVisit(propertyDeclaration.Initializer, data); -// } else { -// TrackedVisit(propertyDeclaration.TypeReference, data); -// } -// } -// -// PrintInterfaceImplementations(propertyDeclaration.InterfaceImplementations); -// -// if (!propertyDeclaration.Initializer.IsNull && !(propertyDeclaration.Initializer is ObjectCreateExpression)) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(propertyDeclaration.Initializer, data); -// } -// -// outputFormatter.NewLine(); -// -// if (!IsAbstract(propertyDeclaration) && (propertyDeclaration.GetRegion.Block != NullBlockStatement.Instance || propertyDeclaration.SetRegion.Block != NullBlockStatement.Instance)) { -// outputFormatter.IsInMemberBody = true; -// ++outputFormatter.IndentationLevel; -// exitTokenStack.Push(Tokens.Property); -// TrackedVisit(propertyDeclaration.GetRegion, data); -// TrackedVisit(propertyDeclaration.SetRegion, data); -// exitTokenStack.Pop(); -// --outputFormatter.IndentationLevel; -// outputFormatter.IsInMemberBody = false; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Property); -// outputFormatter.NewLine(); -// } -// -// return null; -// } -// -// public override object TrackedVisitPropertyGetRegion(PropertyGetRegion propertyGetRegion, object data) -// { -// VisitAttributes(propertyGetRegion.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(propertyGetRegion.Modifier); -// outputFormatter.PrintToken(Tokens.Get); -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// TrackedVisit(propertyGetRegion.Block, data); -// --outputFormatter.IndentationLevel; -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Get); -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitPropertySetRegion(PropertySetRegion propertySetRegion, object data) -// { -// VisitAttributes(propertySetRegion.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(propertySetRegion.Modifier); -// outputFormatter.PrintToken(Tokens.Set); -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// TrackedVisit(propertySetRegion.Block, data); -// --outputFormatter.IndentationLevel; -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Set); -// outputFormatter.NewLine(); -// return null; -// } -// -// TypeReference currentEventType = null; -// public override object TrackedVisitEventDeclaration(EventDeclaration eventDeclaration, object data) -// { -// bool customEvent = eventDeclaration.HasAddRegion || eventDeclaration.HasRemoveRegion; -// -// VisitAttributes(eventDeclaration.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(eventDeclaration.Modifier); -// if (customEvent) { -// outputFormatter.PrintText("Custom"); -// outputFormatter.Space(); -// } -// -// outputFormatter.PrintToken(Tokens.Event); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(eventDeclaration.Name); -// -// if (eventDeclaration.Parameters.Count > 0) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// this.AppendCommaSeparatedList(eventDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// if (!eventDeclaration.TypeReference.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// VisitReturnTypeAttributes(eventDeclaration.Attributes, data); -// TrackedVisit(eventDeclaration.TypeReference, data); -// } -// -// PrintInterfaceImplementations(eventDeclaration.InterfaceImplementations); -// -// if (!eventDeclaration.Initializer.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(eventDeclaration.Initializer, data); -// } -// -// outputFormatter.NewLine(); -// -// if (customEvent) { -// ++outputFormatter.IndentationLevel; -// currentEventType = eventDeclaration.TypeReference; -// exitTokenStack.Push(Tokens.Sub); -// TrackedVisit(eventDeclaration.AddRegion, data); -// TrackedVisit(eventDeclaration.RemoveRegion, data); -// exitTokenStack.Pop(); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Event); -// outputFormatter.NewLine(); -// } -// return null; -// } -// -// void PrintInterfaceImplementations(IList list) -// { -// if (list == null || list.Count == 0) -// return; -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Implements); -// for (int i = 0; i < list.Count; i++) { -// if (i > 0) -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(list[i].InterfaceType, null); -// outputFormatter.PrintToken(Tokens.Dot); -// outputFormatter.PrintIdentifier(list[i].MemberName); -// } -// } -// -// public override object TrackedVisitEventAddRegion(EventAddRegion eventAddRegion, object data) -// { -// VisitAttributes(eventAddRegion.Attributes, data); -// outputFormatter.Indent(); -// outputFormatter.PrintText("AddHandler("); -// if (eventAddRegion.Parameters.Count == 0) { -// outputFormatter.PrintToken(Tokens.ByVal); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier("value"); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// TrackedVisit(currentEventType, data); -// } else { -// this.AppendCommaSeparatedList(eventAddRegion.Parameters); -// } -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// TrackedVisit(eventAddRegion.Block, data); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintText("AddHandler"); -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitEventRemoveRegion(EventRemoveRegion eventRemoveRegion, object data) -// { -// VisitAttributes(eventRemoveRegion.Attributes, data); -// outputFormatter.Indent(); -// outputFormatter.PrintText("RemoveHandler"); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// if (eventRemoveRegion.Parameters.Count == 0) { -// outputFormatter.PrintToken(Tokens.ByVal); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier("value"); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// TrackedVisit(currentEventType, data); -// } else { -// this.AppendCommaSeparatedList(eventRemoveRegion.Parameters); -// } -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// TrackedVisit(eventRemoveRegion.Block, data); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintText("RemoveHandler"); -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitEventRaiseRegion(EventRaiseRegion eventRaiseRegion, object data) -// { -// VisitAttributes(eventRaiseRegion.Attributes, data); -// outputFormatter.Indent(); -// outputFormatter.PrintText("RaiseEvent"); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// if (eventRaiseRegion.Parameters.Count == 0) { -// outputFormatter.PrintToken(Tokens.ByVal); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier("value"); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// TrackedVisit(currentEventType, data); -// } else { -// this.AppendCommaSeparatedList(eventRaiseRegion.Parameters); -// } -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// TrackedVisit(eventRaiseRegion.Block, data); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintText("RaiseEvent"); -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitParameterDeclarationExpression(ParameterDeclarationExpression parameterDeclarationExpression, object data) -// { -// printAttributeSectionInline = true; -// VisitAttributes(parameterDeclarationExpression.Attributes, data); -// printAttributeSectionInline = false; -// OutputModifier(parameterDeclarationExpression.ParamModifier); -// outputFormatter.PrintIdentifier(parameterDeclarationExpression.ParameterName); -// if (!parameterDeclarationExpression.TypeReference.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// VisitReturnTypeAttributes(parameterDeclarationExpression.Attributes, data); -// TrackedVisit(parameterDeclarationExpression.TypeReference, data); -// } -// if (!parameterDeclarationExpression.DefaultValue.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(parameterDeclarationExpression.DefaultValue, data); -// } -// return null; -// } -// -// public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data) -// { -// VisitAttributes(methodDeclaration.Attributes, data); -// if (methodDeclaration.IsExtensionMethod) { -// outputFormatter.Indent(); -// outputFormatter.PrintText(" _"); -// outputFormatter.NewLine(); -// } -// outputFormatter.Indent(); -// OutputModifier(methodDeclaration.Modifier); -// -// bool isSub = methodDeclaration.TypeReference.IsNull || -// methodDeclaration.TypeReference.Type == "System.Void"; -// -// if (isSub) { -// outputFormatter.PrintToken(Tokens.Sub); -// } else { -// outputFormatter.PrintToken(Tokens.Function); -// } -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(methodDeclaration.Name); -// -// PrintTemplates(methodDeclaration.Templates); -// -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(methodDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// if (!isSub) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// VisitReturnTypeAttributes(methodDeclaration.Attributes, data); -// TrackedVisit(methodDeclaration.TypeReference, data); -// } -// -// PrintInterfaceImplementations(methodDeclaration.InterfaceImplementations); -// -// if (methodDeclaration.HandlesClause.Count > 0) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Handles); -// for (int i = 0; i < methodDeclaration.HandlesClause.Count; i++) { -// if (i > 0) -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// outputFormatter.PrintText(methodDeclaration.HandlesClause[i]); -// } -// } -// -// outputFormatter.NewLine(); -// -// if (!IsAbstract(methodDeclaration)) { -// outputFormatter.IsInMemberBody = true; -// BeginVisit(methodDeclaration.Body); -// ++outputFormatter.IndentationLevel; -// exitTokenStack.Push(isSub ? Tokens.Sub : Tokens.Function); -// // we're doing the tracking manually using BeginVisit/EndVisit, so call Tracked... directly -// this.TrackedVisitBlockStatement(methodDeclaration.Body, data); -// exitTokenStack.Pop(); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// if (isSub) { -// outputFormatter.PrintToken(Tokens.Sub); -// } else { -// outputFormatter.PrintToken(Tokens.Function); -// } -// outputFormatter.NewLine(); -// EndVisit(methodDeclaration.Body); -// outputFormatter.IsInMemberBody = false; -// } -// return null; -// } -// -// public override object TrackedVisitInterfaceImplementation(InterfaceImplementation interfaceImplementation, object data) -// { -// throw new InvalidOperationException(); -// } -// -// bool IsAbstract(AttributedNode node) -// { -// if ((node.Modifier & Modifiers.Abstract) == Modifiers.Abstract) -// return true; -// return currentType != null && currentType.Type == ClassType.Interface; -// } -// -// public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) -// { -// VisitAttributes(constructorDeclaration.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(constructorDeclaration.Modifier); -// outputFormatter.PrintToken(Tokens.Sub); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.New); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(constructorDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// outputFormatter.NewLine(); -// -// outputFormatter.IsInMemberBody = true; -// ++outputFormatter.IndentationLevel; -// exitTokenStack.Push(Tokens.Sub); -// -// TrackedVisit(constructorDeclaration.ConstructorInitializer, data); -// -// TrackedVisit(constructorDeclaration.Body, data); -// exitTokenStack.Pop(); -// --outputFormatter.IndentationLevel; -// outputFormatter.IsInMemberBody = false; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Sub); -// outputFormatter.NewLine(); -// -// return null; -// } -// -// public override object TrackedVisitConstructorInitializer(ConstructorInitializer constructorInitializer, object data) -// { -// outputFormatter.Indent(); -// if (constructorInitializer.ConstructorInitializerType == ConstructorInitializerType.This) { -// outputFormatter.PrintToken(Tokens.Me); -// } else { -// outputFormatter.PrintToken(Tokens.MyBase); -// } -// outputFormatter.PrintToken(Tokens.Dot); -// outputFormatter.PrintToken(Tokens.New); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(constructorInitializer.Arguments); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// outputFormatter.NewLine(); -// return null; -// } -// -// public override object TrackedVisitOperatorDeclaration(OperatorDeclaration operatorDeclaration, object data) -// { -// VisitAttributes(operatorDeclaration.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(operatorDeclaration.Modifier); -// -// if (operatorDeclaration.IsConversionOperator) { -// if (operatorDeclaration.ConversionType == ConversionType.Implicit) { -// outputFormatter.PrintToken(Tokens.Widening); -// } else { -// outputFormatter.PrintToken(Tokens.Narrowing); -// } -// outputFormatter.Space(); -// } -// -// outputFormatter.PrintToken(Tokens.Operator); -// outputFormatter.Space(); -// -// int op = -1; -// -// switch(operatorDeclaration.OverloadableOperator) -// { -// case OverloadableOperatorType.Add: -// case OverloadableOperatorType.UnaryPlus: -// op = Tokens.Plus; -// break; -// case OverloadableOperatorType.UnaryMinus: -// case OverloadableOperatorType.Subtract: -// op = Tokens.Minus; -// break; -// case OverloadableOperatorType.Multiply: -// op = Tokens.Times; -// break; -// case OverloadableOperatorType.Divide: -// op = Tokens.Div; -// break; -// case OverloadableOperatorType.Modulus: -// op = Tokens.Mod; -// break; -// case OverloadableOperatorType.Concat: -// op = Tokens.ConcatString; -// break; -// case OverloadableOperatorType.Not: -// op = Tokens.Not; -// break; -// case OverloadableOperatorType.BitNot: -// op = Tokens.Not; -// break; -// case OverloadableOperatorType.BitwiseAnd: -// op = Tokens.And; -// break; -// case OverloadableOperatorType.BitwiseOr: -// op = Tokens.Or; -// break; -// case OverloadableOperatorType.ExclusiveOr: -// op = Tokens.Xor; -// break; -// case OverloadableOperatorType.ShiftLeft: -// op = Tokens.ShiftLeft; -// break; -// case OverloadableOperatorType.ShiftRight: -// op = Tokens.ShiftRight; -// break; -// case OverloadableOperatorType.GreaterThan: -// op = Tokens.GreaterThan; -// break; -// case OverloadableOperatorType.GreaterThanOrEqual: -// op = Tokens.GreaterEqual; -// break; -// case OverloadableOperatorType.Equality: -// op = Tokens.Assign; -// break; -// case OverloadableOperatorType.InEquality: -// op = Tokens.NotEqual; -// break; -// case OverloadableOperatorType.LessThan: -// op = Tokens.LessThan; -// break; -// case OverloadableOperatorType.LessThanOrEqual: -// op = Tokens.LessEqual; -// break; -// case OverloadableOperatorType.Increment: -// Error("Increment operator is not supported in Visual Basic", operatorDeclaration.StartLocation); -// break; -// case OverloadableOperatorType.Decrement: -// Error("Decrement operator is not supported in Visual Basic", operatorDeclaration.StartLocation); -// break; -// case OverloadableOperatorType.IsTrue: -// outputFormatter.PrintText("IsTrue"); -// break; -// case OverloadableOperatorType.IsFalse: -// outputFormatter.PrintText("IsFalse"); -// break; -// case OverloadableOperatorType.Like: -// op = Tokens.Like; -// break; -// case OverloadableOperatorType.Power: -// op = Tokens.Power; -// break; -// case OverloadableOperatorType.CType: -// op = Tokens.CType; -// break; -// case OverloadableOperatorType.DivideInteger: -// op = Tokens.DivInteger; -// break; -// } -// -// -// -// if (operatorDeclaration.IsConversionOperator) { -// outputFormatter.PrintToken(Tokens.CType); -// } else { -// if(op != -1) outputFormatter.PrintToken(op); -// } -// -// PrintTemplates(operatorDeclaration.Templates); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(operatorDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// if (!operatorDeclaration.TypeReference.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// VisitReturnTypeAttributes(operatorDeclaration.Attributes, data); -// TrackedVisit(operatorDeclaration.TypeReference, data); -// } -// -// outputFormatter.NewLine(); -// -// ++outputFormatter.IndentationLevel; -// TrackedVisit(operatorDeclaration.Body, data); -// --outputFormatter.IndentationLevel; -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Operator); -// outputFormatter.NewLine(); -// -// return null; -// } -// -// public override object TrackedVisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data) -// { -// VisitAttributes(declareDeclaration.Attributes, data); -// outputFormatter.Indent(); -// OutputModifier(declareDeclaration.Modifier); -// outputFormatter.PrintToken(Tokens.Declare); -// outputFormatter.Space(); -// -// switch (declareDeclaration.Charset) { -// case CharsetModifier.Auto: -// outputFormatter.PrintToken(Tokens.Auto); -// outputFormatter.Space(); -// break; -// case CharsetModifier.Unicode: -// outputFormatter.PrintToken(Tokens.Unicode); -// outputFormatter.Space(); -// break; -// case CharsetModifier.Ansi: -// outputFormatter.PrintToken(Tokens.Ansi); -// outputFormatter.Space(); -// break; -// } -// -// bool isVoid = declareDeclaration.TypeReference.IsNull || declareDeclaration.TypeReference.Type == "System.Void"; -// if (isVoid) { -// outputFormatter.PrintToken(Tokens.Sub); -// } else { -// outputFormatter.PrintToken(Tokens.Function); -// } -// outputFormatter.Space(); -// -// outputFormatter.PrintIdentifier(declareDeclaration.Name); -// -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Lib); -// outputFormatter.Space(); -// outputFormatter.PrintText(ConvertString(declareDeclaration.Library)); -// outputFormatter.Space(); -// -// if (declareDeclaration.Alias.Length > 0) { -// outputFormatter.PrintToken(Tokens.Alias); -// outputFormatter.Space(); -// outputFormatter.PrintText(ConvertString(declareDeclaration.Alias)); -// outputFormatter.Space(); -// } -// -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(declareDeclaration.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// if (!isVoid) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// VisitReturnTypeAttributes(declareDeclaration.Attributes, data); -// TrackedVisit(declareDeclaration.TypeReference, data); -// } -// -// outputFormatter.NewLine(); -// -// return null; -// } -// #endregion -// -// #region Statements -// public override object TrackedVisitBlockStatement(BlockStatement blockStatement, object data) -// { -// if (blockStatement.Parent is BlockStatement) { -// outputFormatter.Indent(); -// outputFormatter.PrintText("If True Then"); -// outputFormatter.NewLine(); -// outputFormatter.IndentationLevel += 1; -// } -// VisitStatementList(blockStatement.Children); -// if (blockStatement.Parent is BlockStatement) { -// outputFormatter.IndentationLevel -= 1; -// outputFormatter.Indent(); -// outputFormatter.PrintText("End If"); -// outputFormatter.NewLine(); -// } -// return null; -// } -// -// void PrintIndentedBlock(Statement stmt) -// { -// outputFormatter.IndentationLevel += 1; -// if (stmt is BlockStatement) { -// TrackedVisit(stmt, null); -// } else { -// outputFormatter.Indent(); -// TrackedVisit(stmt, null); -// outputFormatter.NewLine(); -// } -// outputFormatter.IndentationLevel -= 1; -// } -// -// void PrintIndentedBlock(IEnumerable statements) -// { -// outputFormatter.IndentationLevel += 1; -// VisitStatementList(statements); -// outputFormatter.IndentationLevel -= 1; -// } -// -// void VisitStatementList(IEnumerable statements) -// { -// foreach (Statement stmt in statements) { -// if (stmt is BlockStatement) { -// TrackedVisit(stmt, null); -// } else { -// outputFormatter.Indent(); -// TrackedVisit(stmt, null); -// outputFormatter.NewLine(); -// } -// } -// } -// -// public override object TrackedVisitAddHandlerStatement(AddHandlerStatement addHandlerStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.AddHandler); -// outputFormatter.Space(); -// TrackedVisit(addHandlerStatement.EventExpression, data); -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(addHandlerStatement.HandlerExpression, data); -// return null; -// } -// -// public override object TrackedVisitRemoveHandlerStatement(RemoveHandlerStatement removeHandlerStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.RemoveHandler); -// outputFormatter.Space(); -// TrackedVisit(removeHandlerStatement.EventExpression, data); -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(removeHandlerStatement.HandlerExpression, data); -// return null; -// } -// -// public override object TrackedVisitRaiseEventStatement(RaiseEventStatement raiseEventStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.RaiseEvent); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(raiseEventStatement.EventName); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(raiseEventStatement.Arguments); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// public override object TrackedVisitEraseStatement(EraseStatement eraseStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Erase); -// outputFormatter.Space(); -// AppendCommaSeparatedList(eraseStatement.Expressions); -// return null; -// } -// -// public override object TrackedVisitErrorStatement(ErrorStatement errorStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Error); -// outputFormatter.Space(); -// TrackedVisit(errorStatement.Expression, data); -// return null; -// } -// -// public override object TrackedVisitOnErrorStatement(OnErrorStatement onErrorStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.On); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Error); -// outputFormatter.Space(); -// TrackedVisit(onErrorStatement.EmbeddedStatement, data); -// return null; -// } -// -// public override object TrackedVisitReDimStatement(ReDimStatement reDimStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.ReDim); -// outputFormatter.Space(); -// if (reDimStatement.IsPreserve) { -// outputFormatter.PrintToken(Tokens.Preserve); -// outputFormatter.Space(); -// } -// -// AppendCommaSeparatedList(reDimStatement.ReDimClauses); -// return null; -// } -// -// public override object TrackedVisitExpressionStatement(ExpressionStatement expressionStatement, object data) -// { -// TrackedVisit(expressionStatement.Expression, data); -// return null; -// } -// -// public override object TrackedVisitLocalVariableDeclaration(LocalVariableDeclaration localVariableDeclaration, object data) -// { -// if (localVariableDeclaration.Modifier != Modifiers.None) { -// OutputModifier(localVariableDeclaration.Modifier & ~Modifiers.Dim); -// } -// if (!isUsingResourceAcquisition) { -// if ((localVariableDeclaration.Modifier & Modifiers.Const) == 0) { -// outputFormatter.PrintToken(Tokens.Dim); -// } -// outputFormatter.Space(); -// } -// currentVariableType = localVariableDeclaration.TypeReference; -// -// AppendCommaSeparatedList(localVariableDeclaration.Variables); -// currentVariableType = null; -// -// return null; -// } -// -// public override object TrackedVisitReturnStatement(ReturnStatement returnStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Return); -// if (!returnStatement.Expression.IsNull) { -// outputFormatter.Space(); -// TrackedVisit(returnStatement.Expression, data); -// } -// return null; -// } -// -// public override object TrackedVisitIfElseStatement(IfElseStatement ifElseStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.If); -// outputFormatter.Space(); -// TrackedVisit(ifElseStatement.Condition, data); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Then); -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(ifElseStatement.TrueStatement); -// -// foreach (ElseIfSection elseIfSection in ifElseStatement.ElseIfSections) { -// TrackedVisit(elseIfSection, data); -// } -// -// if (ifElseStatement.HasElseStatements) { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Else); -// outputFormatter.NewLine(); -// PrintIndentedBlock(ifElseStatement.FalseStatement); -// } -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.If); -// return null; -// } -// -// public override object TrackedVisitElseIfSection(ElseIfSection elseIfSection, object data) -// { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.ElseIf); -// outputFormatter.Space(); -// TrackedVisit(elseIfSection.Condition, data); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Then); -// outputFormatter.NewLine(); -// PrintIndentedBlock(elseIfSection.EmbeddedStatement); -// return null; -// } -// -// public override object TrackedVisitLabelStatement(LabelStatement labelStatement, object data) -// { -// outputFormatter.PrintIdentifier(labelStatement.Label); -// outputFormatter.PrintToken(Tokens.Colon); -// return null; -// } -// -// public override object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.GoTo); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(gotoStatement.Label); -// return null; -// } -// -// public override object TrackedVisitSwitchStatement(SwitchStatement switchStatement, object data) -// { -// exitTokenStack.Push(Tokens.Select); -// outputFormatter.PrintToken(Tokens.Select); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Case); -// outputFormatter.Space(); -// TrackedVisit(switchStatement.SwitchExpression, data); -// outputFormatter.NewLine(); -// ++outputFormatter.IndentationLevel; -// foreach (SwitchSection section in switchStatement.SwitchSections) { -// TrackedVisit(section, data); -// } -// --outputFormatter.IndentationLevel; -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Select); -// exitTokenStack.Pop(); -// return null; -// } -// -// public override object TrackedVisitSwitchSection(SwitchSection switchSection, object data) -// { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Case); -// outputFormatter.Space(); -// this.AppendCommaSeparatedList(switchSection.SwitchLabels); -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(switchSection.Children); -// -// return null; -// } -// -// public override object TrackedVisitCaseLabel(CaseLabel caseLabel, object data) -// { -// if (caseLabel.IsDefault) { -// outputFormatter.PrintToken(Tokens.Else); -// } else { -// if (caseLabel.BinaryOperatorType != BinaryOperatorType.None) { -// switch (caseLabel.BinaryOperatorType) { -// case BinaryOperatorType.Equality: -// outputFormatter.PrintToken(Tokens.Assign); -// break; -// case BinaryOperatorType.InEquality: -// outputFormatter.PrintToken(Tokens.LessThan); -// outputFormatter.PrintToken(Tokens.GreaterThan); -// break; -// -// case BinaryOperatorType.GreaterThan: -// outputFormatter.PrintToken(Tokens.GreaterThan); -// break; -// case BinaryOperatorType.GreaterThanOrEqual: -// outputFormatter.PrintToken(Tokens.GreaterEqual); -// break; -// case BinaryOperatorType.LessThan: -// outputFormatter.PrintToken(Tokens.LessThan); -// break; -// case BinaryOperatorType.LessThanOrEqual: -// outputFormatter.PrintToken(Tokens.LessEqual); -// break; -// } -// outputFormatter.Space(); -// } -// -// TrackedVisit(caseLabel.Label, data); -// if (!caseLabel.ToExpression.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.To); -// outputFormatter.Space(); -// TrackedVisit(caseLabel.ToExpression, data); -// } -// } -// -// return null; -// } -// -// public override object TrackedVisitStopStatement(StopStatement stopStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Stop); -// return null; -// } -// -// public override object TrackedVisitResumeStatement(ResumeStatement resumeStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Resume); -// outputFormatter.Space(); -// if (resumeStatement.IsResumeNext) { -// outputFormatter.PrintToken(Tokens.Next); -// } else { -// outputFormatter.PrintIdentifier(resumeStatement.LabelName); -// } -// return null; -// } -// -// public override object TrackedVisitEndStatement(EndStatement endStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.End); -// return null; -// } -// -// public override object TrackedVisitContinueStatement(ContinueStatement continueStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Continue); -// outputFormatter.Space(); -// switch (continueStatement.ContinueType) { -// case ContinueType.Do: -// outputFormatter.PrintToken(Tokens.Do); -// break; -// case ContinueType.For: -// outputFormatter.PrintToken(Tokens.For); -// break; -// case ContinueType.While: -// outputFormatter.PrintToken(Tokens.While); -// break; -// default: -// outputFormatter.PrintToken(exitTokenStack.Peek()); -// break; -// } -// return null; -// } -// -// public override object TrackedVisitDoLoopStatement(DoLoopStatement doLoopStatement, object data) -// { -// if (doLoopStatement.ConditionPosition == ConditionPosition.None) { -// Error(String.Format("Unknown condition position for loop : {0}.", doLoopStatement), doLoopStatement.StartLocation); -// } -// -// if (doLoopStatement.ConditionPosition == ConditionPosition.Start) { -// switch (doLoopStatement.ConditionType) { -// case ConditionType.DoWhile: -// exitTokenStack.Push(Tokens.Do); -// outputFormatter.PrintToken(Tokens.Do); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.While); -// break; -// case ConditionType.While: -// exitTokenStack.Push(Tokens.While); -// outputFormatter.PrintToken(Tokens.While); -// break; -// case ConditionType.Until: -// exitTokenStack.Push(Tokens.Do); -// outputFormatter.PrintToken(Tokens.Do); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.While); -// break; -// default: -// throw new InvalidOperationException(); -// } -// outputFormatter.Space(); -// TrackedVisit(doLoopStatement.Condition, null); -// } else { -// exitTokenStack.Push(Tokens.Do); -// outputFormatter.PrintToken(Tokens.Do); -// } -// -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(doLoopStatement.EmbeddedStatement); -// -// outputFormatter.Indent(); -// if (doLoopStatement.ConditionPosition == ConditionPosition.Start && doLoopStatement.ConditionType == ConditionType.While) { -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.While); -// } else { -// outputFormatter.PrintToken(Tokens.Loop); -// } -// -// if (doLoopStatement.ConditionPosition == ConditionPosition.End && !doLoopStatement.Condition.IsNull) { -// outputFormatter.Space(); -// switch (doLoopStatement.ConditionType) { -// case ConditionType.While: -// case ConditionType.DoWhile: -// outputFormatter.PrintToken(Tokens.While); -// break; -// case ConditionType.Until: -// outputFormatter.PrintToken(Tokens.Until); -// break; -// } -// outputFormatter.Space(); -// TrackedVisit(doLoopStatement.Condition, null); -// } -// exitTokenStack.Pop(); -// return null; -// } -// -// public override object TrackedVisitForeachStatement(ForeachStatement foreachStatement, object data) -// { -// exitTokenStack.Push(Tokens.For); -// outputFormatter.PrintToken(Tokens.For); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Each); -// outputFormatter.Space(); -// -// // loop control variable -// outputFormatter.PrintIdentifier(foreachStatement.VariableName); -// if (!foreachStatement.TypeReference.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// TrackedVisit(foreachStatement.TypeReference, data); -// } -// -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.In); -// outputFormatter.Space(); -// -// TrackedVisit(foreachStatement.Expression, data); -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(foreachStatement.EmbeddedStatement); -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Next); -// if (!foreachStatement.NextExpression.IsNull) { -// outputFormatter.Space(); -// TrackedVisit(foreachStatement.NextExpression, data); -// } -// exitTokenStack.Pop(); -// return null; -// } -// -// public override object TrackedVisitLockStatement(LockStatement lockStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.SyncLock); -// outputFormatter.Space(); -// TrackedVisit(lockStatement.LockExpression, data); -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(lockStatement.EmbeddedStatement); -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.SyncLock); -// return null; -// } -// -// bool isUsingResourceAcquisition; -// -// public override object TrackedVisitUsingStatement(UsingStatement usingStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Using); -// outputFormatter.Space(); -// -// isUsingResourceAcquisition = true; -// TrackedVisit(usingStatement.ResourceAcquisition, data); -// isUsingResourceAcquisition = false; -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(usingStatement.EmbeddedStatement); -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Using); -// -// return null; -// } -// -// public override object TrackedVisitWithStatement(WithStatement withStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.With); -// outputFormatter.Space(); -// TrackedVisit(withStatement.Expression, data); -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(withStatement.Body); -// -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.With); -// return null; -// } -// -// public override object TrackedVisitTryCatchStatement(TryCatchStatement tryCatchStatement, object data) -// { -// exitTokenStack.Push(Tokens.Try); -// outputFormatter.PrintToken(Tokens.Try); -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(tryCatchStatement.StatementBlock); -// -// foreach (CatchClause catchClause in tryCatchStatement.CatchClauses) { -// TrackedVisit(catchClause, data); -// } -// -// if (!tryCatchStatement.FinallyBlock.IsNull) { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Finally); -// outputFormatter.NewLine(); -// PrintIndentedBlock(tryCatchStatement.FinallyBlock); -// } -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Try); -// exitTokenStack.Pop(); -// return null; -// } -// -// public override object TrackedVisitCatchClause(CatchClause catchClause, object data) -// { -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Catch); -// -// if (!catchClause.TypeReference.IsNull) { -// outputFormatter.Space(); -// if (catchClause.VariableName.Length > 0) { -// outputFormatter.PrintIdentifier(catchClause.VariableName); -// } else { -// outputFormatter.PrintIdentifier("generatedExceptionName"); -// } -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(catchClause.TypeReference.Type); -// } -// -// if (!catchClause.Condition.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.When); -// outputFormatter.Space(); -// TrackedVisit(catchClause.Condition, data); -// } -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(catchClause.StatementBlock); -// -// return null; -// } -// -// public override object TrackedVisitThrowStatement(ThrowStatement throwStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Throw); -// if (!throwStatement.Expression.IsNull) { -// outputFormatter.Space(); -// TrackedVisit(throwStatement.Expression, data); -// } -// return null; -// } -// -// public override object TrackedVisitExitStatement(ExitStatement exitStatement, object data) -// { -// outputFormatter.PrintToken(Tokens.Exit); -// if (exitStatement.ExitType != ExitType.None) { -// outputFormatter.Space(); -// switch (exitStatement.ExitType) { -// case ExitType.Sub: -// outputFormatter.PrintToken(Tokens.Sub); -// break; -// case ExitType.Function: -// outputFormatter.PrintToken(Tokens.Function); -// break; -// case ExitType.Property: -// outputFormatter.PrintToken(Tokens.Property); -// break; -// case ExitType.Do: -// outputFormatter.PrintToken(Tokens.Do); -// break; -// case ExitType.For: -// outputFormatter.PrintToken(Tokens.For); -// break; -// case ExitType.Try: -// outputFormatter.PrintToken(Tokens.Try); -// break; -// case ExitType.While: -// outputFormatter.PrintToken(Tokens.While); -// break; -// case ExitType.Select: -// outputFormatter.PrintToken(Tokens.Select); -// break; -// default: -// Error(String.Format("Unsupported exit type : {0}", exitStatement.ExitType), exitStatement.StartLocation); -// break; -// } -// } -// -// return null; -// } -// -// public override object TrackedVisitForNextStatement(ForNextStatement forNextStatement, object data) -// { -// exitTokenStack.Push(Tokens.For); -// outputFormatter.PrintToken(Tokens.For); -// outputFormatter.Space(); -// -// if (!forNextStatement.LoopVariableExpression.IsNull) { -// TrackedVisit(forNextStatement.LoopVariableExpression, data); -// } else { -// outputFormatter.PrintIdentifier(forNextStatement.VariableName); -// -// if (!forNextStatement.TypeReference.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// TrackedVisit(forNextStatement.TypeReference, data); -// } -// } -// -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// -// TrackedVisit(forNextStatement.Start, data); -// -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.To); -// outputFormatter.Space(); -// -// TrackedVisit(forNextStatement.End, data); -// -// if (!forNextStatement.Step.IsNull) { -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Step); -// outputFormatter.Space(); -// TrackedVisit(forNextStatement.Step, data); -// } -// outputFormatter.NewLine(); -// -// PrintIndentedBlock(forNextStatement.EmbeddedStatement); -// -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.Next); -// -// if (forNextStatement.NextExpressions.Count > 0) { -// outputFormatter.Space(); -// AppendCommaSeparatedList(forNextStatement.NextExpressions); -// } -// exitTokenStack.Pop(); -// return null; -// } -// #endregion -// -// #region Expressions -// -// public override object TrackedVisitClassReferenceExpression(ClassReferenceExpression classReferenceExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.MyClass); -// return null; -// } -// -// -// static string ConvertCharLiteral(char ch) -// { -// if (Char.IsControl(ch)) { -// string charName = GetCharName(ch); -// if (charName != null) -// return "ControlChars." + charName; -// else -// return "ChrW(" + ((int)ch).ToString() + ")"; -// } else if (ch == '"') { -// return "\"\"\"\"C"; -// } else { -// return "\"" + ch.ToString() + "\"C"; -// } -// } -// -// static string GetCharName(char ch) -// { -// switch (ch) { -// case '\b': -// return "Back"; -// case '\r': -// return "Cr"; -// case '\f': -// return "FormFeed"; -// case '\n': -// return "Lf"; -// case '\0': -// return "NullChar"; -// case '\t': -// return "Tab"; -// case '\v': -// return "VerticalTab"; -// default: -// return null; -// } -// } -// -// static string ConvertString(string str) -// { -// StringBuilder sb = new StringBuilder(); -// bool inString = false; -// foreach (char ch in str) { -// if (char.IsControl(ch)) { -// if (inString) { -// sb.Append('"'); -// inString = false; -// } -// if (sb.Length > 0) -// sb.Append(" & "); -// string charName = GetCharName(ch); -// if (charName != null) -// sb.Append("vb" + charName); -// else -// sb.Append("ChrW(" + ((int)ch) + ")"); -// } else { -// if (!inString) { -// if (sb.Length > 0) -// sb.Append(" & "); -// sb.Append('"'); -// inString = true; -// } -// if (ch == '"') { -// sb.Append("\"\""); -// } else { -// sb.Append(ch); -// } -// } -// } -// if (inString) -// sb.Append('"'); -// if (sb.Length == 0) -// return "\"\""; -// return sb.ToString(); -// } -// -// public override object TrackedVisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) -// { -// outputFormatter.PrintText(ToVBNetString(primitiveExpression)); -// return null; -// } -// -// internal static string ToVBNetString(PrimitiveExpression primitiveExpression) -// { -// object val = primitiveExpression.Value; -// if (val == null) { -// return "Nothing"; -// } -// if (val is bool) { -// if ((bool)primitiveExpression.Value) { -// return "True"; -// } else { -// return "False"; -// } -// } -// -// if (val is string) { -// return ConvertString((string)val); -// } -// -// if (val is char) { -// return ConvertCharLiteral((char)primitiveExpression.Value); -// } -// -// if (val is decimal) { -// return ((decimal)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "D"; -// } -// -// if (val is float) { -// return ((float)primitiveExpression.Value).ToString(NumberFormatInfo.InvariantInfo) + "F"; -// } -// -// if (val is double) { -// string text = ((double)val).ToString(NumberFormatInfo.InvariantInfo); -// if (text.IndexOf('.') < 0 && text.IndexOf('E') < 0) -// return text + ".0"; -// else -// return text; -// } -// -// if (val is IFormattable) { -// StringBuilder b = new StringBuilder(); -// if (primitiveExpression.LiteralFormat == LiteralFormat.HexadecimalNumber) { -// b.Append("&H"); -// b.Append(((IFormattable)val).ToString("x", NumberFormatInfo.InvariantInfo)); -// } else { -// b.Append(((IFormattable)val).ToString(null, NumberFormatInfo.InvariantInfo)); -// } -// if (val is ushort || val is uint || val is ulong) { -// b.Append('U'); -// if (val is uint) -// b.Append('I'); -// } -// if (val is long || val is ulong) -// b.Append('L'); -// if (val is short || val is ushort) -// b.Append('S'); -// return b.ToString(); -// } else { -// return val.ToString(); -// } -// } -// -// public override object TrackedVisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) -// { -// int op = 0; -// switch (binaryOperatorExpression.Op) { -// case BinaryOperatorType.Concat: -// op = Tokens.ConcatString; -// break; -// -// case BinaryOperatorType.Add: -// op = Tokens.Plus; -// break; -// -// case BinaryOperatorType.Subtract: -// op = Tokens.Minus; -// break; -// -// case BinaryOperatorType.Multiply: -// op = Tokens.Times; -// break; -// -// case BinaryOperatorType.Divide: -// op = Tokens.Div; -// break; -// -// case BinaryOperatorType.DivideInteger: -// op = Tokens.DivInteger; -// break; -// -// case BinaryOperatorType.Modulus: -// op = Tokens.Mod; -// break; -// -// case BinaryOperatorType.ShiftLeft: -// op = Tokens.ShiftLeft; -// break; -// -// case BinaryOperatorType.ShiftRight: -// op = Tokens.ShiftRight; -// break; -// -// case BinaryOperatorType.BitwiseAnd: -// op = Tokens.And; -// break; -// case BinaryOperatorType.BitwiseOr: -// op = Tokens.Or; -// break; -// case BinaryOperatorType.ExclusiveOr: -// op = Tokens.Xor; -// break; -// -// case BinaryOperatorType.LogicalAnd: -// op = Tokens.AndAlso; -// break; -// case BinaryOperatorType.LogicalOr: -// op = Tokens.OrElse; -// break; -// case BinaryOperatorType.ReferenceEquality: -// op = Tokens.Is; -// break; -// case BinaryOperatorType.ReferenceInequality: -// op = Tokens.IsNot; -// break; -// -// case BinaryOperatorType.Equality: -// op = Tokens.Assign; -// break; -// case BinaryOperatorType.GreaterThan: -// op = Tokens.GreaterThan; -// break; -// case BinaryOperatorType.GreaterThanOrEqual: -// op = Tokens.GreaterEqual; -// break; -// case BinaryOperatorType.InEquality: -// op = Tokens.NotEqual; -// break; -// case BinaryOperatorType.NullCoalescing: -// outputFormatter.PrintText("If("); -// TrackedVisit(binaryOperatorExpression.Left, data); -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(binaryOperatorExpression.Right, data); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// case BinaryOperatorType.DictionaryAccess: -// { -// PrimitiveExpression pright = binaryOperatorExpression.Right as PrimitiveExpression; -// TrackedVisit(binaryOperatorExpression.Left, data); -// if (pright != null && pright.Value is string) { -// outputFormatter.PrintText("!" + (string)pright.Value); -// } else { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(binaryOperatorExpression.Right, data); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// return null; -// } -// case BinaryOperatorType.LessThan: -// op = Tokens.LessThan; -// break; -// case BinaryOperatorType.LessThanOrEqual: -// op = Tokens.LessEqual; -// break; -// } -// -// -// BinaryOperatorExpression childBoe = binaryOperatorExpression.Left as BinaryOperatorExpression; -// bool requireParenthesis = childBoe != null && OperatorPrecedence.ComparePrecedenceVB(binaryOperatorExpression.Op, childBoe.Op) > 0; -// if (requireParenthesis) -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(binaryOperatorExpression.Left, data); -// if (requireParenthesis) -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// outputFormatter.Space(); -// outputFormatter.PrintToken(op); -// outputFormatter.Space(); -// -// childBoe = binaryOperatorExpression.Right as BinaryOperatorExpression; -// requireParenthesis = childBoe != null && OperatorPrecedence.ComparePrecedenceVB(binaryOperatorExpression.Op, childBoe.Op) >= 0; -// if (requireParenthesis) -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(binaryOperatorExpression.Right, data); -// if (requireParenthesis) -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// return null; -// } -// -// public override object TrackedVisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(parenthesizedExpression.Expression, data); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// public override object TrackedVisitInvocationExpression(InvocationExpression invocationExpression, object data) -// { -// TrackedVisit(invocationExpression.TargetObject, data); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(invocationExpression.Arguments); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// void PrintTypeArguments(List typeArguments) -// { -// if (typeArguments != null && typeArguments.Count > 0) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// outputFormatter.PrintToken(Tokens.Of); -// outputFormatter.Space(); -// AppendCommaSeparatedList(typeArguments); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// } -// -// public override object TrackedVisitIdentifierExpression(SimpleNameExpression identifierExpression, object data) -// { -// outputFormatter.PrintIdentifier(identifierExpression.Identifier); -// PrintTypeArguments(identifierExpression.TypeArguments); -// return null; -// } -// -// public override object TrackedVisitTypeReferenceExpression(TypeReferenceExpression typeReferenceExpression, object data) -// { -// TrackedVisit(typeReferenceExpression.TypeReference, data); -// return null; -// } -// -// public override object TrackedVisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) -// { -// switch (unaryOperatorExpression.Op) { -// case UnaryOperatorType.Not: -// case UnaryOperatorType.BitNot: -// outputFormatter.PrintToken(Tokens.Not); -// outputFormatter.Space(); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// return null; -// -// case UnaryOperatorType.Decrement: -// outputFormatter.PrintText("System.Threading.Interlocked.Decrement("); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText(")"); -// return null; -// -// case UnaryOperatorType.Increment: -// outputFormatter.PrintText("System.Threading.Interlocked.Increment("); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText(")"); -// return null; -// -// case UnaryOperatorType.Minus: -// outputFormatter.PrintToken(Tokens.Minus); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// return null; -// -// case UnaryOperatorType.Plus: -// outputFormatter.PrintToken(Tokens.Plus); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// return null; -// -// case UnaryOperatorType.PostDecrement: -// outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Decrement("); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText("),"); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText(" + 1)"); -// return null; -// -// case UnaryOperatorType.PostIncrement: -// outputFormatter.PrintText("System.Math.Max(System.Threading.Interlocked.Increment("); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText("),"); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText(" - 1)"); -// return null; -// -// case UnaryOperatorType.Dereference: -// outputFormatter.PrintToken(Tokens.Times); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// return null; -// case UnaryOperatorType.AddressOf: -// outputFormatter.PrintToken(Tokens.AddressOf); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// return null; -// default: -// Error("unknown unary operator: " + unaryOperatorExpression.Op.ToString(), unaryOperatorExpression.StartLocation); -// outputFormatter.PrintText(unaryOperatorExpression.Op.ToString()); -// outputFormatter.PrintText("("); -// TrackedVisit(unaryOperatorExpression.Expression, data); -// outputFormatter.PrintText(")"); -// return null; -// } -// } -// -// public override object TrackedVisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) -// { -// int op = 0; -// bool unsupportedOpAssignment = false; -// switch (assignmentExpression.Op) { -// case AssignmentOperatorType.Assign: -// op = Tokens.Assign; -// break; -// case AssignmentOperatorType.Add: -// op = Tokens.PlusAssign; -// break; -// case AssignmentOperatorType.Subtract: -// op = Tokens.MinusAssign; -// break; -// case AssignmentOperatorType.Multiply: -// op = Tokens.TimesAssign; -// break; -// case AssignmentOperatorType.Divide: -// op = Tokens.DivAssign; -// break; -// case AssignmentOperatorType.ShiftLeft: -// op = Tokens.ShiftLeftAssign; -// break; -// case AssignmentOperatorType.ShiftRight: -// op = Tokens.ShiftRightAssign; -// break; -// -// case AssignmentOperatorType.ExclusiveOr: -// op = Tokens.Xor; -// unsupportedOpAssignment = true; -// break; -// case AssignmentOperatorType.Modulus: -// op = Tokens.Mod; -// unsupportedOpAssignment = true; -// break; -// case AssignmentOperatorType.BitwiseAnd: -// op = Tokens.And; -// unsupportedOpAssignment = true; -// break; -// case AssignmentOperatorType.BitwiseOr: -// op = Tokens.Or; -// unsupportedOpAssignment = true; -// break; -// } -// -// TrackedVisit(assignmentExpression.Left, data); -// outputFormatter.Space(); -// -// if (unsupportedOpAssignment) { // left = left OP right -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(assignmentExpression.Left, data); -// outputFormatter.Space(); -// } -// -// outputFormatter.PrintToken(op); -// outputFormatter.Space(); -// TrackedVisit(assignmentExpression.Right, data); -// -// return null; -// } -// -// public override object TrackedVisitTypeOfExpression(TypeOfExpression typeOfExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.GetType); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(typeOfExpression.TypeReference, data); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// public override object TrackedVisitDefaultValueExpression(DefaultValueExpression defaultValueExpression, object data) -// { -// // assigning nothing to a generic type in VB compiles to a DefaultValueExpression -// outputFormatter.PrintToken(Tokens.Nothing); -// return null; -// } -// -// public override object TrackedVisitTypeOfIsExpression(TypeOfIsExpression typeOfIsExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.TypeOf); -// outputFormatter.Space(); -// TrackedVisit(typeOfIsExpression.Expression, data); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Is); -// outputFormatter.Space(); -// TrackedVisit(typeOfIsExpression.TypeReference, data); -// return null; -// } -// -// public override object TrackedVisitAddressOfExpression(AddressOfExpression addressOfExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.AddressOf); -// outputFormatter.Space(); -// TrackedVisit(addressOfExpression.Expression, data); -// return null; -// } -// -// public override object TrackedVisitCastExpression(CastExpression castExpression, object data) -// { -// if (castExpression.CastType == CastType.TryCast) { -// return PrintCast(Tokens.TryCast, castExpression); -// } -// if (castExpression.CastType == CastType.Cast || castExpression.CastTo.IsArrayType) { -// return PrintCast(Tokens.DirectCast, castExpression); -// } -// switch (castExpression.CastTo.Type) { -// case "System.Boolean": -// outputFormatter.PrintToken(Tokens.CBool); -// break; -// case "System.Byte": -// outputFormatter.PrintToken(Tokens.CByte); -// break; -// case "System.SByte": -// outputFormatter.PrintToken(Tokens.CSByte); -// break; -// case "System.Char": -// outputFormatter.PrintToken(Tokens.CChar); -// break; -// case "System.DateTime": -// outputFormatter.PrintToken(Tokens.CDate); -// break; -// case "System.Decimal": -// outputFormatter.PrintToken(Tokens.CDec); -// break; -// case "System.Double": -// outputFormatter.PrintToken(Tokens.CDbl); -// break; -// case "System.Int16": -// outputFormatter.PrintToken(Tokens.CShort); -// break; -// case "System.Int32": -// outputFormatter.PrintToken(Tokens.CInt); -// break; -// case "System.Int64": -// outputFormatter.PrintToken(Tokens.CLng); -// break; -// case "System.UInt16": -// outputFormatter.PrintToken(Tokens.CUShort); -// break; -// case "System.UInt32": -// outputFormatter.PrintToken(Tokens.CUInt); -// break; -// case "System.UInt64": -// outputFormatter.PrintToken(Tokens.CULng); -// break; -// case "System.Object": -// outputFormatter.PrintToken(Tokens.CObj); -// break; -// case "System.Single": -// outputFormatter.PrintToken(Tokens.CSng); -// break; -// case "System.String": -// outputFormatter.PrintToken(Tokens.CStr); -// break; -// default: -// return PrintCast(Tokens.CType, castExpression); -// } -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(castExpression.Expression, data); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// object PrintCast(int castToken, CastExpression castExpression) -// { -// outputFormatter.PrintToken(castToken); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(castExpression.Expression, null); -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(castExpression.CastTo, null); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// public override object TrackedVisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.Me); -// return null; -// } -// -// public override object TrackedVisitBaseReferenceExpression(BaseReferenceExpression baseReferenceExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.MyBase); -// return null; -// } -// -// public override object TrackedVisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.New); -// if (!objectCreateExpression.IsAnonymousType) { -// outputFormatter.Space(); -// TrackedVisit(objectCreateExpression.CreateType, data); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(objectCreateExpression.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// } -// CollectionInitializerExpression initializer = objectCreateExpression.ObjectInitializer; -// if (!initializer.IsNull) { -// outputFormatter.Space(); -// if (initializer.CreateExpressions.Any(ce => ce is MemberInitializerExpression)) -// outputFormatter.PrintToken(Tokens.With); -// else -// outputFormatter.PrintToken(Tokens.From); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.OpenCurlyBrace); -// outputFormatter.IndentationLevel++; -// for (int i = 0; i < initializer.CreateExpressions.Count; i++) { -// Expression expr = initializer.CreateExpressions[i]; -// if (i > 0) -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.PrintLineContinuation(); -// outputFormatter.Indent(); -// TrackedVisit(expr, data); -// } -// outputFormatter.IndentationLevel--; -// outputFormatter.PrintLineContinuation(); -// outputFormatter.Indent(); -// outputFormatter.PrintToken(Tokens.CloseCurlyBrace); -// } -// return null; -// } -// -// public override object TrackedVisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.New); -// outputFormatter.Space(); -// PrintTypeReferenceWithoutArray(arrayCreateExpression.CreateType); -// -// if (arrayCreateExpression.Arguments.Count > 0) { -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(arrayCreateExpression.Arguments); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 1); -// } else { -// PrintArrayRank(arrayCreateExpression.CreateType.RankSpecifier, 0); -// } -// -// outputFormatter.Space(); -// -// if (arrayCreateExpression.ArrayInitializer.IsNull) { -// outputFormatter.PrintToken(Tokens.OpenCurlyBrace); -// outputFormatter.PrintToken(Tokens.CloseCurlyBrace); -// } else { -// TrackedVisit(arrayCreateExpression.ArrayInitializer, data); -// } -// return null; -// } -// -// public override object TrackedVisitCollectionInitializerExpression(CollectionInitializerExpression arrayInitializerExpression, object data) -// { -// outputFormatter.PrintToken(Tokens.OpenCurlyBrace); -// this.AppendCommaSeparatedList(arrayInitializerExpression.CreateExpressions); -// outputFormatter.PrintToken(Tokens.CloseCurlyBrace); -// return null; -// } -// -// public override object TrackedVisitMemberInitializerExpression(MemberInitializerExpression memberInitializerExpression, object data) -// { -// if (memberInitializerExpression.IsKey) { -// outputFormatter.PrintToken(Tokens.Key); -// outputFormatter.Space(); -// } -// outputFormatter.PrintToken(Tokens.Dot); -// outputFormatter.PrintIdentifier(memberInitializerExpression.Name); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// TrackedVisit(memberInitializerExpression.Expression, data); -// return null; -// } -// -// public override object TrackedVisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) -// { -// TrackedVisit(memberReferenceExpression.TargetObject, data); -// outputFormatter.PrintToken(Tokens.Dot); -// if (string.Equals(memberReferenceExpression.MemberName, "New", StringComparison.OrdinalIgnoreCase) -// && (memberReferenceExpression.TargetObject is BaseReferenceExpression || memberReferenceExpression.TargetObject is ThisReferenceExpression || memberReferenceExpression.TargetObject is ClassReferenceExpression)) -// { -// outputFormatter.PrintToken(Tokens.New); -// } else { -// outputFormatter.PrintIdentifier(memberReferenceExpression.MemberName); -// } -// PrintTypeArguments(memberReferenceExpression.TypeArguments); -// return null; -// } -// -// public override object TrackedVisitDirectionExpression(DirectionExpression directionExpression, object data) -// { -// // VB does not need to specify the direction in method calls -// TrackedVisit(directionExpression.Expression, data); -// return null; -// } -// -// -// public override object TrackedVisitConditionalExpression(ConditionalExpression conditionalExpression, object data) -// { -// outputFormatter.PrintText("If"); -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// TrackedVisit(conditionalExpression.Condition, data); -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(conditionalExpression.TrueExpression, data); -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// TrackedVisit(conditionalExpression.FalseExpression, data); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// return null; -// } -// -// #endregion -// #endregion -// -// -// void OutputModifier(ParameterModifiers modifier) -// { -// if ((modifier & ParameterModifiers.Optional) == ParameterModifiers.Optional) { -// outputFormatter.PrintToken(Tokens.Optional); -// outputFormatter.Space(); -// } -// if ((modifier & ParameterModifiers.Ref) == ParameterModifiers.Ref -// || (modifier & ParameterModifiers.Out) == ParameterModifiers.Out) { -// outputFormatter.PrintToken(Tokens.ByRef); -// outputFormatter.Space(); -// } -// if ((modifier & ParameterModifiers.Params) == ParameterModifiers.Params) { -// outputFormatter.PrintToken(Tokens.ParamArray); -// outputFormatter.Space(); -// } -// if (prettyPrintOptions.OutputByValModifier && -// (modifier & (ParameterModifiers.Params | ParameterModifiers.Ref)) == ParameterModifiers.None) -// { -// outputFormatter.PrintToken(Tokens.ByVal); -// outputFormatter.Space(); -// } -// } -// -// void OutputModifier(Modifiers modifier) -// { -// OutputModifier(modifier, false, false); -// } -// -// void OutputModifier(Modifiers modifier, bool forTypeDecl, bool forFieldDecl) -// { -// if ((modifier & Modifiers.Public) == Modifiers.Public) { -// outputFormatter.PrintToken(Tokens.Public); -// outputFormatter.Space(); -// } else if ((modifier & Modifiers.Private) == Modifiers.Private) { -// outputFormatter.PrintToken(Tokens.Private); -// outputFormatter.Space(); -// } else if ((modifier & (Modifiers.Protected | Modifiers.Internal)) == (Modifiers.Protected | Modifiers.Internal)) { -// outputFormatter.PrintToken(Tokens.Protected); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Friend); -// outputFormatter.Space(); -// } else if ((modifier & Modifiers.Internal) == Modifiers.Internal) { -// outputFormatter.PrintToken(Tokens.Friend); -// outputFormatter.Space(); -// } else if ((modifier & Modifiers.Protected) == Modifiers.Protected) { -// outputFormatter.PrintToken(Tokens.Protected); -// outputFormatter.Space(); -// } -// -// if ((modifier & Modifiers.Static) == Modifiers.Static) { -// outputFormatter.PrintToken(Tokens.Shared); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Virtual) == Modifiers.Virtual) { -// outputFormatter.PrintToken(Tokens.Overridable); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Abstract) == Modifiers.Abstract) { -// if (forFieldDecl) -// outputFormatter.PrintToken(Tokens.Dim); -// else if (forTypeDecl) -// outputFormatter.PrintToken(Tokens.MustInherit); -// else -// outputFormatter.PrintToken(Tokens.MustOverride); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Dim) == Modifiers.Dim) { -// outputFormatter.PrintToken(Tokens.Dim); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Overloads) == Modifiers.Overloads) { -// outputFormatter.PrintToken(Tokens.Overloads); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Override) == Modifiers.Override) { -// outputFormatter.PrintToken(Tokens.Overrides); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.New) == Modifiers.New) { -// outputFormatter.PrintToken(Tokens.Shadows); -// outputFormatter.Space(); -// } -// -// if ((modifier & Modifiers.Sealed) == Modifiers.Sealed) { -// outputFormatter.PrintToken(forTypeDecl ? Tokens.NotInheritable : Tokens.NotOverridable); -// outputFormatter.Space(); -// } -// -// if ((modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly) { -// outputFormatter.PrintToken(Tokens.ReadOnly); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly) { -// outputFormatter.PrintToken(Tokens.WriteOnly); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Const) == Modifiers.Const) { -// outputFormatter.PrintToken(Tokens.Const); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.WithEvents) == Modifiers.WithEvents) { -// outputFormatter.PrintToken(Tokens.WithEvents); -// outputFormatter.Space(); -// } -// if ((modifier & Modifiers.Partial) == Modifiers.Partial) { -// outputFormatter.PrintToken(Tokens.Partial); -// outputFormatter.Space(); -// } -// -// if ((modifier & Modifiers.Extern) == Modifiers.Extern) { -// // not required in VB -// } -// -// if ((modifier & Modifiers.Default) == Modifiers.Default) { -// outputFormatter.PrintToken(Tokens.Default); -// outputFormatter.Space(); -// } -// -// if ((modifier & Modifiers.Volatile) == Modifiers.Volatile) { -// Error("'Volatile' modifier not convertable", Location.Empty); -// } -// -// if ((modifier & Modifiers.Unsafe) == Modifiers.Unsafe) { -// Error("'Unsafe' modifier not convertable", Location.Empty); -// } -// } -// -// public void AppendCommaSeparatedList(ICollection list) where T : class, INode -// { -// if (list != null) { -// int i = 0; -// foreach (T node in list) { -// TrackedVisit(node, null); -// if (i + 1 < list.Count) { -// outputFormatter.PrintToken(Tokens.Comma); -// outputFormatter.Space(); -// if ((i + 1) % 6 == 0) { -// outputFormatter.PrintLineContinuation(); -// outputFormatter.Indent(); -// outputFormatter.PrintText("\t"); -// } -// } -// i++; -// } -// } -// } -// -// void VisitAttributes(ICollection attributes, object data) -// { -// if (attributes == null) { -// return; -// } -// foreach (AttributeSection section in attributes) { -// if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) -// continue; -// TrackedVisit(section, data); -// } -// } -// -// void VisitReturnTypeAttributes(ICollection attributes, object data) -// { -// if (attributes == null) { -// return; -// } -// printAttributeSectionInline = true; -// foreach (AttributeSection section in attributes) { -// if (string.Equals(section.AttributeTarget, "return", StringComparison.OrdinalIgnoreCase)) { -// TrackedVisit(section, data); -// } -// } -// printAttributeSectionInline = false; -// } -// -// public override object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data) -// { -// bool isSub = !lambdaExpression.ReturnType.IsNull && -// lambdaExpression.ReturnType.Type == "System.Void" && lambdaExpression.ReturnType.IsKeyword; -// -// if (isSub) -// outputFormatter.PrintToken(Tokens.Sub); -// else -// outputFormatter.PrintToken(Tokens.Function); -// -// outputFormatter.PrintToken(Tokens.OpenParenthesis); -// AppendCommaSeparatedList(lambdaExpression.Parameters); -// outputFormatter.PrintToken(Tokens.CloseParenthesis); -// -// outputFormatter.Space(); -// -// if (!lambdaExpression.ExpressionBody.IsNull) { -// return lambdaExpression.ExpressionBody.AcceptVisitor(this, data); -// } else { -// if (!isSub && !lambdaExpression.ReturnType.IsNull) { -// outputFormatter.PrintToken(Tokens.As); -// outputFormatter.Space(); -// TrackedVisit(lambdaExpression.ReturnType, data); -// } -// -// if (lambdaExpression.StatementBody is BlockStatement) -// outputFormatter.NewLine(); -// -// TrackedVisit(lambdaExpression.StatementBody, data); -// -// if (lambdaExpression.StatementBody is BlockStatement) { -// outputFormatter.NewLine(); -// outputFormatter.PrintToken(Tokens.End); -// outputFormatter.Space(); -// if (isSub) -// outputFormatter.PrintToken(Tokens.Sub); -// else -// outputFormatter.PrintToken(Tokens.Function); -// } -// -// return null; -// } -// } -// -// public override object TrackedVisitQueryExpression(QueryExpression queryExpression, object data) -// { -// outputFormatter.IndentationLevel++; -// for (int i = 0; i < queryExpression.Clauses.Count; i++) { -// QueryExpressionClause clause = queryExpression.Clauses[i]; -// if (!clause.IsNull) { -// if (i != 0) { -// outputFormatter.PrintLineContinuation(); -// outputFormatter.Indent(); -// } -// clause.AcceptVisitor(this, null); -// } -// } -// outputFormatter.IndentationLevel--; -// return null; -// } -// -// void PrintClause(QueryExpressionClause clause) -// { -// -// } -// -// public override object TrackedVisitQueryExpressionFromClause(QueryExpressionFromClause fromClause, object data) -// { -// outputFormatter.PrintText("From"); -// outputFormatter.Space(); -// for (int i = 0; i < fromClause.Sources.Count; i++) { -// CollectionRangeVariable clause = fromClause.Sources[i]; -// outputFormatter.PrintIdentifier(clause.Identifier); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.In); -// outputFormatter.Space(); -// clause.Expression.AcceptVisitor(this, data); -// if (i < fromClause.Sources.Count - 1) -// outputFormatter.PrintToken(Tokens.Comma); -// } -// return null; -// } -// -// public override object TrackedVisitQueryExpressionJoinClause(QueryExpressionJoinClause joinClause, object data) -// { -// outputFormatter.PrintText("Join"); -// outputFormatter.Space(); -// CollectionRangeVariable clause = joinClause.Source; -// outputFormatter.PrintIdentifier(clause.Identifier); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.In); -// outputFormatter.Space(); -// clause.Expression.AcceptVisitor(this, data); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.On); -// outputFormatter.Space(); -// joinClause.OnExpression.AcceptVisitor(this, data); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// joinClause.EqualsExpression.AcceptVisitor(this, data); -// if (!string.IsNullOrEmpty(joinClause.IntoIdentifier)) { -// outputFormatter.Space(); -// outputFormatter.PrintText("Into"); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(joinClause.IntoIdentifier); -// } -// return null; -// } -// -//// void VisitQueryExpressionFromOrJoinClause(QueryExpressionFromOrJoinClause clause, object data) -//// { -//// outputFormatter.PrintIdentifier(clause.Identifier); -//// outputFormatter.Space(); -//// outputFormatter.PrintToken(Tokens.In); -//// outputFormatter.Space(); -//// clause.InExpression.AcceptVisitor(this, data); -//// } -// -// public override object TrackedVisitQueryExpressionLetClause(QueryExpressionLetClause letClause, object data) -// { -// outputFormatter.PrintToken(Tokens.Let); -// outputFormatter.Space(); -// outputFormatter.PrintIdentifier(letClause.Identifier); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.Assign); -// outputFormatter.Space(); -// return letClause.Expression.AcceptVisitor(this, data); -// } -// -// public override object TrackedVisitQueryExpressionGroupClause(QueryExpressionGroupClause groupClause, object data) -// { -// outputFormatter.PrintText("Group"); -// outputFormatter.Space(); -// groupClause.Projection.AcceptVisitor(this, data); -// outputFormatter.Space(); -// outputFormatter.PrintText("By"); -// outputFormatter.Space(); -// return groupClause.GroupBy.AcceptVisitor(this, data); -// } -// -// public override object TrackedVisitQueryExpressionOrderClause(QueryExpressionOrderClause queryExpressionOrderClause, object data) -// { -// outputFormatter.PrintText("Order By"); -// outputFormatter.Space(); -// AppendCommaSeparatedList(queryExpressionOrderClause.Orderings); -// return null; -// } -// -// public override object TrackedVisitQueryExpressionOrdering(QueryExpressionOrdering ordering, object data) -// { -// ordering.Criteria.AcceptVisitor(this, data); -// if (ordering.Direction == QueryExpressionOrderingDirection.Ascending) { -// outputFormatter.Space(); -// outputFormatter.PrintText("Ascending"); -// } else if (ordering.Direction == QueryExpressionOrderingDirection.Descending) { -// outputFormatter.Space(); -// outputFormatter.PrintText("Descending"); -// } -// return null; -// } -// -// public override object TrackedVisitQueryExpressionSelectVBClause(QueryExpressionSelectVBClause selectClause, object data) -// { -// outputFormatter.PrintToken(Tokens.Select); -// outputFormatter.Space(); -// foreach (ExpressionRangeVariable var in selectClause.Variables) { -// var.AcceptVisitor(this, data); -// } -// return null; -// } -// -// public override object TrackedVisitQueryExpressionWhereClause(QueryExpressionWhereClause whereClause, object data) -// { -// outputFormatter.Space(); -// outputFormatter.PrintText("Where"); -// outputFormatter.Space(); -// return whereClause.Condition.AcceptVisitor(this, data); -// } -// -// public override object TrackedVisitExternAliasDirective(ExternAliasDirective externAliasDirective, object data) -// { -// UnsupportedNode(externAliasDirective); -// return null; -// } -// -// public override object TrackedVisitXmlContentExpression(XmlContentExpression xmlContentExpression, object data) -// { -// switch (xmlContentExpression.Type) { -// case XmlContentType.Comment: -// outputFormatter.PrintText(""); -// break; -// case XmlContentType.Text: -// outputFormatter.PrintText(xmlContentExpression.Content); -// break; -// case XmlContentType.CData: -// outputFormatter.PrintText(""); -// break; -// case XmlContentType.ProcessingInstruction: -// outputFormatter.PrintText(""); -// break; -// default: -// throw new Exception("Invalid value for XmlContentType"); -// } -// return null; -// } -// -// public override object TrackedVisitXmlEmbeddedExpression(XmlEmbeddedExpression xmlEmbeddedExpression, object data) -// { -// outputFormatter.PrintText("<%="); -// outputFormatter.Space(); -// xmlEmbeddedExpression.InlineVBExpression.AcceptVisitor(this, data); -// outputFormatter.Space(); -// outputFormatter.PrintText("%>"); -// return null; -// } -// -// public override object TrackedVisitXmlAttributeExpression(XmlAttributeExpression xmlAttributeExpression, object data) -// { -// outputFormatter.PrintText(xmlAttributeExpression.Name); -// outputFormatter.PrintToken(Tokens.Assign); -// if (xmlAttributeExpression.IsLiteralValue) { -// if (xmlAttributeExpression.UseDoubleQuotes) -// outputFormatter.PrintText("\""); -// else -// outputFormatter.PrintText("'"); -// outputFormatter.PrintText(xmlAttributeExpression.LiteralValue); -// if (xmlAttributeExpression.UseDoubleQuotes) -// outputFormatter.PrintText("\""); -// else -// outputFormatter.PrintText("'"); -// } else -// xmlAttributeExpression.ExpressionValue.AcceptVisitor(this, data); -// return null; -// } -// -// public override object TrackedVisitXmlElementExpression(XmlElementExpression xmlElementExpression, object data) -// { -// outputFormatter.PrintText("<"); -// if (xmlElementExpression.NameIsExpression) { -// outputFormatter.PrintToken(Tokens.XmlStartInlineVB); -// outputFormatter.Space(); -// xmlElementExpression.NameExpression.AcceptVisitor(this, data); -// outputFormatter.Space(); -// outputFormatter.PrintToken(Tokens.XmlEndInlineVB); -// } else { -// outputFormatter.PrintText(xmlElementExpression.XmlName); -// } -// foreach (XmlExpression attribute in xmlElementExpression.Attributes) { -// outputFormatter.Space(); -// attribute.AcceptVisitor(this, data); -// } -// if (xmlElementExpression.Children.Any()) { -// outputFormatter.PrintText(">"); -// foreach (INode node in xmlElementExpression.Children) { -// node.AcceptVisitor(this, data); -// } -// outputFormatter.PrintText(""); -// } else { -// outputFormatter.Space(); -// outputFormatter.PrintText("/>"); -// } -// return null; -// } -// -// public override object TrackedVisitXmlMemberAccessExpression(XmlMemberAccessExpression xmlMemberAccessExpression, object data) -// { -// xmlMemberAccessExpression.TargetObject.AcceptVisitor(this, data); -// switch (xmlMemberAccessExpression.AxisType) { -// case XmlAxisType.Element: -// outputFormatter.PrintToken(Tokens.Dot); -// break; -// case XmlAxisType.Attribute: -// outputFormatter.PrintToken(Tokens.DotAt); -// break; -// case XmlAxisType.Descendents: -// outputFormatter.PrintToken(Tokens.TripleDot); -// break; -// default: -// throw new Exception("Invalid value for XmlAxisType"); -// } -// if (xmlMemberAccessExpression.IsXmlIdentifier) -// outputFormatter.PrintText("<" + xmlMemberAccessExpression.Identifier + ">"); -// else -// outputFormatter.PrintIdentifier(xmlMemberAccessExpression.Identifier); -// return null; -// } -// } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetPrettyPrintOptions.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetPrettyPrintOptions.cs deleted file mode 100644 index 8178afde0..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/PrettyPrinter/VBNet/VBNetPrettyPrintOptions.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.NRefactory.VB.PrettyPrinter -{ - /// - /// Description of VBNetPrettyPrintOptions. - /// - public class VBNetPrettyPrintOptions : AbstractPrettyPrintOptions - { - /// - /// Gets/Sets if the optional "ByVal" modifier should be written. - /// - public bool OutputByValModifier { get; set; } - } -} diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Properties/AssemblyInfo.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Properties/AssemblyInfo.cs deleted file mode 100644 index 98785222b..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -#region Using directives - -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -#endregion - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ICSharpCode.NRefactory.VB")] -[assembly: AssemblyDescription("VB syntax tree")] diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/VBParser.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/VBParser.cs deleted file mode 100644 index 5f62f952a..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/VBParser.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; - -using ICSharpCode.NRefactory.VB.Ast; -using ICSharpCode.NRefactory.VB.Parser; - -namespace ICSharpCode.NRefactory.VB -{ - public enum SnippetType - { - None, - CompilationUnit, - Expression, - Statements, - TypeMembers - } - - public class VBParser - { - bool hasErrors; - Errors errors; - - public CompilationUnit Parse(string content) - { - return Parse(new StringReader(content)); - } - - public CompilationUnit Parse(TextReader reader) - { - var parser = new ICSharpCode.NRefactory.VB.Parser.VBParser(new VBLexer(reader)); - parser.Parse(); - hasErrors = parser.Errors.Count > 0; - errors = parser.Errors; - return parser.CompilationUnit; - } - - public AstNode ParseSnippet(TextReader reader) - { - throw new NotImplementedException(); - } - - public bool HasErrors { - get { return hasErrors; } - } - - public Errors Errors { - get { return errors; } - } - } -} \ No newline at end of file diff --git a/NRefactory.VB/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs b/NRefactory.VB/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs deleted file mode 100644 index a38d17e23..000000000 --- a/NRefactory.VB/ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs +++ /dev/null @@ -1,2311 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under MIT X11 license (for details please see \doc\license.txt) - -using System; -using System.Collections.Generic; -using System.Linq; - -using ICSharpCode.NRefactory.PatternMatching; -using ICSharpCode.NRefactory.TypeSystem; -using ICSharpCode.NRefactory.VB.Ast; - -namespace ICSharpCode.NRefactory.VB.Visitors -{ - public interface IEnvironmentProvider - { - string RootNamespace { get; } - string GetTypeNameForAttribute(CSharp.Attribute attribute); - TypeKind GetTypeKindForAstType(CSharp.AstType type); - TypeCode ResolveExpression(CSharp.Expression expression); - bool? IsReferenceType(CSharp.Expression expression); - //ITypeResolveContext ResolveContext { get; } - IType ResolveType(AstType type, TypeDeclaration entity = null); - bool IsMethodGroup(CSharp.Expression expression); - bool HasEvent(Expression expression); - CSharp.ParameterDeclaration[] GetParametersForProperty(CSharp.PropertyDeclaration property); - } - - /// - /// Description of CSharpToVBConverterVisitor. - /// - public class CSharpToVBConverterVisitor : CSharp.IAstVisitor - { - IEnvironmentProvider provider; - Stack blocks; - Stack types; - Stack members; - - class MemberInfo - { - public bool inIterator; - } - - public CSharpToVBConverterVisitor(IEnvironmentProvider provider) - { - this.provider = provider; - this.blocks = new Stack(); - this.types = new Stack(); - this.members = new Stack(); - } - - public AstNode VisitAnonymousMethodExpression(CSharp.AnonymousMethodExpression anonymousMethodExpression, object data) - { - members.Push(new MemberInfo()); - - var expr = new MultiLineLambdaExpression() { - IsSub = true, - Body = (BlockStatement)anonymousMethodExpression.Body.AcceptVisitor(this, data) - }; - - ConvertNodes(anonymousMethodExpression.Parameters, expr.Parameters); - - if (members.Pop().inIterator) { - expr.Modifiers |= LambdaExpressionModifiers.Iterator; - } - - return EndNode(anonymousMethodExpression, expr); - } - - public AstNode VisitUndocumentedExpression(CSharp.UndocumentedExpression undocumentedExpression, object data) - { - var invocation = new InvocationExpression(); - - switch (undocumentedExpression.UndocumentedExpressionType) { - case CSharp.UndocumentedExpressionType.ArgListAccess: - case CSharp.UndocumentedExpressionType.ArgList: - invocation.Target = new IdentifierExpression { Identifier = "__ArgList" }; - break; - case CSharp.UndocumentedExpressionType.RefValue: - invocation.Target = new IdentifierExpression { Identifier = "__RefValue" }; - break; - case CSharp.UndocumentedExpressionType.RefType: - invocation.Target = new IdentifierExpression { Identifier = "__RefType" }; - break; - case CSharp.UndocumentedExpressionType.MakeRef: - invocation.Target = new IdentifierExpression { Identifier = "__MakeRef" }; - break; - default: - throw new Exception("Invalid value for UndocumentedExpressionType"); - } - - ConvertNodes(undocumentedExpression.Arguments, invocation.Arguments); - - return EndNode(undocumentedExpression, invocation); - } - - public AstNode VisitArrayCreateExpression(CSharp.ArrayCreateExpression arrayCreateExpression, object data) - { - var expr = new ArrayCreateExpression() { - Type = (AstType)arrayCreateExpression.Type.AcceptVisitor(this, data), - Initializer = (ArrayInitializerExpression)arrayCreateExpression.Initializer.AcceptVisitor(this, data) - }; - ConvertNodes(arrayCreateExpression.Arguments, expr.Arguments, ReduceArrayUpperBoundExpression); - ConvertNodes(arrayCreateExpression.AdditionalArraySpecifiers, expr.AdditionalArraySpecifiers); - - return EndNode(arrayCreateExpression, expr); - } - - Expression ReduceArrayUpperBoundExpression(Expression expression) - { - if (expression is PrimitiveExpression) - { - var numericLiteral = expression as PrimitiveExpression; - int? upperBound = numericLiteral.Value as int?; - if (upperBound.HasValue) - return new PrimitiveExpression(upperBound.Value - 1); - } - return new BinaryOperatorExpression(expression, BinaryOperatorType.Subtract, new PrimitiveExpression(1)); - } - - public AstNode VisitArrayInitializerExpression(CSharp.ArrayInitializerExpression arrayInitializerExpression, object data) - { - var expr = new ArrayInitializerExpression(); - ConvertNodes(arrayInitializerExpression.Elements, expr.Elements); - - return EndNode(arrayInitializerExpression, expr); - } - - public AstNode VisitAsExpression(CSharp.AsExpression asExpression, object data) - { - return EndNode(asExpression, new CastExpression(CastType.TryCast, (AstType)asExpression.Type.AcceptVisitor(this, data), (Expression)asExpression.Expression.AcceptVisitor(this, data))); - } - - public AstNode VisitAssignmentExpression(CSharp.AssignmentExpression assignmentExpression, object data) - { - var left = (Expression)assignmentExpression.Left.AcceptVisitor(this, data); - var op = AssignmentOperatorType.None; - var right = (Expression)assignmentExpression.Right.AcceptVisitor(this, data); - - switch (assignmentExpression.Operator) { - case CSharp.AssignmentOperatorType.Assign: - op = AssignmentOperatorType.Assign; - break; - case CSharp.AssignmentOperatorType.Add: - if (provider.HasEvent(left)) { - var addHandler = new AddRemoveHandlerStatement { IsAddHandler = true }; - addHandler.EventExpression = left; - addHandler.DelegateExpression = right; - return EndNode(assignmentExpression, addHandler); - } - op = AssignmentOperatorType.Add; - break; - case CSharp.AssignmentOperatorType.Subtract: - if (provider.HasEvent(left)) { - var addHandler = new AddRemoveHandlerStatement { IsAddHandler = false }; - addHandler.EventExpression = left; - addHandler.DelegateExpression = right; - return EndNode(assignmentExpression, addHandler); - } - op = AssignmentOperatorType.Subtract; - break; - case CSharp.AssignmentOperatorType.Multiply: - op = AssignmentOperatorType.Multiply; - break; - case CSharp.AssignmentOperatorType.Divide: - op = AssignmentOperatorType.Divide; - break; - case CSharp.AssignmentOperatorType.Modulus: - op = AssignmentOperatorType.Assign; - right = new BinaryOperatorExpression((Expression)left.Clone(), BinaryOperatorType.Modulus, right); - break; - case CSharp.AssignmentOperatorType.ShiftLeft: - op = AssignmentOperatorType.ShiftLeft; - break; - case CSharp.AssignmentOperatorType.ShiftRight: - op = AssignmentOperatorType.ShiftRight; - break; - case CSharp.AssignmentOperatorType.BitwiseAnd: - op = AssignmentOperatorType.Assign; - right = new BinaryOperatorExpression((Expression)left.Clone(), BinaryOperatorType.BitwiseAnd, right); - break; - case CSharp.AssignmentOperatorType.BitwiseOr: - op = AssignmentOperatorType.Assign; - right = new BinaryOperatorExpression((Expression)left.Clone(), BinaryOperatorType.BitwiseOr, right); - break; - case CSharp.AssignmentOperatorType.ExclusiveOr: - op = AssignmentOperatorType.Assign; - right = new BinaryOperatorExpression((Expression)left.Clone(), BinaryOperatorType.ExclusiveOr, right); - break; - default: - throw new Exception("Invalid value for AssignmentOperatorType: " + assignmentExpression.Operator); - } - - var expr = new AssignmentExpression(left, op, right); - return EndNode(assignmentExpression, expr); - } - - public AstNode VisitBaseReferenceExpression(CSharp.BaseReferenceExpression baseReferenceExpression, object data) - { - InstanceExpression result = new InstanceExpression(InstanceExpressionType.MyBase, baseReferenceExpression.StartLocation); - - return EndNode(baseReferenceExpression, result); - } - - public AstNode VisitBinaryOperatorExpression(CSharp.BinaryOperatorExpression binaryOperatorExpression, object data) - { - var left = (Expression)binaryOperatorExpression.Left.AcceptVisitor(this, data); - var op = BinaryOperatorType.None; - var right = (Expression)binaryOperatorExpression.Right.AcceptVisitor(this, data); - - switch (binaryOperatorExpression.Operator) { - case CSharp.BinaryOperatorType.BitwiseAnd: - op = BinaryOperatorType.BitwiseAnd; - break; - case CSharp.BinaryOperatorType.BitwiseOr: - op = BinaryOperatorType.BitwiseOr; - break; - case CSharp.BinaryOperatorType.ConditionalAnd: - op = BinaryOperatorType.LogicalAnd; - break; - case CSharp.BinaryOperatorType.ConditionalOr: - op = BinaryOperatorType.LogicalOr; - break; - case CSharp.BinaryOperatorType.ExclusiveOr: - op = BinaryOperatorType.ExclusiveOr; - break; - case CSharp.BinaryOperatorType.GreaterThan: - op = BinaryOperatorType.GreaterThan; - break; - case CSharp.BinaryOperatorType.GreaterThanOrEqual: - op = BinaryOperatorType.GreaterThanOrEqual; - break; - case CSharp.BinaryOperatorType.Equality: - if (IsReferentialEquality(binaryOperatorExpression)) - op = BinaryOperatorType.ReferenceEquality; - else - op = BinaryOperatorType.Equality; - break; - case CSharp.BinaryOperatorType.InEquality: - if (IsReferentialEquality(binaryOperatorExpression)) - op = BinaryOperatorType.ReferenceInequality; - else - op = BinaryOperatorType.InEquality; - break; - case CSharp.BinaryOperatorType.LessThan: - op = BinaryOperatorType.LessThan; - break; - case CSharp.BinaryOperatorType.LessThanOrEqual: - op = BinaryOperatorType.LessThanOrEqual; - break; - case CSharp.BinaryOperatorType.Add: - // TODO might be string concatenation - op = BinaryOperatorType.Add; - break; - case CSharp.BinaryOperatorType.Subtract: - op = BinaryOperatorType.Subtract; - break; - case CSharp.BinaryOperatorType.Multiply: - op = BinaryOperatorType.Multiply; - break; - case CSharp.BinaryOperatorType.Divide: - op = BinaryOperatorType.Divide; - break; - case CSharp.BinaryOperatorType.Modulus: - op = BinaryOperatorType.Modulus; - break; - case CSharp.BinaryOperatorType.ShiftLeft: - op = BinaryOperatorType.ShiftLeft; - break; - case CSharp.BinaryOperatorType.ShiftRight: - op = BinaryOperatorType.ShiftRight; - break; - case CSharp.BinaryOperatorType.NullCoalescing: - var nullCoalescing = new ConditionalExpression { - ConditionExpression = left, - FalseExpression = right - }; - return EndNode(binaryOperatorExpression, nullCoalescing); - default: - throw new Exception("Invalid value for BinaryOperatorType: " + binaryOperatorExpression.Operator); - } - - return EndNode(binaryOperatorExpression, new BinaryOperatorExpression(left, op, right)); - } - - bool IsReferentialEquality(CSharp.BinaryOperatorExpression binaryOperatorExpression) - { - var left = provider.IsReferenceType(binaryOperatorExpression.Left); - var right = provider.IsReferenceType(binaryOperatorExpression.Right); - - var leftCode = provider.ResolveExpression(binaryOperatorExpression.Left); - var rightCode = provider.ResolveExpression(binaryOperatorExpression.Right); - - return (left == true || right == true) && (leftCode != TypeCode.String && rightCode != TypeCode.String); - } - - public AstNode VisitCastExpression(CSharp.CastExpression castExpression, object data) - { - var expr = new CastExpression(); - - expr.Type = (AstType)castExpression.Type.AcceptVisitor(this, data); - // TODO read additional type information from annotation - // (int)x is equivalent to CInt(Math.Truncate(x)) - expr.CastType = GetCastType(expr.Type, null); - expr.Expression = (Expression)castExpression.Expression.AcceptVisitor(this, data); - - if (expr.CastType != CastType.CType) - expr.Type = null; - - return EndNode(castExpression, expr); - } - - CastType GetCastType(AstType type, object typeInformation) - { - var primType = type as PrimitiveType; - if (primType == null) - return CastType.CType; - - switch (primType.Keyword) { - case "Boolean": - return CastType.CBool; - case "Byte": - return CastType.CByte; - case "Char": - return CastType.CChar; - case "Date": - return CastType.CDate; - case "Double": - return CastType.CDbl; - case "Decimal": - return CastType.CDec; - case "Integer": - return CastType.CInt; - case "Long": - return CastType.CLng; - case "Object": - return CastType.CObj; - case "SByte": - return CastType.CSByte; - case "Short": - return CastType.CShort; - case "Single": - return CastType.CSng; - case "String": - return CastType.CStr; - case "UInteger": - return CastType.CUInt; - case "ULong": - return CastType.CULng; - case "UShort": - return CastType.CUShort; - } - - return CastType.CType; - } - - public AstNode VisitCheckedExpression(CSharp.CheckedExpression checkedExpression, object data) - { - blocks.Peek().AddChild(new Comment(" The following expression was wrapped in a checked-expression", false), AstNode.Roles.Comment); - return EndNode(checkedExpression, checkedExpression.Expression.AcceptVisitor(this, data)); - } - - public AstNode VisitConditionalExpression(CSharp.ConditionalExpression conditionalExpression, object data) - { - var cond = new ConditionalExpression() { - ConditionExpression = (Expression)conditionalExpression.Condition.AcceptVisitor(this, data), - TrueExpression = (Expression)conditionalExpression.TrueExpression.AcceptVisitor(this, data), - FalseExpression = (Expression)conditionalExpression.FalseExpression.AcceptVisitor(this, data) - }; - - return EndNode(conditionalExpression, cond); - } - - public AstNode VisitDefaultValueExpression(CSharp.DefaultValueExpression defaultValueExpression, object data) - { - // Nothing is equivalent to default(T) for reference and value types. - return EndNode(defaultValueExpression, new PrimitiveExpression(null)); - } - - public AstNode VisitDirectionExpression(CSharp.DirectionExpression directionExpression, object data) - { - return EndNode(directionExpression, (Expression)directionExpression.Expression.AcceptVisitor(this, data)); - } - - public AstNode VisitIdentifierExpression(CSharp.IdentifierExpression identifierExpression, object data) - { - var expr = new IdentifierExpression(); - expr.Identifier = new Identifier(identifierExpression.Identifier, TextLocation.Empty); - ConvertNodes(identifierExpression.TypeArguments, expr.TypeArguments); - if (provider.IsMethodGroup(identifierExpression)) { - return EndNode(identifierExpression, new UnaryOperatorExpression(UnaryOperatorType.AddressOf, expr)); - } - - return EndNode(identifierExpression, expr); - } - - public AstNode VisitIndexerExpression(CSharp.IndexerExpression indexerExpression, object data) - { - var expr = new InvocationExpression((Expression)indexerExpression.Target.AcceptVisitor(this, data)); - ConvertNodes(indexerExpression.Arguments, expr.Arguments); - return EndNode(indexerExpression, expr); - } - - public AstNode VisitInvocationExpression(CSharp.InvocationExpression invocationExpression, object data) - { - var expr = new InvocationExpression((Expression)invocationExpression.Target.AcceptVisitor(this, data)); - ConvertNodes(invocationExpression.Arguments, expr.Arguments); - return EndNode(invocationExpression, expr); - } - - public AstNode VisitIsExpression(CSharp.IsExpression isExpression, object data) - { - var expr = new TypeOfIsExpression() { - Type = (AstType)isExpression.Type.AcceptVisitor(this, data), - TypeOfExpression = (Expression)isExpression.Expression.AcceptVisitor(this, data) - }; - - return EndNode(isExpression, expr); - } - - public AstNode VisitLambdaExpression(CSharp.LambdaExpression lambdaExpression, object data) - { - LambdaExpression expr = null; - - if (lambdaExpression.Body is CSharp.Expression) { - var singleLine = new SingleLineFunctionLambdaExpression() { - EmbeddedExpression = (Expression)lambdaExpression.Body.AcceptVisitor(this, data) - }; - ConvertNodes(lambdaExpression.Parameters, singleLine.Parameters); - expr = singleLine; - } else - throw new NotImplementedException(); - - return EndNode(lambdaExpression, expr); - } - - public AstNode VisitMemberReferenceExpression(CSharp.MemberReferenceExpression memberReferenceExpression, object data) - { - var memberAccessExpression = new MemberAccessExpression(); - - memberAccessExpression.Target = (Expression)memberReferenceExpression.Target.AcceptVisitor(this, data); - memberAccessExpression.MemberName = new Identifier(memberReferenceExpression.MemberName, TextLocation.Empty); - ConvertNodes(memberReferenceExpression.TypeArguments, memberAccessExpression.TypeArguments); - if (provider.IsMethodGroup(memberReferenceExpression)) { - return EndNode(memberReferenceExpression, new UnaryOperatorExpression(UnaryOperatorType.AddressOf, memberAccessExpression)); - } - - return EndNode(memberReferenceExpression, memberAccessExpression); - } - - public AstNode VisitNamedArgumentExpression(CSharp.NamedArgumentExpression namedArgumentExpression, object data) - { - Expression expr = new NamedArgumentExpression { - Identifier = namedArgumentExpression.Name, - Expression = (Expression)namedArgumentExpression.Expression.AcceptVisitor(this, data) - }; - - return EndNode(namedArgumentExpression, expr); - } - - public AstNode VisitNamedExpression(CSharp.NamedExpression namedExpression, object data) - { - Expression expr = new FieldInitializerExpression { - IsKey = true, - Identifier = namedExpression.Name, - Expression = (Expression)namedExpression.Expression.AcceptVisitor(this, data) - }; - return EndNode(namedExpression, expr); - } - - public AstNode VisitNullReferenceExpression(CSharp.NullReferenceExpression nullReferenceExpression, object data) - { - return EndNode(nullReferenceExpression, new PrimitiveExpression(null)); - } - - public AstNode VisitObjectCreateExpression(CSharp.ObjectCreateExpression objectCreateExpression, object data) - { - var expr = new ObjectCreationExpression((AstType)objectCreateExpression.Type.AcceptVisitor(this, data)); - ConvertNodes(objectCreateExpression.Arguments, expr.Arguments); - var arg1 = expr.Arguments.FirstOrDefault() as UnaryOperatorExpression; - if (arg1 != null && arg1.Operator == UnaryOperatorType.AddressOf) { - arg1.Remove(); - return EndNode(objectCreateExpression, arg1); - } - if (!objectCreateExpression.Initializer.IsNull) - expr.Initializer = (ArrayInitializerExpression)objectCreateExpression.Initializer.AcceptVisitor(this, data); - - return EndNode(objectCreateExpression, expr); - } - - public AstNode VisitAnonymousTypeCreateExpression(CSharp.AnonymousTypeCreateExpression anonymousTypeCreateExpression, object data) - { - var expr = new AnonymousObjectCreationExpression(); - - ConvertNodes(anonymousTypeCreateExpression.Initializers, expr.Initializer); - - return EndNode(anonymousTypeCreateExpression, expr); - } - - public AstNode VisitParenthesizedExpression(CSharp.ParenthesizedExpression parenthesizedExpression, object data) - { - var result = new ParenthesizedExpression(); - - result.Expression = (Expression)parenthesizedExpression.Expression.AcceptVisitor(this, data); - - return EndNode(parenthesizedExpression, result); - } - - public AstNode VisitPointerReferenceExpression(CSharp.PointerReferenceExpression pointerReferenceExpression, object data) - { - return EndNode(pointerReferenceExpression,((Expression)pointerReferenceExpression.Target.AcceptVisitor(this, data)).Invoke("Dereference").Member(pointerReferenceExpression.MemberName)); - } - - public AstNode VisitPrimitiveExpression(CSharp.PrimitiveExpression primitiveExpression, object data) - { - Expression expr; - - if (!string.IsNullOrEmpty(primitiveExpression.Value as string)) - expr = ConvertToConcat(primitiveExpression.Value.ToString()); - else if (primitiveExpression.Value is char) - expr = ConvertToSpecialChar((char)primitiveExpression.Value); - else - expr = new PrimitiveExpression(primitiveExpression.Value); - - return EndNode(primitiveExpression, expr); - } - - Expression ConvertToConcat(string literal) - { - Stack parts = new Stack(); - int start = 0; - - for (int i = 0; i < literal.Length; i++) { - string part; - switch (literal[i]) { - case '\0': - case '\b': - case '\f': - case '\n': - case '\t': - case '\v': - part = literal.Substring(start, i - start); - if (!string.IsNullOrEmpty(part)) - parts.Push(new PrimitiveExpression(part)); - parts.Push(ConvertToSpecialChar(literal[i])); - start = i + 1; - break; - case '\r': - part = literal.Substring(start, i - start); - if (!string.IsNullOrEmpty(part)) - parts.Push(new PrimitiveExpression(part)); - if (i + 1 < literal.Length && literal[i + 1] == '\n') { - i++; - parts.Push(new IdentifierExpression("vbCrLf")); - } else - parts.Push(new IdentifierExpression("vbCr")); - start = i + 1; - break; - default: - if ((int)literal[i] > 255) { - part = literal.Substring(start, i - start); - if (!string.IsNullOrEmpty(part)) - parts.Push(new PrimitiveExpression(part)); - parts.Push(new InvocationExpression(new IdentifierExpression("ChrW"), new PrimitiveExpression((int)literal[i]))); - } else - continue; - start = i + 1; - break; - } - - } - - if (start < literal.Length) { - string part = literal.Substring(start); - parts.Push(new PrimitiveExpression(part)); - } - - Expression current = parts.Pop(); - - while (parts.Any()) - current = new BinaryOperatorExpression(parts.Pop(), BinaryOperatorType.Concat, current); - - return current; - } - - Expression ConvertToSpecialChar(char ch) - { - switch (ch) { - case '\0': - return new IdentifierExpression("vbNullChar"); - case '\b': - return new IdentifierExpression("vbBack"); - case '\f': - return new IdentifierExpression("vbFormFeed"); - case '\r': - return new IdentifierExpression("vbCr"); - case '\n': - return new IdentifierExpression("vbLf"); - case '\t': - return new IdentifierExpression("vbTab"); - case '\v': - return new IdentifierExpression("vbVerticalTab"); - default: - if (ch > 255) - return new InvocationExpression(new IdentifierExpression("ChrW"), new PrimitiveExpression((int)ch)); - return new PrimitiveExpression(ch); - } - } - - public AstNode VisitSizeOfExpression(CSharp.SizeOfExpression sizeOfExpression, object data) - { - return EndNode( - sizeOfExpression, - new InvocationExpression( - new IdentifierExpression() { Identifier = "__SizeOf" }, - new TypeReferenceExpression((AstType)sizeOfExpression.Type.AcceptVisitor(this, data)) - ) - ); - } - - public AstNode VisitStackAllocExpression(CSharp.StackAllocExpression stackAllocExpression, object data) - { - return EndNode( - stackAllocExpression, - new InvocationExpression( - new IdentifierExpression() { Identifier = "__StackAlloc" }, - new TypeReferenceExpression((AstType)stackAllocExpression.Type.AcceptVisitor(this, data)), - (Expression)stackAllocExpression.CountExpression.AcceptVisitor(this, data) - ) - ); - } - - public AstNode VisitThisReferenceExpression(CSharp.ThisReferenceExpression thisReferenceExpression, object data) - { - InstanceExpression result = new InstanceExpression(InstanceExpressionType.Me, thisReferenceExpression.StartLocation); - return EndNode(thisReferenceExpression, result); - } - - public AstNode VisitTypeOfExpression(CSharp.TypeOfExpression typeOfExpression, object data) - { - var expr = new GetTypeExpression(); - expr.Type = (AstType)typeOfExpression.Type.AcceptVisitor(this, data); - return EndNode(typeOfExpression, expr); - } - - public AstNode VisitTypeReferenceExpression(CSharp.TypeReferenceExpression typeReferenceExpression, object data) - { - var expr = new TypeReferenceExpression((AstType)typeReferenceExpression.Type.AcceptVisitor(this, data)); - return EndNode(typeReferenceExpression, expr); - } - - public AstNode VisitUnaryOperatorExpression(CSharp.UnaryOperatorExpression unaryOperatorExpression, object data) - { - Expression expr; - - switch (unaryOperatorExpression.Operator) { - case CSharp.UnaryOperatorType.Not: - case CSharp.UnaryOperatorType.BitNot: - expr = new UnaryOperatorExpression() { - Expression = (Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data), - Operator = UnaryOperatorType.Not - }; - break; - case CSharp.UnaryOperatorType.Minus: - expr = new UnaryOperatorExpression() { - Expression = (Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data), - Operator = UnaryOperatorType.Minus - }; - break; - case CSharp.UnaryOperatorType.Plus: - expr = new UnaryOperatorExpression() { - Expression = (Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data), - Operator = UnaryOperatorType.Plus - }; - break; - case CSharp.UnaryOperatorType.Increment: - expr = new InvocationExpression(); - ((InvocationExpression)expr).Target = new IdentifierExpression() { Identifier = "__Increment" }; - ((InvocationExpression)expr).Arguments.Add((Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); - break; - case CSharp.UnaryOperatorType.PostIncrement: - expr = new InvocationExpression(); - ((InvocationExpression)expr).Target = new IdentifierExpression() { Identifier = "__PostIncrement" }; - ((InvocationExpression)expr).Arguments.Add((Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); - break; - case CSharp.UnaryOperatorType.Decrement: - expr = new InvocationExpression(); - ((InvocationExpression)expr).Target = new IdentifierExpression() { Identifier = "__Decrement" }; - ((InvocationExpression)expr).Arguments.Add((Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); - break; - case CSharp.UnaryOperatorType.PostDecrement: - expr = new InvocationExpression(); - ((InvocationExpression)expr).Target = new IdentifierExpression() { Identifier = "__PostDecrement" }; - ((InvocationExpression)expr).Arguments.Add((Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); - break; - case CSharp.UnaryOperatorType.AddressOf: - expr = new UnaryOperatorExpression() { - Expression = (Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data), - Operator = UnaryOperatorType.AddressOf - }; - break; - case CSharp.UnaryOperatorType.Dereference: - expr = new InvocationExpression(); - ((InvocationExpression)expr).Target = new IdentifierExpression() { Identifier = "__Dereference" }; - ((InvocationExpression)expr).Arguments.Add((Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data)); - break; - case CSharp.UnaryOperatorType.Await: - expr = new UnaryOperatorExpression() { - Expression = (Expression)unaryOperatorExpression.Expression.AcceptVisitor(this, data), - Operator = UnaryOperatorType.Await - }; - break; - default: - throw new Exception("Invalid value for UnaryOperatorType"); - } - - return EndNode(unaryOperatorExpression, expr); - } - - public AstNode VisitUncheckedExpression(CSharp.UncheckedExpression uncheckedExpression, object data) - { - blocks.Peek().AddChild(new Comment(" The following expression was wrapped in a unchecked-expression", false), AstNode.Roles.Comment); - return EndNode(uncheckedExpression, uncheckedExpression.Expression.AcceptVisitor(this, data)); - } - - public AstNode VisitQueryExpression(CSharp.QueryExpression queryExpression, object data) - { - var expr = new QueryExpression(); - ConvertNodes(queryExpression.Clauses, expr.QueryOperators); - return EndNode(queryExpression, expr); - } - - public AstNode VisitQueryContinuationClause(CSharp.QueryContinuationClause queryContinuationClause, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitQueryFromClause(CSharp.QueryFromClause queryFromClause, object data) - { - var op = new FromQueryOperator(); - op.Variables.Add( - new CollectionRangeVariableDeclaration { - Identifier = new VariableIdentifier { Name = queryFromClause.Identifier }, - Type = (AstType)queryFromClause.Type.AcceptVisitor(this, data), - Expression = (Expression)queryFromClause.Expression.AcceptVisitor(this, data) - } - ); - - return EndNode(queryFromClause, op); - } - - public AstNode VisitQueryLetClause(CSharp.QueryLetClause queryLetClause, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitQueryWhereClause(CSharp.QueryWhereClause queryWhereClause, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitQueryJoinClause(CSharp.QueryJoinClause queryJoinClause, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitQueryOrderClause(CSharp.QueryOrderClause queryOrderClause, object data) - { - var op = new OrderByQueryOperator(); - - ConvertNodes(queryOrderClause.Orderings, op.Expressions); - - return EndNode(queryOrderClause, op); - } - - public AstNode VisitQueryOrdering(CSharp.QueryOrdering queryOrdering, object data) - { - var expr = new OrderExpression(); - - expr.Direction = (QueryOrderingDirection)queryOrdering.Direction; - expr.Expression = (Expression)queryOrdering.Expression.AcceptVisitor(this, data); - - return EndNode(queryOrdering, expr); - } - - int selectVarCount = 0; - - public AstNode VisitQuerySelectClause(CSharp.QuerySelectClause querySelectClause, object data) - { - var op = new SelectQueryOperator(); - - op.Variables.Add( - new VariableInitializer { - Identifier = new VariableIdentifier { Name = "SelectVar" + selectVarCount }, - Expression = (Expression)querySelectClause.Expression.AcceptVisitor(this, data) - }); - - return EndNode(querySelectClause, op); - } - - public AstNode VisitQueryGroupClause(CSharp.QueryGroupClause queryGroupClause, object data) - { - var op = new GroupByQueryOperator(); - - throw new NotImplementedException(); - - //return EndNode(queryGroupClause, op); - } - - public AstNode VisitAttribute(CSharp.Attribute attribute, object data) - { - var attr = new VB.Ast.Attribute(); - AttributeTarget target; - Enum.TryParse(((CSharp.AttributeSection)attribute.Parent).AttributeTarget, true, out target); - attr.Target = target; - attr.Type = (AstType)attribute.Type.AcceptVisitor(this, data); - ConvertNodes(attribute.Arguments, attr.Arguments); - - return EndNode(attribute, attr); - } - - public AstNode VisitAttributeSection(CSharp.AttributeSection attributeSection, object data) - { - AttributeBlock block = new AttributeBlock(); - ConvertNodes(attributeSection.Attributes, block.Attributes); - return EndNode(attributeSection, block); - } - - public AstNode VisitDelegateDeclaration(CSharp.DelegateDeclaration delegateDeclaration, object data) - { - var result = new DelegateDeclaration(); - - ConvertNodes(delegateDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), result.Attributes); - ConvertNodes(delegateDeclaration.ModifierTokens, result.ModifierTokens); - result.Name = new Identifier(delegateDeclaration.Name, TextLocation.Empty); - result.IsSub = IsSub(delegateDeclaration.ReturnType); - ConvertNodes(delegateDeclaration.Parameters, result.Parameters); - ConvertNodes(delegateDeclaration.TypeParameters, result.TypeParameters); - ConvertNodes(delegateDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), result.ReturnTypeAttributes); - if (!result.IsSub) - result.ReturnType = (AstType)delegateDeclaration.ReturnType.AcceptVisitor(this, data); - return EndNode(delegateDeclaration, result); - } - - public AstNode VisitNamespaceDeclaration(CSharp.NamespaceDeclaration namespaceDeclaration, object data) - { - var newNamespace = new NamespaceDeclaration(); - - foreach (string id in namespaceDeclaration.Identifiers) { - newNamespace.Identifiers.Add(new Identifier(id, TextLocation.Empty)); - } - ConvertMembers(namespaceDeclaration, newNamespace, CSharp.NamespaceDeclaration.MemberRole, NamespaceDeclaration.MemberRole); - - return EndNode(namespaceDeclaration, newNamespace); - } - - public AstNode VisitTypeDeclaration(CSharp.TypeDeclaration typeDeclaration, object data) - { - // TODO add missing features! - - if (typeDeclaration.ClassType == CSharp.ClassType.Enum) { - var type = new EnumDeclaration(); - CopyAnnotations(typeDeclaration, type); - - ConvertNodes(typeDeclaration.Attributes, type.Attributes); - ConvertNodes(typeDeclaration.ModifierTokens, type.ModifierTokens); - - if (typeDeclaration.BaseTypes.Any()) { - var first = typeDeclaration.BaseTypes.First(); - - type.UnderlyingType = (AstType)first.AcceptVisitor(this, data); - } - - type.Name = new Identifier(typeDeclaration.Name, TextLocation.Empty); - - ConvertMembers(typeDeclaration, type, CSharp.Roles.TypeMemberRole, EnumDeclaration.MemberRole); - - return EndNode(typeDeclaration, type); - } else { - var type = new TypeDeclaration(); - CopyAnnotations(typeDeclaration, type); - - CSharp.Attribute stdModAttr; - - if (typeDeclaration.ClassType == CSharp.ClassType.Class && HasAttribute(typeDeclaration.Attributes, "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute", out stdModAttr)) { - type.ClassType = ClassType.Module; - // remove AttributeSection if only one attribute is present - var attrSec = (CSharp.AttributeSection)stdModAttr.Parent; - if (attrSec.Attributes.Count == 1) - attrSec.Remove(); - else - stdModAttr.Remove(); - } else { - switch (typeDeclaration.ClassType) { - case CSharp.ClassType.Class: - type.ClassType = ClassType.Class; - break; - case CSharp.ClassType.Struct: - type.ClassType = ClassType.Struct; - break; - case CSharp.ClassType.Interface: - type.ClassType = ClassType.Interface; - break; - default: - throw new InvalidOperationException("Invalid value for ClassType"); - } - } - - if ((typeDeclaration.Modifiers & CSharp.Modifiers.Static) == CSharp.Modifiers.Static) { - type.ClassType = ClassType.Module; - typeDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - } - - ConvertNodes(typeDeclaration.Attributes, type.Attributes); - ConvertNodes(typeDeclaration.ModifierTokens, type.ModifierTokens); - ConvertNodes(typeDeclaration.TypeParameters, type.TypeParameters); - - if (typeDeclaration.BaseTypes.Any()) { - var first = typeDeclaration.BaseTypes.First(); - - if (provider.GetTypeKindForAstType(first) != TypeKind.Interface) { - ConvertNodes(typeDeclaration.BaseTypes.Skip(1), type.ImplementsTypes); - type.InheritsType = (AstType)first.AcceptVisitor(this, data); - } else - ConvertNodes(typeDeclaration.BaseTypes, type.ImplementsTypes); - } - - type.Name = typeDeclaration.Name; - - types.Push(type); - ConvertMembers(typeDeclaration, type, CSharp.Roles.TypeMemberRole, TypeDeclaration.MemberRole); - types.Pop(); - - return EndNode(typeDeclaration, type); - } - } - - public AstNode VisitUsingAliasDeclaration(CSharp.UsingAliasDeclaration usingAliasDeclaration, object data) - { - var imports = new ImportsStatement(); - - var clause = new AliasImportsClause() { - Name = new Identifier(usingAliasDeclaration.Alias, TextLocation.Empty), - Alias = (AstType)usingAliasDeclaration.Import.AcceptVisitor(this, data) - }; - - imports.AddChild(clause, ImportsStatement.ImportsClauseRole); - - return EndNode(usingAliasDeclaration, imports); - } - - public AstNode VisitUsingDeclaration(CSharp.UsingDeclaration usingDeclaration, object data) - { - var imports = new ImportsStatement(); - - var clause = new MemberImportsClause() { - Member = (AstType)usingDeclaration.Import.AcceptVisitor(this, data) - }; - - imports.AddChild(clause, ImportsStatement.ImportsClauseRole); - - return EndNode(usingDeclaration, imports); - } - - public AstNode VisitExternAliasDeclaration(CSharp.ExternAliasDeclaration externAliasDeclaration, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitBlockStatement(CSharp.BlockStatement blockStatement, object data) - { - var block = new BlockStatement(); - blocks.Push(block); - ConvertNodes(blockStatement, block.Statements); - blocks.Pop(); - return EndNode(blockStatement, block); - } - - public AstNode VisitBreakStatement(CSharp.BreakStatement breakStatement, object data) - { - var exit = new ExitStatement(ExitKind.None); - - foreach (var stmt in breakStatement.Ancestors) { - if (stmt is CSharp.MethodDeclaration) { - exit.ExitKind = IsSub(((CSharp.MethodDeclaration)stmt).ReturnType) ? ExitKind.Sub : ExitKind.Function; - break; - } - if (stmt is CSharp.PropertyDeclaration) { - exit.ExitKind = ExitKind.Property; - break; - } - if (stmt is CSharp.DoWhileStatement) { - exit.ExitKind = ExitKind.Do; - break; - } - if (stmt is CSharp.ForStatement || stmt is CSharp.ForeachStatement) { - exit.ExitKind = ExitKind.For; - break; - } - if (stmt is CSharp.WhileStatement) { - exit.ExitKind = ExitKind.While; - break; - } - if (stmt is CSharp.SwitchStatement) { - exit.ExitKind = ExitKind.Select; - break; - } - if (stmt is CSharp.TryCatchStatement) { - exit.ExitKind = ExitKind.Try; - break; - } - } - - return EndNode(breakStatement, exit); - } - - public AstNode VisitCheckedStatement(CSharp.CheckedStatement checkedStatement, object data) - { - blocks.Peek().AddChild(new Comment(" The following expression was wrapped in a checked-statement", false), AstNode.Roles.Comment); - var body = (BlockStatement)checkedStatement.Body.AcceptVisitor(this, data); - - foreach (var stmt in body) { - stmt.Remove(); - blocks.Peek().Add(stmt); - } - - return EndNode(checkedStatement, null); - } - - public AstNode VisitContinueStatement(CSharp.ContinueStatement continueStatement, object data) - { - var @continue = new ContinueStatement(ContinueKind.None); - - foreach (var stmt in continueStatement.Ancestors) { - if (stmt is CSharp.DoWhileStatement) { - @continue.ContinueKind = ContinueKind.Do; - break; - } - if (stmt is CSharp.ForStatement || stmt is CSharp.ForeachStatement) { - @continue.ContinueKind = ContinueKind.For; - break; - } - if (stmt is CSharp.WhileStatement) { - @continue.ContinueKind = ContinueKind.While; - break; - } - } - - return EndNode(continueStatement, @continue); - } - - public AstNode VisitDoWhileStatement(CSharp.DoWhileStatement doWhileStatement, object data) - { - var stmt = new DoLoopStatement(); - - stmt.ConditionType = ConditionType.LoopWhile; - stmt.Expression = (Expression)doWhileStatement.Condition.AcceptVisitor(this, data); - stmt.Body = (BlockStatement)doWhileStatement.EmbeddedStatement.AcceptVisitor(this, data); - - return EndNode(doWhileStatement, stmt); - } - - public AstNode VisitEmptyStatement(CSharp.EmptyStatement emptyStatement, object data) - { - return EndNode(emptyStatement, null); - } - - public AstNode VisitExpressionStatement(CSharp.ExpressionStatement expressionStatement, object data) - { - var node = expressionStatement.Expression.AcceptVisitor(this, data); - if (node is Expression) - node = new ExpressionStatement((Expression)node); - return EndNode(expressionStatement, node); - } - - public AstNode VisitFixedStatement(CSharp.FixedStatement fixedStatement, object data) - { - var block = blocks.Peek(); - block.AddChild(new Comment(" Emulating fixed-Statement, might not be entirely correct!", false), AstNode.Roles.Comment); - - var variables = new LocalDeclarationStatement(); - variables.Modifiers = Modifiers.Dim; - var stmt = new TryStatement(); - stmt.FinallyBlock = new BlockStatement(); - foreach (var decl in fixedStatement.Variables) { - var v = new VariableDeclaratorWithTypeAndInitializer { - Identifiers = { new VariableIdentifier { Name = decl.Name } }, - Type = new SimpleType("GCHandle"), - Initializer = new InvocationExpression( - new MemberAccessExpression { Target = new IdentifierExpression { Identifier = "GCHandle" }, MemberName = "Alloc" }, - (Expression)decl.Initializer.AcceptVisitor(this, data), - new MemberAccessExpression { Target = new IdentifierExpression { Identifier = "GCHandleType" }, MemberName = "Pinned" } - ) - }; - variables.Variables.Add(v); - stmt.FinallyBlock.Add(new IdentifierExpression { Identifier = decl.Name }.Invoke("Free")); - } - - block.Add(variables); - - stmt.Body = (BlockStatement)fixedStatement.EmbeddedStatement.AcceptVisitor(this, data); - - foreach (var ident in stmt.Body.Descendants.OfType()) { - ident.ReplaceWith(expr => ((Expression)expr).Invoke("AddrOfPinnedObject")); - } - - return EndNode(fixedStatement, stmt); - } - - public AstNode VisitForeachStatement(CSharp.ForeachStatement foreachStatement, object data) - { - var stmt = new ForEachStatement() { - Body = (BlockStatement)foreachStatement.EmbeddedStatement.AcceptVisitor(this, data), - InExpression = (Expression)foreachStatement.InExpression.AcceptVisitor(this, data), - Variable = new VariableInitializer() { - Identifier = new VariableIdentifier() { Name = foreachStatement.VariableName }, - Type = (AstType)foreachStatement.VariableType.AcceptVisitor(this, data) - } - }; - - return EndNode(foreachStatement, stmt); - } - - public AstNode VisitForStatement(CSharp.ForStatement forStatement, object data) - { - // for (;;) ; - if (!forStatement.Initializers.Any() && forStatement.Condition.IsNull && !forStatement.Iterators.Any()) - return EndNode(forStatement, new WhileStatement() { Condition = new PrimitiveExpression(true), Body = (BlockStatement)forStatement.EmbeddedStatement.AcceptVisitor(this, data) }); - - CSharp.AstNode counterLoop = new CSharp.ForStatement() { - Initializers = { - new NamedNode( - "iteratorVar", - new Choice { - new CSharp.VariableDeclarationStatement { - Type = new Choice { - new CSharp.PrimitiveType("long"), - new CSharp.PrimitiveType("ulong"), - new CSharp.PrimitiveType("int"), - new CSharp.PrimitiveType("uint"), - new CSharp.PrimitiveType("short"), - new CSharp.PrimitiveType("ushort"), - new CSharp.PrimitiveType("sbyte"), - new CSharp.PrimitiveType("byte") - }, - Variables = { - new AnyNode() - } - }, - new CSharp.ExpressionStatement( - new CSharp.AssignmentExpression() - ) - }) - }, - Condition = new NamedNode( - "condition", - new CSharp.BinaryOperatorExpression { - Left = new NamedNode("ident", new CSharp.IdentifierExpression(Pattern.AnyString)), - Operator = CSharp.BinaryOperatorType.Any, - Right = new AnyNode("endExpr") - }), - Iterators = { - new CSharp.ExpressionStatement( - new NamedNode( - "increment", - new CSharp.AssignmentExpression { - Left = new Backreference("ident"), - Operator = CSharp.AssignmentOperatorType.Any, - Right = new NamedNode("factor", new AnyNode()) - } - ) - ) - }, - EmbeddedStatement = new NamedNode("body", new AnyNode()) - }; - - var match = counterLoop.Match(forStatement); - - if (match.Success) { - var init = match.Get("iteratorVar").SingleOrDefault(); - - AstNode iteratorVariable; - - if (init is CSharp.VariableDeclarationStatement) { - var var = ((CSharp.VariableDeclarationStatement)init).Variables.First(); - iteratorVariable = new VariableInitializer() { - Identifier = new VariableIdentifier { Name = var.Name }, - Type = (AstType)((CSharp.VariableDeclarationStatement)init).Type.AcceptVisitor(this, data), - Expression = (Expression)var.Initializer.AcceptVisitor(this, data) - }; - } else if (init is CSharp.ExpressionStatement) { - iteratorVariable = init.AcceptVisitor(this, data); - } else goto end; - - Expression toExpr = Expression.Null; - - var cond = match.Get("condition").SingleOrDefault(); - var endExpr = (Expression)match.Get("endExpr").SingleOrDefault().AcceptVisitor(this, data); - - if (cond.Operator == CSharp.BinaryOperatorType.LessThanOrEqual || - cond.Operator == CSharp.BinaryOperatorType.GreaterThanOrEqual) { - toExpr = endExpr; - } - - if (cond.Operator == CSharp.BinaryOperatorType.LessThan) - toExpr = new BinaryOperatorExpression(endExpr, BinaryOperatorType.Subtract, new PrimitiveExpression(1)); - if (cond.Operator == CSharp.BinaryOperatorType.GreaterThan) - toExpr = new BinaryOperatorExpression(endExpr, BinaryOperatorType.Add, new PrimitiveExpression(1)); - - Expression stepExpr = Expression.Null; - - var increment = match.Get("increment").SingleOrDefault(); - var factorExpr = (Expression)match.Get("factor").SingleOrDefault().AcceptVisitor(this, data); - - if (increment.Operator == CSharp.AssignmentOperatorType.Add && (factorExpr is PrimitiveExpression && !IsEqual(((PrimitiveExpression)factorExpr).Value, 1))) - stepExpr = factorExpr; - if (increment.Operator == CSharp.AssignmentOperatorType.Subtract) - stepExpr = new UnaryOperatorExpression(UnaryOperatorType.Minus, factorExpr); - - return new ForStatement() { - Variable = iteratorVariable, - ToExpression = toExpr, - StepExpression = stepExpr, - Body = (BlockStatement)match.Get("body").Single().AcceptVisitor(this, data) - }; - } - - end: - var stmt = new WhileStatement() { - Condition = (Expression)forStatement.Condition.AcceptVisitor(this, data), - Body = (BlockStatement)forStatement.EmbeddedStatement.AcceptVisitor(this, data) - }; - ConvertNodes(forStatement.Iterators, stmt.Body.Statements); - foreach (var initializer in forStatement.Initializers) - blocks.Peek().Statements.Add((Statement)initializer.AcceptVisitor(this, data)); - - return EndNode(forStatement, stmt); - } - - bool IsEqual(object value, int num) - { - if (value is byte) - return (byte)value == num; - if (value is sbyte) - return (sbyte)value == num; - if (value is short) - return (short)value == num; - if (value is ushort) - return (ushort)value == num; - if (value is int) - return (int)value == num; - if (value is uint) - return (uint)value == num; - if (value is long) - return (long)value == num; - if (value is ulong) - return (ulong)value == (ulong)num; - - throw new InvalidCastException(); - } - - public AstNode VisitGotoCaseStatement(CSharp.GotoCaseStatement gotoCaseStatement, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitGotoDefaultStatement(CSharp.GotoDefaultStatement gotoDefaultStatement, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitGotoStatement(CSharp.GotoStatement gotoStatement, object data) - { - return EndNode(gotoStatement, new GoToStatement() { Label = new IdentifierExpression() { Identifier = gotoStatement.Label } }); - } - - public AstNode VisitIfElseStatement(CSharp.IfElseStatement ifElseStatement, object data) - { - var stmt = new IfElseStatement(); - - stmt.Condition = (Expression)ifElseStatement.Condition.AcceptVisitor(this, data); - stmt.Body = (Statement)ifElseStatement.TrueStatement.AcceptVisitor(this, data); - stmt.ElseBlock = (Statement)ifElseStatement.FalseStatement.AcceptVisitor(this, data); - - return EndNode(ifElseStatement, stmt); - } - - public AstNode VisitLabelStatement(CSharp.LabelStatement labelStatement, object data) - { - return EndNode(labelStatement, new LabelDeclarationStatement() { Label = new IdentifierExpression() { Identifier = labelStatement.Label } }); - } - - public AstNode VisitLockStatement(CSharp.LockStatement lockStatement, object data) - { - var stmt = new SyncLockStatement(); - - stmt.Expression = (Expression)lockStatement.Expression.AcceptVisitor(this, data); - stmt.Body = (BlockStatement)lockStatement.EmbeddedStatement.AcceptVisitor(this, data); - - return EndNode(lockStatement, stmt); - } - - public AstNode VisitReturnStatement(CSharp.ReturnStatement returnStatement, object data) - { - var stmt = new ReturnStatement((Expression)returnStatement.Expression.AcceptVisitor(this, data)); - - return EndNode(returnStatement, stmt); - } - - public AstNode VisitSwitchStatement(CSharp.SwitchStatement switchStatement, object data) - { - var stmt = new SelectStatement() { Expression = (Expression)switchStatement.Expression.AcceptVisitor(this, data) }; - ConvertNodes(switchStatement.SwitchSections, stmt.Cases); - - return EndNode(switchStatement, stmt); - } - - public AstNode VisitSwitchSection(CSharp.SwitchSection switchSection, object data) - { - var caseStmt = new CaseStatement(); - ConvertNodes(switchSection.CaseLabels, caseStmt.Clauses); - if (switchSection.Statements.Count == 1 && switchSection.Statements.FirstOrDefault() is CSharp.BlockStatement) - caseStmt.Body = (BlockStatement)switchSection.Statements.FirstOrDefault().AcceptVisitor(this, data); - else { - caseStmt.Body = new BlockStatement(); - ConvertNodes(switchSection.Statements, caseStmt.Body.Statements); - } - if (caseStmt.Body.LastOrDefault() is ExitStatement && ((ExitStatement)caseStmt.Body.LastOrDefault()).ExitKind == ExitKind.Select) - caseStmt.Body.LastOrDefault().Remove(); - return EndNode(switchSection, caseStmt); - } - - public AstNode VisitCaseLabel(CSharp.CaseLabel caseLabel, object data) - { - return EndNode(caseLabel, new SimpleCaseClause() { Expression = (Expression)caseLabel.Expression.AcceptVisitor(this, data) }); - } - - public AstNode VisitThrowStatement(CSharp.ThrowStatement throwStatement, object data) - { - return EndNode(throwStatement, new ThrowStatement((Expression)throwStatement.Expression.AcceptVisitor(this, data))); - } - - public AstNode VisitTryCatchStatement(CSharp.TryCatchStatement tryCatchStatement, object data) - { - var stmt = new TryStatement(); - - stmt.Body = (BlockStatement)tryCatchStatement.TryBlock.AcceptVisitor(this, data); - stmt.FinallyBlock = (BlockStatement)tryCatchStatement.FinallyBlock.AcceptVisitor(this, data); - ConvertNodes(tryCatchStatement.CatchClauses, stmt.CatchBlocks); - - return EndNode(tryCatchStatement, stmt); - } - - public AstNode VisitCatchClause(CSharp.CatchClause catchClause, object data) - { - var clause = new CatchBlock(); - - clause.ExceptionType = (AstType)catchClause.Type.AcceptVisitor(this, data); - clause.ExceptionVariable = catchClause.VariableName; - ConvertNodes(catchClause.Body.Statements, clause.Statements); - - return EndNode(catchClause, clause); - } - - public AstNode VisitUncheckedStatement(CSharp.UncheckedStatement uncheckedStatement, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitUnsafeStatement(CSharp.UnsafeStatement unsafeStatement, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitUsingStatement(CSharp.UsingStatement usingStatement, object data) - { - var stmt = new UsingStatement(); - - stmt.Resources.Add(usingStatement.ResourceAcquisition.AcceptVisitor(this, data)); - stmt.Body = (BlockStatement)usingStatement.EmbeddedStatement.AcceptVisitor(this, data); - - return EndNode(usingStatement, stmt); - } - - public AstNode VisitVariableDeclarationStatement(CSharp.VariableDeclarationStatement variableDeclarationStatement, object data) - { - var decl = new LocalDeclarationStatement(); - decl.Modifiers = Modifiers.Dim; - ConvertNodes(variableDeclarationStatement.Variables, decl.Variables); - - return EndNode(variableDeclarationStatement, decl); - } - - public AstNode VisitWhileStatement(CSharp.WhileStatement whileStatement, object data) - { - var stmt = new WhileStatement() { - Condition = (Expression)whileStatement.Condition.AcceptVisitor(this, data), - Body = (BlockStatement)whileStatement.EmbeddedStatement.AcceptVisitor(this, data) - }; - - return EndNode(whileStatement, stmt); - } - - public AstNode VisitYieldBreakStatement(CSharp.YieldBreakStatement yieldBreakStatement, object data) - { - var frame = members.Peek(); - frame.inIterator = true; - return EndNode(yieldBreakStatement, new ReturnStatement()); - } - - public AstNode VisitYieldReturnStatement(CSharp.YieldReturnStatement yieldReturnStatement, object data) - { - var frame = members.Peek(); - frame.inIterator = true; - return EndNode(yieldReturnStatement, new YieldStatement((Expression)yieldReturnStatement.Expression.AcceptVisitor(this, data))); - } - - public AstNode VisitAccessor(CSharp.Accessor accessor, object data) - { - var result = new Accessor(); - - ConvertNodes(accessor.Attributes, result.Attributes); - ConvertNodes(accessor.ModifierTokens, result.ModifierTokens); - result.Body = (BlockStatement)accessor.Body.AcceptVisitor(this, data); - - return EndNode(accessor, result); - } - - public AstNode VisitConstructorDeclaration(CSharp.ConstructorDeclaration constructorDeclaration, object data) - { - var result = new ConstructorDeclaration(); - - ConvertNodes(constructorDeclaration.Attributes, result.Attributes); - ConvertNodes(constructorDeclaration.ModifierTokens, result.ModifierTokens); - ConvertNodes(constructorDeclaration.Parameters, result.Parameters); - result.Body = (BlockStatement)constructorDeclaration.Body.AcceptVisitor(this, data); - if (!constructorDeclaration.Initializer.IsNull) - result.Body.Statements.InsertBefore(result.Body.FirstOrDefault(), (Statement)constructorDeclaration.Initializer.AcceptVisitor(this, data)); - - return EndNode(constructorDeclaration, result); - } - - public AstNode VisitConstructorInitializer(CSharp.ConstructorInitializer constructorInitializer, object data) - { - var result = new InvocationExpression( - new MemberAccessExpression() { - Target = new InstanceExpression(constructorInitializer.ConstructorInitializerType == CSharp.ConstructorInitializerType.This ? InstanceExpressionType.Me : InstanceExpressionType.MyBase, TextLocation.Empty), - MemberName = new Identifier("New", TextLocation.Empty) - } - ); - ConvertNodes(constructorInitializer.Arguments, result.Arguments); - - return EndNode(constructorInitializer, new ExpressionStatement(result)); - } - - public AstNode VisitDestructorDeclaration(CSharp.DestructorDeclaration destructorDeclaration, object data) - { - var finalizer = new MethodDeclaration() { Name = "Finalize", IsSub = true }; - - ConvertNodes(destructorDeclaration.Attributes, finalizer.Attributes); - ConvertNodes(destructorDeclaration.ModifierTokens, finalizer.ModifierTokens); - finalizer.Body = (BlockStatement)destructorDeclaration.Body.AcceptVisitor(this, data); - - return EndNode(destructorDeclaration, finalizer); - } - - public AstNode VisitEnumMemberDeclaration(CSharp.EnumMemberDeclaration enumMemberDeclaration, object data) - { - var result = new EnumMemberDeclaration(); - - ConvertNodes(enumMemberDeclaration.Attributes, result.Attributes); - result.Name = new Identifier(enumMemberDeclaration.Name, TextLocation.Empty); - result.Value = (Expression)enumMemberDeclaration.Initializer.AcceptVisitor(this, data); - - return EndNode(enumMemberDeclaration, result); - } - - public AstNode VisitEventDeclaration(CSharp.EventDeclaration eventDeclaration, object data) - { - members.Push(new MemberInfo()); - - foreach (var evt in eventDeclaration.Variables) { - var result = new EventDeclaration(); - - ConvertNodes(eventDeclaration.Attributes, result.Attributes); - if (types.Any()) { - if (types.Peek().ClassType == ClassType.Module) - eventDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - types.Peek().Members.Add(result); - } - result.Modifiers = ConvertModifiers(eventDeclaration.Modifiers, eventDeclaration); - result.Name = evt.Name; - result.ReturnType = (AstType)eventDeclaration.ReturnType.AcceptVisitor(this, data); - -// CreateImplementsClausesForEvent(result); - } - - members.Pop(); - - return EndNode(eventDeclaration, null); - } - - public AstNode VisitCustomEventDeclaration(CSharp.CustomEventDeclaration customEventDeclaration, object data) - { - var result = new EventDeclaration(); - - members.Push(new MemberInfo()); - - ConvertNodes(customEventDeclaration.Attributes, result.Attributes); - if (types.Any() && types.Peek().ClassType == ClassType.Module) - customEventDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - result.Modifiers = ConvertModifiers(customEventDeclaration.Modifiers, customEventDeclaration); - result.IsCustom = true; - result.Name = new Identifier(customEventDeclaration.Name, TextLocation.Empty); - result.ReturnType = (AstType)customEventDeclaration.ReturnType.AcceptVisitor(this, data); - if (!customEventDeclaration.PrivateImplementationType.IsNull) - result.ImplementsClause.Add( - new InterfaceMemberSpecifier((AstType)customEventDeclaration.PrivateImplementationType.AcceptVisitor(this, data), customEventDeclaration.Name)); -// else -// CreateImplementsClausesForEvent(result); - result.AddHandlerBlock = (Accessor)customEventDeclaration.AddAccessor.AcceptVisitor(this, data); - result.RemoveHandlerBlock = (Accessor)customEventDeclaration.RemoveAccessor.AcceptVisitor(this, data); - - members.Pop(); - - return EndNode(customEventDeclaration, result); - } - - public AstNode VisitFieldDeclaration(CSharp.FieldDeclaration fieldDeclaration, object data) - { - var decl = new FieldDeclaration(); - - members.Push(new MemberInfo()); - - ConvertNodes(fieldDeclaration.Attributes, decl.Attributes); - if (types.Any() && types.Peek().ClassType == ClassType.Module) - fieldDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - decl.Modifiers = ConvertModifiers(fieldDeclaration.Modifiers, fieldDeclaration); - ConvertNodes(fieldDeclaration.Variables, decl.Variables); - - members.Pop(); - - return EndNode(fieldDeclaration, decl); - } - - public AstNode VisitIndexerDeclaration(CSharp.IndexerDeclaration indexerDeclaration, object data) - { - var decl = new PropertyDeclaration(); - - members.Push(new MemberInfo()); - - ConvertNodes(indexerDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), decl.Attributes); - decl.Getter = (Accessor)indexerDeclaration.Getter.AcceptVisitor(this, data); - if (types.Any() && types.Peek().ClassType == ClassType.Module) - indexerDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - decl.Modifiers = ConvertModifiers(indexerDeclaration.Modifiers, indexerDeclaration); - decl.Name = new Identifier(indexerDeclaration.Name, TextLocation.Empty); - ConvertNodes(indexerDeclaration.Parameters, decl.Parameters); - ConvertNodes(indexerDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), decl.ReturnTypeAttributes); - if (!indexerDeclaration.PrivateImplementationType.IsNull) - decl.ImplementsClause.Add( - new InterfaceMemberSpecifier((AstType)indexerDeclaration.PrivateImplementationType.AcceptVisitor(this, data), - indexerDeclaration.Name)); - decl.ReturnType = (AstType)indexerDeclaration.ReturnType.AcceptVisitor(this, data); - decl.Setter = (Accessor)indexerDeclaration.Setter.AcceptVisitor(this, data); - - if (!decl.Setter.IsNull) { - decl.Setter.Parameters.Add(new ParameterDeclaration() { - Name = new Identifier("value", TextLocation.Empty), - Type = (AstType)indexerDeclaration.ReturnType.AcceptVisitor(this, data), - }); - } - - members.Pop(); - - return EndNode(indexerDeclaration, decl); - } - - public AstNode VisitMethodDeclaration(CSharp.MethodDeclaration methodDeclaration, object data) - { - CSharp.Attribute attr; - - if (types.Any() && types.Peek().ClassType == ClassType.Module) - methodDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - - if ((methodDeclaration.Modifiers & CSharp.Modifiers.Extern) == CSharp.Modifiers.Extern && HasAttribute(methodDeclaration.Attributes, "System.Runtime.InteropServices.DllImportAttribute", out attr)) { - var result = new ExternalMethodDeclaration(); - - members.Push(new MemberInfo()); - - // remove AttributeSection if only one attribute is present - var attrSec = (CSharp.AttributeSection)attr.Parent; - if (attrSec.Attributes.Count == 1) - attrSec.Remove(); - else - attr.Remove(); - - result.Library = (attr.Arguments.First().AcceptVisitor(this, data) as PrimitiveExpression).Value.ToString(); - result.CharsetModifier = ConvertCharset(attr.Arguments); - result.Alias = ConvertAlias(attr.Arguments); - - ConvertNodes(methodDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), result.Attributes); - ConvertNodes(methodDeclaration.ModifierTokens, result.ModifierTokens); - result.Name = new Identifier(methodDeclaration.Name, TextLocation.Empty); - result.IsSub = IsSub(methodDeclaration.ReturnType); - ConvertNodes(methodDeclaration.Parameters, result.Parameters); - ConvertNodes(methodDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), result.ReturnTypeAttributes); - if (!result.IsSub) - result.ReturnType = (AstType)methodDeclaration.ReturnType.AcceptVisitor(this, data); - - if (members.Pop().inIterator) { - result.Modifiers |= Modifiers.Iterator; - } - - return EndNode(methodDeclaration, result); - } else { - var result = new MethodDeclaration(); - - members.Push(new MemberInfo()); - - ConvertNodes(methodDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), result.Attributes); - ConvertNodes(methodDeclaration.ModifierTokens, result.ModifierTokens); - result.Name = new Identifier(methodDeclaration.Name, TextLocation.Empty); - result.IsSub = IsSub(methodDeclaration.ReturnType); - ConvertNodes(methodDeclaration.Parameters, result.Parameters); - ConvertNodes(methodDeclaration.TypeParameters, result.TypeParameters); - ConvertNodes(methodDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), result.ReturnTypeAttributes); - if (!methodDeclaration.PrivateImplementationType.IsNull) - result.ImplementsClause.Add( - new InterfaceMemberSpecifier((AstType)methodDeclaration.PrivateImplementationType.AcceptVisitor(this, data), - methodDeclaration.Name)); -// else -// CreateImplementsClausesForMethod(result); - if (!result.IsSub) - result.ReturnType = (AstType)methodDeclaration.ReturnType.AcceptVisitor(this, data); - - if (methodDeclaration.IsExtensionMethod) { - result.Attributes.Add( - new AttributeBlock { - Attributes = { - new Ast.Attribute { - Type = AstType.FromName("System.Runtime.CompilerServices.ExtensionAttribute") - } - } - }); - } - - result.Body = (BlockStatement)methodDeclaration.Body.AcceptVisitor(this, data); - - if (members.Pop().inIterator) { - result.Modifiers |= Modifiers.Iterator; - } - - return EndNode(methodDeclaration, result); - } - } - - void CreateImplementsClausesForMethod(MethodDeclaration result) - { - if (!types.Any()) return; - var current = types.Peek(); - if (current.ClassType == ClassType.Interface) - return; - - foreach (var type in current.ImplementsTypes) { - var resolved = provider.ResolveType(type, current); - var found = resolved.GetMembers(m => m.SymbolKind == SymbolKind.Method && m.Name == result.Name.Name); - if (found.FirstOrDefault() != null) { - result.ImplementsClause.Add(new InterfaceMemberSpecifier((AstType)type.Clone(), found.FirstOrDefault().Name)); - } - } - } - - void CreateImplementsClausesForEvent(EventDeclaration result) - { - if (!types.Any()) return; - var current = types.Peek(); - if (current.ClassType == ClassType.Interface) - return; - - foreach (var type in current.ImplementsTypes) { - var resolved = provider.ResolveType(type, current); - var found = resolved.GetMembers(m => m.SymbolKind == SymbolKind.Event && m.Name == result.Name.Name); - if (found.FirstOrDefault() != null) { - result.ImplementsClause.Add(new InterfaceMemberSpecifier((AstType)type.Clone(), found.FirstOrDefault().Name)); - } - } - } - - string ConvertAlias(CSharp.AstNodeCollection arguments) - { - var pattern = new CSharp.AssignmentExpression() { - Left = new CSharp.IdentifierExpression("EntryPoint"), - Operator = CSharp.AssignmentOperatorType.Assign, - Right = new AnyNode("alias") - }; - - var result = arguments - .Select(expr => pattern.Match(expr)) - .FirstOrDefault(r => r.Success); - - if (result.Success && result.Has("alias")) { - return result.Get("alias") - .First().Value.ToString(); - } - - return null; - } - - CharsetModifier ConvertCharset(CSharp.AstNodeCollection arguments) - { - var pattern = new CSharp.AssignmentExpression() { - Left = new CSharp.IdentifierExpression("CharSet"), - Operator = CSharp.AssignmentOperatorType.Assign, - Right = new NamedNode( - "modifier", - new CSharp.MemberReferenceExpression() { - Target = new CSharp.IdentifierExpression("CharSet"), - MemberName = Pattern.AnyString - }) - }; - - var result = arguments - .Select(expr => pattern.Match(expr)) - .FirstOrDefault(r => r.Success); - - if (result.Success && result.Has("modifier")) { - switch (result.Get("modifier").First().MemberName) { - case "Auto": - return CharsetModifier.Auto; - case "Ansi": - return CharsetModifier.Ansi; - case "Unicode": - return CharsetModifier.Unicode; - } - } - - return CharsetModifier.None; - } - - bool IsSub(CSharp.AstType returnType) - { - var t = returnType as CSharp.PrimitiveType; - return t != null && t.Keyword == "void"; - } - - public AstNode VisitOperatorDeclaration(CSharp.OperatorDeclaration operatorDeclaration, object data) - { - MemberDeclaration result; - members.Push(new MemberInfo()); - - if (types.Any() && types.Peek().ClassType == ClassType.Module) - operatorDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - - if (operatorDeclaration.OperatorType == CSharp.OperatorType.Increment || operatorDeclaration.OperatorType == CSharp.OperatorType.Decrement) { - var m = new MethodDeclaration(); - result = m; - - ConvertNodes(operatorDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), m.Attributes); - ConvertNodes(operatorDeclaration.ModifierTokens, m.ModifierTokens); - m.Name = operatorDeclaration.OperatorType == CSharp.OperatorType.Increment ? "op_Increment" : "op_Decrement"; - ConvertNodes(operatorDeclaration.Parameters, m.Parameters); - ConvertNodes(operatorDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), m.ReturnTypeAttributes); - m.ReturnType = (AstType)operatorDeclaration.ReturnType.AcceptVisitor(this, data); - m.Body = (BlockStatement)operatorDeclaration.Body.AcceptVisitor(this, data); - } else { - var op = new OperatorDeclaration(); - result = op; - - ConvertNodes(operatorDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), op.Attributes); - ConvertNodes(operatorDeclaration.ModifierTokens, op.ModifierTokens); - switch (operatorDeclaration.OperatorType) { - case CSharp.OperatorType.LogicalNot: - case CSharp.OperatorType.OnesComplement: - op.Operator = OverloadableOperatorType.Not; - break; - case CSharp.OperatorType.True: - op.Operator = OverloadableOperatorType.IsTrue; - break; - case CSharp.OperatorType.False: - op.Operator = OverloadableOperatorType.IsFalse; - break; - case CSharp.OperatorType.Implicit: - op.Modifiers |= Modifiers.Widening; - op.Operator = OverloadableOperatorType.CType; - break; - case CSharp.OperatorType.Explicit: - op.Modifiers |= Modifiers.Narrowing; - op.Operator = OverloadableOperatorType.CType; - break; - case CSharp.OperatorType.Addition: - op.Operator = OverloadableOperatorType.Add; - break; - case CSharp.OperatorType.Subtraction: - op.Operator = OverloadableOperatorType.Subtract; - break; - case CSharp.OperatorType.UnaryPlus: - op.Operator = OverloadableOperatorType.UnaryPlus; - break; - case CSharp.OperatorType.UnaryNegation: - op.Operator = OverloadableOperatorType.UnaryMinus; - break; - case CSharp.OperatorType.Multiply: - op.Operator = OverloadableOperatorType.Multiply; - break; - case CSharp.OperatorType.Division: - op.Operator = OverloadableOperatorType.Divide; - break; - case CSharp.OperatorType.Modulus: - op.Operator = OverloadableOperatorType.Modulus; - break; - case CSharp.OperatorType.BitwiseAnd: - op.Operator = OverloadableOperatorType.BitwiseAnd; - break; - case CSharp.OperatorType.BitwiseOr: - op.Operator = OverloadableOperatorType.BitwiseOr; - break; - case CSharp.OperatorType.ExclusiveOr: - op.Operator = OverloadableOperatorType.ExclusiveOr; - break; - case CSharp.OperatorType.LeftShift: - op.Operator = OverloadableOperatorType.ShiftLeft; - break; - case CSharp.OperatorType.RightShift: - op.Operator = OverloadableOperatorType.ShiftRight; - break; - case CSharp.OperatorType.Equality: - op.Operator = OverloadableOperatorType.Equality; - break; - case CSharp.OperatorType.Inequality: - op.Operator = OverloadableOperatorType.InEquality; - break; - case CSharp.OperatorType.GreaterThan: - op.Operator = OverloadableOperatorType.GreaterThan; - break; - case CSharp.OperatorType.LessThan: - op.Operator = OverloadableOperatorType.LessThan; - break; - case CSharp.OperatorType.GreaterThanOrEqual: - op.Operator = OverloadableOperatorType.GreaterThanOrEqual; - break; - case CSharp.OperatorType.LessThanOrEqual: - op.Operator = OverloadableOperatorType.LessThanOrEqual; - break; - default: - throw new Exception("Invalid value for OperatorType"); - } - ConvertNodes(operatorDeclaration.Parameters, op.Parameters); - ConvertNodes(operatorDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), op.ReturnTypeAttributes); - op.ReturnType = (AstType)operatorDeclaration.ReturnType.AcceptVisitor(this, data); - op.Body = (BlockStatement)operatorDeclaration.Body.AcceptVisitor(this, data); - } - - members.Pop(); - - return EndNode(operatorDeclaration, result); - - } - - public AstNode VisitParameterDeclaration(CSharp.ParameterDeclaration parameterDeclaration, object data) - { - var param = new ParameterDeclaration(); - - ConvertNodes(parameterDeclaration.Attributes, param.Attributes); - param.Modifiers = ConvertParamModifiers(parameterDeclaration.ParameterModifier); - if ((parameterDeclaration.ParameterModifier & CSharp.ParameterModifier.Out) == CSharp.ParameterModifier.Out) { - AttributeBlock block = new AttributeBlock(); - block.Attributes.Add(new Ast.Attribute() { Type = new SimpleType("Out") }); - param.Attributes.Add(block); - } - param.Name = new Identifier(parameterDeclaration.Name, TextLocation.Empty); - param.Type = (AstType)parameterDeclaration.Type.AcceptVisitor(this, data); - param.OptionalValue = (Expression)parameterDeclaration.DefaultExpression.AcceptVisitor(this, data); - if (!param.OptionalValue.IsNull) - param.Modifiers |= Modifiers.Optional; - - return EndNode(parameterDeclaration, param); - } - - Modifiers ConvertParamModifiers(CSharp.ParameterModifier mods) - { - switch (mods) { - case CSharp.ParameterModifier.None: - case CSharp.ParameterModifier.This: - return Modifiers.None; - case CSharp.ParameterModifier.Ref: - case CSharp.ParameterModifier.Out: - return Modifiers.ByRef; - case CSharp.ParameterModifier.Params: - return Modifiers.ParamArray; - default: - throw new Exception("Invalid value for ParameterModifier"); - } - } - - public AstNode VisitPropertyDeclaration(CSharp.PropertyDeclaration propertyDeclaration, object data) - { - var decl = new PropertyDeclaration(); - - members.Push(new MemberInfo()); - - if (types.Any() && types.Peek().ClassType == ClassType.Module) - propertyDeclaration.Modifiers &= ~CSharp.Modifiers.Static; - - ConvertNodes(propertyDeclaration.Attributes.Where(section => section.AttributeTarget != "return"), decl.Attributes); - decl.Getter = (Accessor)propertyDeclaration.Getter.AcceptVisitor(this, data); - decl.Modifiers = ConvertModifiers(propertyDeclaration.Modifiers, propertyDeclaration); - decl.Name = new Identifier(propertyDeclaration.Name, TextLocation.Empty); - ConvertNodes(propertyDeclaration.Attributes.Where(section => section.AttributeTarget == "return"), decl.ReturnTypeAttributes); - if (!propertyDeclaration.PrivateImplementationType.IsNull) - decl.ImplementsClause.Add( - new InterfaceMemberSpecifier((AstType)propertyDeclaration.PrivateImplementationType.AcceptVisitor(this, data), - propertyDeclaration.Name)); - decl.ReturnType = (AstType)propertyDeclaration.ReturnType.AcceptVisitor(this, data); - decl.Setter = (Accessor)propertyDeclaration.Setter.AcceptVisitor(this, data); - - if (!decl.Setter.IsNull) { - decl.Setter.Parameters.Add(new ParameterDeclaration() { - Name = new Identifier("value", TextLocation.Empty), - Type = (AstType)propertyDeclaration.ReturnType.AcceptVisitor(this, data), - }); - } - - if (members.Pop().inIterator) { - decl.Modifiers |= Modifiers.Iterator; - } - - ConvertNodes(provider.GetParametersForProperty(propertyDeclaration), decl.Parameters); - - return EndNode(propertyDeclaration, decl); - } - - public AstNode VisitVariableInitializer(CSharp.VariableInitializer variableInitializer, object data) - { - var decl = new VariableDeclaratorWithTypeAndInitializer(); - - // look for type in parent - decl.Type = (AstType)variableInitializer.Parent - .GetChildByRole(CSharp.Roles.Type) - .AcceptVisitor(this, data); - decl.Identifiers.Add(new VariableIdentifier() { Name = variableInitializer.Name }); - decl.Initializer = (Expression)variableInitializer.Initializer.AcceptVisitor(this, data); - - return EndNode(variableInitializer, decl); - } - - public AstNode VisitFixedFieldDeclaration(CSharp.FixedFieldDeclaration fixedFieldDeclaration, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitFixedVariableInitializer(CSharp.FixedVariableInitializer fixedVariableInitializer, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitSyntaxTree(CSharp.SyntaxTree syntaxTree, object data) - { - var unit = new CompilationUnit(); - - foreach (var node in syntaxTree.Children) - unit.AddChild(node.AcceptVisitor(this, null), CompilationUnit.MemberRole); - - return EndNode(syntaxTree, unit); - } - - public AstNode VisitSimpleType(CSharp.SimpleType simpleType, object data) - { - var type = new SimpleType(simpleType.Identifier); - ConvertNodes(simpleType.TypeArguments, type.TypeArguments); - - return EndNode(simpleType, type); - } - - public AstNode VisitMemberType(CSharp.MemberType memberType, object data) - { - AstType target = null; - - if (memberType.Target is CSharp.SimpleType && ((CSharp.SimpleType)(memberType.Target)).Identifier.Equals("global", StringComparison.Ordinal)) - target = new PrimitiveType("Global"); - else - target = (AstType)memberType.Target.AcceptVisitor(this, data); - - var type = new QualifiedType(target, new Identifier(memberType.MemberName, TextLocation.Empty)); - ConvertNodes(memberType.TypeArguments, type.TypeArguments); - - return EndNode(memberType, type); - } - - public AstNode VisitComposedType(CSharp.ComposedType composedType, object data) - { - AstType type = new ComposedType(); - - ConvertNodes(composedType.ArraySpecifiers, ((ComposedType)type).ArraySpecifiers); - ((ComposedType)type).BaseType = (AstType)composedType.BaseType.AcceptVisitor(this, data); - ((ComposedType)type).HasNullableSpecifier = composedType.HasNullableSpecifier; - - for (int i = 0; i < composedType.PointerRank; i++) { - var tmp = new SimpleType() { Identifier = "__Pointer" }; - tmp.TypeArguments.Add(type); - type = tmp; - } - - return EndNode(composedType, type); - } - - public AstNode VisitArraySpecifier(CSharp.ArraySpecifier arraySpecifier, object data) - { - return EndNode(arraySpecifier, new ArraySpecifier(arraySpecifier.Dimensions)); - } - - public AstNode VisitPrimitiveType(CSharp.PrimitiveType primitiveType, object data) - { - string typeName; - - switch (primitiveType.Keyword) { - case "object": - typeName = "Object"; - break; - case "bool": - typeName = "Boolean"; - break; - case "char": - typeName = "Char"; - break; - case "sbyte": - typeName = "SByte"; - break; - case "byte": - typeName = "Byte"; - break; - case "short": - typeName = "Short"; - break; - case "ushort": - typeName = "UShort"; - break; - case "int": - typeName = "Integer"; - break; - case "uint": - typeName = "UInteger"; - break; - case "long": - typeName = "Long"; - break; - case "ulong": - typeName = "ULong"; - break; - case "float": - typeName = "Single"; - break; - case "double": - typeName = "Double"; - break; - case "decimal": - typeName = "Decimal"; - break; - case "string": - typeName = "String"; - break; - // generic constraints - case "new": - typeName = "New"; - break; - case "struct": - typeName = "Structure"; - break; - case "class": - typeName = "Class"; - break; - case "void": - typeName = "Void"; - break; - default: - typeName = "unknown"; - break; - } - - return EndNode(primitiveType, new PrimitiveType(typeName)); - } - - public AstNode VisitComment (CSharp.Comment comment, object data) - { - var c = new Comment (comment.Content, comment.CommentType == CSharp.CommentType.Documentation); - - if (comment.CommentType == CSharp.CommentType.MultiLine) - throw new NotImplementedException (); - - return EndNode (comment, c); - } - - public AstNode VisitPreProcessorDirective (CSharp.PreProcessorDirective preProcessorDirective, object data) - { - // TODO - return null; - } - - public AstNode VisitTypeParameterDeclaration(CSharp.TypeParameterDeclaration typeParameterDeclaration, object data) - { - var param = new TypeParameterDeclaration() { - Variance = typeParameterDeclaration.Variance, - Name = typeParameterDeclaration.Name - }; - - var constraint = typeParameterDeclaration.Parent - .GetChildrenByRole(CSharp.Roles.Constraint) - .SingleOrDefault(c => c.TypeParameter.Identifier == typeParameterDeclaration.Name); - - if (constraint != null) - ConvertNodes(constraint.BaseTypes, param.Constraints); - - // TODO : typeParameterDeclaration.Attributes get lost? - //ConvertNodes(typeParameterDeclaration.Attributes - - return EndNode(typeParameterDeclaration, param); - } - - public AstNode VisitConstraint(CSharp.Constraint constraint, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitCSharpTokenNode(CSharp.CSharpTokenNode cSharpTokenNode, object data) - { - var mod = cSharpTokenNode as CSharp.CSharpModifierToken; - if (mod != null) { - var convertedModifiers = ConvertModifiers(mod.Modifier, mod.Parent); - VBModifierToken token = null; - if (convertedModifiers != Modifiers.None) { - token = new VBModifierToken(TextLocation.Empty, convertedModifiers); - return EndNode(cSharpTokenNode, token); - } - return EndNode(cSharpTokenNode, token); - } else { - throw new NotSupportedException("Should never visit individual tokens"); - } - } - - Modifiers ConvertModifiers(CSharp.Modifiers modifier, CSharp.AstNode container) - { - if ((modifier & CSharp.Modifiers.Any) == CSharp.Modifiers.Any) - return Modifiers.Any; - - var mod = Modifiers.None; - - if ((modifier & CSharp.Modifiers.Const) == CSharp.Modifiers.Const) - mod |= Modifiers.Const; - if ((modifier & CSharp.Modifiers.Abstract) == CSharp.Modifiers.Abstract) { - if (container is CSharp.TypeDeclaration) - mod |= Modifiers.MustInherit; - else - mod |= Modifiers.MustOverride; - } - if ((modifier & CSharp.Modifiers.Static) == CSharp.Modifiers.Static) - mod |= Modifiers.Shared; - - if ((modifier & CSharp.Modifiers.Public) == CSharp.Modifiers.Public) - mod |= Modifiers.Public; - if ((modifier & CSharp.Modifiers.Protected) == CSharp.Modifiers.Protected) - mod |= Modifiers.Protected; - if ((modifier & CSharp.Modifiers.Internal) == CSharp.Modifiers.Internal) - mod |= Modifiers.Friend; - if ((modifier & CSharp.Modifiers.Private) == CSharp.Modifiers.Private) - mod |= Modifiers.Private; - if (container is CSharp.IndexerDeclaration) - mod |= Modifiers.Default; - bool writeable = IsWriteableProperty(container); - bool readable = IsReadableProperty(container); - if (writeable && !readable) - mod |= Modifiers.WriteOnly; - if (readable && !writeable) - mod |= Modifiers.ReadOnly; - - if ((modifier & CSharp.Modifiers.Override) == CSharp.Modifiers.Override) - mod |= Modifiers.Overrides; - if ((modifier & CSharp.Modifiers.Virtual) == CSharp.Modifiers.Virtual) - mod |= Modifiers.Overridable; - if ((modifier & CSharp.Modifiers.Async) == CSharp.Modifiers.Async) - mod |= Modifiers.Async; - - return mod; - } - - bool IsReadableProperty(ICSharpCode.NRefactory.CSharp.AstNode container) - { - if (container is CSharp.IndexerDeclaration) { - var i = container as CSharp.IndexerDeclaration; - return !i.Getter.IsNull; - } - - if (container is CSharp.PropertyDeclaration) { - var p = container as CSharp.PropertyDeclaration; - return !p.Getter.IsNull; - } - - return false; - } - - bool IsWriteableProperty(ICSharpCode.NRefactory.CSharp.AstNode container) - { - if (container is CSharp.IndexerDeclaration) { - var i = container as CSharp.IndexerDeclaration; - return !i.Setter.IsNull; - } - - if (container is CSharp.PropertyDeclaration) { - var p = container as CSharp.PropertyDeclaration; - return !p.Setter.IsNull; - } - - return false; - } - - public AstNode VisitIdentifier(CSharp.Identifier identifier, object data) - { - var ident = new Identifier(identifier.Name, identifier.StartLocation); - - return EndNode(identifier, ident); - } - - public AstNode VisitPatternPlaceholder(CSharp.AstNode placeholder, ICSharpCode.NRefactory.PatternMatching.Pattern pattern, object data) - { - throw new NotImplementedException(); - } - - void ConvertNodes(IEnumerable nodes, VB.AstNodeCollection result, Func transform = null) where T: VB.AstNode - { - foreach (var node in nodes) { - T n = (T)node.AcceptVisitor(this, null); - if (transform != null) - n = transform(n); - if (n != null) - result.Add(n); - } - } - - void ConvertMembers(CSharp.AstNode parent, T result, Role sourceRole, Role targetRole) where T : VB.AstNode where S : CSharp.AstNode where M : VB.AstNode - { - foreach (var node in parent.Children) { - if (node.Role == CSharp.Roles.Comment) { - var n = (Comment)node.AcceptVisitor(this, null); - if (n != null) - result.AddChild(n, AstNode.Roles.Comment); - } - - if (node.Role == sourceRole) { - var n = (M)node.AcceptVisitor(this, null); - if (n != null) - result.AddChild(n, targetRole); - } - } - } - - T EndNode(CSharp.AstNode node, T result) where T : VB.AstNode - { - if (result != null) { - CopyAnnotations(node, result); - } - - return result; - } - - void CopyAnnotations(CSharp.AstNode node, T result) where T : VB.AstNode - { - foreach (var ann in node.Annotations) - result.AddAnnotation(ann); - } - - bool HasAttribute(CSharp.AstNodeCollection attributes, string name, out CSharp.Attribute foundAttribute) - { - foreach (var attr in attributes.SelectMany(a => a.Attributes)) { - if (provider.GetTypeNameForAttribute(attr) == name) { - foundAttribute = attr; - return true; - } - } - foundAttribute = null; - return false; - } - - public AstNode VisitDocumentationReference(CSharp.DocumentationReference documentationReference, object data) - { - throw new NotImplementedException(); - } - - public AstNode VisitNewLine(CSharp.NewLineNode newLineNode, object data) - { - return null; - } - - public AstNode VisitWhitespace(CSharp.WhitespaceNode whitespaceNode, object data) - { - return null; - } - - public AstNode VisitText(CSharp.TextNode textNode, object data) - { - return null; - } - - public AstNode VisitNullNode(ICSharpCode.NRefactory.CSharp.AstNode nullNode, object data) - { - return null; - } - - public AstNode VisitErrorNode(ICSharpCode.NRefactory.CSharp.AstNode errorNode, object data) - { - return null; - } - } -}