本文整理汇总了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);
}
}
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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));
}
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
}
}