Search in sources :

Example 11 with JavaClassReferenceProvider

use of com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider in project intellij-plugins by JetBrains.

the class ExtendableClassConverterImpl method createReferences.

@NotNull
public PsiReference[] createReferences(final GenericDomValue<PsiClass> psiClassGenericDomValue, final PsiElement element, final ConvertContext context) {
    final ExtendClass extendClass = getExtendsAnnotation(psiClassGenericDomValue);
    // 1. "normal" JAVA classes
    final GlobalSearchScope scope = getResolveScope(psiClassGenericDomValue);
    final JavaClassReferenceProvider classReferenceProvider = new JavaClassReferenceProvider() {

        @Override
        public GlobalSearchScope getScope(final Project project) {
            return scope;
        }
    };
    PsiClassConverter.createJavaClassReferenceProvider(psiClassGenericDomValue, extendClass, classReferenceProvider);
    PsiReference[] javaClassReferences = classReferenceProvider.getReferencesByElement(element);
    final boolean allowInterface = extendClass.allowInterface();
    @NonNls String[] referenceTypes = allowInterface ? new String[] { "class", "interface" } : new String[] { "class" };
    // 2. additional resolvers
    for (final ExtendableClassConverterContributor contributor : Extensions.getExtensions(EP_NAME)) {
        if (contributor.isSuitable(context)) {
            final PsiReference[] additionalReferences = contributor.getReferences(context, element, extendClass);
            javaClassReferences = ArrayUtil.mergeArrays(javaClassReferences, additionalReferences, PsiReference.ARRAY_FACTORY);
            referenceTypes = ArrayUtil.append(referenceTypes, contributor.getTypeName(), ArrayUtil.STRING_ARRAY_FACTORY);
        }
    }
    psiClassGenericDomValue.putUserData(REFERENCES_TYPES, referenceTypes);
    return javaClassReferences;
}
Also used : Project(com.intellij.openapi.project.Project) NonNls(org.jetbrains.annotations.NonNls) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiReference(com.intellij.psi.PsiReference) JavaClassReferenceProvider(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JavaClassReferenceProvider (com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider)11 NotNull (org.jetbrains.annotations.NotNull)5 Project (com.intellij.openapi.project.Project)4 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)3 TextRange (com.intellij.openapi.util.TextRange)2 XmlAttribute (com.intellij.psi.xml.XmlAttribute)2 XmlTag (com.intellij.psi.xml.XmlTag)2 NonNls (org.jetbrains.annotations.NonNls)2 ASTNode (com.intellij.lang.ASTNode)1 Module (com.intellij.openapi.module.Module)1 PsiElement (com.intellij.psi.PsiElement)1 PsiReference (com.intellij.psi.PsiReference)1 PsiType (com.intellij.psi.PsiType)1 JavaClassReference (com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReference)1 JavaClassReferenceSet (com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceSet)1 PathListReferenceProvider (com.intellij.psi.impl.source.resolve.reference.impl.providers.PathListReferenceProvider)1 XmlAttributeValue (com.intellij.psi.xml.XmlAttributeValue)1 XmlElement (com.intellij.psi.xml.XmlElement)1 XmlFile (com.intellij.psi.xml.XmlFile)1 ProcessingContext (com.intellij.util.ProcessingContext)1