コード例 #1
0
  /**
   * @return true, if the element contains a reference to a different class than fullyQualifiedName
   *     but which has the same class name
   */
  public static boolean containsConflictingReference(PsiFile element, String fullyQualifiedName) {
    final Map<String, Boolean> cachedValue =
        CachedValuesManager.getManager(element.getProject())
            .getCachedValue(
                element,
                new CachedValueProvider<Map<String, Boolean>>() {
                  @Nullable
                  @Override
                  public Result<Map<String, Boolean>> compute() {
                    return new Result<Map<String, Boolean>>(
                        Collections.synchronizedMap(new HashMap<String, Boolean>()),
                        PsiModificationTracker.MODIFICATION_COUNT);
                  }
                });
    Boolean conflictingRef = cachedValue.get(fullyQualifiedName);
    if (conflictingRef != null) {
      return conflictingRef.booleanValue();
    }

    final ConflictingClassReferenceVisitor visitor =
        new ConflictingClassReferenceVisitor(fullyQualifiedName);
    element.accept(visitor);
    conflictingRef = visitor.isConflictingReferenceFound();
    cachedValue.put(fullyQualifiedName, conflictingRef);

    return conflictingRef.booleanValue();
  }
コード例 #2
0
 static boolean depends(PsiType type, TypeParamsChecker visitor, PsiTypeParameter... param2Check) {
   if (!visitor.startedInference()) return false;
   final Boolean accept = type.accept(visitor);
   if (param2Check.length > 0) {
     return visitor.used(param2Check);
   }
   return accept != null && accept.booleanValue();
 }
コード例 #3
0
 @Override
 public Boolean visitClassType(PsiClassType classType) {
   boolean used = false;
   for (PsiType paramType : classType.getParameters()) {
     final Boolean paramAccepted = paramType.accept(this);
     used |= paramAccepted != null && paramAccepted.booleanValue();
   }
   final PsiClass resolve = classType.resolve();
   if (resolve instanceof PsiTypeParameter) {
     final PsiTypeParameter typeParameter = (PsiTypeParameter) resolve;
     if (check(typeParameter)) {
       myUsedTypeParams.add(typeParameter);
       return true;
     }
   }
   return used;
 }
コード例 #4
0
  public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean beforeB) {
    TreeElement firstAppended = null;
    boolean before = beforeB == null || beforeB.booleanValue();
    try {
      TreeElement next;
      do {
        next = first.getTreeNext();

        if (firstAppended == null) {
          firstAppended = addInternal(first, anchor, before);
          anchor = firstAppended;
        } else {
          anchor = addInternal(first, anchor, false);
        }
      } while (first != last && (first = next) != null);
    } catch (IncorrectOperationException ignored) {
    } finally {
      clearCaches();
    }
    return firstAppended;
  }
コード例 #5
0
 private static boolean shouldImplementDelegatedInterfaces(PsiAnnotation delegate) {
   final Boolean result = GrAnnotationUtil.inferBooleanAttribute(delegate, "interfaces");
   return result == null || result.booleanValue();
 }