@Override public boolean visit(DeleteEdit edit) { try { org.eclipse.lsp4j.TextEdit te = new org.eclipse.lsp4j.TextEdit(); te.setNewText(""); te.setRange(JDTUtils.toRange(compilationUnit,edit.getOffset(),edit.getLength())); converted.add(te); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Error converting TextEdits", e); } return super.visit(edit); }
/** * @return <code>true</code> if a list of {@link org.eclipse.lsp4j.TextEdit} * contains any actual changes, <code>false</code> otherwise. */ public static boolean hasChanges(List<org.eclipse.lsp4j.TextEdit> edits) { if (edits == null) { return false; } //@formatter:off return edits.stream() .filter(edit -> (!edit.getRange().equals(ZERO_RANGE) || !"".equals(edit.getNewText()))) .findFirst() .isPresent(); //@formatter:on }
@Override @Pure public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ColorPresentation other = (ColorPresentation) obj; if (this.label == null) { if (other.label != null) return false; } else if (!this.label.equals(other.label)) return false; if (this.textEdit == null) { if (other.textEdit != null) return false; } else if (!this.textEdit.equals(other.textEdit)) return false; if (this.additionalTextEdits == null) { if (other.additionalTextEdits != null) return false; } else if (!this.additionalTextEdits.equals(other.additionalTextEdits)) return false; return true; }
public List<TextEdit> transform() { List<TextEdit> inverse = new ArrayList<>(); Iterator<TextEdit> editIterator = edits.iterator(); ch = source.get(); while (editIterator.hasNext()) { TextEdit edit = editIterator.next(); advanceTo(edit.getRange().getStart(), sink); Position undoStart = new Position(currentWriteLine, currentWriteChar); for (int i = 0; i < edit.getNewText().length(); i++) { sink.accept((int) edit.getNewText().charAt(i)); } StringBuilder replaced = new StringBuilder(); advanceTo(edit.getRange().getEnd(), forStringBuilder(replaced)); Position undoEnd = new Position(currentWriteLine, currentWriteChar); inverse.add(new TextEdit(new Range(undoStart, undoEnd), replaced.toString())); } // all edits have been processed. Copy the rest of the chars. while (ch >= 0) { sink.accept(ch); ch = source.get(); } return inverse; }
/** * Returns rendered text-edits. * * @return rendered edits */ @Override public List<TextEdit> getRenderedTextEdits() { List<TextEdit> edits = new ArrayList<>(); //Calculate text-edits positions.forEach( (pos, value) -> value.forEach((placeHolder, content) -> { Position position = new Position(pos.eLine, pos.eCol); Range range = new Range(position, position); TextEdit textEdit = new TextEdit(range, content); edits.add(textEdit); }) ); return edits; }
TextDocument newDoc = doc.copy(); edits.apply(newDoc); TextEdit vscodeEdit = new TextEdit(); vscodeEdit.setRange(doc.toRange(replaceEdit.start, replaceEdit.end-replaceEdit.start)); String newText = replaceEdit.newText; IRegion selection = edits.getSelection(); newText = vscodeIndentFix(doc, vscodeEdit.getRange().getStart(), replaceEdit.newText); vscodeEdit.setNewText(newText); return Optional.of(vscodeEdit);
TextEdit edit = editIterator.next(); while (edit != null) { int currentLine = edit.getRange().getStart().getLine(); Position lineStart = new Position(edit.getRange().getStart().getLine(), 0); Position nextLineStart = new Position(edit.getRange().getStart().getLine() + 1, 0); charStreamIter.advanceTo(lineStart, CharStreamIterator.NULL_CONSUMER); StringBuilder lineText = new StringBuilder(); while (edit != null && edit.getRange().getStart().getLine() == currentLine) { result.add(doConvert(edit, lineText)); if (editIterator.hasNext()) {
@Override @Pure public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.label== null) ? 0 : this.label.hashCode()); result = prime * result + ((this.textEdit== null) ? 0 : this.textEdit.hashCode()); return prime * result + ((this.additionalTextEdits== null) ? 0 : this.additionalTextEdits.hashCode()); } }
/** * Renders the template. * * @return rendered string */ public List<TextEdit> getRenderedTextEdits() { Position position = new Position(0, 0); Range range = new Range(position, position); TextEdit textEdit = new TextEdit(range, getRenderedContent()); List<TextEdit> edits = new ArrayList<>(); edits.add(textEdit); return edits; }
if (proposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION || proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_DECLARATION) { completionBuffer.append(edit.getNewText()); range = edit.getRange(); } else { additionalTextEdits.add(edit); item.setTextEdit(new org.eclipse.lsp4j.TextEdit(range, text)); }else{
@Override @Pure public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.label== null) ? 0 : this.label.hashCode()); result = prime * result + ((this.textEdit== null) ? 0 : this.textEdit.hashCode()); return prime * result + ((this.additionalTextEdits== null) ? 0 : this.additionalTextEdits.hashCode()); } }
@Override public boolean visit(ReplaceEdit edit) { try { org.eclipse.lsp4j.TextEdit te = new org.eclipse.lsp4j.TextEdit(); te.setNewText(edit.getText()); te.setRange(JDTUtils.toRange(compilationUnit,edit.getOffset(),edit.getLength())); converted.add(te); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Error converting TextEdits", e); } return super.visit(edit); }
public ReplaceStringData(DocumentRegion target, String newText) throws BadLocationException { this.uri = target.getDocument().getUri(); this.edit = new TextEdit(target.asRange(), newText); }
public TextEditDto(org.eclipse.lsp4j.TextEdit o) { if (o.getRange() == null) { setRange((org.eclipse.lsp4j.Range)null); } else { org.eclipse.lsp4j.Range rangeVal = new RangeDto(o.getRange()); setRange((org.eclipse.lsp4j.Range)rangeVal); } if (o.getNewText() == null) { setNewText((java.lang.String)null); } else { java.lang.String newTextVal = (java.lang.String)makeDto(o.getNewText());; setNewText((java.lang.String)newTextVal); } }
@Override @Pure public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ColorPresentation other = (ColorPresentation) obj; if (this.label == null) { if (other.label != null) return false; } else if (!this.label.equals(other.label)) return false; if (this.textEdit == null) { if (other.textEdit != null) return false; } else if (!this.textEdit.equals(other.textEdit)) return false; if (this.additionalTextEdits == null) { if (other.additionalTextEdits != null) return false; } else if (!this.additionalTextEdits.equals(other.additionalTextEdits)) return false; return true; }
@Override @Pure public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.label== null) ? 0 : this.label.hashCode()); result = prime * result + ((this.kind== null) ? 0 : this.kind.hashCode()); result = prime * result + ((this.detail== null) ? 0 : this.detail.hashCode()); result = prime * result + ((this.documentation== null) ? 0 : this.documentation.hashCode()); result = prime * result + ((this.deprecated== null) ? 0 : this.deprecated.hashCode()); result = prime * result + ((this.preselect== null) ? 0 : this.preselect.hashCode()); result = prime * result + ((this.sortText== null) ? 0 : this.sortText.hashCode()); result = prime * result + ((this.filterText== null) ? 0 : this.filterText.hashCode()); result = prime * result + ((this.insertText== null) ? 0 : this.insertText.hashCode()); result = prime * result + ((this.insertTextFormat== null) ? 0 : this.insertTextFormat.hashCode()); result = prime * result + ((this.textEdit== null) ? 0 : this.textEdit.hashCode()); result = prime * result + ((this.additionalTextEdits== null) ? 0 : this.additionalTextEdits.hashCode()); result = prime * result + ((this.commitCharacters== null) ? 0 : this.commitCharacters.hashCode()); result = prime * result + ((this.command== null) ? 0 : this.command.hashCode()); return prime * result + ((this.data== null) ? 0 : this.data.hashCode()); } }
@Override public boolean visit(InsertEdit edit) { try { org.eclipse.lsp4j.TextEdit te = new org.eclipse.lsp4j.TextEdit(); te.setNewText(edit.getText()); te.setRange(JDTUtils.toRange(compilationUnit,edit.getOffset(),edit.getLength())); converted.add(te); } catch (JavaModelException e) { JavaLanguageServerPlugin.logException("Error converting TextEdits", e); } return super.visit(edit); }
/** * Get TextEdit from doc attachment info. * * @param attachmentInfo Doc attachment info * @return {@link TextEdit} Text edit for attachment info */ private static TextEdit getTextEdit(DocAttachmentInfo attachmentInfo) { Range range = new Range(attachmentInfo.getDocStartPos(), attachmentInfo.getDocStartPos()); return new TextEdit(range, attachmentInfo.getDocAttachment()); } }
public Document applyChanges(final Iterable<? extends TextEdit> changes) { String newContent = this.contents; for (final TextEdit change : changes) { Range _range = change.getRange(); boolean _tripleEquals = (_range == null); if (_tripleEquals) { newContent = change.getNewText(); } else { final int start = this.getOffSet(change.getRange().getStart()); final int end = this.getOffSet(change.getRange().getEnd()); String _substring = newContent.substring(0, start); String _newText = change.getNewText(); String _plus = (_substring + _newText); String _substring_1 = newContent.substring(end); String _plus_1 = (_plus + _substring_1); newContent = _plus_1; } } Integer _xifexpression = null; if ((this.version != null)) { _xifexpression = Integer.valueOf(((this.version).intValue() + 1)); } else { _xifexpression = null; } return new Document(_xifexpression, newContent); }
if (other.textEdit != null) return false; } else if (!this.textEdit.equals(other.textEdit)) return false; if (this.additionalTextEdits == null) {