• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PsiReferenceList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: roleToElementType

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


示例17: encodeRole

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
private static byte encodeRole(PsiReferenceList.Role role) {
  switch (role) {
    case EXTENDS_LIST:        return 0;
    case IMPLEMENTS_LIST:     return 1;
    case THROWS_LIST:         return 2;
    case EXTENDS_BOUNDS_LIST: return 3;
  }
  throw new RuntimeException("Unknown role: " + role);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaClassReferenceListElementType.java


示例18: decodeRole

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
private static PsiReferenceList.Role decodeRole(byte code) {
  switch (code) {
    case 0: return PsiReferenceList.Role.EXTENDS_LIST;
    case 1: return PsiReferenceList.Role.IMPLEMENTS_LIST;
    case 2: return PsiReferenceList.Role.THROWS_LIST;
    case 3: return PsiReferenceList.Role.EXTENDS_BOUNDS_LIST;
  }
  throw new RuntimeException("Unknown role code: " + code);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaClassReferenceListElementType.java


示例19: newReferenceList

import com.intellij.psi.PsiReferenceList; //导入依赖的package包/类
public static void newReferenceList(JavaClassReferenceListElementType type, StubElement parent, String... types) {
  PsiReferenceList.Role role;

  if (type == JavaStubElementTypes.EXTENDS_LIST) role = PsiReferenceList.Role.EXTENDS_LIST;
  else if (type == JavaStubElementTypes.IMPLEMENTS_LIST) role = PsiReferenceList.Role.IMPLEMENTS_LIST;
  else if (type == JavaStubElementTypes.THROWS_LIST) role = PsiReferenceList.Role.THROWS_LIST;
  else if (type == JavaStubElementTypes.EXTENDS_BOUND_LIST) role = PsiReferenceList.Role.EXTENDS_BOUNDS_LIST;
  else throw new IllegalArgumentException("Unknown type: " + type);

  new PsiClassReferenceListStubImpl(type, parent, types, role);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:StubBuildingVisitor.java


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResourceExtractor类代码示例发布时间:2022-05-22
下一篇:
Java MetaClassHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap