private static boolean isNullLiteralExpression(PsiElement expr) { if (expr instanceof PsiLiteralExpression) { final PsiLiteralExpression literalExpression = (PsiLiteralExpression) expr; return PsiType.NULL.equals(literalExpression.getType()); } return false; }
@Override public void visitLiteralExpression(@NotNull PsiLiteralExpression expression) { super.visitLiteralExpression(expression); final PsiType type = expression.getType(); if (!ClassUtils.isPrimitiveNumericType(type)) { return; } if (PsiType.CHAR.equals(type)) { return; } if (isSpecialCaseLiteral(expression)) { return; } if (ExpressionUtils.isDeclaredConstant(expression)) { return; } if (ignoreInHashCode) { final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class); if (MethodUtils.isHashCode(containingMethod)) { return; } } if (ignoreInTestCode && TestUtils.isInTestCode(expression)) { return; } final PsiElement parent = expression.getParent(); if (parent instanceof PsiPrefixExpression) { registerError(parent); } else { registerError(expression); } }
public boolean satisfiedBy(PsiElement element) { if (!(element instanceof PsiLiteralExpression)) { return false; } final PsiLiteralExpression expression = (PsiLiteralExpression) element; final PsiType type = expression.getType(); if (!PsiType.CHAR.equals(type)) { return false; } final String charLiteral = element.getText(); if (charLiteral.length() < 2) return false; // Incomplete char literal probably without closing amp final String charText = charLiteral.substring(1, charLiteral.length() - 1); if (StringUtil.unescapeStringCharacters(charText).length() != 1) { // not satisfied with character literals of more than one character return false; } return isInConcatenationContext(expression); }