use of com.intellij.util.ProcessingContext in project intellij-community by JetBrains.
the class GrLanguageReferenceProvider method registerReferenceProviders.
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
final Configuration configuration = Configuration.getInstance();
registrar.registerReferenceProvider(GroovyPatterns.groovyLiteralExpression().annotationParam(StandardPatterns.string().with(isLanguageAnnotation(configuration)), "value").and(GroovyPatterns.groovyLiteralExpression().with(isStringLiteral())), new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull final ProcessingContext context) {
return new PsiReference[] { new LanguageReference((PsiLiteral) element) };
}
});
}
use of com.intellij.util.ProcessingContext in project intellij-community by JetBrains.
the class JavaFxEventHandlerReferenceProvider method getReferencesByElement.
@Override
protected PsiReference[] getReferencesByElement(@NotNull PsiClass controllerClass, XmlAttributeValue xmlAttributeValue, ProcessingContext context) {
final String attValueString = xmlAttributeValue.getValue();
LOG.assertTrue(attValueString.startsWith("#"));
final XmlAttribute attribute = (XmlAttribute) xmlAttributeValue.getParent();
if (attribute == null || !JavaFxPsiUtil.isEventHandlerProperty(attribute))
return PsiReference.EMPTY_ARRAY;
final String eventHandlerName = attValueString.substring(1);
final PsiMethod[] methods = controllerClass.findMethodsByName(eventHandlerName, true);
final PsiReference[] references = Arrays.stream(methods).filter(psiMethod -> JavaFxEventHandlerReference.isHandlerMethodSignature(psiMethod, controllerClass)).map(psiMethod -> new JavaFxEventHandlerReference(xmlAttributeValue, psiMethod, controllerClass)).toArray(PsiReference.ARRAY_FACTORY::create);
if (references.length == 1) {
return references;
}
if (references.length > 1) {
return new PsiReference[] { new PsiMultiReference(references, xmlAttributeValue) };
}
if (references.length == 0) {
final XmlTag rootTag = ((XmlFile) xmlAttributeValue.getContainingFile()).getRootTag();
if (rootTag == null || FxmlConstants.FX_ROOT.equals(rootTag.getName())) {
return PsiReference.EMPTY_ARRAY;
}
}
return new PsiReference[] { new JavaFxEventHandlerReference(xmlAttributeValue, null, controllerClass) };
}
use of com.intellij.util.ProcessingContext in project intellij-community by JetBrains.
the class PyReferenceImpl method getTypeCompletionVariants.
protected static Object[] getTypeCompletionVariants(PyExpression pyExpression, PyType type) {
ProcessingContext context = new ProcessingContext();
context.put(PyType.CTX_NAMES, new HashSet<>());
return type.getCompletionVariants(pyExpression.getName(), pyExpression, context);
}
use of com.intellij.util.ProcessingContext in project intellij-community by JetBrains.
the class XmlEnumeratedValueReferenceProvider method getReferencesByElement.
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (XmlSchemaTagsProcessor.PROCESSING_FLAG.get() != null || context.get(SUPPRESS) != null) {
return PsiReference.EMPTY_ARRAY;
}
@SuppressWarnings("unchecked") PsiElement host = getHost((T) element);
if (host instanceof PsiLanguageInjectionHost && InjectedLanguageUtil.hasInjections((PsiLanguageInjectionHost) host)) {
return PsiReference.EMPTY_ARRAY;
}
if (XmlHighlightVisitor.skipValidation(element)) {
return PsiReference.EMPTY_ARRAY;
}
String unquotedValue = ElementManipulators.getValueText(element);
if (!XmlUtil.isSimpleValue(unquotedValue, element)) {
return PsiReference.EMPTY_ARRAY;
}
@SuppressWarnings("unchecked") final Object descriptor = getDescriptor((T) element);
if (descriptor instanceof XmlEnumerationDescriptor) {
XmlEnumerationDescriptor enumerationDescriptor = (XmlEnumerationDescriptor) descriptor;
if (enumerationDescriptor.isFixed() || enumerationDescriptor.isEnumerated((XmlElement) element)) {
//noinspection unchecked
return enumerationDescriptor.getValueReferences((XmlElement) element, unquotedValue);
} else if (unquotedValue.equals(enumerationDescriptor.getDefaultValue())) {
// todo case insensitive
return ContainerUtil.map2Array(enumerationDescriptor.getValueReferences((XmlElement) element, unquotedValue), PsiReference.class, reference -> PsiDelegateReference.createSoft(reference, true));
}
}
return PsiReference.EMPTY_ARRAY;
}
use of com.intellij.util.ProcessingContext in project intellij-community by JetBrains.
the class XmlReferenceContributor method registerReferenceProviders.
@Override
public void registerReferenceProviders(@NotNull final PsiReferenceRegistrar registrar) {
final IdReferenceProvider idReferenceProvider = new IdReferenceProvider();
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, idReferenceProvider.getIdForAttributeNames(), idReferenceProvider.getIdForFilter(), true, idReferenceProvider, PsiReferenceRegistrar.DEFAULT_PRIORITY);
final DtdReferencesProvider dtdReferencesProvider = new DtdReferencesProvider();
//registerReferenceProvider(null, XmlEntityDecl.class,dtdReferencesProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlEntityRef.class), dtdReferencesProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlDoctype.class), dtdReferencesProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementDecl.class), dtdReferencesProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlAttlistDecl.class), dtdReferencesProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlElementContentSpec.class), dtdReferencesProvider);
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlToken.class), dtdReferencesProvider);
registrar.registerReferenceProvider(xmlAttributeValue(), new ArbitraryPlaceUrlReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
URIReferenceProvider uriProvider = new URIReferenceProvider();
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, null, dtdReferencesProvider.getSystemReferenceFilter(), uriProvider);
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[] { "href" }, new ScopeFilter(new ParentElementFilter(new AndFilter(new AndFilter(XmlTagFilter.INSTANCE, new XmlTextFilter("include")), new NamespaceFilter(XmlUtil.XINCLUDE_URI)), 2)), true, new XmlBaseReferenceProvider(true));
registrar.registerReferenceProvider(xmlAttributeValue().withLocalName("base").withNamespace(XmlUtil.XML_NAMESPACE_URI), new XmlBaseReferenceProvider(false));
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[] { MicrodataUtil.ITEM_TYPE }, null, new MicrodataReferenceProvider());
final SchemaReferencesProvider schemaReferencesProvider = new SchemaReferencesProvider();
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, schemaReferencesProvider.getCandidateAttributeNamesForSchemaReferences(), new ScopeFilter(new ParentElementFilter(new NamespaceFilter(XmlUtil.SCHEMA_URIS), 2)), schemaReferencesProvider);
registrar.registerReferenceProvider(xmlAttributeValue(xmlAttribute().withNamespace(XmlUtil.XML_SCHEMA_INSTANCE_URI)).withLocalName("type"), schemaReferencesProvider);
registrar.registerReferenceProvider(xmlAttributeValue(xmlAttribute().withNamespace(XmlUtil.XML_SCHEMA_INSTANCE_URI)).withLocalName("noNamespaceSchemaLocation", "schemaLocation"), uriProvider);
registrar.registerReferenceProvider(xmlAttributeValue().withLocalName("schemaLocation", "namespace").withSuperParent(2, xmlTag().withNamespace(XmlUtil.SCHEMA_URIS).withLocalName("import", "include", "redefine")), uriProvider);
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, null, URIReferenceProvider.ELEMENT_FILTER, true, uriProvider);
XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[] { "encoding" }, new ScopeFilter(new ParentElementFilter(new ClassFilter(XmlProcessingInstruction.class))), true, new XmlEncodingReferenceProvider());
registrar.registerReferenceProvider(xmlAttributeValue(), new XmlPrefixReferenceProvider());
registrar.registerReferenceProvider(xmlAttributeValue(), new XmlEnumeratedValueReferenceProvider(), PsiReferenceRegistrar.LOWER_PRIORITY);
registrar.registerReferenceProvider(xmlTag(), XmlEnumeratedValueReferenceProvider.forTags(), PsiReferenceRegistrar.LOWER_PRIORITY);
registrar.registerReferenceProvider(xmlAttributeValue().withLocalName("source").withSuperParent(2, xmlTag().withLocalName("documentation").withNamespace(XmlUtil.SCHEMA_URIS)), new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
return new PsiReference[] { new WebReference(element) };
}
});
}
Aggregations