Package org.sonar.python.quickfix
Class TextEditUtils
java.lang.Object
org.sonar.python.quickfix.TextEditUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic PythonTextEditinsertAfter(Tree tree, String textToInsert) static PythonTextEditinsertAtPosition(int line, int column, String textToInsert) static PythonTextEditinsertBefore(Tree tree, String textToInsert) static PythonTextEditinsertLineAfter(Tree tree, Tree indentReference, String textToInsert) Insert a line with the same offset as the given tree, after the given tree.static PythonTextEditinsertLineBefore(Tree tree, String textToInsert) Insert a line with the same offset as the given tree, before the given tree.static PythonTextEditstatic PythonTextEditremoveRange(int startLine, int startColumn, int endLine, int endColumn) static PythonTextEditremoveStatement(Statement statement) static PythonTextEditremoveUntil(Tree start, Tree until) Remove range including the start token until the beginning of the end tree's first token.static List<PythonTextEdit>renameAllUsages(HasSymbol node, String newName) Returns a list of all replacements for the symbol to new name.static PythonTextEditstatic PythonTextEditreplaceRange(Tree start, Tree end, String replacementText) static List<PythonTextEdit>shiftLeft(StatementList statementList) Shift body statements to be on same level as the parent statement Filter out text edits which apply on the same line which could show up with multiple statements on the same linestatic List<PythonTextEdit>Shift single statement of a statement list by the given offset.
-
Method Details
-
insertLineBefore
Insert a line with the same offset as the given tree, before the given tree. Offset is applied to multiline insertions. -
insertLineAfter
Insert a line with the same offset as the given tree, after the given tree. Offset is applied to multiline insertions and calculated by the reference tree. -
insertBefore
-
insertAfter
-
insertAtPosition
-
replace
-
replaceRange
-
shiftLeft
Shift body statements to be on same level as the parent statement Filter out text edits which apply on the same line which could show up with multiple statements on the same line -
shiftLeft
Shift single statement of a statement list by the given offset. Take care about child statements by collecting all child tokens and shift each line once. -
removeRange
public static PythonTextEdit removeRange(int startLine, int startColumn, int endLine, int endColumn) -
removeUntil
Remove range including the start token until the beginning of the end tree's first token. This is useful to remove and shift multiple statement over multiple lines. -
removeStatement
-
remove
-
renameAllUsages
Returns a list of all replacements for the symbol to new name. If there is no usages empty list is returned.
-