Java 类com.intellij.lang.properties.references.I18nizeQuickFixModel 实例源码

项目:intellij-ce-playground    文件:JavaCreatePropertyFix.java   
@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;
}
项目:tools-idea    文件:JavaCreatePropertyFix.java   
@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;
}
项目:consulo-java    文件:JavaCreatePropertyFix.java   
@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;
}