Package com.google.gwt.core.ext.typeinfo

Examples of com.google.gwt.core.ext.typeinfo.JMethod


     * @return The method returning {@code returnType}, or {@code null} if not found.
     * @throws UnableToCompleteException If more than one matching method is found.
     */
    public JMethod findMethodWithoutParamsReturning(JClassType returnType)
            throws UnableToCompleteException {
        JMethod result = null;
        for (JClassType classType : inspectedClass.getFlattenedSupertypeHierarchy()) {
            for (JMethod method : classType.getMethods()) {
                JClassType actualReturnType = method.getReturnType().isClassOrInterface();
                if (method.getParameters().length == 0
                        && actualReturnType != null
View Full Code Here


     *         found.
     * @throws UnableToCompleteException If more than one matching method is found.
     */
    public JMethod findMethodWithoutParamsReturning(JGenericType returnType,
            JClassType returnTypeParameter) throws UnableToCompleteException {
        JMethod result = null;
        for (JClassType classType : inspectedClass.getFlattenedSupertypeHierarchy()) {
            for (JMethod method : classType.getMethods()) {
                JParameterizedType actualReturnType = method.getReturnType().isParameterized();
                if (method.getParameters().length == 0
                        && actualReturnType != null
View Full Code Here

     *                                   is {@code true}.
     */
    public JMethod findAnnotatedMethodWithoutParamsReturning(JClassType returnType,
            Class<? extends Annotation> annotation,
            boolean failIfAnnotationIsFoundOnWrongMethod) throws UnableToCompleteException {
        JMethod result = null;
        for (JClassType classType : inspectedClass.getFlattenedSupertypeHierarchy()) {
            for (JMethod method : classType.getMethods()) {
                JClassType actualReturnType = method.getReturnType().isClassOrInterface();
                if (method.getAnnotation(annotation) != null) {
                    if (method.getParameters().length == 0
View Full Code Here

     * @return The method annotated with {@code annotation}, or {@code null} if not found.
     * @throws UnableToCompleteException If more than one matching method is found.
     */
    public JMethod findAnnotatedMethod(Class<? extends Annotation> annotation)
            throws UnableToCompleteException {
        JMethod result = null;
        for (JClassType classType : inspectedClass.getFlattenedSupertypeHierarchy()) {
            for (JMethod method : classType.getMethods()) {
                if (method.getAnnotation(annotation) != null) {
                    if (result != null) {
                        logger.log(TreeLogger.ERROR, "The class '" + inspectedClass.getName()
View Full Code Here

     * Look in the presenter and any superclass for a method annotated with {@link TitleFunction}.
     */
    public PresenterTitleMethod findPresenterTitleMethod()
            throws UnableToCompleteException {
        // Look for the title function in the parent presenter
        JMethod method = classInspector.findAnnotatedMethod(TitleFunction.class);
        if (method == null) {
            return null;
        }

        PresenterTitleMethod result = new PresenterTitleMethod(logger, classCollection,
View Full Code Here

     * @throws UnableToCompleteException If something goes wrong. An error will be logged.
     */
    public TabInfoMethod findTabInfoMethod()
            throws UnableToCompleteException {

        JMethod method = classInspector.findAnnotatedMethod(TabInfo.class);
        if (method == null) {
            return null;
        }
        TabInfoMethod result = new TabInfoMethod(logger, classCollection,
                ginjectorInspector, this);
View Full Code Here

   */
  private static JMethod[] findEventMethods(JClassType type) {
    List<JMethod> methods = new ArrayList<JMethod>(Arrays.asList(type.getInheritableMethods()));

    for (Iterator<JMethod> iterator = methods.iterator(); iterator.hasNext();) {
      JMethod jMethod = iterator.next();
      if (!jMethod.getName().equals("onBrowserEvent")) {
        iterator.remove();
      }
    }

    return methods.toArray(new JMethod[methods.size()]);
View Full Code Here

   * for the first one. See {@link #validateRenderParameters(JClassType)} for a
   * method that guarantees this method will succeed.
   */
  private static JParameter[] findRenderParameters(JClassType owner) {
    JMethod[] methods = owner.getInheritableMethods();
    JMethod renderMethod = null;

    for (JMethod jMethod : methods) {
      if (jMethod.getName().equals("render")) {
        renderMethod = jMethod;
      }
    }

    JParameter[] parameters = renderMethod.getParameters();
    return Arrays.copyOfRange(parameters, 1, parameters.length);
  }
View Full Code Here

   * which has a {@code void} return type, and its first parameter is of type
   * {@code SafeHtmlBuilder}.
   */
  private void validateRenderParameters(JClassType owner) throws UnableToCompleteException {
    JMethod[] methods = owner.getInheritableMethods();
    JMethod renderMethod = null;

    for (JMethod jMethod : methods) {
      if (jMethod.getName().equals("render")) {
        if (renderMethod == null) {
          renderMethod = jMethod;
        } else {
          die("%s declares more than one method named render", owner.getQualifiedSourceName());
        }
      }
    }

    if (renderMethod == null
        || renderMethod.getParameterTypes().length < 1
        || !renderMethod.getParameterTypes()[0].getErasedType().getQualifiedSourceName().equals(
            SafeHtmlBuilder.class.getCanonicalName())) {
      die("%s does not declare a render(SafeHtmlBuilder ...) method",
          owner.getQualifiedSourceName());
    }
    if (!JPrimitiveType.VOID.equals(renderMethod.getReturnType())) {
      die("%s#render(SafeHtmlBuilder ...) does not return void", owner.getQualifiedSourceName());
    }
  }
View Full Code Here

    w.indent();
    //   switch (getMethodIndex()) {
    w.write("switch (getMethodIndex()) {");
    w.indent();
    for (int j = 0; j < uiHandlerMethods.length; j++) {
      JMethod uiMethod = uiHandlerMethods[j];

      // case 0:
      w.write("case %s:", j);
      w.indent();

      //   getEventTarget().onClickRoot((ClickEvent) somethingUnlikelyToCollideWithParamNames,
      //       getRoot(), a, b);
      StringBuffer sb = new StringBuffer();
      JParameter[] sourceParameters = sourceMethod.getParameters();
      // Cat the extra parameters i.e. ", a, b"
      JType[] uiHandlerParameterTypes = uiMethod.getParameterTypes();
      if (uiHandlerParameterTypes.length >= 2) {
        sb.append(", getRoot()");
      }
      for (int k = 2; k < uiHandlerParameterTypes.length; k++) {
        JParameter sourceParam = sourceParameters[k + 1];
        sb.append(", ");
        sb.append(sourceParam.getName());
      }
      w.write("getEventTarget().%s((%s) %sEvent%s);", uiMethod.getName(),
          uiHandlerParameterTypes[0].getQualifiedSourceName(), SAFE_VAR_PREFIX,
          sb.toString());
      //   break;
      w.write("break;");
      w.newline();
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.typeinfo.JMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.