using CodePlay.Core.Models; using CodePlay.Core.Common; namespace CodePlay.Core.Interfaces; public interface IParser { Task ParseAsync(string sourceCode, CancellationToken cancellationToken = default); } public interface IConverter { Task ConvertAsync(SyntaxTree syntaxTree, LanguageType targetLanguage, ConversionOptions? options = null, CancellationToken cancellationToken = default); } public interface ICodeGenerator { string Generate(SyntaxTree syntaxTree); } public interface ICompilerValidator { Task ValidateAsync(string code, LanguageType targetLanguage, CancellationToken cancellationToken = default); } public interface IAutoFixEngine { Task FixAsync(string code, List errors, int round, CancellationToken cancellationToken = default); } public interface IConversionStrategy { LanguageType SourceLanguage { get; } LanguageType TargetLanguage { get; } SyntaxNode ConvertNode(SyntaxNode node, ConversionContext context); string MapType(string sourceType); } public class SyntaxTree { public LanguageType Language { get; set; } public SyntaxNode Root { get; set; } = new(); public string? SourceFilePath { get; set; } public string? SourceCode { get; set; } public List Comments { get; set; } = new(); public List Documentation { get; set; } = new(); } public class SyntaxNode { public SyntaxNodeType Type { get; set; } public string Text { get; set; } = string.Empty; public List Children { get; set; } = new(); public Dictionary Metadata { get; set; } = new(); public SyntaxNode? Parent { get; set; } public bool IsUnconvertible { get; set; } public string? TodoDescription { get; set; } } public enum SyntaxNodeType { Unknown = 0, CompilationUnit = 1, Namespace = 2, Class = 3, Interface = 4, Method = 5, Property = 6, Field = 7, Constructor = 8, Statement = 9, Expression = 10, Type = 11, Parameter = 12, Comment = 13, DocumentationComment = 14 } public class SyntaxComment { public CommentType Type { get; set; } public string Text { get; set; } = string.Empty; public int LineNumber { get; set; } } public enum CommentType { SingleLine = 0, MultiLine = 1, XmlDoc = 2, JavaDoc = 3, Doxygen = 4 } public class SyntaxDocumentation { public string ElementName { get; set; } = string.Empty; public string Content { get; set; } = string.Empty; public DocFormat Format { get; set; } } public enum DocFormat { XmlDoc = 0, JavaDoc = 1, Doxygen = 2 } public class ConversionContext { public LanguageType SourceLanguage { get; set; } public LanguageType TargetLanguage { get; set; } public ConversionOptions? Options { get; set; } public List Issues { get; set; } = new(); public List TodoItems { get; set; } = new(); public List Logs { get; set; } = new(); } public class FixResult { public bool CanFix { get; set; } public string? FixedCode { get; set; } public string? FixDescription { get; set; } public List RemainingErrors { get; set; } = new(); } public class CompilationResult { public bool Success { get; set; } public string Output { get; set; } = string.Empty; public List Errors { get; set; } = new(); public List Warnings { get; set; } = new(); }