public override string AddBaseTypeToClass(string existingCode, IClass targetClass, IClass newBaseType) { NR.IParser parser = ParseFile(null, existingCode); if (parser == null) { return(null); } AddTypeToBaseTypesVisitor addTypeToBaseTypesVisitor = new AddTypeToBaseTypesVisitor(targetClass, newBaseType); parser.CompilationUnit.AcceptVisitor(addTypeToBaseTypesVisitor, null); // now use an output visitor for the appropriate language (based on // extension of the existing code file) to format the new interface. IOutputAstVisitor output = GetOutputVisitor(); // run the output visitor with the specials inserter to insert comments using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(), output)) { parser.CompilationUnit.AcceptVisitor(output, null); } parser.Dispose(); if (output.Errors.Count > 0) { ShowSourceCodeErrors(null, output.Errors.ErrorOutput); return(null); } return(output.Text); }
public override string AddBaseTypeToClass(string existingCode, IClass targetClass, IClass newBaseType) { NR.IParser parser = ParseFile(null, existingCode); if (parser == null) { return null; } AddTypeToBaseTypesVisitor addTypeToBaseTypesVisitor = new AddTypeToBaseTypesVisitor(targetClass, newBaseType); parser.CompilationUnit.AcceptVisitor(addTypeToBaseTypesVisitor, null); // now use an output visitor for the appropriate language (based on // extension of the existing code file) to format the new interface. IOutputAstVisitor output = GetOutputVisitor(); // run the output visitor with the specials inserter to insert comments using (SpecialNodesInserter.Install(parser.Lexer.SpecialTracker.RetrieveSpecials(), output)) { parser.CompilationUnit.AcceptVisitor(output, null); } parser.Dispose(); if (output.Errors.Count > 0) { ShowSourceCodeErrors(null, output.Errors.ErrorOutput); return null; } return output.Text; }