use of com.intellij.ide.fileTemplates.FileTemplate in project intellij-community by JetBrains.
the class GroovyGenerateMethodMissingHandler method generateMemberPrototypes.
@NotNull
@Override
protected List<? extends GenerationInfo> generateMemberPrototypes(PsiClass aClass, ClassMember[] members) throws IncorrectOperationException {
final String templName = JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY;
final FileTemplate template = FileTemplateManager.getInstance(aClass.getProject()).getCodeTemplate(templName);
final GrMethod method = genMethod(aClass, template);
return method != null ? Collections.singletonList(new GroovyGenerationInfo<>(method, true)) : Collections.<GenerationInfo>emptyList();
}
use of com.intellij.ide.fileTemplates.FileTemplate in project intellij-community by JetBrains.
the class CCUtils method createTaskContent.
public static void createTaskContent(@NotNull Project project, @Nullable IdeView view, @NotNull Course course, PsiDirectory taskDirectory) {
CCLanguageManager manager = getStudyLanguageManager(course);
if (manager == null) {
return;
}
createFromTemplate(taskDirectory, manager.getTestsTemplate(project), view, false);
createFromTemplate(taskDirectory, FileTemplateManager.getInstance(project).getInternalTemplate(StudyUtils.getTaskDescriptionFileName(CCSettings.getInstance().useHtmlAsDefaultTaskFormat())), view, false);
String defaultExtension = manager.getDefaultTaskFileExtension();
if (defaultExtension != null) {
FileTemplate taskFileTemplate = manager.getTaskFileTemplateForExtension(project, defaultExtension);
createFromTemplate(taskDirectory, taskFileTemplate, view, true);
}
}
use of com.intellij.ide.fileTemplates.FileTemplate in project intellij-community by JetBrains.
the class PyMoveTest method testTemplateAttributesExpansionInCreatedDestinationModule.
// PY-14979
public void testTemplateAttributesExpansionInCreatedDestinationModule() {
final FileTemplateManager instance = FileTemplateManager.getInstance(myFixture.getProject());
final FileTemplate template = instance.getInternalTemplate("Python Script");
assertNotNull(template);
final String oldTemplateContent = template.getText();
try {
template.setText("NAME = '${NAME}'");
doMoveSymbolTest("C", "b.py");
} finally {
template.setText(oldTemplateContent);
}
}
use of com.intellij.ide.fileTemplates.FileTemplate in project intellij-community by JetBrains.
the class JavaI18nizeQuickFixDialog method getI18nizedText.
public String getI18nizedText() {
String propertyKey = StringUtil.escapeStringCharacters(getKey());
I18nizedTextGenerator textGenerator = myResourceBundleManager.getI18nizedTextGenerator();
if (textGenerator != null) {
return generateText(textGenerator, propertyKey, getPropertiesFile(), myLiteralExpression);
}
String templateName = getTemplateName();
LOG.assertTrue(templateName != null);
FileTemplate template = FileTemplateManager.getInstance(myProject).getCodeTemplate(templateName);
Map<String, String> attributes = new THashMap<>();
attributes.put(PROPERTY_KEY_OPTION_KEY, propertyKey);
attributes.put(RESOURCE_BUNDLE_OPTION_KEY, getResourceBundleText());
attributes.put(PROPERTY_VALUE_ATTR, StringUtil.escapeStringCharacters(myDefaultPropertyValue));
addAdditionalAttributes(attributes);
String text = null;
try {
text = template.getText(attributes);
} catch (IOException e) {
LOG.error(e);
}
return text;
}
use of com.intellij.ide.fileTemplates.FileTemplate in project intellij-community by JetBrains.
the class JavaI18nizeQuickFixDialog method suggestAvailableResourceBundleExpressions.
private void suggestAvailableResourceBundleExpressions() {
String templateName = getTemplateName();
if (templateName == null)
return;
if (myShowJavaCodeInfo) {
FileTemplate template = FileTemplateManager.getInstance(myProject).getCodeTemplate(templateName);
boolean showResourceBundleSuggester = template.getText().contains("${" + RESOURCE_BUNDLE_OPTION_KEY + "}");
myJavaCodeInfoPanel.setVisible(showResourceBundleSuggester);
}
Set<String> result = JavaI18nUtil.suggestExpressionOfType(myResourceBundleType, myLiteralExpression);
if (result.isEmpty()) {
result.add(getResourceBundleText());
}
myRBEditorTextField.setHistory(ArrayUtil.toStringArray(result));
SwingUtilities.invokeLater(() -> myRBEditorTextField.setSelectedIndex(0));
}
Aggregations