use of com.intellij.codeInsight.template.impl.editorActions.ExpandLiveTemplateByTabAction in project Perl5-IDEA by Camelcade.
the class PerlLightTestCase method doLiveTemplateTest.
protected void doLiveTemplateTest(@NotNull String fileName, @NotNull String textToType) {
initWithFileSmart(fileName);
Editor editor = getEditor();
Document document = editor.getDocument();
CaretModel caretModel = editor.getCaretModel();
List<Integer> caretsOffsets = getAndRemoveCarets();
String originalText = document.getText();
StringBuilder sb = new StringBuilder();
for (Integer offset : caretsOffsets) {
WriteCommandAction.runWriteCommandAction(getProject(), () -> {
caretModel.moveToOffset(offset);
EditorModificationUtil.insertStringAtCaret(editor, textToType);
String textBeforeAction = document.getText();
myFixture.testAction(new ExpandLiveTemplateByTabAction());
if (!StringUtil.equals(document.getText(), textBeforeAction)) {
sb.append(StringUtil.repeat("-", 80)).append("\n").append("Caret offset: ").append(offset).append("\n").append(StringUtil.repeat("-", 80)).append("\n").append(getEditorTextWithCaretsAndSelections());
}
TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
if (templateState != null) {
templateState.gotoEnd(true);
}
document.setText(originalText);
});
}
UsefulTestCase.assertSameLinesWithFile(getTestResultsFilePath(), sb.toString());
}
Aggregations