Class Import::ImportExpr

An artificial expression representing an import

Direct supertypes

Indirect supertypes

Predicates

bottomModuleName

Gets the name by which the lowest level module or package is imported. NOTE: This is the name that used to import the module, which may not be the name of the module.

getASubExpression

Gets an immediate (non-nested) sub-expression of this expression

getAnImportedModuleName

Gets the names of the modules that may be imported by this import. For example this predicate would return ‘x’ and ‘x.y’ for import x.y

getImportedModuleName

Gets the full name of the module resulting from evaluating this import. NOTE: This is the name that used to import the module, which may not be the name of the module.

getLevel

The language specifies level as -1 if relative imports are to be tried first, 0 for absolute imports, and level > 0 for explicit relative imports.

hasSideEffects

Whether this expression may have a side effect (as determined purely from its syntax)

isRelative

Whether this import is relative, that is not absolute. See https://www.python.org/dev/peps/pep-0328/

topModuleName

Gets the name of topmost module or package being imported

Inherited predicates

contains

Whether this contains inner syntactically

from AstNode
containsInScope

Whether this contains inner syntactically and inner has the same scope as this

from AstNode
defines

Whether this expression defines variable v If doing dataflow, then consider using SsaVariable.getDefinition() for more precision.

from Expr
getAChildNode

Gets a child node of this node in the AST. This predicate exists to aid exploration of the AST and other experiments. The child-parent relation may not be meaningful. For a more meaningful relation in terms of dependency use Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or Scope.getAStmt().

from Expr
getAFlowNode

Gets a flow node corresponding directly to this node. NOTE: For some statements and other purely syntactic elements, there may not be a ControlFlowNode

from AstNode
getEnclosingModule

Gets the module in which this expression occurs

from Expr
getLocationfrom Expr
getName

Gets the name of this import expression.

from ImportExpr_
getParentfrom Expr_
getParentNode

Gets the parent node of this node in the AST. This predicate exists to aid exploration of the AST and other experiments. The child-parent relation may not be meaningful. For a more meaningful relation in terms of dependency use Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or Scope.getAStmt() applied to the parent.

from AstNode
getScope

Gets the scope of this expression

from Expr
isArtificial

Whether this syntactic element is artificial, that is it is generated by the compiler and is not present in the source

from AstNode
isConstant

Whether this expression is a constant

from Expr
isParenthesised

Use isParenthesized instead.

from Expr
isParenthesized

Whether the parenthesized property of this expression is true.

from Expr
isTop

Whether the top level property of this import expression is true.

from ImportExpr_
refersTo

Gets what this expression might “refer-to”. Performs a combination of localized (intra-procedural) points-to analysis and global module-level analysis. This points-to analysis favours precision over recall. It is highly precise, but may not provide information for a significant number of flow-nodes. If the class is unimportant then use refersTo(value) or refersTo(value, origin) instead. NOTE: For complex dataflow, involving multiple stages of points-to analysis, it may be more precise to use ControlFlowNode.refersTo(...) instead.

from Expr
refersTo

Gets what this expression might “refer-to” in the given context.

from Expr
refersTo

Whether this expression might “refer-to” to value which is from origin Unlike this.refersTo(value, _, origin), this predicate includes results where the class cannot be inferred.

from Expr
refersTo

Equivalent to this.refersTo(value, _)

from Expr
strValue

Use StrConst.getText() instead

from Expr
toStringfrom ImportExpr_