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