use of com.intellij.codeInspection.i18n.I18nizeAction in project intellij-community by JetBrains.
the class I18nizeTest method doTest.
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);
ApplicationManager.getApplication().runWriteAction(() -> handler.performI18nization(getFile(), getEditor(), literalExpression, Collections.<PropertiesFile>emptyList(), "key1", "value1", "i18nizedExpr", PsiExpression.EMPTY_ARRAY, JavaI18nUtil.DEFAULT_PROPERTY_CREATION_HANDLER));
checkResultByFile(afterFile);
}
}
Aggregations