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


Java PsiNonJavaFileReferenceProcessor类代码示例

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


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

示例1: findExtensionPointCandidates

import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor; //导入依赖的package包/类
private static void findExtensionPointCandidates(PsiClass psiClass, final List<ExtensionPointCandidate> list) {
  String name = psiClass.getQualifiedName();
  if (name == null) {
    return;
  }

  final Project project = psiClass.getProject();
  final Collection<VirtualFile> candidates = DomService.getInstance().getDomFileCandidates(IdeaPlugin.class, project, GlobalSearchScope.allScope(project));
  GlobalSearchScope scope = GlobalSearchScope.filesScope(project, candidates);
  PsiSearchHelper.SERVICE.getInstance(project).processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
    @Override
    public boolean process(PsiFile file, int startOffset, int endOffset) {
      PsiElement element = file.findElementAt(startOffset);
      processExtensionPointCandidate(element, list);
      return true;
    }
  }, scope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ExtensionPointLocator.java

示例2: findExtensionPointCandidates

import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor; //导入依赖的package包/类
private static void findExtensionPointCandidates(PsiClass aClass, final List<ExtensionPointCandidate> list) {
  String name = aClass.getQualifiedName();
  if (name == null) {
    return;
  }
  GlobalSearchScope scope = GlobalSearchScope.getScopeRestrictedByFileTypes(ProjectScope.getAllScope(aClass.getProject()), XmlFileType.INSTANCE);
  PsiSearchHelper.SERVICE.getInstance(aClass.getProject()).processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
    @Override
    public boolean process(PsiFile file, int startOffset, int endOffset) {
      PsiElement element = file.findElementAt(startOffset);
      processExtensionPointCandidate(element, list);
      return true;
    }
  }, scope);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:RegisterExtensionFixProvider.java

示例3: getItems

import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor; //导入依赖的package包/类
@NotNull
@Override
public List<? extends GotoRelatedItem> getItems(@NotNull PsiElement context) {
  PsiClass psiClass = PsiTreeUtil.getParentOfType(context, PsiClass.class, false);
  if (psiClass != null) {
    final Project project = psiClass.getProject();
    while (psiClass != null && TestNGUtil.hasTest(psiClass) && PsiClassUtil.isRunnableClass(psiClass, true)) {
      final String qName = psiClass.getQualifiedName();
      if (qName != null) {
        final String packageQName = ((PsiJavaFile)psiClass.getContainingFile()).getPackageName();
        final String packageName = StringUtil.getShortName(packageQName);
        final String[] names;
        if (packageQName.length() > 0) {
          final String pName = packageName.length() > 0 ? packageName : packageQName;
          names = new String[]{qName, pName};
        }
        else {
          names = new String[]{qName};
        }
        final List<PsiElement> tags = new ArrayList<PsiElement>();
        for (final String name : names) {
          PsiSearchHelper.SERVICE.getInstance(project)
            .processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
              public boolean process(final PsiFile file, final int startOffset, final int endOffset) {
                final PsiReference referenceAt = file.findReferenceAt(startOffset);
                if (referenceAt != null) {
                  if (packageQName.endsWith(name)) { //special package tag required
                    final XmlTag tag = PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), XmlTag.class);
                    if (tag == null || !tag.getName().equals("package")) {
                      return true;
                    }
                    final XmlAttribute attribute = tag.getAttribute("name");
                    if (attribute == null) return true;
                    final String value = attribute.getValue();
                    if (value == null) return true;
                    if (!(value.equals(StringUtil.getQualifiedName(packageQName, "*")) || value.equals(packageQName))) return true;
                  }
                  tags.add(referenceAt.getElement());
                }
                return true;
              }
            }, new TestNGSearchScope(project));
        }

        if (!tags.isEmpty()) {
          return GotoRelatedItem.createItems(tags, "TestNG");
        }
      }
      psiClass = PsiTreeUtil.getParentOfType(psiClass, PsiClass.class);
    }
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:TestNGRelatedFilesProvider.java

示例4: checkClass

