|
@@ -5,6 +5,7 @@ from models.funcnode import FuncNode, get_script, match_data_type, \
|
|
|
from models.sentencenode import SuspectedSentenceNode
|
|
|
from utils import log
|
|
|
from utils.ERRORLIST import error_list
|
|
|
+
|
|
|
logging = log.getlogger()
|
|
|
|
|
|
|
|
@@ -30,7 +31,7 @@ def parse_tree(source, lattices, file_name, tree_node, code_lines, node_list=Non
|
|
|
node_list = []
|
|
|
data_type = lattices["dataType"]
|
|
|
purpose_dict = lattices["purpose"]
|
|
|
- if isinstance(tree_node, ast.FunctionDef):
|
|
|
+ if isinstance(tree_node, ast.FunctionDef) or isinstance(tree_node, ast.AsyncFunctionDef):
|
|
|
func_node = FuncNode(tree_node, file_name, lattices, code_lines)
|
|
|
try:
|
|
|
all_nodes = func_node.get_sentence_nodes()
|
|
@@ -55,7 +56,7 @@ def parse_tree(source, lattices, file_name, tree_node, code_lines, node_list=Non
|
|
|
elif isinstance(tree_node, ast.ClassDef):
|
|
|
class_name = tree_node.name
|
|
|
for node_son in tree_node.body:
|
|
|
- if isinstance(node_son, ast.FunctionDef):
|
|
|
+ if isinstance(node_son, ast.FunctionDef) or isinstance(tree_node, ast.AsyncFunctionDef):
|
|
|
node_list, func_dict = parse_tree(source, lattices, file_name, node_son, code_lines, node_list,
|
|
|
func_dict, class_name)
|
|
|
|
|
@@ -139,7 +140,9 @@ def add_code(lattices, file_name, tree_node, code_lines, node_list):
|
|
|
"""
|
|
|
data_type = lattices["dataType"]
|
|
|
purpose_dict = lattices["purpose"]
|
|
|
- if not isinstance(tree_node, ast.FunctionDef) and not isinstance(tree_node, ast.ClassDef) and not isinstance(
|
|
|
+ if not isinstance(tree_node, ast.FunctionDef) and not isinstance(tree_node,
|
|
|
+ ast.AsyncFunctionDef) and not isinstance(tree_node,
|
|
|
+ ast.ClassDef) and not isinstance(
|
|
|
tree_node, ast.Import) and not isinstance(tree_node, ast.Module):
|
|
|
line_no = tree_node.lineno
|
|
|
script_ori, script = get_script(tree_node, code_lines)
|