/** * Replaces parameters in element names (even if detected as a * substring). */ @Override public void scanCtNamedElement(CtNamedElement element) { if (element.getDocComment() != null) { element.setDocComment(substituteInDocComment(element.getDocComment())); } // replace parameters in names String name = element.getSimpleName(); for (String pname : parameterNames) { if (name.contains(pname)) { Object value = Parameters.getValue(template, pname, null); if (value instanceof String) { // replace with the string value name = name.replace(pname, (String) value); element.setSimpleName(name); } else if ((value instanceof CtTypeReference) && (element instanceof CtType)) { // replace with the type reference's name name = name.replace(pname, ((CtTypeReference<?>) value).getSimpleName()); element.setSimpleName(name); } } } super.scanCtNamedElement(element); }
public void visitCtNamedElement(CtNamedElement e) { // Write comments if (!env.isPreserveLineNumbers() && env.isGenerateJavadoc() && (e.getDocComment() != null)) { write("/** ").writeln().writeTabs(); String[] lines = e.getDocComment().split("\n"); for (int i = 0; i < lines.length; i++) { String com = lines[i].trim(); if ("".equals(com) && (i == 0 || i == lines.length - 1)) { continue; } if (com.startsWith("//")) { write(com).writeln().writeTabs(); } else { write(" * " + com).writeln().writeTabs(); } } write(" */").writeln(); } // Write element parameters (Annotations) writeAnnotations(e); if (env.isPreserveLineNumbers()) { adjustPosition(e); } }