PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { @Override public void visitReturnStatement(@NotNull PsiReturnStatement statement) { PsiExpression returnValue = statement.getReturnValue(); if (returnValue == null) return; PsiType type = returnValue.getType(); if (type == null) return; if (!type.equalsToText("byte") && !type.equalsToText(CommonClassNames.JAVA_LANG_BYTE)) { return; } process(returnValue); } private void process(PsiExpression expression) { PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class); if (method == null) return; if (!READ_INPUT_STREAM.methodMatches(method)) return; registerProblem(expression); } private void registerProblem(PsiExpression expression) { holder.registerProblem(expression, JavaBundle.message("inspection.suspicious.return.byte.input.stream.name"), new ConvertToUnsignedByteFix()); } }; }