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;
}
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();
}
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();
}
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);
}
}
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());
}
Aggregations