mirror of
https://gitee.com/openharmony/interface_sdk_c
synced 2024-11-23 14:50:20 +00:00
更改diff结果:diff结果是否为api变更列,按统计规则的要求(符合要求的函数和变量)
Signed-off-by: zhangwuf <zhangwu47@huawei.com>
This commit is contained in:
parent
e4f1c0dd95
commit
cadf57f8dd
@ -36,13 +36,9 @@ def get_not_api_kind_list():
|
||||
|
||||
|
||||
def wrap_diff_info(old_info, new_info, diff_info: DiffInfo):
|
||||
not_api_kind_list = get_not_api_kind_list()
|
||||
if old_info is not None:
|
||||
if 'temporary_name' in old_info['name']:
|
||||
old_info['name'] = ''
|
||||
if (not diff_info.is_api_change) and 'kind' in old_info \
|
||||
and (old_info['kind'] not in not_api_kind_list):
|
||||
diff_info.set_is_api_change(True)
|
||||
diff_info.set_api_name(old_info['name'])
|
||||
diff_info.set_api_type(old_info['kind'])
|
||||
diff_info.set_api_line(old_info['location']['location_line'])
|
||||
@ -63,9 +59,6 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo):
|
||||
if new_info is not None:
|
||||
if 'temporary_name' in new_info['name']:
|
||||
new_info['name'] = ''
|
||||
if (not diff_info.is_api_change) and 'kind' in new_info \
|
||||
and (new_info['kind'] not in not_api_kind_list):
|
||||
diff_info.set_is_api_change(True)
|
||||
diff_info.set_api_name(new_info['name'])
|
||||
diff_info.set_api_type(new_info['kind'])
|
||||
diff_info.set_api_line(new_info['location']['location_line'])
|
||||
@ -108,8 +101,6 @@ def get_member_result_diff(old_target, new_target):
|
||||
|
||||
def get_initial_result_obj(diff_type: DiffType, new_node, old_node=None):
|
||||
result_message_obj = DiffInfo(diff_type)
|
||||
if 'kind' in new_node and 'MACRO_DEFINITION' != new_node['kind']:
|
||||
result_message_obj.set_is_api_change(True)
|
||||
|
||||
return result_message_obj
|
||||
|
||||
@ -587,6 +578,12 @@ def collect_change_data_total(data: dict, diff_info_list):
|
||||
change_data_total.append(diff_info_list)
|
||||
|
||||
|
||||
def set_is_api_change_result(result_data, key_extern):
|
||||
for element in result_data:
|
||||
if key_extern:
|
||||
element.set_is_api_change(True)
|
||||
|
||||
|
||||
def judgment_entrance(old, new, data_type=0):
|
||||
"""
|
||||
Args:
|
||||
@ -595,25 +592,35 @@ def judgment_entrance(old, new, data_type=0):
|
||||
data_type(int): 数据处理类型。1-文件新增或删除;0-其他
|
||||
"""
|
||||
diff_info_list = []
|
||||
key_extern = False
|
||||
if old is None and new is None:
|
||||
return diff_info_list
|
||||
if old is None:
|
||||
if 'is_extern' in new and new['is_extern']:
|
||||
key_extern = True
|
||||
diff_type = DiffType.ADD_FILE if data_type == 1 else DiffType.ADD_API
|
||||
diff_info_list.append(wrap_diff_info(old, new, DiffInfo(diff_type)))
|
||||
set_is_api_change_result(diff_info_list, key_extern)
|
||||
if diff_type == DiffType.ADD_API:
|
||||
collect_change_data_total(new, diff_info_list)
|
||||
return diff_info_list
|
||||
if new is None:
|
||||
if 'is_extern' in old and old['is_extern']:
|
||||
key_extern = True
|
||||
diff_type = DiffType.REDUCE_FILE if data_type == 1 else DiffType.REDUCE_API
|
||||
diff_info_list.append(wrap_diff_info(old, new, DiffInfo(diff_type)))
|
||||
if diff_type == DiffType.REDUCE_API:
|
||||
set_is_api_change_result(diff_info_list, key_extern)
|
||||
collect_change_data_total(old, diff_info_list)
|
||||
return diff_info_list
|
||||
kind = new['kind']
|
||||
if 'is_extern' in old and old['is_extern']:
|
||||
key_extern = True
|
||||
diff_info_list.extend(process_comment_str(old, new))
|
||||
if kind in process_data:
|
||||
diff_info_list.extend(process_data[kind](old, new))
|
||||
if diff_info_list:
|
||||
set_is_api_change_result(diff_info_list, key_extern)
|
||||
collect_change_data_total(new, diff_info_list)
|
||||
return diff_info_list
|
||||
|
||||
|
@ -195,16 +195,23 @@ special_node_process = {
|
||||
|
||||
def get_api_unique_id(cursor, loc):
|
||||
parent_of_cursor = cursor.semantic_parent
|
||||
struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value,
|
||||
NodeKind.ENUM_DECL.value]
|
||||
unique_id = ''
|
||||
if parent_of_cursor:
|
||||
unique_name = cursor.spelling
|
||||
if parent_of_cursor.kind == CursorKind.TRANSLATION_UNIT:
|
||||
parent_name_str = ''
|
||||
elif parent_of_cursor.kind.name in struct_union_enum:
|
||||
parent_name_str = parent_of_cursor.type.spelling
|
||||
else:
|
||||
parent_name_str = parent_of_cursor.spelling
|
||||
if cursor.kind.name in struct_union_enum:
|
||||
unique_name = cursor.type.spelling
|
||||
if not parent_name_str:
|
||||
unique_id = '{}#{}'.format(loc["location_path"], cursor.spelling)
|
||||
unique_id = '{}#{}'.format(loc["location_path"], unique_name)
|
||||
else:
|
||||
unique_id = '{}#{}#{}'.format(loc["location_path"], parent_name_str, cursor.spelling)
|
||||
unique_id = '{}#{}#{}'.format(loc["location_path"], parent_name_str, unique_name)
|
||||
return unique_id
|
||||
|
||||
|
||||
@ -318,7 +325,7 @@ def parser_data_assignment(cursor, current_file, gn_path=None, comment=None, key
|
||||
return data
|
||||
|
||||
|
||||
def ast_to_dict(cursor, current_file, last_data, gn_path=None, comment=None, key=0): # 解析数据的整理
|
||||
def ast_to_dict(cursor, current_file, last_data, gn_path, comment=None, key=0): # 解析数据的整理
|
||||
# 通用赋值
|
||||
data = parser_data_assignment(cursor, current_file, gn_path, comment, key)
|
||||
if last_data:
|
||||
@ -474,7 +481,7 @@ def processing_ast_node(child, current_file, data, name, gn_path):
|
||||
data[name].append(child_data)
|
||||
|
||||
|
||||
def preorder_travers_ast(cursor, total, comment, current_file, gn_path=None): # 获取属性
|
||||
def preorder_travers_ast(cursor, total, comment, current_file, gn_path): # 获取属性
|
||||
previous_data = {}
|
||||
ast_dict = ast_to_dict(cursor, current_file, previous_data, gn_path, comment) # 获取节点属性
|
||||
total.append(ast_dict) # 追加到数据统计列表里面
|
||||
@ -524,7 +531,7 @@ def open_file(include_path):
|
||||
return content
|
||||
|
||||
|
||||
def api_entrance(share_lib, include_path, gn_path=None, link_path=None): # 统计入口
|
||||
def api_entrance(share_lib, include_path, gn_path, link_path=None): # 统计入口
|
||||
# clang.cindex需要用到libclang.dll共享库 所以配置共享库
|
||||
if not Config.loaded:
|
||||
Config.set_library_file(share_lib)
|
||||
@ -547,7 +554,7 @@ def api_entrance(share_lib, include_path, gn_path=None, link_path=None): # 统
|
||||
return data_total
|
||||
|
||||
|
||||
def get_include_file(include_file_path, link_path, gn_path=None): # 库路径、.h文件路径、链接头文件路径
|
||||
def get_include_file(include_file_path, link_path, gn_path): # 库路径、.h文件路径、链接头文件路径
|
||||
# libclang.dll库路径
|
||||
libclang_path = StringConstant.LIB_CLG_PATH.value
|
||||
# c头文件的路径
|
||||
|
Loading…
Reference in New Issue
Block a user