def source_code(): if (request.method == 'POST'): content1 = json.loads(request.data) print("Source code") content = content1.split('!')[0] nameApp = content1.split('!')[1] print("nameApp: ", nameApp) if (content == ""): method = "com.helpshift.util.HelpshiftContext.b()" method_name = content method_name = content.split(',')[0] # The BBID in the log d = database.getline(method_name.split('(')[0]) log_bbid = d[0]['BB_ID'] data_structure = [] # filename = "/Users/snehagathani/Desktop/Sem 2/IR/projectcopy2/sourceCode" filename_path, method_found, args = file_path.find_file( method_name, nameApp) l, c = file_path.find_line_no(filename_path, method_name, args, method_found, log_bbid) # bbblock_line_no = file_path.findbbblock(filename_path, line_no) line_no = [] character = [] line_no.append(l) character.append(c) # Figure out the relation between BB_ID and hexcode and then send only that line number underneath so that only that gets highlighted code = file_path.source_code(filename_path) clean_code = [] for i in range(0, len(code)): temp = code[i].split("\n") clean_code.append(temp[0]) clean_code.append("Line_nos") to_send = clean_code + line_no character.insert(0, "Character_nos") to_send = to_send + character to_send.append(method_found) return jsonify(to_send)
def select_in_stack(): if (request.method == 'POST'): content1 = json.loads(request.data) content = content1.split('!')[0] nameApp = content1.split('!')[1] print("SelectInStackNameApp: ", nameApp) nodes, edges = input_json.getvalues('raw_data.json') # Get the thread of the method thread = database.get_thread(content) # Get all the data of this thread with 'Function: 1' for method_selected data = database.get_particular_selected(content, thread) print(data) # data = database.get_particular_selected(content) d = database.getline(content) precomputed_pos, rect_data, maximum_height, maximum_width = precalc.precalc( data) # line_it = None # for j in range(0, len(d)): # for i in range(0, len(rect_data)): # if(rect_data[i]['Method'].split('(')[0] == content): # line_it = i # break line_it = None for j in range(0, len(rect_data)): if (rect_data[j]['Method'].split('(')[0] == content): line_it = j break autoscroll_position_index = -1 if (line_it != None): autoscroll_position_index = line_it for i in range(0, len(precomputed_pos)): precomputed_pos[i].pop(0) to_send1 = [] to_send1.append(precomputed_pos) to_send1.append(rect_data) to_send1.append(maximum_height) to_send1.append(maximum_width) to_send1.append(autoscroll_position_index) if (content == ""): method = "com.helpshift.util.HelpshiftContext.b()" method_name = content method_name = content.split(',')[0] log_bbid = d[0]['BB_ID'] filename_path, method_found, args = file_path.find_file( method_name, nameApp) l, c = file_path.find_line_no(filename_path, method_name, args, method_found, log_bbid) # bbblock_line_no = file_path.findbbblock(filename_path, line_no) line_no = [] character = [] line_no.append(l) character.append(c) # Figure out the relation between BB_ID and hexcode and then send only that line number underneath so that only that gets highlighted code = file_path.source_code(filename_path) clean_code = [] for i in range(0, len(code)): temp = code[i].split("\n") clean_code.append(temp[0]) clean_code.append("Line_nos") to_send2 = clean_code + line_no character.insert(0, "Character_nos") to_send2 = to_send2 + character to_send2.append(method_found) to_send = [] to_send.append(to_send1) to_send.append(to_send2) return jsonify(to_send)