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


Java ElementPattern.accepts方法代码示例

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


在下文中一共展示了ElementPattern.accepts方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: assertPhpReferenceResolveTo

import com.intellij.patterns.ElementPattern; //导入方法依赖的package包/类
public void assertPhpReferenceResolveTo(LanguageFileType languageFileType, String configureByText, ElementPattern<?> pattern) {
    myFixture.configureByText(languageFileType, configureByText);
    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());

    psiElement = PsiTreeUtil.getParentOfType(psiElement, PhpReference.class);
    if (psiElement == null) {
        fail("Element is not PhpReference.");
    }

    PsiElement resolve = ((PhpReference) psiElement).resolve();
    if(!pattern.accepts(resolve)) {
        fail(String.format("failed pattern matches element of '%s'", resolve == null ? "null" : resolve.toString()));
    }

    assertTrue(pattern.accepts(resolve));
}
 
开发者ID:Haehnchen,项目名称:idea-php-toolbox,代码行数:17,代码来源:SymfonyLightCodeInsightFixtureTestCase.java

示例7: findPrefixDefault

import com.intellij.patterns.ElementPattern; //导入方法依赖的package包/类
public static String findPrefixDefault(final PsiElement insertedElement, final int offset, @NotNull final ElementPattern trimStart) {
  String substr = insertedElement.getText().substring(0, offset - insertedElement.getTextRange().getStartOffset());
  if (substr.length() == 0 || Character.isWhitespace(substr.charAt(substr.length() - 1))) return "";

  substr = substr.trim();

  int i = 0;
  while (substr.length() > i && trimStart.accepts(substr.charAt(i))) i++;
  return substr.substring(i).trim();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:CompletionData.java

示例8: fromClassPattern

import com.intellij.patterns.ElementPattern; //导入方法依赖的package包/类
public static ClassContextFilter fromClassPattern(final ElementPattern pattern) {
  return new ClassContextFilter(new Condition<Pair<PsiType, PsiFile>>() {
    @Override
    public boolean value(Pair<PsiType, PsiFile> pair) {
      final PsiType type = pair.first;
      return type instanceof PsiClassType ? pattern.accepts(((PsiClassType)type).resolve()) : false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ClassContextFilter.java

示例9: doTest

import com.intellij.patterns.ElementPattern; //导入方法依赖的package包/类
private boolean doTest(final String text, final ElementPattern<PsiElement> ref) {
  myFixture.configureByText(PythonFileType.INSTANCE, text);
  PsiElement element = myFixture.getFile().findElementAt(text.length() - 1);
  return ref.accepts(element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PyCompletionPatternsTest.java

示例10: isAfterForParameter

import com.intellij.patterns.ElementPattern; //导入方法依赖的package包/类
private static boolean isAfterForParameter(PsiElement position) {
  ElementPattern<PsiElement> forParameter =
    PsiJavaPatterns.psiElement().withParents(GrParameter.class, GrTraditionalForClause.class, GrForStatement.class);
  return PsiJavaPatterns.psiElement().withParent(GrReferenceExpression.class).afterLeaf(forParameter).accepts(position) ||
         forParameter.accepts(position) && PsiJavaPatterns.psiElement().afterLeaf(PsiJavaPatterns.psiElement(GroovyTokenTypes.mIDENT)).accepts(position);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:GroovyCompletionData.java

示例11: isAfterForParameter

import com.intellij.patterns.ElementPattern; //导入方法依赖的package包/类
private static boolean isAfterForParameter(PsiElement position) {
  ElementPattern<PsiElement> forParameter =
    psiElement().withParents(GrParameter.class, GrTraditionalForClause.class, GrForStatement.class);
  return psiElement().withParent(GrReferenceExpression.class).afterLeaf(forParameter).accepts(position) ||
         forParameter.accepts(position) && psiElement().afterLeaf(psiElement(GroovyTokenTypes.mIDENT)).accepts(position);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:GroovyCompletionData.java


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