static boolean doRemove(NLSSubstitution substitution, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap) { if (substitution.getInitialState() != NLSSubstitution.EXTERNALIZED || substitution.getInitialKey() == null) { return false; // was not in property file before } if (oldKeyToSubstMap.get(substitution.getInitialKey()) != substitution) { return false; // not the owner of this key } if (substitution.hasStateChanged()) { return true; // was externalized, but not anymore } else { if (substitution.hasPropertyFileChange() && newKeyToSubstMap.get(substitution.getKey()) != substitution) { return true; // has been changed to an already existing } } return false; }
private static void addRemoveEdits(TextChange textChange, NLSSubstitution[] substitutions, Map newKeyToSubstMap, Map oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doRemove(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { TextEdit edit= model.remove(substitution.getInitialKey()); if (edit != null) { TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_remove_entry, substitution.getInitialKey()), edit); } } } }
private static void addRemoveEdits(TextChange textChange, NLSSubstitution[] substitutions, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doRemove(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { TextEdit edit= model.remove(substitution.getInitialKey()); if (edit != null) { TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_remove_entry, BasicElementLabels.getJavaElementName(substitution.getInitialKey())), edit); } } } }
private static void addRemoveEdits(TextChange textChange, NLSSubstitution[] substitutions, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doRemove(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { TextEdit edit= model.remove(substitution.getInitialKey()); if (edit != null) { TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_remove_entry, BasicElementLabels.getJavaElementName(substitution.getInitialKey())), edit); } } } }
static boolean doInsert(NLSSubstitution substitution, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED) { return false; // does not go into the property file } if (!substitution.hasStateChanged() && substitution.getInitialValue() != null) { if (!substitution.isKeyRename() || oldKeyToSubstMap.get(substitution.getInitialKey()) == substitution) { return false; // no key rename and was not a duplicate } } if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only insert if we're not a duplicate return true; } return false; }
static boolean doInsert(NLSSubstitution substitution, Map newKeyToSubstMap, Map oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED) { return false; // does not go into the property file } if (!substitution.hasStateChanged() && substitution.getInitialValue() != null) { if (!substitution.isKeyRename() || oldKeyToSubstMap.get(substitution.getInitialKey()) == substitution) { return false; // no key rename and was not a duplicate } } if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only insert if we're not a duplicate return true; } return false; }
static boolean doInsert(NLSSubstitution substitution, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED) { return false; // does not go into the property file } if (!substitution.hasStateChanged() && substitution.getInitialValue() != null) { if (!substitution.isKeyRename() || oldKeyToSubstMap.get(substitution.getInitialKey()) == substitution) { return false; // no key rename and was not a duplicate } } if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only insert if we're not a duplicate return true; } return false; }
static boolean doReplace(NLSSubstitution substitution, Map newKeyToSubstMap, Map oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED || substitution.hasStateChanged() || substitution.getInitialValue() == null) { return false; // was not in property file before } if (oldKeyToSubstMap.get(substitution.getInitialKey()) != substitution) { return false; // not the owner of this key } if (substitution.isKeyRename() || substitution.isValueRename()) { if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only rename if we're not a duplicate. duplicates will be removed return true; } } return false; }
static boolean doReplace(NLSSubstitution substitution, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED || substitution.hasStateChanged() || substitution.getInitialValue() == null) { return false; // was not in property file before } if (oldKeyToSubstMap.get(substitution.getInitialKey()) != substitution) { return false; // not the owner of this key } if (substitution.isKeyRename() || substitution.isValueRename()) { if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only rename if we're not a duplicate. duplicates will be removed return true; } } return false; }
static boolean doReplace(NLSSubstitution substitution, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap) { if (substitution.getState() != NLSSubstitution.EXTERNALIZED || substitution.hasStateChanged() || substitution.getInitialValue() == null) { return false; // was not in property file before } if (oldKeyToSubstMap.get(substitution.getInitialKey()) != substitution) { return false; // not the owner of this key } if (substitution.isKeyRename() || substitution.isValueRename()) { if (newKeyToSubstMap.get(substitution.getKey()) == substitution) { // only rename if we're not a duplicate. duplicates will be removed return true; } } return false; }
private void removeKey(NLSSubstitution sub, TextChange change) { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_remove_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); change.addTextEditGroup(editGroup); fFields.remove(node); }
private void renameKey(NLSSubstitution sub, TextChange change) throws CoreException { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_replace_entry, sub.getKey()); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); fFields.remove(node); addKey(sub, change, editGroup); change.addTextEditGroup(editGroup); }
private void removeKey(NLSSubstitution sub, TextChange change) { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_remove_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); change.addTextEditGroup(editGroup); fFields.remove(node); }
private void renameKey(NLSSubstitution sub, TextChange change) { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_replace_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); fFields.remove(node); addKey(sub, editGroup); change.addTextEditGroup(editGroup); }
private void renameKey(NLSSubstitution sub, TextChange change) { ASTNode node= findField(fRoot, sub.getInitialKey()); if (node == null) return; String name= Messages.format(NLSMessages.AccessorClassModifier_replace_entry, BasicElementLabels.getJavaElementName(sub.getKey())); TextEditGroup editGroup= new TextEditGroup(name); fListRewrite.remove(node, editGroup); fFields.remove(node); addKey(sub, editGroup); change.addTextEditGroup(editGroup); }
private static void addReplaceEdits(TextChange textChange, NLSSubstitution[] substitutions, Map newKeyToSubstMap, Map oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doReplace(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { KeyValuePair initialPair= new KeyValuePair(substitution.getInitialKey(), substitution.getInitialValue()); KeyValuePair newPair= new KeyValuePair(substitution.getKey(), substitution.getValueNonEmpty()); TextEdit edit= model.replace(initialPair, newPair); if (edit != null) { TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_replace_entry, substitution.getKey()), edit); } } } }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), substitution.getKey()}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), BasicElementLabels.getJavaElementName(substitution.getKey())}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private void replaceKey(NLSSubstitution substitution, TextChange change) { Region region= substitution.getNLSElement().getPosition(); String[] args= {substitution.getInitialKey(), BasicElementLabels.getJavaElementName(substitution.getKey())}; ReplaceEdit replaceEdit; if (fIsEclipseNLS) replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), substitution.getKey()); else replaceEdit= new ReplaceEdit(region.getOffset(), region.getLength(), '\"' + unwindEscapeChars(substitution.getKey()) + '\"'); // TextChangeCompatibility.addTextEdit(change, Messages.format(NLSMessages.NLSSourceModifier_replace_key, args), replaceEdit); }
private static void addReplaceEdits(TextChange textChange, NLSSubstitution[] substitutions, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap, PropertyFileDocumentModel model) { for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doReplace(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { KeyValuePair initialPair= new KeyValuePair(substitution.getInitialKey(), substitution.getInitialValue()); String key= PropertyFileDocumentModel.escape(substitution.getKey(), false); String value= PropertyFileDocumentModel.escape(substitution.getValue(), true) + model.getLineDelimiter(); KeyValuePair newPair= new KeyValuePair(key, value); TextEdit edit= model.replace(initialPair, newPair); if (edit != null) { TextChangeCompatibility.addTextEdit(textChange, Messages.format(NLSMessages.NLSPropertyFileModifier_replace_entry, BasicElementLabels.getJavaElementName(substitution.getKey())), edit); } } } }