From a803b8fd8d04183242264fae5743e922eca66d4e Mon Sep 17 00:00:00 2001 From: Soonho Kong Date: Mon, 15 Sep 2014 15:17:46 -0700 Subject: [PATCH] fix(bin/ltags): handle recursor specially in tags generation fix #197 --- bin/ltags | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/ltags b/bin/ltags index b90e36f9d..add451758 100755 --- a/bin/ltags +++ b/bin/ltags @@ -31,11 +31,17 @@ def parse_arg(argv): args = parser.parse_args(argv) return args -def get_short_name(id): - last_pos_of_dot = id.rfind('.') - if last_pos_of_dot >= 0: - return id[last_pos_of_dot+1:] - return id +def get_short_name(item): + category = item['category'] + declname = item['declname'] + names = declname.split(".") + if category == "d": + kind = item['kind'] + # For instance, for the recursor "nat.rec", this function should return "nat" + if kind == "recursor" and len(names) >= 2: + return names[-2] + # Normally, it returns the last part of hierarchical name + return names[-1] def build_line_to_byteoffset_map(ilean_filename): """Given a .ilean filename, return a mapping from a line number to the @@ -68,7 +74,7 @@ def convert_position_to_etag_style(info): linenum = item['linenum'] col = item['col'] item['offset'] = line_to_byteoffset[linenum] + col - item['prefix'] = contents[linenum][:col] + get_short_name(item['declname']) + item['prefix'] = contents[linenum][:col] + get_short_name(item) def extract_info_from_ilean(ilean_file, decl_dict): info = []