private static void addInsertEdits(TextChange textChange, NLSSubstitution[] substitutions, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap, PropertyFileDocumentModel model) { ArrayList<KeyValuePair> keyValuePairsToAdd= new ArrayList<>(); for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doInsert(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { String value= PropertyFileDocumentModel.escape(substitution.getValueNonEmpty(), true) + model.getLineDelimiter(); String key= PropertyFileDocumentModel.escape(substitution.getKey(), false); keyValuePairsToAdd.add(new KeyValuePair(key, value)); } } if (keyValuePairsToAdd.size() > 0) { model.insert(keyValuePairsToAdd.toArray(new KeyValuePair[keyValuePairsToAdd.size()]), textChange); } }
private static void addInsertEdits(TextChange textChange, NLSSubstitution[] substitutions, Map<String, NLSSubstitution> newKeyToSubstMap, Map<String, NLSSubstitution> oldKeyToSubstMap, PropertyFileDocumentModel model) { ArrayList<KeyValuePair> keyValuePairsToAdd= new ArrayList<>(); for (int i= 0; i < substitutions.length; i++) { NLSSubstitution substitution= substitutions[i]; if (doInsert(substitution, newKeyToSubstMap, oldKeyToSubstMap)) { String value= PropertyFileDocumentModel.escape(substitution.getValueNonEmpty(), true) + model.getLineDelimiter(); String key= PropertyFileDocumentModel.escape(substitution.getKey(), false); keyValuePairsToAdd.add(new KeyValuePair(key, value)); } } if (keyValuePairsToAdd.size() > 0) { model.insert(keyValuePairsToAdd.toArray(new KeyValuePair[keyValuePairsToAdd.size()]), textChange); } }
private void addMatch(FileEntry groupElement, String propertyName) { /* * TODO (bug 63794): Should read in .properties file with our own reader and not * with Properties.load(InputStream) . Then, we can remember start position and * original version (not interpreting escape characters) for each property. * * The current workaround is to escape the key again before searching in the * .properties file. However, this can fail if the key is escaped in a different * manner than what PropertyFileDocumentModel.unwindEscapeChars(.) produces. */ String escapedPropertyName= PropertyFileDocumentModel.escape(propertyName, false); int start= findPropertyNameStartPosition(escapedPropertyName); int length; if (start == -1) { // not found -> report at beginning start= 0; length= 0; } else { length= escapedPropertyName.length(); } fResult.addMatch(new Match(groupElement, start, length)); }
private void addMatch(FileEntry groupElement, String propertyName) { /* * TODO (bug 63794): Should read in .properties file with our own reader and not * with Properties.load(InputStream) . Then, we can remember start position and * original version (not interpreting escape characters) for each property. * * The current workaround is to escape the key again before searching in the * .properties file. However, this can fail if the key is escaped in a different * manner than what PropertyFileDocumentModel.unwindEscapeChars(.) produces. */ String escapedPropertyName= PropertyFileDocumentModel.escape(propertyName, false); int start= findPropertyNameStartPosition(escapedPropertyName); int length; if (start == -1) { // not found -> report at beginning start= 0; length= 0; } else { length= escapedPropertyName.length(); } fResult.addMatch(new Match(groupElement, start, length)); }
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); } } } }
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); } } } }
PropertyKeyHyperlinkDetector detector= new PropertyKeyHyperlinkDetector(); detector.setContext(editor); String key= PropertyFileDocumentModel.escape(keyName, false); int offset= document.getLength() - 1; try {
PropertyKeyHyperlinkDetector detector= new PropertyKeyHyperlinkDetector(); detector.setContext(editor); String key= PropertyFileDocumentModel.escape(keyName, false); int offset= document.getLength() - 1; try {