Search in sources :

Example 1 with I18nizedTextGenerator

use of com.intellij.lang.properties.psi.I18nizedTextGenerator 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;
}
Also used : I18nizedTextGenerator(com.intellij.lang.properties.psi.I18nizedTextGenerator) THashMap(gnu.trove.THashMap) FileTemplate(com.intellij.ide.fileTemplates.FileTemplate) IOException(java.io.IOException)

Aggregations

FileTemplate (com.intellij.ide.fileTemplates.FileTemplate)1 I18nizedTextGenerator (com.intellij.lang.properties.psi.I18nizedTextGenerator)1 THashMap (gnu.trove.THashMap)1 IOException (java.io.IOException)1