use of com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider in project intellij-community by JetBrains.
the class TestNGSuiteReferenceContributor method registerReferenceProviders.
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
registrar.registerReferenceProvider(ourTestClassPattern, new JavaClassReferenceProvider());
registrar.registerReferenceProvider(ourListenerClassPattern, new JavaClassReferenceProvider());
final JavaClassReferenceProvider methodSelectorProvider = new JavaClassReferenceProvider();
methodSelectorProvider.setOption(JavaClassReferenceProvider.EXTEND_CLASS_NAMES, new String[] { "org.testng.IMethodSelector" });
registrar.registerReferenceProvider(ourMethodSelectorPattern, methodSelectorProvider);
registrar.registerReferenceProvider(ourSuiteFilePattern, new PathListReferenceProvider() {
@Override
protected boolean disableNonSlashedPaths() {
return false;
}
});
}
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 PsiPlainTextFile file, final PsiReferenceProcessor processor) {
final Project project = file.getProject();
final XmlTag rootTag = ApplicationManager.getApplication().runReadAction(new Computable<XmlTag>() {
public XmlTag compute() {
final XmlFile xmlFile = (XmlFile) PsiFileFactory.getInstance(project).createFileFromText("a.xml", XmlFileType.INSTANCE, file.getViewProvider().getContents());
return xmlFile.getRootTag();
}
});
if (rootTag == null || !Utils.FORM_NAMESPACE.equals(rootTag.getNamespace())) {
return;
}
@NonNls final String name = rootTag.getName();
if (!"form".equals(name)) {
return;
}
PsiReference classReference = null;
final XmlAttribute classToBind = rootTag.getAttribute("bind-to-class", null);
if (classToBind != null) {
// reference to class
final XmlAttributeValue valueElement = classToBind.getValueElement();
if (valueElement == null) {
return;
}
final String className = valueElement.getValue().replace('$', '.');
final PsiReference[] referencesByString = new JavaClassReferenceProvider().getReferencesByString(className, file, valueElement.getTextRange().getStartOffset() + 1);
if (referencesByString.length < 1) {
// There are no references there
return;
}
for (PsiReference aReferencesByString : referencesByString) {
processor.execute(aReferencesByString);
}
classReference = referencesByString[referencesByString.length - 1];
}
final PsiReference finalClassReference = classReference;
ApplicationManager.getApplication().runReadAction(() -> processReferences(rootTag, finalClassReference, file, processor));
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider in project intellij-community by JetBrains.
the class PsiClassConverter method createReferences.
@NotNull
public PsiReference[] createReferences(GenericDomValue<PsiClass> genericDomValue, PsiElement element, ConvertContext context) {
ExtendClass extendClass = genericDomValue.getAnnotation(ExtendClass.class);
final JavaClassReferenceProvider provider = createClassReferenceProvider(genericDomValue, context, extendClass);
return provider.getReferencesByElement(element);
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider in project intellij-community by JetBrains.
the class ExtendsClassChecker method checkExtendsClassInReferences.
public static List<DomElementProblemDescriptor> checkExtendsClassInReferences(final GenericDomValue element, final DomElementAnnotationHolder holder) {
if (!isPsiClassType(element)) {
return Collections.emptyList();
}
final Object valueObject = element.getValue();
if (!(valueObject instanceof PsiClass))
return Collections.emptyList();
final XmlElement valueElement = DomUtil.getValueElement(element);
if (valueElement == null)
return Collections.emptyList();
final PsiReference[] references = ourProvider.getReferencesByElement(valueElement, new ProcessingContext());
for (PsiReference reference : references) {
if (reference instanceof JavaClassReference) {
final PsiReferenceProvider psiReferenceProvider = ((JavaClassReference) reference).getProvider();
final String[] value = psiReferenceProvider instanceof JavaClassReferenceProvider ? JavaClassReferenceProvider.EXTEND_CLASS_NAMES.getValue(((JavaClassReferenceProvider) psiReferenceProvider).getOptions()) : null;
if (value != null && value.length != 0) {
for (String className : value) {
final List<DomElementProblemDescriptor> problemDescriptors = checkExtendClass(element, ((PsiClass) valueObject), className, false, false, true, false, true, true, holder);
if (!problemDescriptors.isEmpty()) {
return problemDescriptors;
}
}
}
}
}
return Collections.emptyList();
}
use of com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassReferenceProvider in project intellij-community by JetBrains.
the class ClassReferenceParser method getReferences.
@NotNull
@Override
public PsiReference[] getReferences(@NotNull HeaderValuePart headerValuePart) {
final Module module = ModuleUtilCore.findModuleForPsiElement(headerValuePart);
JavaClassReferenceProvider provider;
if (module != null) {
provider = new JavaClassReferenceProvider() {
@Override
public GlobalSearchScope getScope(Project project) {
return GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
}
};
} else {
provider = new JavaClassReferenceProvider();
}
return provider.getReferencesByElement(headerValuePart);
}
Aggregations