PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { if (!HighlightingFeature.TEXT_BLOCK_ESCAPES.isAvailable(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR; return new JavaElementVisitor() { @Override public void visitFragment(@NotNull PsiFragment fragment) { check(fragment, fragment.isTextBlock()); } @Override public void visitLiteralExpression(@NotNull PsiLiteralExpression literal) { PsiType type = literal.getType(); if (!TypeUtils.isJavaLangString(type) && !PsiTypes.charType().equals(type)) return; check(literal, literal.isTextBlock()); } private void check(@NotNull PsiElement fragment, boolean textBlock) { for (int pos : findPositions(fragment.getText(), textBlock)) { holder.registerProblem(fragment, TextRange.create(pos, pos + 2), textBlock ? InspectionGadgetsBundle.message("inspection.use.of.slash.s.message") : InspectionGadgetsBundle.message("inspection.use.of.slash.s.non.text.block.message"), new ReplaceWithSpaceFix()); } } }; }