import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor; //导入依赖的package包/类
@Nullable
public ProblemDescriptor[] checkClass(@NotNull final PsiClass aClass,
                                      @NotNull final InspectionManager manager,
                                      final boolean isOnTheFly) {
  if (TestNGUtil.hasTest(aClass) && PsiClassUtil.isRunnableClass(aClass, true)) {
    final Project project = aClass.getProject();
    final String qName = aClass.getQualifiedName();
    if (qName == null) return null;
    final String packageQName = StringUtil.getPackageName(qName);
    final List<String> names = new ArrayList<String>();
    for(int i = 0; i < qName.length(); i++) {
      if (qName.charAt(i) == '.') {
        names.add(qName.substring(0, i));
      }
    }
    names.add(qName);
    Collections.reverse(names);

    for (final String name : names) {
      final boolean isFullName = qName.equals(name);
      final boolean[] found = new boolean[]{false};
      PsiSearchHelper.SERVICE.getInstance(project)
        .processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
          public boolean process(final PsiFile file, final int startOffset, final int endOffset) {
            if (file.findReferenceAt(startOffset) != null) {
              if (!isFullName) { //special package tag required
                final XmlTag tag = PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), XmlTag.class);
                if (tag == null || !tag.getName().equals("package")) {
                  return true;
                }
                final XmlAttribute attribute = tag.getAttribute("name");
                if (attribute == null) return true;
                final String value = attribute.getValue();
                if (value == null) return true;
                if (!value.endsWith(".*") && !value.equals(packageQName)) return true;
              }
              found[0] = true;
              return false;
            }
            return true;
          }
        }, new TestNGSearchScope(project));
      if (found[0]) return null;
    }
    final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
    LOG.assertTrue(nameIdentifier != null);
    return new ProblemDescriptor[]{manager.createProblemDescriptor(nameIdentifier, "Undeclared test \'" + aClass.getName() + "\'",
                                                                   isOnTheFly, new LocalQuickFix[]{new RegisterClassFix(aClass),
                                                                     new CreateTestngFix()},
                                                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:54,代码来源:UndeclaredTestInspection.java

示例5: checkClass

import com.intellij.psi.search.PsiNonJavaFileReferenceProcessor; //导入依赖的package包/类
@Nullable
public ProblemDescriptor[] checkClass(@NotNull final PsiClass aClass,
                                      @NotNull final InspectionManager manager,
                                      final boolean isOnTheFly) {
  if (TestNGUtil.hasTest(aClass) && PsiClassUtil.isRunnableClass(aClass, true)) {
    final Project project = aClass.getProject();
    final String qName = aClass.getQualifiedName();
    if (qName == null) return null;

    final List<String> names = new ArrayList<String>();
    for(int i = 0; i < qName.length(); i++) {
      if (qName.charAt(i) == '.') {
        names.add(qName.substring(0, i));
      }
    }
    names.add(qName);
    Collections.reverse(names);

    for (final String name : names) {
      final boolean isFullName = qName.equals(name);
      final boolean[] found = new boolean[]{false};
      PsiSearchHelper.SERVICE.getInstance(project)
        .processUsagesInNonJavaFiles(name, new PsiNonJavaFileReferenceProcessor() {
          public boolean process(final PsiFile file, final int startOffset, final int endOffset) {
            if (file.findReferenceAt(startOffset) != null) {
              if (!isFullName) { //special package tag required
                final XmlTag tag = PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), XmlTag.class);
                if (tag == null || !tag.getName().equals("package")) {
                  return true;
                }
                final XmlAttribute attribute = tag.getAttribute("name");
                if (attribute == null) return true;
                final String value = attribute.getValue();
                if (value == null) return true;
                if (!value.endsWith(".*")) return true;
              }
              found[0] = true;
              return false;
            }
            return true;
          }
        }, new TestNGSearchScope(project));
      if (found[0]) return null;
    }
    final PsiIdentifier nameIdentifier = aClass.getNameIdentifier();
    LOG.assertTrue(nameIdentifier != null);
    return new ProblemDescriptor[]{manager.createProblemDescriptor(nameIdentifier, "Undeclared test \'" + aClass.getName() + "\'",
                                                                   isOnTheFly, new LocalQuickFix[]{new RegisterClassFix(aClass),
                                                                     new CreateTestngFix()},
                                                                   ProblemHighlightType.GENERIC_ERROR_OR_WARNING)};
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:54,代码来源:UndeclaredTestInspection.java


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