Package org.eclipse.lemminx.utils
Class TextEditUtils
- java.lang.Object
-
- org.eclipse.lemminx.utils.TextEditUtils
-
public class TextEditUtils extends Object
Utilities forTextEdit.- Author:
- Angelo ZERR
-
-
Constructor Summary
Constructors Constructor Description TextEditUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intadjustOffsetWithLeftWhitespaces(int leftLimit, int to, String text)Returns the offset of the first whitespace that's found in the given range [leftLimit,to] from the left of the to, and leftLimit otherwise.static StringapplyEdits(TextDocument document, List<? extends org.eclipse.lsp4j.TextEdit> edits)static org.eclipse.lsp4j.TextEditcreateTextEditIfNeeded(int from, int to, String expectedContent, TextDocument textDocument)Returns theTextEditto insert the given expected content from the given range (from, to) of the given text document and null otherwise.static org.eclipse.lsp4j.WorkspaceEditcreateWorkspaceEdit(List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.TextDocumentEdit,org.eclipse.lsp4j.ResourceOperation>> documentChanges)static org.eclipse.lsp4j.TextDocumentEditcreatTextDocumentEdit(DOMDocument document, List<org.eclipse.lsp4j.TextEdit> textEdits)Creates a TextDocumentEdit object for the specified document and list of text edits
-
-
-
Method Detail
-
createTextEditIfNeeded
public static org.eclipse.lsp4j.TextEdit createTextEditIfNeeded(int from, int to, String expectedContent, TextDocument textDocument)Returns theTextEditto insert the given expected content from the given range (from, to) of the given text document and null otherwise.- Parameters:
from- the range from.to- the range to.expectedContent- the expected content.textDocument- the text document.- Returns:
- the
TextEditto insert the given expected content from the given range (from, to) of the given text document and null otherwise.
-
applyEdits
public static String applyEdits(TextDocument document, List<? extends org.eclipse.lsp4j.TextEdit> edits) throws BadLocationException
- Throws:
BadLocationException
-
adjustOffsetWithLeftWhitespaces
public static int adjustOffsetWithLeftWhitespaces(int leftLimit, int to, String text)Returns the offset of the first whitespace that's found in the given range [leftLimit,to] from the left of the to, and leftLimit otherwise.- Parameters:
leftLimit- the left limit range.to- the to range.- Returns:
- the offset of the first whitespace that's found in the given range [leftLimit,to] from the left of the to, and leftLimit otherwise.
-
creatTextDocumentEdit
public static org.eclipse.lsp4j.TextDocumentEdit creatTextDocumentEdit(DOMDocument document, List<org.eclipse.lsp4j.TextEdit> textEdits)
Creates a TextDocumentEdit object for the specified document and list of text edits- Parameters:
document- Document to be changedtextEdits- a list of text edit changes- Returns:
- A Text Dpcument Edit object
-
createWorkspaceEdit
public static org.eclipse.lsp4j.WorkspaceEdit createWorkspaceEdit(List<org.eclipse.lsp4j.jsonrpc.messages.Either<org.eclipse.lsp4j.TextDocumentEdit,org.eclipse.lsp4j.ResourceOperation>> documentChanges)
-
-