Search in sources :

Example 6 with JavaClassReferenceProvider

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

the class PluginPsiClassConverter method createClassReferenceProvider.

@Override
protected JavaClassReferenceProvider createClassReferenceProvider(GenericDomValue<PsiClass> genericDomValue, ConvertContext context, ExtendClass extendClass) {
    final JavaClassReferenceProvider provider = super.createClassReferenceProvider(genericDomValue, context, extendClass);
    provider.setOption(JavaClassReferenceProvider.JVM_FORMAT, Boolean.TRUE);
    provider.setOption(JavaClassReferenceProvider.ALLOW_DOLLAR_NAMES, Boolean.TRUE);
    return provider;
}
Also used : JavaClassReferenceProvider(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider)

Example 7 with JavaClassReferenceProvider

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

the class CfmlStringLiteralExpression method getReferences.

@NotNull
@Override
public PsiReference[] getReferences() {
    CfmlFunctionCallExpression functionCallEl = PsiTreeUtil.getParentOfType(this, CfmlFunctionCallExpression.class);
    if (functionCallEl != null && functionCallEl.isCreateObject()) {
        final String[] args = functionCallEl.getArgumentsAsStrings();
        final CfmlExpression[] expressions = functionCallEl.getArguments();
        final PsiElement referenceElement = findChildByType(CfmlTokenTypes.STRING_TEXT);
        if (referenceElement == null) {
            return super.getReferences();
        }
        if (args.length == 2 && "java".equals(args[0]) && expressions.length == 2 && expressions[1] == this) {
            final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
            return provider.getReferencesByString(args[1], referenceElement, 0);
        } else if ((args.length == 2 && "component".equals(args[0]) && expressions.length == 2 && expressions[1] == this) || (args.length == 1 && expressions.length == 1 && expressions[0] == this)) {
            final ASTNode referenceNode = referenceElement.getNode();
            if (referenceNode != null) {
                return new PsiReference[] { new CfmlComponentReference(referenceNode) };
            }
        }
    } else if (functionCallEl != null && functionCallEl.isExpandPath()) {
        final PsiElement referenceElement = findChildByType(CfmlTokenTypes.STRING_TEXT);
        if (referenceElement == null) {
            return super.getReferences();
        }
        final ASTNode referenceNode = referenceElement.getNode();
        if (referenceNode != null) {
            return (new CfmlFileReferenceSet(this, 1)).getAllReferences();
        }
    } else if (functionCallEl != null && functionCallEl.isCreateFromJavaLoader()) {
        CfmlExpression[] expressions = functionCallEl.getArguments();
        if (expressions.length > 0 && expressions[0] == this) {
            PsiElement stringTextElement = findChildByType(CfmlTokenTypes.STRING_TEXT);
            if (stringTextElement != null) {
                // getting javaloader type
                PsiElement secondChild = functionCallEl.getFirstChild().getFirstChild();
                if (!(secondChild instanceof CfmlReferenceExpression)) {
                    return super.getReferences();
                }
                PsiType type = ((CfmlReferenceExpression) secondChild).getPsiType();
                if (!(type instanceof CfmlJavaLoaderClassType)) {
                    return super.getReferences();
                }
                final GlobalSearchScope ss = ((CfmlJavaLoaderClassType) type).getSearchScope();
                String possibleJavaClassName = stringTextElement.getText();
                final JavaClassReferenceProvider provider = new JavaClassReferenceProvider() {

                    @Override
                    public GlobalSearchScope getScope(Project project) {
                        return ss;
                    }
                };
                return provider.getReferencesByString(possibleJavaClassName, stringTextElement, 0);
            }
        }
    } else if (getParent() instanceof CfmlComponentConstructorCall || getParent() instanceof CfmlImport) {
        PsiElement stringTextElement = findChildByType(CfmlTokenTypes.STRING_TEXT);
        if (stringTextElement != null) {
            return new PsiReference[] { new CfmlComponentReference(stringTextElement.getNode(), this) };
        }
    }
    return super.getReferences();
}
Also used : JavaClassReferenceProvider(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider) Project(com.intellij.openapi.project.Project) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ASTNode(com.intellij.lang.ASTNode) PsiElement(com.intellij.psi.PsiElement) PsiType(com.intellij.psi.PsiType) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with JavaClassReferenceProvider

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

the class OgnlFqnTypeExpressionBase method getReferences.

