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


Java PsiReferenceList.getReferenceElements方法代码示例

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


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

示例1: visitClass

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  final PsiReferenceList implementsList = aClass.getImplementsList();
  if (implementsList == null) {
    return;
  }
  final PsiJavaCodeReferenceElement[] references =
    implementsList.getReferenceElements();
  for (final PsiJavaCodeReferenceElement reference : references) {
    final PsiElement target = reference.resolve();
    if (!(target instanceof PsiClass)) {
      return;
    }
    final PsiClass targetClass = (PsiClass)target;
    if (targetClass.isInterface() && interfaceContainsOnlyConstants(targetClass, new HashSet<PsiClass>())) {
      registerError(reference);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:StaticInheritanceInspection.java

示例2: satisfiedBy

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@Override
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiReferenceList)) {
    return false;
  }
  final PsiReferenceList throwsList = (PsiReferenceList)element;
  if (throwsList.getReferenceElements().length < 2) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiMethod)) {
    return false;
  }
  final PsiMethod method = (PsiMethod)parent;
  return method.getThrowsList().equals(element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ObscureThrownExceptionsPredicate.java

示例3: visitClass

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  final PsiReferenceList implementsList = aClass.getImplementsList();
  if (implementsList == null) {
    return;
  }
  final PsiJavaCodeReferenceElement[] references =
    implementsList.getReferenceElements();
  for (final PsiJavaCodeReferenceElement reference : references) {
    final PsiClass iface = (PsiClass)reference.resolve();
    if (iface != null) {
      if (interfaceContainsOnlyConstants(iface, new HashSet<PsiClass>())) {
        registerError(reference);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:StaticInheritanceInspection.java

示例4: checkReferenceList

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
private void checkReferenceList(PsiReferenceList referenceList,
                                PsiClass containingClass) {
  if (referenceList == null) {
    return;
  }
  final PsiJavaCodeReferenceElement[] elements =
    referenceList.getReferenceElements();
  for (final PsiJavaCodeReferenceElement element : elements) {
    final PsiElement referent = element.resolve();
    if (!(referent instanceof PsiClass)) {
      continue;
    }
    final PsiClass psiClass = (PsiClass)referent;
    psiClass.isAnnotationType();
    if (psiClass.isAnnotationType()) {
      registerError(element, containingClass);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ExtendsAnnotationInspection.java

示例5: addSuperClass

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
public static void addSuperClass(@NotNull PsiClass targetClass, @NotNull PsiClass superClass, @NotNull Project project)
{
    if (classHasDirectSuperClass(targetClass, superClass))
    {
        return;
    }

    final PsiReferenceList psiReferenceList = targetClass.getExtendsList();
    if (psiReferenceList == null)
    {
        return;
    }

    if (psiReferenceList.getReferenceElements().length != 0 && !targetClass.isInterface())
    {
        final String message = "Multiple inheritance is not allowed. " + targetClass.getName() + " already contains a super class.";
        throw new IncorrectOperationException(message);
    }
    else
    {
        psiReferenceList.add(getElementFactory(project).createClassReferenceElement(superClass));
    }
}
 
开发者ID:monday-consulting,项目名称:idea-coremedia-plugin,代码行数:24,代码来源:PsiClassUtil.java

示例6: getImplementationNames

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@NotNull
private static List<String> getImplementationNames(@NotNull List<PsiProvidesStatement> statements)
{
	List<String> list = new ArrayList<>();
	for(PsiProvidesStatement statement : statements)
	{
		PsiReferenceList implementationList = statement.getImplementationList();
		if(implementationList == null)
		{
			continue;
		}
		for(PsiJavaCodeReferenceElement element : implementationList.getReferenceElements())
		{
			ContainerUtil.addIfNotNull(list, element.getQualifiedName());
		}
	}
	return list;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:MergeProvidesStatementsFix.java

示例7: visitMethod

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  if (!TestUtils.isJUnitTestMethod(method)) {
    return;
  }
  final PsiReferenceList throwsList = method.getThrowsList();
  final PsiJavaCodeReferenceElement[] referenceElements =
    throwsList.getReferenceElements();
  if (referenceElements.length < 2) {
    return;
  }

  final Query<PsiReference> query =
    MethodReferencesSearch.search(method);
  final PsiReference firstReference = query.findFirst();
  if (firstReference != null) {
    return;
  }
  registerError(throwsList);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:MultipleExceptionsDeclaredOnTestMethodInspection.java

示例8: visitMethod

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  // note: no call to super
  if (method.getNameIdentifier() == null) {
    return;
  }
  final PsiReferenceList throwList = method.getThrowsList();
  final PsiJavaCodeReferenceElement[] thrownExceptions =
    throwList.getReferenceElements();
  final int exceptionCount = thrownExceptions.length;
  if (exceptionCount <= getLimit()) {
    return;
  }
  registerMethodError(method, Integer.valueOf(exceptionCount));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ThrownExceptionsPerMethodInspection.java

示例9: referenceListContainsClass

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
private static boolean referenceListContainsClass(@NotNull PsiReferenceList psiReferenceList, @NotNull PsiClass aClass)
{
    for (PsiJavaCodeReferenceElement element : psiReferenceList.getReferenceElements())
    {
        if (element.getQualifiedName().equals(aClass.getQualifiedName()))
        {
            return true;
        }
    }
    return false;
}
 
开发者ID:monday-consulting,项目名称:idea-coremedia-plugin,代码行数:12,代码来源:PsiClassUtil.java

示例10: visitMethod

import com.intellij.psi.PsiReferenceList; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (ignoreTestCases) {
    final PsiClass containingClass = method.getContainingClass();
    if (containingClass != null && TestFrameworks.getInstance().isTestClass(containingClass)) {
      return;
    }
    if (TestUtils.isJUnitTestMethod(method)) {
      return;
    }
  }
  if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  final PsiReferenceList throwsList = method.getThrowsList();
  final PsiJavaCodeReferenceElement[] references = throwsList.getReferenceElements();
  for (PsiJavaCodeReferenceElement reference : references) {
    final PsiElement element = reference.resolve();
    if (!(element instanceof PsiClass)) {
      continue;
    }
    final PsiClass thrownClass = (PsiClass)element;
    final String qualifiedName = thrownClass.getQualifiedName();
    if (qualifiedName != null && exceptions.contains(qualifiedName)) {
      registerError(reference);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:BadExceptionDeclaredInspection.java


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