From a34de3e520fb24e90a875de042aedc122656087b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ta=C5=9Fkaya?= Date: Sat, 1 Jun 2019 16:34:30 +0300 Subject: [PATCH] Add support for python's assignment expressions --- ctags/parsers/python.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ctags/parsers/python.c b/ctags/parsers/python.c index b84906926d..ffb1db0401 100644 --- a/ctags/parsers/python.c +++ b/ctags/parsers/python.c @@ -561,11 +561,17 @@ static const char *findVariable(const char *line) * Assignment to a tuple 'x, y = 2, 3' not supported. * TODO: ignore duplicate tags from reassignment statements. */ const char *cp, *sp, *eq, *start; + int offset = 2; - cp = strstr(line, "="); - if (!cp) - return NULL; - eq = cp + 1; + cp = strstr(line, ":="); + if (!cp){ + cp = strstr(line, "="); + if (!cp){ + return NULL; + } + --offset; + } + eq = cp + offset; while (*eq) { if (*eq == '=') @@ -586,7 +592,7 @@ static const char *findVariable(const char *line) sp = start; while (sp >= line && isspace ((int) *sp)) --sp; - if ((sp + 1) != line) /* the line isn't a simple variable assignment */ + if ((sp + 1) != line && offset == 1) /* the line isn't a simple variable assignment */ return NULL; /* the line is valid, parse the variable name */ ++start;