public override void DefaultVisit(BaseSyntax node) { foreach (var child in node.ChildNodes) { child.Accept(this); } }
public static string GenerateApex(BaseSyntax ast, int tabSize = 4) { var generator = new ApexCleanCodeGen { IndentSize = tabSize }; ast.Accept(generator); return(generator.Code.ToString()); }
protected void Check(BaseSyntax node, string expected) { string nows(string s) => NoWhitespaceRegex.Replace(s, string.Empty); var nodeToApex = node.ToApex(); Assert.AreEqual(nows(expected), nows(nodeToApex)); CompareLineByLine(nodeToApex, ApexSharpParser.IndentApex(expected)); }
public static string GenerateCSharp(BaseSyntax ast, int tabSize = 4, string @namespace = null) { var options = new ApexSharpParserOptions { TabSize = tabSize }; if (!string.IsNullOrWhiteSpace(@namespace)) { options.Namespace = @namespace; } return(GenerateCSharp(ast, options)); }
public static string GenerateCSharp(BaseSyntax ast, int tabSize = 4, string @namespace = null) { var generator = new CSharpCodeGenerator { IndentSize = tabSize }; if (!string.IsNullOrWhiteSpace(@namespace)) { generator.Namespace = @namespace; } ast.Accept(generator); return(generator.Code.ToString()); }
public static string GenerateCSharp(BaseSyntax ast, ApexSharpParserOptions options) { // set default options options = options ?? new ApexSharpParserOptions(); var generator = new CSharpCodeGenerator { IndentSize = options.TabSize, Namespace = options.Namespace, UseLocalSObjectsNamespace = options.UseLocalSObjectsNamespace, }; ast.Accept(generator); return(generator.Code.ToString()); }
public static string GenerateApex(BaseSyntax ast, Settings settings = null) { if (ast == null) { return(string.Empty); } settings = settings ?? new Settings(); var generator = new CustomApexCodeGenerator { Settings = settings, IndentSize = settings.TabIndentSize }; ast.Accept(generator); return(generator.Code.ToString()); }
internal static AnnotationSyntax ConvertUnitTestAnnotation(AnnotationSyntax node, BaseSyntax parentNode) { // TODO: refactor this method out of CSharpCodeGenerator if (!node.IsTest) { return(node); } if (parentNode is ClassDeclarationSyntax) { // IsTest => TestFixture if (string.Equals(node.Identifier, ApexKeywords.IsTest, StringComparison.OrdinalIgnoreCase)) { return(new AnnotationSyntax { LeadingComments = node.LeadingComments, Identifier = "TestFixture", Parameters = node.Parameters, TrailingComments = node.TrailingComments, }); } } else if (parentNode is MethodDeclarationSyntax) { // IsTest => Test if (string.Equals(node.Identifier, ApexKeywords.IsTest, StringComparison.OrdinalIgnoreCase)) { return(new AnnotationSyntax { LeadingComments = node.LeadingComments, Identifier = "Test", Parameters = node.Parameters, TrailingComments = node.TrailingComments, }); } // TestSetup => SetUp else if (string.Equals(node.Identifier, ApexKeywords.TestSetup, StringComparison.OrdinalIgnoreCase)) { return(new AnnotationSyntax { LeadingComments = node.LeadingComments, Identifier = "SetUp", Parameters = node.Parameters, TrailingComments = node.TrailingComments, }); } } return(node); }
public virtual void DefaultVisit(BaseSyntax node) { }
protected virtual void AppendTrailingComments(BaseSyntax node) => AppendComments(node?.TrailingComments, indentFirst: false);
public static string ToCSharp(this BaseSyntax node, ApexSharpParserOptions options) => CSharpCodeGenerator.GenerateCSharp(node, options);
protected void Check(BaseSyntax node, string expected) => CompareLineByLine(node.ToApex(), expected);
public static string ToCSharp(this BaseSyntax node, int tabSize = 4, string @namespace = null) => CSharpCodeGenerator.GenerateCSharp(node, tabSize, @namespace);
// Convert Apex AST to C# public static string ConvertToCSharp(BaseSyntax ast, string @namespace = null) { return(ast.ToCSharp(@namespace: @namespace)); }
protected virtual void AppendLeadingComments(BaseSyntax node) => AppendComments(node?.LeadingComments);
public static string ToApex(this BaseSyntax node, int tabSize = 4) => ApexCodeGenerator.GenerateApex(node, tabSize);
protected void Check(BaseSyntax node, string expected) {