addons; Add get_function_call_name_args

This commit is contained in:
Daniel Marjamäki 2021-07-24 19:34:11 +02:00
parent 40b52169cf
commit e08ee3bac7
1 changed files with 30 additions and 0 deletions

View File

@ -1275,6 +1275,36 @@ def simpleMatch(token, pattern):
token = token.next token = token.next
return True return True
def get_function_call_name_args(token):
"""Get function name and arguments for function call
name, args = get_function_call_name_args(tok)
"""
if token is None:
return None, None
if not token.isName or not token.scope.isExecutable:
return None, None
if not simpleMatch(token.next, '('):
return None, None
if token.function:
nametok = token.function.token
if token in (token.function.token, token.function.tokenDef):
return None, None
name = nametok.str
while nametok.previous and nametok.previous.previous and nametok.previous.str == '::' and nametok.previous.previous.isName:
name = nametok.previous.previous.str + '::' + name
nametok = nametok.previous.previous
scope = token.function.nestedIn
while scope:
if scope.className:
name = scope.className + '::' + name
scope = scope.nestedIn
else:
nametok = token
name = nametok.str
while nametok.previous and nametok.previous.previous and nametok.previous.str == '::' and nametok.previous.previous.isName:
name = nametok.previous.previous.str + '::' + name
nametok = nametok.previous.previous
return name, getArguments(token)
def is_suppressed(location, message, errorId): def is_suppressed(location, message, errorId):
for suppression in current_dumpfile_suppressions: for suppression in current_dumpfile_suppressions: