PCART  v1.4
Automated Repair of Python API Parameter Compatibility Issues
Public Member Functions | List of all members
WithVisitor Class Reference

Get all with nodes from a project source file 项目源码with节点遍历器 More...

Inheritance diagram for WithVisitor:
[legend]
Collaboration diagram for WithVisitor:
[legend]

Public Member Functions

def __init__ (self)
 Initialize the withitem call dictionary 初始化withitem调用字典 More...
 
def get_withitem_call (self)
 Return the withitem call dictionary 返回withitem调用字典 More...
 
def visit_AsyncWith (self, node)
 Visit an AsyncWith node with the same alias resolution rules as With 访问AsyncWith节点,与With保持相同的别名还原规则 More...
 
def visit_With (self, node)
 Visit a With node and record withitem context expressions 访问With节点,记录withitem上下文表达式 More...
 
def visit_withitem (self, node)
 Visit a standalone withitem node (top-level visitor entry) 访问独立的withitem节点 More...
 

Detailed Description

Get all with nodes from a project source file 项目源码with节点遍历器

For a withitem node, extract the call name in the context_expr and its alias name (if any) in the optional_vars 对于withitem节点,提取其中的call节点和别名(如果有)

Definition at line 122 of file extractCall.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)

Initialize the withitem call dictionary 初始化withitem调用字典

同名with别名可能在不同作用域重复出现,因此按别名保存所有候选及其行号范围

Definition at line 127 of file extractCall.py.

Member Function Documentation

◆ get_withitem_call()

def get_withitem_call (   self)

Return the withitem call dictionary 返回withitem调用字典

Returns
dict mapping alias name to list of {callName, lineno, end_lineno} items

Definition at line 133 of file extractCall.py.

◆ visit_AsyncWith()

def visit_AsyncWith (   self,
  node 
)

Visit an AsyncWith node with the same alias resolution rules as With 访问AsyncWith节点,与With保持相同的别名还原规则

Parameters
nodeThe AsyncWith AST node
Returns
None

Definition at line 151 of file extractCall.py.

Here is the call graph for this function:

◆ visit_With()

def visit_With (   self,
  node 
)

Visit a With node and record withitem context expressions 访问With节点,记录withitem上下文表达式

手动遍历body,避免generic_visit再次访问withitem导致重复记录

Parameters
nodeThe With AST node
Returns
None

Definition at line 142 of file extractCall.py.

Here is the call graph for this function:

◆ visit_withitem()

def visit_withitem (   self,
  node 
)

Visit a standalone withitem node (top-level visitor entry) 访问独立的withitem节点

Parameters
nodeThe withitem AST node
Returns
None

Definition at line 168 of file extractCall.py.

Here is the call graph for this function:

The documentation for this class was generated from the following file: