public static void generateStubs(Framework framework, File location) { final StringBuilder builder = new StringBuilder(); builder .append("# This is a machine generated stub for: ") .append(framework.getName()) .append("\n"); builder .append("# Created on: ") .append(DateFormatUtil.formatDateTime(new Date())) .append("\n\n"); for (Class aClass : framework.getClasses()) { generateClassStub(builder, framework, aClass); } for (Function function : framework.getFunctions()) { generateFunctionStub(builder, function, ""); } for (Constant constant : framework.getConstants()) { generateConstantStub(builder, constant); } for (Map.Entry<String, String> entry : framework.getFunctionAliases().entrySet()) { generateAlias(builder, entry); } try { FileUtil.writeToFile(location, builder.toString()); } catch (Throwable ignored) { } }
private static void generateClassStub(StringBuilder builder, Framework framework, Class aClass) { builder.append("class ").append(aClass.getName()); final String parent = InheritanceInfoHolder.getInstance() .getInheritance(aClass.getName(), framework.getVersion()); if (parent != null) { builder.append(" < ").append(parent); } builder.append("\n"); for (Function function : aClass.getFunctions()) { generateFunctionStub(builder, function, " "); } builder.append("end\n\n"); }