Skip to content

Commit

Permalink
Added support for the virtual Apex class modifier (converted to the V…
Browse files Browse the repository at this point in the history
…irtual attribute).
  • Loading branch information
yallie committed Oct 17, 2018
1 parent bf18695 commit f422371
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EditorConfig: http://EditorConfig.org
# VS extension: https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328

# tab indentation
[*.cs]
indent_style = space
indent_size = 4
4 changes: 4 additions & 0 deletions ApexParser/Visitors/ApexSyntaxBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ private object ConvertClassAnnotation(ApexAnnotationSyntax node)
{
return ApexKeywords.Global;
}
else if (node.Identifier == "Virtual")
{
return ApexKeywords.Virtual;
}
else if (node.Identifier == "WithSharing")
{
return $"{ApexKeywords.With} {ApexKeywords.Sharing}";
Expand Down
4 changes: 4 additions & 0 deletions ApexParser/Visitors/CSharpCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ protected override IAnnotatedSyntax ConvertModifiersAndAnnotations(IAnnotatedSyn
result.Annotations.Add(new AnnotationSyntax("Global"));
isGlobal = true;
}
else if (modifier == ApexKeywords.Virtual && ownerNode is ClassDeclarationSyntax)
{
result.Annotations.Add(new AnnotationSyntax("Virtual"));
}
else if (modifier.StartsWith(ApexKeywords.Without))
{
result.Annotations.Add(new AnnotationSyntax("WithoutSharing"));
Expand Down
1 change: 1 addition & 0 deletions ApexParserTest/Visitors/ApexSyntaxBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public void ApexClassAttributesAreConvertedToModifiers()
Check("[Global] public class X {}", "global class X {}");
Check("[WithSharing] public class X {}", "public with sharing class X {}");
Check("[WithoutSharing] public class X {}", "public without sharing class X {}");
Check("[Virtual] public class X {}", "public virtual class X {}");
}

[Test]
Expand Down
6 changes: 6 additions & 0 deletions ApexParserTest/Visitors/CSharpGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ public void UnsupportedModifiersGetConvertedIntoAttributes()
public global class TestClass {
private with sharing class Inner1 { }
public without sharing class Inner2 { }
public virtual class Inner3 { }
private testMethod void MyTest(final int x) { }
public webservice void MyService() { }
transient int TransientField = 0;
Expand Down Expand Up @@ -949,6 +950,11 @@ public class Inner2
{
}
[Virtual]
public class Inner3
{
}
[Test]
private void MyTest([Final] int x)
{
Expand Down

0 comments on commit f422371

Please sign in to comment.