@Override protected Couple<String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) { final Couple<String> result = super.doAction(project, psiElement, model); if (result != null && psiElement instanceof PsiLiteralExpression) { final String key = result.first; final StringBuilder buffer = new StringBuilder(); buffer.append('"'); StringUtil.escapeStringCharacters(key.length(), key, buffer); buffer.append('"'); final AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(JavaCreatePropertyFix.class); try { final PsiExpression newKeyLiteral = JavaPsiFacade.getElementFactory(project).createExpressionFromText(buffer.toString(), null); psiElement.replace(newKeyLiteral); } catch (IncorrectOperationException e) { LOG.error(e); } finally { token.finish(); } } return result; }
@Override protected Pair<String, String> doAction(Project project, PsiElement psiElement, I18nizeQuickFixModel model) { final Pair<String, String> result = super.doAction(project, psiElement, model); if (result != null && psiElement instanceof PsiLiteralExpression) { final String key = result.first; final StringBuilder buffer = new StringBuilder(); buffer.append('"'); StringUtil.escapeStringCharacters(key.length(), key, buffer); buffer.append('"'); final AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(JavaCreatePropertyFix.class); try { final PsiExpression newKeyLiteral = JavaPsiFacade.getElementFactory(project).createExpressionFromText(buffer.toString(), null); psiElement.replace(newKeyLiteral); } catch (IncorrectOperationException e) { LOG.error(e); } finally { token.finish(); } } return result; }