Search in sources :

Example 6 with ElementPattern

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));
}
Also used : XmlTagPattern(com.intellij.patterns.XmlTagPattern) ElementPattern(com.intellij.patterns.ElementPattern)

Example 7 with ElementPattern

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);
}
Also used : ProcessingContext(com.intellij.util.ProcessingContext) XmlTagPattern(com.intellij.patterns.XmlTagPattern) ElementPattern(com.intellij.patterns.ElementPattern) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with ElementPattern

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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) ElementPattern(com.intellij.patterns.ElementPattern)

Aggregations

ElementPattern (com.intellij.patterns.ElementPattern)8 XmlTagPattern (com.intellij.patterns.XmlTagPattern)2 ProcessingContext (com.intellij.util.ProcessingContext)2 NotNull (org.jetbrains.annotations.NotNull)2 FrameworkDetector (com.intellij.framework.detection.FrameworkDetector)1 FileType (com.intellij.openapi.fileTypes.FileType)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 Pair (com.intellij.openapi.util.Pair)1 IElementType (com.intellij.psi.tree.IElementType)1 LightweightHint (com.intellij.ui.LightweightHint)1 MultiMap (com.intellij.util.containers.MultiMap)1 THashMap (gnu.trove.THashMap)1 Pattern (java.util.regex.Pattern)1 BaseInjection (org.intellij.plugins.intelliLang.inject.config.BaseInjection)1 InjectionPlace (org.intellij.plugins.intelliLang.inject.config.InjectionPlace)1