use of com.google.gwt.core.ext.typeinfo.JMethod in project rstudio by rstudio.
the class ImageResourceInfo method emitConstructor.
private void emitConstructor(SourceWriter writer, ImageResourceInfo images) throws UnableToCompleteException {
writer.println("public " + simpleName_ + "() {");
// Get additional properties from XML resource file, if exists
Map<String, Element> props = getCommandProperties();
// Implement the methods for the commands
for (JMethod method : commandMethods_) emitCommandInitializers(writer, props, method, images);
writer.println();
writer.indentln("__registerShortcuts();");
writer.println("}");
}
use of com.google.gwt.core.ext.typeinfo.JMethod in project rstudio by rstudio.
the class ImageResourceInfo method emitMenus.
private void emitMenus(SourceWriter writer) throws UnableToCompleteException {
for (JMethod method : menuMethods_) {
String name = method.getName();
NodeList nodes = getConfigDoc("/commands/menu[@id='" + name + "']");
if (nodes.getLength() == 0) {
logger_.log(TreeLogger.Type.ERROR, "Unable to find config info for menu " + name);
throw new UnableToCompleteException();
} else if (nodes.getLength() > 1) {
logger_.log(TreeLogger.Type.ERROR, "Duplicate menu entries for menu " + name);
}
String menuClass = new MenuEmitter(logger_, context_, bundleType_, (Element) nodes.item(0)).generate();
writer.println("public void " + name + "(MenuCallback callback) {");
writer.indentln("new " + menuClass + "(this).createMenu(callback);");
writer.println("}");
}
}
use of com.google.gwt.core.ext.typeinfo.JMethod in project GwtMobile by dennisjzh.
the class GenUtils method inspectType.
public void inspectType(String typeName, List<JMethod> getters, List<JMethod> hasManyRels, List<JMethod> hasOneRels) throws UnableToCompleteException {
JClassType classType = getClassType(typeName);
for (JMethod method : classType.getOverridableMethods()) {
if (!method.isAbstract()) {
continue;
}
String methodName = method.getName();
if (methodName.startsWith("get")) {
// getId() is reserved.
String propertyName = methodName.substring(3);
if (propertyName.equals("Id")) {
continue;
}
JType returnType = method.getReturnType();
String returnTypeName = returnType.getSimpleSourceName();
if (returnType.isPrimitive() != null && !returnTypeName.equals("long") || returnTypeName.equals("String") || returnTypeName.equals("Date") || isSubclassOf(returnType, "JSONValue")) {
getters.add(method);
continue;
}
if (returnTypeName.equals("long")) {
logger.log(TreeLogger.ERROR, "GWT JSNI does not support 'long' as return type on getter '" + methodName + "'. Use 'double' instead.");
throw new UnableToCompleteException();
}
if (returnTypeName.startsWith("Collection")) {
hasManyRels.add(method);
continue;
}
if (isSubclassOf(returnType, "Persistable")) {
hasOneRels.add(method);
continue;
}
logger.log(TreeLogger.ERROR, "Unsupported return type '" + returnTypeName + "' on getter '" + methodName + "'.");
throw new UnableToCompleteException();
} else {
// TODO: check if method is a setter. ignore if so, error if not.
}
}
}
use of com.google.gwt.core.ext.typeinfo.JMethod in project rstudio by rstudio.
the class ImageResourceInfo method getMethods.
private JMethod[] getMethods(boolean includeCommands, boolean includeMenus, boolean includeShortcuts) throws UnableToCompleteException {
ArrayList<JMethod> methods = new ArrayList<JMethod>();
for (JMethod method : bundleType_.getMethods()) {
if (!method.isAbstract())
continue;
validateMethod(method);
if (!includeCommands && isCommandMethod(method))
continue;
if (!includeMenus && isMenuMethod(method))
continue;
if (!includeShortcuts && isShortcutsMethod(method))
continue;
methods.add(method);
}
return methods.toArray(new JMethod[methods.size()]);
}
use of com.google.gwt.core.ext.typeinfo.JMethod in project rstudio by rstudio.
the class ImageResourceInfo method emitCommandAccessors.
private void emitCommandAccessors(SourceWriter writer) {
for (JMethod method : commandMethods_) {
String name = method.getName();
writer.println("public AppCommand " + name + "() {");
writer.indent();
writer.println("return " + name + "_;");
writer.outdent();
writer.println("}");
}
}
Aggregations