예제 #1
0
  private static void assertResolvedCallsAreCompleted(
      @NotNull Diagnostic diagnostic,
      @NotNull Collection<? extends ResolvedCall<?>> resolvedCalls) {
    boolean allCallsAreCompleted = true;
    for (ResolvedCall<?> resolvedCall : resolvedCalls) {
      if (!((MutableResolvedCall<?>) resolvedCall).isCompleted()) {
        allCallsAreCompleted = false;
      }
    }

    PsiElement element = diagnostic.getPsiElement();
    DiagnosticUtils.LineAndColumn lineAndColumn =
        DiagnosticUtils.getLineAndColumnInPsiFile(
            element.getContainingFile(), element.getTextRange());

    assertTrue(
        "Resolved calls stored in "
            + diagnostic.getFactory().getName()
            + "\n"
            + "for '"
            + element.getText()
            + "'"
            + lineAndColumn
            + " are not completed",
        allCallsAreCompleted);
  }
예제 #2
0
 @SuppressWarnings({"unchecked", "ConstantConditions"})
 private static void checkResolvedCallsInDiagnostics(BindingContext bindingContext) {
   Set<DiagnosticFactory> diagnosticsStoringResolvedCalls1 =
       Sets.<DiagnosticFactory>newHashSet(
           OVERLOAD_RESOLUTION_AMBIGUITY,
           NONE_APPLICABLE,
           CANNOT_COMPLETE_RESOLVE,
           UNRESOLVED_REFERENCE_WRONG_RECEIVER,
           ASSIGN_OPERATOR_AMBIGUITY,
           ITERATOR_AMBIGUITY);
   Set<DiagnosticFactory> diagnosticsStoringResolvedCalls2 =
       Sets.<DiagnosticFactory>newHashSet(
           COMPONENT_FUNCTION_AMBIGUITY,
           DELEGATE_SPECIAL_FUNCTION_AMBIGUITY,
           DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE);
   Diagnostics diagnostics = bindingContext.getDiagnostics();
   for (Diagnostic diagnostic : diagnostics) {
     DiagnosticFactory factory = diagnostic.getFactory();
     if (diagnosticsStoringResolvedCalls1.contains(factory)) {
       assertResolvedCallsAreCompleted(
           diagnostic,
           ((DiagnosticWithParameters1<PsiElement, Collection<? extends ResolvedCall<?>>>)
                   diagnostic)
               .getA());
     }
     if (diagnosticsStoringResolvedCalls2.contains(factory)) {
       assertResolvedCallsAreCompleted(
           diagnostic,
           ((DiagnosticWithParameters2<PsiElement, Object, Collection<? extends ResolvedCall<?>>>)
                   diagnostic)
               .getB());
     }
   }
 }