com.intellij.psi.JavaResolveResult Java Examples

The following examples show how to use com.intellij.psi.JavaResolveResult. 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: EventHandlerAnnotator.java    From litho with Apache License 2.0 5 votes vote down vote up
/**
 * Tries to guess if the given methodCall requires event handler.
 *
 * @return Qualified name of the handled Event or null, if methodCall neither accepts event
 *     handler, nor require fix.
 */
@Nullable
private static String resolveEventName(PsiMethodCallExpression methodCall) {
  return Optional.of(methodCall.getMethodExpression().multiResolve(true))
      .map(results -> results.length == 1 ? results[0] : JavaResolveResult.EMPTY)
      .filter(MethodCandidateInfo.class::isInstance)
      .map(MethodCandidateInfo.class::cast)
      .filter(MethodCandidateInfo::isTypeArgumentsApplicable)
      .filter(info -> !info.isApplicable() && !info.isValidResult())
      .map(info -> info.getElement().getParameterList().getParameters())
      .filter(parameters -> parameters.length > 0) // method(EventHandler<T> e)
      .map(parameters -> parameters[0].getType())
      .filter(PsiClassType.class::isInstance)
      .filter(
          parameterType -> {
            String fullName = parameterType.getCanonicalText();
            int genericIndex = fullName.indexOf('<');
            if (genericIndex <= 0) {
              return false;
            }
            String className = fullName.substring(0, genericIndex);
            return LithoClassNames.EVENT_HANDLER_CLASS_NAME.equals(className);
          })
      .map(parameterType -> ((PsiClassType) parameterType).getParameters())
      .filter(generics -> generics.length == 1) // <T>
      .map(generics -> generics[0].getCanonicalText())
      .orElse(null);
}
 
Example #2
Source File: HaxeClassResolveResult.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public JavaResolveResult toJavaResolveResult() {
  return new JavaResult(this);
}
 
Example #3
Source File: LombokEnumConstantBuilder.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
@Override
public JavaResolveResult resolveMethodGenerics() {
  return JavaResolveResult.EMPTY;
}