public MethodBuffer addParameters(final String... parameters) { for (final String parameter : parameters) { final IsParameter param = JavaLexer.lexParam(parameter); this.parameters.add(param.toString()); } return this; }
public MethodBuffer setReturnType(final String canonicalName) { if ("".equals(canonicalName)) { returnType = new TypeData(""); } else { returnType = JavaLexer.extractType(canonicalName, 0); } return this; }
@Override public void visitGeneric(String generic, final SourceBuilder<?> receiver) { generic = generic.trim(); if (generic.charAt(0) == '<') { generic = generic.substring(1, generic.length() - 1); } for (final String importable : JavaLexer.findImportsInGeneric(generic)) { final String imported = receiver.getImports().addImport(importable); if (importable.length() != imported.length()) { int len = -1; while (len != generic.length()) { len = generic.length(); generic = generic.replace(importable, imported); } } } generics.add(generic); }
/** * Uses {@link JavaLexer} to extract a MethodBuffer definition. * * <p>This is slower than manually setting method metadata, but it does automatically import fully * qualified class names (if and only if there is not already an imported type matching imported * simple name). * * @param definition - Any valid java method definition. "public void doSomething()" * @return - A method buffer initialized to whatever the provided text lexes. * <p>Report any parsing errors to github.com/WeTheInternet/com.google.gwt.thirdparty.xapi * and/or [email protected] */ public MethodBuffer setDefinition(final String definition) { // JavaMetadata will extract all modifiers for us JavaLexer.visitMethodSignature(this, context, definition, 0); return this; }