当前位置: 首页>>代码示例>>Java>>正文


Java ElementPattern类代码示例

本文整理汇总了Java中com.intellij.patterns.ElementPattern的典型用法代码示例。如果您正苦于以下问题:Java ElementPattern类的具体用法?Java ElementPattern怎么用?Java ElementPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ElementPattern类属于com.intellij.patterns包,在下文中一共展示了ElementPattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertNavigationMatch

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
private void assertNavigationMatch(ElementPattern<?> pattern) {

        PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

        Set<String> targetStrings = new HashSet<String>();

        for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {

            PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
            if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) {
                continue;
            }

            for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
                targetStrings.add(gotoDeclarationTarget.toString());
                if(pattern.accepts(gotoDeclarationTarget)) {
                    return;
                }
            }
        }

        fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString()));
    }
 
开发者ID:adelf,项目名称:idea-php-dotenv-plugin,代码行数:24,代码来源:DotEnvLightCodeInsightFixtureTestCase.java

示例2: compute

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
@NotNull
@Override
protected ElementPattern<PsiElement> compute() {
  return psiElement().andNot(psiElement().afterLeaf("@", ".")).
    andOr(
      psiElement().and(new FilterPattern(CLASS_BODY.getValue())).
        andOr(
          new FilterPattern(END_OF_BLOCK.getValue()),
          psiElement().afterLeaf(or(
            psiElement().inside(PsiModifierList.class),
            psiElement().withElementType(JavaTokenType.GT).inside(PsiTypeParameterList.class)
          ))),
      psiElement().withParents(PsiJavaCodeReferenceElement.class, PsiTypeElement.class, PsiMember.class),
      psiElement().withParents(PsiJavaCodeReferenceElement.class, PsiTypeElement.class, PsiClassLevelDeclarationStatement.class)
    );
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JavaKeywordCompletion.java

示例3: registerProvider

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public void registerProvider(@NonNls @NotNull String[] names,
                             @NotNull ElementPattern filter,
                             boolean caseSensitive,
                             @NotNull PsiReferenceProvider provider,
                             final double priority) {
  final Map<String, List<ProviderInfo<ElementPattern>>> map = caseSensitive ? myNamesToProvidersMap : myNamesToProvidersMapInsensitive;

  for (final String attributeName : names) {
    String key = caseSensitive ? attributeName : attributeName.toLowerCase();
    List<ProviderInfo<ElementPattern>> psiReferenceProviders = map.get(key);

    if (psiReferenceProviders == null) {
      map.put(key, psiReferenceProviders = new SmartList<ProviderInfo<ElementPattern>>());
    }

    psiReferenceProviders.add(new ProviderInfo<ElementPattern>(provider, filter, priority));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:NamedObjectProviderBinding.java

示例4: findIdentifierPrefix

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public static String findIdentifierPrefix(PsiElement insertedElement, int offset, ElementPattern<Character> idPart,
                                           ElementPattern<Character> idStart) {
  if(insertedElement == null) return "";
  final String text = insertedElement.getText();

  final int offsetInElement = offset - insertedElement.getTextRange().getStartOffset();
  int start = offsetInElement - 1;
  while (start >=0 ) {
    if (!idPart.accepts(text.charAt(start))) break;
    --start;
  }
  while (start + 1 < offsetInElement && !idStart.accepts(text.charAt(start + 1))) {
    start++;
  }

  return text.substring(start + 1, offsetInElement).trim();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:CompletionUtil.java

示例5: findPrefixStatic

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public static String findPrefixStatic(final PsiElement insertedElement, final int offsetInFile, ElementPattern<Character> prefixStartTrim) {
  if(insertedElement == null) return "";

  final Document document = insertedElement.getContainingFile().getViewProvider().getDocument();
  assert document != null;
  LOG.assertTrue(!PsiDocumentManager.getInstance(insertedElement.getProject()).isUncommited(document), "Uncommitted");

  final String prefix = getReferencePrefix(insertedElement, offsetInFile);
  if (prefix != null) return prefix;

  if (insertedElement instanceof PsiPlainText || insertedElement instanceof PsiComment) {
    return CompletionUtil.findJavaIdentifierPrefix(insertedElement, offsetInFile);
  }

  return findPrefixDefault(insertedElement, offsetInFile, prefixStartTrim);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CompletionData.java

示例6: prefixUpdated

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public void prefixUpdated() {
  final int caretOffset = myEditor.getCaretModel().getOffset();
  if (caretOffset < myStartCaret) {
    scheduleRestart();
    myRestartingPrefixConditions.clear();
    return;
  }

  final CharSequence text = myEditor.getDocument().getCharsSequence();
  for (Pair<Integer, ElementPattern<String>> pair : myRestartingPrefixConditions) {
    int start = pair.first;
    if (caretOffset >= start && start >= 0) {
      final String newPrefix = text.subSequence(start, caretOffset).toString();
      if (pair.second.accepts(newPrefix)) {
        scheduleRestart();
        myRestartingPrefixConditions.clear();
        return;
      }
    }
  }

  hideAutopopupIfMeaningless();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:CompletionProgressIndicator.java

示例7: accepts

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PathPattern.java

示例8: collectProducers

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
private MultiMap<SemKey, NullableFunction<PsiElement, ? extends SemElement>> collectProducers() {
  final MultiMap<SemKey, NullableFunction<PsiElement, ? extends SemElement>> map = MultiMap.createSmart();

  final SemRegistrar registrar = new SemRegistrar() {
    @Override
    public <T extends SemElement, V extends PsiElement> void registerSemElementProvider(SemKey<T> key,
                                                                                        final ElementPattern<? extends V> place,
                                                                                        final NullableFunction<V, T> provider) {
      map.putValue(key, new NullableFunction<PsiElement, SemElement>() {
        @Override
        public SemElement fun(PsiElement element) {
          if (place.accepts(element)) {
            return provider.fun((V)element);
          }
          return null;
        }
      });
    }
  };

  for (SemContributorEP contributor : myProject.getExtensions(SemContributor.EP_NAME)) {
    contributor.registerSemProviders(myProject.getPicoContainer(), registrar);
  }

  return map;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SemServiceImpl.java

示例9: isInContext

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
@Override
public boolean isInContext(@NotNull PsiFile file, int offset) {
  if (!super.isInContext(file, offset)) {
    return false;
  }
  final ElementPattern<PsiElement> illegalPattern = or(psiElement().inside(JsonStringLiteral.class),
                                                       psiElement().inside(psiElement(JsonValue.class)
                                                                             .with(new PatternCondition<PsiElement>("insidePropertyKey") {
                                                                               @Override
                                                                               public boolean accepts(@NotNull PsiElement element,
                                                                                                      ProcessingContext context) {
                                                                                 return JsonPsiUtil.isPropertyKey(element);
                                                                               }
                                                                             })));
  return !illegalPattern.accepts(file.findElementAt(offset));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:JsonContextType.java

示例10: getXmlAnnotatedElementsValue

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
private Trinity<Long, Pattern, Collection<String>> getXmlAnnotatedElementsValue() {
  Trinity<Long, Pattern, Collection<String>> index = myXmlIndex;
  if (index == null || myConfiguration.getModificationCount() != index.first.longValue()) {
    final Map<ElementPattern<?>, BaseInjection> map = new THashMap<ElementPattern<?>, BaseInjection>();
    for (BaseInjection injection : myConfiguration.getInjections(XmlLanguageInjectionSupport.XML_SUPPORT_ID)) {
      for (InjectionPlace place : injection.getInjectionPlaces()) {
        if (!place.isEnabled() || place.getElementPattern() == null) continue;
        map.put(place.getElementPattern(), injection);
      }
    }
    final Collection<String> stringSet = PatternValuesIndex.buildStringIndex(map.keySet());
    index = Trinity.create(myConfiguration.getModificationCount(), buildPattern(stringSet), stringSet);
    myXmlIndex = index;
  }
  return index;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XmlLanguageInjector.java

示例11: registerKeyProviders

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:I18nReferenceContributor.java

示例12: withArguments

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public GroovyMethodCallPattern withArguments(final ElementPattern<? extends GrExpression>... arguments) {
  return with(new PatternCondition<GrCallExpression>("withArguments") {
    @Override
    public boolean accepts(@NotNull GrCallExpression callExpression, ProcessingContext context) {
      final GrArgumentList argumentList = callExpression.getArgumentList();
      if (argumentList == null) return false;
      final GrExpression[] actualArguments = argumentList.getExpressionArguments();
      if (arguments.length != actualArguments.length) {
        return false;
      }
      for (int i = 0; i < actualArguments.length; i++) {
        if (!arguments[i].accepts(actualArguments[i], context)) {
          return false;
        }
      }
      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyMethodCallPattern.java

示例13: getUriDefinition

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public static ElementPattern<PsiElement> getUriDefinition() {

        return PlatformPatterns.or(
                PlatformPatterns
                        .psiElement()
                        .withText(
                                StandardPatterns.string().startsWith("app://")
                        )
                        .withLanguage(PhpLanguage.INSTANCE)
                ,
                PlatformPatterns
                        .psiElement()
                        .withText(
                                StandardPatterns.string().startsWith("page://")
                        )
                        .withLanguage(PhpLanguage.INSTANCE)
        );
    }
 
开发者ID:kuma-guy,项目名称:idea-php-bear-sunday-plugin,代码行数:19,代码来源:UriElementPatternHelper.java

示例14: getPrintBlockFunctionPattern

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
/**
 * Check for {{ include('|')  }}
 *
 * @param functionName twig function name
 */
public static ElementPattern<PsiElement> getPrintBlockFunctionPattern(String... functionName) {
    //noinspection unchecked
    return PlatformPatterns
        .psiElement(TwigTokenTypes.STRING_TEXT)
        .withParent(PlatformPatterns.or(
            PlatformPatterns.psiElement(TwigElementTypes.PRINT_BLOCK),
            PlatformPatterns.psiElement(TwigElementTypes.SET_TAG),
            PlatformPatterns.psiElement(TwigElementTypes.IF_TAG)
        ))
        .afterLeafSkipping(
            PlatformPatterns.or(
                PlatformPatterns.psiElement(TwigTokenTypes.LBRACE),
                PlatformPatterns.psiElement(PsiWhiteSpace.class),
                PlatformPatterns.psiElement(TwigTokenTypes.WHITE_SPACE),
                PlatformPatterns.psiElement(TwigTokenTypes.SINGLE_QUOTE),
                PlatformPatterns.psiElement(TwigTokenTypes.DOUBLE_QUOTE)
            ),
            PlatformPatterns.psiElement(TwigTokenTypes.IDENTIFIER).withText(PlatformPatterns.string().oneOf(functionName))
        )
        .withLanguage(TwigLanguage.INSTANCE);
}
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:27,代码来源:TwigUtil.java

示例15: assertNavigationMatch

import com.intellij.patterns.ElementPattern; //导入依赖的package包/类
public void assertNavigationMatch(LanguageFileType languageFileType, String configureByText, ElementPattern<?> pattern) {

        myFixture.configureByText(languageFileType, configureByText);
        PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

        Set<String> targetStrings = new HashSet<>();

        for (GotoDeclarationHandler gotoDeclarationHandler : Extensions.getExtensions(GotoDeclarationHandler.EP_NAME)) {

            PsiElement[] gotoDeclarationTargets = gotoDeclarationHandler.getGotoDeclarationTargets(psiElement, 0, myFixture.getEditor());
            if(gotoDeclarationTargets == null || gotoDeclarationTargets.length == 0) {
                continue;
            }

            for (PsiElement gotoDeclarationTarget : gotoDeclarationTargets) {
                targetStrings.add(gotoDeclarationTarget.toString());
                if(pattern.accepts(gotoDeclarationTarget)) {
                    return;
                }
            }
        }

        fail(String.format("failed that PsiElement (%s) navigate matches one of %s", psiElement.toString(), targetStrings.toString()));
    }
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:25,代码来源:SymfonyLightCodeInsightFixtureTestCase.java


注:本文中的com.intellij.patterns.ElementPattern类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。