本文整理汇总了Java中com.siyeh.ig.psiutils.CollectionUtils.isConstantEmptyArray方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.isConstantEmptyArray方法的具体用法?Java CollectionUtils.isConstantEmptyArray怎么用?Java CollectionUtils.isConstantEmptyArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.siyeh.ig.psiutils.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.isConstantEmptyArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitField
import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
super.visitField(field);
if (!field.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
if (!field.hasModifierProperty(PsiModifier.STATIC)) {
return;
}
final PsiType type = field.getType();
if (!(type instanceof PsiArrayType)) {
return;
}
if (CollectionUtils.isConstantEmptyArray(field)) {
return;
}
registerFieldError(field);
}
示例2: visitMethodCallExpression
import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
@NonNls final String methodName = methodExpression.getReferenceName();
if (!"toArray".equals(methodName)) {
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if (arguments.length != 1) {
return;
}
final PsiExpression argument = arguments[0];
final PsiType type = argument.getType();
if (!(type instanceof PsiArrayType)) {
return;
}
if (type.getArrayDimensions() != 1) {
return;
}
if (argument instanceof PsiReferenceExpression) {
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)argument;
final PsiElement element = referenceExpression.resolve();
if (!(element instanceof PsiField)) {
return;
}
final PsiField field = (PsiField)element;
if (!CollectionUtils.isConstantEmptyArray(field)) {
return;
}
}
else if (!ExpressionUtils.isZeroLengthArrayConstruction(argument)) {
return;
}
final PsiMethod method = expression.resolveMethod();
if (method == null) {
return;
}
final PsiClass containingClass = method.getContainingClass();
if (!InheritanceUtil.isInheritor(containingClass, CommonClassNames.JAVA_UTIL_COLLECTION)) {
return;
}
registerMethodCallError(expression, expression, argument);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:46,代码来源:ToArrayCallWithZeroLengthArrayArgumentInspectionBase.java
示例3: visitMethodCallExpression
import com.siyeh.ig.psiutils.CollectionUtils; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression)
{
super.visitMethodCallExpression(expression);
final PsiReferenceExpression methodExpression = expression.getMethodExpression();
@NonNls final String methodName = methodExpression.getReferenceName();
if(!"toArray".equals(methodName))
{
return;
}
final PsiExpressionList argumentList = expression.getArgumentList();
final PsiExpression[] arguments = argumentList.getExpressions();
if(arguments.length != 1)
{
return;
}
final PsiExpression argument = arguments[0];
final PsiType type = argument.getType();
if(!(type instanceof PsiArrayType))
{
return;
}
if(type.getArrayDimensions() != 1)
{
return;
}
if(argument instanceof PsiReferenceExpression)
{
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression) argument;
final PsiElement element = referenceExpression.resolve();
if(!(element instanceof PsiField))
{
return;
}
final PsiField field = (PsiField) element;
if(!CollectionUtils.isConstantEmptyArray(field))
{
return;
}
}
else if(!ConstructionUtils.isEmptyArrayInitializer(argument))
{
return;
}
final PsiMethod method = expression.resolveMethod();
if(method == null)
{
return;
}
final PsiClass containingClass = method.getContainingClass();
if(!InheritanceUtil.isInheritor(containingClass, CommonClassNames.JAVA_UTIL_COLLECTION))
{
return;
}
registerMethodCallError(expression, expression, argument);
}
开发者ID:consulo,项目名称:consulo-java,代码行数:57,代码来源:ToArrayCallWithZeroLengthArrayArgumentInspectionBase.java