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


Java CollectionUtils.isArrayOrCollectionField方法代码示例

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


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

示例1: visitReturnStatement

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
  super.visitReturnStatement(statement);
  final PsiExpression returnValue = statement.getReturnValue();
  if (returnValue == null) {
    return;
  }
  final PsiElement element = PsiTreeUtil.getParentOfType(statement, PsiMethod.class, PsiLambdaExpression.class);
  if (element == null) {
    return;
  }
  if (ignorePrivateMethods && element instanceof PsiMethod && ((PsiMethod)element).hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  final PsiClass returnStatementClass = PsiTreeUtil.getParentOfType(statement, PsiClass.class);
  if (returnStatementClass == null) {
    return;
  }
  if (!(returnValue instanceof PsiReferenceExpression)) {
    return;
  }
  final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)returnValue;
  final PsiElement referent = referenceExpression.resolve();
  if (!(referent instanceof PsiField)) {
    return;
  }
  final PsiField field = (PsiField)referent;
  final PsiClass fieldClass = field.getContainingClass();
  if (!returnStatementClass.equals(fieldClass)) {
    return;
  }
  if (!CollectionUtils.isArrayOrCollectionField(field)) {
    return;
  }
  registerError(returnValue, field, returnValue);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ReturnOfCollectionFieldInspectionBase.java

示例2: visitReturnStatement

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
  super.visitReturnStatement(statement);
  final PsiExpression returnValue = statement.getReturnValue();
  if (returnValue == null) {
    return;
  }
  final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(statement, PsiMethod.class);
  if (containingMethod == null) {
    return;
  }
  if (ignorePrivateMethods && containingMethod.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  final PsiClass returnStatementClass = containingMethod.getContainingClass();
  if (returnStatementClass == null) {
    return;
  }
  if (!(returnValue instanceof PsiReferenceExpression)) {
    return;
  }
  final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)returnValue;
  final PsiElement referent = referenceExpression.resolve();
  if (!(referent instanceof PsiField)) {
    return;
  }
  final PsiField field = (PsiField)referent;
  final PsiClass fieldClass = field.getContainingClass();
  if (!returnStatementClass.equals(fieldClass)) {
    return;
  }
  if (!CollectionUtils.isArrayOrCollectionField(field)) {
    return;
  }
  registerError(returnValue, field, returnValue);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:ReturnOfCollectionFieldInspectionBase.java

示例3: visitAssignmentExpression

import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitAssignmentExpression(@NotNull
                                      PsiAssignmentExpression expression) {
  super.visitAssignmentExpression(expression);
  final PsiExpression rhs = expression.getRExpression();
  if (!(rhs instanceof PsiReferenceExpression)) {
    return;
  }
  final IElementType tokenType = expression.getOperationTokenType();
  if (!tokenType.equals(JavaTokenType.EQ)) {
    return;
  }
  final PsiExpression lhs = expression.getLExpression();
  if (!(lhs instanceof PsiReferenceExpression)) {
    return;
  }
  if (ignorePrivateMethods) {
    final PsiMethod containingMethod =
      PsiTreeUtil.getParentOfType(expression,
                                  PsiMethod.class);
    if (containingMethod == null ||
        containingMethod.hasModifierProperty(
          PsiModifier.PRIVATE)) {
      return;
    }
  }
  final PsiElement element = ((PsiReference)rhs).resolve();
  if (!(element instanceof PsiParameter)) {
    return;
  }
  if (!(element.getParent() instanceof PsiParameterList)) {
    return;
  }
  final PsiReferenceExpression referenceExpression =
    (PsiReferenceExpression)lhs;
  final PsiElement referent = referenceExpression.resolve();
  if (!(referent instanceof PsiField)) {
    return;
  }
  final PsiField field = (PsiField)referent;
  if (!CollectionUtils.isArrayOrCollectionField(field)) {
    return;
  }
  registerError(lhs, rhs, field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:AssignmentToCollectionFieldFromParameterInspection.java


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