Package org.sonar.python.tree
Class TreeUtils
- java.lang.Object
-
- org.sonar.python.tree.TreeUtils
-
public class TreeUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TreefirstAncestor(Tree tree, Predicate<Tree> predicate)static TreefirstAncestorOfKind(Tree tree, Tree.Kind... kinds)static Stream<Expression>flattenTuples(Expression expression)static ClassSymbolgetClassSymbolFromDef(ClassDef classDef)static FunctionSymbolgetFunctionSymbolFromDef(FunctionDef functionDef)static Optional<Symbol>getSymbolFromTree(Tree tree)static booleanhasDescendant(Tree tree, Predicate<Tree> predicate)static List<Parameter>nonTupleParameters(FunctionDef functionDef)static List<Token>nonWhitespaceTokens(Tree tree)static RegularArgumentnthArgumentOrKeyword(int argPosition, String keyword, List<Argument> arguments)static List<Parameter>positionalParameters(FunctionDef functionDef)static List<Token>tokens(Tree tree)static List<FunctionDef>topLevelFunctionDefs(ClassDef classDef)Collects all top-level function definitions within a class def.
-
-
-
Method Detail
-
firstAncestor
@CheckForNull public static Tree firstAncestor(Tree tree, Predicate<Tree> predicate)
-
firstAncestorOfKind
@CheckForNull public static Tree firstAncestorOfKind(Tree tree, Tree.Kind... kinds)
-
flattenTuples
public static Stream<Expression> flattenTuples(Expression expression)
-
getClassSymbolFromDef
@CheckForNull public static ClassSymbol getClassSymbolFromDef(@Nullable ClassDef classDef)
-
getFunctionSymbolFromDef
@CheckForNull public static FunctionSymbol getFunctionSymbolFromDef(@Nullable FunctionDef functionDef)
-
nonTupleParameters
public static List<Parameter> nonTupleParameters(FunctionDef functionDef)
-
positionalParameters
public static List<Parameter> positionalParameters(FunctionDef functionDef)
-
topLevelFunctionDefs
public static List<FunctionDef> topLevelFunctionDefs(ClassDef classDef)
Collects all top-level function definitions within a class def. It is used to discover methods defined within "strange" constructs, such asclass A: if p: def f(self): ...
-
nthArgumentOrKeyword
@CheckForNull public static RegularArgument nthArgumentOrKeyword(int argPosition, String keyword, List<Argument> arguments)
-
-