ModCommand (@NotNull ActionContext context, @NotNull PsiElement element) { final String text; if (element instanceof PsiFragment) { text = buildStringTemplateText((PsiTemplate)element.getParent()); } else { PsiPolyadicExpression polyadic = PsiTreeUtil.getNonStrictParentOfType(element, PsiPolyadicExpression.class); if (ExpressionUtils.isStringConcatenation(polyadic)) { text = buildConcatenationText(polyadic); } else if (element.getParent() instanceof PsiLiteralExpression literalExpression) { if (!(literalExpression.getValue() instanceof String string)) { return ModCommand.nop(); } text = string; } else { return ModCommand.nop(); } } return ModCommand.copyToClipboard(text); }