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


Java PsiReferenceList类代码示例

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


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

示例1: indexStub

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
@Override
public void indexStub(@NotNull PsiClassReferenceListStub stub, @NotNull IndexSink sink) {
  PsiReferenceList.Role role = stub.getRole();
  if (role == PsiReferenceList.Role.EXTENDS_LIST || role == PsiReferenceList.Role.IMPLEMENTS_LIST) {
    String[] names = stub.getReferencedNames();
    for (String name : names) {
      String shortName = PsiNameHelper.getShortClassName(name);
      if (!StringUtil.isEmptyOrSpaces(shortName)) {
        sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, shortName);
      }
    }

    if (role == PsiReferenceList.Role.EXTENDS_LIST) {
      StubElement parentStub = stub.getParentStub();
      if (parentStub instanceof PsiClassStub) {
        PsiClassStub psiClassStub = (PsiClassStub)parentStub;
        if (psiClassStub.isEnum()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Enum");
        }
        if (psiClassStub.isAnnotationType()) {
          sink.occurrence(JavaStubIndexKeys.SUPER_CLASSES, "Annotation");
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:JavaClassReferenceListElementType.java

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

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

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

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

示例6: makeClassImplementParcelable

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
/**
 * Make the class implementing Parcelable
 */
private void makeClassImplementParcelable(PsiElementFactory elementFactory, JavaCodeStyleManager styleManager) {
  final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
  final String implementsType = "android.os.Parcelable";

  for (PsiClassType implementsListType : implementsListTypes) {
    PsiClass resolved = implementsListType.resolve();

    // Already implements Parcelable, no need to add it
    if (resolved != null && implementsType.equals(resolved.getQualifiedName())) {
      return;
    }
  }

  PsiJavaCodeReferenceElement implementsReference =
      elementFactory.createReferenceFromText(implementsType, psiClass);
  PsiReferenceList implementsList = psiClass.getImplementsList();

  if (implementsList != null) {
    styleManager.shortenClassReferences(implementsList.add(implementsReference));
  }
}
 
开发者ID:sockeqwe,项目名称:ParcelablePlease,代码行数:25,代码来源:CodeGenerator.java

示例7: compareThrows

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
private void compareThrows(PsiReferenceList beforeThrows, PsiReferenceList afterThrows, PsiMethod psiMethod) {
  PsiClassType[] beforeTypes = beforeThrows.getReferencedTypes();
  PsiClassType[] afterTypes = afterThrows.getReferencedTypes();

  assertEquals("Throws counts are different for Method :" + psiMethod.getName(), beforeTypes.length, afterTypes.length);
  for (PsiClassType beforeType : beforeTypes) {
    boolean found = false;
    for (PsiClassType afterType : afterTypes) {
      if (beforeType.equals(afterType)) {
        found = true;
        break;
      }
    }
    assertTrue("Expected throw: " + beforeType.getClassName() + " not found on " + psiMethod.getName(), found);
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:17,代码来源:AbstractLombokParsingTestCase.java

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

示例9: elementTypeToRole

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
@NotNull
public static PsiReferenceList.Role elementTypeToRole(@NotNull IElementType type)
{
	if(type == JavaStubElementTypes.EXTENDS_BOUND_LIST)
	{
		return PsiReferenceList.Role.EXTENDS_BOUNDS_LIST;
	}
	if(type == JavaStubElementTypes.EXTENDS_LIST)
	{
		return PsiReferenceList.Role.EXTENDS_LIST;
	}
	if(type == JavaStubElementTypes.IMPLEMENTS_LIST)
	{
		return PsiReferenceList.Role.IMPLEMENTS_LIST;
	}
	if(type == JavaStubElementTypes.THROWS_LIST)
	{
		return PsiReferenceList.Role.THROWS_LIST;
	}
	if(type == JavaStubElementTypes.PROVIDES_WITH_LIST)
	{
		return PsiReferenceList.Role.PROVIDES_WITH_LIST;
	}
	throw new RuntimeException("Unknown element type: " + type);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:JavaClassReferenceListElementType.java

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

示例11: getPreferredCondition

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
@Nullable
protected Preference getPreferredCondition(@NotNull final PsiElement position)
{
	if(INSIDE_REFERENCE_LIST.accepts(position))
	{
		PsiReferenceList list = (PsiReferenceList) position.getParent().getParent();
		PsiReferenceList.Role role = list.getRole();
		if(shouldContainInterfaces(list, role))
		{
			return Preference.Interfaces;
		}
		if(role == PsiReferenceList.Role.EXTENDS_LIST)
		{
			return Preference.Classes;
		}
		if(role == PsiReferenceList.Role.THROWS_LIST)
		{
			return Preference.Exceptions;

		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:24,代码来源:ReferenceListWeigher.java

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

示例13: getBoundingType

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
private static PsiClass getBoundingType( PsiTypeParameter tp )
{
  PsiReferenceList extendsList = tp.getExtendsList();
  PsiClassType[] referencedTypes = extendsList.getReferencedTypes();
  if( referencedTypes.length > 0 )
  {
    return referencedTypes[0].resolve();
  }
  return ClassUtil.findPsiClass( tp.getManager(), Object.class.getName() );
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:11,代码来源:TypeUtil.java

示例14: deserialize

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
@NotNull
@Override
public PsiClassReferenceListStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
  byte role = dataStream.readByte();

  int len = dataStream.readVarInt();
  StringRef[] names = StringRef.createArray(len);
  for (int i = 0; i < names.length; i++) {
    names[i] = dataStream.readName();
  }

  PsiReferenceList.Role decodedRole = decodeRole(role);
  return new PsiClassReferenceListStubImpl(roleToElementType(decodedRole), parentStub, names, decodedRole);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaClassReferenceListElementType.java

示例15: elementTypeToRole

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
private static PsiReferenceList.Role elementTypeToRole(IElementType type) {
  if (type == JavaStubElementTypes.EXTENDS_BOUND_LIST) return PsiReferenceList.Role.EXTENDS_BOUNDS_LIST;
  else if (type == JavaStubElementTypes.EXTENDS_LIST) return PsiReferenceList.Role.EXTENDS_LIST;
  else if (type == JavaStubElementTypes.IMPLEMENTS_LIST) return PsiReferenceList.Role.IMPLEMENTS_LIST;
  else if (type == JavaStubElementTypes.THROWS_LIST) return PsiReferenceList.Role.THROWS_LIST;
  throw new RuntimeException("Unknown element type: " + type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JavaClassReferenceListElementType.java


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