@Override void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException { if (fSource == null) throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.no_source")); //$NON-NLS-1$ if (fSource.getTargetEdit() != this) throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.different_target")); //$NON-NLS-1$ }
@Override void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException { if (fSource == null) throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.no_source")); //$NON-NLS-1$ if (fSource.getTargetEdit() != this) throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.different_target")); //$NON-NLS-1$ }
/** * Sets the source edit. * * @param edit the source edit * * @exception MalformedTreeException is thrown if the target edit * is a direct or indirect child of the source edit */ public void setSourceEdit(MoveSourceEdit edit) { if (fSource != edit) { fSource= edit; fSource.setTargetEdit(this); TextEdit parent= getParent(); while (parent != null) { if (parent == fSource) throw new MalformedTreeException(parent, this, TextEditMessages.getString("MoveTargetEdit.wrong_parent")); //$NON-NLS-1$ parent= parent.getParent(); } } }
/** * Sets the source edit. * * @param edit the source edit * * @exception MalformedTreeException is thrown if the target edit * is a direct or indirect child of the source edit */ public void setSourceEdit(MoveSourceEdit edit) { if (fSource != edit) { fSource= edit; fSource.setTargetEdit(this); TextEdit parent= getParent(); while (parent != null) { if (parent == fSource) throw new MalformedTreeException(parent, this, TextEditMessages.getString("MoveTargetEdit.wrong_parent")); //$NON-NLS-1$ parent= parent.getParent(); } } }
@Override public boolean visit(MoveSourceEdit edit) { try { // If MoveSourcedEdit & MoveTargetEdit are the same level, should delete the original contenxt. // See issue#https://github.com/redhat-developer/vscode-java/issues/253 if (edit.getParent() != null && edit.getTargetEdit() != null && edit.getParent().equals(edit.getTargetEdit().getParent())) { org.eclipse.lsp4j.TextEdit te = new org.eclipse.lsp4j.TextEdit(); te.setNewText(""); te.setRange(JDTUtils.toRange(compilationUnit, edit.getOffset(), edit.getLength())); converted.add(te); return false; } } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Error converting TextEdits", e); } return super.visit(edit); }