use of org.eclipse.titan.codegenerator.SourceCode in project titan.EclipsePlug-ins by eclipse.
the class ModuleConstants method getJavaSource.
@Override
public String getJavaSource() {
SourceCode code = new SourceCode();
code.line("public class ", getClassName(), " {");
for (Constant c : constants) {
code.newLine();
code.indent(1).line("public static ", c.type, " ", c.name, "() {");
code.indent(2).append("return ").write(2, c.value).line(";");
code.indent(1).line("}");
}
code.line("}");
return code.toString();
}
use of org.eclipse.titan.codegenerator.SourceCode in project titan.EclipsePlug-ins by eclipse.
the class ModuleTemplates method getJavaSource.
@Override
public String getJavaSource() {
SourceCode code = new SourceCode();
code.line("public class ", getClassName(), " {");
for (Template t : templates) {
code.newLine();
StringJoiner params = new StringJoiner(", ");
t.getParameters().forEach(field -> params.add(field.toString()));
code.indent(1).line("public static ", t.getType(), " ", t.getName(), "(", params, ") {");
Value value = t.getValue();
if (value == null) {
code.append(null, " /* Unexpected null value! */");
} else {
code.indent(2).append(value.getType(), " value = ");
value.write(code, 2);
}
code.line(";");
for (Modification m : t.getModifications()) {
code.indent(2).append("value", m.path(), " = ");
m.write(code, 2);
code.line(";");
}
code.indent(2).line("return value;");
code.indent(1).line("}");
}
code.line("}");
return code.toString();
}
Aggregations