use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class I18nReferenceContributor method registerKeyProviders.
private static void registerKeyProviders(PsiReferenceRegistrar registrar) {
ElementPattern pattern = createPattern(EXTENSION_TAG_NAMES, "key", "groupKey");
registrar.registerReferenceProvider(pattern, new PropertyKeyReferenceProvider(false, "groupKey", "groupBundle"), PsiReferenceRegistrar.DEFAULT_PRIORITY);
ElementPattern typeNameKeyPattern = createPattern(TYPE_NAME_TAG, "resourceKey");
registrar.registerReferenceProvider(typeNameKeyPattern, new PropertyKeyReferenceProvider(false, "resourceKey", "resourceBundle"), PsiReferenceRegistrar.DEFAULT_PRIORITY);
final XmlTagPattern.Capture intentionActionKeyTagPattern = XmlPatterns.xmlTag().withName("categoryKey").withParent(XmlPatterns.xmlTag().withName(INTENTION_ACTION_TAG).withSuperParent(2, XmlPatterns.xmlTag().withName("idea-plugin")));
registrar.registerReferenceProvider(intentionActionKeyTagPattern, new PropertyKeyReferenceProvider(true, null, INTENTION_ACTION_BUNDLE_TAG));
}
use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class I18nReferenceContributor method registerBundleNameProviders.
private static void registerBundleNameProviders(PsiReferenceRegistrar registrar) {
final PsiReferenceProvider bundleReferenceProvider = new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
return new PsiReference[] { new MyResourceBundleReference(element) };
}
};
final XmlTagPattern.Capture resourceBundleTagPattern = XmlPatterns.xmlTag().withName("resource-bundle").withParent(XmlPatterns.xmlTag().withName("idea-plugin"));
registrar.registerReferenceProvider(resourceBundleTagPattern, bundleReferenceProvider);
ElementPattern bundlePattern = createPattern(EXTENSION_TAG_NAMES, "bundle", "groupBundle");
registrar.registerReferenceProvider(bundlePattern, bundleReferenceProvider, PsiReferenceRegistrar.DEFAULT_PRIORITY);
ElementPattern typeNameBundlePattern = createPattern(TYPE_NAME_TAG, "resourceBundle");
registrar.registerReferenceProvider(typeNameBundlePattern, bundleReferenceProvider, PsiReferenceRegistrar.DEFAULT_PRIORITY);
final XmlTagPattern.Capture intentionActionBundleTagPattern = XmlPatterns.xmlTag().withName(INTENTION_ACTION_BUNDLE_TAG).withParent(XmlPatterns.xmlTag().withName(INTENTION_ACTION_TAG).withSuperParent(2, XmlPatterns.xmlTag().withName("idea-plugin")));
registrar.registerReferenceProvider(intentionActionBundleTagPattern, bundleReferenceProvider, PsiReferenceRegistrar.DEFAULT_PRIORITY);
}
use of com.intellij.patterns.ElementPattern in project intellij-community by JetBrains.
the class PathPattern method accepts.
public boolean accepts(PrattBuilder builder) {
ListIterator<IElementType> iterator = null;
for (final ElementPattern pattern : myPath) {
if (builder == null)
return false;
if (iterator == null) {
iterator = builder.getBackResultIterator();
}
if (pattern == null) {
if (iterator.hasPrevious())
return false;
builder = builder.getParent();
iterator = null;
} else {
if (!iterator.hasPrevious())
return false;
if (!pattern.accepts(iterator.previous()))
return false;
}
}
return true;
}
Aggregations