private void insertPropertyLast(String key, String value, PropertiesFile propertiesFile) {
   final List<IProperty> properties = propertiesFile.getProperties();
   final IProperty lastProperty =
       properties.isEmpty() ? null : properties.get(properties.size() - 1);
   myCodeStyleManager.reformat(
       propertiesFile.addPropertyAfter(key, value, lastProperty).getPsiElement());
 }
  protected static void collectPropertiesFileVariants(
      @Nullable PropertiesFile file, @Nullable String prefix, List<Object> result) {
    if (file == null) return;

    for (IProperty each : file.getProperties()) {
      String name = each.getKey();
      if (name != null) {
        if (prefix != null) name = prefix + name;
        result.add(createLookupElement(each, name, PlatformIcons.PROPERTY_ICON));
      }
    }
  }
 ResourceBundleKeyRenameValidator(
     Project project,
     ResourceBundleEditor editor,
     ResourceBundle bundle,
     String oldPropertyName) {
   myEditor = editor;
   myOldPropertyName = oldPropertyName;
   for (PropertiesFile file : bundle.getPropertiesFiles(project)) {
     for (IProperty property : file.getProperties()) {
       myExistingProperties.add(property.getKey());
     }
   }
   myExistingProperties.remove(oldPropertyName);
 }
  private static void sortPropertiesFile(final PropertiesFile file) {
    final List<IProperty> properties = new ArrayList<IProperty>(file.getProperties());

    Collections.sort(
        properties,
        new Comparator<IProperty>() {
          @Override
          public int compare(IProperty p1, IProperty p2) {
            return Comparing.compare(p1.getKey(), p2.getKey());
          }
        });
    final char delimiter =
        PropertiesCodeStyleSettings.getInstance(file.getProject()).KEY_VALUE_DELIMITER;
    final StringBuilder rawText = new StringBuilder();
    for (int i = 0; i < properties.size(); i++) {
      IProperty property = properties.get(i);
      final String value = property.getUnescapedValue();
      rawText.append(
          PropertiesElementFactory.getPropertyText(
              property.getKey(), value != null ? value : "", delimiter, null));
      if (i != properties.size() - 1) {
        rawText.append("\n");
      }
    }

    final PropertiesFile fakeFile =
        PropertiesElementFactory.createPropertiesFile(file.getProject(), rawText.toString());

    final PropertiesList propertiesList =
        PsiTreeUtil.findChildOfType(file.getContainingFile(), PropertiesList.class);
    LOG.assertTrue(propertiesList != null);
    final PropertiesList fakePropertiesList =
        PsiTreeUtil.findChildOfType(fakeFile.getContainingFile(), PropertiesList.class);
    LOG.assertTrue(fakePropertiesList != null);
    propertiesList.replace(fakePropertiesList);
  }