Java Code Examples for com.google.gwt.core.ext.typeinfo.JClassType#getOverridableMethods()

The following examples show how to use com.google.gwt.core.ext.typeinfo.JClassType#getOverridableMethods() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 6 votes vote down vote up
private void writeMethods(TreeLogger logger, ResourceContext context, JMethod method,
    SourceWriter sw, ConstantDefinitions constantDefinitions,
    Map<String, String> originalConstantNameMapping, Map<String, String> substitutionMap)
    throws UnableToCompleteException {
  JClassType gssResource = method.getReturnType().isInterface();

  boolean success = true;

  for (JMethod toImplement : gssResource.getOverridableMethods()) {
    if (toImplement == getTextMethod) {
      writeGetText(logger, context, method, sw);
    } else if (toImplement == ensuredInjectedMethod) {
      writeEnsureInjected(sw);
    } else if (toImplement == getNameMethod) {
      writeGetName(method, sw);
    } else {
      success &= writeUserMethod(logger, toImplement, sw, constantDefinitions,
          originalConstantNameMapping, substitutionMap);
    }
  }

  if (!success) {
    throw new UnableToCompleteException();
  }
}
 
Example 2
Source File: Mvp4gRunAsyncGenerator.java    From mvp4g with Apache License 2.0 5 votes vote down vote up
String getRunAsync(JClassType originalType) {
  JMethod[] methods = originalType.getOverridableMethods();
  for (JMethod method : methods) {
    if ("load".equals(method.getName())) {
      return method.getParameters()[0].getType()
                                      .getQualifiedSourceName();
    }
  }
  return null;
}
 
Example 3
Source File: InjectCreatorUtil.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Collection<JMethod> listMethod(JClassType type, Class<? extends Annotation> annotationClass) {
	Collection<JMethod> methodAnnoted = Lists.newArrayList();
	JMethod[] methods = type.getOverridableMethods();
	for (JMethod method : methods) {
		Annotation annotation = method.getAnnotation(annotationClass);
		if (annotation != null) {
			methodAnnoted.add(method);
		}
	}

	return methodAnnoted;
}
 
Example 4
Source File: GssResourceGenerator.java    From gss.gwt with Apache License 2.0 5 votes vote down vote up
private Map<String, String> computeReplacementsForType(JClassType cssResource) {
  Map<String, String> replacements = replacementsByClassAndMethod.get(cssResource);

  if (replacements == null) {
    replacements = new HashMap<String, String>();
    replacementsByClassAndMethod.put(cssResource, replacements);

    String resourcePrefix = resourcePrefixBuilder.get(cssResource.getQualifiedSourceName());

    // This substitution map will prefix each renamed class with the resource prefix and use a
    // MinimalSubstitutionMap for computing the obfuscated name.
    SubstitutionMap prefixingSubstitutionMap = new PrefixingSubstitutionMap(
        new MinimalSubstitutionMap(), obfuscationPrefix + resourcePrefix + "-");

    for (JMethod method : cssResource.getOverridableMethods()) {
      if (method == getNameMethod || method == getTextMethod || method == ensuredInjectedMethod) {
        continue;
      }

      String styleClass = getClassName(method);

      if (replacementsForSharedMethods.containsKey(method)) {
        replacements.put(styleClass, replacementsForSharedMethods.get(method));
      } else {
        String obfuscatedClassName = prefixingSubstitutionMap.get(styleClass);
        String replacement = obfuscationStyle.getPrettyName(styleClass, cssResource,
            obfuscatedClassName);

        replacements.put(styleClass, replacement);
        maybeHandleSharedMethod(method, replacement);
      }
    }
  }

  return replacements;
}