@NotNull
@Override
public PsiReference[] getReferences() {
    JavaClassReferenceProvider referenceProvider = new JavaClassReferenceProvider();
    referenceProvider.setOption(JavaClassReferenceProvider.DEFAULT_PACKAGE, CommonClassNames.DEFAULT_PACKAGE);
    OgnlPsiUtil.customizeFqnTypeExpressionReferences(this, referenceProvider);
    final JavaClassReferenceSet classReferenceSet = new JavaClassReferenceSet(getText(), this, 0, false, referenceProvider);
    return classReferenceSet.getReferences();
}
Also used : JavaClassReferenceSet(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceSet) JavaClassReferenceProvider(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with JavaClassReferenceProvider

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

the class FormReferenceProvider method processReferences.

private static void processReferences(final XmlTag tag, final PsiReference classReference, final PsiPlainTextFile file, final PsiReferenceProcessor processor) {
    final XmlAttribute clsAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CLASS, null);
    final String classNameStr = clsAttribute != null ? clsAttribute.getValue().replace('$', '.') : null;
    // field
    {
        final XmlAttribute bindingAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_BINDING, null);
        if (bindingAttribute != null && classReference != null) {
            final XmlAttribute customCreateAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_CUSTOM_CREATE, null);
            boolean customCreate = (customCreateAttribute != null && Boolean.parseBoolean(customCreateAttribute.getValue()));
            final TextRange nameRange = clsAttribute != null ? getValueRange(clsAttribute) : null;
            processor.execute(new FieldFormReference(file, classReference, getValueRange(bindingAttribute), classNameStr, nameRange, customCreate));
        }
        final XmlAttribute titleBundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_RESOURCE_BUNDLE, null);
        final XmlAttribute titleKeyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_TITLE_KEY, null);
        if (titleBundleAttribute != null && titleKeyAttribute != null) {
            processResourceBundleFileReferences(file, processor, titleBundleAttribute);
            processor.execute(new ResourceBundleKeyReference(file, titleBundleAttribute.getValue(), getValueRange(titleKeyAttribute)));
        }
        final XmlAttribute bundleAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_RESOURCE_BUNDLE, null);
        final XmlAttribute keyAttribute = tag.getAttribute(UIFormXmlConstants.ATTRIBUTE_KEY, null);
        if (bundleAttribute != null && keyAttribute != null) {
            processResourceBundleFileReferences(file, processor, bundleAttribute);
            processor.execute(new ResourceBundleKeyReference(file, bundleAttribute.getValue(), getValueRange(keyAttribute)));
        }
        processNestedFormReference(tag, processor, file);
        processButtonGroupReference(tag, processor, file, classReference);
    }
    // component class
    {
        if (clsAttribute != null) {
            final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
            final PsiReference[] referencesByString = provider.getReferencesByString(classNameStr, file, clsAttribute.getValueElement().getTextRange().getStartOffset() + 1);
            if (referencesByString.length < 1) {
                // There are no references there
                return;
            }
            for (PsiReference aReferencesByString : referencesByString) {
                processor.execute(aReferencesByString);
            }
        }
    }
    // property references
    XmlTag parentTag = tag.getParentTag();
    if (parentTag != null && parentTag.getName().equals(UIFormXmlConstants.ELEMENT_PROPERTIES)) {
        XmlTag componentTag = parentTag.getParentTag();
        if (componentTag != null) {
            String className = componentTag.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_CLASS, Utils.FORM_NAMESPACE);
            if (className != null) {
                processPropertyReference(tag, processor, file, className.replace('$', '.'));
            }
        }
    }
    final XmlTag[] subtags = tag.getSubTags();
    for (XmlTag subtag : subtags) {
        processReferences(subtag, classReference, file, processor);
    }
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) TextRange(com.intellij.openapi.util.TextRange) JavaClassReferenceProvider(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider) XmlTag(com.intellij.psi.xml.XmlTag)

Example 10 with JavaClassReferenceProvider

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

the class CfmlReferenceContributor method getReferencesToJavaTypes.

public static PsiReference[] getReferencesToJavaTypes(PsiElement element) {
    final String text = element.getText();
    TextRange range = findTypeNameRange(text);
    if (range == null) {
        return PsiReference.EMPTY_ARRAY;
    }
    final JavaClassReferenceProvider provider = new JavaClassReferenceProvider();
    return provider.getReferencesByString(range.substring(text), element, range.getStartOffset());
}
Also used : TextRange(com.intellij.openapi.util.TextRange) JavaClassReferenceProvider(com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider)

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