コード例 #1
0
  private static GroovyResolveResult getBestResolveResult(GrReferenceExpression ref) {
    GroovyResolveResult[] results = ref.multiResolve(false);
    if (results.length == 0) return GroovyResolveResult.EMPTY_RESULT;
    if (results.length == 1) return results[0];

    for (GroovyResolveResult result : results) {
      if (result.isAccessible() && result.isStaticsOK()) return result;
    }

    for (GroovyResolveResult result : results) {
      if (result.isStaticsOK()) return result;
    }

    return results[0];
  }
コード例 #2
0
 private static String getMethodCandidateInfo(GrReferenceExpression expr) {
   final GroovyResolveResult[] candidates = expr.multiResolve(false);
   final String text = expr.getText();
   if (candidates.length > 0) {
     @NonNls final StringBuilder sb = new StringBuilder();
     for (final GroovyResolveResult candidate : candidates) {
       final PsiElement element = candidate.getElement();
       if (!(element instanceof PsiMethod)) {
         continue;
       }
       final String str =
           PsiFormatUtil.formatMethod(
               (PsiMethod) element,
               candidate.getSubstitutor(),
               PsiFormatUtilBase.SHOW_NAME
                   | PsiFormatUtilBase.SHOW_TYPE
                   | PsiFormatUtilBase.SHOW_PARAMETERS,
               PsiFormatUtilBase.SHOW_TYPE);
       createElementLink(sb, element, str);
     }
     return CodeInsightBundle.message("javadoc.candidates", text, sb);
   }
   return CodeInsightBundle.message("javadoc.candidates.not.found", text);
 }
コード例 #3
0
  private static boolean shouldHighlightAsUnresolved(
      @NotNull GrReferenceExpression referenceExpression) {
    if (GrHighlightUtil.isDeclarationAssignment(referenceExpression)) return false;

    GrExpression qualifier = referenceExpression.getQualifier();
    if (qualifier != null && qualifier.getType() == null && !isRefToPackage(qualifier))
      return false;

    if (qualifier != null
        && referenceExpression.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER
        && referenceExpression.multiResolve(false).length > 0) {
      return false;
    }

    if (!GroovyUnresolvedHighlightFilter.shouldHighlight(referenceExpression)) return false;

    CollectConsumer<PomTarget> consumer = new CollectConsumer<PomTarget>();
    for (PomDeclarationSearcher searcher : PomDeclarationSearcher.EP_NAME.getExtensions()) {
      searcher.findDeclarationsAt(referenceExpression, 0, consumer);
      if (!consumer.getResult().isEmpty()) return false;
    }

    return true;
  }