public PsiReference[] getReferences(@Nullable PsiType type, String typeText, int startOffsetInText, final @NotNull PsiElement element) {
    String trimmed = typeText.trim();
    int offset = ElementManipulators.getValueTextRange(element).getStartOffset() + startOffsetInText + typeText.indexOf(trimmed);
    if (trimmed.startsWith(ARRAY_PREFIX)) {
      offset += ARRAY_PREFIX.length();
      if (trimmed.endsWith(";")) {
        trimmed = trimmed.substring(ARRAY_PREFIX.length(), trimmed.length() - 1);
      } else {
        trimmed = trimmed.substring(ARRAY_PREFIX.length());
      }
    }

    if (type != null) {
      type = type.getDeepComponentType();
    }
    final boolean isPrimitiveType = type instanceof PsiPrimitiveType;

    return new JavaClassReferenceSet(trimmed, element, offset, false, new JavaClassReferenceProvider()) {
      @Override
      protected @NotNull JavaClassReference createReference(int refIndex, @NotNull String subRefText, @NotNull TextRange textRange, boolean staticImport) {
        return new JavaClassReference(this, textRange, refIndex, subRefText, staticImport) {
          @Override
          public boolean isSoft() {
            return true;
          }

          @Override
          public @NotNull JavaResolveResult advancedResolve(final boolean incompleteCode) {
            if (isPrimitiveType) {
              return new CandidateInfo(element, PsiSubstitutor.EMPTY, false, false, element);
            }

            return super.advancedResolve(incompleteCode);
          }

          @Override
          public void processVariants(final @NotNull PsiScopeProcessor processor) {
            if (processor instanceof JavaCompletionProcessor) {
              ((JavaCompletionProcessor)processor).setCompletionElements(getVariants());
            } else {
              super.processVariants(processor);
            }
          }

          @Override
          public Object @NotNull [] getVariants() {
            final Object[] variants = super.getVariants();
            if (myIndex == 0) {
              return ArrayUtil.mergeArrays(variants, PRIMITIVES, ArrayUtil.OBJECT_ARRAY_FACTORY);
            }
            return variants;
          }
        };
      }
    }.getAllReferences();
  }
public PsiReference[] getReferences(@Nullable PsiType type, String typeText, int startOffsetInText, final @NotNull PsiElement element)