本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}