Package org.sonar.python.quickfix
Class PythonTextEdit
- java.lang.Object
-
- org.sonar.python.quickfix.PythonTextEdit
-
public class PythonTextEdit extends Object
For internal use only. Can not be used outside SonarPython analyzer.
-
-
Constructor Summary
Constructors Constructor Description PythonTextEdit(String message, int startLine, int startLineOffset, int endLine, int endLineOffset)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intendLine()intendLineOffset()booleanequals(Object o)inthashCode()static 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 PythonTextEditremove(Tree toRemove)static 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 PythonTextEditreplace(Tree toReplace, String replacementText)StringreplacementText()static 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 lineintstartLine()intstartLineOffset()StringtoString()
-
-
-
Constructor Detail
-
PythonTextEdit
public PythonTextEdit(String message, int startLine, int startLineOffset, int endLine, int endLineOffset)
-
-
Method Detail
-
insertLineBefore
public static PythonTextEdit insertLineBefore(Tree tree, String textToInsert)
Insert a line with the same offset as the given tree, before the given tree. Offset is applied to multiline insertions.
-
insertLineAfter
public static PythonTextEdit insertLineAfter(Tree tree, Tree indentReference, String textToInsert)
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
public static PythonTextEdit insertBefore(Tree tree, String textToInsert)
-
insertAfter
public static PythonTextEdit insertAfter(Tree tree, String textToInsert)
-
insertAtPosition
public static PythonTextEdit insertAtPosition(int line, int column, String textToInsert)
-
replace
public static PythonTextEdit replace(Tree toReplace, String replacementText)
-
replaceRange
public static PythonTextEdit replaceRange(Tree start, Tree end, String replacementText)
-
shiftLeft
public 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 line
-
removeRange
public static PythonTextEdit removeRange(int startLine, int startColumn, int endLine, int endColumn)
-
removeUntil
public static PythonTextEdit removeUntil(Tree start, Tree until)
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
public static PythonTextEdit removeStatement(Statement statement)
-
remove
public static PythonTextEdit remove(Tree toRemove)
-
renameAllUsages
public static List<PythonTextEdit> renameAllUsages(HasSymbol node, String newName)
Returns a list of all replacements for the symbol to new name. If there is no usages empty list is returned.
-
replacementText
public String replacementText()
-
startLine
public int startLine()
-
startLineOffset
public int startLineOffset()
-
endLine
public int endLine()
-
endLineOffset
public int endLineOffset()
-
-