use of com.intellij.ide.fileTemplates.impl.CustomFileTemplate in project intellij-community by JetBrains.
the class EmbeddedLiveTemplatesTest method doTest.
protected void doTest(String text, String result) {
CustomFileTemplate template = new CustomFileTemplate("foo", "txt");
template.setText(text);
template.setLiveTemplateEnabled(true);
myFixture.testAction(new TestAction(template));
VirtualFile[] files = FileEditorManager.getInstance(getProject()).getSelectedFiles();
myFixture.openFileInEditor(files[0]);
myFixture.checkResult(result);
}
use of com.intellij.ide.fileTemplates.impl.CustomFileTemplate in project intellij-community by JetBrains.
the class FileTemplateUtil method createTemplate.
@NotNull
public static FileTemplate createTemplate(@NotNull String prefName, @NotNull String extension, @NotNull String content, FileTemplate[] templates) {
final Set<String> names = new HashSet<>();
for (FileTemplate template : templates) {
names.add(template.getName());
}
String name = prefName;
int i = 0;
while (names.contains(name)) {
name = prefName + " (" + ++i + ")";
}
final FileTemplate newTemplate = new CustomFileTemplate(name, extension);
newTemplate.setText(content);
return newTemplate;
}
use of com.intellij.ide.fileTemplates.impl.CustomFileTemplate in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoCreateFileActionTest method doTest.
private static void doTest(@NotNull PsiDirectory dir, @NotNull String newFileName, @NotNull String expectedPackage, @NotNull String expectedPackageWithTestSuffix) {
CustomFileTemplate template = new CustomFileTemplate("testTemplate", "go");
template.setText("package ${GO_PACKAGE_NAME}");
CustomFileTemplate templateWithSuffix = new CustomFileTemplate("testTemplate", "go");
templateWithSuffix.setText("package ${GO_PACKAGE_NAME_WITH_TEST_SUFFIX}");
doTemplateTest(dir, newFileName, expectedPackage, template);
doTemplateTest(dir, newFileName, expectedPackageWithTestSuffix, templateWithSuffix);
}
Aggregations