private void injectToStringMethod(ClassNode classNode) { final boolean hasToString = /*GrailsASTUtils.*/ implementsZeroArgMethod(classNode, "toString"); if (!hasToString) { GStringExpression ge = new GStringExpression(classNode.getName() + " : ${id}"); ge.addString(new ConstantExpression(classNode.getName() + " : ")); ge.addValue(new VariableExpression("id")); Statement s = new ReturnStatement(ge); MethodNode mn = new MethodNode( "toString", Modifier.PUBLIC, new ClassNode(String.class), new Parameter[0], new ClassNode[0], s); // if(LOG.isDebugEnabled()) { // LOG.debug("[GrailsDomainInjector] Adding method [toString()] to class [" + // classNode.getName() + "]"); // } classNode.addMethod(mn); } }
@Override public void visitGStringExpression(GStringExpression expression) { // LOG.debug "Transforming expression '${expression}':" if (expression.getLineNumber() >= 0 && expression.getLineNumber() < lineNumbers.length) { // LOG.debug " start from ${expression.lineNumber} to ${lineNumbers[expression.lineNumber // - 1]}" expression.setLineNumber(lineNumbers[expression.getLineNumber() - 1]); } if (expression.getLastLineNumber() > 0 && expression.getLastLineNumber() < lineNumbers.length) { // LOG.debug " end from ${expression.lastLineNumber} to // ${lineNumbers[expression.lastLineNumber - 1]}" expression.setLastLineNumber(lineNumbers[expression.getLastLineNumber() - 1]); } super.visitGStringExpression(expression); }
public void visitGStringExpression(GStringExpression expression) { visitListOfExpressions(expression.getStrings()); visitListOfExpressions(expression.getValues()); }
public void visitGStringExpression(GStringExpression expression) { super.visitGStringExpression(expression); for (ConstantExpression ce : expression.getStrings()) { checkStringExceedingMaximumLength(ce); } }