/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }
private String applySourceModifier(String content, ISourceModifier modifier) { if (StringUtils.isBlank(content) || modifier == null) { return content; } SimpleDocument subDocument = new SimpleDocument(content); TextEdit newEdit = new MultiTextEdit(0, subDocument.getLength()); ReplaceEdit[] replaces = modifier.getModifications(content); for (ReplaceEdit replace : replaces) { newEdit.addChild(replace); } try { newEdit.apply(subDocument, TextEdit.NONE); } catch (BadLocationException e) { JavaLanguageServerPlugin.logException("Error applying edit to document", e); } return subDocument.get(); } }
/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }
/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }
/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }
/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }
/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }
/** * Apply the given edit on the given string and return the updated string. * Return the given string if anything wrong happen while applying the edit. * * @param original the given string * @param edit the given edit * * @return the updated string */ public final static String editedString(String original, TextEdit edit) { if (edit == null) { return original; } SimpleDocument document = new SimpleDocument(original); try { edit.apply(document, TextEdit.NONE); return document.get(); } catch (MalformedTreeException e) { e.printStackTrace(); } catch (BadLocationException e) { e.printStackTrace(); } return original; }