use of com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReference in project intellij-plugins by JetBrains.
the class StrutsConstantValueReference method getVariants.
@NotNull
@SuppressWarnings({ "unchecked" })
public Object[] getVariants() {
if (elementConverterPair == null) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
final Converter converter = elementConverterPair.second;
if (!(converter instanceof ResolvingConverter)) {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
final ResolvingConverter resolvingConverter = (ResolvingConverter) converter;
// merge "normal" + additional variants
final DomElement paramValueElement = elementConverterPair.first;
final ConvertContext convertContext = ConvertContextFactory.createConvertContext(paramValueElement);
// wrap explicitly for empty list
final Collection converterVariants = new ArrayList(resolvingConverter.getVariants(convertContext));
final Collection variants;
if (!converterVariants.isEmpty() && converterVariants.iterator().next() instanceof DomElement) {
variants = Arrays.asList(ElementPresentationManager.getInstance().createVariants(converterVariants));
} else {
variants = converterVariants;
}
variants.addAll(resolvingConverter.getAdditionalVariants(convertContext));
// add custom created references
if (resolvingConverter instanceof CustomReferenceConverter) {
final PsiReference[] references = ((CustomReferenceConverter) resolvingConverter).createReferences((GenericDomValue) paramValueElement, myElement, convertContext);
for (final PsiReference customReference : references) {
if (customReference instanceof JavaClassReference) {
JavaClassReference javaClassReference = (JavaClassReference) customReference;
String[] names = javaClassReference.getExtendClassNames();
PsiElement context = javaClassReference.getCompletionContext();
if (names != null && context instanceof PsiPackage) {
javaClassReference.processSubclassVariants((PsiPackage) context, names, element -> variants.add(element));
continue;
}
}
Collections.addAll(variants, customReference.getVariants());
}
}
return ArrayUtil.toObjectArray(variants);
}
Aggregations