Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions Extract/extractCall.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## @package extractCall
# Provide some class definitions for extracting lib API calls
#
# More details (TODO)

import ast
#访问import节点和importFrom节点

## Import and ImportFrom node visitor
## 访问import节点和importFrom节点
#
# Inherits from ast.NodeVisitor
class Import(ast.NodeVisitor):
def __init__(self):
self._md_name={}
Expand All @@ -25,8 +34,10 @@ def visit_ImportFrom(self, node):
self._md_name[it["asname"]]=node.module+'.'+it["name"]



#从根节点开始,直接找根节点的孩子,Call存在于Expr和Assign节点中
## Extract all call type nodes from a project source file
#
# Use DFS algorithm to traverse the call type node from the root node. Each API call is stored in a tuple (API name, parameters, call statement, line no)
# 从根节点开始,直接找根节点的孩子,Call存在于Expr和Assign节点中。每个API调用存储为四元组(API名称,参数,调用语句,行号)
class GetFuncCall:
def __init__(self):
self._func_call=[] #list中每个元素都是一个tuple
Expand Down Expand Up @@ -59,9 +70,11 @@ def dfsVisit(self,node):
# print(node.lineno,'<-->',callState)
return


#找到所有的Assign节点
#对于Assign节点,只需要关注等号左右两边的名字
## Get all assign nodes from a project source file
## 找到所有的Assign节点
#
# For an assign node, extract the values before (the variable name) and after (the value expression) the assignment operator
# 对于Assign节点,只需要关注等号左右两边的名字
class AssignVisitor(ast.NodeVisitor):
def __init__(self):
self._targetCall={}
Expand Down
9 changes: 9 additions & 0 deletions Path/getPath.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## @package getPath
# Provide the class definition for obtaining source files and directories from a project/lib
#
# More details (TODO)

import os
import copy

## The Path class definition
#
# provide functionalities for obtaining the paths of source files and directories
class Path:
def __init__(self,mode):
#mode='D' 表示只获取根目录下的一级子目录
Expand Down