public void ProcessFile(FileInfo file, char[] whitespace, CodeCompileUnit unit) { CommentLineContext commentLineContext = new CommentLineContext(null, null, false); List <string> importNamespaces = new List <string>(); // namespaces to import StringBuilder currentNamespaceBuilder = new StringBuilder(); Action <string> currentNamespaceAppender = s => { if (currentNamespaceBuilder.Length > 0) { currentNamespaceBuilder.Append("."); } currentNamespaceBuilder.Append(s); }; StreamReader reader = new StreamReader(file.FullName, true); int lineNumber = 1; for (string line = reader.ReadLine(); line != null; line = reader.ReadLine(), lineNumber++) { string lineArgument; CodeLineType lineType = _languageProvider.ParseLine(line, out lineArgument); if (lineType == CodeLineType.NamespaceImport) { ProcessNamespaceImportLine(importNamespaces, lineArgument); } else if (lineType == CodeLineType.NamespaceDeclaration) { ProcessNamespaceDeclarationLine(lineArgument, currentNamespaceAppender); } else if (lineType == CodeLineType.LineComment) { commentLineContext = ProcessCommentLine(file, line, lineArgument, commentLineContext, whitespace, lineNumber); if (commentLineContext.IsXmlFragmentComplete) { continue; } } else if (lineType == CodeLineType.ClassDeclaration) { if (!commentLineContext.IsXmlFragmentComplete && commentLineContext.XmlFragmentContext != null) { ProcessXmlFragment(commentLineContext.XmlFragmentContext, file); } ProcessClassDeclarationLine(lineArgument, currentNamespaceBuilder.ToString(), commentLineContext.FunctionDeclaration); break; } } if (commentLineContext.IsXmlFragmentComplete && commentLineContext.FunctionDeclaration != null) { GenerateClass(file, importNamespaces, commentLineContext.FunctionDeclaration, unit, commentLineContext.XmlFragmentContext.FirstLineNumber); } }
public int DOI { get; set; } //to store doi public LineEntity(int lineNumber, LineEntity parent, CodeLineType type) { this.LineNumber = lineNumber; if (parent != null) { this.Parent = parent; this.LineDepth = parent.LineDepth + 1; } else //is root { this.Parent = null; this.LineDepth = 0; } this.Type = type; this.DisT = DisplayType.Origin; this.Children = new List<LineEntity>(); this.DOI = 0; }
public CodeLine(CodeLineType type, string target) { CodeActionType = type; Target = target; }
public CodeAction(CodeLineType type, string varType, string target, string codeNamespace = "") : base(type, target) { VariableType = varType; Namespace = codeNamespace; }
public CodeFunction(CodeLineType type, string returnType, string target, string functionName, string[] parameterTypes, string[] parameterValues) : base(type, returnType, target) { FunctionName = functionName; ParameterTypes = parameterTypes; ParameterValues = parameterValues; }