Browse Source

Fixed enumerations with base type in VB output visitor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@829 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
10e90d3769
  1. 21
      src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs
  2. 2325
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs
  3. 3
      src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG
  4. 6
      src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs
  5. 16
      src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs

21
src/Libraries/NRefactory/Project/Src/Output/VBNet/VBNetOutputVisitor.cs

@ -112,13 +112,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -112,13 +112,13 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
return "Object";
case "System.UInt64":
return "System.UInt64";
return "ULong";
case "System.UInt32":
return "System.UInt32";
return "UInt";
case "System.UInt16":
return "System.UInt16";
return "UShort";
case "System.SByte":
return "System.SByte";
return "SByte";
}
return typeString;
}
@ -324,9 +324,20 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -324,9 +324,20 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
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) {
nodeTracker.TrackedVisit(baseTypeRef, data);
}
}
outputFormatter.NewLine();
if (typeDeclaration.BaseTypes != null) {
if (typeDeclaration.BaseTypes != null && typeDeclaration.Type != ClassType.Enum) {
foreach (TypeReference baseTypeRef in typeDeclaration.BaseTypes) {
outputFormatter.Indent();

2325
src/Libraries/NRefactory/Project/Src/Parser/VBNet/Parser.cs

File diff suppressed because it is too large Load Diff

3
src/Libraries/NRefactory/Project/Src/Parser/VBNet/VBNET.ATG

@ -644,7 +644,6 @@ TypeParameterConstraints<TemplateDefinition template> @@ -644,7 +644,6 @@ TypeParameterConstraints<TemplateDefinition template>
/* 6.4.2 */
NonModuleDeclaration<Modifiers m, List<AttributeSection> attributes>
(.
string name = null;
TypeReference typeRef = null;
List<TypeReference> baseInterfaces = null;
.) =
@ -710,7 +709,7 @@ NonModuleDeclaration<Modifiers m, List<AttributeSection> attributes> @@ -710,7 +709,7 @@ NonModuleDeclaration<Modifiers m, List<AttributeSection> attributes>
newType.Type = ClassType.Enum;
.)
Identifier (. newType.Name = t.val; .)
[ "As" PrimitiveTypeName<out name> (. newType.BaseTypes.Add(new TypeReference(name)); .) ]
[ "As" NonArrayTypeName<out typeRef, false> (. newType.BaseTypes.Add(typeRef); .) ]
EOL
EnumBody<newType>
(.

6
src/Libraries/NRefactory/Test/Output/VBNet/VBNetOutputTest.cs

@ -66,6 +66,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter @@ -66,6 +66,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestTypeMember("Sub Method()\nEnd Sub");
}
[Test]
public void EnumWithBaseType()
{
TestProgram("Public Enum Foo As UShort\nEnd Enum");
}
[Test]
public void PartialModifier()
{

16
src/Libraries/NRefactory/Test/Parser/GlobalScope/TypeDeclarationTests.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
@ -184,6 +184,20 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2 @@ -184,6 +184,20 @@ public abstract class MyClass : MyBase, Interface1, My.Test.Interface2
Assert.AreEqual("TestEnum", td.Name);
Assert.AreEqual(ClassType.Enum, td.Type);
Assert.AreEqual("Byte", td.BaseTypes[0].Type);
Assert.AreEqual(0, td.Children.Count);
}
[Test]
public void VBNetEnumWithSystemBaseClassDeclarationTest()
{
string program = "Enum TestEnum As System.UInt16\n" +
"End Enum\n";
TypeDeclaration td = ParseUtilVBNet.ParseGlobal<TypeDeclaration>(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]

Loading…
Cancel
Save