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


Java CollectionUtils.getInterfaceForClass方法代码示例

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


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

示例1: checkToWeaken

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
private void checkToWeaken(PsiType type, PsiTypeElement typeElement, PsiElement variable) {
  if (typeElement == null) {
    return;
  }
  final PsiJavaCodeReferenceElement reference = typeElement.getInnermostComponentReferenceElement();
  if (reference == null) {
    return;
  }
  final PsiElement nameElement = reference.getReferenceNameElement();
  if (nameElement == null) {
    return;
  }
  final Collection<PsiClass> weaklings = WeakestTypeFinder.calculateWeakestClassesNecessary(variable, false, true);
  if (weaklings.isEmpty()) {
    return;
  }
  final PsiClassType javaLangObject = PsiType.getJavaLangObject(nameElement.getManager(), nameElement.getResolveScope());
  final List<PsiClass> weaklingList = new ArrayList<PsiClass>(weaklings);
  final PsiClass objectClass = javaLangObject.resolve();
  weaklingList.remove(objectClass);
  if (weaklingList.isEmpty()) {
    final String typeText = type.getCanonicalText();
    final String interfaceText = CollectionUtils.getInterfaceForClass(typeText);
    if (interfaceText == null) {
      return;
    }
    registerError(nameElement, interfaceText);
  }
  else {
    final PsiClass weakling = weaklingList.get(0);
    final String qualifiedName = weakling.getQualifiedName();
    registerError(nameElement, qualifiedName);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:DeclareCollectionAsInterfaceInspection.java

示例2: visitVariable

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitVariable(@NotNull PsiVariable variable) {
  if (isOnTheFly() && !isCheapEnoughToSearch(variable)) {
    return;
  }
  if (ignoreLocalVariables && variable instanceof PsiLocalVariable) {
    return;
  }
  if (ignorePrivateMethodsAndFields) {
    if (variable instanceof PsiField) {
      if (variable.hasModifierProperty(PsiModifier.PRIVATE)) {
        return;
      }
    }
  }
  if (variable instanceof PsiParameter) {
    final PsiParameter parameter = (PsiParameter)variable;
    final PsiElement scope = parameter.getDeclarationScope();
    if (scope instanceof PsiMethod) {
      if (ignorePrivateMethodsAndFields) {
        final PsiMethod method = (PsiMethod)scope;
        if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
          return;
        }
      }
    }
    else if (ignoreLocalVariables) {
      return;
    }
  }
  final PsiType type = variable.getType();
  if (!CollectionUtils.isCollectionClass(type)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethodParameter(variable)) {
    return;
  }
  final PsiTypeElement typeElement = variable.getTypeElement();
  if (typeElement == null) {
    return;
  }
  final PsiJavaCodeReferenceElement reference =
    typeElement.getInnermostComponentReferenceElement();
  if (reference == null) {
    return;
  }
  final PsiElement nameElement = reference.getReferenceNameElement();
  if (nameElement == null) {
    return;
  }
  final Collection<PsiClass> weaklings =
    WeakestTypeFinder.calculateWeakestClassesNecessary(variable,
                                                       false, true);
  if (weaklings.isEmpty()) {
    return;
  }
  final List<PsiClass> weaklingList = new ArrayList(weaklings);
  final PsiClassType javaLangObject = TypeUtils.getObjectType(variable);
  final PsiClass objectClass = javaLangObject.resolve();
  weaklingList.remove(objectClass);
  if (weaklingList.isEmpty()) {
    final String typeText = type.getCanonicalText();
    final String interfaceText =
      CollectionUtils.getInterfaceForClass(typeText);
    registerError(nameElement, interfaceText);
  }
  else {
    final PsiClass weakling = weaklingList.get(0);
    final String qualifiedName = weakling.getQualifiedName();
    registerError(nameElement, qualifiedName);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:73,代码来源:DeclareCollectionAsInterfaceInspection.java

示例3: visitMethod

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  super.visitMethod(method);
  if (ignorePrivateMethodsAndFields &&
      method.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  if (isOnTheFly() && !isCheapEnoughToSearch(method)) {
    return;
  }
  final PsiType type = method.getReturnType();
  if (type == null || !CollectionUtils.isCollectionClass(type)) {
    return;
  }
  if (LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  final PsiTypeElement typeElement = method.getReturnTypeElement();
  if (typeElement == null) {
    return;
  }
  final PsiJavaCodeReferenceElement referenceElement =
    typeElement.getInnermostComponentReferenceElement();
  if (referenceElement == null) {
    return;
  }
  final PsiElement nameElement =
    referenceElement.getReferenceNameElement();
  if (nameElement == null) {
    return;
  }
  final Collection<PsiClass> weaklings =
    WeakestTypeFinder.calculateWeakestClassesNecessary(method,
                                                       false, true);
  if (weaklings.isEmpty()) {
    return;
  }
  final List<PsiClass> weaklingList = new ArrayList(weaklings);
  final PsiClassType javaLangObject = TypeUtils.getObjectType(method);
  final PsiClass objectClass = javaLangObject.resolve();
  weaklingList.remove(objectClass);
  if (weaklingList.isEmpty()) {
    final String typeText = type.getCanonicalText();
    final String interfaceText =
      CollectionUtils.getInterfaceForClass(typeText);
    registerError(nameElement, interfaceText);
  }
  else {
    final PsiClass weakling = weaklingList.get(0);
    registerError(nameElement, weakling.getQualifiedName());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:53,代码来源:DeclareCollectionAsInterfaceInspection.java

示例4: checkToWeaken

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
private void checkToWeaken(PsiType type, PsiTypeElement typeElement, PsiElement variable)
{
	if(typeElement == null)
	{
		return;
	}
	final PsiJavaCodeReferenceElement reference = typeElement.getInnermostComponentReferenceElement();
	if(reference == null)
	{
		return;
	}
	final PsiElement nameElement = reference.getReferenceNameElement();
	if(nameElement == null)
	{
		return;
	}
	final Collection<PsiClass> weaklings = WeakestTypeFinder.calculateWeakestClassesNecessary(variable, false, true);
	if(weaklings.isEmpty())
	{
		return;
	}
	final PsiClassType javaLangObject = PsiType.getJavaLangObject(nameElement.getManager(), nameElement.getResolveScope());
	final List<PsiClass> weaklingList = new ArrayList<>(weaklings);
	final PsiClass objectClass = javaLangObject.resolve();
	weaklingList.remove(objectClass);
	if(weaklingList.isEmpty())
	{
		final String typeText = type.getCanonicalText();
		final String interfaceText = CollectionUtils.getInterfaceForClass(typeText);
		if(interfaceText == null)
		{
			return;
		}
		registerError(nameElement, interfaceText);
	}
	else
	{
		final PsiClass weakling = weaklingList.get(0);
		final String qualifiedName = weakling.getQualifiedName();
		registerError(nameElement, qualifiedName);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:43,代码来源:DeclareCollectionAsInterfaceInspection.java


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