当前位置: 首页>>代码示例>>Java>>正文


Java I18nQuickFixHandler类代码示例

本文整理汇总了Java中com.intellij.codeInspection.i18n.I18nQuickFixHandler的典型用法代码示例。如果您正苦于以下问题:Java I18nQuickFixHandler类的具体用法?Java I18nQuickFixHandler怎么用?Java I18nQuickFixHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


I18nQuickFixHandler类属于com.intellij.codeInspection.i18n包,在下文中一共展示了I18nQuickFixHandler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTest

import com.intellij.codeInspection.i18n.I18nQuickFixHandler; //导入依赖的package包/类
private void doTest(@NonNls String ext) throws Exception {
  configureByFile(getBasePath() + "/before"+getTestName(false)+"."+ext);
  I18nizeAction action = new I18nizeAction();
  DataContext dataContext = DataManager.getInstance().getDataContext(myEditor.getComponent());
  AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "place", dataContext);
  action.update(event);
  @NonNls String afterFile = getBasePath() + "/after" + getTestName(false) + "." + ext;
  boolean afterFileExists = new File(PathManagerEx.getTestDataPath() + afterFile).exists();
  I18nQuickFixHandler handler = I18nizeAction.getHandler(event);
  try {
    if (handler != null) {
      handler.checkApplicability(getFile(), getEditor());
    }
  }
  catch (IncorrectOperationException e) {
    event.getPresentation().setEnabled(false);
  }
  assertEquals(afterFileExists, event.getPresentation().isEnabled());

  if (afterFileExists) {
    PsiLiteralExpression literalExpression = I18nizeAction.getEnclosingStringLiteral(getFile(), getEditor());
    assertNotNull(handler);
    handler.performI18nization(getFile(), getEditor(), literalExpression, Collections.<PropertiesFile>emptyList(), "key1", "value1", "i18nizedExpr",
                               PsiExpression.EMPTY_ARRAY, JavaI18nUtil.DEFAULT_PROPERTY_CREATION_HANDLER);
    checkResultByFile(afterFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:I18nizeTest.java

示例2: doTest

import com.intellij.codeInspection.i18n.I18nQuickFixHandler; //导入依赖的package包/类
private void doTest(@NonNls String ext) throws Exception {
  configureByFile(getBasePath() + "/before"+getTestName(false)+"."+ext);
  I18nizeAction action = new I18nizeAction();
  DataContext dataContext = DataManager.getInstance().getDataContext(myEditor.getComponent());
  AnActionEvent event = new AnActionEvent(null, dataContext, "place", action.getTemplatePresentation(), null, 0);
  action.update(event);
  @NonNls String afterFile = getBasePath() + "/after" + getTestName(false) + "." + ext;
  boolean afterFileExists = new File(PathManagerEx.getTestDataPath() + afterFile).exists();
  I18nQuickFixHandler handler = action.getHandler(event);
  try {
    if (handler != null) {
      handler.checkApplicability(getFile(), getEditor());
    }
  }
  catch (IncorrectOperationException e) {
    event.getPresentation().setEnabled(false);
  }
  assertEquals(afterFileExists, event.getPresentation().isEnabled());

  if (afterFileExists) {
    PsiLiteralExpression literalExpression = I18nizeAction.getEnclosingStringLiteral(getFile(), getEditor());
    assertNotNull(handler);
    handler.performI18nization(getFile(), getEditor(), literalExpression, Collections.<PropertiesFile>emptyList(), "key1", "value1", "i18nizedExpr",
                               PsiExpression.EMPTY_ARRAY, JavaI18nUtil.DEFAULT_PROPERTY_CREATION_HANDLER);
    checkResultByFile(afterFile);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:I18nizeTest.java

示例3: doTest

import com.intellij.codeInspection.i18n.I18nQuickFixHandler; //导入依赖的package包/类
private void doTest(@NonNls String ext) throws Exception {
  configureByFile(getBasePath() + "/before"+getTestName(false)+"."+ext);
  I18nizeAction action = new I18nizeAction();
  DataContext dataContext = DataManager.getInstance().getDataContext(myEditor.getComponent());
  AnActionEvent event = new AnActionEvent(null, dataContext, "place", action.getTemplatePresentation(), null, 0);
  action.update(event);
  @NonNls String afterFile = getBasePath() + "/after" + getTestName(false) + "." + ext;
  boolean afterFileExists = new File(afterFile).exists();
  I18nQuickFixHandler handler = action.getHandler(event);
  try {
    if (handler != null) {
      handler.checkApplicability(getFile(), getEditor());
    }
  }
  catch (IncorrectOperationException e) {
    event.getPresentation().setEnabled(false);
  }
  assertEquals(afterFileExists, event.getPresentation().isEnabled());

  if (afterFileExists) {
    PsiLiteralExpression literalExpression = I18nizeAction.getEnclosingStringLiteral(getFile(), getEditor());
    assertNotNull(handler);
    handler.performI18nization(getFile(), getEditor(), literalExpression, Collections.<PropertiesFile>emptyList(), "key1", "value1", "i18nizedExpr",
                               PsiExpression.EMPTY_ARRAY, JavaI18nUtil.DEFAULT_PROPERTY_CREATION_HANDLER);
    checkResultByFile(afterFile);
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:28,代码来源:I18nizeTest.java


注:本文中的com.intellij.codeInspection.i18n.I18nQuickFixHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。